diff --git a/.aspell.yml b/.aspell.yml new file mode 100644 index 00000000..7dd95fe3 --- /dev/null +++ b/.aspell.yml @@ -0,0 +1,54 @@ +mode: commit +min_length: 3 +allowed: + - aspell + - repo + - yaml + - config + - Github + - Gitlab + - env + - failsafe + - golang + - mkdir + - WORKDIR + - apk + - ENTRYPOINT + - ubuntu + - golangci + - sudo + - releaser + - backend + - backends + - frontend + - frontends + - tcp + - cpu + - crd + - linter + - linters + - govulncheck + - dataplaneapi + - quic + - userlist + - cve + - ssl + - crl + - crt + - ocsp + - logrus + - backport + - dns + - newcert + - libdns + - txt + - testname + - uid + - DPAPI + - PROPAGDELAY + - PROPAGTIMEOUT + - cfg + - resolv + - conf + - resolvers + - desec diff --git a/.github/workflows/.goreleaser.yml b/.github/workflows/.goreleaser.yml new file mode 100644 index 00000000..8ecb10e2 --- /dev/null +++ b/.github/workflows/.goreleaser.yml @@ -0,0 +1,27 @@ +name: goreleaser +on: + push: + tags: + - '*' +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + # we have to fetch all history to be able to generate the release note. c.f. https://goreleaser.com/ci/actions/. + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: '1.25' + check-latest: true + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..085c9e87 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: go build +on: + pull_request: + branches: + - master +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + id: go + - name: Get dependencies + run: | + go get -v -t -d ./... + - name: Build + run: | + go build -v . diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..7068f888 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,13 @@ +name: HAProxy check commit message +on: + pull_request: + branches: + - master +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: commit-policy + uses: docker://ghcr.io/haproxytech/commit-check:5.0.4 + env: + API_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 00000000..6219b362 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,24 @@ +name: e2e +on: + pull_request: + branches: + - master +jobs: + build: + name: HAProxy + strategy: + matrix: + haproxy_version: ["3.2"] + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + - name: Downloading required packages + run: sudo apt-get install bats + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - run: make e2e + env: + HAPROXY_VERSION: ${{ matrix.haproxy_version }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..73a19e3f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,49 @@ +name: golangci-lint +on: + pull_request: + branches: + - master +jobs: + gofumpt: + name: gofumpt + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: tidy + run: make gofumpt + - name: changes + run: test -z "$(git diff 2> /dev/null)" || exit "Go code not formatted, issue \`make gofumpt\` and commit the result" + golangci-lint: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Lint + run: | + make lint diff --git a/.github/workflows/manual_goreleaser.yml b/.github/workflows/manual_goreleaser.yml new file mode 100644 index 00000000..f1cb4b94 --- /dev/null +++ b/.github/workflows/manual_goreleaser.yml @@ -0,0 +1,28 @@ +name: manual goreleaser +on: + workflow_dispatch: +jobs: + manual_goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # we have to fetch all history to be able to generate the release note. c.f. https://goreleaser.com/ci/actions/. + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + check-latest: true + - name: Reposition to latest tag + run: | + git checkout $(git describe --tags --abbrev=0) + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b5961e50..e742912c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,11 @@ build/ +e2e/logs/ vendor/ -cmd/dataplaneapi/dataplaneapi +cmd/dataplaneapi/* +.vscode/ +.test/ +bin/golangci-lint +bin/check-commit + +# ignore Goland ide config +.idea diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..8269a062 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,200 @@ +stages: + - bots + - lint + - checks + - build + - test + - e2e +variables: + DOCKER_HOST: tcp://docker:2375 + DOCKER_BASE_IMAGE: $CI_REGISTRY_GO/haproxy-debian + BATS_VERSION: v1.10.0 + GO_VERSION: "1.25" + DOCKER_VERSION: "29.1" + +pipelines-check: + stage: bots + needs: [] + image: + name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION + entrypoint: [""] + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + tags: + - go + script: + - go run cmd/gitlab-mr-pipelines/main.go +mr-backport-question: + stage: bots + needs: [] + image: + name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION + entrypoint: [ "" ] + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH + tags: + - go + script: + - go run cmd/gitlab-mr-checker/main.go +diff: + stage: lint + image: + name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION + entrypoint: [""] + services: + - name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind + alias: docker + tags: + - go + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + script: + #- apk add make curl bash jq + - SWAGGER_VERSION=$(curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $2}') + - wget -q "https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_VERSION}/swagger_linux_amd64" -O /usr/local/bin/swagger && chmod +x /usr/local/bin/swagger + - make generate-native + - test -z "$(git diff 2> /dev/null)" || exit "Specification is not generated, issue \`make generate\` and commit the result" + - test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Specification generation created untracked files, cannot proceed" +diff-spec-parent: + stage: lint + image: + name: $CI_REGISTRY_GO/golang:$GO_VERSION + entrypoint: [""] + tags: + - go + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + script: + - make generate-parent-aliases + - test -z "$(git diff 2> /dev/null)" || exit "Parent aliases are not generated, issue \`make generate-parent-aliases\` and commit the result" + - test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Parent aliases created untracked files, cannot proceed" +golangci-lint: + stage: lint + artifacts: + paths: + - build + image: + name: $CI_REGISTRY_GO/golang:$GO_VERSION + entrypoint: [""] + tags: + - go + script: + - make lint + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' +gofumpt: + stage: lint + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + image: + name: $CI_REGISTRY_GO/golang:$GO_VERSION + entrypoint: [""] + tags: + - go + script: + - make gofumpt + - test -z "$(git diff 2> /dev/null)" || exit 'Go code not formatted, issue \`make gofumpt\` and commit the result' +commit-policy: + stage: lint + image: + name: $CI_REGISTRY_GO/commit-check:5.4.2 + entrypoint: [""] + tags: + - go + script: + - /check + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + +build: + stage: build + artifacts: + paths: + - build + image: + name: $CI_REGISTRY_GO/golang:$GO_VERSION + entrypoint: [""] + tags: + - go + script: + - go env + - go mod verify + - make build + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + +test: + stage: test + image: + name: $CI_REGISTRY_GO/golang:$GO_VERSION + entrypoint: [ "" ] + tags: + - go + before_script: + - go env -w "GONOSUMDB=gitlab.int.haproxy.com/*" "GOPROXY=http://goproxy.int.haproxy.com" + script: + - go test ./... + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: "$CI_PROJECT_NAMESPACE == 'haproxy-controller' && $CI_PIPELINE_SOURCE == 'push'" + +.e2e: + stage: e2e + artifacts: + paths: + - build + - e2e/logs/* + when: on_failure + image: + name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION + entrypoint: [""] + services: + - name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-dind + alias: docker + variables: + LOCAL_IP_ADDRESS: docker + tags: + - go + before_script: + - apk add git bash curl jq git + - git clone https://github.com/bats-core/bats-core.git && cd bats-core && git checkout $BATS_VERSION && ./install.sh /usr/local && cd .. + - docker login -u='$app' -p $CI_REGISTRY_TOKEN $CI_REGISTRY_GO + script: + - bash -x ./e2e/run.bash + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + +govulncheck: + stage: checks + needs: [] + image: + name: $CI_REGISTRY_GO/docker:$DOCKER_VERSION-go$GO_VERSION + entrypoint: [ "" ] + rules: + - if: $CI_PIPELINE_SOURCE == 'schedule' && $SCHEDULE_TYPE == 'daily' + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + changes: + - go.mod + - if: "$CI_PROJECT_NAMESPACE == 'haproxy-controller' && $CI_PIPELINE_SOURCE == 'push'" + changes: + - go.mod + tags: + - go + script: + - go install golang.org/x/vuln/cmd/govulncheck@latest + - govulncheck -version + - go mod tidy + - go run cmd/govulncheck-report/main.go + +HAProxy_3.4: + extends: .e2e + parallel: + matrix: + - TESTPART: ["1/4", "2/4", "3/4", "4/4"] + HAPROXY_VERSION: "3.4" diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..2eebe346 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,104 @@ +version: "2" +linters: + default: all + disable: + - containedctx + - contextcheck + - depguard + - dupl + - err113 + - errcheck + - errorlint + - exhaustive + - exhaustruct + - forbidigo + - forcetypeassert + - funcorder + - funlen + - gochecknoglobals + - gocognit + - goconst + - gocritic + - gocyclo + - godoclint + - godot + - godox + - ireturn + - lll + - mnd + - nakedret + - nestif + - nlreturn + - noctx + - noinlineerr + - nonamedreturns + - paralleltest + - prealloc + - recvcheck + - rowserrcheck + - sqlclosecheck + - tagalign + - tagliatelle + - testpackage + - unparam + - unused + - varnamelen + - wastedassign + - wrapcheck + - wsl + - wsl_v5 + settings: + cyclop: + max-complexity: 42 + dupl: + threshold: 200 + goconst: + min-len: 2 + min-occurrences: 2 + gocyclo: + min-complexity: 42 + revive: + rules: + - name: var-naming + severity: warning + disabled: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - staticcheck + text: duplicate struct tag + - linters: + - gosec + text: G[501] + - linters: + - gosec + text: G[404] + - path: (.+)\.go$ + text: 'undeclared name: `shellquote`' + - path: (.+)\.go$ + text: github.com/kballard/go-shellquote" imported but not used + - path: (.+)\.go$ + text: github.com/haproxytech/client-native/v6/config-parser/types" imported but not used + paths: + - test + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - test + - third_party$ + - builtin$ + - examples$ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..1f3b1ce5 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,137 @@ +--- +version: 2 +before: + hooks: + - go mod download + - go mod tidy +builds: + - + id: my-build + main: ./cmd/dataplaneapi + binary: dataplaneapi + ldflags: + - -s -w -X main.GitRepo={{.GitURL}} -X main.GitTag={{.Tag}} -X main.GitCommit={{.ShortCommit}} -X main.GitDirty= -X main.BuildTime={{.Date}} + env: + - CGO_ENABLED=0 + goos: + - linux + - freebsd + - darwin + goarch: + - "386" + - amd64 + - arm + - arm64 + - ppc64le + - s390x +changelog: + sort: asc + use: git +archives: + - + id: my-archive + builds: + - my-build + name_template: >- + {{.ProjectName}}_{{.Version}}_{{.Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + files: + - LICENSE + - README.md + - src: dist/CHANGELOG.md + dst: "" + strip_parent: true + - src: assets/packages/dataplaneapi.yml.dist + dst: "" + strip_parent: true +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +release: + github: + owner: haproxytech + name: dataplaneapi + header: | + ## Release Notes + HAProxy Data Plane API {{.Tag}} {{.ShortCommit}} + + Build from: git@github.com:haproxytech/dataplaneapi.git + Build date: {{.Date}} + draft: true + name_template: "HAProxy Data Plane API v{{.Version}}" +nfpms: + - + id: my-package + package_name: dataplaneapi + builds: + - my-build + file_name_template: >- + {{.ProjectName}}_{{.Version}}_{{.Os }}_ + {{- if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + vendor: HAProxy Technologies + homepage: https://github.com/haproxytech/dataplaneapi + maintainer: Marko Juraga + description: HAProxy Data Plane API - API endpoints for managing HAProxy + license: Apache 2.0 + formats: + - apk + - deb + - rpm + dependencies: + - haproxy + bindir: /usr/sbin + section: net + priority: optional + contents: + - dst: /etc/dataplaneapi + type: dir + file_info: + owner: root + group: root + mode: 0750 + - dst: /var/lib/dataplaneapi + type: dir + file_info: + owner: root + group: root + mode: 0750 + - src: assets/packages/dataplaneapi.yml.dist + dst: /etc/dataplaneapi/dataplaneapi.yml + type: "config|noreplace" + file_info: + owner: root + group: root + mode: 0640 + - src: assets/packages/dataplaneapi.service + dst: /etc/systemd/system/dataplaneapi.service + type: config + file_info: + owner: root + group: root + mode: 0640 + - src: assets/packages/default + dst: /etc/default/dataplaneapi + type: config + file_info: + owner: root + group: root + mode: 0640 + - src: assets/packages/logrotate + dst: /etc/logrotate.d/dataplaneapi + type: config + file_info: + owner: root + group: root + mode: 0640 + scripts: + postinstall: "assets/packages/post-install.sh" + preremove: "assets/packages/pre-uninstall.sh" + postremove: "assets/packages/post-uninstall.sh" + deb: + lintian_overrides: + - statically-linked-binary + - changelog-file-missing-in-native-package diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca7ed1f0..230f815f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,45 +6,54 @@ This document is a short guide for contributing to this project. ## API Specification - Development guide -Data Plane API is generated using [go-swagger](https://github.com/go-swagger/go-swagger) from the swagger spec found [here](https://github.com/haproxytech/dataplaneapi-specification/blob/master/build/haproxy_spec.yaml) using the following command. - -``` -./swagger generate server -f haproxy_spec.yaml \ - -A "Data Plane" \ - -t $GOPATH/src/github.com/haproxytech/ \ - --existing-models github.com/haproxytech/models \ - --exclude-main \ - --skip-models \ - -s dataplaneapi \ - --tags=Discovery \ - --tags=Information \ - --tags=Specification \ - --tags=Transactions \ - --tags=Sites \ - --tags=Stats \ - --tags=Global \ - --tags=Frontend \ - --tags=Backend \ - --tags=Bind \ - --tags=Server \ - --tags=Configuration \ - --tags=HTTPRequestRule \ - --tags=HTTPResponseRule \ - --tags=BackendSwitchingRule \ - --tags=ServerSwitchingRule \ - --tags=TCPResponseRule \ - --tags=TCPRequestRule \ - --tags=Filter \ - --tags=StickRule \ - --tags=LogTarget \ - --tags=Reloads \ - --tags=ACL \ - --tags=Defaults \ - -r ~/dataplaneapi-specification/copyright.txt +### Dataplane API generation +Data Plane API is generated using [go-swagger](https://github.com/go-swagger/go-swagger) from the swagger spec found [here](https://github.com/haproxytech/client-native/blob/master/specification/build/haproxy_spec.yaml) using the following command. + +``` +make generate +``` +or if you prefer to run it directly (not in docker) +``` +make generate-native ``` +`make generate-native` must also be used if you are using local client-native on disk (you have `replace github.com/haproxytech/client-native/v6 => ../client-native` in go.mod file) + This command generates some of the files in this project, which are marked with // Code generated by go-swagger; DO NOT EDIT. -comments at the top of the files. These are not to be edited, as they are overwritten when specification is changed and the above-mentioned command is run. If you want to change those files, please change the specification where neccessary and then generate them again. +comments at the top of the files. These are not to be edited, as they are overwritten when specification is changed and the above-mentioned command is run. If you want to change those files, please change the specification where necessary and then generate them again. + +### handlers/parents_xxx_generated.go generation + +Some handler files `handler/parents_xxx_generated.go` are automatically generated. For this use the following command: +``` +make generate-parent-aliases +``` + +Pre-requisites: for this command to run you need to update the following files: +- [generate/parents/main.go](./generate/parents/main.go) + - Update this section with the list of children for which you generate a `handler/parents_xxx_generated.go` +``` + children := []string{ + cnparents.ServerChildType, + cnparents.HTTPAfterResponseRuleChildType, + cnparents.HTTPCheckChildType, + cnparents.HTTPErrorRuleChildType, + cnparents.HTTPRequestRuleChildType, + cnparents.HTTPResponseRuleChildType, + cnparents.TCPCheckChildType, + cnparents.TCPRequestRuleChildType, + cnparents.TCPResponseRuleChildType, + cnparents.ACLChildType, + cnparents.BindChildType, + cnparents.FilterChildType, + cnparents.LogTargetChildType, + } +``` + +- [generate/parents/operations.go](./generate/parents/operations.go) + - Contains the list of operations to generate an alias for in the `handler/parents_xxx_generated.go`. + - Note that the list of parents for wich an alias is generated is defined in: *client-native* (refer to client-native `specification/README.md`) + ## Commit Messages and General Style diff --git a/Makefile b/Makefile index 6b345498..97f152d6 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,73 @@ -DATAPLANEAPI_PATH=${PWD} -GIT_REPO=$(shell git config --get remote.origin.url) +DATAPLANEAPI_PATH?=$(shell pwd) +GIT_REPO?=$(shell git config --get remote.origin.url) GIT_HEAD_COMMIT=$(shell git rev-parse --short HEAD) GIT_LAST_TAG=$(shell git describe --abbrev=0 --tags) GIT_TAG_COMMIT=$(shell git rev-parse --short ${GIT_LAST_TAG}) GIT_MODIFIED1=$(shell git diff "${GIT_HEAD_COMMIT}" "${GIT_TAG_COMMIT}" --quiet || echo .dev) GIT_MODIFIED2=$(shell git diff --quiet || echo .dirty) GIT_MODIFIED=${GIT_MODIFIED1}${GIT_MODIFIED2} -BUILD_DATE=$(shell date '+%Y-%m-%dT%H:%M:%S') +SWAGGER_VERSION=${shell curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $$2}'} +BUILD_DATE=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ') +CGO_ENABLED?=0 +GOLANGCI_LINT_VERSION=2.8.0 +CHECK_COMMIT=5.4.0 all: update clean build update: - go get -v + go mod tidy + +.PHONY: lint +lint: + cd bin;GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} sh lint-check.sh + bin/golangci-lint run --timeout 10m --color always --max-issues-per-linter 0 --max-same-issues 0 + +.PHONY: gofumpt +gofumpt: + go install mvdan.cc/gofumpt@latest + gofumpt -l -w . clean: rm -rf ${DATAPLANEAPI_PATH}/build +.PHONY: build build: - mkdir ${DATAPLANEAPI_PATH}/build - CGO_ENABLED=0 go build -gcflags "-N -l" -ldflags "-X main.GitRepo=${GIT_REPO} -X main.GitTag=${GIT_LAST_TAG} -X main.GitCommit=${GIT_HEAD_COMMIT} -X main.GitDirty=${GIT_MODIFIED} -X main.BuildTime=${BUILD_DATE}" -o ${DATAPLANEAPI_PATH}/build/dataplaneapi ${DATAPLANEAPI_PATH}/cmd/dataplaneapi/ + mkdir -p ${DATAPLANEAPI_PATH}/build + CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "-X \"main.GitRepo=${GIT_REPO}\" -X main.GitTag=${GIT_LAST_TAG} -X main.GitCommit=${GIT_HEAD_COMMIT} -X main.GitDirty=${GIT_MODIFIED} -X main.BuildTime=${BUILD_DATE}" -o ${DATAPLANEAPI_PATH}/build/dataplaneapi ${DATAPLANEAPI_PATH}/cmd/dataplaneapi/ + +.PHONY: e2e +e2e: build + TESTNAME="$(TESTNAME)" TESTNUMBER=$(TESTNUMBER) TESTDESCRIPTION="$(TESTDESCRIPTION)" SKIP_CLEANUP=$(SKIP_CLEANUP) PREWIPE=$(PREWIPE) HAPROXY_VERSION=$(HAPROXY_VERSION) ./e2e/run.bash + +.PHONY: generate-parent-aliases_no_formatting +generate-parent-aliases_no_formatting: + rm -f handlers/parent_*_generated.go + go run generate/parents/*.go + +.PHONY: generate-parent-aliases +generate-parent-aliases: generate-parent-aliases_no_formatting gofumpt + + +.PHONY: generate +generate: + cd generate/swagger;docker build \ + --build-arg SWAGGER_VERSION=${SWAGGER_VERSION} \ + --build-arg UID=$(shell id -u) \ + --build-arg GID=$(shell id -g) \ + -t dataplaneapi-swagger-gen . + docker run --rm -v "$(shell pwd)":/data dataplaneapi-swagger-gen + generate/post_swagger.sh + +.PHONY: generate-native +generate-native: + generate/swagger/script.sh + generate/post_swagger.sh + +.PHONY: test +test: + go test ./... +.PHONY: check-commit +check-commit: + cd bin;CHECK_COMMIT=${CHECK_COMMIT} sh check-commit.sh + bin/check-commit diff --git a/README.md b/README.md index 10fe7eaa..de4c9b35 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,14 @@ ## HAProxy Data Plane API +[![Contributors](https://img.shields.io/github/contributors/haproxytech/dataplaneapi?color=purple)](CONTRIBUTING.md) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) + **Data Plane API** is a sidecar process that runs next to HAProxy and provides API endpoints for managing HAProxy. It requires HAProxy version 1.9.0 or higher. ## Building the Data Plane API -In order to build the Data Plane API you need go 1.12 installed on your system with go modules support enabled, and execute the following steps: +In order to build the Data Plane API you need Go installed on your system with go modules support enabled, and execute the following steps: 1\. Clone dataplaneapi repository @@ -20,7 +23,7 @@ git clone https://github.com/haproxytech/dataplaneapi.git make build ``` -3\. You can find the built binary in /build directory. +3\. You can find the built binary in /build directory. TEST ## Running the Data Plane API Basic usage: @@ -32,54 +35,83 @@ Usage: API for editing and managing haproxy instances Application Options: - --scheme= the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec - --cleanup-timeout= grace period for which to wait before killing idle connections (default: 10s) - --graceful-timeout= grace period for which to wait before shutting down the server (default: 15s) - --max-header-size= controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size - of the request body. (default: 1MiB) - --socket-path= the unix socket to listen on (default: /var/run/data-plane.sock) - --host= the IP to listen on (default: localhost) [$HOST] - --port= the port to listen on for insecure connections, defaults to a random value [$PORT] - --listen-limit= limit the number of outstanding requests - --keep-alive= sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download) (default: 3m) - --read-timeout= maximum duration before timing out read of the request (default: 30s) - --write-timeout= maximum duration before timing out write of the response (default: 60s) - --tls-host= the IP to listen on for tls, when not specified it's the same as --host [$TLS_HOST] - --tls-port= the port to listen on for secure connections, defaults to a random value [$TLS_PORT] - --tls-certificate= the certificate to use for secure connections [$TLS_CERTIFICATE] - --tls-key= the private key to use for secure connections [$TLS_PRIVATE_KEY] - --tls-ca= the certificate authority file to be used with mutual tls auth [$TLS_CA_CERTIFICATE] - --tls-listen-limit= limit the number of outstanding requests - --tls-keep-alive= sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download) - --tls-read-timeout= maximum duration before timing out read of the request - --tls-write-timeout= maximum duration before timing out write of the response + --scheme= the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec + --cleanup-timeout= grace period for which to wait before killing idle connections (default: 10s) + --graceful-timeout= grace period for which to wait before shutting down the server (default: 15s) + --max-header-size= controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request + body. (default: 1MiB) + --socket-path= the unix socket to listen on (default: /var/run/data-plane.sock) + --host= the IP to listen on (default: localhost) [$HOST] + --port= the port to listen on for insecure connections, defaults to a random value [$PORT] + --listen-limit= limit the number of outstanding requests + --keep-alive= sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download) (default: 3m) + --read-timeout= maximum duration before timing out read of the request (default: 30s) + --write-timeout= maximum duration before timing out write of the response (default: 60s) + --tls-host= the IP to listen on for tls, when not specified it's the same as --host [$TLS_HOST] + --tls-port= the port to listen on for secure connections, defaults to a random value [$TLS_PORT] + --tls-certificate= the certificate to use for secure connections [$TLS_CERTIFICATE] + --tls-key= the private key to use for secure connections [$TLS_PRIVATE_KEY] + --tls-ca= the certificate authority file to be used with mutual tls auth [$TLS_CA_CERTIFICATE] + --tls-listen-limit= limit the number of outstanding requests + --tls-keep-alive= sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download) + --tls-read-timeout= maximum duration before timing out read of the request + --tls-write-timeout= maximum duration before timing out write of the response + --uid user id value to set on start + --gid group id value to set on start HAProxy options: - -c, --config-file= Path to the haproxy configuration file (default: /etc/haproxy/haproxy.cfg) - -u, --userlist= Userlist in HAProxy configuration to use for API Basic Authentication (default: controller) - -b, --haproxy-bin= Path to the haproxy binary file (default: haproxy) - -d, --reload-delay= Minimum delay between two reloads (in s) (default: 5) - -r, --reload-cmd= Reload command - -s, --restart-cmd= Restart command - --reload-retention= Reload retention in days, every older reload id will be deleted (default: 1) - -t, --transaction-dir= Path to the transaction directory (default: /tmp/haproxy) - -n, --backups-number= Number of backup configuration files you want to keep, stored in the config dir with version number suffix (default: 0) - -m, --master-runtime= Path to the master Runtime API socket - -i, --show-system-info Show system info on info endpoint - + -c, --config-file= Path to the haproxy configuration file (default: /etc/haproxy/haproxy.cfg) + -u, --userlist= Userlist in HAProxy configuration to use for API Basic Authentication (default: controller) + -b, --haproxy-bin= Path to the haproxy binary file (default: haproxy) + -d, --reload-delay= Minimum delay between two reloads (in s) (default: 5) + -r, --reload-cmd= Reload command + -s, --restart-cmd= Restart command + --reload-retention= Reload retention in days, every older reload id will be deleted (default: 1) + -t, --transaction-dir= Path to the transaction directory (default: /tmp/haproxy) + -n, --backups-number= Number of backup configuration files you want to keep, stored in the config dir with version number suffix (default: 0) + --backups-dir= Path to directory in which to place backup files + -m, --master-runtime= Path to the master Runtime API socket + -i, --show-system-info Show system info on info endpoint + -f= Path to the dataplane configuration file (default: /etc/haproxy/dataplaneapi.yaml) + --userlist-file= Path to the dataplaneapi userlist file. By default userlist is read from HAProxy conf. When specified userlist would be read from this file + --fid= Path to file that will dataplaneapi use to write its id (not a pid) that was given to him after joining a cluster + -p, --maps-dir= Path to directory of map files managed by dataplane (default: /etc/haproxy/maps) + --ssl-certs-dir= Path to SSL certificates directory (default: /etc/haproxy/ssl) + --update-map-files Flag used for syncing map files with runtime maps values + --update-map-files-period= Elapsed time in seconds between two maps syncing operations (default: 10) + --cluster-tls-dir= Path where cluster tls certificates will be stored. Defaults to same directory as dataplane configuration file + --spoe-dir= Path to SPOE directory. (default: /etc/haproxy/spoe) + --spoe-transaction-dir= Path to the SPOE transaction directory (default: /tmp/spoe-haproxy) + --master-worker-mode Flag to enable helpers when running within HAProxy + --max-open-transactions= Limit for active transaction in pending state (default: 20) + --validate-cmd= Executes a custom command to perform the HAProxy configuration check + --disable-inotify Disables inotify watcher watcher for the configuration file + --pid-file= Path to file that will dataplaneapi use to write its pid + --debug-socket-path= Unix socket path for the debugging command socket Logging options: - --log-to=[stdout|file] Log target, can be stdout or file (default: stdout) - --log-file= Location of the log file (default: /var/log/dataplaneapi/dataplaneapi.log) - --log-level=[trace|debug|info|warning|error] Logging level (default: warning) - --log-format=[text|JSON] Logging format (default: text) + --log-to=[stdout|file|syslog] Log target, can be stdout, file, or syslog (default: stdout) + --log-file= Location of the log file (default: /var/log/dataplaneapi/dataplaneapi.log) + --log-level=[trace|debug|info|warning|error] Logging level (default: warning) + --log-format=[text|JSON] Logging format (default: text) + --apache-common-log-format= Apache Common Log Format to format the access log entries (default: %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i" %{us}T) + +Syslog options: + --syslog-address= Syslog address (with port declaration in case of TCP type) where logs should be forwarded: accepting socket path in case of unix or unixgram + --syslog-protocol=[tcp|tcp4|tcp6|unix|unixgram] Syslog server protocol (default: tcp) + --syslog-tag= String to tag the syslog messages (default: dataplaneapi) + --syslog-level= Define the required syslog messages level, allowed values: debug|info|notice|warning|error|critical|alert|emergency (default: debug) + --syslog-facility= Define the Syslog facility number, allowed values: kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|authpriv|ftp|local0|local1|local2|local3|local4|local5|local6|local7 + (default: local0) Show version: - -v, --version Version and build information + -v, --version Version and build information Help Options: - -h, --help Show this help message + -h, --help Show this help message ``` +Beside those options, everything can be defined in side of configuration file. See [configuration file](configuration/README.md) + ## Example You can test it by simply running: @@ -88,17 +120,28 @@ You can test it by simply running: ./dataplaneapi --port 5555 -b /usr/sbin/haproxy -c /etc/haproxy/haproxy.cfg -d 5 -r "service haproxy reload" -s "service haproxy restart" -u dataplaneapi -t /tmp/haproxy ``` +Dataplaneapi will require write permissions to the haproxy configuration file and the directories containing additional managed files (maps, ssl, spoe). The default locations can be overriden with command-line options. Test it out with curl, note that you need user/pass combination setup in HAProxy userlist in haproxy configuration (in above example: /etc/haproxy/haproxy.cfg, userlist controller): ``` -curl -u : -H "Content-Type: application/json" "http://127.0.0.1:5555/v1/" +curl -u : -H "Content-Type: application/json" "http://127.0.0.1:5555/v2/" ``` If you are using secure passwords, supported algorithms are: md5, sha-256 and sha-512. ## Using the Data Plane API -For more docs how to use the Data Plane API check our [documentation](https://www.haproxy.com/documentation/hapee/1-9r1/configuration/dataplaneapi/) +For more docs how to use the Data Plane API check our [documentation](https://www.haproxy.com/documentation/hapee/latest/api/data-plane-api/) + +Alternatively, dataplaneapi serves its own interactive documentation relevant for the current build on the `/v2/docs` uri. Just point your browser to the host/port dataplane was started with (i.e. `http://localhost:5555/v2/docs`) + +## Service Discovery + +Check the documentation in the [README](./discovery/README.md). + +## Command socket for debugging purpose + +Check the documentation in the [README](./runtime/README.md). ## Contributing diff --git a/acme/constructor.go b/acme/constructor.go new file mode 100644 index 00000000..097f449a --- /dev/null +++ b/acme/constructor.go @@ -0,0 +1,95 @@ +// Code generated from 'constructor.tmpl'; DO NOT EDIT. + +package acme + +import ( + "fmt" + + "github.com/haproxytech/dataplaneapi/acme/exec" + jsoniter "github.com/json-iterator/go" + "github.com/libdns/azure" + "github.com/libdns/cloudflare" + "github.com/libdns/cloudns" + "github.com/libdns/desec" + "github.com/libdns/digitalocean" + "github.com/libdns/gandi" + "github.com/libdns/godaddy" + "github.com/libdns/googleclouddns" + "github.com/libdns/hetzner" + "github.com/libdns/infomaniak" + "github.com/libdns/inwx" + "github.com/libdns/ionos" + "github.com/libdns/linode" + "github.com/libdns/namecheap" + "github.com/libdns/netcup" + "github.com/libdns/ovh" + "github.com/libdns/porkbun" + "github.com/libdns/rfc2136" + "github.com/libdns/route53" + "github.com/libdns/scaleway" + "github.com/libdns/vultr/v2" +) + +func NewDNSProvider(name string, params map[string]any) (DNSProvider, error) { + var prov DNSProvider + + switch name { + case "azure": + prov = &azure.Provider{} + case "cloudflare": + prov = &cloudflare.Provider{} + case "cloudns": + prov = &cloudns.Provider{} + case "desec": + prov = &desec.Provider{} + case "digitalocean": + prov = &digitalocean.Provider{} + case "exec": + prov = &exec.Provider{} + case "gandi": + prov = &gandi.Provider{} + case "godaddy": + prov = &godaddy.Provider{} + case "googleclouddns": + prov = &googleclouddns.Provider{} + case "hetzner": + prov = &hetzner.Provider{} + case "infomaniak": + prov = &infomaniak.Provider{} + case "inwx": + prov = &inwx.Provider{} + case "ionos": + prov = &ionos.Provider{} + case "linode": + prov = &linode.Provider{} + case "namecheap": + prov = &namecheap.Provider{} + case "netcup": + prov = &netcup.Provider{} + case "ovh": + prov = &ovh.Provider{} + case "porkbun": + prov = &porkbun.Provider{} + case "rfc2136": + prov = &rfc2136.Provider{} + case "route53": + prov = &route53.Provider{} + case "scaleway": + prov = &scaleway.Provider{} + case "vultr": + prov = &vultr.Provider{} + default: + return nil, fmt.Errorf("invalid DNS provider name: '%s'", name) + } + + jsoni := jsoniter.ConfigCompatibleWithStandardLibrary + js, err := jsoni.Marshal(params) + if err != nil { + return nil, fmt.Errorf("failed to marshal params for DNS provider %s: %w", name, err) + } + if err = jsoni.Unmarshal(js, prov); err != nil { + return nil, fmt.Errorf("invalid params for DNS provider %s: %w", name, err) + } + + return prov, nil +} diff --git a/acme/constructor.tmpl b/acme/constructor.tmpl new file mode 100644 index 00000000..b8a5ba76 --- /dev/null +++ b/acme/constructor.tmpl @@ -0,0 +1,36 @@ +// Code generated from 'constructor.tmpl'; DO NOT EDIT. + +package acme + +import ( + "fmt" + + jsoniter "github.com/json-iterator/go" +{{- range $mod := .}} + "{{$mod}}" +{{- end}} +) + +func NewDNSProvider(name string, params map[string]any) (DNSProvider, error) { + var prov DNSProvider + + switch name { +{{- range $mod := .}} + case "{{basename $mod}}": + prov = &{{basename $mod}}.Provider{} +{{- end}} + default: + return nil, fmt.Errorf("invalid DNS provider name: '%s'", name) + } + + jsoni := jsoniter.ConfigCompatibleWithStandardLibrary + js, err := jsoni.Marshal(params) + if err != nil { + return nil, fmt.Errorf("failed to marshal params for DNS provider %s: %w", name, err) + } + if err = jsoni.Unmarshal(js, prov); err != nil { + return nil, fmt.Errorf("invalid params for DNS provider %s: %w", name, err) + } + + return prov, nil +} diff --git a/acme/dns01-providers.txt b/acme/dns01-providers.txt new file mode 100644 index 00000000..1e0f077c --- /dev/null +++ b/acme/dns01-providers.txt @@ -0,0 +1,22 @@ +github.com/libdns/azure +github.com/libdns/cloudflare +github.com/libdns/cloudns +github.com/libdns/desec +github.com/libdns/digitalocean +github.com/haproxytech/dataplaneapi/acme/exec +github.com/libdns/gandi +github.com/libdns/godaddy +github.com/libdns/googleclouddns +github.com/libdns/hetzner +github.com/libdns/infomaniak +github.com/libdns/inwx +github.com/libdns/ionos +github.com/libdns/linode +github.com/libdns/namecheap +github.com/libdns/netcup +github.com/libdns/ovh +github.com/libdns/porkbun +github.com/libdns/rfc2136 +github.com/libdns/route53 +github.com/libdns/scaleway +github.com/libdns/vultr/v2 diff --git a/acme/dns01.go b/acme/dns01.go new file mode 100644 index 00000000..faa62f4b --- /dev/null +++ b/acme/dns01.go @@ -0,0 +1,208 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +//go:generate go run gen_constructor.go -i dns01-providers.txt -t constructor.tmpl -o constructor.go + +import ( + "context" + "fmt" + "strings" + "time" + + "github.com/libdns/libdns" + "github.com/miekg/dns" +) + +const ( + // TTL of the temporary DNS record used for DNS-01 validation. + DefaultTTL = 30 * time.Second + // Typical negative response TTL defined in the SOA. + defaultDNSPropagationTimeout = 300 * time.Second +) + +// DNSProvider defines the operations required for dns-01 challenges. +type DNSProvider interface { + libdns.RecordAppender + libdns.RecordDeleter +} + +// A DNS01Solver uses a DNSProvider to actually solve the challenge. +type DNS01Solver struct { + provider DNSProvider + TTL time.Duration + + // How long to wait before starting propagation checks. + // Default: 0 (no wait). + PropagationDelay time.Duration + + // Maximum time to wait for temporary DNS record to appear. + // Set to -1 to disable propagation checks. + // Default: 2 minutes. + PropagationTimeout time.Duration + + // Preferred DNS resolver(s) to use when doing DNS lookups. + Resolvers []string +} + +func NewDNS01Solver(name string, params map[string]any, ttl ...time.Duration) (*DNS01Solver, error) { + prov, err := NewDNSProvider(name, params) + if err != nil { + return nil, err + } + + recordTTL := DefaultTTL + if len(ttl) > 0 { + recordTTL = ttl[0] + } + + return &DNS01Solver{provider: prov, TTL: recordTTL}, nil +} + +// Present creates the DNS TXT record for the given ACME challenge. +func (s *DNS01Solver) Present(ctx context.Context, domain, zone, keyAuth string) error { + rec := makeRecord(domain, keyAuth, s.TTL) + + if zone == "" { + zone = GuessZone(domain) + } else { + zone = rooted(zone) + } + + results, err := s.provider.AppendRecords(ctx, zone, []libdns.Record{rec}) + if err != nil { + return fmt.Errorf("adding temporary record for zone %q: %w", zone, err) + } + if len(results) != 1 { + return fmt.Errorf("expected one record, got %d: %v", len(results), results) + } + + return nil +} + +// Wait blocks until the TXT record created in Present() appears in +// authoritative lookups, i.e. until it has propagated, or until +// timeout, whichever is first. +func (s *DNS01Solver) Wait(ctx context.Context, domain, zone, keyAuth string) error { + // if configured to, pause before doing propagation checks + // (even if they are disabled, the wait might be desirable on its own) + if s.PropagationDelay > 0 { + select { + case <-time.After(s.PropagationDelay): + case <-ctx.Done(): + return ctx.Err() + } + } + + // skip propagation checks if configured to do so + if s.PropagationTimeout == -1 { + return nil + } + + // timings + timeout := s.PropagationTimeout + if timeout == 0 { + timeout = defaultDNSPropagationTimeout + } + const interval = 5 * time.Second + + // how we'll do the checks + checkAuthoritativeServers := len(s.Resolvers) == 0 + resolvers := RecursiveNameservers(s.Resolvers) + + absName := strings.Trim(domain, ".") + + var err error + start := time.Now() + for time.Since(start) < timeout { + select { + case <-time.After(interval): + case <-ctx.Done(): + return ctx.Err() + } + + var ready bool + ready, err = checkDNSPropagation(ctx, absName, dns.TypeTXT, keyAuth, checkAuthoritativeServers, resolvers) + if err != nil { + return fmt.Errorf("checking DNS propagation of %q (resolvers=%v): %w", absName, resolvers, err) + } + if ready { + return nil + } + } + + return fmt.Errorf("DNS propagation timed out. Last error: %v", err) +} + +// CleanUp deletes the DNS TXT record created in Present(). +func (s *DNS01Solver) CleanUp(ctx context.Context, domain, zone, keyAuth string) error { + rr := makeRecord(domain, keyAuth, s.TTL) + + if zone == "" { + zone = GuessZone(domain) + } else { + zone = rooted(zone) + } + + _, err := s.provider.DeleteRecords(ctx, zone, []libdns.Record{rr}) + if err != nil { + return fmt.Errorf("deleting temporary record for name %q in zone %q: %w", zone, rr, err) + } + + return nil +} + +// Assemble a TXT Record suited for DNS-01 challenges. +func makeRecord(fqdn, keyAuth string, ttl time.Duration) libdns.RR { + return libdns.RR{ + Type: "TXT", + Name: "_acme-challenge." + trimWildcard(fqdn), + Data: keyAuth, + TTL: ttl, + } +} + +// Guess the root zone for a domain when we cannot use a better method. +func GuessZone(fqdn string) string { + fqdn = trimWildcard(fqdn) + parts := make([]string, 0, 8) + strings.SplitSeq(fqdn, ".")(func(part string) bool { + if part != "" { + parts = append(parts, part) + } + return true + }) + + n := len(parts) + if n < 3 { + return rooted(fqdn) + } + return rooted(strings.Join(parts[n-2:], ".")) +} + +// Remove the wildcard from a domain so it can be used in a record name. +func trimWildcard(fqdn string) string { + fqdn = strings.TrimSpace(fqdn) + return strings.TrimPrefix(fqdn, "*.") +} + +// Ensures a domain name has its final dot (the root zone). +func rooted(domain string) string { + if !strings.HasSuffix(domain, ".") { + domain += "." + } + return domain +} diff --git a/acme/dns01_test.go b/acme/dns01_test.go new file mode 100644 index 00000000..f2d874b7 --- /dev/null +++ b/acme/dns01_test.go @@ -0,0 +1,103 @@ +package acme + +import ( + "reflect" + "testing" + + "github.com/libdns/cloudflare" + "github.com/libdns/googleclouddns" + "github.com/libdns/ovh" +) + +func TestNewDNSProvider(t *testing.T) { + tests := []struct { + name string + args map[string]any + want DNSProvider + wantErr bool + }{ + { + name: "cloudflare", + args: map[string]any{ + "api_token": "foo", + "zone_token": "bar", + }, + want: &cloudflare.Provider{APIToken: "foo", ZoneToken: "bar"}, + wantErr: false, + }, + { + name: "googleclouddns", + args: map[string]any{ + "gcp_project": "Project X", + "gcp_application_default": `{"gcp_account_id":"j9h8hl094756h98990h"}`, + }, + want: &googleclouddns.Provider{Project: "Project X", ServiceAccountJSON: `{"gcp_account_id":"j9h8hl094756h98990h"}`}, + wantErr: false, + }, + { + name: "ovh", + args: map[string]any{ + "endpoint": "/lol", + "application_key": "foobar", + }, + want: &ovh.Provider{Endpoint: "/lol", ApplicationKey: "foobar"}, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := NewDNSProvider(tt.name, tt.args) + if (err != nil) != tt.wantErr { + t.Errorf("NewDNSProvider() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("NewDNSProvider() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_guessZone(t *testing.T) { + tests := []struct { + fqdn string + want string + }{ + { + fqdn: "", + want: ".", + }, + { + fqdn: "haproxy.org", + want: "haproxy.org.", + }, + { + fqdn: "foo.haproxy.org", + want: "haproxy.org.", + }, + { + fqdn: "*.haproxy.org.", + want: "haproxy.org.", + }, + { + fqdn: "*.foo.haproxy.org", + want: "haproxy.org.", + }, + { + fqdn: "localhost", + want: "localhost.", + }, + { + fqdn: "very.long.sub.domain.name.haproxy.lol", + want: "haproxy.lol.", + }, + } + for _, tt := range tests { + t.Run(tt.fqdn, func(t *testing.T) { + got := GuessZone(tt.fqdn) + if got != tt.want { + t.Errorf("guessZone() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/acme/exec/doc.go b/acme/exec/doc.go new file mode 100644 index 00000000..3dfc415e --- /dev/null +++ b/acme/exec/doc.go @@ -0,0 +1,17 @@ +// Package exec provides a libdns provider which calls an external command. +// +// When called, the configured Command will be launched with the following +// environment variables: +// +// ACTION describes which action is the program expected to perform. Possible +// values are: get, append, set, delete. +// +// ZONE contains the DNS zone where the record is located. +// +// REC_NAME, REC_TTL, REC_TYPE, REC_DATA: respectively the record name, TTL in +// seconds, type (usually TXT), and value. +// +// When ran with the `get` action, the REC_* variables are not provided. Instead, +// the program is expected to scan the given zone and print the results as a JSON +// document on stdout. It must be parsable as a `[]libdns.RR`. +package exec diff --git a/acme/exec/provider.go b/acme/exec/provider.go new file mode 100644 index 00000000..604a26fa --- /dev/null +++ b/acme/exec/provider.go @@ -0,0 +1,112 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package exec + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + osexec "os/exec" + "strconv" + "strings" + "time" + + "github.com/libdns/libdns" +) + +type Provider struct { + Command string `json:"command"` + Environment []string `json:"environment,omitempty"` +} + +func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error) { + cmd := osexec.CommandContext(ctx, p.Command) // #nosec G204 + p.populateEnv(cmd, "get", zone, nil) + out, err := cmd.Output() + if err != nil { + return nil, err + } + + var result []libdns.RR + err = json.Unmarshal(out, &result) + if err != nil || len(result) == 0 { + return nil, err + } + + records := make([]libdns.Record, 0, len(result)) + for _, rr := range result { + record, err := rr.Parse() + if err != nil { + return nil, err + } + records = append(records, record) + } + + return records, nil +} + +func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { + return p.doRecords(ctx, "append", zone, records) +} + +func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { + return p.doRecords(ctx, "set", zone, records) +} + +func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error) { + return p.doRecords(ctx, "delete", zone, records) +} + +func (p *Provider) doRecords(ctx context.Context, action, zone string, records []libdns.Record) ([]libdns.Record, error) { + for _, record := range records { + rr := record.RR() + cmd := osexec.CommandContext(ctx, p.Command) // #nosec G204 + p.populateEnv(cmd, action, zone, &rr) + var stderr bytes.Buffer + cmd.Stderr = &stderr + if err := cmd.Run(); err != nil { + if _, ok := err.(*osexec.ExitError); ok { + if msg := strings.TrimSpace(stderr.String()); len(msg) > 0 { + return nil, fmt.Errorf("%v (stderr: %s)", err, msg) + } + } + return nil, err + } + } + return records, nil +} + +func (p *Provider) populateEnv(cmd *osexec.Cmd, action, zone string, rr *libdns.RR) { + env := cmd.Environ() + if len(p.Environment) > 0 { + env = append(env, p.Environment...) + } + env = append(env, "ACTION="+action, "ZONE="+zone) + if rr != nil { + env = append(env, rr2env(rr)...) + } + cmd.Env = env +} + +func rr2env(rr *libdns.RR) []string { + return []string{ + "REC_NAME=" + rr.Name, + "REC_TTL=" + strconv.Itoa(int(rr.TTL/time.Second)), + "REC_TYPE=" + rr.Type, + "REC_DATA=" + rr.Data, + } +} diff --git a/acme/gen_constructor.go b/acme/gen_constructor.go new file mode 100644 index 00000000..7a25ef30 --- /dev/null +++ b/acme/gen_constructor.go @@ -0,0 +1,86 @@ +//go:build ignore + +package main + +import ( + "bytes" + "flag" + "fmt" + "io" + "os" + "path" + "regexp" + "strings" + "text/template" +) + +var ( + modListFile = flag.String("i", "", "input file with the list of DNS provider modules") + templateFile = flag.String("t", "", "template file") + outputFile = flag.String("o", "", "output filename") +) + +func main() { + var err error + flag.Parse() + + in := os.Stdin + if *modListFile != "" { + in, err = os.Open(*modListFile) + chk(err) + } + + out := os.Stdout + if *outputFile != "" { + out, err = os.OpenFile(*outputFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644) + chk(err) + } + + funcs := template.FuncMap{ + "basename": modname, + } + + tmpl, err := template.New(path.Base(*templateFile)).Funcs(funcs).ParseFiles(*templateFile) + chk(err) + + // Read the list of modules, 1 per line. + modules := make([]string, 0, 32) + lines, err := io.ReadAll(in) + chk(err) + bytes.SplitSeq(lines, []byte{'\n'})(func(line []byte) bool { + line = bytes.Trim(line, " \"\n\t\r") + if len(line) > 0 && line[0] != '/' && line[0] != '#' { + modules = append(modules, string(line)) + } + return true + }) + + chk(tmpl.Execute(out, modules)) +} + +func chk(err error) { + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} + +// Like basename but for Go repository names. +func modname(s string) string { + slash := strings.LastIndexByte(s, '/') + // ignore "/v2" + match, err := regexp.MatchString("^/v[1-9]+$", s[slash:]) + chk(err) + if match { + s = s[:slash] + slash = strings.LastIndexByte(s, '/') + } + s = s[slash+1:] + if dash := strings.IndexByte(s, '-'); dash != -1 { + s = s[dash+1:] + } + if end := strings.IndexByte(s, '.'); end != -1 { + s = s[:end] + } + return s +} diff --git a/acme/propagation.go b/acme/propagation.go new file mode 100644 index 00000000..7501f5d5 --- /dev/null +++ b/acme/propagation.go @@ -0,0 +1,324 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// This file contains code adapted from certmagic by Matt Holt. +// https://github.com/caddyserver/certmagic +// +// It has been modified. + +package acme + +import ( + "context" + "errors" + "fmt" + "net" + "strings" + "time" + + "github.com/miekg/dns" +) + +var dnsTimeout = 10 * time.Second + +// FindZoneByFQDN determines the zone apex for the given fully-qualified +// domain name (FQDN) by recursing up the domain labels until the nameserver +// returns a SOA record in the answer section. +func FindZoneByFQDN(ctx context.Context, fqdn string, nameservers []string) (string, error) { + if !strings.HasSuffix(fqdn, ".") { + fqdn += "." + } + + if err := ctx.Err(); err != nil { + return "", err + } + + soa, err := fetchSoaByFqdn(ctx, fqdn, nameservers) + if err != nil { + return "", err + } + + return soa.Hdr.Name, nil +} + +func fetchSoaByFqdn(ctx context.Context, fqdn string, nameservers []string) (*dns.SOA, error) { + var err error + var in *dns.Msg + + labelIndexes := dns.Split(fqdn) + for _, index := range labelIndexes { + if err := ctx.Err(); err != nil { + return nil, err + } + + domain := fqdn[index:] + + in, err = dnsQuery(ctx, domain, dns.TypeSOA, nameservers, true) + if err != nil { + continue + } + if in == nil { + continue + } + + switch in.Rcode { + case dns.RcodeSuccess: + // Check if we got a SOA RR in the answer section + if len(in.Answer) == 0 { + continue + } + + // CNAME records cannot/should not exist at the root of a zone. + // So we skip a domain when a CNAME is found. + if dnsMsgContainsCNAME(in) { + continue + } + + for _, ans := range in.Answer { + if soa, ok := ans.(*dns.SOA); ok { + return soa, nil + } + } + case dns.RcodeNameError: + // NXDOMAIN + default: + // Any response code other than NOERROR and NXDOMAIN is treated as error + return nil, fmt.Errorf("unexpected response code '%s' for %s", dns.RcodeToString[in.Rcode], domain) + } + } + + return nil, fmt.Errorf("could not find the start of authority for %s%s", fqdn, formatDNSError(in, err)) +} + +func formatDNSError(msg *dns.Msg, err error) string { + var parts []string + if msg != nil { + parts = append(parts, dns.RcodeToString[msg.Rcode]) + } + if err != nil { + parts = append(parts, err.Error()) + } + if len(parts) > 0 { + return ": " + strings.Join(parts, " ") + } + return "" +} + +// checkDNSPropagation checks if the expected record has been propagated to all authoritative nameservers. +func checkDNSPropagation(ctx context.Context, fqdn string, recType uint16, expectedValue string, checkAuthoritativeServers bool, resolvers []string) (bool, error) { + if !strings.HasSuffix(fqdn, ".") { + fqdn += "." + } + + // Initial attempt to resolve at the recursive NS - but do not actually + // dereference (follow) a CNAME record if we are targeting a CNAME record + // itself + if recType != dns.TypeCNAME { + r, err := dnsQuery(ctx, fqdn, recType, resolvers, true) + if err != nil { + return false, fmt.Errorf("CNAME dns query: %v", err) + } + if r.Rcode == dns.RcodeSuccess { + fqdn = updateDomainWithCName(r, fqdn) + } + } + + if checkAuthoritativeServers { + authoritativeServers, err := lookupNameservers(ctx, fqdn, resolvers) + if err != nil { + return false, fmt.Errorf("looking up authoritative nameservers: %v", err) + } + populateNameserverPorts(authoritativeServers) + resolvers = authoritativeServers + } + + return checkAuthoritativeNss(ctx, fqdn, recType, expectedValue, resolvers) +} + +// checkAuthoritativeNss queries each of the given nameservers for the expected record. +func checkAuthoritativeNss(ctx context.Context, fqdn string, recType uint16, expectedValue string, nameservers []string) (bool, error) { + for _, ns := range nameservers { + r, err := dnsQuery(ctx, fqdn, recType, []string{ns}, true) + if err != nil { + return false, fmt.Errorf("querying authoritative nameservers: %v", err) + } + + if r.Rcode != dns.RcodeSuccess { + if r.Rcode == dns.RcodeNameError || r.Rcode == dns.RcodeServerFailure { + // if Present() succeeded, then it must show up eventually, or else + // something is really broken in the DNS provider or their API; + // no need for error here, simply have the caller try again + return false, nil + } + return false, fmt.Errorf("NS %s returned %s for %s", ns, dns.RcodeToString[r.Rcode], fqdn) + } + + for _, rr := range r.Answer { + switch recType { + case dns.TypeTXT: + if txt, ok := rr.(*dns.TXT); ok { + record := strings.Join(txt.Txt, "") + if record == expectedValue { + return true, nil + } + } + case dns.TypeCNAME: + if cname, ok := rr.(*dns.CNAME); ok { + // TODO: whether a DNS provider assumes a trailing dot or not varies, and we may have to standardize this in libdns packages + if strings.TrimSuffix(cname.Target, ".") == strings.TrimSuffix(expectedValue, ".") { + return true, nil + } + } + default: + return false, fmt.Errorf("unsupported record type: %d", recType) + } + } + } + + return false, nil +} + +// lookupNameservers returns the authoritative nameservers for the given fqdn. +func lookupNameservers(ctx context.Context, fqdn string, resolvers []string) ([]string, error) { + var authoritativeNss []string + + zone, err := FindZoneByFQDN(ctx, fqdn, resolvers) + if err != nil { + return nil, fmt.Errorf("could not determine the zone for '%s': %w", fqdn, err) + } + + r, err := dnsQuery(ctx, zone, dns.TypeNS, resolvers, true) + if err != nil { + return nil, fmt.Errorf("querying NS resolver for zone '%s' recursively: %v", zone, err) + } + + for _, rr := range r.Answer { + if ns, ok := rr.(*dns.NS); ok { + authoritativeNss = append(authoritativeNss, strings.ToLower(ns.Ns)) + } + } + + if len(authoritativeNss) > 0 { + return authoritativeNss, nil + } + return nil, errors.New("could not determine authoritative nameservers") +} + +// Update FQDN with CNAME if any +func updateDomainWithCName(r *dns.Msg, fqdn string) string { + for _, rr := range r.Answer { + if cn, ok := rr.(*dns.CNAME); ok { + if cn.Hdr.Name == fqdn { + return cn.Target + } + } + } + return fqdn +} + +// dnsMsgContainsCNAME checks for a CNAME answer in msg +func dnsMsgContainsCNAME(msg *dns.Msg) bool { + for _, ans := range msg.Answer { + if _, ok := ans.(*dns.CNAME); ok { + return true + } + } + return false +} + +func dnsQuery(ctx context.Context, fqdn string, rtype uint16, nameservers []string, recursive bool) (*dns.Msg, error) { + m := createDNSMsg(fqdn, rtype, recursive) + var in *dns.Msg + var err error + for _, ns := range nameservers { + in, err = sendDNSQuery(ctx, m, ns) + if err == nil && len(in.Answer) > 0 { + break + } + } + return in, err +} + +func createDNSMsg(fqdn string, rtype uint16, recursive bool) *dns.Msg { + m := new(dns.Msg) + m.SetQuestion(fqdn, rtype) + + // See: https://caddy.community/t/hard-time-getting-a-response-on-a-dns-01-challenge/15721/16 + m.SetEdns0(1232, false) + if !recursive { + m.RecursionDesired = false + } + return m +} + +func sendDNSQuery(ctx context.Context, m *dns.Msg, ns string) (*dns.Msg, error) { + udp := &dns.Client{Net: "udp", Timeout: dnsTimeout} + in, _, err := udp.ExchangeContext(ctx, m, ns) + // two kinds of errors we can handle by retrying with TCP: + // truncation and timeout; see https://github.com/caddyserver/caddy/issues/3639 + truncated := in != nil && in.Truncated + timeoutErr := err != nil && strings.Contains(err.Error(), "timeout") + if truncated || timeoutErr { + tcp := &dns.Client{Net: "tcp", Timeout: dnsTimeout} + in, _, err = tcp.ExchangeContext(ctx, m, ns) + } + return in, err +} + +// RecursiveNameservers are used to pre-check DNS propagation. It +// picks user-configured nameservers (custom) OR the defaults +// obtained from resolv.conf and defaultNameservers if none is +// configured and ensures that all server addresses have a port value. +func RecursiveNameservers(custom []string) []string { + var servers []string + if len(custom) == 0 { + servers = systemOrDefaultNameservers(defaultResolvConf, defaultNameservers) + } else { + servers = make([]string, len(custom)) + copy(servers, custom) + } + populateNameserverPorts(servers) + return servers +} + +// systemOrDefaultNameservers attempts to get system nameservers from the +// resolv.conf file given by path before falling back to hard-coded defaults. +func systemOrDefaultNameservers(path string, defaults []string) []string { + config, err := dns.ClientConfigFromFile(path) + if err != nil || len(config.Servers) == 0 { + return defaults + } + return config.Servers +} + +// populateNameserverPorts ensures that all nameservers have a port number. +// If not, the default DNS server port of 53 will be appended. +func populateNameserverPorts(servers []string) { + for i := range servers { + _, port, _ := net.SplitHostPort(servers[i]) + if port == "" { + servers[i] = net.JoinHostPort(servers[i], "53") + } + } +} + +var defaultNameservers = []string{ + "8.8.8.8:53", + "8.8.4.4:53", + "1.1.1.1:53", + "1.0.0.1:53", +} + +const defaultResolvConf = "/etc/resolv.conf" diff --git a/adapters/adapters.go b/adapters/adapters.go index 7c9dc0b5..9c4bc137 100644 --- a/adapters/adapters.go +++ b/adapters/adapters.go @@ -19,64 +19,22 @@ import ( "fmt" "net/http" "runtime" + "strconv" "strings" - "time" - "github.com/docker/go-units" - - "github.com/haproxytech/models" - - "github.com/sirupsen/logrus" + clientnative "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/log" ) // Adapter is just a wrapper over http handler function type Adapter func(http.Handler) http.Handler -type statusResponseWriter struct { - http.ResponseWriter - status int - length int -} - -func (srw *statusResponseWriter) WriteHeader(s int) { - srw.status = s - srw.ResponseWriter.WriteHeader(s) -} - -func (srw *statusResponseWriter) Write(b []byte) (int, error) { - if srw.status == 0 { - // The status will be StatusOK if WriteHeader has not been called yet - srw.status = 200 - srw.ResponseWriter.WriteHeader(srw.Status()) - } - size, err := srw.ResponseWriter.Write(b) - srw.length = size - return size, err -} - -func (srw *statusResponseWriter) Header() http.Header { - return srw.ResponseWriter.Header() -} - -func (srw *statusResponseWriter) Status() int { - return srw.status -} - -func (srw *statusResponseWriter) Length() int { - return srw.length -} - -func newStatusResponseWriter(rw http.ResponseWriter) *statusResponseWriter { - nsrw := &statusResponseWriter{ - ResponseWriter: rw, - } - return nsrw -} - type frame struct { File string - Line int Name string + Line int } type stack []frame @@ -120,16 +78,16 @@ func stripPackage(n string) string { } // RecoverMiddleware used for recovering from panic, logs the panic to given logger and returns 500 -func RecoverMiddleware(logger *logrus.Logger) func(h http.Handler) http.Handler { +func RecoverMiddleware(logger *log.Logger) func(h http.Handler) http.Handler { return func(h http.Handler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { frames := callers() - entry := logrus.NewEntry(logger) - entry = entry.WithField("stack_trace", frames.String()) - entry.Error(fmt.Sprintf("Panic %v", err)) + fields := make(map[string]any) + fields["stack_trace"] = frames.String() + logger.WithFieldsf(fields, log.ErrorLevel, "Panic %v", err) w.WriteHeader(http.StatusInternalServerError) @@ -141,9 +99,9 @@ func RecoverMiddleware(logger *logrus.Logger) func(h http.Handler) http.Handler } errMsg, _ := e.MarshalJSON() - ct := r.Header.Get(http.CanonicalHeaderKey("Content-Type")) + ct := r.Header.Get("Content-Type") if strings.HasPrefix(ct, "application/json") { - w.Header().Set(http.CanonicalHeaderKey("Content-Type"), "application/json") + w.Header().Set("Content-Type", "application/json") } w.Write(errMsg) } @@ -154,40 +112,72 @@ func RecoverMiddleware(logger *logrus.Logger) func(h http.Handler) http.Handler } } -// LoggingMiddleware logs before and after the response to given logger -func LoggingMiddleware(logger *logrus.Logger) Adapter { +func ApacheLogMiddleware(logger *log.ACLLogger) Adapter { return func(h http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - start := time.Now() - logBefore(logger, r) - res := newStatusResponseWriter(w) - defer logAfter(logger, res, start) - h.ServeHTTP(res, r) - }) + apacheLogWritter := logger.Writer() + return logger.ApacheLog.Wrap(h, apacheLogWritter) } } -func logBefore(logger *logrus.Logger, req *http.Request) { - e := logrus.NewEntry(logger) - if reqID := req.Header.Get("X-Request-Id"); reqID != "" { - e = e.WithField("request_id", reqID) - } - e = e.WithField("request", req.RequestURI) - e = e.WithField("method", req.Method) - remote := req.RemoteAddr - if realIP := req.Header.Get("X-Real-IP"); realIP != "" { - remote = realIP +type serverWriter struct { + w http.ResponseWriter + client configuration.Configuration + transactionID string + wroteHeader bool +} + +func (s serverWriter) WriteHeader(code int) { + if !s.wroteHeader { + version, err := fetchConfgVersion(s.client, s.transactionID) + if err == nil { + s.w.Header().Set("Configuration-Version", version) + } + s.wroteHeader = true //nolint:staticcheck } - e = e.WithField("remote", remote) + s.w.WriteHeader(code) +} + +func (s serverWriter) Write(b []byte) (int, error) { + return s.w.Write(b) +} - e.Info("started handling request") +func (s serverWriter) Header() http.Header { + return s.w.Header() } -func logAfter(logger *logrus.Logger, res *statusResponseWriter, start time.Time) { - latency := time.Since(start) - e := logrus.NewEntry(logger) - e = e.WithField("status", res.Status()) - e = e.WithField("length", units.HumanSize(float64(res.Length()))) - e = e.WithField("took", latency) - e.Info("completed handling request") +func ConfigVersionMiddleware(client clientnative.HAProxyClient) Adapter { + return func(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + qs := r.URL.Query() + tID := qs.Get("transaction_id") + configuration, err := client.Configuration() + if err != nil { + http.Error(w, err.Error(), http.StatusNotImplemented) + } + sw := serverWriter{ + w: w, + client: configuration, + transactionID: tID, + wroteHeader: false, + } + h.ServeHTTP(sw, r) + }) + } +} + +func fetchConfgVersion(client configuration.Configuration, transactionID string) (string, error) { + var v int64 + var err error + if transactionID == "" { + v, err = client.GetConfigurationVersion("") + } else { + tr, _ := client.GetTransaction(transactionID) + if tr != nil && tr.Status == models.TransactionStatusInProgress { + v, err = client.GetConfigurationVersion(tr.ID) + } + } + if err == nil { + return strconv.FormatInt(v, 10), nil + } + return "", err } diff --git a/assets/packages/dataplaneapi.service b/assets/packages/dataplaneapi.service new file mode 100644 index 00000000..a20c78ef --- /dev/null +++ b/assets/packages/dataplaneapi.service @@ -0,0 +1,15 @@ +[Unit] +Description=HAProxy Data Plane API +After=syslog.target network-online.target + +[Service] +Environment="PIDFILE=/run/dataplaneapi.pid" +EnvironmentFile=/etc/default/dataplaneapi +ExecStart=/usr/sbin/dataplaneapi $SYSD_OPTIONS +ExecReload=/bin/kill -s SIGUSR1 $MAINPID +Type=simple +PIDFile= +GuessMainPID=1 + +[Install] +WantedBy=multi-user.target diff --git a/assets/packages/dataplaneapi.yml.dist b/assets/packages/dataplaneapi.yml.dist new file mode 100644 index 00000000..7a399ac6 --- /dev/null +++ b/assets/packages/dataplaneapi.yml.dist @@ -0,0 +1,28 @@ +dataplaneapi: + host: 0.0.0.0 + port: 5555 + userlist: + userlist: dataplaneapi + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + spoe_dir: /etc/haproxy/spoe + transaction: + transaction_dir: /var/lib/dataplaneapi/transactions + backups_number: 10 + backups_dir: /var/lib/dataplaneapi/backups +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/sbin/haproxy + reload: + reload_delay: 5 + service_name: haproxy + reload_strategy: systemd +log_targets: +- log_to: file + log_file: /var/log/dataplaneapi.log + log_level: info + log_types: + - access + - app diff --git a/assets/packages/default b/assets/packages/default new file mode 100644 index 00000000..d29e4314 --- /dev/null +++ b/assets/packages/default @@ -0,0 +1,3 @@ +# Options for dataplaneapi + +SYSD_OPTIONS='-f /etc/dataplaneapi/dataplaneapi.yml' diff --git a/assets/packages/logrotate b/assets/packages/logrotate new file mode 100644 index 00000000..f6bf29bd --- /dev/null +++ b/assets/packages/logrotate @@ -0,0 +1,9 @@ +/var/log/dataplaneapi.log { + missingok + compress + notifempty + copytruncate + daily + rotate 7 + create 0640 root root +} diff --git a/assets/packages/post-install.sh b/assets/packages/post-install.sh new file mode 100644 index 00000000..7b236a27 --- /dev/null +++ b/assets/packages/post-install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +systemctl --system daemon-reload || true +systemctl enable dataplaneapi || true diff --git a/assets/packages/post-uninstall.sh b/assets/packages/post-uninstall.sh new file mode 100644 index 00000000..4c0c8847 --- /dev/null +++ b/assets/packages/post-uninstall.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +systemctl --system daemon-reload || true diff --git a/assets/packages/pre-uninstall.sh b/assets/packages/pre-uninstall.sh new file mode 100644 index 00000000..d7c14c1b --- /dev/null +++ b/assets/packages/pre-uninstall.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +systemctl stop dataplaneapi || true +systemctl disable dataplaneapi || true diff --git a/bin/check-commit.sh b/bin/check-commit.sh new file mode 100644 index 00000000..b7390b51 --- /dev/null +++ b/bin/check-commit.sh @@ -0,0 +1,9 @@ +#!/bin/sh +V=$(./check-commit tag) + +if echo "$V" | grep -q "v$CHECK_COMMIT"; then + echo "$V" +else + echo "go install github.com/haproxytech/check-commit/v5@v$CHECK_COMMIT" + GOBIN=$(pwd) go install github.com/haproxytech/check-commit/v5@v$CHECK_COMMIT +fi diff --git a/bin/lint-check.sh b/bin/lint-check.sh new file mode 100644 index 00000000..0383b626 --- /dev/null +++ b/bin/lint-check.sh @@ -0,0 +1,7 @@ +#!/bin/sh +V=$(./golangci-lint --version) + +case "$V" in + *$GOLANGCI_LINT_VERSION*) echo "$V" ;; + *) curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(pwd) "v$GOLANGCI_LINT_VERSION" ;; +esac diff --git a/client-native/cn.go b/client-native/cn.go new file mode 100644 index 00000000..2235de19 --- /dev/null +++ b/client-native/cn.go @@ -0,0 +1,196 @@ +package cn + +import ( + "context" + "fmt" + "sync" + "time" + + clientnative "github.com/haproxytech/client-native/v6" + + parser "github.com/haproxytech/client-native/v6/config-parser" + "github.com/haproxytech/client-native/v6/config-parser/types" + "github.com/haproxytech/client-native/v6/configuration" + configuration_options "github.com/haproxytech/client-native/v6/configuration/options" + runtime_api "github.com/haproxytech/client-native/v6/runtime" + runtime_options "github.com/haproxytech/client-native/v6/runtime/options" + + dataplaneapi_config "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/misc" +) + +var ( + socketsList = map[int]string{} //nolint:unused + muSocketsList sync.Mutex +) + +func ConfigureConfigurationClient(haproxyOptions dataplaneapi_config.HAProxyConfiguration, mWorker bool) (configuration.Configuration, error) { + confClient, err := configuration.New(context.Background(), + configuration_options.ConfigurationFile(haproxyOptions.ConfigFile), + configuration_options.HAProxyBin(haproxyOptions.HAProxy), + configuration_options.Backups(haproxyOptions.BackupsNumber), + configuration_options.BackupsDir(haproxyOptions.BackupsDir), + configuration_options.UsePersistentTransactions, + configuration_options.TransactionsDir(haproxyOptions.TransactionDir), + configuration_options.ValidateCmd(haproxyOptions.ValidateCmd), + configuration_options.MasterWorker, + configuration_options.UseMd5Hash, + configuration_options.PreferredTimeSuffix(haproxyOptions.PreferredTimeSuffix), + ) + if err != nil { + return nil, fmt.Errorf("error setting up configuration client: %s", err.Error()) + } + + p := confClient.Parser() + comments, err := p.Get(parser.Comments, parser.CommentsSectionName, "#") + insertDisclaimer := err != nil + data, ok := comments.([]types.Comments) + if !ok { + insertDisclaimer = true + } else if len(data) == 0 || data[0].Value != "Dataplaneapi managed File" { + insertDisclaimer = true + } + if insertDisclaimer { + commentsNew := types.Comments{Value: "Dataplaneapi managed File"} + err = p.Insert(parser.Comments, parser.CommentsSectionName, "#", commentsNew, 0) + if err != nil { + return nil, fmt.Errorf("error setting up configuration client: %s", err.Error()) + } + commentsNew = types.Comments{Value: "changing file directly can cause a conflict if dataplaneapi is running"} + err = p.Insert(parser.Comments, parser.CommentsSectionName, "#", commentsNew, 1) + if err != nil { + return nil, fmt.Errorf("error setting up configuration client: %s", err.Error()) + } + } + + return confClient, nil +} + +func ConfigureRuntimeClient(ctx context.Context, confClient configuration.Configuration, haproxyOptions dataplaneapi_config.HAProxyConfiguration) runtime_api.Runtime { + mapsDir := runtime_options.MapsDir(haproxyOptions.MapsDir) + var runtimeClient runtime_api.Runtime + + _, globalConf, err := confClient.GetGlobalConfiguration("") + waitForRuntimeOption := runtime_options.AllowDelayedStart(haproxyOptions.DelayedStartMax, haproxyOptions.DelayedStartTick) + + // First try to setup master runtime socket + if err == nil { + var err error + // If master socket is set and a valid unix socket, use only this + if haproxyOptions.MasterRuntime != "" && misc.IsUnixSocketAddr(haproxyOptions.MasterRuntime) { + masterSocket := haproxyOptions.MasterRuntime + // nbproc has been removed, use master socket with 1 process + ms := runtime_options.MasterSocket(masterSocket) + runtimeClient, err = runtime_api.New(ctx, mapsDir, ms, waitForRuntimeOption) + if err == nil { + return runtimeClient + } + log.Warningf("Error setting up runtime client with master socket: %s : %s", masterSocket, err.Error()) + } + + runtimeAPIs := globalConf.RuntimeAPIs + // if no master socket set, read from first valid socket + sockets := make(map[int]string) + for _, r := range runtimeAPIs { + if misc.IsUnixSocketAddr(*r.Address) { + socketsL := runtime_options.Socket(*r.Address) + runtimeClient, err = runtime_api.New(ctx, mapsDir, socketsL, waitForRuntimeOption) + if err == nil { + muSocketsList.Lock() + socketsList = sockets + muSocketsList.Unlock() + return runtimeClient + } + log.Warningf("Error setting up runtime client with socket: %s : %s", *r.Address, err.Error()) + } + } + + if err != nil { + log.Warning("Runtime API not configured, not using it: " + err.Error()) + } else { + log.Warning("Runtime API not configured, not using it") + } + return runtimeClient + } + log.Warning("Cannot read runtime API configuration, not using it") + return runtimeClient +} + +// ReconfigureRuntime check if runtime client need be reconfigured by comparing the current configuration with the old +// one and returns a callback that ReloadAgent can use to reconfigure the runtime client. +func ReconfigureRuntime(client clientnative.HAProxyClient) (callbackNeeded bool, callback func(), err error) { + cfg, err := client.Configuration() + if err != nil { + return false, nil, err + } + + reconfigureRuntime := false + + // client Runtime is not reconfigured yet, so client.Runtime() return the "old" runtime + oldRuntime, err := client.Runtime() + // In case we have an error, we need to reconfigure + if err != nil { + reconfigureRuntime = true + } + + if !reconfigureRuntime { + // If we are not using stats socket (i.e. using master socket) + // Return immediately and do not reconfigure + // Do not try to compare the master socket path with stats socket paths + if !oldRuntime.IsStatsSocket() { + return false, nil, nil + } + + _, globalConf, err := cfg.GetGlobalConfiguration("") + if err != nil { + return false, nil, err + } + runtimeAPIsNew := globalConf.RuntimeAPIs + + oldSocketPath := oldRuntime.SocketPath() + + // Now check if the new configuration contains the "old" runtime socket we are using + // If yes, no need to reconfigure, socket path still exists. + // If not found, only then reconfigure + // This, only if stats socket, not for master socket + found := false + for _, runtimeNew := range runtimeAPIsNew { + if runtimeNew.Address == nil { + continue + } + if *runtimeNew.Address == oldSocketPath { + found = true + break + } + } + if !found { + reconfigureRuntime = true + } + } + + if reconfigureRuntime { + dpapiCfg := dataplaneapi_config.Get() + haproxyOptions := dpapiCfg.HAProxy + return true, func() { + var rnt runtime_api.Runtime + i := 1 + for i < 10 { + rnt = ConfigureRuntimeClient(context.Background(), cfg, haproxyOptions) + if rnt != nil { + break + } + time.Sleep(time.Duration(i) * time.Second) + i += i // exponential backoof + } + client.ReplaceRuntime(rnt) + if rnt == nil { + log.Debugf("reload callback completed, no runtime API") + } else { + log.Debugf("reload callback completed, runtime API reconfigured") + } + }, nil + } + + return false, nil, nil +} diff --git a/client-native/events.go b/client-native/events.go new file mode 100644 index 00000000..d181665a --- /dev/null +++ b/client-native/events.go @@ -0,0 +1,205 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cn + +import ( + "context" + "errors" + "fmt" + "io" + "strings" + "sync/atomic" + "time" + + clientnative "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/runtime" + "github.com/haproxytech/dataplaneapi/log" +) + +// Listen for HAProxy's event on the master socket. + +// Events categgories +const ( + EventAcme = "acme" +) + +type HAProxyEventListener struct { + listener *runtime.EventListener + client clientnative.HAProxyClient // for storage only + rt runtime.Runtime + stop atomic.Bool + lastEvent time.Time +} + +var ( + ErrNoMasterSocket = errors.New("master socket not configured") + ErrOldVersion = errors.New("this version of HAProxy does not support event sinks") +) + +func ListenHAProxyEvents(ctx context.Context, client clientnative.HAProxyClient) (*HAProxyEventListener, error) { + rt, err := client.Runtime() + if err != nil { + return nil, err + } + if rt == nil || rt.IsStatsSocket() { + return nil, ErrNoMasterSocket + } + + version, err := rt.GetVersion() + if err != nil { + return nil, err + } + // v3.2+ + if version.Major < 3 || (version.Major == 3 && version.Minor < 2) { + return nil, ErrOldVersion + } + + el, err := newHAProxyEventListener(rt.SocketPath()) + if err != nil { + return nil, err + } + + h := &HAProxyEventListener{ + client: client, + listener: el, + rt: rt, + } + + go h.listen(ctx) + + log.Debugf("listening for HAProxy events on: %s", rt.SocketPath()) + + return h, nil +} + +// Reconfigure a running listener with a new Runtime. +func (h *HAProxyEventListener) Reconfigure(ctx context.Context, rt runtime.Runtime) error { + if rt == nil || rt.IsStatsSocket() { + return ErrNoMasterSocket + } + + if rt.SocketPath() == h.rt.SocketPath() { + // no need to restart the listener + h.rt = rt + return nil + } + + h.Reset() + h.rt = rt + h.stop.Store(false) + go h.listen(ctx) + + return nil +} + +func (h *HAProxyEventListener) Reset() { + if h.listener != nil { + if err := h.listener.Close(); err != nil { + log.Warning(err) + } + h.listener = nil + } +} + +func (h *HAProxyEventListener) Stop() error { + h.stop.Store(true) + return h.listener.Close() +} + +func newHAProxyEventListener(socketPath string) (*runtime.EventListener, error) { + // This is both the connect and write timeout. + // Use a small value here since at this point dataplane is supposed + // to be already connected to the master socket. + timeout := 3 * time.Second + + el, err := runtime.NewEventListener("unix", socketPath, "dpapi", timeout, "-w", "-0") + if err != nil { + return nil, fmt.Errorf("could not listen to HAProxy's events: %w", err) + } + + return el, nil +} + +func (h *HAProxyEventListener) listen(ctx context.Context) { + var err error + retryAfter := 100 * time.Millisecond + + for { + if h.stop.Load() { + // Stop requested. + h.Reset() + return + } + if h.listener == nil { + h.listener, err = newHAProxyEventListener(h.rt.SocketPath()) + if err != nil { + // Try again. + log.Warning(err) + time.Sleep(retryAfter) + retryAfter *= 2 + if retryAfter == 51200*time.Millisecond { + // Give up after 10 iterations. + h.stop.Store(true) + } + continue + } + } + + for { + ev, err := h.listener.Listen(ctx) + if err != nil { + // EOF errors usually happen when HAProxy restarts, do not log. + if !errors.Is(err, io.EOF) { + log.Warning(err) + } + // Reset the connection. + h.Reset() + break + } + + h.handle(ctx, ev) + + if h.listener == nil { // just in case + break + } + } + } +} + +func (h *HAProxyEventListener) handle(ctx context.Context, ev runtime.Event) { + if !ev.Timestamp.After(h.lastEvent) { + // Event already seen! Skip. + log.Debugf("events: skipping already seen: '%s'", ev.String()) + return + } + h.lastEvent = ev.Timestamp + + log.Debugf("events: new: '%s'", ev.String()) + + category, rest, ok := strings.Cut(ev.Message, " ") + if !ok { + log.Warningf("failed to parse HAProxy Event: '%s'", ev.Message) + return + } + + if category == EventAcme { + h.handleAcmeEvent(ctx, rest) + return + } + + // Do not expect dataplaneapi to be able to handle all event types. + log.Debugf("unknown HAProxy Event type: '%s'", ev.Message) +} diff --git a/client-native/events_acme.go b/client-native/events_acme.go new file mode 100644 index 00000000..acaaa30f --- /dev/null +++ b/client-native/events_acme.go @@ -0,0 +1,314 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cn + +import ( + "context" + "errors" + "fmt" + "io" + "os" + "path/filepath" + "strconv" + "strings" + "time" + + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/dataplaneapi/acme" + "github.com/haproxytech/dataplaneapi/log" + jsoniter "github.com/json-iterator/go" +) + +// Supported event types. +const ( + EventAcmeNewCert = "newcert" + EventAcmeDeploy = "deploy" +) + +// Structs used to unmarshal ACME messages in JSON. +type acmeIdentifier struct { + Type string `json:"type"` + Value string `json:"value"` +} +type acmeStatus struct { + Identifier acmeIdentifier `json:"identifier"` +} + +func (h *HAProxyEventListener) handleAcmeEvent(ctx context.Context, message string) { + name, args, ok := strings.Cut(message, " ") + if !ok { + log.Warningf("failed to parse ACME Event: '%s'", message) + return + } + + switch name { + case EventAcmeNewCert: + h.handleAcmeNewCertEvent(args) + return + case EventAcmeDeploy: + h.handleAcmeDeployEvent(ctx, args) + return + } + + log.Debugf("unknown ACME Event type: '%s'", message) +} + +// HAProxy has created a new certificate and needs dpapi to write it to Storage. +// ex: acme newcert foobar.pem.rsa +func (h *HAProxyEventListener) handleAcmeNewCertEvent(args string) { + if len(args) == 0 { + log.Error("received HAProxy Event 'acme newcert' without a cert name") + return + } + + // Do not use the certificate name in args as a storage name. + // It could be an alias, or the user could have split keys and certs storage. + + crt, err := h.rt.ShowCertificate(args) + if err != nil { + log.Errorf("events: acme newcert %s: %s", args, err.Error()) + return + } + + storage, err := h.client.SSLCertStorage() + if err != nil { + log.Error(err) + return + } + + // 'dump ssl cert' can only be issued on sockets with level "admin". + pem, err := h.rt.DumpCertificate(crt.StorageName) + if err != nil { + log.Errorf("events: acme newcert %s: dump cert: %s", args, err.Error()) + return + } + + // The storage API only wants the filename, while the runtime API uses paths. + storageName := filepath.Base(crt.StorageName) + + // Create or Replace the certificate. + _, _, err = storage.Get(storageName) + if err != nil { + if errors.Is(err, configuration.ErrObjectDoesNotExist) { + rc := io.NopCloser(strings.NewReader(pem)) + _, _, err = storage.Create(storageName, rc) + } + } else { + _, err = storage.Replace(storageName, pem) + } + + if err != nil { + log.Errorf("events: acme newcert %s: storage: %s", args, err.Error()) + return + } + + log.Debugf("events: OK: acme newcert %s => %s", args, crt.StorageName) +} + +// HAProxy needs dpapi to solve a dns-01 challenge. +// example: +// acme deploy CertIdentifier thumbprint "QPFLnguBJSfyTiN2c4DWiWJvpveUB3bvY3EoC8cZC-U"\n +// provider-name "godaddy"\n +// acme-vars "var=var1,var=var2"\n +// acme-vars "var1=foobar,var2=var2"\n +// +// { +// "identifier": { +// "type": "dns", +// "value": "test1.example.com" +// }, +// "status": "pending", +// "expires": "2025-04-02T13:25:16Z", +// "challenges": [ +// { +// "type": "dns-01", +// "url": "https://acme-staging-v02.api.letsencrypt.org/acme/chall/189956024/16553103724/hj-ldw", +// "status": "pending", +// "token": "Yz3R-LFz6JPr04FN6FjnArcojzyFoD9ojFXZAaG5Rmo" +// }, +// ... +// ] +// }\0 +func (h *HAProxyEventListener) handleAcmeDeployEvent(ctx context.Context, args string) { + if len(args) == 0 { + log.Error("received HAProxy Event 'acme deploy' without any argument") + return + } + + var ( + firstLine = true + isJSON = false + certID string + provider string + keyAuth string + acmeArgs []string + acmeJSON string + parseErr error + ) + + // Parse the message line by line. + strings.SplitSeq(args, "\n")(func(line string) bool { + if firstLine { + firstLine = false + words := strings.Split(line, " ") + if len(words) != 3 || words[1] != "thumbprint" || len(words[2]) < 3 { + parseErr = fmt.Errorf("invalid acme deploy line: '%s'", line) + return false + } + certID = strings.Trim(words[0], `"`) + return true + } + if isJSON { + acmeJSON += line + return true + } + if strings.HasPrefix(line, "provider-name ") { + words := strings.Split(line, " ") + if len(words) != 2 { + parseErr = fmt.Errorf("invalid provider-name line: '%s'", line) + return false + } + provider = strings.Trim(words[1], `"`) + return true + } + if strings.HasPrefix(line, "acme-vars ") { + _, vars, found := strings.Cut(line, " ") + if !found || len(vars) == 0 { + parseErr = fmt.Errorf("invalid acme-vars line: '%s'", line) + return false + } + // Do not trim the double-quotes here. + acmeArgs = append(acmeArgs, vars) + return true + } + if strings.HasPrefix(line, "dns-01-record ") { + words := strings.Split(line, " ") + if len(words) != 2 { + parseErr = fmt.Errorf("invalid dns-01-record line: '%s'", line) + return false + } + keyAuth = strings.Trim(words[1], `"`) + return true + } + if strings.HasPrefix(line, "{") { + isJSON = true + acmeJSON += line + return true + } + // Ignore anything else. + return true + }) + + if parseErr != nil { + log.Errorf("events: acme deploy: %s", parseErr.Error()) + return + } + + // Parse the JSON to get the domain name. + var status acmeStatus + if err := jsoniter.UnmarshalFromString(acmeJSON, &status); err != nil { + log.Errorf("events: acme deploy: json.Unmarshal: %s", err.Error()) + return + } + + domainName := status.Identifier.Value + + // Merge the acme-vars + vars := make(map[string]any, 8) + for _, line := range acmeArgs { + hmap := configuration.ParseAcmeVars(line) + for k, v := range hmap { + vars[k] = v + } + } + + // Solve the DNS challenge. + solver, err := acme.NewDNS01Solver(provider, vars) + if err != nil { + log.Errorf("events: acme deploy: DNS provider: %s", err.Error()) + return + } + + // These options will be configurable from haproxy.cfg in a future version. + // For now use environment variables. + solver.PropagationDelay = getEnvDuration("DPAPI_ACME_PROPAGDELAY_SEC", 0) + solver.PropagationTimeout = getEnvDuration("DPAPI_ACME_PROPAGTIMEOUT_SEC", time.Hour) + + var zone string + if solver.PropagationTimeout != -1 { + zone = acme.GuessZone(domainName) + } else { + zone, err = acme.FindZoneByFQDN(ctx, domainName, acme.RecursiveNameservers(nil)) + } + if err != nil { + log.Errorf("events: acme deploy: failed to find root zone for '%s': %s", domainName, err.Error()) + return + } + err = solver.Present(ctx, domainName, zone, keyAuth) + if err != nil { + log.Errorf("events: acme deploy: DNS solver: %s", err.Error()) + return + } + // Wait for DNS propagation and cleanup. + err = solver.Wait(ctx, domainName, zone, keyAuth) + // Remove the challenge in 10m if Wait() was successful. This should be + // more than enough for HAProxy to finish the challenge with the ACME server. + waitBeforeCleanup := 10 * time.Minute + if err != nil { + waitBeforeCleanup = time.Second + } + go func() { + time.Sleep(waitBeforeCleanup) + if err := solver.CleanUp(ctx, domainName, zone, keyAuth); err != nil { + log.Errorf("events: acme deploy: cleanup failed for %s: %v", domainName, err) + } + }() + if err != nil { + log.Errorf("events: acme deploy: DNS propagation check failed for '%s': %v", domainName, err) + return + } + + // Send back a response to HAProxy. + rt, err := h.client.Runtime() + if err != nil { + log.Error(err) + return + } + resp, err := rt.ExecuteRaw("acme challenge_ready " + certID + " domain " + domainName) + if err != nil { + log.Errorf("events: acme deploy: sending response: %s", err.Error()) + return + } + + log.Debugf("events: OK: acme deploy %s => %s", domainName, resp) +} + +// Parse an environment variable containing a duration in seconds, or return a default value. +func getEnvDuration(name string, def time.Duration) time.Duration { + str := os.Getenv(name) + if str == "" { + return def + } + if str == "-1" { + // special case to disable waiting for propagation + return -1 + } + num, err := strconv.Atoi(str) + if err != nil { + return def + } + return time.Duration(num) * time.Second +} diff --git a/cmd/dataplaneapi/main.go b/cmd/dataplaneapi/main.go index af246e07..1aecfe2b 100644 --- a/cmd/dataplaneapi/main.go +++ b/cmd/dataplaneapi/main.go @@ -16,42 +16,82 @@ package main import ( + "context" "fmt" "os" + "path" + "path/filepath" + "syscall" - log "github.com/sirupsen/logrus" - + _ "github.com/KimMachineGun/automemlimit" loads "github.com/go-openapi/loads" - flags "github.com/jessevdk/go-flags" - + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/security" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/client-native/v6/storage" "github.com/haproxytech/dataplaneapi" + "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/log" "github.com/haproxytech/dataplaneapi/operations" + socket_runtime "github.com/haproxytech/dataplaneapi/runtime" + flags "github.com/jessevdk/go-flags" + "github.com/joho/godotenv" + _ "go.uber.org/automaxprocs" ) -func init() { - log.SetFormatter(&log.TextFormatter{ - FullTimestamp: true, - DisableColors: true, - }) - log.SetOutput(os.Stdout) -} +// GitRepo ... +var GitRepo = "" + +// GitTag ... +var GitTag = "" + +// GitCommit ... +var GitCommit = "dev" + +// GitDirty ... +var GitDirty = ".dirty" + +// BuildTime ... +var BuildTime = "" var cliOptions struct { Version bool `short:"v" long:"version" description:"Version and build information"` } func main() { + _ = godotenv.Load() + cancelDebugServer := startRuntimeDebugServer() + + cfg := configuration.Get() + for { + restart := startServer(cfg, cancelDebugServer) + if !restart.Load() { + break + } + } +} + +func startRuntimeDebugServer() context.CancelFunc { + ctx := context.Background() + ctx, cancelDebugServer := context.WithCancel(ctx) + debugServer := socket_runtime.GetServer() + debugServer.DAPIVersion = fmt.Sprintf("%s %s%s", GitTag, GitCommit, GitDirty) + go debugServer.Start(ctx, cancelDebugServer) + return cancelDebugServer +} + +func startServer(cfg *configuration.Configuration, cancelDebugServer context.CancelFunc) (reload configuration.AtomicBool) { //nolint: maintidx swaggerSpec, err := loads.Embedded(dataplaneapi.SwaggerJSON, dataplaneapi.FlatSwaggerJSON) if err != nil { - log.Fatalln(err) + fmt.Println(err) + os.Exit(1) } - + dataplaneapi.BuildTime = BuildTime dataplaneapi.Version = fmt.Sprintf("%s %s%s", GitTag, GitCommit, GitDirty) - + api := operations.NewDataPlaneAPI(swaggerSpec) server := dataplaneapi.NewServer(api) - defer server.Shutdown() parser := flags.NewParser(server, flags.Default) parser.ShortDescription = "HAProxy Data Plane API" @@ -59,23 +99,26 @@ func main() { server.ConfigureFlags() for _, optsGroup := range api.CommandLineOptionsGroups { - _, err := parser.AddGroup(optsGroup.ShortDescription, optsGroup.LongDescription, optsGroup.Options) + _, err = parser.AddGroup(optsGroup.ShortDescription, optsGroup.LongDescription, optsGroup.Options) if err != nil { - log.Fatalln(err) + fmt.Println(err) + os.Exit(1) } } _, err = parser.AddGroup("Show version", "Show build and version information", &cliOptions) if err != nil { - log.Fatalln(err) + fmt.Println(err) + os.Exit(1) } - if _, err := parser.Parse(); err != nil { + if _, err = parser.Parse(); err != nil { if fe, ok := err.(*flags.Error); ok { if fe.Type == flags.ErrHelp { os.Exit(0) } else { - log.Fatalln(err) + fmt.Println(err) + os.Exit(1) } } } @@ -84,16 +127,157 @@ func main() { fmt.Printf("HAProxy Data Plane API %s %s%s\n\n", GitTag, GitCommit, GitDirty) fmt.Printf("Build from: %s\n", GitRepo) fmt.Printf("Build date: %s\n\n", BuildTime) - return + return reload } - server.ConfigureAPI() + var loadMsg []string + _, err = cfg.Load() + if err != nil { + fmt.Println("configuration error:", err) + os.Exit(1) + } + + if cfg.HAProxy.UID != 0 { + if err = syscall.Setuid(cfg.HAProxy.UID); err != nil { + fmt.Println("set uid:", err) + os.Exit(1) + } + } + + if cfg.HAProxy.GID != 0 { + if err = syscall.Setgid(cfg.HAProxy.GID); err != nil { + fmt.Println("set gid:", err) + os.Exit(1) + } + } + + loadMsg, err = cfg.LoadDataplaneStorageConfig() + if err != nil { + fmt.Println("configuration error:", err) + os.Exit(1) + } + cfg.FlagLoadDapiStorageData = true + + // incorporate changes from file to global settings + dataplaneapi.SyncWithFileSettings(server, cfg) + err = cfg.LoadRuntimeVars(dataplaneapi.SwaggerJSON, server.Host, server.Port) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + configuration.HandlePIDFile(cfg.HAProxy) + + if cfg.Mode.Load() == configuration.ModeCluster { + if cfg.Cluster.CertificateFetched.Load() { + log.Info("HAProxy Data Plane API in cluster mode") + server.TLSCertificate = flags.Filename(path.Join(cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s.crt", cfg.Name.Load()))) + server.TLSCertificateKey = flags.Filename(path.Join(cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s.key", cfg.Name.Load()))) + server.EnabledListeners = []string{"https"} + if server.TLSPort == 0 { + server.TLSPort = server.Port + } + // override storage dir location + storageDir := cfg.Cluster.StorageDir.Load() + if storageDir != "" { + cfg.HAProxy.MapsDir = path.Join(storageDir, string(storage.MapsType)) + cfg.HAProxy.SSLCertsDir = path.Join(storageDir, string(storage.SSLType)) + cfg.HAProxy.GeneralStorageDir = path.Join(storageDir, string(storage.GeneralType)) + cfg.HAProxy.DataplaneStorageDir = filepath.Clean(path.Join(storageDir, "dataplane")) + cfg.HAProxy.SpoeDir = path.Join(storageDir, string(storage.SpoeType)) + cfg.HAProxy.SpoeTransactionDir = path.Join(storageDir, string(storage.SpoeTransactionsType)) + cfg.HAProxy.BackupsDir = path.Join(storageDir, string(storage.BackupsType)) + cfg.HAProxy.TransactionDir = path.Join(storageDir, string(storage.TransactionsType)) + // dataplane internal + cfg.HAProxy.ClusterTLSCertDir = path.Join(storageDir, "certs-cluster") + cfg.Cluster.CertificateDir.Store(path.Join(storageDir, "certs-cluster")) + } + } else if cfg.Cluster.ActiveBootstrapKey.Load() != "" { + cfg.Notify.BootstrapKeyChanged.NotifyWithRetry() + } + } + + clusterLogTargets := parseClusterLogTargets(cfg) + if err = log.InitWithConfiguration(cfg.LogTargets, cfg.Logging, cfg.Syslog, clusterLogTargets, cfg.Cluster.ID.Load()); err != nil { + fmt.Println(err) + os.Exit(1) + } + + cfg.InitSignalHandler() log.Infof("HAProxy Data Plane API %s %s%s", GitTag, GitCommit, GitDirty) log.Infof("Build from: %s", GitRepo) log.Infof("Build date: %s", BuildTime) + log.Infof("Reload strategy: %s", cfg.HAProxy.ReloadStrategy) + + // log deprecation message + if len(loadMsg) > 0 { + for _, msg := range loadMsg { + log.Warning(msg) + } + } + + err = cfg.Save() + if err != nil { + log.Fatalf("Error saving configuration: %s", err.Error()) + } + + // Applies when the Authorization header is set with the Basic scheme + api.BasicAuthAuth = configuration.AuthenticateUser + api.BasicAuthenticator = func(authentication security.UserPassAuthentication) runtime.Authenticator { + // if mTLS is enabled with backing Certificate Authority, skipping basic authentication + if len(server.TLSCACertificate) > 0 && server.TLSPort > 0 { + return runtime.AuthenticatorFunc(func(i any) (bool, any, error) { + return true, "", nil + }) + } + return security.BasicAuthRealm("", authentication) + } + + dataplaneapi.ContextHandler.Init() + go func() { + <-cfg.Notify.Reload.Subscribe("main") + log.Info("HAProxy Data Plane API reloading") + reload.Store(true) + cfg.UnSubscribeAll() + cfg.StopSignalHandler() + dataplaneapi.ContextHandler.Cancel() + err = server.Shutdown() + if err != nil { + log.Fatalf("Error reloading HAProxy Data Plane API: %s", err.Error()) + } + }() + + go func() { + select { + case <-cfg.Notify.Shutdown.Subscribe("main"): + log.Info("HAProxy Data Plane API shutting down") + err = server.Shutdown() + if err != nil { + log.Fatalf("Error shutting down HAProxy Data Plane API: %s", err.Error()) + } + cancelDebugServer() + os.Exit(0) + case <-dataplaneapi.ContextHandler.Context().Done(): + return + } + }() + + server.ConfigureAPI() + dataplaneapi.SetServerStartedCallback(cfg.Notify.ServerStarted.Notify) if err := server.Serve(); err != nil { - log.Fatalln(err) + log.Fatalf("Error running HAProxy Data Plane API: %s", err.Error()) + } + + defer server.Shutdown() //nolint:errcheck + + return reload +} + +func parseClusterLogTargets(cfg *configuration.Configuration) []*models.ClusterLogTarget { + if cfg.Mode.Load() == "cluster" && cfg.Cluster.ClusterLogTargets != nil && len(cfg.Cluster.ClusterLogTargets) > 0 { + return cfg.Cluster.ClusterLogTargets } + return []*models.ClusterLogTarget{} } diff --git a/cmd/dataplaneapi/version.go b/cmd/dataplaneapi/version.go deleted file mode 100644 index 6f6c4705..00000000 --- a/cmd/dataplaneapi/version.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -//GitRepo ... -var GitRepo = "" - -//GitTag ... -var GitTag = "" - -//GitCommit ... -var GitCommit = "dev" - -//GitDirty ... -var GitDirty = ".dirty" - -//BuildTime ... -var BuildTime = "" diff --git a/cmd/gitlab-mr-checker/main.go b/cmd/gitlab-mr-checker/main.go new file mode 100644 index 00000000..5285aaf8 --- /dev/null +++ b/cmd/gitlab-mr-checker/main.go @@ -0,0 +1,455 @@ +// Copyright 2019 HAProxy Technologies LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "net/url" + "os" + "slices" + "sort" + "strconv" + "strings" + "time" + + "github.com/Masterminds/semver" + "github.com/joho/godotenv" +) + +type Issue struct { + Title string `json:"title"` + State string `json:"state"` + ID int `json:"id"` + IID int `json:"iid"` +} + +type Note struct { + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + Body string `json:"body"` + Attachment string `json:"attachment"` + Author Author `json:"author"` + ID int `json:"id"` + ProjectID int `json:"project_id"` + System bool `json:"system"` + Resolvable bool `json:"resolvable"` + Confidential bool `json:"confidential"` + Internal bool `json:"internal"` +} + +type Author struct { + CreatedAt time.Time `json:"created_at"` + Username string `json:"username"` + Email string `json:"email"` + Name string `json:"name"` + State string `json:"state"` + ID int `json:"id"` +} + +type Thread struct { + Body string `json:"body"` + ID int `json:"id"` + IID int `json:"iid"` +} + +// GitlabLabel defines the structure for a GitLab label. +// It includes common fields; you are primarily using Name. +type GitlabLabel struct { + ID int `json:"id"` + Name string `json:"name"` + Color string `json:"color"` + Description string `json:"description,omitempty"` // omitempty handles cases where description might be null or absent +} + +type Support struct { + Versions []string `yaml:"versions"` +} + +type MergeRequest struct { + Description string `json:"description"` +} + +var baseURL string + +const LABEL_COLOR = "#8fbc8f" + +func main() { + _ = godotenv.Overload() + fmt.Print(hello) //nolint:forbidigo + + logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + AddSource: true, + ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + if a.Key == "source" { + x := a.Value + src := x.Any().(*slog.Source) + path := strings.Split(src.File, "/") + src.File = path[len(path)-1] + return slog.Attr{ + Key: "source", + Value: slog.AnyValue(src), + } + } + return a + }, + })) + slog.SetDefault(logger) + + baseURL = os.Getenv("CI_API_V4_URL") + if baseURL == "" { + slog.Error("CI_API_V4_URL not set") + os.Exit(1) + } + + docs, err := GetBranches() + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + var versions []*semver.Version + for _, r := range docs { + v, err := semver.NewVersion(r) + if err != nil { + slog.Debug("could not parse branch name as semver, skipping", "branch", r, "error", err) + continue + } + versions = append(versions, v) + } + + sort.Sort(semver.Collection(versions)) + // leave only last three since only those are maintained + if len(versions) > 3 { + versions = versions[len(versions)-3:] + } + + gitlabToken := os.Getenv("GITLAB_TOKEN") + + CI_MERGE_REQUEST_IID_STR := os.Getenv("CI_MERGE_REQUEST_IID") + if CI_MERGE_REQUEST_IID_STR == "" { + slog.Error("CI_MERGE_REQUEST_IID not set") + os.Exit(1) + } + CI_MERGE_REQUEST_IID, err := strconv.Atoi(CI_MERGE_REQUEST_IID_STR) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + CI_PROJECT_ID := os.Getenv("CI_PROJECT_ID") + if CI_PROJECT_ID == "" { + slog.Error("CI_PROJECT_ID not set") + os.Exit(1) + } + sb := strings.Builder{} + sb.WriteString(`` + "\n" + "Does this needs backport ? \n| Version | label |\n|:--:|:--:|") + backportLabels := map[string]struct{}{ + "backport-ee": {}, + } + for _, version := range versions { + ver := strconv.Itoa(int(version.Major())) + "." + strconv.Itoa(int(version.Minor())) + sb.WriteString("\n") + sb.WriteString("| ") + sb.WriteString(ver) + sb.WriteString(" | ") + sb.WriteString("backport-") + sb.WriteString(ver) + sb.WriteString(" |") + backportLabels["backport-"+ver] = struct{}{} + } + // ee + sb.WriteString("\n" + "| EE | " + "backport-ee |") + sb.WriteString("\n\n" + "please add labels for backporting.") + + mr, err := getMergeRequest(baseURL, gitlabToken, CI_PROJECT_ID, CI_MERGE_REQUEST_IID) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + if strings.Contains(mr.Description, "") { + slog.Info("Dependabot MR detected, skipping backport check.") + os.Exit(0) + } + + notes, err := getMergeRequestComments(baseURL, gitlabToken, CI_PROJECT_ID, CI_MERGE_REQUEST_IID) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + index := slices.IndexFunc(notes, func(note Note) bool { + return strings.Contains(note.Body, "") + }) + if index == -1 { + // add missing labels + err = getProjectlabels(backportLabels, CI_PROJECT_ID) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + slog.Info("No backport question found, creating one as thread") + startThreadOnMergeRequest(baseURL, gitlabToken, CI_PROJECT_ID, CI_MERGE_REQUEST_IID, sb.String()) + } +} + +func startThreadOnMergeRequest(baseURL, token, projectID string, mergeRequestIID int, threadBody string) { + client := &http.Client{} + threadData := map[string]any{ + "body": threadBody, + } + threadDataBytes, err := json.Marshal(threadData) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, + fmt.Sprintf("%s/projects/%s/merge_requests/%d/discussions", baseURL, url.PathEscape(projectID), mergeRequestIID), bytes.NewBuffer(threadDataBytes)) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + req.Header.Add("PRIVATE-TOKEN", token) //nolint:canonicalheader + req.Header.Add("Content-Type", "application/json") + + resp, err := client.Do(req) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + defer resp.Body.Close() +} + +func getMergeRequest(baseURL, token, projectID string, mergeRequestIID int) (*MergeRequest, error) { + client := &http.Client{} + + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, + fmt.Sprintf("%s/projects/%s/merge_requests/%d", baseURL, url.PathEscape(projectID), mergeRequestIID), nil) + if err != nil { + return nil, err + } + req.Header.Add("PRIVATE-TOKEN", token) //nolint:canonicalheader + + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + return nil, fmt.Errorf("failed to get merge request: status %s, body: %s", resp.Status, string(body)) + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + var mr MergeRequest + err = json.Unmarshal(body, &mr) + if err != nil { + return nil, err + } + + return &mr, nil +} + +func getMergeRequestComments(baseURL, token, projectID string, mergeRequestIID int) ([]Note, error) { + client := &http.Client{} + + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, + fmt.Sprintf("%s/projects/%s/merge_requests/%d/notes", baseURL, url.PathEscape(projectID), mergeRequestIID), nil) + if err != nil { + return nil, err + } + req.Header.Add("PRIVATE-TOKEN", token) //nolint:canonicalheader + + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + var notes []Note + err = json.Unmarshal(body, ¬es) + if err != nil { + return nil, err + } + + return notes, nil +} + +func getProjectlabels(backportLabels map[string]struct{}, projectID string) error { + client := &http.Client{} + token := os.Getenv("GITLAB_TOKEN") + if token == "" { + return errors.New("GITLAB_TOKEN not set") + } + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, + fmt.Sprintf("%s/projects/%s/labels", baseURL, url.PathEscape(projectID)), nil) + if err != nil { + return fmt.Errorf("failed to create request: %w", err) + } + req.Header.Add("PRIVATE-TOKEN", token) //nolint:canonicalheader + resp, err := client.Do(req) + if err != nil { + return fmt.Errorf("failed to get project labels: %w", err) + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return fmt.Errorf("failed to read response body: %w", err) + } + + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("failed to get project labels: status %s, body: %s", resp.Status, string(body)) + } + + var projectLabels []GitlabLabel + err = json.Unmarshal(body, &projectLabels) + if err != nil { + return fmt.Errorf("failed to unmarshal response body (status %s): %w. Body: %s", resp.Status, err, string(body)) + } + + for _, label := range projectLabels { + _, ok := backportLabels[label.Name] + if ok { + delete(backportLabels, label.Name) + } + } + for label := range backportLabels { + // Create the label if it doesn't exist + labelData := map[string]string{ + "name": label, + "color": LABEL_COLOR, + "description": "Label for backporting to " + label + " branch", + } + labelDataBytes, err := json.Marshal(labelData) + if err != nil { + return fmt.Errorf("failed to marshal label data: %w", err) + } + req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, + fmt.Sprintf("%s/projects/%s/labels", baseURL, url.PathEscape(projectID)), bytes.NewBuffer(labelDataBytes)) + if err != nil { + return fmt.Errorf("failed to create request to create label: %w", err) + } + req.Header.Add("PRIVATE-TOKEN", token) //nolint:canonicalheader + req.Header.Add("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil { + return fmt.Errorf("failed to create label %s: %w", label, err) + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusCreated { + return fmt.Errorf("failed to create label %s, status code: %d", label, resp.StatusCode) + } + } + + return nil +} + +func GetBranches() ([]string, error) { + projectID := os.Getenv("CI_PROJECT_ID") + token := os.Getenv("GITLAB_TOKEN") + + if baseURL == "" || projectID == "" || token == "" { + return nil, errors.New("one or more required environment variables are not set: CI_API_V4_URL, CI_PROJECT_ID, GITLAB_TOKEN") + } + + var branches []string + client := &http.Client{} + + nextPageURL := fmt.Sprintf("%s/projects/%s/repository/branches", baseURL, url.PathEscape(projectID)) + + for nextPageURL != "" { + req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, nextPageURL, nil) + if err != nil { + return nil, fmt.Errorf("failed to create request: %w", err) + } + req.Header.Add("PRIVATE-TOKEN", token) //nolint:canonicalheader + + resp, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("failed to get branches: %w", err) + } + + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + resp.Body.Close() + return nil, fmt.Errorf("failed to get branches: status %s, body: %s", resp.Status, string(body)) + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + resp.Body.Close() + return nil, fmt.Errorf("failed to read response body: %w", err) + } + resp.Body.Close() + + type Branch struct { + Name string `json:"name"` + } + var gitlabBranches []Branch + err = json.Unmarshal(body, &gitlabBranches) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal response body: %w", err) + } + + for _, b := range gitlabBranches { + branches = append(branches, b.Name) + } + + // Check for the next page using Link header + linkHeader := resp.Header.Get("Link") + if linkHeader == "" { + nextPageURL = "" + continue + } + + links := strings.Split(linkHeader, ",") + nextPageURL = "" + for _, link := range links { + parts := strings.Split(strings.TrimSpace(link), ";") + if len(parts) == 2 && strings.TrimSpace(parts[1]) == `rel="next"` { + nextPageURL = strings.Trim(parts[0], "<>") + break + } + } + } + + return branches, nil +} + +const hello = ` + __ __ ____ _ _ +| \/ | _ \ ___| |__ ___ ___| | _____ _ __ +| |\/| | |_) | / __| '_ \ / _ \/ __| |/ / _ \ '__| +| | | | _ < | (__| | | | __/ (__| < __/ | +|_| |_|_| \_\ \___|_| |_|\___|\___|_|\_\___|_| + +` diff --git a/cmd/gitlab-mr-pipelines/ascii.txt b/cmd/gitlab-mr-pipelines/ascii.txt new file mode 100644 index 00000000..d3b21f22 --- /dev/null +++ b/cmd/gitlab-mr-pipelines/ascii.txt @@ -0,0 +1,11 @@ + ____ _ _ _ _ + / ___(_) |_| | __ _| |__ + | | _| | __| |/ _` | '_ \ + | |_| | | |_| | (_| | |_) | + \____|_|\__|_|\__,_|_.__/ + ____ _ _ _ _ _ + | _ \(_)_ __ ___| (_)_ __ ___ ___| |__ ___ ___| | __ + | |_) | | '_ \ / _ \ | | '_ \ / _ \ / __| '_ \ / _ \/ __| |/ / + | __/| | |_) | __/ | | | | | __/ | (__| | | | __/ (__| < + |_| |_| .__/ \___|_|_|_| |_|\___| \___|_| |_|\___|\___|_|\_\ + |_| diff --git a/cmd/gitlab-mr-pipelines/main.go b/cmd/gitlab-mr-pipelines/main.go new file mode 100644 index 00000000..9eca2569 --- /dev/null +++ b/cmd/gitlab-mr-pipelines/main.go @@ -0,0 +1,159 @@ +// Copyright 2019 HAProxy Technologies LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package main + +import ( + _ "embed" + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "strconv" + "strings" +) + +//go:embed ascii.txt +var hello string + +//nolint:forbidigo +func main() { + fmt.Println(hello) + // Check if we are in a merge request context + mrIID := os.Getenv("CI_MERGE_REQUEST_IID") + if mrIID == "" { + fmt.Println("Not a merge request. Exiting.") + os.Exit(0) + } + + // Get necessary environment variables + gitlabAPIURL := os.Getenv("CI_API_V4_URL") + projectID := os.Getenv("CI_PROJECT_ID") + sourceProjectID := os.Getenv("CI_MERGE_REQUEST_SOURCE_PROJECT_ID") + gitlabToken := os.Getenv("GITLAB_TOKEN") + + if gitlabAPIURL == "" || projectID == "" || sourceProjectID == "" { + fmt.Println("Missing required GitLab CI/CD environment variables.") + os.Exit(1) + } + + if gitlabToken == "" { + fmt.Print("GitLab token not found in environment variable.\n") + os.Exit(1) + } + + // 1. Get all old pipelines for this Merge Request + pipelinesToCancel, err := getOldMergeRequestPipelines(gitlabAPIURL, projectID, mrIID, gitlabToken) + if err != nil { + fmt.Printf("Error getting merge request pipelines: %v\n", err) + os.Exit(1) + } + + if len(pipelinesToCancel) == 0 { + fmt.Println("No old, running pipelines found for this merge request.") + os.Exit(0) + } + + fmt.Printf("Found %d old pipelines to cancel.\n", len(pipelinesToCancel)) + + // 2. Cancel all found pipelines + for _, p := range pipelinesToCancel { + fmt.Printf("Canceling pipeline ID %d on project ID %d\n", p.ID, p.ProjectID) + err = cancelPipeline(gitlabAPIURL, strconv.Itoa(p.ProjectID), p.ID, gitlabToken) + if err != nil { + // Log error but continue trying to cancel others + fmt.Printf("Failed to cancel pipeline %d: %v\n", p.ID, err) + } else { + fmt.Printf("Successfully requested cancellation for pipeline %d\n", p.ID) + } + } +} + +type pipelineInfo struct { + ID int `json:"id"` + ProjectID int `json:"project_id"` + Status string `json:"status"` +} + +func getOldMergeRequestPipelines(apiURL, projectID, mrIID, token string) ([]pipelineInfo, error) { + // Get the current pipeline ID to avoid canceling ourselves + currentPipelineIDStr := os.Getenv("CI_PIPELINE_ID") + var currentPipelineID int + if currentPipelineIDStr != "" { + // a non-integer value will result in 0, which is fine since pipeline IDs are positive + currentPipelineID, _ = strconv.Atoi(currentPipelineIDStr) + } + + url := fmt.Sprintf("%s/projects/%s/merge_requests/%s/pipelines", apiURL, projectID, mrIID) + req, err := http.NewRequest("GET", url, nil) //nolint:noctx,usestdlibvars + if err != nil { + return nil, err + } + req.Header.Set("PRIVATE-TOKEN", token) //nolint:canonicalheader + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + return nil, fmt.Errorf("failed to list merge request pipelines: status %d, body: %s", resp.StatusCode, string(body)) + } + + var pipelines []pipelineInfo + if err := json.NewDecoder(resp.Body).Decode(&pipelines); err != nil { + return nil, err + } + + var pipelinesToCancel []pipelineInfo + for _, p := range pipelines { + // Cancel pipelines that are running or pending, and are not the current pipeline + if (p.Status == "running" || p.Status == "pending") && p.ID != currentPipelineID { + pipelinesToCancel = append(pipelinesToCancel, p) + } + } + + return pipelinesToCancel, nil +} + +func cancelPipeline(apiURL, projectID string, pipelineID int, token string) error { + url := fmt.Sprintf("%s/projects/%s/pipelines/%d/cancel", apiURL, projectID, pipelineID) + req, err := http.NewRequest("POST", url, nil) //nolint:noctx,usestdlibvars + if err != nil { + return err + } + req.Header.Set("PRIVATE-TOKEN", token) //nolint:canonicalheader + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + body, _ := io.ReadAll(resp.Body) + // It's possible the pipeline is already finished. + if strings.Contains(string(body), "Cannot cancel a pipeline that is not pending or running") { + fmt.Println("Pipeline already finished, nothing to do.") //nolint:forbidigo + return nil + } + return fmt.Errorf("failed to cancel pipeline: status %d, body: %s", resp.StatusCode, string(body)) + } + + return nil +} diff --git a/cmd/govulncheck-report/main.go b/cmd/govulncheck-report/main.go new file mode 100644 index 00000000..dd8b101b --- /dev/null +++ b/cmd/govulncheck-report/main.go @@ -0,0 +1,359 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "log/slog" + "net/http" + "net/url" + "os" + "os/exec" + "strconv" + "strings" +) + +type Note struct { + Body string `json:"body"` + ID int `json:"id"` +} + +type Issue struct { + Title string `json:"title"` + State string `json:"state"` + ID int `json:"id"` + IID int `json:"iid"` +} + +type Thread struct { + Body string `json:"body"` + ID int `json:"id"` + IID int `json:"iid"` +} + +const baseURL = "https://gitlab.int.haproxy.com/api/v4" + +func main() { + fmt.Print(hello) + logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ + AddSource: true, + ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + if a.Key == "source" { + x := a.Value + src := x.Any().(*slog.Source) + path := strings.Split(src.File, "/") + src.File = path[len(path)-1] + return slog.Attr{ + Key: "source", + Value: slog.AnyValue(src), + } + } + return a + }, + })) + slog.SetDefault(logger) + + slog.Info("Starting GoVulnCheck") + mergeRequestMode := false + currentBranch := os.Getenv("CI_COMMIT_BRANCH") + if currentBranch == "" { + currentBranch = os.Getenv("CI_MERGE_REQUEST_SOURCE_BRANCH_NAME") + mergeRequestMode = true + } + if currentBranch == "" { + cmd := exec.Command("git", "branch", "--show-current") + out, err := cmd.Output() + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + currentBranch = string(out) + } + slog.Info("Current branch: " + currentBranch) + + cmd := exec.Command("govulncheck", "./...") + out, _ := cmd.Output() + + vulnMessage := string(out) + fmt.Println(vulnMessage) + noVuln := !strings.Contains(vulnMessage, "Vulnerability #") + + if currentBranch == "" { + if strings.Contains(vulnMessage, "Vulnerability #") { + slog.Error(vulnMessage) + os.Exit(1) + } + slog.Info("Current branch is empty, exiting...") + os.Exit(0) + } + + if mergeRequestMode { + if strings.Contains(vulnMessage, "Vulnerability #") { + os.Exit(1) + } + slog.Info("no vulnerabilities found") + os.Exit(0) + } + + token := os.Getenv("GITLAB_GOPHERS_TOKEN") + projectID := "534" + title := "Data Plane API: GoVulnCheck: Branch: " + strings.Trim(currentBranch, "\n") + + userID, err := fetchUserID(token) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + issues, err := fetchOpenIssues(projectID, userID, token) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + found := false + var issueFound Issue + for _, issue := range issues { + if issue.Title == title && issue.State == "opened" { + found = true + issueFound = issue + break + } + } + vulnMessage = "```\n" + vulnMessage + "\n```" + if found { + if noVuln { + closeTheIssue(baseURL, token, projectID, issueFound.IID, "No vulnerability found.") + } else { + addCommentToIssue(baseURL, token, projectID, issueFound.IID, vulnMessage) + } + } else if !noVuln { + createIssue(baseURL, token, projectID, title, vulnMessage) + } + slog.Info("GoVulnCheck done.") +} + +func createIssue(baseURL, token, projectID string, title, commentBody string) { + slog.Info("Active issue with title '" + title + "' not found in project " + projectID) + // Create the issue here + issueData := map[string]any{ + "title": title, + "description": commentBody, + "labels": "bot,critical", + // Add other fields as needed + } + issueDataBytes, err := json.Marshal(issueData) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/projects/%s/issues", baseURL, url.PathEscape(projectID)), bytes.NewBuffer(issueDataBytes)) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + req.Header.Add("Private-Token", token) + req.Header.Add("Content-Type", "application/json") + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + var issue Issue + err = json.Unmarshal(body, &issue) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + slog.Info("Issue created with ID " + strconv.Itoa(issue.ID)) +} + +func closeTheIssue(baseURL, token, projectID string, issueIID int, commentBody string) { + addCommentToIssue(baseURL, token, projectID, issueIID, commentBody) + + client := &http.Client{} + issueData := map[string]any{ + "state_event": "close", + } + issueDataBytes, err := json.Marshal(issueData) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + req, err := http.NewRequest(http.MethodPut, fmt.Sprintf("%s/projects/%s/issues/%d", baseURL, url.PathEscape(projectID), issueIID), bytes.NewBuffer(issueDataBytes)) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + req.Header.Add("Private-Token", token) + req.Header.Add("Content-Type", "application/json") + + resp, err := client.Do(req) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + var issue Issue + err = json.Unmarshal(body, &issue) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + slog.Info("Issue " + strconv.Itoa(issue.IID) + " closed") +} + +func addCommentToIssue(baseURL, token, projectID string, issueIID int, commentBody string) { + client := &http.Client{} + noteData := map[string]any{ + "body": commentBody, + } + noteDataBytes, err := json.Marshal(noteData) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/projects/%s/issues/%d/notes", baseURL, url.PathEscape(projectID), issueIID), bytes.NewBuffer(noteDataBytes)) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + req.Header.Add("Private-Token", token) + req.Header.Add("Content-Type", "application/json") + + resp, err := client.Do(req) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + var note Note + err = json.Unmarshal(body, ¬e) + if err != nil { + slog.Error(err.Error()) + os.Exit(1) + } + + slog.Info("Comment added with ID " + strconv.Itoa(note.ID)) +} + +func fetchOpenIssues(projectID string, userID int, accessToken string) ([]Issue, error) { + perPage := 20 // Number of issues to fetch per page + + var allIssues []Issue + page := 1 + + for { + url := fmt.Sprintf("%s/projects/%s/issues?state=opened&author_id=%s&page=%d&per_page=%d", baseURL, projectID, strconv.Itoa(userID), page, perPage) + + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + return nil, err + } + + req.Header.Set("Authorization", "Bearer "+accessToken) + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + var issues []Issue + err = json.Unmarshal(body, &issues) + if err != nil { + return nil, err + } + + allIssues = append(allIssues, issues...) + + // Check if there are more pages + linkHeader := resp.Header.Get("Link") + if !strings.Contains(linkHeader, `rel="next"`) { + break + } + + page++ + } + + return allIssues, nil +} + +func fetchUserID(accessToken string) (int, error) { + url := baseURL + "/user" + + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + return 0, err + } + + req.Header.Set("Authorization", "Bearer "+accessToken) + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + return 0, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return 0, err + } + + var user struct { + ID int `json:"id"` + } + + err = json.Unmarshal(body, &user) + if err != nil { + return 0, err + } + + return user.ID, nil +} + +const hello = ` + _ _ _ + __ _ _____ ___ _| |_ __ ___| |__ ___ ___| | __ + / _` + "`" + ` |/ _ \ \ / / | | | | '_ \ / __| '_ \ / _ \/ __| |/ / +| (_| | (_) \ V /| |_| | | | | | (__| | | | __/ (__| < + \__, |\___/ \_/ \__,_|_|_| |_|\___|_| |_|\___|\___|_|\_\ + |___/ +` diff --git a/configuration/README.md b/configuration/README.md new file mode 100644 index 00000000..7d70ad86 --- /dev/null +++ b/configuration/README.md @@ -0,0 +1,77 @@ +# ![HAProxy](../assets/images/haproxy-weblogo-210x49.png "HAProxy") + +## HAProxy Data Plane API configuration file + +documentation can be seen at [doc](doc/README.md) + +example can be seen [yaml](examples/example-dataplaneapi.yaml) + +full examples of configuration also can be seen at [yaml](examples/example-full.yaml) + +# IMPORTANT information regarding migration from 2.x to 3.0 version + +Some fields in dataplane configuration file are *deprecated* starting from version 3.0. + +They are now moved to Data Plane API internal storage (`dataplane_storage_dir`): [read here](../storage/README.md) + + + +Those fields are the one that were not really dataplane configuration attributes but *dynamic* data (cluster, users...). They are moved to a dataplane internal storage. Hence the dataplane configuration file is not any more updated with states and data and only contains configuration. + +- `dataplaneapi.user` (**only cluster mode users, whose name are starting with `dpapi-c` are migrated**) +- `cluster` +- `service_discovery` +- `status` + +Those data are moved to dataplane internal storage. + + + +## Migration from Dataplane API 2.x to 3.0 behavior + +Data (`user`, `cluster`, `service_discovery`, `status`) that were in Dataplane API configuration file are automatically created in: +- `/service_discovery.json` +- `/cluster.json` + + +## General behavior regarding the deprecated section + +If some of those data are manually updated in Dataplane configuration file (**this should not be done, fields are deprecated**), or if it's the first start of a *3.0* dataplane API: +- A warning log is issued (search for logs having `"[CFG DEPRECATED]`) with `[SKIP]` or `[MIGRATE]` and the category: + - `[User]` or + - `[Cluster]` or + - `[Consul]` or + - `[AWS Region]` or + - `[Status]` + +Below an an example for cluster users: + +``` +time="2024-07-22T09:12:09+02:00" level=warning msg="[CFG DEPRECATED] [SKIP] [User] [dpapi-c-Abr8s1V]: already migrated. Old location [/home/helene/go/src/gitlab.int.haproxy.com/dataplaneapi-ee/.test/etc/dataplaneapi-cluster.yml] New location [/home/helene/go/src/gitlab.int.haproxy.com/dataplaneapi-ee/.test/storage/dataplane/users.json]. Use only new location" +``` +``` +time="2024-07-22T09:12:09+02:00" level=warning msg="[CFG DEPRECATED] [MIGRATE] [User] [dpapi-c-8Mk2Z5UK]: migrating. Old location [/home/helene/go/src/gitlab.int.haproxy.com/dataplaneapi-ee/.test/etc/dataplaneapi-cluster.yml] New location [/home/helene/go/src/gitlab.int.haproxy.com/dataplaneapi-ee/.test/storage/dataplane/users.json]. Use only new location" +``` + +- **After migration, data are removed from the dataplane configuration file.** +- **If a data is added again in the dataplane configuration file, and has already been migrated to the internal storage, then the value from the configuration file is ignored. Only the value from the storage is kept.** + + + +**IMPORTANT NOTE: only cluster mode users, whose name are starting with `dpapi-` are migrated** + + + +## Cluster Mode: deprecation + +The dataplane api configuration field: +- `mode` (values = `single` or `cluster`) + +is now deprecated and this value is removed from dataplane api configuration file after migration. + +The way `cluster` vs `single` is now handled is as following: + +| Mode | /cluster.json content | +|-----------|-------------------| +| Single| `cluster` attribute is empty| +| Cluster| `cluster` attribute is not empty | diff --git a/configuration/bool.go b/configuration/bool.go new file mode 100644 index 00000000..6edd20bd --- /dev/null +++ b/configuration/bool.go @@ -0,0 +1,58 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "sync/atomic" +) + +type AtomicBool struct { + value atomic.Value +} + +func (s *AtomicBool) Load() bool { + v := s.value.Load() + if v == nil { + return false + } + return v.(bool) +} + +func (s *AtomicBool) Store(str bool) { + s.value.Store(str) +} + +func (s *AtomicBool) String() string { + if s.Load() { + return "true" + } + return "false" +} + +func (s *AtomicBool) UnmarshalYAML(unmarshal func(any) error) error { + var buf bool + err := unmarshal(&buf) + if err != nil { + return err + } + + s.Store(buf) + return nil +} + +func (s AtomicBool) MarshalYAML() (any, error) { + return s.Load(), nil +} diff --git a/configuration/cluster_sync.go b/configuration/cluster_sync.go new file mode 100644 index 00000000..dc70b344 --- /dev/null +++ b/configuration/cluster_sync.go @@ -0,0 +1,626 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "bytes" + "context" + "crypto/rand" + "crypto/rsa" + "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/pem" + "errors" + "fmt" + "io" + "net/http" + "path" + "strconv" + "strings" + "time" + + "github.com/google/renameio" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/config-parser/types" + jsoniter "github.com/json-iterator/go" + + "github.com/haproxytech/dataplaneapi/log" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" +) + +const DataplaneAPIType = "community" + +// Node is structure required for connection to cluster +type Node struct { + Facts map[string]string `json:"facts"` + Address string `json:"address"` + APIBasePath string `json:"api_base_path"` + APIPassword string `json:"api_password"` + APIUser string `json:"api_user"` + Certificate string `json:"certificate,omitempty"` + Description string `json:"description,omitempty"` + ID string `json:"id,omitempty"` + Name string `json:"name"` + Status string `json:"status"` + Type string `json:"type"` + Port int64 `json:"port,omitempty"` +} + +// ClusterSync fetches certificates for joining cluster +type ClusterSync struct { + cfg *Configuration + certFetch chan struct{} + cli client_native.HAProxyClient + Context context.Context + ReloadAgent haproxy.IReloadAgent +} + +var expectedResponseCodes = map[string]int{ + "POST": 201, + "PUT": 200, +} + +func (c *ClusterSync) Monitor(cfg *Configuration, cli client_native.HAProxyClient) { + c.cfg = cfg + c.cli = cli + + go c.monitorBootstrapKey() + go c.monitorCertificateRefresh() + + c.certFetch = make(chan struct{}, 2) + go c.fetchCert() + + <-c.cfg.Notify.ServerStarted.Subscribe("clusterMonitor") + + key := c.cfg.Cluster.BootstrapKey.Load() + certFetched := cfg.Cluster.CertificateFetched.Load() + + if key != "" && !certFetched { + c.cfg.Notify.BootstrapKeyChanged.Notify() + } +} + +func (c *ClusterSync) monitorCertificateRefresh() { + for { + select { + case <-c.cfg.Notify.CertificateRefresh.Subscribe("monitorCertificateRefresh"): + log.Info("refreshing certificate") + + key := c.cfg.Cluster.BootstrapKey.Load() + data, err := DecodeBootstrapKey(key) + if err != nil { + log.Warning(err) + continue + } + url := fmt.Sprintf("%s://%s", data["schema"], data["address"]) + + csr, key, err := generateCSR() + if err != nil { + log.Warning(err) + continue + } + err = renameio.WriteFile(path.Join(c.cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s-csr.crt", c.cfg.Name.Load())), []byte(csr), 0o644) + if err != nil { + log.Warning(err) + continue + } + err = c.issueRefreshRequest(url, data["port"], data["api-base-path"], data["path"], csr, key) + if err != nil { + log.Warning(err) + continue + } + case <-c.Context.Done(): + return + } + } +} + +func (c *ClusterSync) issueRefreshRequest(url, port, basePath string, nodesPath string, csr, key string) error { + url = fmt.Sprintf("%s:%s/%s", url, port, strings.TrimLeft(path.Join(basePath, nodesPath, c.cfg.Cluster.ID.Load()), "/")) + apiAddress := c.cfg.APIOptions.APIAddress + if apiAddress == "" { + apiAddress = c.cfg.RuntimeData.Host + } + nodeData := Node{ + ID: c.cfg.Cluster.ID.Load(), + Address: apiAddress, + Certificate: csr, + Status: cfg.Status.Load(), + Type: DataplaneAPIType, + } + json := jsoniter.ConfigCompatibleWithStandardLibrary + bytesRepresentation, _ := json.Marshal(nodeData) + + req, err := http.NewRequest(http.MethodPatch, url, bytes.NewBuffer(bytesRepresentation)) + if err != nil { + return errors.New("error creating new POST request for cluster comunication") + } + req.Header.Add("X-Node-Key", c.cfg.Cluster.Token.Load()) + req.Header.Add("Content-Type", "application/json") + log.Infof("Refreshing certificate %s", url) + httpClient := createHTTPClient() + resp, err := httpClient.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + if resp.StatusCode != http.StatusAccepted { + return fmt.Errorf("status code not proper [%d] %s", resp.StatusCode, string(body)) + } + var responseData Node + err = json.Unmarshal(body, &responseData) + if err != nil { + return err + } + log.Infof("Cluster re joined, status: %s", responseData.Status) + err = renameio.WriteFile(path.Join(c.cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s.crt", c.cfg.Name.Load())), []byte(csr), 0o644) + if err != nil { + log.Warning(err) + return err + } + err = renameio.WriteFile(path.Join(c.cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s.key", c.cfg.Name.Load())), []byte(key), 0o644) + if err != nil { + log.Warning(err) + return err + } + c.cfg.Cluster.Token.Store(resp.Header.Get("X-Node-Key")) + if err = c.cfg.SaveClusterModeData(); err != nil { + log.Warning(err) + return fmt.Errorf("failed to save cluster mode data: %v", err) + } + c.cfg.Notify.Reload.Notify() + return nil +} + +func (c *ClusterSync) monitorBootstrapKey() { + for { + select { + case <-c.cfg.Notify.BootstrapKeyChanged.Subscribe("monitorBootstrapKey"): + log.Warningf("detected change in configured bootstrap key") + key := c.cfg.Cluster.BootstrapKey.Load() + c.cfg.Cluster.CertificateFetched.Store(false) + if key == "" { + // do we need to delete cert here maybe? + log.Warningf("setting bootstrap key to empty") + c.cfg.Cluster.ActiveBootstrapKey.Store("") + err := c.cfg.SaveClusterModeData() + if err != nil { + log.Panic(err) + } + break + } + if key == c.cfg.Cluster.ActiveBootstrapKey.Load() { + if !c.cfg.Cluster.CertificateFetched.Load() { + c.certFetch <- struct{}{} + } + break + } + data, err := DecodeBootstrapKey(key) + if err != nil { + log.Warning(err) + } + // check if storage key is ok + errStorageDir := CheckIfStorageDirIsOK(data["storage-dir"], c.cfg) + if errStorageDir != err { + log.Error(errStorageDir) + continue + } + // Init NOTICE file to inform user that the cluster storage folder is programmatically managed by Fusion API + if errStorageInit := InitStorageNoticeFile(data["storage-dir"]); errStorageInit != nil { + log.Warningf("unable to create notice file, %s: skipping it", errStorageInit.Error()) + } + url := fmt.Sprintf("%s://%s", data["schema"], data["address"]) + c.cfg.Cluster.URL.Store(url) + c.cfg.Cluster.Port.Store(func() int { + i, _ := strconv.Atoi(data["port"]) + return i + }()) + c.cfg.Cluster.APIBasePath.Store(data["api-base-path"]) + registerPath, ok := data["register-path"] + if !ok { + c.cfg.Cluster.APIRegisterPath.Store(data["path"]) + c.cfg.Cluster.APINodesPath.Store(data["path"]) + } else { + c.cfg.Cluster.APIRegisterPath.Store(registerPath) + c.cfg.Cluster.APINodesPath.Store(data["nodes-path"]) + } + c.cfg.Cluster.Name.Store(data["name"]) + c.cfg.Cluster.Description.Store(data["description"]) + c.cfg.Cluster.StorageDir.Store(data["storage-dir"]) + c.cfg.Cluster.ClusterID.Store(data["cluster-id"]) + c.cfg.HAProxy.ClusterTLSCertDir = path.Join(data["storage-dir"], "certs-cluster") + c.cfg.Cluster.CertificateDir.Store(path.Join(data["storage-dir"], "certs-cluster")) + err = c.cfg.SaveClusterModeData() + if err != nil { + log.Panic(err) + } + + if err != nil { + log.Panic(err) + } + csr, key, err := generateCSR() + if err != nil { + log.Warning(err) + break + } + err = renameio.WriteFile(path.Join(c.cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s.key", c.cfg.Name.Load())), []byte(key), 0o644) + if err != nil { + log.Warning(err) + break + } + err = renameio.WriteFile(path.Join(c.cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s-csr.crt", c.cfg.Name.Load())), []byte(csr), 0o644) + if err != nil { + log.Warning(err) + break + } + err = c.cfg.SaveClusterModeData() + if err != nil { + log.Panic(err) + } + registerMerhod := "POST" + if method, ok := data["register-method"]; ok { + registerMerhod = method + } + log.Warningf("issuing cluster join request to cluster %s at %s", data["name"], data["address"]) + userStore := GetUsersStore() + user, pwd, err := misc.CreateClusterUser() + if err != nil { + log.Error(err) + break + } + err = userStore.AddUser(user) + if err != nil { + log.Error(err) + break + } + backOff := 1 + numTries := 0 + maxTries := 10 + for { + err = c.issueJoinRequest(url, data["port"], data["api-base-path"], c.cfg.Cluster.APIRegisterPath.Load(), registerMerhod, csr, key, user, pwd) + if err == nil { + break + } + log.Error(err) + if !misc.IsNetworkErr(err) { + break + } + numTries++ + backOff *= 2 + if backOff > 60 { + backOff = 60 + } + if numTries > maxTries { + log.Error("Joining cluster failed") + break + } + log.Warningf("Joining cluster will be retried after %d seconds [%d/%d]", backOff, numTries, maxTries) + time.Sleep(time.Second * time.Duration(backOff)) + } + if err != nil { + break + } + + if !c.cfg.Cluster.CertificateFetched.Load() { + log.Warningf("starting certificate fetch") + c.certFetch <- struct{}{} + } + case <-c.Context.Done(): + return + } + } +} + +func (c *ClusterSync) issueJoinRequest(url, port, basePath string, registerPath string, registerMethod string, csr, key string, user types.User, userPWD string) error { + url = fmt.Sprintf("%s:%s/%s", url, port, strings.TrimLeft(path.Join(basePath, registerPath), "/")) + apiCfg := c.cfg.APIOptions + + apiAddress := apiCfg.APIAddress + if apiAddress == "" { + apiAddress = c.cfg.RuntimeData.Host + } + apiPort := apiCfg.APIPort + if apiPort == 0 { + apiPort = int64(c.cfg.RuntimeData.Port) + } + + nodeData := Node{ + // ID: "", + Address: apiAddress, + APIBasePath: c.cfg.RuntimeData.APIBasePath, + APIPassword: userPWD, + APIUser: user.Name, + Certificate: csr, + Description: "", + Name: c.cfg.Name.Load(), + Port: apiPort, + Status: "waiting_approval", + Type: DataplaneAPIType, + } + nodeData.Facts = c.getNodeFacts() + + json := jsoniter.ConfigCompatibleWithStandardLibrary + bytesRepresentation, _ := json.Marshal(nodeData) + + req, err := http.NewRequest(registerMethod, url, bytes.NewBuffer(bytesRepresentation)) + if err != nil { + return fmt.Errorf("error creating new %s request for cluster comunication", registerMethod) + } + req.Header.Add("X-Bootstrap-Key", c.cfg.Cluster.BootstrapKey.Load()) + req.Header.Add("Content-Type", "application/json") + log.Infof("Joining cluster %s", url) + httpClient := createHTTPClient() + resp, err := httpClient.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + if resp.StatusCode != expectedResponseCodes[registerMethod] { + return fmt.Errorf("invalid status code [%d] %s", resp.StatusCode, string(body)) + } + log.Warningf("success sending local info, joining in progress") + var responseData Node + err = json.Unmarshal(body, &responseData) + if err != nil { + return err + } + if c.cfg.HAProxy.NodeIDFile != "" { + configuration, errCfg := c.cli.Configuration() + if errCfg != nil { + return errCfg + } + // write id to file + errFID := renameio.WriteFile(c.cfg.HAProxy.NodeIDFile, []byte(responseData.ID), 0o644) + if errFID != nil { + return errFID + } + version, errVersion := configuration.GetVersion("") + if errVersion != nil || version < 1 { + // silently fallback to 1 + version = 1 + } + t, err1 := configuration.StartTransaction(version) + if err1 != nil { + return err1 + } + // write id to peers + _, peerSections, errorGet := configuration.GetPeerSections(t.ID) + if errorGet != nil { + return errorGet + } + peerFound := false + dataplaneID := c.cfg.Cluster.ID.Load() + if dataplaneID == "" { + dataplaneID = "localhost" + } + for _, section := range peerSections { + _, peerEntries, err1 := configuration.GetPeerEntries(section.Name, t.ID) + if err1 != nil { + return err1 + } + for _, peer := range peerEntries { + if peer.Name == dataplaneID { + peerFound = true + peer.Name = responseData.ID + errEdit := configuration.EditPeerEntry(dataplaneID, section.Name, peer, t.ID, 0) + if errEdit != nil { + _ = configuration.DeleteTransaction(t.ID) + return err + } + } + } + } + if !peerFound { + _ = configuration.DeleteTransaction(t.ID) + return fmt.Errorf("peer [%s] not found in HAProxy config", dataplaneID) + } + _, err = configuration.CommitTransaction(t.ID) + if err != nil { + return err + } + // restart HAProxy + errRestart := c.ReloadAgent.Restart() + if errRestart != nil { + return errRestart + } + } + c.cfg.Cluster.ID.Store(responseData.ID) + c.cfg.Cluster.Name.Store(responseData.Name) + c.cfg.Cluster.Token.Store(resp.Header.Get("X-Node-Key")) + c.cfg.Cluster.ActiveBootstrapKey.Store(c.cfg.Cluster.BootstrapKey.Load()) + log.Warning("cluster joined") + _, err = c.checkCertificate(responseData) + if err != nil { + return err + } + return c.cfg.SaveClusterModeData() +} + +// checkCertificate checks if we have received valid certificate or we just got CSR back +// +// two options are possible here: +// -----BEGIN CERTIFICATE----- or -----BEGIN CERTIFICATE REQUEST----- +func (c *ClusterSync) checkCertificate(node Node) (fetched bool, err error) { + if !strings.HasPrefix(node.Certificate, "-----BEGIN CERTIFICATE-----") { + c.cfg.Status.Store(StatusUnconfigured) + return false, nil + } + err = renameio.WriteFile(path.Join(c.cfg.GetClusterCertDir(), fmt.Sprintf("dataplane-%s.crt", c.cfg.Name.Load())), []byte(node.Certificate), 0o644) + if err != nil { + c.cfg.Status.Store(StatusUnconfigured) + return false, err + } + c.cfg.Cluster.CertificateFetched.Store(true) + c.cfg.Notify.Reload.Notify() + c.cfg.Status.Store(StatusActive) + return true, nil +} + +func (c *ClusterSync) activateFetchCert(err error) { + go func(err error) { + log.Warning(err) + time.Sleep(1 * time.Minute) + if !c.cfg.Cluster.CertificateFetched.Load() { + c.certFetch <- struct{}{} + } + }(err) +} + +func (c *ClusterSync) fetchCert() { + for { + select { + case <-c.Context.Done(): + close(c.certFetch) + return + case <-c.certFetch: + key := c.cfg.Cluster.BootstrapKey.Load() + if key == "" || c.cfg.Cluster.Token.Load() == "" { + break + } + // if not, sleep and start all over again + certFetched := c.cfg.Cluster.CertificateFetched.Load() + if !certFetched { + url := c.cfg.Cluster.URL.Load() + port := c.cfg.Cluster.Port.Load() + apiBasePath := c.cfg.Cluster.APIBasePath.Load() + apiNodesPath := c.cfg.Cluster.APINodesPath.Load() + id := c.cfg.Cluster.ID.Load() + url = fmt.Sprintf("%s:%d/%s", url, port, strings.TrimLeft(path.Join(apiBasePath, apiNodesPath, id), "/")) + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + c.activateFetchCert(err) + break + } + req.Header.Add("X-Node-Key", c.cfg.Cluster.Token.Load()) + req.Header.Add("Content-Type", "application/json") + httpClient := createHTTPClient() + resp, err := httpClient.Do(req) + if err != nil { + c.activateFetchCert(err) + break + } + body, err := io.ReadAll(resp.Body) + resp.Body.Close() + if err != nil { + c.activateFetchCert(err) + break + } + if resp.StatusCode != http.StatusOK { + c.activateFetchCert(fmt.Errorf("status code not proper [%d] %s", resp.StatusCode, string(body))) + break + } + var responseData Node + json := jsoniter.ConfigCompatibleWithStandardLibrary + err = json.Unmarshal(body, &responseData) + if err != nil { + c.activateFetchCert(err) + break + } + log.Warningf("Fetching certificate, status: %s", responseData.Status) + + certFetched, err = c.checkCertificate(responseData) + if err != nil { + log.Warning(err.Error()) + break + } + err = c.cfg.SaveClusterModeData() + if err != nil { + log.Warning(err) + } + } + if !certFetched { + time.AfterFunc(time.Minute, func() { + if !c.cfg.Cluster.CertificateFetched.Load() { + log.Warningf("retrying certificate fetch") + c.certFetch <- struct{}{} + } + }) + } + } + } +} + +func generateCSR() (string, string, error) { + keyBytes, _ := rsa.GenerateKey(rand.Reader, 2048) + + oidEmailAddress := asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 1} + emailAddress := "test@example.com" + subj := pkix.Name{ + CommonName: "haproxy.com", + Country: []string{"US"}, + Province: []string{""}, + Locality: []string{"Waltham"}, + Organization: []string{"HAProxy Technologies LLC"}, + OrganizationalUnit: []string{"IT"}, + ExtraNames: []pkix.AttributeTypeAndValue{ + { + Type: oidEmailAddress, + Value: asn1.RawValue{ + Tag: asn1.TagIA5String, + Bytes: []byte(emailAddress), + }, + }, + }, + } + + template := x509.CertificateRequest{ + Subject: subj, + SignatureAlgorithm: x509.SHA256WithRSA, + } + csrBytes, _ := x509.CreateCertificateRequest(rand.Reader, &template, keyBytes) + var buf bytes.Buffer + err := pem.Encode(&buf, &pem.Block{Type: "CERTIFICATE REQUEST", Bytes: csrBytes}) + if err != nil { + return "", "", err + } + + caPrivKeyPEMBuff := new(bytes.Buffer) + err = pem.Encode(caPrivKeyPEMBuff, &pem.Block{ + Type: "RSA PRIVATE KEY", + Bytes: x509.MarshalPKCS1PrivateKey(keyBytes), + }) + if err != nil { + return "", "", err + } + return buf.String(), caPrivKeyPEMBuff.String(), err +} + +func createHTTPClient() *http.Client { + client := &http.Client{ + Transport: &http.Transport{ + MaxIdleConnsPerHost: 20, + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: true, // this is deliberate, might only have self signed certificate + }, + }, + Timeout: time.Duration(30) * time.Second, + } + return client +} diff --git a/configuration/cluster_sync_helpers.go b/configuration/cluster_sync_helpers.go new file mode 100644 index 00000000..71de55c6 --- /dev/null +++ b/configuration/cluster_sync_helpers.go @@ -0,0 +1,48 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "os" + + "github.com/haproxytech/dataplaneapi/log" +) + +func (c *ClusterSync) getNodeFacts() map[string]string { + facts := map[string]string{} + + // report the dataplane_cmdline if started from within haproxy + if c.cfg.HAProxy.MasterWorkerMode || os.Getenv("HAPROXY_MWORKER") == "1" { + facts["dataplane_cmdline"] = c.cfg.Cmdline.String() + } + + runtime, err := c.cli.Runtime() + if err != nil { + log.Errorf("unable to fetch processInfo: %s", err.Error()) + return facts + } + processInfo, err := runtime.GetInfo() + if err != nil { + log.Error("unable to fetch processInfo") + } else { + if processInfo.Info != nil { + facts["haproxy_version"] = processInfo.Info.Version + } else { + log.Error("empty process info") + } + } + return facts +} diff --git a/configuration/configuration.go b/configuration/configuration.go new file mode 100644 index 00000000..e8d20fde --- /dev/null +++ b/configuration/configuration.go @@ -0,0 +1,396 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "encoding/json" + "errors" + "fmt" + "io/fs" + "os" + "path/filepath" + "strings" + "sync" + "time" + + petname "github.com/dustinkirkland/golang-petname" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/storage" + "github.com/haproxytech/dataplaneapi/storagetype" + jsoniter "github.com/json-iterator/go" +) + +var cfg *Configuration + +type HAProxyConfiguration struct { + SpoeDir string `long:"spoe-dir" description:"Path to SPOE directory." default:"/etc/haproxy/spoe" group:"resources"` + ServiceName string `long:"service" description:"Name of the HAProxy service" group:"reload"` + HAProxy string `short:"b" long:"haproxy-bin" description:"Path to the haproxy binary file" default:"haproxy" group:"haproxy"` + UserListFile string `long:"userlist-file" description:"Path to the dataplaneapi userlist file. By default userlist is read from HAProxy conf. When specified userlist would be read from this file" group:"userlist"` + ReloadCmd string `short:"r" long:"reload-cmd" description:"Reload command" group:"reload"` + RestartCmd string `short:"s" long:"restart-cmd" description:"Restart command" group:"reload"` + StatusCmd string `long:"status-cmd" description:"Status command" group:"reload"` + NodeIDFile string `long:"fid" description:"Path to file that will dataplaneapi use to write its id (not a pid) that was given to him after joining a cluster" group:"haproxy"` + PIDFile string `long:"pid-file" description:"Path to file that will dataplaneapi use to write its pid" group:"dataplaneapi" example:"/tmp/dataplane.pid"` + ReloadStrategy string `long:"reload-strategy" description:"Either systemd, s6 or custom" default:"custom" group:"reload"` + TransactionDir string `short:"t" long:"transaction-dir" description:"Path to the transaction directory" default:"/tmp/haproxy" group:"transaction"` + ValidateCmd string `long:"validate-cmd" description:"Executes a custom command to perform the HAProxy configuration check" group:"reload"` + BackupsDir string `long:"backups-dir" description:"Path to directory in which to place backup files" group:"transaction"` + MapsDir string `short:"p" long:"maps-dir" description:"Path to directory of map files managed by dataplane" default:"/etc/haproxy/maps" group:"resources"` + SpoeTransactionDir string `long:"spoe-transaction-dir" description:"Path to the SPOE transaction directory" default:"/tmp/spoe-haproxy" group:"resources"` + DataplaneConfig string `short:"f" description:"Path to the dataplane configuration file" default:"/etc/haproxy/dataplaneapi.yaml" yaml:"-"` + ConfigFile string `short:"c" long:"config-file" description:"Path to the haproxy configuration file" default:"/etc/haproxy/haproxy.cfg" group:"haproxy"` + Userlist string `short:"u" long:"userlist" description:"Userlist in HAProxy configuration to use for API Basic Authentication" default:"controller" group:"userlist"` + MasterRuntime string `short:"m" long:"master-runtime" description:"Path to the master Runtime API socket" group:"haproxy"` + SSLCertsDir string `long:"ssl-certs-dir" description:"Path to SSL certificates directory" default:"/etc/haproxy/ssl" group:"resources"` + GeneralStorageDir string `long:"general-storage-dir" description:"Path to general storage directory" default:"/etc/haproxy/general" group:"resources"` + ClusterTLSCertDir string `long:"cluster-tls-dir" description:"Path where cluster tls certificates will be stored. Defaults to same directory as dataplane configuration file" group:"cluster"` + DataplaneStorageDir string `long:"dataplane-storage-dir" description:"Path to dataplane internal storage directory" default:"/etc/haproxy/dataplane" group:"resources"` + PreferredTimeSuffix string `long:"time-suffix" description:"Preferred time unit to use when writing time values in configuration (nearest, none, ms, s, m, h, d)" default:"nearest" group:"haproxy"` + UpdateMapFilesPeriod int64 `long:"update-map-files-period" description:"Elapsed time in seconds between two maps syncing operations" default:"10" group:"resources"` + ReloadDelay int `short:"d" long:"reload-delay" description:"Minimum delay between two reloads (in s)" default:"5" group:"reload"` + MaxOpenTransactions int64 `long:"max-open-transactions" description:"Limit for active transaction in pending state" default:"20" group:"transaction"` + BackupsNumber int `short:"n" long:"backups-number" description:"Number of backup configuration files you want to keep, stored in the config dir with version number suffix" default:"0" group:"transaction"` + ReloadRetention int `long:"reload-retention" description:"Reload retention in days, every older reload id will be deleted" default:"1" group:"reload"` + UID int `long:"uid" description:"User id value to set on start" group:"dataplaneapi" example:"1000"` + GID int `long:"gid" description:"Group id value to set on start" group:"dataplaneapi" example:"1000"` + UpdateMapFiles bool `long:"update-map-files" description:"Flag used for syncing map files with runtime maps values" group:"resources"` + ShowSystemInfo bool `short:"i" long:"show-system-info" description:"Show system info on info endpoint" group:"dataplaneapi"` + MasterWorkerMode bool `long:"master-worker-mode" description:"Flag to enable helpers when running within HAProxy" group:"haproxy"` + DisableInotify bool `long:"disable-inotify" description:"Disables inotify watcher for the configuration file" group:"dataplaneapi"` + DebugSocketPath string `long:"debug-socket-path" description:"Unix socket path for the debugging command socket" group:"dataplaneapi"` + DelayedStartMax time.Duration `long:"delayed-start-max" description:"Maximum duration to wait for the haproxy runtime socket to be ready" default:"30s" group:"haproxy"` + DelayedStartTick time.Duration `long:"delayed-start-tick" description:"Duration between checks for the haproxy runtime socket to be ready" default:"500ms" group:"haproxy"` +} + +type User struct { + Name string `long:"name" description:"User name" group:"user" example:"admin"` + Password string `long:"password" description:"password" group:"user" example:"adminpwd"` + Insecure bool `long:"insecure" description:"insecure password" group:"user" example:"true"` +} + +type APIConfiguration struct { + APIAddress string `long:"api-address" description:"Advertised API address" group:"advertised" yaml:"address" example:"10.2.3.4" save:"true"` + APIPort int64 `long:"api-port" description:"Advertised API port" group:"advertised" yaml:"port" example:"80" save:"true"` +} + +type ClusterConfiguration struct { + APIRegisterPath AtomicString `yaml:"api_register_path,omitempty" group:"cluster" save:"true"` + APIBasePath AtomicString `yaml:"api_base_path,omitempty" group:"cluster" save:"true"` + ActiveBootstrapKey AtomicString `yaml:"active_bootstrap_key,omitempty" group:"cluster" save:"true"` + Token AtomicString `yaml:"token,omitempty" group:"cluster" save:"true"` + ID AtomicString `yaml:"id,omitempty" group:"cluster" save:"true"` + Port AtomicInt `yaml:"port,omitempty" group:"cluster" save:"true"` + BootstrapKey AtomicString `yaml:"bootstrap_key,omitempty" group:"cluster" save:"true"` + APINodesPath AtomicString `yaml:"api_nodes_path,omitempty" group:"cluster" save:"true"` + URL AtomicString `yaml:"url,omitempty" group:"cluster" save:"true"` + StorageDir AtomicString `yaml:"storage_dir,omitempty" group:"cluster" save:"true"` + CertificateDir AtomicString `yaml:"cert_path,omitempty" group:"cluster" save:"true"` + CertificateFetched AtomicBool `yaml:"cert_fetched,omitempty" group:"cluster" save:"true" example:"false"` + Name AtomicString `yaml:"name,omitempty" group:"cluster" save:"true"` + Description AtomicString `yaml:"description,omitempty" group:"cluster" save:"true"` + ClusterID AtomicString `yaml:"cluster_id,omitempty" group:"cluster" save:"true"` + ClusterLogTargets []*models.ClusterLogTarget `yaml:"cluster_log_targets,omitempty" group:"cluster" save:"true"` +} + +func (c *ClusterConfiguration) Clear() { + c.ID.Store("") + c.ActiveBootstrapKey.Store("") + c.Token.Store("") + c.Port.Store(0) + c.APIBasePath.Store("") + c.APINodesPath.Store("") + c.APIRegisterPath.Store("") + c.CertificateFetched.Store(false) + c.Name.Store("") + c.Description.Store("") + c.ClusterID.Store("") + c.ClusterLogTargets = nil + c.URL.Store("") + c.StorageDir.Store("") + c.CertificateDir.Store("") +} + +type RuntimeData struct { + Host string + APIBasePath string + Port int +} + +type NotifyConfiguration struct { + BootstrapKeyChanged *ChanNotify `yaml:"-"` + ServerStarted *ChanNotify `yaml:"-"` + CertificateRefresh *ChanNotify `yaml:"-"` + Reload *ChanNotify `yaml:"-"` + Shutdown *ChanNotify `yaml:"-"` +} + +type ServiceDiscovery struct { + Consuls []*models.Consul `yaml:"consuls" group:"service_discovery" save:"true"` + AWSRegions []*models.AwsRegion `yaml:"aws-regions" group:"service_discovery" save:"true"` + consulMu sync.Mutex + awsMu sync.Mutex +} + +//nolint:staticcheck +type Configuration struct { + Cluster ClusterConfiguration `yaml:"-"` + Notify NotifyConfiguration `yaml:"-"` + Mode AtomicString `yaml:"mode" default:"single"` + storage Storage `yaml:"-"` + clusterModeStorage storage.ClusterModeStorage `yaml:"-"` + sdConsulStorage storage.SDConsulStorage `yaml:"-"` + sdAWSRegionStorage storage.SDAWStorage `yaml:"-"` + Name AtomicString `yaml:"name" example:"famous_condor"` + Cmdline AtomicString `yaml:"-"` + Status AtomicString `yaml:"status,omitempty"` + DeprecatedBootstrapKey AtomicString `yaml:"bootstrap_key,omitempty" deprecated:"true"` + reloadSignal chan os.Signal + shutdownSignal chan os.Signal + MapSync *MapSync `yaml:"-"` + Syslog log.SyslogOptions `yaml:"-"` + Logging log.LoggingOptions `yaml:"-"` + RuntimeData RuntimeData `yaml:"-"` + ServiceDiscovery ServiceDiscovery `yaml:"-"` + Users []User `yaml:"-"` + APIOptions APIConfiguration `yaml:"-"` + LogTargets log.Targets `yaml:"log_targets,omitempty" group:"log"` + HAProxy HAProxyConfiguration `yaml:"-"` + FlagLoadDapiStorageData bool `yaml:"-"` + mutex sync.Mutex +} + +var cfgInitOnce sync.Once + +// Get returns pointer to configuration +func Get() *Configuration { + cfgInitOnce.Do(func() { + cfg = &Configuration{} + cfg.Notify.BootstrapKeyChanged = NewChanNotify() + cfg.Notify.ServerStarted = NewChanNotify() + cfg.Notify.CertificateRefresh = NewChanNotify() + cfg.Notify.Reload = NewChanNotify() + cfg.Notify.Shutdown = NewChanNotify() + cfg.MapSync = NewMapSync() + + var sb strings.Builder + for _, v := range os.Args { + if !strings.HasPrefix(v, "-") && !strings.Contains(v, `\ `) && strings.ContainsAny(v, " ") { + fmt.Fprintf(&sb, "\"%s\" ", v) + } else { + fmt.Fprintf(&sb, "%s ", v) + } + } + + cfg.Cmdline.Store(sb.String()) + }) + return cfg +} + +func (c *Configuration) GetStorageData() *StorageDataplaneAPIConfiguration { + return c.storage.Get() +} + +func (c *Configuration) GetClusterModeStorage() storage.ClusterModeStorage { + return c.clusterModeStorage +} + +func (c *Configuration) GetUsers() storagetype.Users { + // SingleModeUsers + ClusterModeUsers + // ClusterMode users + users := c.clusterModeStorage.GetUsers() + // SingleMode users + for _, user := range c.Users { + found := false + for _, cmUser := range users { + if cmUser.Name == user.Name { + found = true + break + } + } + pwd := user.Password + insecure := user.Insecure + if !found { + users = append(users, storagetype.User{ + Name: user.Name, + Password: &pwd, + Insecure: &insecure, + }) + } + } + return users +} + +func (c *Configuration) UnSubscribeAll() { + c.Notify.BootstrapKeyChanged.UnSubscribeAll() + c.Notify.ServerStarted.UnSubscribeAll() + c.Notify.CertificateRefresh.UnSubscribeAll() + c.Notify.Reload.UnSubscribeAll() + c.Notify.Shutdown.UnSubscribeAll() +} + +func (c *Configuration) Load() ([]string, error) { + c.mutex.Lock() + defer c.mutex.Unlock() + + var err error + deprecationInfoMsg := make([]string, 0) + if c.HAProxy.DataplaneConfig == "" { + c.storage = &StorageDummy{} + _ = c.storage.Load("") + } else { + c.storage = &StorageYML{} + if err = c.storage.Load(c.HAProxy.DataplaneConfig); err != nil { + if errors.Is(err, fs.ErrNotExist) { + fmt.Printf("configuration file %s does not exists, creating one\n", c.HAProxy.DataplaneConfig) + } else { + return deprecationInfoMsg, fmt.Errorf("configuration file %s not valid (only yaml format is supported): %w", c.HAProxy.DataplaneConfig, err) + } + } + } + + copyToConfiguration(c) + + if c.FlagLoadDapiStorageData { + deprecationInfoMsg, err = c.LoadDataplaneStorageConfig() + if err != nil { + return deprecationInfoMsg, err + } + } + + if c.Name.Load() == "" { + hostname, nameErr := os.Hostname() + if nameErr != nil { + fmt.Printf("Error fetching hostname, using petname for dataplaneapi name: %s\n", nameErr.Error()) + c.Name.Store(petname.Generate(2, "_")) + } + c.Name.Store(hostname) + } + + if err = validateReloadConfiguration(&c.HAProxy); err != nil { + return deprecationInfoMsg, err + } + + return deprecationInfoMsg, nil +} + +func (c *Configuration) LoadDataplaneStorageConfig() ([]string, error) { + var err error + var deprecationInfoMsg []string + + //-------------------- + // Load from dataplane storage cluster.json: users, cluster, service_discovery + // It has to be after copyToConfiguration as it needs the dataplaneapi_storage_path + //-------------------- + if err = c.loadClusterModeData(); err != nil { + return deprecationInfoMsg, err + } + if err = c.loadSDConsuls(); err != nil { + return deprecationInfoMsg, err + } + if err = c.loadSDAWSRegions(); err != nil { + return deprecationInfoMsg, err + } + + //-------------------- + // Deprecated fields migration + //-------------------- + deprecationInfoMsg, err = c.migrateDeprecatedFields() + if err != nil { + return deprecationInfoMsg, err + } + + if c.clusterModeStorage.IsClusterMode() { + c.Mode.Store(ModeCluster) + } else { + c.Mode.Store(ModeSingle) + } + log.Debugf("Mode: %s", c.Mode.Load()) + return deprecationInfoMsg, err +} + +func (c *Configuration) LoadRuntimeVars(swaggerJSON json.RawMessage, host string, port int) error { + var m map[string]any + json := jsoniter.ConfigCompatibleWithStandardLibrary + err := json.Unmarshal(swaggerJSON, &m) + if err != nil { + return err + } + + cfg.RuntimeData.APIBasePath = m["basePath"].(string) + if host == "localhost" { + host = "127.0.0.1" + } + cfg.RuntimeData.Host = host + cfg.RuntimeData.Port = port + + return nil +} + +func (c *Configuration) Save() error { + c.mutex.Lock() + defer c.mutex.Unlock() + + copyConfigurationToStorage(c) + if len(c.LogTargets) == 0 { + cfg := c.storage.Get() + cfg.LogTargets = nil + } + // clean storage data if we are not in cluster mode or preparing to go into that mode + if c.Mode.Load() != ModeCluster && c.Cluster.BootstrapKey.Load() == "" { + storage := c.storage.Get() + storage.DeprecatedCluster = nil + } + + // dataplane storage + if err := c.SaveClusterModeData(); err != nil { + return err + } + if err := c.SaveSDConsuls(); err != nil { + return err + } + + return c.storage.Save() +} + +func (c *Configuration) GetClusterCertDir() string { + dir := c.Cluster.CertificateDir.Load() + if dir == "" { + dir = c.HAProxy.ClusterTLSCertDir + } + if dir == "" { + // use same dir as dataplane config file + url := c.HAProxy.DataplaneConfig + dir = filepath.Dir(url) + } + return dir +} + +func (c *Configuration) SaveConsuls(consuls []*models.Consul) error { + c.ServiceDiscovery.consulMu.Lock() + defer c.ServiceDiscovery.consulMu.Unlock() + c.ServiceDiscovery.Consuls = consuls + return c.SaveSDConsuls() +} + +func (c *Configuration) SaveAWS(aws []*models.AwsRegion) error { + c.ServiceDiscovery.awsMu.Lock() + defer c.ServiceDiscovery.awsMu.Unlock() + + c.ServiceDiscovery.AWSRegions = aws + return c.SaveSDAWSRegions() +} diff --git a/configuration/configuration_deprecated.go b/configuration/configuration_deprecated.go new file mode 100644 index 00000000..c0120245 --- /dev/null +++ b/configuration/configuration_deprecated.go @@ -0,0 +1,298 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "fmt" + "path" + + "github.com/haproxytech/dataplaneapi/storage" + "github.com/haproxytech/dataplaneapi/storagetype" +) + +func (c *Configuration) migrateDeprecatedFields() ([]string, error) { + if c.DeprecatedBootstrapKey.Load() != "" { + c.Cluster.BootstrapKey.Store(c.DeprecatedBootstrapKey.Load()) + } + + deprecationInfoMsg := make([]string, 0) + + // Users + deprMsgUsers, err := c.migrateUsers() + deprecationInfoMsg = append(deprecationInfoMsg, deprMsgUsers...) + if err != nil { + return deprecationInfoMsg, err + } + + // Cluster + deprMsgCluster, err := c.migrateCluster() + deprecationInfoMsg = append(deprecationInfoMsg, deprMsgCluster...) + if err != nil { + return deprecationInfoMsg, err + } + + // Service Discovery Consuls + deprMsgConsuls, err := c.migrateSDConsuls() + deprecationInfoMsg = append(deprecationInfoMsg, deprMsgConsuls...) + if err != nil { + return deprecationInfoMsg, err + } + + // Service Discovery AWS Regions + deprMsgAwsRegions, err := c.migrateSDAwsRegions() + deprecationInfoMsg = append(deprecationInfoMsg, deprMsgAwsRegions...) + if err != nil { + return deprecationInfoMsg, err + } + + // Remove deprecated fields after migration + c.storage.Get().emptyDeprecatedSections() + + return deprecationInfoMsg, nil +} + +func (c *Configuration) migrateUsers() ([]string, error) { + deprecationInfoMsg := make([]string, 0) + dapiCfgStorage := c.storage.Get() + + // Users + dapiStorageUsers := c.clusterModeStorage.GetUsers() + clusterModeStoragePath := path.Join(c.HAProxy.DataplaneStorageDir, storage.ClusterModeDataFileName) + + usersToMigrate := make([]storagetype.User, 0) + if dapiCfgStorage.Dataplaneapi != nil { + for _, singleModeUser := range dapiCfgStorage.Dataplaneapi.Users { + found := false + // Only migrate cluster users + if !singleModeUser.IsClusterUser() { + continue + } + + var muser storagetype.User + for _, muser = range dapiStorageUsers { + if muser.Name == singleModeUser.Name { + found = true + break + } + } + + // Already migrated + if found { + msg := fmt.Sprintf("[CFG DEPRECATED] [SKIP] [User] [%s]: already migrated. Old location [%s] New location [%s]. Use only new location", + singleModeUser.Name, + c.HAProxy.DataplaneConfig, + clusterModeStoragePath) + // Logging is not done here as at startup, the logger is not yet initialized + // so it's done later on + deprecationInfoMsg = append(deprecationInfoMsg, msg) + } else { + // If not already migrated, then migrate it + msg := fmt.Sprintf("[CFG DEPRECATED] [MIGRATE] [User] [%s]: migrating. Old location [%s] New location [%s]. Use only new location", + singleModeUser.Name, + c.HAProxy.DataplaneConfig, + clusterModeStoragePath) + // Logging is not done here as at startup, the logger is not yet initialized + // so it's done later on + deprecationInfoMsg = append(deprecationInfoMsg, msg) + usersToMigrate = append(usersToMigrate, singleModeUser) + } + } + } + if err := c.clusterModeStorage.AddUsersAndStore(usersToMigrate); err != nil { + return deprecationInfoMsg, err + } + return deprecationInfoMsg, nil +} + +func (c *Configuration) migrateCluster() ([]string, error) { + deprecationInfoMsg := make([]string, 0) + + dapiCfgStorage := c.storage.Get() + dapiStorageCluster := c.clusterModeStorage.GetCluster() + clusterStoragePath := path.Join(c.HAProxy.DataplaneStorageDir, storage.ClusterModeDataFileName) + var alreadyMigrated bool + + // Status + dapiCfgStatus := dapiCfgStorage.DeprecatedStatus + dapiStorageStatus := c.clusterModeStorage.GetStatus() + if dapiCfgStatus != nil { + alreadyMigrated = dapiStorageStatus != nil && *dapiStorageStatus != "" + if alreadyMigrated { + deprecationInfoMsg = append(deprecationInfoMsg, + fmt.Sprintf("[CFG DEPRECATED] [SKIP] [Status]: already migrated. Old location [%s] New location [%s]. Use only new location", + c.HAProxy.DataplaneConfig, + clusterStoragePath)) + } else { + deprecationInfoMsg = append(deprecationInfoMsg, + fmt.Sprintf("[CFG DEPRECATED] [MIGRATE] [Status]: migrating. Old location [%s] New location [%s]. Use only new location", + c.HAProxy.DataplaneConfig, + clusterStoragePath)) + // not already migrated + c.Status.Store(*dapiCfgStatus) + c.clusterModeStorage.SetStatusAndStore(dapiCfgStatus) + } + } + + // Nothing in dapi configuration file + dapiCfgCluster := dapiCfgStorage.DeprecatedCluster + if dapiCfgCluster == nil { + return deprecationInfoMsg, nil + } + + // Comparing on Bootstrap Key + alreadyMigrated = isAlreadyMigrated(dapiCfgCluster, dapiStorageCluster) + if alreadyMigrated { + // If we have a cluster in dapi configuration file (deprecated) + // We do not try to check if there was any change between dapi config file and storage, we skip + deprecationInfoMsg = append(deprecationInfoMsg, + fmt.Sprintf("[CFG DEPRECATED] [SKIP] [Cluster] [%s]: already migrated. Old location [%s] New location [%s]. Use only new location", + dapiStorageCluster.LogDisplayName(), + c.HAProxy.DataplaneConfig, + clusterStoragePath)) + } else { + // If not already migrated, then migrate it + deprecationInfoMsg = append(deprecationInfoMsg, + fmt.Sprintf("[CFG DEPRECATED] [MIGRATE] [Cluster] [%s]: migrating. Old location [%s] New location [%s]. Use only new location", + dapiCfgCluster.LogDisplayName(), + c.HAProxy.DataplaneConfig, + clusterStoragePath)) + + if err := c.clusterModeStorage.SetClusterAndStore(dapiCfgCluster); err != nil { + return deprecationInfoMsg, err + } + // Then udpate cluster in configuration too + c.copyClusterToConfiguration(dapiCfgCluster) + } + + return deprecationInfoMsg, nil +} + +func isAlreadyMigrated(dapiCfgCluster *storagetype.Cluster, dapiStorageCluster *storagetype.Cluster) bool { + if dapiStorageCluster == nil || dapiCfgCluster == nil { + return false + } + if dapiStorageCluster.BootstrapKey != nil && dapiCfgCluster.BootstrapKey != nil && *dapiStorageCluster.BootstrapKey == *dapiCfgCluster.BootstrapKey { + return true + } + return false +} + +func (c *Configuration) migrateSDConsuls() ([]string, error) { + deprecationInfoMsg := make([]string, 0) + + dapiCfgStorage := c.storage.Get() + dapiStorageConsuls := c.sdConsulStorage.GetConsuls() + consulsStoragePath := path.Join(c.HAProxy.DataplaneStorageDir, storage.ConsulFileName) + + consulsToMigrate := make(storagetype.Consuls, 0) + if dapiCfgStorage.DeprecatedServiceDiscovery == nil || dapiCfgStorage.DeprecatedServiceDiscovery.Consuls == nil { + return deprecationInfoMsg, nil + } + for _, cfgConsul := range *dapiCfgStorage.DeprecatedServiceDiscovery.Consuls { + found := false + // Check done on ID + for _, dapiStorageConsul := range dapiStorageConsuls { + if dapiStorageConsul.ID != nil && cfgConsul.ID != nil && + *dapiStorageConsul.ID == *cfgConsul.ID { + found = true + break + } + } + + consulID := "" + if cfgConsul.ID != nil { + consulID = *cfgConsul.ID + } + // Already migrated + if found { + msg := fmt.Sprintf("[CFG DEPRECATED] [SKIP] [Consul] [%s]: already migrated. Old location [%s] New location [%s]. Use only new location", + consulID, + c.HAProxy.DataplaneConfig, + consulsStoragePath) + // Logging is not done here as at startup, the logger is not yet initialized + // so it's done later on + deprecationInfoMsg = append(deprecationInfoMsg, msg) + } else { + // If not already migrated, then migrate it + msg := fmt.Sprintf("[CFG DEPRECATED] [MIGRATE] [Consul] [%s]: migrating. Old location [%s] New location [%s]. Use only new location", + consulID, + c.HAProxy.DataplaneConfig, + consulsStoragePath) + // Logging is not done here as at startup, the logger is not yet initialized + // so it's done later on + deprecationInfoMsg = append(deprecationInfoMsg, msg) + consulsToMigrate = append(consulsToMigrate, cfgConsul) + } + } + if err := c.sdConsulStorage.AddConsulsAndStore(consulsToMigrate); err != nil { + return deprecationInfoMsg, err + } + c.ServiceDiscovery.Consuls = append(c.ServiceDiscovery.Consuls, consulsToMigrate...) + return deprecationInfoMsg, nil +} + +func (c *Configuration) migrateSDAwsRegions() ([]string, error) { + deprecationInfoMsg := make([]string, 0) + + dapiCfgStorage := c.storage.Get() + dapiStorageAwsRegions := c.sdAWSRegionStorage.GetAWSRegions() + awsRegionsStoragePath := path.Join(c.HAProxy.DataplaneStorageDir, storage.AWSRegionFileName) + + awsRegionssToMigrate := make(storagetype.AWSRegions, 0) + if dapiCfgStorage.DeprecatedServiceDiscovery == nil || dapiCfgStorage.DeprecatedServiceDiscovery.AWSRegions == nil { + return deprecationInfoMsg, nil + } + for _, cfgAwsRegion := range *dapiCfgStorage.DeprecatedServiceDiscovery.AWSRegions { + found := false + for _, dapiStorageAwsRegion := range dapiStorageAwsRegions { + if dapiStorageAwsRegion.Name != nil && cfgAwsRegion.Name != nil && + *dapiStorageAwsRegion.Name == *cfgAwsRegion.Name { + found = true + break + } + } + + awsRegionName := "" + if cfgAwsRegion.Name != nil { + awsRegionName = *cfgAwsRegion.Name + } + // Already migrated + if found { + msg := fmt.Sprintf("[CFG DEPRECATED] [SKIP] [AWS Region] [%s]: already migrated. Old location [%s] New location [%s]. Use only new location", + awsRegionName, + c.HAProxy.DataplaneConfig, + awsRegionsStoragePath) + // Logging is not done here as at startup, the logger is not yet initialized + // so it's done later on + deprecationInfoMsg = append(deprecationInfoMsg, msg) + } else { + // If not already migrated, then migrate it + msg := fmt.Sprintf("[CFG DEPRECATED] [MIGRATE] [AWS Region] [%s]: migrating. Old location [%s] New location [%s]. Use only new location", + awsRegionName, + c.HAProxy.DataplaneConfig, + awsRegionsStoragePath) + // Logging is not done here as at startup, the logger is not yet initialized + // so it's done later on + deprecationInfoMsg = append(deprecationInfoMsg, msg) + awsRegionssToMigrate = append(awsRegionssToMigrate, cfgAwsRegion) + } + } + if err := c.sdAWSRegionStorage.AddAWSRegionsAndStore(awsRegionssToMigrate); err != nil { + return deprecationInfoMsg, err + } + c.ServiceDiscovery.AWSRegions = append(c.ServiceDiscovery.AWSRegions, awsRegionssToMigrate...) + return deprecationInfoMsg, nil +} diff --git a/configuration/configuration_storage.go b/configuration/configuration_storage.go new file mode 100644 index 00000000..a29ec412 --- /dev/null +++ b/configuration/configuration_storage.go @@ -0,0 +1,401 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "time" + + "github.com/jessevdk/go-flags" + + "github.com/haproxytech/client-native/v6/models" + dpapilog "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/storagetype" +) + +type configTypeDataplaneapi struct { + WriteTimeout *string `yaml:"write_timeout,omitempty"` + GracefulTimeout *string `yaml:"graceful_timeout,omitempty"` + ShowSystemInfo *bool `yaml:"show_system_info,omitempty"` + MaxHeaderSize *string `yaml:"max_header_size,omitempty"` + SocketPath *flags.Filename `yaml:"socket_path,omitempty"` + DebugSocketPath *string `yaml:"debug_socket_path,omitempty"` + Host *string `yaml:"host,omitempty"` + Port *int `yaml:"port,omitempty"` + ListenLimit *int `yaml:"listen_limit,omitempty"` + DisableInotify *bool `yaml:"disable_inotify,omitempty"` + ReadTimeout *string `yaml:"read_timeout,omitempty"` + Advertised *configTypeAdvertised `yaml:"advertised,omitempty"` + CleanupTimeout *string `yaml:"cleanup_timeout,omitempty"` + KeepAlive *string `yaml:"keep_alive,omitempty"` + PIDFile *string `yaml:"pid_file,omitempty"` + UID *int `yaml:"uid,omitempty"` + GID *int `yaml:"gid,omitempty"` + TLS *configTypeTLS `yaml:"tls,omitempty"` + EnabledListeners *[]string `yaml:"scheme,omitempty"` + Userlist *configTypeUserlist `yaml:"userlist,omitempty"` + Transaction *configTypeTransaction `yaml:"transaction,omitempty"` + Resources *configTypeResources `yaml:"resources,omitempty"` + Users []storagetype.User `yaml:"user,omitempty"` +} + +type configTypeTLS struct { + TLSHost *string `yaml:"tls_host,omitempty"` + TLSPort *int `yaml:"tls_port,omitempty"` + TLSCertificate *flags.Filename `yaml:"tls_certificate,omitempty"` + TLSCertificateKey *flags.Filename `yaml:"tls_key,omitempty"` + TLSCACertificate *flags.Filename `yaml:"tls_ca,omitempty"` + TLSListenLimit *int `yaml:"tls_listen_limit,omitempty"` + TLSKeepAlive *string `yaml:"tls_keep_alive,omitempty"` + TLSReadTimeout *string `yaml:"tls_read_timeout,omitempty"` + TLSWriteTimeout *string `yaml:"tls_write_timeout,omitempty"` +} + +type configTypeHaproxy struct { + ConfigFile *string `yaml:"config_file,omitempty"` + HAProxy *string `yaml:"haproxy_bin,omitempty"` + MasterRuntime *string `yaml:"master_runtime,omitempty"` + NodeIDFile *string `yaml:"fid,omitempty"` + MasterWorkerMode *bool `yaml:"master_worker_mode,omitempty"` + Reload *configTypeReload `yaml:"reload,omitempty"` + DelayedStartMax *string `yaml:"delayed_start_max,omitempty"` + DelayedStartTick *string `yaml:"delayed_start_tick,omitempty"` +} + +type configTypeUserlist struct { + Userlist *string `yaml:"userlist,omitempty"` + UserListFile *string `yaml:"userlist_file,omitempty"` +} + +type configTypeReload struct { + ReloadDelay *int `yaml:"reload_delay,omitempty"` + ReloadCmd *string `yaml:"reload_cmd,omitempty"` + RestartCmd *string `yaml:"restart_cmd,omitempty"` + StatusCmd *string `yaml:"status_cmd,omitempty"` + ServiceName *string `yaml:"service_name,omitempty"` + ReloadRetention *int `yaml:"reload_retention,omitempty"` + ReloadStrategy *string `yaml:"reload_strategy,omitempty"` + ValidateCmd *string `yaml:"validate_cmd,omitempty"` +} + +type configTypeTransaction struct { + TransactionDir *string `yaml:"transaction_dir,omitempty"` + BackupsNumber *int `yaml:"backups_number,omitempty"` + BackupsDir *string `yaml:"backups_dir,omitempty"` + MaxOpenTransactions *int64 `yaml:"max_open_transactions,omitempty"` +} + +type configTypeResources struct { + MapsDir *string `yaml:"maps_dir,omitempty"` + SSLCertsDir *string `yaml:"ssl_certs_dir,omitempty"` + GeneralStorageDir *string `yaml:"general_storage_dir,omitempty"` + DataplaneStorageDir *string `yaml:"dataplane_storage_dir,omitempty"` + UpdateMapFiles *bool `yaml:"update_map_files,omitempty"` + UpdateMapFilesPeriod *int64 `yaml:"update_map_files_period,omitempty"` + SpoeDir *string `yaml:"spoe_dir,omitempty"` + SpoeTransactionDir *string `yaml:"spoe_transaction_dir,omitempty"` +} + +type configTypeAdvertised struct { + APIAddress *string `yaml:"api_address,omitempty"` + APIPort *int64 `yaml:"api_port,omitempty"` +} + +type storagetypeerviceDiscovery struct { + Consuls *[]*models.Consul `yaml:"consuls,omitempty"` + AWSRegions *[]*models.AwsRegion `yaml:"aws_regions,omitempty"` +} + +type configKeepalived struct { + ConfigFile *string `yaml:"config_file"` + StartCmd *string `yaml:"start_cmd"` + ReloadCmd *string `yaml:"reload_cmd"` + RestartCmd *string `yaml:"restart_cmd"` + StopCmd *string `yaml:"stop_cmd"` + StatusCmd *string `yaml:"status_cmd,omitempty"` + ValidateCmd *string `yaml:"validate_cmd"` + ReloadDelay *int `yaml:"reload_delay"` + TransactionDir *string `yaml:"transaction_dir"` + BackupsDir *string `yaml:"backups_dir"` + BackupsNumber *int `yaml:"backups_number"` +} + +type storagetypeyslog struct { + SyslogAddr *string `yaml:"syslog_address,omitempty"` + SyslogProto *string `yaml:"syslog_protocol,omitempty"` + SyslogTag *string `yaml:"syslog_tag,omitempty"` + SyslogLevel *string `yaml:"syslog_level,omitempty"` + SyslogFacility *string `yaml:"syslog_facility,omitempty"` +} + +type configTypeLog struct { + LogTo *string `yaml:"log_to,omitempty"` + LogFile *string `yaml:"log_file,omitempty"` + LogLevel *string `yaml:"log_level,omitempty"` + LogFormat *string `yaml:"log_format,omitempty"` + ACLFormat *string `yaml:"apache_common_log_format,omitempty"` + Syslog *storagetypeyslog `yaml:"syslog,omitempty"` +} + +type StorageDataplaneAPIConfiguration struct { + Version *int `yaml:"config_version,omitempty"` + Name *string `yaml:"name,omitempty"` + DeprecatedMode *string `yaml:"mode,omitempty"` + DeprecatedBootstrapKey *string `yaml:"bootstrap_key,omitempty"` + DeprecatedStatus *string `yaml:"status,omitempty"` + Dataplaneapi *configTypeDataplaneapi `yaml:"dataplaneapi,omitempty"` + Haproxy *configTypeHaproxy `yaml:"haproxy,omitempty"` + DeprecatedCluster *storagetype.Cluster `yaml:"cluster,omitempty"` + DeprecatedServiceDiscovery *storagetypeerviceDiscovery `yaml:"service_discovery,omitempty"` + Log *configTypeLog `yaml:"log,omitempty"` + LogTargets *dpapilog.Targets `yaml:"log_targets,omitempty"` +} + +func copyToConfiguration(cfg *Configuration) { //nolint:cyclop,maintidx + cfgStorage := cfg.storage.Get() + if cfgStorage.Name != nil { + cfg.Name.Store(*cfgStorage.Name) + } + if cfgStorage.DeprecatedBootstrapKey != nil { + cfg.DeprecatedBootstrapKey.Store(*cfgStorage.DeprecatedBootstrapKey) + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.ShowSystemInfo != nil && !misc.HasOSArg("i", "show-system-info", "") { + cfg.HAProxy.ShowSystemInfo = *cfgStorage.Dataplaneapi.ShowSystemInfo + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.DisableInotify != nil && !misc.HasOSArg("", "disable-inotify", "") { + cfg.HAProxy.DisableInotify = *cfgStorage.Dataplaneapi.DisableInotify + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.PIDFile != nil && !misc.HasOSArg("", "pid-file", "") { + cfg.HAProxy.PIDFile = *cfgStorage.Dataplaneapi.PIDFile + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.DebugSocketPath != nil && !misc.HasOSArg("", "debug-socket-path", "") { + cfg.HAProxy.DebugSocketPath = *cfgStorage.Dataplaneapi.DebugSocketPath + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.UID != nil && !misc.HasOSArg("", "uid", "") { + cfg.HAProxy.UID = *cfgStorage.Dataplaneapi.UID + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.GID != nil && !misc.HasOSArg("", "gid", "") { + cfg.HAProxy.GID = *cfgStorage.Dataplaneapi.GID + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Users != nil { + cfg.Users = []User{} + // If find users in dataplaneapi config file, then use them + for _, item := range cfgStorage.Dataplaneapi.Users { + itemUser := User{ + Name: item.Name, + } + if item.Insecure != nil { + itemUser.Insecure = *item.Insecure + } + if item.Password != nil { + itemUser.Password = *item.Password + } + cfg.Users = append(cfg.Users, itemUser) + } + } + + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.ConfigFile != nil && !misc.HasOSArg("c", "config-file", "") { + cfg.HAProxy.ConfigFile = *cfgStorage.Haproxy.ConfigFile + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.HAProxy != nil && !misc.HasOSArg("b", "haproxy-bin", "") { + cfg.HAProxy.HAProxy = *cfgStorage.Haproxy.HAProxy + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.MasterRuntime != nil && !misc.HasOSArg("m", "master-runtime", "") { + cfg.HAProxy.MasterRuntime = *cfgStorage.Haproxy.MasterRuntime + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.NodeIDFile != nil && !misc.HasOSArg("", "fid", "") { + cfg.HAProxy.NodeIDFile = *cfgStorage.Haproxy.NodeIDFile + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.MasterWorkerMode != nil && !misc.HasOSArg("", "master-worker-mode", "") { + cfg.HAProxy.MasterWorkerMode = *cfgStorage.Haproxy.MasterWorkerMode + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Userlist != nil && cfgStorage.Dataplaneapi.Userlist.Userlist != nil && !misc.HasOSArg("u", "userlist", "") { + cfg.HAProxy.Userlist = *cfgStorage.Dataplaneapi.Userlist.Userlist + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Userlist != nil && cfgStorage.Dataplaneapi.Userlist.UserListFile != nil && !misc.HasOSArg("", "userlist-file", "") { + cfg.HAProxy.UserListFile = *cfgStorage.Dataplaneapi.Userlist.UserListFile + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.ReloadDelay != nil && !misc.HasOSArg("d", "reload-delay", "") { + cfg.HAProxy.ReloadDelay = *cfgStorage.Haproxy.Reload.ReloadDelay + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.ReloadCmd != nil && !misc.HasOSArg("r", "reload-cmd", "") { + cfg.HAProxy.ReloadCmd = *cfgStorage.Haproxy.Reload.ReloadCmd + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.RestartCmd != nil && !misc.HasOSArg("s", "restart-cmd", "") { + cfg.HAProxy.RestartCmd = *cfgStorage.Haproxy.Reload.RestartCmd + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.StatusCmd != nil && !misc.HasOSArg("", "status-cmd", "") { + cfg.HAProxy.StatusCmd = *cfgStorage.Haproxy.Reload.StatusCmd + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.ServiceName != nil && !misc.HasOSArg("", "service", "") { + cfg.HAProxy.ServiceName = *cfgStorage.Haproxy.Reload.ServiceName + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.ReloadRetention != nil && !misc.HasOSArg("", "reload-retention", "") { + cfg.HAProxy.ReloadRetention = *cfgStorage.Haproxy.Reload.ReloadRetention + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.ReloadStrategy != nil && !misc.HasOSArg("", "reload-strategy", "") { + cfg.HAProxy.ReloadStrategy = *cfgStorage.Haproxy.Reload.ReloadStrategy + } + if cfgStorage.Haproxy != nil && cfgStorage.Haproxy.Reload != nil && cfgStorage.Haproxy.Reload.ValidateCmd != nil && !misc.HasOSArg("", "validate-cmd", "") { + cfg.HAProxy.ValidateCmd = *cfgStorage.Haproxy.Reload.ValidateCmd + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Transaction != nil && cfgStorage.Dataplaneapi.Transaction.TransactionDir != nil && !misc.HasOSArg("t", "transaction-dir", "") { + cfg.HAProxy.TransactionDir = *cfgStorage.Dataplaneapi.Transaction.TransactionDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Transaction != nil && cfgStorage.Dataplaneapi.Transaction.BackupsNumber != nil && !misc.HasOSArg("n", "backups-number", "") { + cfg.HAProxy.BackupsNumber = *cfgStorage.Dataplaneapi.Transaction.BackupsNumber + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Transaction != nil && cfgStorage.Dataplaneapi.Transaction.BackupsDir != nil && !misc.HasOSArg("", "backups-dir", "") { + cfg.HAProxy.BackupsDir = *cfgStorage.Dataplaneapi.Transaction.BackupsDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Transaction != nil && cfgStorage.Dataplaneapi.Transaction.MaxOpenTransactions != nil && !misc.HasOSArg("", "max-open-transactions", "") { + cfg.HAProxy.MaxOpenTransactions = *cfgStorage.Dataplaneapi.Transaction.MaxOpenTransactions + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.MapsDir != nil && !misc.HasOSArg("p", "maps-dir", "") { + cfg.HAProxy.MapsDir = *cfgStorage.Dataplaneapi.Resources.MapsDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.SSLCertsDir != nil && !misc.HasOSArg("", "ssl-certs-dir", "") { + cfg.HAProxy.SSLCertsDir = *cfgStorage.Dataplaneapi.Resources.SSLCertsDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.GeneralStorageDir != nil && !misc.HasOSArg("", "general-storage-dir", "") { + cfg.HAProxy.GeneralStorageDir = *cfgStorage.Dataplaneapi.Resources.GeneralStorageDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.DataplaneStorageDir != nil && !misc.HasOSArg("", "dataplane-storage-dir", "") { + cfg.HAProxy.DataplaneStorageDir = *cfgStorage.Dataplaneapi.Resources.DataplaneStorageDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.UpdateMapFiles != nil && !misc.HasOSArg("", "update-map-files", "") { + cfg.HAProxy.UpdateMapFiles = *cfgStorage.Dataplaneapi.Resources.UpdateMapFiles + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.UpdateMapFilesPeriod != nil && !misc.HasOSArg("", "update-map-files-period", "") { + cfg.HAProxy.UpdateMapFilesPeriod = *cfgStorage.Dataplaneapi.Resources.UpdateMapFilesPeriod + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.SpoeDir != nil && !misc.HasOSArg("", "spoe-dir", "") { + cfg.HAProxy.SpoeDir = *cfgStorage.Dataplaneapi.Resources.SpoeDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Resources != nil && cfgStorage.Dataplaneapi.Resources.SpoeTransactionDir != nil && !misc.HasOSArg("", "spoe-transaction-dir", "") { + cfg.HAProxy.SpoeTransactionDir = *cfgStorage.Dataplaneapi.Resources.SpoeTransactionDir + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Advertised != nil && cfgStorage.Dataplaneapi.Advertised.APIAddress != nil && !misc.HasOSArg("", "api-address", "") { + cfg.APIOptions.APIAddress = *cfgStorage.Dataplaneapi.Advertised.APIAddress + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Dataplaneapi.Advertised != nil && cfgStorage.Dataplaneapi.Advertised.APIPort != nil && !misc.HasOSArg("", "api-port", "") { + cfg.APIOptions.APIPort = *cfgStorage.Dataplaneapi.Advertised.APIPort + } + if cfgStorage.Log != nil && cfgStorage.Log.Syslog != nil && cfgStorage.Log.Syslog.SyslogAddr != nil && !misc.HasOSArg("", "syslog-address", "") { + cfg.Syslog.SyslogAddr = *cfgStorage.Log.Syslog.SyslogAddr + } + if cfgStorage.Log != nil && cfgStorage.Log.Syslog != nil && cfgStorage.Log.Syslog.SyslogProto != nil && !misc.HasOSArg("", "syslog-protocol", "") { + cfg.Syslog.SyslogProto = *cfgStorage.Log.Syslog.SyslogProto + } + if cfgStorage.Log != nil && cfgStorage.Log.Syslog != nil && cfgStorage.Log.Syslog.SyslogTag != nil && !misc.HasOSArg("", "syslog-tag", "") { + cfg.Syslog.SyslogTag = *cfgStorage.Log.Syslog.SyslogTag + } + if cfgStorage.Log != nil && cfgStorage.Log.Syslog != nil && cfgStorage.Log.Syslog.SyslogLevel != nil && !misc.HasOSArg("", "syslog-level", "") { + cfg.Syslog.SyslogLevel = *cfgStorage.Log.Syslog.SyslogLevel + } + if cfgStorage.Log != nil && cfgStorage.Log.Syslog != nil && cfgStorage.Log.Syslog.SyslogFacility != nil && !misc.HasOSArg("", "syslog-facility", "") { + cfg.Syslog.SyslogFacility = *cfgStorage.Log.Syslog.SyslogFacility + } + if cfgStorage.Log != nil && cfgStorage.Log.LogTo != nil && !misc.HasOSArg("", "log-to", "") { + cfg.Logging.LogTo = *cfgStorage.Log.LogTo + } + if cfgStorage.Log != nil && cfgStorage.Log.LogFile != nil && !misc.HasOSArg("", "log-file", "") { + cfg.Logging.LogFile = *cfgStorage.Log.LogFile + } + if cfgStorage.Log != nil && cfgStorage.Log.LogLevel != nil && !misc.HasOSArg("", "log-level", "") { + cfg.Logging.LogLevel = *cfgStorage.Log.LogLevel + } + if cfgStorage.Log != nil && cfgStorage.Log.LogFormat != nil && !misc.HasOSArg("", "log-format", "") { + cfg.Logging.LogFormat = *cfgStorage.Log.LogFormat + } + if cfgStorage.Log != nil && cfgStorage.Log.ACLFormat != nil && !misc.HasOSArg("", "apache-common-log-format", "") { + cfg.Logging.ACLFormat = *cfgStorage.Log.ACLFormat + } + if cfgStorage.LogTargets != nil { + cfg.LogTargets = *cfgStorage.LogTargets + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Haproxy.DelayedStartMax != nil && !misc.HasOSArg("", "delayed-start-max", "") { + if d, err := time.ParseDuration(*cfgStorage.Haproxy.DelayedStartMax); err == nil { + cfg.HAProxy.DelayedStartMax = d + } + } + if cfgStorage.Dataplaneapi != nil && cfgStorage.Haproxy.DelayedStartTick != nil && !misc.HasOSArg("", "delayed-start-tick", "") { + if d, err := time.ParseDuration(*cfgStorage.Haproxy.DelayedStartTick); err == nil { + cfg.HAProxy.DelayedStartTick = d + } + } +} + +func copyConfigurationToStorage(cfg *Configuration) { + cfgStorage := cfg.storage.Get() + + version := 2 + cfgStorage.Version = &version + + valueName := cfg.Name.Load() + cfgStorage.Name = &valueName + + if cfgStorage.Dataplaneapi == nil { + cfgStorage.Dataplaneapi = &configTypeDataplaneapi{} + } + if cfgStorage.Dataplaneapi.Advertised == nil { + cfgStorage.Dataplaneapi.Advertised = &configTypeAdvertised{} + } + cfgStorage.Dataplaneapi.Advertised.APIAddress = &cfg.APIOptions.APIAddress + cfgStorage.Dataplaneapi.Advertised.APIPort = &cfg.APIOptions.APIPort + + if cfgStorage.Dataplaneapi.Userlist == nil { + cfgStorage.Dataplaneapi.Userlist = &configTypeUserlist{} + } + cfgStorage.Dataplaneapi.Userlist.Userlist = &cfg.HAProxy.Userlist + cfgStorage.Dataplaneapi.Userlist.UserListFile = &cfg.HAProxy.UserListFile + + if cfgStorage.Haproxy == nil { + cfgStorage.Haproxy = &configTypeHaproxy{ + Reload: &configTypeReload{}, + } + } + cfgStorage.Haproxy.Reload.ReloadStrategy = &cfg.HAProxy.ReloadStrategy + + if cfgStorage.LogTargets == nil { + cfgStorage.LogTargets = &dpapilog.Targets{} + } + cfgStorage.LogTargets = &cfg.LogTargets +} + +func (cfgStorage *StorageDataplaneAPIConfiguration) emptyDeprecatedSections() { + cfgStorage.DeprecatedBootstrapKey = nil + // Remove Cluster Users from dapi configuration file + if cfgStorage.Dataplaneapi != nil { + for i := 0; i < len(cfgStorage.Dataplaneapi.Users); { + if cfgStorage.Dataplaneapi.Users[i].IsClusterUser() { + if len(cfgStorage.Dataplaneapi.Users) > i { + cfgStorage.Dataplaneapi.Users = append(cfgStorage.Dataplaneapi.Users[:i], cfgStorage.Dataplaneapi.Users[i+1:]...) + continue + } + } + i++ + } + } + // Remove Cluster + cfgStorage.DeprecatedCluster = nil + // Remove Status + cfgStorage.DeprecatedStatus = nil + // Remove Mode + cfgStorage.DeprecatedMode = nil + // Remove ServiceDiscovery Consuls and AWS Regions + cfgStorage.DeprecatedServiceDiscovery = nil +} diff --git a/configuration/const.go b/configuration/const.go new file mode 100644 index 00000000..a6407753 --- /dev/null +++ b/configuration/const.go @@ -0,0 +1,26 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +const ( + ModeCluster = "cluster" + ModeSingle = "single" +) + +const ( + StatusActive = "active" + StatusUnconfigured = "unconfigured" +) diff --git a/configuration/dataplane_storage.go b/configuration/dataplane_storage.go new file mode 100644 index 00000000..c9db3cd3 --- /dev/null +++ b/configuration/dataplane_storage.go @@ -0,0 +1,186 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "fmt" + "path" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/storage" + "github.com/haproxytech/dataplaneapi/storagetype" +) + +// loadClusterModeData loads data from storage/dataplane (and not from dapi config file) +func (c *Configuration) loadClusterModeData() error { + // ClusterModeData + clusterModeStorage, cmErr := storage.NewClusterModeStorage(path.Join(c.HAProxy.DataplaneStorageDir, storage.ClusterModeDataFileName)) + if cmErr != nil { + return fmt.Errorf("cluster mode storage error: %w", cmErr) + } + c.clusterModeStorage = clusterModeStorage + + if err := c.clusterModeStorage.Load(); err != nil { + return err + } + if c.clusterModeStorage.GetStatus() != nil { + c.Status.Store(*c.clusterModeStorage.GetStatus()) + } + + c.copyClusterToConfiguration(c.clusterModeStorage.GetCluster()) + + return nil +} + +func (c *Configuration) SaveClusterModeData() error { + cfgCluster := c.Cluster + dPort := cfgCluster.Port.Load() + cfgCertificateFetched := cfgCluster.CertificateFetched.Load() + + dapiStorageCluster := storagetype.Cluster{ + APINodesPath: misc.StringP(cfgCluster.APINodesPath.Load()), + Token: misc.StringP(cfgCluster.Token.Load()), + ClusterTLSCertDir: &c.HAProxy.ClusterTLSCertDir, + ActiveBootstrapKey: misc.StringP(cfgCluster.ActiveBootstrapKey.Load()), + APIRegisterPath: misc.StringP(cfgCluster.APIRegisterPath.Load()), + URL: misc.StringP(cfgCluster.URL.Load()), + Port: &dPort, + StorageDir: misc.StringP(cfgCluster.StorageDir.Load()), + BootstrapKey: misc.StringP(cfgCluster.BootstrapKey.Load()), + ID: misc.StringP(cfgCluster.ID.Load()), + APIBasePath: misc.StringP(cfgCluster.APIBasePath.Load()), + CertificateDir: misc.StringP(cfgCluster.CertificateDir.Load()), + CertificateFetched: &cfgCertificateFetched, + Name: misc.StringP(cfgCluster.Name.Load()), + Description: misc.StringP(cfgCluster.Description.Load()), + ClusterID: misc.StringP(cfgCluster.ClusterID.Load()), + ClusterLogTargets: cfgCluster.ClusterLogTargets, + } + cfgStatus := c.Status.Load() + c.clusterModeStorage.SetStatusAndStore(&cfgStatus) + if err := c.clusterModeStorage.SetClusterAndStore(&dapiStorageCluster); err != nil { + return err + } + + return nil +} + +func (c *Configuration) copyClusterToConfiguration(dapiStorageCluster *storagetype.Cluster) { + if dapiStorageCluster == nil { + return + } + if dapiStorageCluster.ClusterTLSCertDir != nil && !misc.HasOSArg("", "cluster-tls-dir", "") { + c.HAProxy.ClusterTLSCertDir = *dapiStorageCluster.ClusterTLSCertDir + } + if dapiStorageCluster.ID != nil && !misc.HasOSArg("", "", "") { + c.Cluster.ID.Store(*dapiStorageCluster.ID) + } + if dapiStorageCluster.BootstrapKey != nil && !misc.HasOSArg("", "", "") { + c.Cluster.BootstrapKey.Store(*dapiStorageCluster.BootstrapKey) + } + if dapiStorageCluster.ActiveBootstrapKey != nil && !misc.HasOSArg("", "", "") { + c.Cluster.ActiveBootstrapKey.Store(*dapiStorageCluster.ActiveBootstrapKey) + } + if dapiStorageCluster.Token != nil && !misc.HasOSArg("", "", "") { + c.Cluster.Token.Store(*dapiStorageCluster.Token) + } + if dapiStorageCluster.URL != nil && !misc.HasOSArg("", "", "") { + c.Cluster.URL.Store(*dapiStorageCluster.URL) + } + if dapiStorageCluster.Port != nil && !misc.HasOSArg("", "", "") { + c.Cluster.Port.Store(*dapiStorageCluster.Port) + } + if dapiStorageCluster.APIBasePath != nil && !misc.HasOSArg("", "", "") { + c.Cluster.APIBasePath.Store(*dapiStorageCluster.APIBasePath) + } + if dapiStorageCluster.APINodesPath != nil && !misc.HasOSArg("", "", "") { + c.Cluster.APINodesPath.Store(*dapiStorageCluster.APINodesPath) + } + if dapiStorageCluster.APIRegisterPath != nil && !misc.HasOSArg("", "", "") { + c.Cluster.APIRegisterPath.Store(*dapiStorageCluster.APIRegisterPath) + } + if dapiStorageCluster.StorageDir != nil && !misc.HasOSArg("", "", "") { + c.Cluster.StorageDir.Store(*dapiStorageCluster.StorageDir) + } + if dapiStorageCluster.CertificateDir != nil && !misc.HasOSArg("", "", "") { + c.Cluster.CertificateDir.Store(*dapiStorageCluster.CertificateDir) + } + if dapiStorageCluster.CertificateFetched != nil && !misc.HasOSArg("", "", "") { + c.Cluster.CertificateFetched.Store(*dapiStorageCluster.CertificateFetched) + } + if dapiStorageCluster.Name != nil && !misc.HasOSArg("", "", "") { + c.Cluster.Name.Store(*dapiStorageCluster.Name) + } + if dapiStorageCluster.Description != nil && !misc.HasOSArg("", "", "") { + c.Cluster.Description.Store(*dapiStorageCluster.Description) + } + if dapiStorageCluster.ClusterID != nil && !misc.HasOSArg("", "", "") { + c.Cluster.ClusterID.Store(*dapiStorageCluster.ClusterID) + } + if len(dapiStorageCluster.ClusterLogTargets) > 0 { + c.Cluster.ClusterLogTargets = dapiStorageCluster.ClusterLogTargets + } +} + +func (c *Configuration) loadSDConsuls() error { + // ClusterModeData + consulStorage, cmErr := storage.NewSDConsulStorage(path.Join(c.HAProxy.DataplaneStorageDir, storage.ConsulFileName)) + if cmErr != nil { + return fmt.Errorf("consul storage error: %w", cmErr) + } + + if err := consulStorage.Load(); err != nil { + return err + } + c.sdConsulStorage = consulStorage + + // Copy to configuration + c.ServiceDiscovery.Consuls = c.sdConsulStorage.GetConsuls() + + return nil +} + +func (c *Configuration) SaveSDConsuls() error { + if err := c.sdConsulStorage.ReplaceAllConsulsAndStore(c.ServiceDiscovery.Consuls); err != nil { + return err + } + return nil +} + +func (c *Configuration) loadSDAWSRegions() error { + // ClusterModeData + awsRegionStorage, cmErr := storage.NewSDAWSRegionStorage(path.Join(c.HAProxy.DataplaneStorageDir, storage.AWSRegionFileName)) + if cmErr != nil { + return fmt.Errorf("aws region storage error: %w", cmErr) + } + + if err := awsRegionStorage.Load(); err != nil { + return err + } + c.sdAWSRegionStorage = awsRegionStorage + + // Copy to configuration + c.ServiceDiscovery.AWSRegions = c.sdAWSRegionStorage.GetAWSRegions() + + return nil +} + +func (c *Configuration) SaveSDAWSRegions() error { + if err := c.sdAWSRegionStorage.ReplaceAllAWSRegionsAndStore(c.ServiceDiscovery.AWSRegions); err != nil { + return err + } + return nil +} diff --git a/configuration/doc/README.md b/configuration/doc/README.md new file mode 100644 index 00000000..67d9408f --- /dev/null +++ b/configuration/doc/README.md @@ -0,0 +1,278 @@ +# HAProxy Data Plane API Configuration + +## Overview + +The primary configuration for the Data Plane API is managed through a YAML file. This file allows you to set various parameters that control the behavior of the API and its interaction with HAProxy. + +## Top-Level Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `config_version` | integer | No | Configuration version | +| `name` | string | No | Name | + +## Structure + +The configuration file is structured into several sections, each corresponding to a different aspect of the Data Plane API's functionality. Here's a breakdown of the main sections and their options: + +### dataplaneapi Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `write_timeout` | string | No | Specifies the write timeout for API requests | +| `graceful_timeout` | string | No | Sets the graceful shutdown timeout | +| `show_system_info` | boolean | No | Enables or disables the display of system information on the info endpoint | +| `max_header_size` | string | No | Defines the maximum header size for API requests | +| `socket_path` | string | No | Specifies the path to the API's Unix socket | +| `debug_socket_path` | string | No | Defines the path for the debugging command socket | +| `host` | string | No | Sets the host address for the API | +| `port` | integer | No | Defines the port number for the API | +| `listen_limit` | integer | No | Sets the maximum number of connections the API can handle | +| `disable_inotify` | boolean | No | Disables the inotify watcher for the configuration file | +| `read_timeout` | string | No | Specifies the read timeout for API requests | +| `advertised` | object | No | Contains settings for the advertised API address and port. [See advertised options](#dataplaneapiadvertised-configuration-options) | +| `cleanup_timeout` | string | No | Sets the timeout for cleanup operations | +| `keep_alive` | string | No | Defines the keep-alive timeout for connections | +| `pid_file` | string | No | Specifies the path to the file where the API's PID will be written | +| `uid` | integer | No | User id value to set on start | +| `gid` | integer | No | Group id value to set on start | +| `tls` | object | No | Contains settings for TLS encryption. [See TLS options](#dataplanapitls-configuration-options) | +| `scheme` | array of strings | No | Enabled listeners | +| `userlist` | object | No | Contains settings for userlist. [See userlist options](#dataplanapituserlist-configuration-options) | +| `transaction` | object | No | Contains settings for transactions. [See transaction options](#dataplanapitransaction-configuration-options) | +| `resources` | object | No | Contains settings for resources. [See resources options](#dataplaneapiresources-configuration-options) | +| `user` | array of objects | No | List of users. [See user options](#dataplaneapiuser-configuration-options) | + +### dataplaneapi.advertised Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `api_address` | string | No | The advertised API address | +| `api_port` | integer | No | The advertised API port | + +### dataplaneapi.tls Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `tls_host` | string | No | The host address for TLS connections | +| `tls_port` | integer | No | The port number for TLS connections | +| `tls_certificate` | string | No | Path to the TLS certificate file | +| `tls_key` | string | No | Path to the TLS certificate key file | +| `tls_ca` | string | No | Path to the TLS CA certificate file | +| `tls_listen_limit` | integer | No | The maximum number of TLS connections | +| `tls_keep_alive` | string | No | The keep-alive timeout for TLS connections | +| `tls_read_timeout` | string | No | The read timeout for TLS connections | +| `tls_write_timeout` | string | No | The write timeout for TLS connections | + +### dataplaneapi.userlist Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `userlist` | string | No | Userlist in HAProxy configuration to use for API Basic Authentication | +| `userlist_file` | string | No | Path to the dataplaneapi userlist file | + +### dataplaneapi.transaction Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `transaction_dir` | string | No | Path to the transaction directory | +| `backups_number` | integer | No | Number of backup configuration files to keep | +| `backups_dir` | string | No | Path to directory in which to place backup files | +| `max_open_transactions` | integer | No | Limit for active transaction in pending state | + +### dataplaneapi.resources Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `maps_dir` | string | No | Path to directory of map files managed by dataplane | +| `ssl_certs_dir` | string | No | Path to SSL certificates directory | +| `general_storage_dir` | string | No | Path to general storage directory | +| `dataplane_storage_dir` | string | No | Path to dataplane internal storage directory | +| `update_map_files` | boolean | No | Flag used for syncing map files with runtime maps values | +| `update_map_files_period` | integer | No | Elapsed time in seconds between two maps syncing operations | +| `spoe_dir` | string | No | Path to SPOE directory | +| `spoe_transaction_dir` | string | No | Path to the SPOE transaction directory | + +### dataplaneapi.user Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `name` | string | Yes | User name | +| `password` | string | Yes | Password | +| `insecure` | boolean | No | Insecure password | + +### haproxy Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `config_file` | string | No | Path to the HAProxy configuration file | +| `haproxy_bin` | string | No | Path to the HAProxy binary file | +| `master_runtime` | string | No | Path to the master Runtime API socket | +| `fid` | string | No | Path to file that will dataplaneapi use to write its id | +| `master_worker_mode` | boolean | No | Flag to enable helpers when running HAProxy in master worker mode | +| `reload` | object | No | Contains settings for reloading HAProxy. [See reload options](#haproxyreload-configuration-options) | +| `delayed_start_max` | string | No | Maximum duration to wait for the haproxy runtime socket to be ready | +| `delayed_start_tick` | string | No | Duration between checks for the haproxy runtime socket to be ready | + +### haproxy.reload Configuration Options + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `reload_delay` | integer | No | Minimum delay between two reloads (in s) | +| `reload_cmd` | string | No | Reload command | +| `restart_cmd` | string | No | Restart command | +| `status_cmd` | string | No | Status command | +| `service_name` | string | No | Name of the HAProxy service | +| `reload_retention` | integer | No | Reload retention in days | +| `reload_strategy` | string | No | Either systemd, s6 or custom | +| `validate_cmd` | string | No | Executes a custom command to perform the HAProxy configuration check | + +### log_targets Configuration Options + +This section contains settings related to log targets. + +- **`log_targets`**: (array of objects, optional) - List of log targets. + + The `log_targets` option allows you to define multiple destinations for log messages. Each element in the `log_targets` array is an object that defines a specific log target. Each log target object can have the following properties: + +| Option | Type | Required | Description | +|--------|------|----------|-------------| +| `log_to` | string | Yes | Type of log target: 'file', 'syslog', or 'stdout' | +| `log_format` | string | No | Log format for this target: 'text', 'json', or 'apache_common'. Default is 'text' | +| `log_level` | string | No | Log level: 'trace', 'debug', 'info', 'warning', 'error', or 'critical'. Default is 'info' | +| `log_file` | string | No | If target is 'file', specifies the path to the log file | +| `acl_format` | string | No | Apache Common Log Format to format the access log entries, default:\"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-agent}i\\\" %{us}T" | +| `syslog_address` | string | No | If target is 'syslog', specifies the syslog server address | +| `syslog_protocol` | string | No | If target is 'syslog', specifies the syslog protocol (e.g., 'udp', 'tcp') | +| `syslog_tag` | string | No | If target is 'syslog', specifies the syslog tag | +| `syslog_facility` | string | No | If target is 'syslog', define the Syslog facility number, allowed values: 'kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7' | +| `syslog_level` | string | No | If target is 'syslog', define the required syslog messages level, allowed values: 'debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency' | +| `log_types` | array of strings | No | Define which log types to log to this target, allowed values: 'app', 'access' | + +**Example of `log_targets`:** + +```yaml +log_targets: + - log_target: file + log_file: /var/log/dataplaneapi.log + log_format: json + log_level: debug + log_types: + - access + - app + - log_target: syslog + syslog_address: 127.0.0.1:514 + syslog_protocol: udp + syslog_tag: dataplaneapi + syslog_facility: local0 + log_level: info + log_types: + - access + - log_target: stdout + log_format: text + log_level: warning + log_types: + - access + - app +``` + +## Command-Line Overrides + +Many of the configuration options available in the YAML file can be overridden by command-line arguments when starting the Data Plane API. This allows for flexibility in deployment and testing. + +### CLI Argument Precedence + +When a configuration option is set both in the YAML file and via a command-line argument, the command-line argument takes precedence. + +### Common CLI Flags + +- `-c`, `--config-file`: Overrides the `haproxy.config_file` option. +- `-b`, `--haproxy-bin`: Overrides the `haproxy.haproxy_bin` option. +- `-m`, `--master-runtime`: Overrides the `haproxy.master_runtime` option. +- `-u`, `--userlist`: Overrides the `dataplaneapi.userlist.userlist` option. +- `-d`, `--reload-delay`: Overrides the `haproxy.reload.reload_delay` option. +- `-r`, `--reload-cmd`: Overrides the `haproxy.reload.reload_cmd` option. +- `-s`, `--restart-cmd`: Overrides the `haproxy.reload.restart_cmd` option. +- `-t`, `--transaction-dir`: Overrides the `dataplaneapi.transaction.transaction_dir` option. +- `-n`, `--backups-number`: Overrides the `dataplaneapi.transaction.backups_number` option. +- `-p`, `--maps-dir`: Overrides the `dataplaneapi.resources.maps_dir` option. +- `-i`, `--show-system-info`: Overrides the `dataplaneapi.show_system_info` option. +- `--disable-inotify`: Overrides the `dataplaneapi.disable_inotify` option. +- `--pid-file`: Overrides the `dataplaneapi.pid_file` option. +- `--debug-socket-path`: Overrides the `dataplaneapi.debug_socket_path` option. +- `--uid`: Overrides the `dataplaneapi.uid` option. +- `--gid`: Overrides the `dataplaneapi.gid` option. +- `--userlist-file`: Overrides the `dataplaneapi.userlist.userlist_file` option. +- `--status-cmd`: Overrides the `haproxy.reload.status_cmd` option. +- `--service`: Overrides the `haproxy.reload.service_name` option. +- `--reload-retention`: Overrides the `haproxy.reload.reload_retention` option. +- `--reload-strategy`: Overrides the `haproxy.reload.reload_strategy` option. +- `--validate-cmd`: Overrides the `haproxy.reload.validate_cmd` option. +- `--backups-dir`: Overrides the `dataplaneapi.transaction.backups_dir` option. +- `--max-open-transactions`: Overrides the `dataplaneapi.transaction.max_open_transactions` option. +- `--ssl-certs-dir`: Overrides the `dataplaneapi.resources.ssl_certs_dir` option. +- `--general-storage-dir`: Overrides the `dataplaneapi.resources.general_storage_dir` option. +- `--dataplane-storage-dir`: Overrides the `dataplaneapi.resources.dataplane_storage_dir` option. +- `--update-map-files`: Overrides the `dataplaneapi.resources.update_map_files` option. +- `--update-map-files-period`: Overrides the `dataplaneapi.resources.update_map_files_period` option. +- `--spoe-dir`: Overrides the `dataplaneapi.resources.spoe_dir` option. +- `--spoe-transaction-dir`: Overrides the `dataplaneapi.resources.spoe_transaction_dir` option. +- `--api-address`: Overrides the `dataplaneapi.advertised.api_address` option. +- `--api-port`: Overrides the `dataplaneapi.advertised.api_port` option. +- `--syslog-address`: Overrides the `log.syslog.syslog_address` option. +- `--syslog-protocol`: Overrides the `log.syslog.syslog_protocol` option. +- `--syslog-tag`: Overrides the `log.syslog.syslog_tag` option. +- `--syslog-level`: Overrides the `log.syslog.syslog_level` option. +- `--syslog-facility`: Overrides the `log.syslog.syslog_facility` option. +- `--log-to`: Overrides the `log.log_to` option. +- `--log-file`: Overrides the `log.log_file` option. +- `--log-level`: Overrides the `log.log_level` option. +- `--log-format`: Overrides the `log.log_format` option. +- `--apache-common-log-format`: Overrides the `log.apache_common_log_format` option. +- `--master-worker-mode`: Overrides the `haproxy.master_worker_mode` option. +- `--delayed-start-max`: Overrides the `haproxy.delayed_start_max` option. +- `--delayed-start-tick`: Overrides the `haproxy.delayed_start_tick` option. +- `--fid`: Overrides the `haproxy.fid` option. + +## Example Configuration + +```yaml +config_version: 2 +name: haproxy-dataplaneapi +dataplaneapi: + host: 0.0.0.0 + port: 5555 + scheme: + - http + users: + name: admin + passowrd: adminpwd + insecure: true + transaction: + transaction_dir: /etc/haproxy/transactions + backups_number: 10 + backups_dir: /etc/haproxy/backups + max_open_transactions: 10 + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + spoe_dir: /etc/haproxy/spoe + dataplane_storage_dir: /etc/haproxy/dataplane +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/sbin/haproxy + master_worker_mode: true + master_runtime: /var/run/haproxy/master.sock + reload: + reload_delay: 5 + service_name: haproxy + reload_strategy: systemd +log_targets: +- log_to: file + log_file: /var/log/haproxy-dataplaneapi.log + log_level: info + log_types: + - access + - app +``` diff --git a/configuration/examples/dapi-storage/cluster.json b/configuration/examples/dapi-storage/cluster.json new file mode 100644 index 00000000..62018eeb --- /dev/null +++ b/configuration/examples/dapi-storage/cluster.json @@ -0,0 +1,29 @@ +{ + "users": [ + { + "name": "dpapi-c-E9oHDqXg", + "insecure": false, + "password": "$6$W4zXT9s0dsid1ab7$ziGLEPJkR/Ym6Xh8opir4jQVXEUUACyCydMtZMSh0GKCXZCTZBjE.CSXd8RQeDpiS4QFsjgg.Lnbn6LJmWs5s1" + } + ], + "status": "active", + "cluster": { + "api_nodes_path": "/nodes", + "token": "01J3FM4B84T9ZCXWVRT6YABXP9", + "cluster_tls_dir": "/var/lib/dataplaneapi/storage/certs-cluster", + "active_bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiI0MzIzZTkwZC1mODVlLTRmYWYtYWM5MS05ZjZjZTgxMThiMjMiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxODE2ODY2IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy80MzIzZTkwZC1mODVlLTRmYWYtYWM5MS05ZjZjZTgxMThiMjMvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNGSjQwSE5aSFM4TVNYNVRXNDhEU0JNIn0=", + "api_register_path": "/clusters/4323e90d-f85e-4faf-ac91-9f6ce8118b23/nodes", + "url": "http://127.0.0.1", + "port": 4449, + "storage_dir": "/var/lib/dataplaneapi/storage", + "bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiI0MzIzZTkwZC1mODVlLTRmYWYtYWM5MS05ZjZjZTgxMThiMjMiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxODE2ODY2IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy80MzIzZTkwZC1mODVlLTRmYWYtYWM5MS05ZjZjZTgxMThiMjMvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNGSjQwSE5aSFM4TVNYNVRXNDhEU0JNIn0=", + "id": "01J3FM4B84MJ97EA6MWR0VXWX3", + "api_base_path": "/v1", + "cert_path": "/var/lib/dataplaneapi/storage/certs-cluster", + "cert_fetched": true, + "use_hash_storage": false, + "name": "hd-laptop", + "description": "", + "cluster_id": "4323e90d-f85e-4faf-ac91-9f6ce8118b23" + } +} diff --git a/configuration/examples/example-dataplaneapi.yaml b/configuration/examples/example-dataplaneapi.yaml new file mode 100644 index 00000000..af5ba631 --- /dev/null +++ b/configuration/examples/example-dataplaneapi.yaml @@ -0,0 +1,38 @@ +config_version: 2 +name: haproxy-dataplaneapi +dataplaneapi: + host: 0.0.0.0 + port: 5555 + scheme: + - http + user: + name: admin + passowrd: adminpwd + insecure: true + transaction: + transaction_dir: /etc/haproxy/transactions + backups_number: 10 + backups_dir: /etc/haproxy/backups + max_open_transactions: 10 + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + spoe_dir: /etc/haproxy/spoe + dataplane_storage_dir: /etc/haproxy/dataplane +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/sbin/haproxy + master_worker_mode: true + master_runtime: /var/run/haproxy/master.sock + reload: + reload_delay: 5 + service_name: haproxy + reload_strategy: systemd +log_targets: +- log_to: file + log_file: /var/log/haproxy-dataplaneapi.log + log_level: info + log_types: + - access + - app diff --git a/configuration/examples/example-full.yaml b/configuration/examples/example-full.yaml new file mode 100644 index 00000000..161006be --- /dev/null +++ b/configuration/examples/example-full.yaml @@ -0,0 +1,128 @@ +config_version: 2 +name: famous_condor # string +mode: "single" # string +status: null # string # Deprecated starting 3.0 for cluster users, see ./README.md for more information +dataplaneapi: + scheme: # []string + - http + cleanup_timeout: "10s" # time.Duration + graceful_timeout: "15s" # time.Duration + max_header_size: "1MiB" # flagext.ByteSize + socket_path: "/var/run/data-plane.sock" # flags.Filename + debug_socket_path: "/var/run/dataplane-debug.sock" #string + host: "localhost" # string + port: 80 # int + listen_limit: 1024 # int + keep_alive: "3m" # time.Duration + read_timeout: "30s" # time.Duration + write_timeout: "60s" # time.Duration + show_system_info: false # bool + disable_inotify: false # bool + pid_file: /tmp/dataplane.pid # string + uid: 1000 # int + gid: 1000 # int + tls: + tls_host: null # string 2 + tls_port: 6443 # int 2 + tls_certificate: null # flags.Filename 2 + tls_key: null # flags.Filename 2 + tls_ca: null # flags.Filename 2 + tls_listen_limit: 10 # int 2 + tls_keep_alive: 1m # time.Duration 2 + tls_read_timeout: 10s # time.Duration 2 + tls_write_timeout: 10s # time.Duration 2 + user: # Deprecated starting 3.0 for cluster users, see ./README.md for more information + - name: admin # string 2 + insecure: true # bool 2 + password: adminpwd # string 2 + userlist: + userlist: "controller" # string 2 + userlist_file: null # string 2 + transaction: + transaction_dir: "/tmp/haproxy" # string 2 + backups_number: 0 # int 2 + backups_dir: /tmp/backups # string 2 + max_open_transactions: 20 # int64 2 + resources: + maps_dir: "/etc/haproxy/maps" # string 2 + ssl_certs_dir: "/etc/haproxy/ssl" # string 2 + update_map_files: false # bool 2 + update_map_files_period: 10 # int64 2 + spoe_dir: "/etc/haproxy/spoe" # string 2 + spoe_transaction_dir: "/tmp/spoe-haproxy" # string 2 + dataplane_storage_dir: "/etc/haproxy/general" # string 2 + advertised: + api_address: 10.2.3.4 # string 2 + api_port: 80 # int64 2 +haproxy: + config_file: "/etc/haproxy/haproxy.cfg" # string + haproxy_bin: "haproxy" # string + master_runtime: null # string + fid: null # string + master_worker_mode: false # bool + delayed_start_max: 30s # time.Duration + delayed_start_tick: 500ms # time.Duration + preferred_time_suffix: nearest # enum [nearest, none, ms, s, m, h, d] + reload: + reload_delay: 5 # int 2 + reload_cmd: "systemctl reload haproxy" + restart_cmd: "systemctl restart haproxy" + status_cmd: "systemctl status haproxy" + service_name: "haproxy.service" + reload_retention: 1 # int 2 + reload_strategy: custom + validate_cmd: null # string 2 +cluster: # Deprecated starting 3.0, see ./README.md for more information + cluster_tls_dir: null # string + id: null # string + bootstrap_key: null # string + active_bootstrap_key: null # string + token: null # string + url: null # string + port: 80 # int + api_base_path: null # string + api_nodes_path: null # string + api_register_path: null # string + storage_dir: null # string + cert_path: null # string + cert_fetched: false # bool + name: null # string + description: null # string +service_discovery: # Deprecated starting 3.0, see ./README.md for more information + consuls: [] # []*models.Consul + aws_regions: [] # []*models.AwsRegion +log_targets: +- log_to: stdout + log_level: debug + log_format: json + log_types: + - access + - app +- log_to: file + log_file: /var/log/dataplanepi.log + log_level: info + log_format: text + log_types: + - app +- log_to: syslog + log_level: info + syslog_address: 127.0.0.1 + syslog_protocol: tcp + syslog_tag: dataplaneapi + syslog_level: debug + syslog_facility: local0 + log_types: + - access +# Deprecated: use log_targets instead +log: + log_to: "stdout" # string + log_file: "/var/log/dataplaneapi/dataplaneapi.log" # string + log_level: "warning" # string + log_format: "text" # string + apache_common_log_format: "%h" # string + syslog: + syslog_address: null # string 2 + syslog_protocol: "tcp" # string 2 + syslog_tag: "dataplaneapi" # string 2 + syslog_level: "debug" # string 2 + syslog_facility: "local0" # string 2 diff --git a/configuration/file-storage-nostorage.go b/configuration/file-storage-nostorage.go new file mode 100644 index 00000000..2778fdf3 --- /dev/null +++ b/configuration/file-storage-nostorage.go @@ -0,0 +1,40 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +type StorageDummy struct { + cfg *StorageDataplaneAPIConfiguration +} + +func (s *StorageDummy) Load(filename string) error { + s.cfg = &StorageDataplaneAPIConfiguration{} + return nil +} + +func (s *StorageDummy) Get() *StorageDataplaneAPIConfiguration { + return s.cfg +} + +func (s *StorageDummy) Set(cfg *StorageDataplaneAPIConfiguration) { +} + +func (s *StorageDummy) SaveAs(filename string) error { + return nil +} + +func (s *StorageDummy) Save() error { + return nil +} diff --git a/configuration/file-storage-yml.go b/configuration/file-storage-yml.go new file mode 100644 index 00000000..f31e4abd --- /dev/null +++ b/configuration/file-storage-yml.go @@ -0,0 +1,70 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "os" + + "github.com/google/renameio" + "gopkg.in/yaml.v2" +) + +type StorageYML struct { + cfg *StorageDataplaneAPIConfiguration + filename string +} + +func (s *StorageYML) Load(filename string) error { + s.filename = filename + cfg := &StorageDataplaneAPIConfiguration{} + var err error + + yamlFile, err := os.ReadFile(filename) + if err != nil { + return err + } + err = yaml.Unmarshal(yamlFile, cfg) + if err != nil { + return err + } + + s.cfg = cfg + return nil +} + +func (s *StorageYML) Get() *StorageDataplaneAPIConfiguration { + if s.cfg == nil { + s.cfg = &StorageDataplaneAPIConfiguration{} + } + return s.cfg +} + +func (s *StorageYML) Set(cfg *StorageDataplaneAPIConfiguration) { + s.cfg = cfg +} + +func (s *StorageYML) SaveAs(filename string) error { + data, err := yaml.Marshal(s.cfg) + if err != nil { + return err + } + + return renameio.WriteFile(filename, data, 0o644) +} + +func (s *StorageYML) Save() error { + return s.SaveAs(s.filename) +} diff --git a/configuration/file-storage.go b/configuration/file-storage.go new file mode 100644 index 00000000..3230c8fb --- /dev/null +++ b/configuration/file-storage.go @@ -0,0 +1,24 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +type Storage interface { + Load(filename string) error + Get() *StorageDataplaneAPIConfiguration + Set(cfg *StorageDataplaneAPIConfiguration) + SaveAs(filename string) error + Save() error +} diff --git a/configuration/int.go b/configuration/int.go new file mode 100644 index 00000000..0abedc62 --- /dev/null +++ b/configuration/int.go @@ -0,0 +1,56 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "strconv" + "sync/atomic" +) + +type AtomicInt struct { + value atomic.Value +} + +func (s *AtomicInt) Load() int { + v := s.value.Load() + if v == nil { + return 0 + } + return v.(int) +} + +func (s *AtomicInt) Store(str int) { + s.value.Store(str) +} + +func (s *AtomicInt) String() string { + return strconv.Itoa(s.Load()) +} + +func (s *AtomicInt) UnmarshalYAML(unmarshal func(any) error) error { + var buf int + err := unmarshal(&buf) + if err != nil { + return err + } + + s.Store(buf) + return nil +} + +func (s AtomicInt) MarshalYAML() (any, error) { + return s.Load(), nil +} diff --git a/configuration/map_sync.go b/configuration/map_sync.go new file mode 100644 index 00000000..601f43b2 --- /dev/null +++ b/configuration/map_sync.go @@ -0,0 +1,200 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "fmt" + "math/rand" + "os" + "sort" + "sync" + "time" + + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/log" +) + +type MapSync struct { + mapQuitChan chan struct{} + mu sync.RWMutex +} + +func NewMapSync() *MapSync { + return &MapSync{ + mapQuitChan: make(chan struct{}), + } +} + +// Stop stops maps syncing +func (ms *MapSync) Stop() { + ms.mapQuitChan <- struct{}{} +} + +// SyncAll sync maps file entries with runtime maps entries for all configured files. +// Missing runtime entries are appended to the map file +func (ms *MapSync) SyncAll(client client_native.HAProxyClient) { + haproxyOptions := Get().HAProxy + + d := time.Duration(haproxyOptions.UpdateMapFilesPeriod) + ticker := time.NewTicker(d * time.Second) //nolint:durationcheck + + for { + select { + case <-ticker.C: + runtime, err := client.Runtime() + if err != nil { + log.Warning("show maps sync error: ", err.Error()) + continue + } + maps, err := runtime.ShowMaps() + if err != nil { + log.Warning("show maps sync error: ", err.Error()) + continue + } + for _, mp := range maps { + go func(mp *models.Map) { + _, err := ms.Sync(mp, client) + if err != nil { + log.Warning(err.Error()) + } + }(mp) + } + case <-ms.mapQuitChan: + return + } + } +} + +// Sync syncs one map file to runtime entries +func (ms *MapSync) Sync(mp *models.Map, client client_native.HAProxyClient) (bool, error) { + ms.mu.Lock() + defer ms.mu.Unlock() + + rawFile, err := os.Open(mp.File) + if err != nil { + return false, fmt.Errorf("error reading map file: %s %s", mp.File, err.Error()) + } + runtime, err := client.Runtime() + if err != nil { + return false, fmt.Errorf("getting runtime entries error: id: %s %s", mp.ID, err.Error()) + } + fileEntries := runtime.ParseMapEntriesFromFile(rawFile, false) + sort.Slice(fileEntries, func(i, j int) bool { return fileEntries[i].Key < fileEntries[j].Key }) + + // runtime map entries + id := "#" + mp.ID + runtimeEntries, err := runtime.ShowMapEntries(id) + if err != nil { + return false, fmt.Errorf("getting runtime entries error: id: %s %s", id, err.Error()) + } + sort.Slice(runtimeEntries, func(i, j int) bool { return runtimeEntries[i].Key < runtimeEntries[j].Key }) + + if len(fileEntries) != len(runtimeEntries) { + return dumpRuntimeEntries(mp.File, runtimeEntries) + } + + if !equalSomeEntries(fileEntries, runtimeEntries) { + return dumpRuntimeEntries(mp.File, runtimeEntries) + } + + if !equal(fileEntries, runtimeEntries) { + return dumpRuntimeEntries(mp.File, runtimeEntries) + } + return true, nil +} + +// equalSomeEntries compares last few runtime entries with file entries +// if records differs, check is run against random entries +func equalSomeEntries(fEntries, rEntries models.MapEntries, index ...int) bool { + if len(fEntries) != len(rEntries) { + return false + } + + var maximum int + switch l := len(rEntries); { + case l > 19: + for i := l - 20; i < l; i++ { + if rEntries[i].Key != fEntries[i].Key || rEntries[i].Value != fEntries[i].Value { + return false + } + } + maximum = l - 19 + case l == 0: + return true + default: + maximum = l + } + + maxRandom := min(maximum, 10) + + for range maxRandom { + // There's no need for strong number generation, here, just need for performance + r := rand.Intn(maximum) + if len(index) > 0 { + r = index[0] + } + if rEntries[r].Key != fEntries[r].Key || rEntries[r].Value != fEntries[r].Value { + return false + } + } + return true +} + +// equal compares runtime and map entries +// Returns true if all entries are same, otherwise returns false +func equal(a, b models.MapEntries) bool { + if len(a) != len(b) { + return false + } + for i, v := range a { + // ID should not be compared, since it doesn't exists in file + if v.Key != b[i].Key || v.Value != b[i].Value { + return false + } + } + return true +} + +// dumpRuntimeEntries dumps runtime entries into map file +// Returns true,nil if succeed, otherwise returns false,error +func dumpRuntimeEntries(file string, me models.MapEntries) (bool, error) { + f, err := os.OpenFile(file, os.O_APPEND|os.O_WRONLY|os.O_TRUNC, 0o600) + if err != nil { + return false, fmt.Errorf("error opening map file: %s %s", file, err.Error()) + } + defer f.Close() + + err = f.Truncate(0) + if err != nil { + return false, fmt.Errorf("error truncating map file: %s %s", file, err.Error()) + } + + _, err = f.Seek(0, 0) + if err != nil { + return false, fmt.Errorf("error setting file to offset: %s %s", file, err.Error()) + } + + for _, e := range me { + line := fmt.Sprintf("%s %s%s", e.Key, e.Value, "\n") + _, err = f.WriteString(line) + if err != nil { + return false, fmt.Errorf("error writing map file: %s %s", file, err.Error()) + } + } + log.Infof("map file %s synced with runtime entries", file) + return true, nil +} diff --git a/configuration/map_sync_test.go b/configuration/map_sync_test.go new file mode 100644 index 00000000..865a0b7a --- /dev/null +++ b/configuration/map_sync_test.go @@ -0,0 +1,185 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "strconv" + "testing" + + "github.com/haproxytech/client-native/v6/models" +) + +func data(differentAtIndex ...int) (fileEntries models.MapEntries, runtimeEntries models.MapEntries) { + for i := range 50 { + fe := &models.MapEntry{Key: "k" + strconv.Itoa(i), Value: "v" + strconv.Itoa(i)} + re := &models.MapEntry{Key: "k" + strconv.Itoa(i), Value: "v" + strconv.Itoa(i)} + fileEntries = append(fileEntries, fe) + runtimeEntries = append(runtimeEntries, re) + } + if len(differentAtIndex) > 0 { + fileEntries[differentAtIndex[0]].Key = "abc" + // fileEntries[differentAtIndex[0]].Value = "abc" + } + return fileEntries, runtimeEntries +} + +func Test_equalSomeEntries(t *testing.T) { + index := 10 + feDifferent, re := data(index) + feSame, reSame := data() + + type args struct { + fEntries models.MapEntries + rEntries models.MapEntries + index []int + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "Same Entries", + args: args{ + fEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}}, + rEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}}, + index: []int{0}, + }, + want: true, + }, + { + name: "Same Entries 2", + args: args{ + fEntries: feSame, + rEntries: reSame, + }, + want: true, + }, + { + name: "Both Empty", + args: args{ + fEntries: models.MapEntries{}, + rEntries: models.MapEntries{}, + }, + want: true, + }, + { + name: "Different Entries", + args: args{ + fEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}}, + rEntries: models.MapEntries{&models.MapEntry{Key: "0", Value: "0"}}, + index: []int{0}, + }, + want: false, + }, + { + name: "Different Length", + args: args{ + fEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}}, + rEntries: models.MapEntries{}, + }, + want: false, + }, + { + name: "Different At Index", + args: args{ + fEntries: feDifferent, + rEntries: re, + index: []int{index}, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := equalSomeEntries(tt.args.fEntries, tt.args.rEntries, tt.args.index...); got != tt.want { + t.Errorf("equalSomeEntries() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_equal(t *testing.T) { + index := 25 + feDifferent, re := data(index) + feSame, reSame := data() + + type args struct { + fEntries models.MapEntries + rEntries models.MapEntries + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "Same Entries", + args: args{ + fEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}, &models.MapEntry{Key: "2", Value: "2"}}, + rEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}, &models.MapEntry{Key: "2", Value: "2"}}, + }, + want: true, + }, + { + name: "Same Entries 2", + args: args{ + fEntries: feSame, + rEntries: reSame, + }, + want: true, + }, + { + name: "Both Empty", + args: args{ + fEntries: models.MapEntries{}, + rEntries: models.MapEntries{}, + }, + want: true, + }, + { + name: "Different Entries", + args: args{ + fEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}}, + rEntries: models.MapEntries{&models.MapEntry{Key: "0", Value: "0"}}, + }, + want: false, + }, + { + name: "Different Length", + args: args{ + fEntries: models.MapEntries{&models.MapEntry{Key: "1", Value: "1"}}, + rEntries: models.MapEntries{}, + }, + want: false, + }, + { + name: "Different At Index", + args: args{ + fEntries: feDifferent, + rEntries: re, + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := equal(tt.args.fEntries, tt.args.rEntries); got != tt.want { + t.Errorf("equalHash() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/configuration/misc.go b/configuration/misc.go new file mode 100644 index 00000000..0a4bcf4b --- /dev/null +++ b/configuration/misc.go @@ -0,0 +1,126 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "encoding/base64" + "errors" + "fmt" + "io/fs" + "os" + "path" + "strconv" + "strings" + "syscall" + "time" + + "github.com/go-openapi/strfmt" + "github.com/google/renameio" + "github.com/haproxytech/client-native/v6/misc" + "github.com/haproxytech/client-native/v6/storage" + jsoniter "github.com/json-iterator/go" +) + +func DecodeBootstrapKey(key string) (map[string]string, error) { + raw, err := base64.StdEncoding.DecodeString(key) + if err != nil { + return nil, fmt.Errorf("%s - %w", key, err) + } + var decodedKey map[string]string + json := jsoniter.ConfigCompatibleWithStandardLibrary + err = json.Unmarshal(raw, &decodedKey) + if err != nil { + return nil, fmt.Errorf("%s - %w", key, err) + } + + var keySummary string + if len(key) > 10 { + keySummary = key[:4] + "..." + key[len(key)-5:] + } else { + keySummary = key + } + + if expiryUnixTS, ok := decodedKey["expiring-time"]; ok { + tUnix, ok2 := strconv.ParseInt(expiryUnixTS, 10, 64) + if ok2 != nil { + return nil, fmt.Errorf("bootstrap key %s error, decoding expiry to int: %s", keySummary, expiryUnixTS) + } + expiryTime := time.Unix(tUnix, 0) + if expiryTime.Before(time.Now()) { + return nil, fmt.Errorf("refusing to use expired bootstrap key: %s expired on: %s", keySummary, strfmt.DateTime(expiryTime)) + } + } + + return decodedKey, nil +} + +func processExists(pid int) bool { + process, err := os.FindProcess(pid) + if err != nil { + return false + } + err = process.Signal(syscall.Signal(0)) + return err == nil +} + +func fileExists(filename string) bool { + info, err := os.Stat(filename) + if errors.Is(err, fs.ErrNotExist) { + return false + } + return !info.IsDir() +} + +func RemoveStorageFolder(storageDir string) error { + return os.RemoveAll(storageDir) +} + +func InitStorageNoticeFile(storageDir string) error { + content := strings.Builder{} + + _, _ = fmt.Fprintf(&content, "# *********************************************************************************\n") + _, _ = fmt.Fprintf(&content, "# NOTE: This storage folder contains files managed by HAProxy Fusion Control Plane:\n") + _, _ = fmt.Fprintf(&content, "# manual edits may cause issues and misconfigurations.\n") + + return renameio.WriteFile(path.Join(storageDir, "NOTICE"), []byte(content.String()), os.ModePerm) +} + +func CheckIfStorageDirIsOK(storageDir string, config *Configuration) error { + if storageDir == "" { + return errors.New("storage-dir in bootstrap key is empty") + } + _, errStorage := misc.CheckOrCreateWritableDirectory(storageDir) + if errStorage != nil { + return errStorage + } + dirs := []storage.FileType{ + storage.BackupsType, storage.MapsType, storage.SSLType, + storage.SpoeTransactionsType, storage.SpoeType, + storage.TransactionsType, + storage.FileType("certs-cluster"), + } + for _, dir := range dirs { + _, errStorage := misc.CheckOrCreateWritableDirectory(path.Join(storageDir, string(dir))) + if errStorage != nil { + return errStorage + } + } + return nil +} + +func removeFromSlice[T any](slice []T, s int) []T { + return append(slice[:s], slice[s+1:]...) +} diff --git a/configuration/pid.go b/configuration/pid.go new file mode 100644 index 00000000..68764246 --- /dev/null +++ b/configuration/pid.go @@ -0,0 +1,55 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "os" + "strconv" + + "github.com/google/renameio" + "github.com/haproxytech/dataplaneapi/log" +) + +func HandlePIDFile(haproxyOptions HAProxyConfiguration) { + if haproxyOptions.PIDFile == "" { + return + } + + if fileExists(haproxyOptions.PIDFile) { + data, err := os.ReadFile(haproxyOptions.PIDFile) + if err != nil { + log.Fatalf("error while reading PID file content: %v", err) + } + pid, err := strconv.ParseInt(string(data), 10, 32) + if err != nil { + log.Fatalf("error while parsing PID file content: %v", err) + } + if os.Getpid() == int(pid) { + log.Info("Stored PID matches current PID, proceeding...") + return + } + if processExists(int(pid)) { + log.Fatalf("process with PID %v already exists", pid) + } + } + + err := renameio.WriteFile(haproxyOptions.PIDFile, []byte(strconv.Itoa(os.Getpid())), 0o644) + if err != nil { + log.Fatalf("error while writing PID file: %s %s", haproxyOptions.PIDFile, err.Error()) + } else { + log.Infof("PID %v stored in %v", os.Getpid(), haproxyOptions.PIDFile) + } +} diff --git a/configuration/reload-strategy.go b/configuration/reload-strategy.go new file mode 100644 index 00000000..aee52635 --- /dev/null +++ b/configuration/reload-strategy.go @@ -0,0 +1,83 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "errors" + "fmt" +) + +const ( + ReloadStratCustom = "custom" + ReloadStratS6 = "s6" + ReloadStratSystemd = "systemd" + + // Default systemd commands. + systemdReloadCmd = "sudo -n systemctl reload" + systemdRestartCmd = "sudo -n systemctl restart" + systemdStatusCmd = "systemctl --quiet is-active" + systemdDefaultService = "haproxy.service" + + // Default s6 commands. + s6ReloadCmd = "s6-svc -2" + s6RestartCmd = "s6-svc -r" + s6StatusCmd = "s6-svstat -u" + s6DefaultService = "/var/run/service/haproxy" +) + +// Set a default value to a string. +func setDefault(option *string, cmd, service string) { + if *option == "" { + *option = cmd + " " + service + } +} + +// Validate and initialize the way dataplaneapi will reload and monitor HAPRoxy. +func validateReloadConfiguration(c *HAProxyConfiguration) error { + // By default, use the custom strategy. + if c.ReloadStrategy == "" { + c.ReloadStrategy = ReloadStratCustom + } + + switch c.ReloadStrategy { + case ReloadStratCustom: + // The custom commands need to be set. + if c.ReloadCmd == "" || c.RestartCmd == "" { + return errors.New("the custom reload strategy requires these options to be set: " + + "ReloadCmd, RestartCmd") + } + case ReloadStratS6: + svc := s6DefaultService + if c.ServiceName != "" { + svc = c.ServiceName + } + setDefault(&c.ReloadCmd, s6ReloadCmd, svc) + setDefault(&c.RestartCmd, s6RestartCmd, svc) + setDefault(&c.StatusCmd, s6StatusCmd, svc) + case ReloadStratSystemd: + svc := systemdDefaultService + if c.ServiceName != "" { + svc = c.ServiceName + } + setDefault(&c.ReloadCmd, systemdReloadCmd, svc) + setDefault(&c.RestartCmd, systemdRestartCmd, svc) + setDefault(&c.StatusCmd, systemdStatusCmd, svc) + default: + return fmt.Errorf("invalid reload strategy: '%s'", c.ReloadStrategy) + } + + return nil +} diff --git a/configuration/signals.go b/configuration/signals.go new file mode 100644 index 00000000..ee074eff --- /dev/null +++ b/configuration/signals.go @@ -0,0 +1,112 @@ +// Copyright 2020 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "os" + "os/signal" + "sync" + "syscall" + "time" + + "github.com/haproxytech/dataplaneapi/log" +) + +type ChanNotify struct { + subscribers map[string]chan struct{} + mu sync.RWMutex +} + +func NewChanNotify() *ChanNotify { + cn := &ChanNotify{} + cn.subscribers = make(map[string]chan struct{}) + return cn +} + +func (cn *ChanNotify) Subscribe(name string) chan struct{} { + cn.mu.Lock() + defer cn.mu.Unlock() + + c := make(chan struct{}, 1) + cn.subscribers[name] = c + return c +} + +func (cn *ChanNotify) UnSubscribeAll() { + cn.mu.Lock() + defer cn.mu.Unlock() + cn.subscribers = make(map[string]chan struct{}) +} + +func (cn *ChanNotify) Notify() { + cn.notify(0) +} + +func (cn *ChanNotify) NotifyWithRetry() { + cn.notify(3) +} + +func (cn *ChanNotify) notify(numTry int) { + if numTry < 0 { + return + } + cn.mu.RLock() + defer cn.mu.RUnlock() + + if len(cn.subscribers) == 0 { + go func() { + time.Sleep(2 * time.Second) + numTry-- + cn.notify(numTry) + }() + return + } + + for _, c := range cn.subscribers { + c <- struct{}{} + } +} + +func (c *Configuration) InitSignalHandler() { + c.shutdownSignal = make(chan os.Signal, 1) + signal.Notify(c.shutdownSignal, syscall.SIGINT, syscall.SIGTERM) + + go func() { + for sig := range c.shutdownSignal { + log.Debug("Received signal ", sig) + c.Notify.Shutdown.Notify() + } + }() + + c.reloadSignal = make(chan os.Signal, 1) + signal.Notify(c.reloadSignal, syscall.SIGHUP) + + go func() { + for sig := range c.reloadSignal { + log.Debug("Received signal ", sig) + c.Notify.Reload.Notify() + } + }() +} + +func (c *Configuration) StopSignalHandler() { + log.Debug("Unloading signal handler") + signal.Stop(c.shutdownSignal) + signal.Stop(c.reloadSignal) + signal.Ignore(syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) + close(c.shutdownSignal) + close(c.reloadSignal) +} diff --git a/configuration/string.go b/configuration/string.go new file mode 100644 index 00000000..ae166525 --- /dev/null +++ b/configuration/string.go @@ -0,0 +1,55 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "sync/atomic" +) + +type AtomicString struct { + value atomic.Value +} + +func (s *AtomicString) Load() string { + v := s.value.Load() + if v == nil { + return "" + } + return v.(string) +} + +func (s *AtomicString) Store(str string) { + s.value.Store(str) +} + +func (s *AtomicString) String() string { + return s.Load() +} + +func (s *AtomicString) UnmarshalYAML(unmarshal func(any) error) error { + var buf string + err := unmarshal(&buf) + if err != nil { + return err + } + + s.Store(buf) + return nil +} + +func (s AtomicString) MarshalYAML() (any, error) { + return s.Load(), nil +} diff --git a/configuration/user.go b/configuration/user.go new file mode 100644 index 00000000..bc21e217 --- /dev/null +++ b/configuration/user.go @@ -0,0 +1,232 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "errors" + "fmt" + "io/fs" + "net/http" + "os" + "slices" + "strings" + "sync" + + "github.com/GehirnInc/crypt" + api_errors "github.com/go-openapi/errors" + parser "github.com/haproxytech/client-native/v6/config-parser" + "github.com/haproxytech/client-native/v6/config-parser/common" + "github.com/haproxytech/client-native/v6/config-parser/options" + "github.com/haproxytech/client-native/v6/config-parser/types" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/storagetype" +) + +const mockPass = "$2a$10$e.I1x5KPNu7xy9u0zSzJaOcr5it8kR1Awnaf3boOtYno9y4DolER." + +var usersStore *Users + +var syncUserStore sync.Once + +type Users struct { + users []types.User + mu sync.Mutex +} + +func GetUsersStore() *Users { + syncUserStore.Do(func() { + usersStore = &Users{} + }) + return usersStore +} + +func (u *Users) GetUsers() []types.User { + return u.users +} + +func (u *Users) setUser(data common.ParserData, file string) error { + if data == nil { + return fmt.Errorf("no users configured in %s", file) + } + + users, ok := data.([]types.User) + if !ok { + return fmt.Errorf("error reading users from %s", file) + } + if len(users) == 0 { + return fmt.Errorf("no users configured in %s", file) + } + u.mu.Lock() + defer u.mu.Unlock() + + u.users = append(u.users, users...) + return nil +} + +func (u *Users) Init() error { + configuration := Get() + u.users = []types.User{} + mode := configuration.Mode.Load() + allUsers := configuration.GetUsers() // single + cluster mode + if len(allUsers) > 0 { + for _, storageUser := range allUsers { + if mode != ModeCluster || strings.HasPrefix(storageUser.Name, storagetype.DapiClusterUserPrefix) { + user := types.User{ + Name: storageUser.Name, + } + if storageUser.Password != nil { + user.Password = *storageUser.Password + } + if storageUser.Insecure != nil { + user.IsInsecure = *storageUser.Insecure + } + u.users = append(u.users, user) + } + } + return nil + } + if mode == ModeCluster { + return nil + } + if configuration.HAProxy.UserListFile != "" { + errUserList := u.getUsersFromUsersListSection(configuration.HAProxy.UserListFile, configuration.HAProxy.Userlist) + if errUserList != nil { + return errUserList // file was specified, but errors exists, exit + } + return nil + } + return u.getUsersFromUsersListSection(configuration.HAProxy.ConfigFile, configuration.HAProxy.Userlist) +} + +func (u *Users) AddUser(user types.User) error { + clusterModeStorage := Get().GetClusterModeStorage() + + u.users = append(u.users, user) + + err := clusterModeStorage.AddUserAndStore(storagetype.User{ + Name: user.Name, + Insecure: &user.IsInsecure, + Password: &user.Password, + }) + return err +} + +func (u *Users) RemoveUser(user types.User) error { + clusterModeStorage := Get().GetClusterModeStorage() + + for i, v := range u.users { + if v.Name == user.Name { + u.users = slices.Delete(u.users, i, i+1) + break + } + } + err := clusterModeStorage.RemoveUserAndStore(storagetype.User{ + Name: user.Name, + Insecure: &user.IsInsecure, + Password: &user.Password, + }) + return err +} + +func (u *Users) getUsersFromUsersListSection(filename, userlistSection string) error { + // if file doesn't exists + if _, err := os.Stat(filename); errors.Is(err, fs.ErrNotExist) { + return fmt.Errorf("cannot read %s, file does not exist", filename) + } + p, errP := parser.New(options.Path(filename)) + if errP != nil { + return errP + } + data, err := p.Get(parser.UserList, userlistSection, "user") + if err != nil { + return fmt.Errorf("no users configured in %v, error: %w", filename, err) + } + + return u.setUser(data, cfg.HAProxy.UserListFile) +} + +// findUser searches user by its name. If found, returns user, otherwise returns an error. +func findUser(userName string, users []types.User) (*types.User, error) { + for _, u := range users { + if u.Name == userName { + return &u, nil + } + } + return nil, api_errors.New(401, "no configured users") +} + +func AuthenticateUser(user string, pass string) (any, error) { + users := GetUsersStore().GetUsers() + if len(users) == 0 { + return nil, api_errors.New(http.StatusUnauthorized, "no configured users") + } + + unatuhorized := false + u, err := findUser(user, users) + if err != nil { + unatuhorized = true + } + + userPass := mockPass + if u != nil { + userPass = u.Password + } + + if strings.HasPrefix(userPass, "\"${") && strings.HasSuffix(userPass, "}\"") { + userPass = os.Getenv(misc.ExtractEnvVar(userPass)) + if userPass == "" { + unatuhorized = true + userPass = mockPass + } + } + + if u != nil && u.IsInsecure { + if pass != userPass { + unatuhorized = true + } + } else { + if !checkPassword(pass, userPass) { + unatuhorized = true + } + } + if unatuhorized { + return nil, api_errors.New(http.StatusUnauthorized, "unauthorized") + } + return user, nil +} + +func checkPassword(pass, storedPass string) bool { + parts := strings.Split(storedPass, "$") + if len(parts) == 4 { + var c crypt.Crypter + switch parts[1] { + case "1": + c = crypt.MD5.New() + case "5": + c = crypt.SHA256.New() + case "6": + c = crypt.SHA512.New() + default: + return false + } + if err := c.Verify(storedPass, []byte(pass)); err == nil { + return true + } + } + + return false +} diff --git a/configuration/watcher.go b/configuration/watcher.go new file mode 100644 index 00000000..39de16a3 --- /dev/null +++ b/configuration/watcher.go @@ -0,0 +1,113 @@ +// Copyright 2020 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "context" + "crypto/md5" + "encoding/hex" + "os" + "path/filepath" + "strings" + + "github.com/fsnotify/fsnotify" + "github.com/haproxytech/dataplaneapi/log" +) + +type ConfigWatcherParams struct { + Ctx context.Context + Callback func() + FilePath string + Version string +} + +type ConfigWatcher struct { + callback func() + done <-chan struct{} + wa *fsnotify.Watcher + configFile string +} + +func NewConfigWatcher(params ConfigWatcherParams) (*ConfigWatcher, error) { + watcher, err := fsnotify.NewWatcher() + if err != nil { + log.Infof("Failed to initialize watcher: %s", err.Error()) + return nil, err + } + if err := watcher.Add(filepath.Dir(params.FilePath)); err != nil { + log.Infof("Failed to watch config file: %s: %s", params.FilePath, err.Error()) + return nil, err + } + + ctx := params.Ctx + if ctx == nil { + ctx = context.Background() + } + cw := &ConfigWatcher{ + wa: watcher, + configFile: params.FilePath, + callback: params.Callback, + done: ctx.Done(), + } + return cw, nil +} + +func (w *ConfigWatcher) Listen() { + defer w.wa.Close() + for { + select { + case event, ok := <-w.wa.Events: + if !ok { + return + } + if event.Name != w.configFile { + continue + } + if w.checkFlags(event) { + if w.invalidHash() { + w.callback() + } + } + case err, ok := <-w.wa.Errors: + log.Infof("Closing config file watcher watcher: %s", err.Error()) + if !ok { + return + } + case <-w.done: + return + } + } +} + +func (w *ConfigWatcher) checkFlags(event fsnotify.Event) bool { + return event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Create == fsnotify.Create +} + +func (w *ConfigWatcher) invalidHash() bool { + content, err := os.ReadFile(w.configFile) + if err != nil { + log.Warningf("Watcher: error reading config file: %s", err.Error()) + return false + } + lines := strings.Split(string(content), "\n") + parts := strings.Split(lines[0], "=") + if len(parts) != 2 || parts[0] != "# _md5hash" { + return true + } + bHash := md5.Sum([]byte(strings.Join(lines[1:], "\n"))) + hash := hex.EncodeToString(bHash[:]) + return parts[1] != hash +} diff --git a/configure_data_plane.go b/configure_data_plane.go index 257aaad4..ae96c5d4 100644 --- a/configure_data_plane.go +++ b/configure_data_plane.go @@ -18,46 +18,51 @@ package dataplaneapi import ( + "context" "crypto/tls" "encoding/json" - "fmt" + "io" "net/http" "os" "os/signal" - "path/filepath" "runtime/debug" "strings" + "sync" "syscall" - "github.com/haproxytech/dataplaneapi/adapters" - "github.com/haproxytech/dataplaneapi/operations/specification" - - parser "github.com/haproxytech/config-parser" - "github.com/haproxytech/config-parser/types" - - log "github.com/sirupsen/logrus" - - "github.com/haproxytech/dataplaneapi/misc" - + "github.com/getkin/kin-openapi/openapi2" + "github.com/getkin/kin-openapi/openapi2conv" + "github.com/getkin/kin-openapi/openapi3" + api_errors "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/haproxytech/dataplaneapi/operations/discovery" - - client_native "github.com/haproxytech/client-native" + "github.com/go-openapi/swag/cmdutils" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/client-native/v6/options" + cn_runtime "github.com/haproxytech/client-native/v6/runtime" + "github.com/haproxytech/client-native/v6/spoe" + "github.com/haproxytech/client-native/v6/storage" + "github.com/haproxytech/dataplaneapi/log" + jsoniter "github.com/json-iterator/go" + "github.com/rs/cors" - "github.com/haproxytech/client-native/configuration" - runtime_api "github.com/haproxytech/client-native/runtime" + "github.com/haproxytech/dataplaneapi/adapters" + cn "github.com/haproxytech/dataplaneapi/client-native" + dataplaneapi_config "github.com/haproxytech/dataplaneapi/configuration" + service_discovery "github.com/haproxytech/dataplaneapi/discovery" "github.com/haproxytech/dataplaneapi/handlers" "github.com/haproxytech/dataplaneapi/haproxy" - - errors "github.com/go-openapi/errors" - runtime "github.com/go-openapi/runtime" - swag "github.com/go-openapi/swag" - "github.com/rs/cors" - + "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations" + "github.com/haproxytech/dataplaneapi/operations/discovery" + "github.com/haproxytech/dataplaneapi/operations/specification" + "github.com/haproxytech/dataplaneapi/operations/specification_openapiv3" + "github.com/haproxytech/dataplaneapi/rate" + "github.com/haproxytech/dataplaneapi/resilient" + socket_runtime "github.com/haproxytech/dataplaneapi/runtime" - "github.com/GehirnInc/crypt" - // import various crypting algorihtms + // import various crypting algorithms _ "github.com/GehirnInc/crypt/md5_crypt" _ "github.com/GehirnInc/crypt/sha256_crypt" _ "github.com/GehirnInc/crypt/sha512_crypt" @@ -65,112 +70,169 @@ import ( //go:generate swagger generate server --target ../../../../../../github.com/haproxytech --name controller --spec ../../../../../../../../haproxy-api/haproxy-open-api-spec/build/haproxy_spec.yaml --server-package controller --tags Stats --tags Information --tags Configuration --tags Discovery --tags Frontend --tags Backend --tags Bind --tags Server --tags TCPRequestRule --tags HTTPRequestRule --tags HTTPResponseRule --tags Acl --tags BackendSwitchingRule --tags ServerSwitchingRule --tags TCPResponseRule --skip-models --exclude-main -var Version string -var BuildTime string - -var haproxyOptions struct { - ConfigFile string `short:"c" long:"config-file" description:"Path to the haproxy configuration file" default:"/etc/haproxy/haproxy.cfg"` - Userlist string `short:"u" long:"userlist" description:"Userlist in HAProxy configuration to use for API Basic Authentication" default:"controller"` - HAProxy string `short:"b" long:"haproxy-bin" description:"Path to the haproxy binary file" default:"haproxy"` - ReloadDelay int `short:"d" long:"reload-delay" description:"Minimum delay between two reloads (in s)" default:"5"` - ReloadCmd string `short:"r" long:"reload-cmd" description:"Reload command"` - RestartCmd string `short:"s" long:"restart-cmd" description:"Restart command"` - ReloadRetention int `long:"reload-retention" description:"Reload retention in days, every older reload id will be deleted" default:"1"` - TransactionDir string `short:"t" long:"transaction-dir" description:"Path to the transaction directory" default:"/tmp/haproxy"` - BackupsNumber int `short:"n" long:"backups-number" description:"Number of backup configuration files you want to keep, stored in the config dir with version number suffix" default:"0"` - MasterRuntime string `short:"m" long:"master-runtime" description:"Path to the master Runtime API socket"` - ShowSystemInfo bool `short:"i" long:"show-system-info" description:"Show system info on info endpoint"` -} +var ( + Version string + BuildTime string + mWorker = false + logFile *os.File + AppLogger *log.Logger + AccLogger *log.Logger + serverStartedCallback func() + clientMutex sync.Mutex + eventListener *cn.HAProxyEventListener +) -var loggingOptions struct { - LogTo string `long:"log-to" description:"Log target, can be stdout or file" default:"stdout" choice:"stdout" choice:"file"` - LogFile string `long:"log-file" description:"Location of the log file" default:"/var/log/dataplaneapi/dataplaneapi.log"` - LogLevel string `long:"log-level" description:"Logging level" default:"warning" choice:"trace" choice:"debug" choice:"info" choice:"warning" choice:"error"` - LogFormat string `long:"log-format" description:"Logging format" default:"text" choice:"text" choice:"JSON"` +func SetServerStartedCallback(callFunc func()) { + serverStartedCallback = callFunc } -var logFile *os.File - func configureFlags(api *operations.DataPlaneAPI) { - haproxyOptionsGroup := swag.CommandLineOptionsGroup{ + cfg := dataplaneapi_config.Get() + + haproxyOptionsGroup := cmdutils.CommandLineOptionsGroup{ ShortDescription: "HAProxy options", LongDescription: "Options for configuring haproxy locations.", - Options: &haproxyOptions, + Options: &cfg.HAProxy, } - loggingOptionsGroup := swag.CommandLineOptionsGroup{ + loggingOptionsGroup := cmdutils.CommandLineOptionsGroup{ ShortDescription: "Logging options", LongDescription: "Options for configuring logging.", - Options: &loggingOptions, + Options: &cfg.Logging, } - api.CommandLineOptionsGroups = make([]swag.CommandLineOptionsGroup, 0, 1) + syslogOptionsGroup := cmdutils.CommandLineOptionsGroup{ + ShortDescription: "Syslog options", + LongDescription: "Options for configuring syslog logging.", + Options: &cfg.Syslog, + } + + api.CommandLineOptionsGroups = make([]cmdutils.CommandLineOptionsGroup, 0, 1) api.CommandLineOptionsGroups = append(api.CommandLineOptionsGroups, haproxyOptionsGroup) api.CommandLineOptionsGroups = append(api.CommandLineOptionsGroups, loggingOptionsGroup) + api.CommandLineOptionsGroups = append(api.CommandLineOptionsGroups, syslogOptionsGroup) } -func configureAPI(api *operations.DataPlaneAPI) http.Handler { - configureLogging() +func configureAPI(api *operations.DataPlaneAPI) http.Handler { //nolint:cyclop,maintidx + clientMutex.Lock() + defer clientMutex.Unlock() - defer func() { - if err := recover(); err != nil { - log.Fatalf("Error starting Data Plane API: %s\n Stacktrace from panic: \n%s", err, string(debug.Stack())) + cfg := dataplaneapi_config.Get() + + haproxyOptions := cfg.HAProxy + // Override options with env variables + if os.Getenv("HAPROXY_MWORKER") == "1" { + mWorker = true + masterRuntime := os.Getenv("HAPROXY_MASTER_CLI") + if misc.IsUnixSocketAddr(masterRuntime) { + haproxyOptions.MasterRuntime = strings.Replace(masterRuntime, "unix@", "", 1) } - }() + } + + if cfgFiles := os.Getenv("HAPROXY_CFGFILES"); cfgFiles != "" { + m := map[string]bool{"configuration": false} + if len(haproxyOptions.UserListFile) > 0 { + m["userlist"] = false + } + + for f := range strings.SplitSeq(cfgFiles, ";") { + var conf bool + var user bool + + if f == haproxyOptions.ConfigFile { + conf = true + m["configuration"] = true + } + if len(haproxyOptions.UserListFile) > 0 && f == haproxyOptions.UserListFile { + user = true + m["userlist"] = true + } + if !conf && !user { + log.Warningf("The configuration file %s in HAPROXY_CFGFILES is not defined, neither by --config-file or --userlist-file flags.", f) + } + } + for f, ok := range m { + if !ok { + log.Fatalf("The %s file is not declared in the HAPROXY_CFGFILES environment variable, cannot start.", f) + } + } + } + // end overriding options with env variables + // configure the api here - api.ServeError = errors.ServeError + api.ServeError = api_errors.ServeError // Set your custom logger if needed. Default one is log.Printf - // Expected interface func(string, ...interface{}) + // Expected interface func(string, ...any) // // Example: api.Logger = log.Printf - api.JSONConsumer = runtime.JSONConsumer() + api.JSONConsumer = runtime.ConsumerFunc(func(reader io.Reader, data any) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary + dec := json.NewDecoder(reader) + dec.UseNumber() // preserve number formats + return dec.Decode(data) + }) api.TxtConsumer = runtime.TextConsumer() - api.JSONProducer = runtime.JSONProducer() - - api.TxtProducer = runtime.TextProducer() + api.JSONProducer = runtime.ProducerFunc(func(writer io.Writer, data any) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary + enc := json.NewEncoder(writer) + enc.SetEscapeHTML(false) + return enc.Encode(data) + }) api.ServerShutdown = serverShutdown - client := configureNativeClient() + ctx := ContextHandler.Context() + clientCtx, cancel := context.WithCancel(ctx) + + client := configureNativeClient(clientCtx, haproxyOptions, mWorker) + + initDataplaneStorage(haproxyOptions.DataplaneStorageDir, client) + + configureEventListener(clientCtx, client) + + users := dataplaneapi_config.GetUsersStore() + // this is not part of GetUsersStore(), + // in case of reload we need to reread users + // mode might have changed from single to cluster one + if err := users.Init(); err != nil { + log.Fatalf("Error initiating users: %s", err.Error()) + } // Handle reload signals sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGUSR1, syscall.SIGUSR2) - go handleSignals(sigs, client) + go handleSignals(ctx, cancel, sigs, client, haproxyOptions, users) - // Initialize reload agent - ra := &haproxy.ReloadAgent{} - if err := ra.Init(haproxyOptions.ReloadDelay, haproxyOptions.ReloadCmd, haproxyOptions.RestartCmd, haproxyOptions.ConfigFile, haproxyOptions.ReloadRetention); err != nil { - log.Fatalf("Cannot initialize reload agent: %v", err) + ra := configureReloadAgent(haproxyOptions, client, ctx) + + if !haproxyOptions.DisableInotify { + if err := startWatcher(ctx, client, haproxyOptions, users, ra); err != nil { + haproxyOptions.DisableInotify = true + client = configureNativeClient(clientCtx, haproxyOptions, mWorker) + ra = configureReloadAgent(haproxyOptions, client, ctx) + } } - // Applies when the Authorization header is set with the Basic scheme - api.BasicAuthAuth = func(user string, pass string) (interface{}, error) { - return authenticateUser(user, pass, client) + // Sync map physical file with runtime map entries + if haproxyOptions.UpdateMapFiles { + go cfg.MapSync.SyncAll(client) } - // setup discovery handlers - api.DiscoveryGetAPIEndpointsHandler = discovery.GetAPIEndpointsHandlerFunc(func(params discovery.GetAPIEndpointsParams, principal interface{}) middleware.Responder { - uriSlice := strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2) - rURI := "" - if len(uriSlice) < 2 { - rURI = "/" - } else { - rURI = "/" + uriSlice[1] - } - ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) + // setup discovery handlers + api.DiscoveryGetAPIEndpointsHandler = discovery.GetAPIEndpointsHandlerFunc(func(params discovery.GetAPIEndpointsParams, principal any) middleware.Responder { + ends, err := misc.DiscoverChildPaths("", SwaggerJSON) if err != nil { e := misc.HandleError(err) return discovery.NewGetAPIEndpointsDefault(int(*e.Code)).WithPayload(e) } return discovery.NewGetAPIEndpointsOK().WithPayload(ends) }) - api.DiscoveryGetServicesEndpointsHandler = discovery.GetServicesEndpointsHandlerFunc(func(params discovery.GetServicesEndpointsParams, principal interface{}) middleware.Responder { + api.DiscoveryGetServicesEndpointsHandler = discovery.GetServicesEndpointsHandlerFunc(func(params discovery.GetServicesEndpointsParams, principal any) middleware.Responder { rURI := "/" + strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2)[1] ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) if err != nil { @@ -179,7 +241,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { } return discovery.NewGetServicesEndpointsOK().WithPayload(ends) }) - api.DiscoveryGetConfigurationEndpointsHandler = discovery.GetConfigurationEndpointsHandlerFunc(func(params discovery.GetConfigurationEndpointsParams, principal interface{}) middleware.Responder { + api.DiscoveryGetConfigurationEndpointsHandler = discovery.GetConfigurationEndpointsHandlerFunc(func(params discovery.GetConfigurationEndpointsParams, principal any) middleware.Responder { rURI := "/" + strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2)[1] ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) if err != nil { @@ -188,7 +250,16 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { } return discovery.NewGetConfigurationEndpointsOK().WithPayload(ends) }) - api.DiscoveryGetHaproxyEndpointsHandler = discovery.GetHaproxyEndpointsHandlerFunc(func(params discovery.GetHaproxyEndpointsParams, principal interface{}) middleware.Responder { + api.DiscoveryGetRuntimeEndpointsHandler = discovery.GetRuntimeEndpointsHandlerFunc(func(params discovery.GetRuntimeEndpointsParams, principal any) middleware.Responder { + rURI := "/" + strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2)[1] + ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) + if err != nil { + e := misc.HandleError(err) + return discovery.NewGetRuntimeEndpointsDefault(int(*e.Code)).WithPayload(e) + } + return discovery.NewGetRuntimeEndpointsOK().WithPayload(ends) + }) + api.DiscoveryGetHaproxyEndpointsHandler = discovery.GetHaproxyEndpointsHandlerFunc(func(params discovery.GetHaproxyEndpointsParams, principal any) middleware.Responder { rURI := "/" + strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2)[1] ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) if err != nil { @@ -197,7 +268,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { } return discovery.NewGetHaproxyEndpointsOK().WithPayload(ends) }) - api.DiscoveryGetStatsEndpointsHandler = discovery.GetStatsEndpointsHandlerFunc(func(params discovery.GetStatsEndpointsParams, principal interface{}) middleware.Responder { + api.DiscoveryGetStatsEndpointsHandler = discovery.GetStatsEndpointsHandlerFunc(func(params discovery.GetStatsEndpointsParams, principal any) middleware.Responder { rURI := "/" + strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2)[1] ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) if err != nil { @@ -206,13 +277,60 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { } return discovery.NewGetStatsEndpointsOK().WithPayload(ends) }) + api.DiscoveryGetSpoeEndpointsHandler = discovery.GetSpoeEndpointsHandlerFunc(func(params discovery.GetSpoeEndpointsParams, principal any) middleware.Responder { + rURI := "/" + strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2)[1] + ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) + if err != nil { + e := misc.HandleError(err) + return discovery.NewGetSpoeEndpointsDefault(int(*e.Code)).WithPayload(e) + } + return discovery.NewGetSpoeEndpointsOK().WithPayload(ends) + }) + api.DiscoveryGetStorageEndpointsHandler = discovery.GetStorageEndpointsHandlerFunc(func(params discovery.GetStorageEndpointsParams, principal any) middleware.Responder { + rURI := "/" + strings.SplitN(params.HTTPRequest.RequestURI[1:], "/", 2)[1] + ends, err := misc.DiscoverChildPaths(rURI, SwaggerJSON) + if err != nil { + e := misc.HandleError(err) + return discovery.NewGetStorageEndpointsDefault(int(*e.Code)).WithPayload(e) + } + return discovery.NewGetStorageEndpointsOK().WithPayload(ends) + }) // setup transaction handlers + client = resilient.NewClient(client) api.TransactionsStartTransactionHandler = &handlers.StartTransactionHandlerImpl{Client: client} api.TransactionsDeleteTransactionHandler = &handlers.DeleteTransactionHandlerImpl{Client: client} api.TransactionsGetTransactionHandler = &handlers.GetTransactionHandlerImpl{Client: client} api.TransactionsGetTransactionsHandler = &handlers.GetTransactionsHandlerImpl{Client: client} - api.TransactionsCommitTransactionHandler = &handlers.CommitTransactionHandlerImpl{Client: client, ReloadAgent: ra} + api.TransactionsCommitTransactionHandler = &handlers.CommitTransactionHandlerImpl{Client: client, ReloadAgent: ra, Mutex: &sync.Mutex{}} + if cfg.HAProxy.MaxOpenTransactions > 0 { + // creating the threshold limit using the CLI flag as hard quota and current open transactions as starting point + actualCount := func() uint64 { + configuration, err := client.Configuration() + if err != nil { + log.Errorf("Cannot retrieve current open transactions for rate limit, default to zero (%s)", err.Error()) + return 0 + } + ts, err := configuration.GetTransactions(models.TransactionStatusInProgress) + if err != nil { + log.Errorf("Cannot retrieve current open transactions for rate limit, default to zero (%s)", err.Error()) + return 0 + } + return uint64(len(*ts)) + } + transactionLimiter := rate.NewThresholdLimit(uint64(cfg.HAProxy.MaxOpenTransactions), actualCount) + api.TransactionsStartTransactionHandler = &handlers.RateLimitedStartTransactionHandlerImpl{ + TransactionCounter: transactionLimiter, + Handler: api.TransactionsStartTransactionHandler, + } + } + + // setup transaction handlers + api.SpoeTransactionsStartSpoeTransactionHandler = &handlers.SpoeTransactionsStartSpoeTransactionHandlerImpl{Client: client} + api.SpoeTransactionsDeleteSpoeTransactionHandler = &handlers.SpoeTransactionsDeleteSpoeTransactionHandlerImpl{Client: client} + api.SpoeTransactionsGetSpoeTransactionHandler = &handlers.SpoeTransactionsGetSpoeTransactionHandlerImpl{Client: client} + api.SpoeTransactionsGetAllSpoeTransactionHandler = &handlers.SpoeTransactionsGetAllSpoeTransactionHandlerImpl{Client: client} + api.SpoeTransactionsCommitSpoeTransactionHandler = &handlers.SpoeTransactionsCommitSpoeTransactionHandlerImpl{Client: client, ReloadAgent: ra} // setup sites handlers api.SitesCreateSiteHandler = &handlers.CreateSiteHandlerImpl{Client: client, ReloadAgent: ra} @@ -228,6 +346,27 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { api.BackendGetBackendsHandler = &handlers.GetBackendsHandlerImpl{Client: client} api.BackendReplaceBackendHandler = &handlers.ReplaceBackendHandlerImpl{Client: client, ReloadAgent: ra} + // setup ring handlers + api.RingCreateRingHandler = &handlers.CreateRingHandlerImpl{Client: client, ReloadAgent: ra} + api.RingDeleteRingHandler = &handlers.DeleteRingHandlerImpl{Client: client, ReloadAgent: ra} + api.RingGetRingHandler = &handlers.GetRingHandlerImpl{Client: client} + api.RingGetRingsHandler = &handlers.GetRingsHandlerImpl{Client: client} + api.RingReplaceRingHandler = &handlers.ReplaceRingHandlerImpl{Client: client, ReloadAgent: ra} + + // setup log forward handlers + api.LogForwardCreateLogForwardHandler = &handlers.CreateLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + api.LogForwardDeleteLogForwardHandler = &handlers.DeleteLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + api.LogForwardGetLogForwardHandler = &handlers.GetLogForwardHandlerImpl{Client: client} + api.LogForwardGetLogForwardsHandler = &handlers.GetLogForwardsHandlerImpl{Client: client} + api.LogForwardReplaceLogForwardHandler = &handlers.ReplaceLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + + // setup dgram bind handlers + api.DgramBindCreateDgramBindHandler = &handlers.CreateDgramBindHandlerImpl{Client: client, ReloadAgent: ra} + api.DgramBindDeleteDgramBindHandler = &handlers.DeleteDgramBindHandlerImpl{Client: client, ReloadAgent: ra} + api.DgramBindGetDgramBindHandler = &handlers.GetDgramBindHandlerImpl{Client: client} + api.DgramBindGetDgramBindsHandler = &handlers.GetDgramBindsHandlerImpl{Client: client} + api.DgramBindReplaceDgramBindHandler = &handlers.ReplaceDgramBindHandlerImpl{Client: client, ReloadAgent: ra} + // setup frontend handlers api.FrontendCreateFrontendHandler = &handlers.CreateFrontendHandlerImpl{Client: client, ReloadAgent: ra} api.FrontendDeleteFrontendHandler = &handlers.DeleteFrontendHandlerImpl{Client: client, ReloadAgent: ra} @@ -235,47 +374,214 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { api.FrontendGetFrontendsHandler = &handlers.GetFrontendsHandlerImpl{Client: client} api.FrontendReplaceFrontendHandler = &handlers.ReplaceFrontendHandlerImpl{Client: client, ReloadAgent: ra} + // setup userlist handlers + api.UserlistCreateUserlistHandler = &handlers.CreateUserListHandlerImpl{Client: client, ReloadAgent: ra} + api.UserlistDeleteUserlistHandler = &handlers.DeleteUserListHandlerImpl{Client: client, ReloadAgent: ra} + api.UserlistGetUserlistHandler = &handlers.GetUserListHandlerImpl{Client: client} + api.UserlistGetUserlistsHandler = &handlers.GetUserListsHandlerImpl{Client: client} + + // setup user handlers + api.UserCreateUserHandler = &handlers.CreateUserHandlerImpl{Client: client, ReloadAgent: ra} + api.UserDeleteUserHandler = &handlers.DeleteUserHandlerImpl{Client: client, ReloadAgent: ra} + api.UserGetUserHandler = &handlers.GetUserHandlerImpl{Client: client} + api.UserGetUsersHandler = &handlers.GetUsersHandlerImpl{Client: client} + api.UserReplaceUserHandler = &handlers.ReplaceUserHandlerImpl{Client: client, ReloadAgent: ra} + + // setup group handlers + api.GroupCreateGroupHandler = &handlers.CreateGroupHandlerImpl{Client: client, ReloadAgent: ra} + api.GroupDeleteGroupHandler = &handlers.DeleteGroupHandlerImpl{Client: client, ReloadAgent: ra} + api.GroupGetGroupHandler = &handlers.GetGroupHandlerImpl{Client: client} + api.GroupGetGroupsHandler = &handlers.GetGroupsHandlerImpl{Client: client} + api.GroupReplaceGroupHandler = &handlers.ReplaceGroupHandlerImpl{Client: client, ReloadAgent: ra} + // setup server handlers - api.ServerCreateServerHandler = &handlers.CreateServerHandlerImpl{Client: client, ReloadAgent: ra} - api.ServerDeleteServerHandler = &handlers.DeleteServerHandlerImpl{Client: client, ReloadAgent: ra} - api.ServerGetServerHandler = &handlers.GetServerHandlerImpl{Client: client} - api.ServerGetServersHandler = &handlers.GetServersHandlerImpl{Client: client} - api.ServerReplaceServerHandler = &handlers.ReplaceServerHandlerImpl{Client: client, ReloadAgent: ra} + // Create + api.ServerCreateServerBackendHandler = &handlers.CreateServerBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerCreateServerPeerHandler = &handlers.CreateServerPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerCreateServerRingHandler = &handlers.CreateServerRingHandlerImpl{Client: client, ReloadAgent: ra} + // Get all + api.ServerGetAllServerBackendHandler = &handlers.GetAllServerBackendHandlerImpl{Client: client} + api.ServerGetAllServerPeerHandler = &handlers.GetAllServerPeerHandlerImpl{Client: client} + api.ServerGetAllServerRingHandler = &handlers.GetAllServerRingHandlerImpl{Client: client} + // Delete one + api.ServerDeleteServerBackendHandler = &handlers.DeleteServerBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerDeleteServerPeerHandler = &handlers.DeleteServerPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerDeleteServerRingHandler = &handlers.DeleteServerRingHandlerImpl{Client: client, ReloadAgent: ra} + // Get one + api.ServerGetServerBackendHandler = &handlers.GetServerBackendHandlerImpl{Client: client} + api.ServerGetServerPeerHandler = &handlers.GetServerPeerHandlerImpl{Client: client} + api.ServerGetServerRingHandler = &handlers.GetServerRingHandlerImpl{Client: client} + // Replace one + api.ServerReplaceServerBackendHandler = &handlers.ReplaceServerBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerReplaceServerPeerHandler = &handlers.ReplaceServerPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerReplaceServerRingHandler = &handlers.ReplaceServerRingHandlerImpl{Client: client, ReloadAgent: ra} + + // setup server template handlers + api.ServerTemplateCreateServerTemplateHandler = &handlers.CreateServerTemplateHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerTemplateDeleteServerTemplateHandler = &handlers.DeleteServerTemplateHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerTemplateGetServerTemplateHandler = &handlers.GetServerTemplateHandlerImpl{Client: client} + api.ServerTemplateGetServerTemplatesHandler = &handlers.GetServerTemplatesHandlerImpl{Client: client} + api.ServerTemplateReplaceServerTemplateHandler = &handlers.ReplaceServerTemplateHandlerImpl{Client: client, ReloadAgent: ra} // setup bind handlers - api.BindCreateBindHandler = &handlers.CreateBindHandlerImpl{Client: client, ReloadAgent: ra} - api.BindDeleteBindHandler = &handlers.DeleteBindHandlerImpl{Client: client, ReloadAgent: ra} - api.BindGetBindHandler = &handlers.GetBindHandlerImpl{Client: client} - api.BindGetBindsHandler = &handlers.GetBindsHandlerImpl{Client: client} - api.BindReplaceBindHandler = &handlers.ReplaceBindHandlerImpl{Client: client, ReloadAgent: ra} + api.BindCreateBindFrontendHandler = &handlers.CreateBindFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.BindDeleteBindFrontendHandler = &handlers.DeleteBindFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.BindGetBindFrontendHandler = &handlers.GetBindFrontendHandlerImpl{Client: client} + api.BindGetAllBindFrontendHandler = &handlers.GetAllBindFrontendHandlerImpl{Client: client} + api.BindReplaceBindFrontendHandler = &handlers.ReplaceBindFrontendHandlerImpl{Client: client, ReloadAgent: ra} + + api.BindCreateBindPeerHandler = &handlers.CreateBindPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.BindDeleteBindPeerHandler = &handlers.DeleteBindPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.BindGetBindPeerHandler = &handlers.GetBindPeerHandlerImpl{Client: client} + api.BindGetAllBindPeerHandler = &handlers.GetAllBindPeerHandlerImpl{Client: client} + api.BindReplaceBindPeerHandler = &handlers.ReplaceBindPeerHandlerImpl{Client: client, ReloadAgent: ra} + + api.BindCreateBindLogForwardHandler = &handlers.CreateBindLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + api.BindDeleteBindLogForwardHandler = &handlers.DeleteBindLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + api.BindGetBindLogForwardHandler = &handlers.GetBindLogForwardHandlerImpl{Client: client} + api.BindGetAllBindLogForwardHandler = &handlers.GetAllBindLogForwardHandlerImpl{Client: client} + api.BindReplaceBindLogForwardHandler = &handlers.ReplaceBindLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + + // setup http check handlers + api.HTTPCheckGetHTTPCheckBackendHandler = &handlers.GetHTTPCheckBackendHandlerImpl{Client: client} + api.HTTPCheckGetAllHTTPCheckBackendHandler = &handlers.GetAllHTTPCheckBackendHandlerImpl{Client: client} + api.HTTPCheckCreateHTTPCheckBackendHandler = &handlers.CreateHTTPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPCheckReplaceHTTPCheckBackendHandler = &handlers.ReplaceHTTPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPCheckDeleteHTTPCheckBackendHandler = &handlers.DeleteHTTPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPCheckReplaceAllHTTPCheckBackendHandler = &handlers.ReplaceAllHTTPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPCheckGetHTTPCheckDefaultsHandler = &handlers.GetHTTPCheckDefaultsHandlerImpl{Client: client} + api.HTTPCheckGetAllHTTPCheckDefaultsHandler = &handlers.GetAllHTTPCheckDefaultsHandlerImpl{Client: client} + api.HTTPCheckCreateHTTPCheckDefaultsHandler = &handlers.CreateHTTPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPCheckReplaceHTTPCheckDefaultsHandler = &handlers.ReplaceHTTPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPCheckDeleteHTTPCheckDefaultsHandler = &handlers.DeleteHTTPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPCheckReplaceAllHTTPCheckDefaultsHandler = &handlers.ReplaceAllHTTPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} // setup http request rule handlers - api.HTTPRequestRuleCreateHTTPRequestRuleHandler = &handlers.CreateHTTPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.HTTPRequestRuleDeleteHTTPRequestRuleHandler = &handlers.DeleteHTTPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.HTTPRequestRuleGetHTTPRequestRuleHandler = &handlers.GetHTTPRequestRuleHandlerImpl{Client: client} - api.HTTPRequestRuleGetHTTPRequestRulesHandler = &handlers.GetHTTPRequestRulesHandlerImpl{Client: client} - api.HTTPRequestRuleReplaceHTTPRequestRuleHandler = &handlers.ReplaceHTTPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleCreateHTTPRequestRuleBackendHandler = &handlers.CreateHTTPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleDeleteHTTPRequestRuleBackendHandler = &handlers.DeleteHTTPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleGetHTTPRequestRuleBackendHandler = &handlers.GetHTTPRequestRuleBackendHandlerImpl{Client: client} + api.HTTPRequestRuleGetAllHTTPRequestRuleBackendHandler = &handlers.GetAllHTTPRequestRuleBackendHandlerImpl{Client: client} + api.HTTPRequestRuleReplaceHTTPRequestRuleBackendHandler = &handlers.ReplaceHTTPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleReplaceAllHTTPRequestRuleBackendHandler = &handlers.ReplaceAllHTTPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleCreateHTTPRequestRuleFrontendHandler = &handlers.CreateHTTPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleDeleteHTTPRequestRuleFrontendHandler = &handlers.DeleteHTTPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleGetHTTPRequestRuleFrontendHandler = &handlers.GetHTTPRequestRuleFrontendHandlerImpl{Client: client} + api.HTTPRequestRuleGetAllHTTPRequestRuleFrontendHandler = &handlers.GetAllHTTPRequestRuleFrontendHandlerImpl{Client: client} + api.HTTPRequestRuleReplaceHTTPRequestRuleFrontendHandler = &handlers.ReplaceHTTPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPRequestRuleReplaceAllHTTPRequestRuleFrontendHandler = &handlers.ReplaceAllHTTPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + + // setup http after response rule handlers + api.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleBackendHandler = &handlers.CreateHTTPAfterResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleBackendHandler = &handlers.DeleteHTTPAfterResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPAfterResponseRuleGetHTTPAfterResponseRuleBackendHandler = &handlers.GetHTTPAfterResponseRuleBackendHandlerImpl{Client: client} + api.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleBackendHandler = &handlers.GetAllHTTPAfterResponseRuleBackendHandlerImpl{Client: client} + api.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleBackendHandler = &handlers.ReplaceHTTPAfterResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleBackendHandler = &handlers.ReplaceAllHTTPAfterResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleFrontendHandler = &handlers.CreateHTTPAfterResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleFrontendHandler = &handlers.DeleteHTTPAfterResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPAfterResponseRuleGetHTTPAfterResponseRuleFrontendHandler = &handlers.GetHTTPAfterResponseRuleFrontendHandlerImpl{Client: client} + api.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleFrontendHandler = &handlers.GetAllHTTPAfterResponseRuleFrontendHandlerImpl{Client: client} + api.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleFrontendHandler = &handlers.ReplaceHTTPAfterResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleFrontendHandler = &handlers.ReplaceAllHTTPAfterResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} // setup http response rule handlers - api.HTTPResponseRuleCreateHTTPResponseRuleHandler = &handlers.CreateHTTPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.HTTPResponseRuleDeleteHTTPResponseRuleHandler = &handlers.DeleteHTTPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.HTTPResponseRuleGetHTTPResponseRuleHandler = &handlers.GetHTTPResponseRuleHandlerImpl{Client: client} - api.HTTPResponseRuleGetHTTPResponseRulesHandler = &handlers.GetHTTPResponseRulesHandlerImpl{Client: client} - api.HTTPResponseRuleReplaceHTTPResponseRuleHandler = &handlers.ReplaceHTTPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPResponseRuleCreateHTTPResponseRuleBackendHandler = &handlers.CreateHTTPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPResponseRuleDeleteHTTPResponseRuleBackendHandler = &handlers.DeleteHTTPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPResponseRuleGetHTTPResponseRuleBackendHandler = &handlers.GetHTTPResponseRuleBackendHandlerImpl{Client: client} + api.HTTPResponseRuleGetAllHTTPResponseRuleBackendHandler = &handlers.GetAllHTTPResponseRuleBackendHandlerImpl{Client: client} + api.HTTPResponseRuleReplaceHTTPResponseRuleBackendHandler = &handlers.ReplaceHTTPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPResponseRuleReplaceAllHTTPResponseRuleBackendHandler = &handlers.ReplaceAllHTTPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.HTTPResponseRuleCreateHTTPResponseRuleFrontendHandler = &handlers.CreateHTTPResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPResponseRuleDeleteHTTPResponseRuleFrontendHandler = &handlers.DeleteHTTPResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPResponseRuleGetHTTPResponseRuleFrontendHandler = &handlers.GetHTTPResponseRuleFrontendHandlerImpl{Client: client} + api.HTTPResponseRuleGetAllHTTPResponseRuleFrontendHandler = &handlers.GetAllHTTPResponseRuleFrontendHandlerImpl{Client: client} + api.HTTPResponseRuleReplaceHTTPResponseRuleFrontendHandler = &handlers.ReplaceHTTPResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPResponseRuleReplaceAllHTTPResponseRuleFrontendHandler = &handlers.ReplaceAllHTTPResponseRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + + // setup http error rule handlers + api.HTTPErrorRuleCreateHTTPErrorRuleBackendHandler = &handlers.CreateHTTPErrorRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleDeleteHTTPErrorRuleBackendHandler = &handlers.DeleteHTTPErrorRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleGetHTTPErrorRuleBackendHandler = &handlers.GetHTTPErrorRuleBackendHandlerImpl{Client: client} + api.HTTPErrorRuleGetAllHTTPErrorRuleBackendHandler = &handlers.GetAllHTTPErrorRuleBackendHandlerImpl{Client: client} + api.HTTPErrorRuleReplaceHTTPErrorRuleBackendHandler = &handlers.ReplaceHTTPErrorRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleReplaceAllHTTPErrorRuleBackendHandler = &handlers.ReplaceAllHTTPErrorRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.HTTPErrorRuleCreateHTTPErrorRuleFrontendHandler = &handlers.CreateHTTPErrorRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleDeleteHTTPErrorRuleFrontendHandler = &handlers.DeleteHTTPErrorRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleGetHTTPErrorRuleFrontendHandler = &handlers.GetHTTPErrorRuleFrontendHandlerImpl{Client: client} + api.HTTPErrorRuleGetAllHTTPErrorRuleFrontendHandler = &handlers.GetAllHTTPErrorRuleFrontendHandlerImpl{Client: client} + api.HTTPErrorRuleReplaceHTTPErrorRuleFrontendHandler = &handlers.ReplaceHTTPErrorRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleReplaceAllHTTPErrorRuleFrontendHandler = &handlers.ReplaceAllHTTPErrorRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + + api.HTTPErrorRuleCreateHTTPErrorRuleDefaultsHandler = &handlers.CreateHTTPErrorRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleDeleteHTTPErrorRuleDefaultsHandler = &handlers.DeleteHTTPErrorRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleGetHTTPErrorRuleDefaultsHandler = &handlers.GetHTTPErrorRuleDefaultsHandlerImpl{Client: client} + api.HTTPErrorRuleGetAllHTTPErrorRuleDefaultsHandler = &handlers.GetAllHTTPErrorRuleDefaultsHandlerImpl{Client: client} + api.HTTPErrorRuleReplaceHTTPErrorRuleDefaultsHandler = &handlers.ReplaceHTTPErrorRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorRuleReplaceAllHTTPErrorRuleDefaultsHandler = &handlers.ReplaceAllHTTPErrorRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} // setup tcp content rule handlers - api.TCPRequestRuleCreateTCPRequestRuleHandler = &handlers.CreateTCPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.TCPRequestRuleDeleteTCPRequestRuleHandler = &handlers.DeleteTCPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.TCPRequestRuleGetTCPRequestRuleHandler = &handlers.GetTCPRequestRuleHandlerImpl{Client: client} - api.TCPRequestRuleGetTCPRequestRulesHandler = &handlers.GetTCPRequestRulesHandlerImpl{Client: client} - api.TCPRequestRuleReplaceTCPRequestRuleHandler = &handlers.ReplaceTCPRequestRuleHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPRequestRuleCreateTCPRequestRuleBackendHandler = &handlers.CreateTCPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPRequestRuleDeleteTCPRequestRuleBackendHandler = &handlers.DeleteTCPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPRequestRuleGetTCPRequestRuleBackendHandler = &handlers.GetTCPRequestRuleBackendHandlerImpl{Client: client} + api.TCPRequestRuleGetAllTCPRequestRuleBackendHandler = &handlers.GetAllTCPRequestRuleBackendHandlerImpl{Client: client} + api.TCPRequestRuleReplaceTCPRequestRuleBackendHandler = &handlers.ReplaceTCPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPRequestRuleReplaceAllTCPRequestRuleBackendHandler = &handlers.ReplaceAllTCPRequestRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.TCPRequestRuleCreateTCPRequestRuleFrontendHandler = &handlers.CreateTCPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPRequestRuleDeleteTCPRequestRuleFrontendHandler = &handlers.DeleteTCPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPRequestRuleGetTCPRequestRuleFrontendHandler = &handlers.GetTCPRequestRuleFrontendHandlerImpl{Client: client} + api.TCPRequestRuleGetAllTCPRequestRuleFrontendHandler = &handlers.GetAllTCPRequestRuleFrontendHandlerImpl{Client: client} + api.TCPRequestRuleReplaceTCPRequestRuleFrontendHandler = &handlers.ReplaceTCPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPRequestRuleReplaceAllTCPRequestRuleFrontendHandler = &handlers.ReplaceAllTCPRequestRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} // setup tcp connection rule handlers - api.TCPResponseRuleCreateTCPResponseRuleHandler = &handlers.CreateTCPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.TCPResponseRuleDeleteTCPResponseRuleHandler = &handlers.DeleteTCPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra} - api.TCPResponseRuleGetTCPResponseRuleHandler = &handlers.GetTCPResponseRuleHandlerImpl{Client: client} - api.TCPResponseRuleGetTCPResponseRulesHandler = &handlers.GetTCPResponseRulesHandlerImpl{Client: client} - api.TCPResponseRuleReplaceTCPResponseRuleHandler = &handlers.ReplaceTCPResponseRuleHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPResponseRuleCreateTCPResponseRuleBackendHandler = &handlers.CreateTCPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPResponseRuleDeleteTCPResponseRuleBackendHandler = &handlers.DeleteTCPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPResponseRuleGetTCPResponseRuleBackendHandler = &handlers.GetTCPResponseRuleBackendHandlerImpl{Client: client} + api.TCPResponseRuleGetAllTCPResponseRuleBackendHandler = &handlers.GetAllTCPResponseRuleBackendHandlerImpl{Client: client} + api.TCPResponseRuleReplaceTCPResponseRuleBackendHandler = &handlers.ReplaceTCPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPResponseRuleReplaceAllTCPResponseRuleBackendHandler = &handlers.ReplaceAllTCPResponseRuleBackendHandlerImpl{Client: client, ReloadAgent: ra} + + // setup tcp check handlers + api.TCPCheckCreateTCPCheckBackendHandler = &handlers.CreateTCPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPCheckDeleteTCPCheckBackendHandler = &handlers.DeleteTCPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPCheckGetTCPCheckBackendHandler = &handlers.GetTCPCheckBackendHandlerImpl{Client: client} + api.TCPCheckGetAllTCPCheckBackendHandler = &handlers.GetAllTCPCheckBackendHandlerImpl{Client: client} + api.TCPCheckReplaceTCPCheckBackendHandler = &handlers.ReplaceTCPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPCheckReplaceAllTCPCheckBackendHandler = &handlers.ReplaceAllTCPCheckBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.TCPCheckCreateTCPCheckDefaultsHandler = &handlers.CreateTCPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPCheckDeleteTCPCheckDefaultsHandler = &handlers.DeleteTCPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPCheckGetTCPCheckDefaultsHandler = &handlers.GetTCPCheckDefaultsHandlerImpl{Client: client} + api.TCPCheckGetAllTCPCheckDefaultsHandler = &handlers.GetAllTCPCheckDefaultsHandlerImpl{Client: client} + api.TCPCheckReplaceTCPCheckDefaultsHandler = &handlers.ReplaceTCPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.TCPCheckReplaceAllTCPCheckDefaultsHandler = &handlers.ReplaceAllTCPCheckDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + + // setup quic initia; rule handlers + api.QUICInitialRuleCreateQUICInitialRuleDefaultsHandler = &handlers.CreateQUICInitialRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.QUICInitialRuleDeleteQUICInitialRuleDefaultsHandler = &handlers.DeleteQUICInitialRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.QUICInitialRuleGetQUICInitialRuleDefaultsHandler = &handlers.GetQUICInitialRuleDefaultsHandlerImpl{Client: client} + api.QUICInitialRuleGetAllQUICInitialRuleDefaultsHandler = &handlers.GetAllQUICInitialRuleDefaultsHandlerImpl{Client: client} + api.QUICInitialRuleReplaceQUICInitialRuleDefaultsHandler = &handlers.ReplaceQUICInitialRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.QUICInitialRuleReplaceAllQUICInitialRuleDefaultsHandler = &handlers.ReplaceAllQUICInitialRuleDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + + api.QUICInitialRuleCreateQUICInitialRuleFrontendHandler = &handlers.CreateQUICInitialRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.QUICInitialRuleDeleteQUICInitialRuleFrontendHandler = &handlers.DeleteQUICInitialRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.QUICInitialRuleGetQUICInitialRuleFrontendHandler = &handlers.GetQUICInitialRuleFrontendHandlerImpl{Client: client} + api.QUICInitialRuleGetAllQUICInitialRuleFrontendHandler = &handlers.GetAllQUICInitialRuleFrontendHandlerImpl{Client: client} + api.QUICInitialRuleReplaceQUICInitialRuleFrontendHandler = &handlers.ReplaceQUICInitialRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.QUICInitialRuleReplaceAllQUICInitialRuleFrontendHandler = &handlers.ReplaceAllQUICInitialRuleFrontendHandlerImpl{Client: client, ReloadAgent: ra} + + // setup declare capture handlers + api.DeclareCaptureCreateDeclareCaptureHandler = &handlers.CreateDeclareCaptureHandlerImpl{Client: client, ReloadAgent: ra} + api.DeclareCaptureDeleteDeclareCaptureHandler = &handlers.DeleteDeclareCaptureHandlerImpl{Client: client, ReloadAgent: ra} + api.DeclareCaptureGetDeclareCaptureHandler = &handlers.GetDeclareCaptureHandlerImpl{Client: client} + api.DeclareCaptureGetDeclareCapturesHandler = &handlers.GetDeclareCapturesHandlerImpl{Client: client} + api.DeclareCaptureReplaceDeclareCaptureHandler = &handlers.ReplaceDeclareCaptureHandlerImpl{Client: client, ReloadAgent: ra} + api.DeclareCaptureReplaceDeclareCapturesHandler = &handlers.ReplaceDeclareCapturesHandlerImpl{Client: client, ReloadAgent: ra} // setup backend switching rule handlers api.BackendSwitchingRuleCreateBackendSwitchingRuleHandler = &handlers.CreateBackendSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra} @@ -283,6 +589,7 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { api.BackendSwitchingRuleGetBackendSwitchingRuleHandler = &handlers.GetBackendSwitchingRuleHandlerImpl{Client: client} api.BackendSwitchingRuleGetBackendSwitchingRulesHandler = &handlers.GetBackendSwitchingRulesHandlerImpl{Client: client} api.BackendSwitchingRuleReplaceBackendSwitchingRuleHandler = &handlers.ReplaceBackendSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra} + api.BackendSwitchingRuleReplaceBackendSwitchingRulesHandler = &handlers.ReplaceBackendSwitchingRulesHandlerImpl{Client: client, ReloadAgent: ra} // setup server switching rule handlers api.ServerSwitchingRuleCreateServerSwitchingRuleHandler = &handlers.CreateServerSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra} @@ -290,13 +597,22 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { api.ServerSwitchingRuleGetServerSwitchingRuleHandler = &handlers.GetServerSwitchingRuleHandlerImpl{Client: client} api.ServerSwitchingRuleGetServerSwitchingRulesHandler = &handlers.GetServerSwitchingRulesHandlerImpl{Client: client} api.ServerSwitchingRuleReplaceServerSwitchingRuleHandler = &handlers.ReplaceServerSwitchingRuleHandlerImpl{Client: client, ReloadAgent: ra} + api.ServerSwitchingRuleReplaceServerSwitchingRulesHandler = &handlers.ReplaceServerSwitchingRulesHandlerImpl{Client: client, ReloadAgent: ra} // setup filter handlers - api.FilterCreateFilterHandler = &handlers.CreateFilterHandlerImpl{Client: client, ReloadAgent: ra} - api.FilterDeleteFilterHandler = &handlers.DeleteFilterHandlerImpl{Client: client, ReloadAgent: ra} - api.FilterGetFilterHandler = &handlers.GetFilterHandlerImpl{Client: client} - api.FilterGetFiltersHandler = &handlers.GetFiltersHandlerImpl{Client: client} - api.FilterReplaceFilterHandler = &handlers.ReplaceFilterHandlerImpl{Client: client, ReloadAgent: ra} + api.FilterCreateFilterBackendHandler = &handlers.CreateFilterBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.FilterDeleteFilterBackendHandler = &handlers.DeleteFilterBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.FilterGetFilterBackendHandler = &handlers.GetFilterBackendHandlerImpl{Client: client} + api.FilterGetAllFilterBackendHandler = &handlers.GetAllFilterBackendHandlerImpl{Client: client} + api.FilterReplaceFilterBackendHandler = &handlers.ReplaceFilterBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.FilterReplaceAllFilterBackendHandler = &handlers.ReplaceAllFilterBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.FilterCreateFilterFrontendHandler = &handlers.CreateFilterFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.FilterDeleteFilterFrontendHandler = &handlers.DeleteFilterFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.FilterGetFilterFrontendHandler = &handlers.GetFilterFrontendHandlerImpl{Client: client} + api.FilterGetAllFilterFrontendHandler = &handlers.GetAllFilterFrontendHandlerImpl{Client: client} + api.FilterReplaceFilterFrontendHandler = &handlers.ReplaceFilterFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.FilterReplaceAllFilterFrontendHandler = &handlers.ReplaceAllFilterFrontendHandlerImpl{Client: client, ReloadAgent: ra} // setup stick rule handlers api.StickRuleCreateStickRuleHandler = &handlers.CreateStickRuleHandlerImpl{Client: client, ReloadAgent: ra} @@ -304,20 +620,148 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { api.StickRuleGetStickRuleHandler = &handlers.GetStickRuleHandlerImpl{Client: client} api.StickRuleGetStickRulesHandler = &handlers.GetStickRulesHandlerImpl{Client: client} api.StickRuleReplaceStickRuleHandler = &handlers.ReplaceStickRuleHandlerImpl{Client: client, ReloadAgent: ra} + api.StickRuleReplaceStickRulesHandler = &handlers.ReplaceStickRulesHandlerImpl{Client: client, ReloadAgent: ra} // setup log target handlers - api.LogTargetCreateLogTargetHandler = &handlers.CreateLogTargetHandlerImpl{Client: client, ReloadAgent: ra} - api.LogTargetDeleteLogTargetHandler = &handlers.DeleteLogTargetHandlerImpl{Client: client, ReloadAgent: ra} - api.LogTargetGetLogTargetHandler = &handlers.GetLogTargetHandlerImpl{Client: client} - api.LogTargetGetLogTargetsHandler = &handlers.GetLogTargetsHandlerImpl{Client: client} - api.LogTargetReplaceLogTargetHandler = &handlers.ReplaceLogTargetHandlerImpl{Client: client, ReloadAgent: ra} - - // setup log target handlers - api.ACLCreateACLHandler = &handlers.CreateACLHandlerImpl{Client: client, ReloadAgent: ra} - api.ACLDeleteACLHandler = &handlers.DeleteACLHandlerImpl{Client: client, ReloadAgent: ra} - api.ACLGetACLHandler = &handlers.GetACLHandlerImpl{Client: client} - api.ACLGetAclsHandler = &handlers.GetAclsHandlerImpl{Client: client} - api.ACLReplaceACLHandler = &handlers.ReplaceACLHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetCreateLogTargetBackendHandler = &handlers.CreateLogTargetBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetDeleteLogTargetBackendHandler = &handlers.DeleteLogTargetBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetGetLogTargetBackendHandler = &handlers.GetLogTargetBackendHandlerImpl{Client: client} + api.LogTargetGetAllLogTargetBackendHandler = &handlers.GetAllLogTargetBackendHandlerImpl{Client: client} + api.LogTargetReplaceLogTargetBackendHandler = &handlers.ReplaceLogTargetBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetReplaceAllLogTargetBackendHandler = &handlers.ReplaceAllLogTargetBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.LogTargetCreateLogTargetFrontendHandler = &handlers.CreateLogTargetFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetDeleteLogTargetFrontendHandler = &handlers.DeleteLogTargetFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetGetLogTargetFrontendHandler = &handlers.GetLogTargetFrontendHandlerImpl{Client: client} + api.LogTargetGetAllLogTargetFrontendHandler = &handlers.GetAllLogTargetFrontendHandlerImpl{Client: client} + api.LogTargetReplaceLogTargetFrontendHandler = &handlers.ReplaceLogTargetFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetReplaceAllLogTargetFrontendHandler = &handlers.ReplaceAllLogTargetFrontendHandlerImpl{Client: client, ReloadAgent: ra} + + api.LogTargetCreateLogTargetDefaultsHandler = &handlers.CreateLogTargetDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetDeleteLogTargetDefaultsHandler = &handlers.DeleteLogTargetDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetGetLogTargetDefaultsHandler = &handlers.GetLogTargetDefaultsHandlerImpl{Client: client} + api.LogTargetGetAllLogTargetDefaultsHandler = &handlers.GetAllLogTargetDefaultsHandlerImpl{Client: client} + api.LogTargetReplaceLogTargetDefaultsHandler = &handlers.ReplaceLogTargetDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetReplaceAllLogTargetDefaultsHandler = &handlers.ReplaceAllLogTargetDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + + api.LogTargetCreateLogTargetLogForwardHandler = &handlers.CreateLogTargetLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetDeleteLogTargetLogForwardHandler = &handlers.DeleteLogTargetLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetGetLogTargetLogForwardHandler = &handlers.GetLogTargetLogForwardHandlerImpl{Client: client} + api.LogTargetGetAllLogTargetLogForwardHandler = &handlers.GetAllLogTargetLogForwardHandlerImpl{Client: client} + api.LogTargetReplaceLogTargetLogForwardHandler = &handlers.ReplaceLogTargetLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetReplaceAllLogTargetLogForwardHandler = &handlers.ReplaceAllLogTargetLogForwardHandlerImpl{Client: client, ReloadAgent: ra} + + api.LogTargetCreateLogTargetPeerHandler = &handlers.CreateLogTargetPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetDeleteLogTargetPeerHandler = &handlers.DeleteLogTargetPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetGetLogTargetPeerHandler = &handlers.GetLogTargetPeerHandlerImpl{Client: client} + api.LogTargetGetAllLogTargetPeerHandler = &handlers.GetAllLogTargetPeerHandlerImpl{Client: client} + api.LogTargetReplaceLogTargetPeerHandler = &handlers.ReplaceLogTargetPeerHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetReplaceAllLogTargetPeerHandler = &handlers.ReplaceAllLogTargetPeerHandlerImpl{Client: client, ReloadAgent: ra} + + api.LogTargetCreateLogTargetGlobalHandler = &handlers.CreateLogTargetGlobalHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetDeleteLogTargetGlobalHandler = &handlers.DeleteLogTargetGlobalHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetGetLogTargetGlobalHandler = &handlers.GetLogTargetGlobalHandlerImpl{Client: client} + api.LogTargetGetAllLogTargetGlobalHandler = &handlers.GetAllLogTargetGlobalHandlerImpl{Client: client} + api.LogTargetReplaceLogTargetGlobalHandler = &handlers.ReplaceLogTargetGlobalHandlerImpl{Client: client, ReloadAgent: ra} + api.LogTargetReplaceAllLogTargetGlobalHandler = &handlers.ReplaceAllLogTargetGlobalHandlerImpl{Client: client, ReloadAgent: ra} + + // setup acl rule handlers + api.ACLCreateACLBackendHandler = &handlers.CreateACLBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLDeleteACLBackendHandler = &handlers.DeleteACLBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLGetACLBackendHandler = &handlers.GetACLBackendHandlerImpl{Client: client} + api.ACLGetAllACLBackendHandler = &handlers.GetAllACLBackendHandlerImpl{Client: client} + api.ACLReplaceACLBackendHandler = &handlers.ReplaceACLBackendHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLReplaceAllACLBackendHandler = &handlers.ReplaceAllACLBackendHandlerImpl{Client: client, ReloadAgent: ra} + + api.ACLCreateACLFrontendHandler = &handlers.CreateACLFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLDeleteACLFrontendHandler = &handlers.DeleteACLFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLGetACLFrontendHandler = &handlers.GetACLFrontendHandlerImpl{Client: client} + api.ACLGetAllACLFrontendHandler = &handlers.GetAllACLFrontendHandlerImpl{Client: client} + api.ACLReplaceACLFrontendHandler = &handlers.ReplaceACLFrontendHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLReplaceAllACLFrontendHandler = &handlers.ReplaceAllACLFrontendHandlerImpl{Client: client, ReloadAgent: ra} + + api.ACLCreateACLFCGIAppHandler = &handlers.CreateACLFCGIAppHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLDeleteACLFCGIAppHandler = &handlers.DeleteACLFCGIAppHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLGetACLFCGIAppHandler = &handlers.GetACLFCGIAppHandlerImpl{Client: client} + api.ACLGetAllACLFCGIAppHandler = &handlers.GetAllACLFCGIAppHandlerImpl{Client: client} + api.ACLReplaceACLFCGIAppHandler = &handlers.ReplaceACLFCGIAppHandlerImpl{Client: client, ReloadAgent: ra} + api.ACLReplaceAllACLFCGIAppHandler = &handlers.ReplaceAllACLFCGIAppHandlerImpl{Client: client, ReloadAgent: ra} + + // setup resolvers handlers + api.ResolverCreateResolverHandler = &handlers.CreateResolverHandlerImpl{Client: client, ReloadAgent: ra} + api.ResolverDeleteResolverHandler = &handlers.DeleteResolverHandlerImpl{Client: client, ReloadAgent: ra} + api.ResolverGetResolverHandler = &handlers.GetResolverHandlerImpl{Client: client} + api.ResolverGetResolversHandler = &handlers.GetResolversHandlerImpl{Client: client} + api.ResolverReplaceResolverHandler = &handlers.ReplaceResolverHandlerImpl{Client: client, ReloadAgent: ra} + + // setup nameserver handlers + api.NameserverCreateNameserverHandler = &handlers.CreateNameserverHandlerImpl{Client: client, ReloadAgent: ra} + api.NameserverDeleteNameserverHandler = &handlers.DeleteNameserverHandlerImpl{Client: client, ReloadAgent: ra} + api.NameserverGetNameserverHandler = &handlers.GetNameserverHandlerImpl{Client: client} + api.NameserverGetNameserversHandler = &handlers.GetNameserversHandlerImpl{Client: client} + api.NameserverReplaceNameserverHandler = &handlers.ReplaceNameserverHandlerImpl{Client: client, ReloadAgent: ra} + + // setup mailers sections handlers + api.MailersCreateMailersSectionHandler = &handlers.CreateMailersSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.MailersDeleteMailersSectionHandler = &handlers.DeleteMailersSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.MailersGetMailersSectionHandler = &handlers.GetMailersSectionHandlerImpl{Client: client} + api.MailersGetMailersSectionsHandler = &handlers.GetMailersSectionsHandlerImpl{Client: client} + api.MailersEditMailersSectionHandler = &handlers.EditMailersSectionHandlerImpl{Client: client, ReloadAgent: ra} + + // setup mailer entry handlers + api.MailerEntryCreateMailerEntryHandler = &handlers.CreateMailerEntryHandlerImpl{Client: client, ReloadAgent: ra} + api.MailerEntryDeleteMailerEntryHandler = &handlers.DeleteMailerEntryHandlerImpl{Client: client, ReloadAgent: ra} + api.MailerEntryGetMailerEntryHandler = &handlers.GetMailerEntryHandlerImpl{Client: client} + api.MailerEntryGetMailerEntriesHandler = &handlers.GetMailerEntriesHandlerImpl{Client: client} + api.MailerEntryReplaceMailerEntryHandler = &handlers.ReplaceMailerEntryHandlerImpl{Client: client, ReloadAgent: ra} + + // setup peer section handlers + api.PeerCreatePeerHandler = &handlers.CreatePeerHandlerImpl{Client: client, ReloadAgent: ra} + api.PeerDeletePeerHandler = &handlers.DeletePeerHandlerImpl{Client: client, ReloadAgent: ra} + api.PeerGetPeerSectionHandler = &handlers.GetPeerHandlerImpl{Client: client} + api.PeerGetPeerSectionsHandler = &handlers.GetPeersHandlerImpl{Client: client} + + // setup peer entries handlers + api.PeerEntryCreatePeerEntryHandler = &handlers.CreatePeerEntryHandlerImpl{Client: client, ReloadAgent: ra} + api.PeerEntryDeletePeerEntryHandler = &handlers.DeletePeerEntryHandlerImpl{Client: client, ReloadAgent: ra} + api.PeerEntryGetPeerEntryHandler = &handlers.GetPeerEntryHandlerImpl{Client: client} + api.PeerEntryGetPeerEntriesHandler = &handlers.GetPeerEntriesHandlerImpl{Client: client} + api.PeerEntryReplacePeerEntryHandler = &handlers.ReplacePeerEntryHandlerImpl{Client: client, ReloadAgent: ra} + + // setup tables handlers + api.TableCreateTableHandler = &handlers.CreateTableHandlerImpl{Client: client, ReloadAgent: ra} + api.TableDeleteTableHandler = &handlers.DeleteTableHandlerImpl{Client: client, ReloadAgent: ra} + api.TableGetTableHandler = &handlers.GetTableHandlerImpl{Client: client} + api.TableGetTablesHandler = &handlers.GetTablesHandlerImpl{Client: client} + api.TableReplaceTableHandler = &handlers.ReplaceTableHandlerImpl{Client: client, ReloadAgent: ra} + + // setup http-errors sections handlers + api.HTTPErrorsCreateHTTPErrorsSectionHandler = &handlers.CreateHTTPErrorsSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorsDeleteHTTPErrorsSectionHandler = &handlers.DeleteHTTPErrorsSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.HTTPErrorsGetHTTPErrorsSectionHandler = &handlers.GetHTTPErrorsSectionHandlerImpl{Client: client} + api.HTTPErrorsGetHTTPErrorsSectionsHandler = &handlers.GetHTTPErrorsSectionsHandlerImpl{Client: client} + api.HTTPErrorsReplaceHTTPErrorsSectionHandler = &handlers.ReplaceHTTPErrorsSectionHandlerImpl{Client: client, ReloadAgent: ra} + + // setup cache handlers + api.CacheCreateCacheHandler = &handlers.CreateCacheHandlerImpl{Client: client, ReloadAgent: ra} + api.CacheDeleteCacheHandler = &handlers.DeleteCacheHandlerImpl{Client: client, ReloadAgent: ra} + api.CacheGetCacheHandler = &handlers.GetCacheHandlerImpl{Client: client} + api.CacheGetCachesHandler = &handlers.GetCachesHandlerImpl{Client: client} + api.CacheReplaceCacheHandler = &handlers.ReplaceCacheHandlerImpl{Client: client, ReloadAgent: ra} + + // setup program handlers + api.ProcessManagerCreateProgramHandler = &handlers.CreateProgramHandlerImpl{Client: client, ReloadAgent: ra} + api.ProcessManagerDeleteProgramHandler = &handlers.DeleteProgramHandlerImpl{Client: client, ReloadAgent: ra} + api.ProcessManagerGetProgramHandler = &handlers.GetProgramHandlerImpl{Client: client} + api.ProcessManagerGetProgramsHandler = &handlers.GetProgramsHandlerImpl{Client: client} + api.ProcessManagerReplaceProgramHandler = &handlers.ReplaceProgramHandlerImpl{Client: client, ReloadAgent: ra} + + // setup fcgi handlers + api.FCGIAppCreateFCGIAppHandler = &handlers.CreateFCGIAppHandlerImpl{Client: client, ReloadAgent: ra} + api.FCGIAppDeleteFCGIAppHandler = &handlers.DeleteFCGIAppHandlerImpl{Client: client, ReloadAgent: ra} + api.FCGIAppGetFCGIAppHandler = &handlers.GetFCGIAppHandlerImpl{Client: client} + api.FCGIAppGetFCGIAppsHandler = &handlers.GetFCGIAppsHandlerImpl{Client: client} + api.FCGIAppReplaceFCGIAppHandler = &handlers.ReplaceFCGIAppHandlerImpl{Client: client, ReloadAgent: ra} // setup stats handler api.StatsGetStatsHandler = &handlers.GetStatsHandlerImpl{Client: client} @@ -334,19 +778,142 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { api.GlobalReplaceGlobalHandler = &handlers.ReplaceGlobalHandlerImpl{Client: client, ReloadAgent: ra} // setup defaults configuration handlers - api.DefaultsGetDefaultsHandler = &handlers.GetDefaultsHandlerImpl{Client: client} - api.DefaultsReplaceDefaultsHandler = &handlers.ReplaceDefaultsHandlerImpl{Client: client, ReloadAgent: ra} + api.DefaultsCreateDefaultsSectionHandler = &handlers.CreateDefaultsSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.DefaultsAddDefaultsSectionHandler = &handlers.AddDefaultsSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.DefaultsDeleteDefaultsSectionHandler = &handlers.DeleteDefaultsSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.DefaultsReplaceDefaultsSectionHandler = &handlers.ReplaceDefaultsSectionHandlerImpl{Client: client, ReloadAgent: ra} + api.DefaultsGetDefaultsSectionHandler = &handlers.GetDefaultsSectionHandlerImpl{Client: client} + api.DefaultsGetDefaultsSectionsHandler = &handlers.GetDefaultsSectionsHandlerImpl{Client: client} // setup reload handlers api.ReloadsGetReloadHandler = &handlers.GetReloadHandlerImpl{ReloadAgent: ra} api.ReloadsGetReloadsHandler = &handlers.GetReloadsHandlerImpl{ReloadAgent: ra} + // setup runtime server handlers + api.ServerGetRuntimeServerHandler = &handlers.GetRuntimeServerHandlerImpl{Client: client} + api.ServerGetAllRuntimeServerHandler = &handlers.GetAllRuntimeServerHandlerImpl{Client: client} + api.ServerReplaceRuntimeServerHandler = &handlers.ReplaceRuntimeServerHandlerImpl{Client: client} + api.ServerAddRuntimeServerHandler = &handlers.AddRuntimeServerHandlerImpl{Client: client} + api.ServerDeleteRuntimeServerHandler = &handlers.DeleteRuntimeServerHandlerImpl{Client: client} + + // setup stick table handlers + api.StickTableGetStickTablesHandler = &handlers.GetStickTablesHandlerImpl{Client: client} + api.StickTableGetStickTableHandler = &handlers.GetStickTableHandlerImpl{Client: client} + api.StickTableGetStickTableEntriesHandler = &handlers.GetStickTableEntriesHandlerImpl{Client: client} + api.StickTableSetStickTableEntriesHandler = &handlers.SetStickTableEntriesHandlerImpl{Client: client} + + // setup ACL runtime handlers + api.ACLRuntimeGetServicesHaproxyRuntimeAclsHandler = &handlers.GetACLSHandlerRuntimeImpl{Client: client} + api.ACLRuntimeGetServicesHaproxyRuntimeAclsIDHandler = &handlers.GetACLHandlerRuntimeImpl{Client: client} + api.ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesHandler = &handlers.GetACLFileEntriesHandlerRuntimeImpl{Client: client} + api.ACLRuntimePostServicesHaproxyRuntimeAclsParentNameEntriesHandler = &handlers.PostACLFileEntryHandlerRuntimeImpl{Client: client} + api.ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler = &handlers.GetACLFileEntryRuntimeImpl{Client: client} + api.ACLRuntimeDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler = &handlers.DeleteACLFileEntryHandlerRuntimeImpl{Client: client} + api.ACLRuntimeAddPayloadRuntimeACLHandler = &handlers.ACLRuntimeAddPayloadRuntimeACLHandlerImpl{Client: client} + + // setup map handlers + api.MapsGetAllRuntimeMapFilesHandler = &handlers.GetMapsHandlerImpl{Client: client} + api.MapsGetOneRuntimeMapHandler = &handlers.GetMapHandlerImpl{Client: client} + api.MapsClearRuntimeMapHandler = &handlers.ClearMapHandlerImpl{Client: client} + api.MapsShowRuntimeMapHandler = &handlers.ShowMapHandlerImpl{Client: client} + api.MapsAddMapEntryHandler = &handlers.AddMapEntryHandlerImpl{Client: client} + api.MapsAddPayloadRuntimeMapHandler = &handlers.MapsAddPayloadRuntimeMapHandlerImpl{Client: client} + api.MapsGetRuntimeMapEntryHandler = &handlers.GetRuntimeMapEntryHandlerImpl{Client: client} + api.MapsReplaceRuntimeMapEntryHandler = &handlers.ReplaceRuntimeMapEntryHandlerImpl{Client: client} + api.MapsDeleteRuntimeMapEntryHandler = &handlers.DeleteRuntimeMapEntryHandlerImpl{Client: client} + + // crt-store handlers + api.CrtStoreGetCrtStoresHandler = &handlers.GetCrtStoresHandlerImpl{Client: client} + api.CrtStoreGetCrtStoreHandler = &handlers.GetCrtStoreHandlerImpl{Client: client} + api.CrtStoreCreateCrtStoreHandler = &handlers.CreateCrtStoreHandlerImpl{Client: client, ReloadAgent: ra} + api.CrtStoreEditCrtStoreHandler = &handlers.EditCrtStoreHandler{Client: client, ReloadAgent: ra} + api.CrtStoreDeleteCrtStoreHandler = &handlers.DeleteCrtStoreHandlerImpl{Client: client, ReloadAgent: ra} + // crt-store load handlers + api.CrtLoadGetCrtLoadsHandler = &handlers.GetCrtLoadsHandlerImpl{Client: client} + api.CrtLoadGetCrtLoadHandler = &handlers.GetCrtLoadHandlerImpl{Client: client} + api.CrtLoadCreateCrtLoadHandler = &handlers.CreateCrtLoadHandlerImpl{Client: client, ReloadAgent: ra} + api.CrtLoadReplaceCrtLoadHandler = &handlers.ReplaceCrtLoadHandler{Client: client, ReloadAgent: ra} + api.CrtLoadDeleteCrtLoadHandler = &handlers.DeleteCrtLoadHandlerImpl{Client: client, ReloadAgent: ra} + + // traces handlers + api.TracesGetTracesHandler = &handlers.GetTracesHandlerImpl{Client: client} + api.TracesCreateTracesHandler = &handlers.CreateTracesHandlerImpl{Client: client, ReloadAgent: ra} + api.TracesReplaceTracesHandler = &handlers.ReplaceTracesHandler{Client: client, ReloadAgent: ra} + api.TracesDeleteTracesHandler = &handlers.DeleteTracesHandlerImpl{Client: client, ReloadAgent: ra} + api.TracesCreateTraceEntryHandler = &handlers.CreateTraceEntryHandlerImpl{Client: client, ReloadAgent: ra} + api.TracesDeleteTraceEntryHandler = &handlers.DeleteTraceEntryHandlerImpl{Client: client, ReloadAgent: ra} + + // log-profile handlers + api.LogProfileGetLogProfilesHandler = &handlers.GetLogProfilesHandlerImpl{Client: client} + api.LogProfileGetLogProfileHandler = &handlers.GetLogProfileHandlerImpl{Client: client} + api.LogProfileCreateLogProfileHandler = &handlers.CreateLogProfileHandlerImpl{Client: client, ReloadAgent: ra} + api.LogProfileEditLogProfileHandler = &handlers.EditLogProfileHandler{Client: client, ReloadAgent: ra} + api.LogProfileDeleteLogProfileHandler = &handlers.DeleteLogProfileHandlerImpl{Client: client, ReloadAgent: ra} + + // ssl-f-use handlers + api.SslFrontUseGetAllSSLFrontUsesHandler = &handlers.GetAllSSLFrontUsesHandlerImpl{Client: client} + api.SslFrontUseCreateSSLFrontUseHandler = &handlers.CreateSSLFrontUseHandlerImpl{Client: client, ReloadAgent: ra} + api.SslFrontUseGetSSLFrontUseHandler = &handlers.GetSSLFrontUseHandlerImpl{Client: client} + api.SslFrontUseReplaceSSLFrontUseHandler = &handlers.ReplaceSSLFrontUseHandlerImpl{Client: client, ReloadAgent: ra} + api.SslFrontUseDeleteSSLFrontUseHandler = &handlers.DeleteSSLFrontUseHandlerImpl{Client: client, ReloadAgent: ra} + + // Runtime SSL CA Files + api.SslRuntimeGetAllCaFilesHandler = &handlers.GetAllCaFilesHandlerImpl{Client: client} + api.SslRuntimeCreateCaFileHandler = &handlers.CreateCaFileHandlerImpl{Client: client} + api.SslRuntimeGetCaFileHandler = &handlers.GetCaFileHandlerImpl{Client: client} + api.SslRuntimeSetCaFileHandler = &handlers.SetCaFileHandlerImpl{Client: client} + api.SslRuntimeDeleteCaFileHandler = &handlers.DeleteCaFileHandlerImpl{Client: client} + api.SslRuntimeAddCaEntryHandler = &handlers.AddCaEntryHandlerImpl{Client: client} + api.SslRuntimeGetCaEntryHandler = &handlers.GetCaEntryHandlerImpl{Client: client} + + // Runtime SSL Cert + api.SslRuntimeGetAllCertsHandler = &handlers.GetAllCertsHandlerImpl{Client: client} + api.SslRuntimeCreateCertHandler = &handlers.CreateCertHandlerImpl{Client: client} + api.SslRuntimeGetCertHandler = &handlers.GetCertHandlerImpl{Client: client} + api.SslRuntimeReplaceCertHandler = &handlers.ReplaceCertHandlerImpl{Client: client} + api.SslRuntimeDeleteCertHandler = &handlers.DeleteCertHandlerImpl{Client: client} + + // Runtime SSL Crl Files + api.SslRuntimeGetAllCrlHandler = &handlers.GetAllCrlHandlerImpl{Client: client} + api.SslRuntimeCreateCrlHandler = &handlers.CreateCrlHandlerImpl{Client: client} + api.SslRuntimeGetCrlHandler = &handlers.GetCrlHandlerImpl{Client: client} + api.SslRuntimeReplaceCrlHandler = &handlers.ReplaceCrlHandlerImpl{Client: client} + api.SslRuntimeDeleteCrlHandler = &handlers.DeleteCrlHandlerImpl{Client: client} + + // Runtime SSL Crt List + api.SslRuntimeGetAllCrtListsHandler = &handlers.GetAllCrtListsHandlerImpl{Client: client} + api.SslRuntimeGetAllCrtListEntriesHandler = &handlers.GetAllCrtListEntriesHandlerImpl{Client: client} + api.SslRuntimeAddCrtListEntryHandler = &handlers.AddCrtListEntryHandlerImpl{Client: client} + api.SslRuntimeDeleteCrtListEntryHandler = &handlers.DeleteCrtListEntryHandlerImpl{Client: client} + + // ACME providers + api.AcmeGetAcmeProvidersHandler = &handlers.GetAcmeProvidersHandlerImpl{Client: client} + api.AcmeGetAcmeProviderHandler = &handlers.GetAcmeProviderHandlerImpl{Client: client} + api.AcmeCreateAcmeProviderHandler = &handlers.CreateAcmeProviderHandlerImpl{Client: client, ReloadAgent: ra} + api.AcmeEditAcmeProviderHandler = &handlers.EditAcmeProviderHandler{Client: client, ReloadAgent: ra} + api.AcmeDeleteAcmeProviderHandler = &handlers.DeleteAcmeProviderHandlerImpl{Client: client, ReloadAgent: ra} + + // ACME runtime + api.AcmeRuntimeGetAcmeStatusHandler = &handlers.GetAcmeStatusHandlerImpl{Client: client} + api.AcmeRuntimeRenewAcmeCertificateHandler = &handlers.RenewAcmeCertificateHandlerImpl{Client: client} + // setup info handler api.InformationGetInfoHandler = &handlers.GetInfoHandlerImpl{SystemInfo: haproxyOptions.ShowSystemInfo, BuildTime: BuildTime, Version: Version} + // setup cluster handlers + api.ClusterGetClusterHandler = &handlers.GetClusterHandlerImpl{Config: cfg} + api.ClusterPostClusterHandler = &handlers.CreateClusterHandlerImpl{Client: client, Config: cfg, ReloadAgent: ra} + api.ClusterDeleteClusterHandler = &handlers.DeleteClusterHandlerImpl{Client: client, Config: cfg, Users: dataplaneapi_config.GetUsersStore(), ReloadAgent: ra} + api.ClusterEditClusterHandler = &handlers.EditClusterHandlerImpl{Config: cfg} + api.ClusterInitiateCertificateRefreshHandler = &handlers.ClusterInitiateCertificateRefreshHandlerImpl{Config: cfg} + + clusterSync := dataplaneapi_config.ClusterSync{ReloadAgent: ra, Context: ctx} + go clusterSync.Monitor(cfg, client) + // setup specification handler - api.SpecificationGetSpecificationHandler = specification.GetSpecificationHandlerFunc(func(params specification.GetSpecificationParams, principal interface{}) middleware.Responder { - var m map[string]interface{} + api.SpecificationGetSpecificationHandler = specification.GetSpecificationHandlerFunc(func(params specification.GetSpecificationParams, principal any) middleware.Responder { + var m map[string]any + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal(SwaggerJSON, &m); err != nil { e := misc.HandleError(err) return specification.NewGetSpecificationDefault(int(*e.Code)).WithPayload(e) @@ -354,7 +921,242 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler { return specification.NewGetSpecificationOK().WithPayload(&m) }) - return setupGlobalMiddleware(api.Serve(setupMiddlewares)) + configurationClient, err := client.Configuration() + if err != nil { + log.Fatal(err) + } + // set up service discovery handlers + discovery := service_discovery.NewServiceDiscoveries(service_discovery.ServiceDiscoveriesParams{ + Client: configurationClient, + ReloadAgent: ra, + Context: ctx, + }) + api.ServiceDiscoveryCreateConsulHandler = &handlers.CreateConsulHandlerImpl{Discovery: discovery, PersistCallback: cfg.SaveConsuls} + api.ServiceDiscoveryDeleteConsulHandler = &handlers.DeleteConsulHandlerImpl{Discovery: discovery, PersistCallback: cfg.SaveConsuls} + api.ServiceDiscoveryGetConsulHandler = &handlers.GetConsulHandlerImpl{Discovery: discovery} + api.ServiceDiscoveryGetConsulsHandler = &handlers.GetConsulsHandlerImpl{Discovery: discovery} + api.ServiceDiscoveryReplaceConsulHandler = &handlers.ReplaceConsulHandlerImpl{Discovery: discovery, PersistCallback: cfg.SaveConsuls} + + api.ServiceDiscoveryCreateAWSRegionHandler = &handlers.CreateAWSHandlerImpl{Discovery: discovery, PersistCallback: cfg.SaveAWS} + api.ServiceDiscoveryGetAWSRegionHandler = &handlers.GetAWSRegionHandlerImpl{Discovery: discovery} + api.ServiceDiscoveryGetAWSRegionsHandler = &handlers.GetAWSRegionsHandlerImpl{Discovery: discovery} + api.ServiceDiscoveryReplaceAWSRegionHandler = &handlers.ReplaceAWSRegionHandlerImpl{Discovery: discovery, PersistCallback: cfg.SaveAWS} + api.ServiceDiscoveryDeleteAWSRegionHandler = &handlers.DeleteAWSRegionHandlerImpl{Discovery: discovery, PersistCallback: cfg.SaveAWS} + + // create stored consul instances + for _, data := range cfg.ServiceDiscovery.Consuls { + var errSD error + if data.ID == nil || len(*data.ID) == 0 { + data.ID = service_discovery.NewServiceDiscoveryUUID() + } + if errSD = service_discovery.ValidateConsulData(data, true); errSD != nil { + log.Fatal("Error validating Consul instance: " + errSD.Error()) + } + if errSD = discovery.AddNode("consul", *data.ID, data); errSD != nil { + log.Warning("Error creating consul instance: " + errSD.Error()) + } + } + _ = cfg.SaveConsuls(cfg.ServiceDiscovery.Consuls) + + // create stored AWS instances + for _, data := range cfg.ServiceDiscovery.AWSRegions { + var errSD error + + if data.ID == nil || len(*data.ID) == 0 { + data.ID = service_discovery.NewServiceDiscoveryUUID() + } + if errSD = service_discovery.ValidateAWSData(data, true); errSD != nil { + log.Fatal("Error validating AWS instance: " + errSD.Error()) + } + if errSD = discovery.AddNode("aws", *data.ID, data); errSD != nil { + log.Warning("Error creating AWS instance: " + errSD.Error()) + } + } + _ = cfg.SaveAWS(cfg.ServiceDiscovery.AWSRegions) + + api.ConfigurationGetConfigurationVersionHandler = &handlers.ConfigurationGetConfigurationVersionHandlerImpl{Client: client} + + // map file storage handlers + + api.StorageCreateStorageMapFileHandler = &handlers.StorageCreateStorageMapFileHandlerImpl{Client: client} + api.StorageGetAllStorageMapFilesHandler = &handlers.GetAllStorageMapFilesHandlerImpl{Client: client} + api.StorageGetOneStorageMapHandler = &handlers.GetOneStorageMapHandlerImpl{Client: client} + api.StorageDeleteStorageMapHandler = &handlers.StorageDeleteStorageMapHandlerImpl{Client: client} + api.StorageReplaceStorageMapFileHandler = &handlers.StorageReplaceStorageMapFileHandlerImpl{Client: client, ReloadAgent: ra} + + // SSL certs file storage handlers + api.StorageGetAllStorageSSLCertificatesHandler = &handlers.StorageGetAllStorageSSLCertificatesHandlerImpl{Client: client} + api.StorageGetOneStorageSSLCertificateHandler = &handlers.StorageGetOneStorageSSLCertificateHandlerImpl{Client: client} + api.StorageDeleteStorageSSLCertificateHandler = &handlers.StorageDeleteStorageSSLCertificateHandlerImpl{Client: client, ReloadAgent: ra} + api.StorageReplaceStorageSSLCertificateHandler = &handlers.StorageReplaceStorageSSLCertificateHandlerImpl{Client: client, ReloadAgent: ra} + api.StorageCreateStorageSSLCertificateHandler = &handlers.StorageCreateStorageSSLCertificateHandlerImpl{Client: client, ReloadAgent: ra} + + // SSL certificate lists storage handlers + api.StorageGetAllStorageSSLCrtListFilesHandler = &handlers.StorageGetAllStorageSSLCrtListFilesHandlerImpl{Client: client} + api.StorageGetOneStorageSSLCrtListFileHandler = &handlers.StorageGetOneStorageSSLCrtListFileHandlerImpl{Client: client} + api.StorageCreateStorageSSLCrtListFileHandler = &handlers.StorageCreateStorageSSLCrtListFileHandlerImpl{Client: client, ReloadAgent: ra} + api.StorageReplaceStorageSSLCrtListFileHandler = &handlers.StorageReplaceStorageSSLCrtListFileHandlerImpl{Client: client, ReloadAgent: ra} + api.StorageDeleteStorageSSLCrtListFileHandler = &handlers.StorageDeleteStorageSSLCrtListFileHandlerImpl{Client: client, ReloadAgent: ra} + // crt-list entries + api.StorageGetStorageSSLCrtListEntriesHandler = &handlers.StorageGetStorageSSLCrtListEntriesHandlerImpl{Client: client} + api.StorageCreateStorageSSLCrtListEntryHandler = &handlers.StorageCreateStorageSSLCrtListEntryHandlerImpl{Client: client, ReloadAgent: ra} + api.StorageDeleteStorageSSLCrtListEntryHandler = &handlers.StorageDeleteStorageSSLCrtListEntryHandlerImpl{Client: client, ReloadAgent: ra} + + // general file storage handlers + api.StorageCreateStorageGeneralFileHandler = &handlers.StorageCreateStorageGeneralFileHandlerImpl{Client: client} + api.StorageGetAllStorageGeneralFilesHandler = &handlers.StorageGetAllStorageGeneralFilesHandlerImpl{Client: client} + api.StorageGetOneStorageGeneralFileHandler = &handlers.StorageGetOneStorageGeneralFileHandlerImpl{Client: client} + api.StorageDeleteStorageGeneralFileHandler = &handlers.StorageDeleteStorageGeneralFileHandlerImpl{Client: client} + api.StorageReplaceStorageGeneralFileHandler = &handlers.StorageReplaceStorageGeneralFileHandlerImpl{Client: client, ReloadAgent: ra} + + // setup OpenAPI v3 specification handler + api.SpecificationOpenapiv3GetOpenapiv3SpecificationHandler = specification_openapiv3.GetOpenapiv3SpecificationHandlerFunc(func(params specification_openapiv3.GetOpenapiv3SpecificationParams, principal any) middleware.Responder { + v2 := openapi2.T{} + v2JSONString := string(SwaggerJSON) + v2JSONString = strings.ReplaceAll(v2JSONString, "#/definitions", "#/components/schemas") + curatedV2 := json.RawMessage([]byte(v2JSONString)) + + err = v2.UnmarshalJSON(curatedV2) + if err != nil { + e := misc.HandleError(err) + return specification_openapiv3.NewGetOpenapiv3SpecificationDefault(int(*e.Code)).WithPayload(e) + } + + // if host is empty(dynamic hosts), server prop is empty, + // so we need to set it explicitly + if v2.Host == "" { + cfg = dataplaneapi_config.Get() + v2.Host = cfg.RuntimeData.Host + } + + var v3 *openapi3.T + v3, err = openapi2conv.ToV3(&v2) + if err != nil { + e := misc.HandleError(err) + return specification_openapiv3.NewGetOpenapiv3SpecificationDefault(int(*e.Code)).WithPayload(e) + } + return specification_openapiv3.NewGetOpenapiv3SpecificationOK().WithPayload(v3) + }) + + // TODO: do we need a ReloadAgent for SPOE + // setup SPOE handlers + api.SpoeCreateSpoeHandler = &handlers.SpoeCreateSpoeHandlerImpl{Client: client} + api.SpoeDeleteSpoeFileHandler = &handlers.SpoeDeleteSpoeFileHandlerImpl{Client: client} + api.SpoeGetAllSpoeFilesHandler = &handlers.SpoeGetAllSpoeFilesHandlerImpl{Client: client} + api.SpoeGetOneSpoeFileHandler = &handlers.SpoeGetOneSpoeFileHandlerImpl{Client: client} + + // SPOE scope + api.SpoeGetAllSpoeScopeHandler = &handlers.SpoeGetAllSpoeScopeHandlerImpl{Client: client} + api.SpoeGetSpoeScopeHandler = &handlers.SpoeGetSpoeScopeHandlerImpl{Client: client} + api.SpoeCreateSpoeScopeHandler = &handlers.SpoeCreateSpoeScopeHandlerImpl{Client: client} + api.SpoeDeleteSpoeScopeHandler = &handlers.SpoeDeleteSpoeScopeHandlerImpl{Client: client} + + // SPOE agent + api.SpoeGetAllSpoeAgentHandler = &handlers.SpoeGetAllSpoeAgentHandlerImpl{Client: client} + api.SpoeGetSpoeAgentHandler = &handlers.SpoeGetSpoeAgentHandlerImpl{Client: client} + api.SpoeCreateSpoeAgentHandler = &handlers.SpoeCreateSpoeAgentHandlerImpl{Client: client} + api.SpoeDeleteSpoeAgentHandler = &handlers.SpoeDeleteSpoeAgentHandlerImpl{Client: client} + api.SpoeReplaceSpoeAgentHandler = &handlers.SpoeReplaceSpoeAgentHandlerImpl{Client: client} + + // SPOE messages + api.SpoeGetAllSpoeMessageHandler = &handlers.SpoeGetAllSpoeMessageHandlerImpl{Client: client} + api.SpoeGetSpoeMessageHandler = &handlers.SpoeGetSpoeMessageHandlerImpl{Client: client} + api.SpoeCreateSpoeMessageHandler = &handlers.SpoeCreateSpoeMessageHandlerImpl{Client: client} + api.SpoeDeleteSpoeMessageHandler = &handlers.SpoeDeleteSpoeMessageHandlerImpl{Client: client} + api.SpoeReplaceSpoeMessageHandler = &handlers.SpoeReplaceSpoeMessageHandlerImpl{Client: client} + + // SPOE groups + api.SpoeGetAllSpoeGroupHandler = &handlers.SpoeGetAllSpoeGroupHandlerImpl{Client: client} + api.SpoeGetSpoeGroupHandler = &handlers.SpoeGetSpoeGroupHandlerImpl{Client: client} + api.SpoeCreateSpoeGroupHandler = &handlers.SpoeCreateSpoeGroupHandlerImpl{Client: client} + api.SpoeDeleteSpoeGroupHandler = &handlers.SpoeDeleteSpoeGroupHandlerImpl{Client: client} + api.SpoeReplaceSpoeGroupHandler = &handlers.SpoeReplaceSpoeGroupHandlerImpl{Client: client} + + // SPOE version + api.SpoeGetSpoeConfigurationVersionHandler = &handlers.SpoeGetSpoeConfigurationVersionHandlerImpl{Client: client} + + defer func() { + if err := recover(); err != nil { + log.Fatalf("Error starting Data Plane API: %s\n Stacktrace from panic: \n%s", err, string(debug.Stack())) + } + }() + + // Health + api.HealthGetHealthHandler = &handlers.GetHealthHandlerImpl{HAProxy: ra} + + // middlewares + var adpts []adapters.Adapter + adpts = append(adpts, + cors.New(cors.Options{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{ + http.MethodHead, + http.MethodGet, + http.MethodPost, + http.MethodPut, + http.MethodPatch, + http.MethodDelete, + }, + AllowedHeaders: []string{"*"}, + ExposedHeaders: []string{"Reload-ID", "Configuration-Version"}, + AllowCredentials: true, + MaxAge: 86400, + }).Handler, + adapters.ConfigVersionMiddleware(client), + ) + + // setup logging middlewares + accessLogger, err := log.AccessLogger() + if err != nil { + log.Warningf("Error getting access loggers: %s", err.Error()) + } + + if accessLogger != nil { + for _, logger := range accessLogger.Loggers() { + adpts = append(adpts, adapters.ApacheLogMiddleware(logger)) + } + } + + appLogger, err := log.AppLogger() + if err != nil { + log.Warningf("Error getting app loggers: %s", err.Error()) + } + if appLogger != nil { + adpts = append(adpts, adapters.RecoverMiddleware(appLogger)) + } + + // Configure/Re-configure DebugServer on runtime socket + debugServer := socket_runtime.GetServer() + select { + case debugServer.CnChannel <- client: + default: + // ... do not block dataplane + log.Warning("-- command socket failed to update cn client") + } + + return setupGlobalMiddleware(api.Serve(setupMiddlewares), adpts...) +} + +func configureReloadAgent(haproxyOptions dataplaneapi_config.HAProxyConfiguration, client client_native.HAProxyClient, ctx context.Context) *haproxy.ReloadAgent { + // Initialize reload agent + raParams := haproxy.ReloadAgentParams{ + Delay: haproxyOptions.ReloadDelay, + ReloadCmd: haproxyOptions.ReloadCmd, + UseMasterSocket: canUseMasterSocketReload(&haproxyOptions, client), + RestartCmd: haproxyOptions.RestartCmd, + StatusCmd: haproxyOptions.StatusCmd, + ConfigFile: haproxyOptions.ConfigFile, + BackupDir: haproxyOptions.BackupsDir, + Retention: haproxyOptions.ReloadRetention, + Client: client, + Ctx: ctx, + } + + ra, e := haproxy.NewReloadAgent(raParams) + if e != nil { + log.Fatalf("Cannot initialize reload agent: %v", e) + } + return ra } // The TLS configuration before HTTPS server starts. @@ -377,225 +1179,220 @@ func setupMiddlewares(handler http.Handler) http.Handler { // The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. // So this is a good place to plug in a panic handling middleware, logging and metrics -func setupGlobalMiddleware(handler http.Handler) http.Handler { - handleCORS := cors.New(cors.Options{ - AllowedOrigins: []string{"*"}, - AllowedMethods: []string{ - http.MethodHead, - http.MethodGet, - http.MethodPost, - http.MethodPut, - http.MethodPatch, - http.MethodDelete, - }, - AllowedHeaders: []string{"*"}, - ExposedHeaders: []string{"Reload-ID", "Configuration-Version"}, - AllowCredentials: true, - MaxAge: 86400, - }).Handler - recovery := adapters.RecoverMiddleware(log.StandardLogger()) - logViaLogrus := adapters.LoggingMiddleware(log.StandardLogger()) - return (logViaLogrus(handleCORS(recovery(handler)))) +func setupGlobalMiddleware(handler http.Handler, adapters ...adapters.Adapter) http.Handler { + for _, adpt := range adapters { + handler = adpt(handler) + } + + return handler } -func authenticateUser(user string, pass string, cli *client_native.HAProxyClient) (interface{}, error) { - data, err := cli.Configuration.Parser.Get(parser.UserList, haproxyOptions.Userlist, "user") - if err != nil { - return nil, fmt.Errorf("Error reading userlist %v userlist in conf: %s", haproxyOptions.Userlist, err.Error()) +func serverShutdown() { + cfg := dataplaneapi_config.Get() + if logFile != nil { + logFile.Close() } - users, ok := data.([]types.User) - if !ok { - return nil, fmt.Errorf("Error reading users from %v userlist in conf", haproxyOptions.Userlist) + if cfg.HAProxy.UpdateMapFiles { + cfg.MapSync.Stop() } - if len(users) == 0 { - return nil, fmt.Errorf("No users configured in %v userlist in conf", haproxyOptions.Userlist) +} + +// Determine if we can reload HAProxy's configuration using the master socket 'reload' command. +// This requires at least HAProxy 2.7 configured in master/worker mode, with a master socket. +func canUseMasterSocketReload(conf *dataplaneapi_config.HAProxyConfiguration, client client_native.HAProxyClient) bool { + useMasterSocket := conf.MasterWorkerMode && conf.MasterRuntime != "" && misc.IsUnixSocketAddr(conf.MasterRuntime) + if !useMasterSocket { + return false } - for _, u := range users { - if u.Name == user { - if u.IsInsecure { - if u.Password == pass { - return user, nil - } - } else { - if checkPassword(pass, u.Password) { - return user, nil - } - } - return nil, errors.New(401, "Invalid username/password") - } + rt, err := client.Runtime() + if err != nil { + return false } - return nil, errors.New(401, "Invalid username/password") + currVersion, err := rt.GetVersion() + if err != nil { + return false + } + + return cn_runtime.IsBiggerOrEqual(&cn_runtime.HAProxyVersion{Major: 2, Minor: 7}, &currVersion) } -func configureLogging() { - switch loggingOptions.LogFormat { - case "text": - log.SetFormatter(&log.TextFormatter{ - FullTimestamp: true, - DisableColors: true, - }) - case "JSON": - log.SetFormatter(&log.JSONFormatter{}) - } - - switch loggingOptions.LogTo { - case "stdout": - log.SetOutput(os.Stdout) - case "file": - dir := filepath.Dir(loggingOptions.LogFile) - os.MkdirAll(dir, os.ModePerm) - - logFile, err := os.OpenFile(loggingOptions.LogFile, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) - if err != nil { - log.Warning("Error opening log file, no logging implemented: " + err.Error()) - } - log.SetOutput(logFile) +func configureNativeClient(cyx context.Context, haproxyOptions dataplaneapi_config.HAProxyConfiguration, mWorker bool) client_native.HAProxyClient { + // Initialize HAProxy native client + confClient, err := cn.ConfigureConfigurationClient(haproxyOptions, mWorker) + if err != nil { + log.Fatalf("Error initializing configuration client: %v", err) } - switch loggingOptions.LogLevel { - case "debug": - log.SetLevel(log.DebugLevel) - case "info": - log.SetLevel(log.InfoLevel) - case "warning": - log.SetLevel(log.WarnLevel) - case "error": - log.SetLevel(log.ErrorLevel) + runtimeClient := cn.ConfigureRuntimeClient(cyx, confClient, haproxyOptions) + + opt := []options.Option{ + options.Configuration(confClient), + options.Runtime(runtimeClient), + } + if haproxyOptions.MapsDir != "" { + var mapStorage storage.Storage + mapStorage, err = storage.New(haproxyOptions.MapsDir, storage.MapsType) + if err != nil { + log.Fatalf("error initializing map storage: %v", err) + } + opt = append(opt, options.MapStorage(mapStorage)) + } else { + log.Fatalf("error trying to use empty string for managed map directory") } -} -func checkPassword(pass, storedPass string) bool { - parts := strings.Split(storedPass, "$") - if len(parts) == 4 { - var c crypt.Crypter - switch parts[1] { - case "1": - c = crypt.MD5.New() - case "5": - c = crypt.SHA256.New() - case "6": - c = crypt.SHA512.New() - default: - return false + if haproxyOptions.SSLCertsDir != "" { + var sslCertStorage storage.Storage + sslCertStorage, err = storage.New(haproxyOptions.SSLCertsDir, storage.SSLType) + if err != nil { + log.Fatalf("error initializing SSL certs storage: %v", err) } - if err := c.Verify(storedPass, []byte(pass)); err == nil { - return true + opt = append(opt, options.SSLCertStorage(sslCertStorage)) + // crt-lists use the same directory + var crtListStorage storage.Storage + crtListStorage, err = storage.New(haproxyOptions.SSLCertsDir, storage.CrtListType) + if err != nil { + log.Fatalf("error initializing CRT Lists storage: %v", err) } + opt = append(opt, options.CrtListStorage(crtListStorage)) + } else { + log.Fatalf("error trying to use empty string for managed SSL certificates directory") } - return false -} - -func serverShutdown() { - if logFile != nil { - logFile.Close() + if haproxyOptions.GeneralStorageDir != "" { + var generalStorage storage.Storage + generalStorage, err = storage.New(haproxyOptions.GeneralStorageDir, storage.GeneralType) + if err != nil { + log.Fatalf("error initializing General storage: %v", err) + } + opt = append(opt, options.GeneralStorage(generalStorage)) + } else { + log.Fatalf("error trying to use empty string for managed general files directory") } -} -func configureNativeClient() *client_native.HAProxyClient { - // Override options with env variables - if os.Getenv("HAPROXY_MWORKER") == "1" { - masterRuntime := os.Getenv("HAPROXY_MASTER_CLI") - if masterRuntime != "" && !strings.HasPrefix(masterRuntime, "ipv4@") { - haproxyOptions.MasterRuntime = masterRuntime + if haproxyOptions.SpoeDir != "" { + prms := spoe.Params{ + SpoeDir: haproxyOptions.SpoeDir, + TransactionDir: haproxyOptions.SpoeTransactionDir, } + var spoeClient spoe.Spoe + spoeClient, err = spoe.NewSpoe(prms) + if err != nil { + log.Fatalf("error setting up spoe: %v", err) + } + opt = append(opt, options.Spoe(spoeClient)) + } else { + log.Fatalf("error trying to use empty string for SPOE configuration directory") } - cfgFiles := os.Getenv("HAPROXY_CFGFILES") - if cfgFiles != "" { - cfg := strings.Split(cfgFiles, ";") - haproxyOptions.ConfigFile = cfg[0] - } - // Initialize HAProxy native client - confClient, err := configureConfigurationClient() + + client, err := client_native.New(cyx, opt...) if err != nil { log.Fatalf("Error initializing configuration client: %v", err) } - runtimeClient := configureRuntimeClient(confClient) - client := &client_native.HAProxyClient{} - if err := client.Init(confClient, runtimeClient); err != nil { - log.Fatalf("Error setting up native client: %v", err) - } - return client } -func configureConfigurationClient() (*configuration.Client, error) { - confClient := &configuration.Client{} - confParams := configuration.ClientParams{ - ConfigurationFile: haproxyOptions.ConfigFile, - Haproxy: haproxyOptions.HAProxy, - BackupsNumber: haproxyOptions.BackupsNumber, - UseValidation: false, - PersistentTransactions: true, - TransactionDir: haproxyOptions.TransactionDir, - } - err := confClient.Init(confParams) +func configureEventListener(ctx context.Context, client client_native.HAProxyClient) { + rt, err := client.Runtime() if err != nil { - return nil, fmt.Errorf("Error setting up configuration client: %s", err.Error()) + return } - return confClient, nil -} - -func configureRuntimeClient(confClient *configuration.Client) *runtime_api.Client { - runtimeClient := &runtime_api.Client{} - _, globalConf, err := confClient.GetGlobalConfiguration("") - if err == nil { - statsSocketConfigured := false - socketList := make([]string, 0, 1) - runtimeAPIs := globalConf.RuntimeApis - - if len(runtimeAPIs) != 0 { - statsSocketConfigured = true - for _, r := range runtimeAPIs { - if !strings.HasPrefix(*r.Address, "ipv4@") { - socketList = append(socketList, *r.Address) - } - } - } - masterSocket := "" - nbproc := 0 - if haproxyOptions.MasterRuntime != "" && !strings.HasPrefix(haproxyOptions.MasterRuntime, "ipv4@") { - if globalConf.Nbproc > 0 { - statsSocketConfigured = true - nbproc = int(globalConf.Nbproc) - masterSocket = haproxyOptions.MasterRuntime - } - } - - if statsSocketConfigured { - if err := runtimeClient.Init(socketList, masterSocket, nbproc); err != nil { - log.Warning("Error setting up runtime client, not using one") - return nil - } - } else { - log.Warning("Runtime API not configured, not using it") - return nil + if eventListener != nil { + err = eventListener.Reconfigure(ctx, rt) + if err != nil { + // Stop the listener if the new conf has no master socket. + log.Info("Stopping the EventListener:", err.Error()) + _ = eventListener.Stop() } } else { - log.Warning("Cannot read runtime API configuration, not using it") - return nil + // First start. + eventListener, err = cn.ListenHAProxyEvents(ctx, client) + if err != nil && err != cn.ErrNoMasterSocket && err != cn.ErrOldVersion { + log.Error("Failed to start HAProxy's event listener:", err.Error()) + } } - return runtimeClient } -func handleSignals(sigs chan os.Signal, client *client_native.HAProxyClient) { +func handleSignals(ctx context.Context, cancel context.CancelFunc, sigs chan os.Signal, client client_native.HAProxyClient, haproxyOptions dataplaneapi_config.HAProxyConfiguration, users *dataplaneapi_config.Users) { for { select { case sig := <-sigs: - if sig == syscall.SIGUSR1 { - client.Runtime = configureRuntimeClient(client.Configuration) - log.Info("Reloaded Data Plane API") - } else if sig == syscall.SIGUSR2 { - confClient, err := configureConfigurationClient() + switch sig { + case syscall.SIGUSR1: + var clientCtx context.Context + cancel() + clientCtx, cancel = context.WithCancel(ctx) + configuration, err := client.Configuration() if err != nil { - log.Fatalf(err.Error()) + log.Infof("Unable to reload Data Plane API: %s", err.Error()) + } else { + client.ReplaceRuntime(cn.ConfigureRuntimeClient(clientCtx, configuration, haproxyOptions)) + configureEventListener(clientCtx, client) + log.Info("Reloaded Data Plane API") } - log.Info("Rereading Configuration Files") - client.Configuration = confClient + case syscall.SIGUSR2: + reloadConfigurationFile(client, haproxyOptions, users) } + case <-ctx.Done(): + cancel() + return } } } + +func reloadConfigurationFile(client client_native.HAProxyClient, haproxyOptions dataplaneapi_config.HAProxyConfiguration, users *dataplaneapi_config.Users) { + confClient, err := cn.ConfigureConfigurationClient(haproxyOptions, mWorker) + if err != nil { + log.Fatal(err.Error()) + } + if err := users.Init(); err != nil { + log.Fatal(err.Error()) + } + log.Info("Rereading Configuration Files") + clientMutex.Lock() + defer clientMutex.Unlock() + client.ReplaceConfiguration(confClient) +} + +func startWatcher(ctx context.Context, client client_native.HAProxyClient, haproxyOptions dataplaneapi_config.HAProxyConfiguration, users *dataplaneapi_config.Users, reloadAgent *haproxy.ReloadAgent) error { + cb := func() { + // reload configuration from config file. + reloadConfigurationFile(client, haproxyOptions, users) + + // reload runtime client if necessary. + callbackNeeded, reconfigureFunc, err := cn.ReconfigureRuntime(client) + if err != nil { + log.Warningf("Failed to check if native client need to be reloaded: %s", err) + return + } + if callbackNeeded { + reloadAgent.ReloadWithCallback(reconfigureFunc) + } + + // Reconfigure the event listener if needed. + configureEventListener(ctx, client) + + // get the last configuration which has been updated by reloadConfigurationFile and increment version in config file. + configuration, err := client.Configuration() + if err != nil { + log.Warningf("Failed to get configuration: %s", err) + return + } + if err := configuration.IncrementVersion(); err != nil { + log.Warningf("Failed to increment configuration version: %v", err) + } + } + + watcher, err := dataplaneapi_config.NewConfigWatcher(dataplaneapi_config.ConfigWatcherParams{ + FilePath: haproxyOptions.ConfigFile, + Callback: cb, + Ctx: ctx, + }) + if err != nil { + return err + } + go watcher.Listen() + return nil +} diff --git a/configure_data_plane_storage.go b/configure_data_plane_storage.go new file mode 100644 index 00000000..fc548c03 --- /dev/null +++ b/configure_data_plane_storage.go @@ -0,0 +1,33 @@ +package dataplaneapi + +import ( + "os" + "path/filepath" + + client_native "github.com/haproxytech/client-native/v6" + native_misc "github.com/haproxytech/client-native/v6/misc" + "github.com/haproxytech/dataplaneapi/log" +) + +func initDataplaneStorage(path string, client client_native.HAProxyClient) { + if path == "" { + return + } + if _, err := native_misc.CheckOrCreateWritableDirectory(path); err != nil { + log.Fatalf("error initializing dataplane internal storage: %v", err) + } + if _, err := os.Stat(filepath.Join(path, "logs.json")); err != nil && os.IsNotExist(err) { + generalStorage, storageErr := client.GeneralStorage() + if storageErr != nil { + log.Warningf("failed to get general storage: %v", storageErr) + return + } + src, _, getErr := generalStorage.Get("logs.json") + if getErr == nil { + dst := filepath.Join(path, "logs.json") + if err := os.Rename(src, dst); err != nil { + log.Warningf("Failed to move logs.json to dataplane internal storage: %v", err) + } + } + } +} diff --git a/configure_data_plane_test.go b/configure_data_plane_test.go new file mode 100644 index 00000000..862f7e6a --- /dev/null +++ b/configure_data_plane_test.go @@ -0,0 +1,46 @@ +// This file is safe to edit. Once it exists it will not be overwritten + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dataplaneapi + +import ( + "encoding/json" + "strings" + "testing" + + "github.com/getkin/kin-openapi/openapi2" + "github.com/getkin/kin-openapi/openapi2conv" +) + +func TestConvOpenAPIV2ToV3(t *testing.T) { + v2JSONString := string(SwaggerJSON) + v2JSONString = strings.ReplaceAll(v2JSONString, "#/definitions", "#/components/schemas") + curatedV2 := json.RawMessage([]byte(v2JSONString)) + + var v2 openapi2.T + err := v2.UnmarshalJSON(curatedV2) + if err != nil { + t.Error(err) + return + } + + _, err = openapi2conv.ToV3(&v2) + if err != nil { + t.Error(err) + return + } +} diff --git a/context.go b/context.go new file mode 100644 index 00000000..32fe7fe7 --- /dev/null +++ b/context.go @@ -0,0 +1,54 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dataplaneapi + +import ( + "context" + "sync" +) + +var ( + ContextHandler *CtxHandler + once sync.Once +) + +type CtxHandler struct { + ctx context.Context + cancel context.CancelFunc + rwx sync.RWMutex +} + +func (ch *CtxHandler) Init() { + once.Do(func() { + ContextHandler = &CtxHandler{} + ch = ContextHandler + }) + ch.rwx.Lock() + ch.ctx, ch.cancel = context.WithCancel(context.Background()) + ch.rwx.Unlock() +} + +func (ch *CtxHandler) Cancel() { + ch.rwx.RLock() + ch.cancel() + ch.rwx.RUnlock() +} + +func (ch *CtxHandler) Context() context.Context { + ch.rwx.RLock() + defer ch.rwx.RUnlock() + return ch.ctx +} diff --git a/dataplaneapi_configuration.go b/dataplaneapi_configuration.go new file mode 100644 index 00000000..f66b6fe5 --- /dev/null +++ b/dataplaneapi_configuration.go @@ -0,0 +1,117 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dataplaneapi + +import ( + "time" + + "github.com/docker/go-units" + "github.com/go-openapi/runtime/flagext" + + "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/misc" +) + +func SyncWithFileSettings(server *Server, cfg *configuration.Configuration) { //nolint: cyclop + configStorage := cfg.GetStorageData() + // This is added to allow backward compatibility if no scheme is defined it defaults to specification schemes + // and recently we added https to specification for clarity, and then old configs without scheme in them would + // start to fail. + if len(server.EnabledListeners) == 0 && configStorage.Dataplaneapi != nil { + if configStorage.Dataplaneapi.EnabledListeners == nil { + configStorage.Dataplaneapi.EnabledListeners = &[]string{"http"} + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.EnabledListeners != nil && !misc.HasOSArg("", "scheme", "") { + server.EnabledListeners = *configStorage.Dataplaneapi.EnabledListeners + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.CleanupTimeout != nil && !misc.HasOSArg("", "cleanup-timeout", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.CleanupTimeout); err == nil { + server.CleanupTimeout = d + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.GracefulTimeout != nil && !misc.HasOSArg("", "graceful-timeout", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.GracefulTimeout); err == nil { + server.GracefulTimeout = d + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.MaxHeaderSize != nil && !misc.HasOSArg("", "max-header-size", "") { + s, err := units.FromHumanSize(*configStorage.Dataplaneapi.MaxHeaderSize) + if err == nil { + server.MaxHeaderSize = flagext.ByteSize(s) + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.SocketPath != nil && !misc.HasOSArg("", "socket-path", "") { + server.SocketPath = *configStorage.Dataplaneapi.SocketPath + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.Host != nil && !misc.HasOSArg("", "host", "HOST") { + server.Host = *configStorage.Dataplaneapi.Host + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.Port != nil && !misc.HasOSArg("", "port", "PORT") { + server.Port = *configStorage.Dataplaneapi.Port + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.ListenLimit != nil && !misc.HasOSArg("", "listen-limit", "") { + server.ListenLimit = *configStorage.Dataplaneapi.ListenLimit + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.KeepAlive != nil && !misc.HasOSArg("", "keep-alive", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.KeepAlive); err == nil { + server.KeepAlive = d + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.ReadTimeout != nil && !misc.HasOSArg("", "read-timeout", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.ReadTimeout); err == nil { + server.ReadTimeout = d + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.WriteTimeout != nil && !misc.HasOSArg("", "write-timeout", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.WriteTimeout); err == nil { + server.WriteTimeout = d + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSHost != nil && !misc.HasOSArg("", "tls-host", "TLS_HOST") { + server.TLSHost = *configStorage.Dataplaneapi.TLS.TLSHost + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSPort != nil && !misc.HasOSArg("", "tls-port", "TLS_PORT") { + server.TLSPort = *configStorage.Dataplaneapi.TLS.TLSPort + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSCertificate != nil && !misc.HasOSArg("", "tls-certificate", "TLS_CERTIFICATE") { + server.TLSCertificate = *configStorage.Dataplaneapi.TLS.TLSCertificate + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSCertificateKey != nil && !misc.HasOSArg("", "tls-key", "TLS_PRIVATE_KEY") { + server.TLSCertificateKey = *configStorage.Dataplaneapi.TLS.TLSCertificateKey + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSCACertificate != nil && !misc.HasOSArg("", "tls-ca", "TLS_CA_CERTIFICATE") { + server.TLSCACertificate = *configStorage.Dataplaneapi.TLS.TLSCACertificate + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSListenLimit != nil && !misc.HasOSArg("", "tls-listen-limit", "") { + server.TLSListenLimit = *configStorage.Dataplaneapi.TLS.TLSListenLimit + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSKeepAlive != nil && !misc.HasOSArg("", "tls-keep-alive", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.TLS.TLSKeepAlive); err == nil { + server.TLSKeepAlive = d + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSReadTimeout != nil && !misc.HasOSArg("", "tls-read-timeout", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.TLS.TLSReadTimeout); err == nil { + server.TLSReadTimeout = d + } + } + if configStorage.Dataplaneapi != nil && configStorage.Dataplaneapi.TLS != nil && configStorage.Dataplaneapi.TLS.TLSWriteTimeout != nil && !misc.HasOSArg("", "tls-write-timeout", "") { + if d, err := time.ParseDuration(*configStorage.Dataplaneapi.TLS.TLSWriteTimeout); err == nil { + server.TLSWriteTimeout = d + } + } +} diff --git a/discovery/AWS.md b/discovery/AWS.md new file mode 100644 index 00000000..6a3cff02 --- /dev/null +++ b/discovery/AWS.md @@ -0,0 +1,178 @@ +# AWS Service Discovery + +Data Plane API allows performing EC2 instances discovery, self-registering IP addresses as backend servers. + +## Required tags + +All instances must be tagged with the following tags: + +- `HAProxy:Service:Name`: the service name will compose the HAProxy `backend` name. +- `HAProxy:Service:Port`: the default service port is listening to (only one port is allowed). + +> The said tags are mandatory, otherwise, the instance will be ignored. + +An additional tag is provided, in case of override for the single instance + +- `HAProxy:Instance:Port`: allows to override the default Service port (only one port is allowed). + +## Filtering + +By default, all instances in the selected AWS region will be considered. + +Selection of specific instances can be achieved using the `allowlist` functionality, specifying the desired EC2 filter to consider according to the [AWS documentation](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options). + +```yaml + aws_regions: + - description: "Allowlist example" + allowlist: + - key: tag-key + value: "Must:Have:This:Tag:Key" + enabled: false + id: 96b14c57-b011-42e5-8d01-b58feba07319 + name: john.doe + region: "us-east-1" + retrytimeout: 10 + serverslotsbase: 10 + serverslotsgrowthincrement: 10 + serverslotsgrowthtype: exponential +``` + +As `allowlist`, the `denylist` option allows to filter out specific instances matching the desired filters. + +```yaml + aws_regions: + - description: "Denylist example" + allowlist: + - key: tag-key + value: "Must:Have:This:Tag:Key" + denylist: + - key: "tag:Environment + value: Development" + enabled: false + id: 96b14c57-b011-42e5-8d01-b58feba07319 + name: john.doe + region: "us-east-1" + retrytimeout: 10 + serverslotsbase: 10 + serverslotsgrowthincrement: 10 + serverslotsgrowthtype: exponential +``` + +## Authorization + +Data Plane API needs the plain AWS credentials to interact with it. + +```yaml + aws_regions: + - description: "Credentials example" + secretaccesskey: "************************************soLl" + accesskeyid: "****************L7GT" + enabled: false + id: 96b14c57-b011-42e5-8d01-b58feba07319 + name: john.doe + region: "us-east-1" + retrytimeout: 10 + serverslotsbase: 10 + serverslotsgrowthincrement: 10 + serverslotsgrowthtype: exponential +``` + +> In case of Data Plane API running in an EC2 with a IAM Role attached (as [`AmazonEC2ReadOnlyAccess`](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess$serviceLevelSummary)), there's no need for additional credentials. + +## Server options + +Upon a Service discovery, Data Plane API will create the corresponding `backend` section using the following options: + +- `ServerSlotsBase`: the minimum amount of `server` entries per `backend` +- `ServerSlotsGrowthIncrement`: the additional slots allocating for `server` in case of additional entries +- `ServerSlotsGrowthType`: the function type to implement in case of `server` slots growth + +## Instances IP address + +Using the JSON `ipv4_address` option you can specify which kind of IP address Data Plane API has to consider for the backend `server`. + +Available values can be `private` (for the private one, reachable inside the AWS VPC) or `public`. + +> If the instances doesn't have a public IPv4 address, and the service discovery configuration claims the `public` type, In case of `public` type, the EC2 will be ignored. + +## Retry timeout + +With the JSON `retry_timeout` option you can specify the interval of time elapsing between the reconciliation and the following. + +Unit is expressed in __seconds__. + +# Examples + +## Creating a discovery on a selected AWS region + +```json +// curl -XPOST "http://localhost:5555/v2/service_discovery/aws" -H 'content-type: application/json' -d @/path/to/payload.json +{ + "access_key_id": "****************L7GT", + "enabled": true, + "name": "my-service-discovery", + "region": "us-east-1", + "secret_access_key": "****************soLl", + "ipv4_address": "private", + "retry_timeout": 60 +} +``` + +```yaml + aws_regions: + - enabled: true + name: john.doe + region: "us-east-1" + secretaccesskey: "************************************soLl" + ipv4address: private + retrytimeout: 60 +``` + +The resulting output will be the following, YMMV. + +``` +backend aws-us-east-1-my-service-discovery-my-service-name-8080 + server SRV_L17LT 172.31.68.158:8080 check weight 128 + server SRV_lsVqM 127.0.0.1:80 disabled weight 128 + server SRV_NTZyL 127.0.0.1:80 disabled weight 128 + server SRV_KMIFS 127.0.0.1:80 disabled weight 128 + server SRV_D2x28 127.0.0.1:80 disabled weight 128 + server SRV_MlgPJ 127.0.0.1:80 disabled weight 128 + server SRV_0SDZV 127.0.0.1:80 disabled weight 128 + server SRV_HnHJP 127.0.0.1:80 disabled weight 128 + server SRV_xMKi0 127.0.0.1:80 disabled weight 128 + server SRV_tWxu3 127.0.0.1:80 disabled weight 128 +``` + +The `backend` name pattern is built with the following format: +`aws----` + +## Pausing the discovery on a selected AWS region + +```json +// curl -XPUT "http://localhost:5555/v2/service_discovery/aws/96b14c57-b011-42e5-8d01-b58feba07319" -H 'content-type: application/json' -d @/path/to/payload.json +{ + "access_key_id": "****************L7GT", + "enabled": false, + "name": "my-service-discovery", + "region": "us-east-1", + "secret_access_key": "****************soLl", + "ipv4_address": "private", + "retry_timeout": 60 +} +``` + +```yaml + aws_regions: + - accesskeyid: "****************L7GT" + enabled: false + name: my-service-discovery + region: "us-east-1" + secretaccesskey: "****************soLl" + ipv4address: private + retrytimeout: 60 +``` + +As a result of this action, Data Plane API will not update the discovered `backend` sections and their `server` entries: no data will be lost. + +> Potentially, due to the spawn of newer EC2 instances or reboots with a change of the IPv4 address, data could be outdated. diff --git a/discovery/CONSUL.md b/discovery/CONSUL.md new file mode 100644 index 00000000..448886e2 --- /dev/null +++ b/discovery/CONSUL.md @@ -0,0 +1,69 @@ +# CONSUL service discovery + +Dataplane enables connecting to a existing consul service discovery instance and maps services into backends with the nodes as servers. + +# Connecting to consul + +In order to connect dataplane to consul an ACL token is required with appropriate policies/roles set. To register a consul services with +dataplane a request to the `service_discovery/consul` needs to be sent: + +```json +curl -XPOST "http://localhost:5555/v2/service_discovery/consul" -H 'content-type: application/json' -d @/path/to/payload.json +{ + "token": "****************", + "enabled": true, + "name": "my-consul-service", + "description": "Consul test system", + "address": "127.0.0.1", + "port" : 2222, + "retry_timeout": 60 +} +``` +# Filtering + +Namespace filtering can be done by providing the `namespace` option. Only one namespace can be specified and only services from that +namespaces will be tracked. + +Using the `service_allowlist` and `service_denylist` fields a list of services to be tracked or ignored respectively can be provided. The `service_allowlist` option has precedence. In both cases, or if neither option is used, the `consul` service is ignored by dataplane. + +Both of these filtering options can be used simultaneously. + +# Backend example + +The backend in the haproxy configuration associated with the consul service `my-service` will have the following format: + +``` +backend consul-backend-127.0.0.1-2222-my-service + server SRV_rfBd5 127.0.0.11:8088 weight 128 + server SRV_6ti2S 127.0.0.23:8081 weight 128 + server SRV_MtYvS 127.0.0.1:80 disabled weight 128 + server SRV_gD5xA 127.0.0.1:80 disabled weight 128 + server SRV_V0YU9 127.0.0.1:80 disabled weight 128 + server SRV_9zamp 127.0.0.1:80 disabled weight 128 + server SRV_ta7Z7 127.0.0.1:80 disabled weight 128 + server SRV_S575K 127.0.0.1:80 disabled weight 128 + server SRV_LkIZ9 127.0.0.1:80 disabled weight 128 + server SRV_PYkL1 127.0.0.1:80 disabled weight 128 +``` + +The backend name will always have the following format: `consul-backend---`. +Each node associated with the services is represented by a server line with the following format: +`server SRV_ : weight 128` +In addition some additional disabled server lines will be added for future nodes to be used. + +# Updating + +After a consul service discovery is connected to dataplane its data will be polled every `retry_timeout` amount of seconds. Consuls +health endpoint i used to check if there have been changes for each individual service and if there were the server list for that +service gets updated. The changes to all services in a single update cycle are done in a single transaction. If the consul instance +gets updated and the `enabled` parameter gets set to `false` data for that instance will not be pulled anymore but the existing configuration +for that service persists in its current state. + +# Server slot scaling + +The amount of server lines in a backend can be controlled using the `server_slots_base`, `server_slots_growth_type` and `server_slots_growth_increment` parameters. The `server_slots_base` option indicates how many servers are created on backend creation. Once the base slots used up the servers +expand based on the `server_slots_growth_type`: +- `linear` : on each expansion the number of servers increases by the amount specified in `server_slots_growth_increment` +- `exponential` : the number of servers doubles on each server count increase +In case nodes get removed from the service the number of servers in the backend will decrease based on the specified growth type. + diff --git a/discovery/README.md b/discovery/README.md new file mode 100644 index 00000000..5c29018d --- /dev/null +++ b/discovery/README.md @@ -0,0 +1,9 @@ +# Data Plane API Service Discovery + +## AWS + +Check the AWS Service Discovery [README](./AWS.md). + +## CONSUL + +Check the CONSUL Service Discovery [README](./CONSUL.md). diff --git a/discovery/aws_service_discovery.go b/discovery/aws_service_discovery.go new file mode 100644 index 00000000..d9ed3789 --- /dev/null +++ b/discovery/aws_service_discovery.go @@ -0,0 +1,117 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "context" + "errors" + + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" +) + +type awsServiceDiscovery struct { + services Store + client configuration.Configuration + reloadAgent haproxy.IReloadAgent + context context.Context +} + +// NewAWSDiscoveryService creates a new ServiceDiscovery that connects to AWS +func NewAWSDiscoveryService(params ServiceDiscoveriesParams) ServiceDiscovery { + return &awsServiceDiscovery{ + services: NewInstanceStore(), + client: params.Client, + reloadAgent: params.ReloadAgent, + context: params.Context, + } +} + +func (a awsServiceDiscovery) AddNode(id string, params ServiceDiscoveryParams) (err error) { + aParams, ok := params.(*models.AwsRegion) + if !ok { + return errors.New("expected *models.AwsRegion") + } + + var instance *awsInstance + instance, err = newAWSRegionInstance(a.context, aParams, a.client, a.reloadAgent) + if err != nil { + return err + } + + if err = a.services.Create(id, instance); err != nil { + return err + } + + if *aParams.Enabled { + instance.start() + } + return err +} + +func (a awsServiceDiscovery) GetNode(id string) (params ServiceDiscoveryParams, err error) { + var i any + if i, err = a.services.Read(id); err != nil { + return params, err + } + return i.(*awsInstance).params, nil +} + +func (a awsServiceDiscovery) GetNodes() (ServiceDiscoveryParams, error) { + var awsRegions models.AwsRegions + for _, as := range a.services.List() { + awsRegions = append(awsRegions, as.(*awsInstance).params) + } + return awsRegions, nil +} + +func (a awsServiceDiscovery) RemoveNode(id string) error { + return a.services.Delete(id) +} + +func (a awsServiceDiscovery) UpdateNode(id string, params ServiceDiscoveryParams) error { + newParams, ok := params.(*models.AwsRegion) + if !ok { + return errors.New("expected *models.AwsRegion") + } + return a.services.Update(id, func(item any) (err error) { + ai := item.(*awsInstance) + + if err = ai.updateTimeout(*newParams.RetryTimeout); err != nil { + if *ai.params.Enabled { + ai.stop() + } + return errors.New("invalid retry_timeout") + } + + switch { + case *newParams.Enabled == *ai.params.Enabled: + break + case *newParams.Enabled && !*ai.params.Enabled: + ai.start() + default: + ai.stop() + } + ai.params = newParams + + if *ai.params.Enabled { + ai.update <- struct{}{} + } + + return err + }) +} diff --git a/discovery/aws_service_discovery_instance.go b/discovery/aws_service_discovery_instance.go new file mode 100644 index 00000000..433f3185 --- /dev/null +++ b/discovery/aws_service_discovery_instance.go @@ -0,0 +1,418 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "context" + "fmt" + "strconv" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/credentials" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/misc" +) + +const ( + HAProxyServiceNameTag = "HAProxy:Service:Name" + HAProxyServicePortTag = "HAProxy:Service:Port" + HAProxyInstancePortTag = "HAProxy:Instance:Port" +) + +type awsInstance struct { + ctx context.Context + params *models.AwsRegion + update chan struct{} + state map[string]map[string]time.Time + discoveryConfig *ServiceDiscoveryInstance + logFields map[string]any + timeout time.Duration +} + +type awsService struct { + instances map[string]types.Instance + name string + region string + instanceName string + ipv4 string + changed bool +} + +func (a awsService) GetName() string { + return a.name +} + +func (a awsService) GetFrom() string { + return "" +} + +func (a awsService) GetBackendName() string { + return fmt.Sprintf("aws-%s-%s-%s", a.region, a.instanceName, a.GetName()) +} + +func (a awsService) Changed() bool { + return a.changed +} + +func (a awsService) GetServers() (servers []configuration.ServiceServer) { + for _, instance := range a.instances { + parsedPort, _ := a.instancePortFromEC2(instance) + var address string + switch a.ipv4 { + case models.AwsRegionIPV4AddressPrivate: + address = aws.ToString(instance.PrivateIpAddress) + case models.AwsRegionIPV4AddressPublic: + address = aws.ToString(instance.PublicIpAddress) + default: + continue + } + // In case of public IPv4 and the instance doesn't have it, ignoring. + if len(address) == 0 { + continue + } + var port *int64 + + if parsedPort > 0 { + port = misc.Int64P(parsedPort) + } + + servers = append(servers, configuration.ServiceServer{ + Address: address, + Port: port, + }) + } + return servers +} + +func newAWSRegionInstance(ctx context.Context, params *models.AwsRegion, client configuration.Configuration, reloadAgent haproxy.IReloadAgent) (*awsInstance, error) { + timeout, err := time.ParseDuration(fmt.Sprintf("%ds", *params.RetryTimeout)) + if err != nil { + return nil, err + } + + logFields := map[string]any{"ServiceDiscovery": "AWS", "ID": *params.ID} + + ai := &awsInstance{ + params: params, + timeout: timeout, + ctx: ctx, + logFields: logFields, + state: make(map[string]map[string]time.Time), + discoveryConfig: NewServiceDiscoveryInstance(client, reloadAgent, discoveryInstanceParams{ + Allowlist: []string{}, + Denylist: []string{}, + LogFields: logFields, + ServerSlotsBase: int(*params.ServerSlotsBase), + SlotsGrowthType: *params.ServerSlotsGrowthType, + SlotsIncrement: int(params.ServerSlotsGrowthIncrement), + }), + } + if err = ai.updateTimeout(*params.RetryTimeout); err != nil { + return nil, err + } + + return ai, nil +} + +func (a *awsInstance) filterConverter(in []*models.AwsFilters) (out []types.Filter) { + out = make([]types.Filter, len(in)) + for i, l := range in { + out[i] = types.Filter{ + Name: l.Key, + Values: []string{aws.ToString(l.Value)}, + } + } + return out +} + +func (a *awsInstance) updateTimeout(timeoutSeconds int64) error { + timeout, err := time.ParseDuration(fmt.Sprintf("%ds", timeoutSeconds)) + if err != nil { + return err + } + a.timeout = timeout + return nil +} + +func (a *awsInstance) updateServicesFn() { + a.logDebug("discovery job update triggered") + + var api *ec2.Client + var err error + + if api, err = a.setAPIClient(); err != nil { + a.logErrorf("error while setting up the API client: %s", err.Error()) + return + } + + if err = a.updateServices(api); err != nil { + switch t := err.(type) { + case *configuration.ConfError: + switch t.Err() { + case configuration.ErrObjectAlreadyExists: + a.logDebug("object already exists, ignoring error") + return + default: + a.logErrorf("a configuration error occurred while updating service: %s", err.Error()) + return + } + default: + a.logErrorf("an error occurred while updating service: %s", err.Error()) + return + } + } + + a.logDebug("discovery job reconciliation completed") +} + +func (a *awsInstance) start() { + a.update = make(chan struct{}) + + go func() { + a.logDebug("discovery job starting") + + discoveryTimer := time.NewTimer(a.timeout) + defer discoveryTimer.Stop() + + for { + select { + case _, ok := <-a.update: + if !ok { + return + } + + a.logDebug("discovery job update triggered") + + err := a.discoveryConfig.UpdateParams(discoveryInstanceParams{ + Allowlist: []string{}, + Denylist: []string{}, + LogFields: a.logFields, + ServerSlotsBase: int(*a.params.ServerSlotsBase), + SlotsGrowthType: *a.params.ServerSlotsGrowthType, + SlotsIncrement: int(a.params.ServerSlotsGrowthIncrement), + }) + if err != nil { + a.logErrorf("error while updating discovery settings: %s", err.Error()) + break + } + + a.logDebug("discovery job update completed") + case <-discoveryTimer.C: + a.updateServicesFn() + discoveryTimer.Reset(a.timeout) + case <-a.ctx.Done(): + a.stop() + } + } + }() +} + +func (a *awsInstance) setAPIClient() (*ec2.Client, error) { + ctx, cancelFn := context.WithTimeout(a.ctx, a.timeout) + defer cancelFn() + + opts := []func(options *config.LoadOptions) error{ + config.WithRegion(*a.params.Region), + } + if len(a.params.AccessKeyID) > 0 && len(a.params.SecretAccessKey) > 0 { + opts = append(opts, config.WithCredentialsProvider(credentials.StaticCredentialsProvider{ + Value: aws.Credentials{ + AccessKeyID: a.params.AccessKeyID, + SecretAccessKey: a.params.SecretAccessKey, + }, + })) + } + cfg, err := config.LoadDefaultConfig(ctx, opts...) + if err != nil { + return nil, fmt.Errorf("cannot generate the AWS instance due to a configuration setup error: %w", err) + } + + return ec2.NewFromConfig(cfg), nil +} + +func (a *awsInstance) updateServices(api *ec2.Client) (err error) { + ctx, cancel := context.WithTimeout(a.ctx, a.timeout) + defer cancel() + + var io *ec2.DescribeInstancesOutput + + io, err = api.DescribeInstances(ctx, &ec2.DescribeInstancesInput{ + Filters: append([]types.Filter{ + { + Name: aws.String("tag-key"), + Values: []string{HAProxyServiceNameTag, HAProxyServicePortTag}, + }, + { + Name: aws.String("instance-state-name"), + Values: []string{"running"}, + }, + }, a.filterConverter(a.params.Allowlist)...), + }) + if err != nil { + return err + } + + mapService := make(map[string]*awsService) + + for _, r := range io.Reservations { + for _, i := range r.Instances { + var sn string + sn, err = a.serviceNameFromEC2(i) + if err != nil { + a.logErrorf("unable to retrieve service name for the instance %s", *i.InstanceId) + + continue + } + // creating empty service in case it isn't there + if _, ok := mapService[sn]; !ok { + mapService[sn] = &awsService{ + name: sn, + region: *a.params.Region, + instanceName: *a.params.Name, + ipv4: *a.params.IPV4Address, + instances: make(map[string]types.Instance), + } + } + instanceID := aws.ToString(i.InstanceId) + + if _, portErr := mapService[sn].instancePortFromEC2(i); portErr != nil { + a.logErrorf("unable to retrieve service port for the instance %s", *i.InstanceId) + + continue + } + + mapService[sn].instances[instanceID] = i + } + } + + if len(a.params.Denylist) > 0 { + // AWS API doesn't provide negative filter search, so doing on our own + io, err = api.DescribeInstances(ctx, &ec2.DescribeInstancesInput{ + Filters: a.filterConverter(a.params.Denylist), + }) + if err == nil { + for _, r := range io.Reservations { + for _, i := range r.Instances { + var sn string + sn, err = a.serviceNameFromEC2(i) + // definitely we can skip, there's no Service metadata tag + if err != nil { + continue + } + // neither tracked as Service, we can skip + if _, ok := mapService[sn]; !ok { + continue + } + // we have an occurrence, we have to delete + instanceID := aws.ToString(i.InstanceId) + delete(mapService[sn].instances, instanceID) + } + } + } + } + + var services []ServiceInstance + for _, s := range mapService { + // We don't have a proper way to understand if a Service has changed, or not, this can be achieved + // iterating over the instances being part of the Service and check the last launch time: + // if something differs, a change occurred. + s.changed = func() bool { + if _, ok := a.state[s.name]; !ok { + return true + } + if len(a.state[s.name]) != len(s.instances) { + return true + } + for _, instance := range s.instances { + instanceID := aws.ToString(instance.InstanceId) + v, ok := a.state[s.name][instanceID] + if !ok { + return true + } + if v != *instance.LaunchTime { + return true + } + } + return false + }() + services = append(services, s) + + a.state[s.name] = func(instances map[string]types.Instance) (hash map[string]time.Time) { + hash = make(map[string]time.Time) + for _, instance := range instances { + id := aws.ToString(instance.InstanceId) + hash[id] = aws.ToTime(instance.LaunchTime) + } + return hash + }(s.instances) + } + + return a.discoveryConfig.UpdateServices(services) +} + +func (a *awsInstance) stop() { + a.logDebug("discovery job stopping") + close(a.update) +} + +func (a *awsService) instancePortFromEC2(instance types.Instance) (port int, err error) { + for _, t := range instance.Tags { + switch *t.Key { + case HAProxyServicePortTag: + port, err = strconv.Atoi(*t.Value) + case HAProxyInstancePortTag: + return strconv.Atoi(*t.Value) + } + } + return port, err +} + +func (a *awsInstance) serviceNameFromEC2(instance types.Instance) (string, error) { + var name, port string +L: + for _, t := range instance.Tags { + switch { + case *t.Key == HAProxyServiceNameTag: + name = aws.ToString(t.Value) + case *t.Key == HAProxyServicePortTag: + port = aws.ToString(t.Value) + case len(name) > 0 && len(port) > 0: + break L + } + } + + if len(name) == 0 || len(port) == 0 { + return "", fmt.Errorf("missing metadata for instance %s", *instance.InstanceId) + } + + return fmt.Sprintf("%s-%s", name, port), nil +} + +func (a *awsInstance) logDebug(message string) { + log.WithFields(a.logFields, log.DebugLevel, message) +} + +func (a *awsInstance) logErrorf(format string, args ...any) { + log.WithFieldsf(a.logFields, log.ErrorLevel, format, args...) +} diff --git a/discovery/consul_service_discovery.go b/discovery/consul_service_discovery.go new file mode 100644 index 00000000..6b9f0796 --- /dev/null +++ b/discovery/consul_service_discovery.go @@ -0,0 +1,123 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" +) + +type consulServiceDiscovery struct { + consulServices Store + client configuration.Configuration + reloadAgent haproxy.IReloadAgent + context context.Context +} + +// NewConsulDiscoveryService creates a new ServiceDiscovery that connects to consul +func NewConsulDiscoveryService(params ServiceDiscoveriesParams) ServiceDiscovery { + return &consulServiceDiscovery{ + consulServices: NewInstanceStore(), + client: params.Client, + reloadAgent: params.ReloadAgent, + context: params.Context, + } +} + +func (c *consulServiceDiscovery) AddNode(id string, params ServiceDiscoveryParams) (err error) { + cParams, ok := params.(*models.Consul) + if !ok { + return errors.New("expected models.Consuls") + } + + var timeout time.Duration + timeout, err = time.ParseDuration(fmt.Sprintf("%ds", *cParams.RetryTimeout)) + if err != nil { + return err + } + + logFields := map[string]any{"ServiceDiscovery": "Consul", "ID": *cParams.ID} + + instance := &consulInstance{ + params: cParams, + ctx: c.context, + timeout: timeout, + discoveryConfig: NewServiceDiscoveryInstance(c.client, c.reloadAgent, discoveryInstanceParams{ + Allowlist: cParams.ServiceAllowlist, + Denylist: cParams.ServiceDenylist, + LogFields: logFields, + ServerSlotsBase: int(*cParams.ServerSlotsBase), + SlotsGrowthType: *cParams.ServerSlotsGrowthType, + SlotsIncrement: int(cParams.ServerSlotsGrowthIncrement), + }), + prevIndexes: make(map[string]uint64), + logFields: logFields, + } + + if err = c.consulServices.Create(id, instance); err != nil { + return err + } + + instance.prevEnabled = *cParams.Enabled + + if *cParams.Enabled { + return instance.start() + } + return nil +} + +func (c *consulServiceDiscovery) GetNode(id string) (p ServiceDiscoveryParams, err error) { + var i any + if i, err = c.consulServices.Read(id); err != nil { + return p, err + } + p = i.(*consulInstance).params + return p, err +} + +func (c *consulServiceDiscovery) GetNodes() (ServiceDiscoveryParams, error) { + var consuls models.Consuls + for _, ci := range c.consulServices.List() { + consuls = append(consuls, ci.(*consulInstance).params) + } + return consuls, nil +} + +func (c *consulServiceDiscovery) RemoveNode(id string) error { + return c.consulServices.Delete(id) +} + +func (c *consulServiceDiscovery) UpdateNode(id string, params ServiceDiscoveryParams) (err error) { + cParams, ok := params.(*models.Consul) + if !ok { + return errors.New("expected models.Consuls") + } + return c.consulServices.Update(id, func(item any) error { + ci := item.(*consulInstance) + ci.params = cParams + if err = ci.updateTimeout(int(*cParams.RetryTimeout)); err != nil { + ci.stop() + return errors.New("invalid retry_timeout") + } + return ci.handleStateChange() + }) +} diff --git a/discovery/consul_service_discovery_instance.go b/discovery/consul_service_discovery_instance.go new file mode 100644 index 00000000..6b68eadd --- /dev/null +++ b/discovery/consul_service_discovery_instance.go @@ -0,0 +1,427 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "context" + "fmt" + "io" + "net" + "net/http" + "net/url" + "strconv" + "time" + + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/misc" + jsoniter "github.com/json-iterator/go" +) + +type consulService struct { + params *models.Consul + name string + servers []configuration.ServiceServer + changed bool +} + +func (c *consulService) GetName() string { + return c.name +} + +func (c *consulService) GetFrom() string { + return c.params.Defaults +} + +func (c *consulService) GetBackendName() string { + return fmt.Sprintf("consul-backend-%s-%d-%s", *c.params.Address, *c.params.Port, c.name) +} + +func (c *consulService) Changed() bool { + return c.changed +} + +func (c *consulService) GetServers() []configuration.ServiceServer { + return c.servers +} + +type consulInstance struct { + ctx context.Context + params *models.Consul + httpClient *http.Client + discoveryConfig *ServiceDiscoveryInstance + prevIndexes map[string]uint64 + update chan struct{} + logFields map[string]any + timeout time.Duration + prevEnabled bool +} + +func (c *consulInstance) start() error { + c.logDebug("discovery job starting") + if err := c.setAPIClient(); err != nil { + return err + } + c.update = make(chan struct{}, 1) + go c.watch() + return nil +} + +func (c *consulInstance) setAPIClient() error { + c.httpClient = &http.Client{ + Timeout: time.Minute, + } + return nil +} + +func (c *consulInstance) watch() { + watchTimer := time.NewTimer(c.timeout) + defer watchTimer.Stop() + + for { + select { + case _, ok := <-c.update: + if !ok { + return + } + c.logDebug("discovery job update triggered") + if err := c.setAPIClient(); err != nil { + c.logErrorf("error while setting up the API client: %s", err.Error()) + c.stop() + continue + } + err := c.discoveryConfig.UpdateParams(discoveryInstanceParams{ + Allowlist: c.params.ServiceAllowlist, + Denylist: c.params.ServiceDenylist, + LogFields: c.logFields, + ServerSlotsBase: int(*c.params.ServerSlotsBase), + SlotsGrowthType: *c.params.ServerSlotsGrowthType, + SlotsIncrement: int(c.params.ServerSlotsGrowthIncrement), + }) + if err != nil { + c.stop() + c.logErrorf("error while updating the instance: %s", err.Error()) + } + case <-c.ctx.Done(): + c.stop() + case <-watchTimer.C: + c.logDebug("discovery job reconciliation started") + if err := c.updateServices(); err != nil { + // c.log.Errorf("error while updating service: %w", err) + c.stop() + } + c.logDebug("discovery job reconciliation completed") + watchTimer.Reset(c.timeout) + } + } +} + +func (c *consulInstance) stop() { + c.logDebug("discovery job stopping") + c.httpClient = nil + c.prevEnabled = false + close(c.update) +} + +func (c *consulInstance) updateServices() error { + services := make([]ServiceInstance, 0) + params := &queryParams{} + if c.params.Namespace != "" { + params.Namespace = c.params.Namespace + } + + if c.params.ServiceNameRegexp != "" { + params.Filter = fmt.Sprintf("ServiceName matches \"%s\"", c.params.ServiceNameRegexp) + } + cServices, _, err := c.queryCatalogServices(params) + if err != nil { + return err + } + newIndexes := make(map[string]uint64) + for se := range cServices { + if se == "consul" { + continue + } + nodes, meta, err := c.queryHealthService(se, &queryParams{}) + if err != nil { + continue + } + newIndexes[se] = meta.LastIndex + services = append(services, &consulService{ + name: se, + params: c.params, + servers: c.convertToServers(nodes), + changed: c.hasServiceChanged(se, meta.LastIndex), + }) + } + c.prevIndexes = newIndexes + return c.discoveryConfig.UpdateServices(services) +} + +func (c *consulInstance) convertToServers(nodes []*serviceEntry) []configuration.ServiceServer { + servers := make([]configuration.ServiceServer, 0) + for _, node := range nodes { + if !c.validateHealthChecks(node) { + continue + } + if node.Service.Address != "" { + ss := configuration.ServiceServer{ + Address: node.Service.Address, + } + if node.Service.Port > 0 { + ss.Port = misc.Int64P(node.Service.Port) + } + servers = append(servers, ss) + } else { + ss := configuration.ServiceServer{ + Address: node.Node.Address, + } + if node.Service.Port > 0 { + ss.Port = misc.Int64P(node.Service.Port) + } + servers = append(servers, ss) + } + } + return servers +} + +func (c *consulInstance) validateHealthChecks(node *serviceEntry) bool { + if c.params.HealthCheckPolicy == nil { + return true + } + switch *c.params.HealthCheckPolicy { + case models.ConsulHealthCheckPolicyAny: + return c.validateHealthChecksAny(node) + case models.ConsulHealthCheckPolicyAll: + return c.validateHealthChecksAll(node) + case models.ConsulHealthCheckPolicyMin: + return c.validateHealthChecksMin(node) + case models.ConsulHealthCheckPolicyNone: + return true + default: + return true + } +} + +func (c *consulInstance) validateHealthChecksAny(node *serviceEntry) bool { + if len(node.Checks) == 0 { + return false + } + + for _, check := range node.Checks { + if check.Status == "passing" { + return true + } + } + return false +} + +func (c *consulInstance) validateHealthChecksAll(node *serviceEntry) bool { + if len(node.Checks) == 0 { + return false + } + + for _, check := range node.Checks { + if check.Status != "passing" { + return false + } + } + return true +} + +func (c *consulInstance) validateHealthChecksMin(node *serviceEntry) bool { + if len(node.Checks) == 0 { + return false + } + + passing := 0 + for _, check := range node.Checks { + if check.Status == "passing" { + passing++ + } + } + return passing >= int(c.params.HealthCheckPolicyMin) +} + +func (c *consulInstance) hasServiceChanged(service string, index uint64) bool { + prevIndex, ok := c.prevIndexes[service] + if !ok { + return true + } + return prevIndex != index +} + +func (c *consulInstance) updateTimeout(timeoutSeconds int) error { + timeout, err := time.ParseDuration(fmt.Sprintf("%ds", timeoutSeconds)) + if err != nil { + return err + } + c.timeout = timeout + return nil +} + +func (c *consulInstance) handleStateChange() error { + if c.stateChangedToEnabled() { + if err := c.start(); err != nil { + c.prevEnabled = false + return err + } + c.prevEnabled = *c.params.Enabled + return nil + } + if c.stateChangedToDisabled() { + c.stop() + } + if *c.params.Enabled { + c.update <- struct{}{} + } + c.prevEnabled = *c.params.Enabled + return nil +} + +func (c *consulInstance) stateChangedToEnabled() bool { + return !c.prevEnabled && *c.params.Enabled +} + +func (c *consulInstance) stateChangedToDisabled() bool { + return c.prevEnabled && !*c.params.Enabled +} + +func (c *consulInstance) logDebug(message string) { + log.WithFields(c.logFields, log.DebugLevel, message) +} + +func (c *consulInstance) logErrorf(format string, args ...any) { + log.WithFieldsf(c.logFields, log.ErrorLevel, format, args...) +} + +func (c *consulInstance) queryCatalogServices(params *queryParams) (map[string][]string, *queryMetadata, error) { + nodes := map[string][]string{} + meta, err := c.doConsulQuery(http.MethodGet, "/v1/catalog/services", params, &nodes) + if err != nil { + return nil, nil, err + } + return nodes, meta, nil +} + +func (c *consulInstance) queryHealthService(se string, params *queryParams) ([]*serviceEntry, *queryMetadata, error) { + services := []*serviceEntry{} + path, err := url.JoinPath("/v1/health/service/", se) + if err != nil { + return nil, nil, err + } + meta, err := c.doConsulQuery(http.MethodGet, path, params, &services) + if err != nil { + return nil, nil, err + } + return services, meta, nil +} + +func (c *consulInstance) doConsulQuery(method string, path string, params *queryParams, resp any) (*queryMetadata, error) { + mode := "http://" + if c.params.Mode != nil { + mode = *c.params.Mode + "://" + } + fullPath, err := url.JoinPath( + mode, + net.JoinHostPort(*c.params.Address, strconv.FormatInt(*c.params.Port, 10)), + path, + ) + if err != nil { + return nil, err + } + req, err := http.NewRequest(method, fullPath, nil) + if err != nil { + return nil, err + } + + // Global Consul parameters. + if c.params.Token != "" { + req.Header.Add("X-Consul-Token", c.params.Token) + } + + q := url.Values{} + + // Request's parameters. + if params.Namespace != "" { + q.Add("ns", c.params.Namespace) + } + + if params.Filter != "" { + q.Add("filter", params.Filter) + } + + req.URL.RawQuery = q.Encode() + + httpResp, err := c.httpClient.Do(req) + if err != nil { + return nil, err + } + defer httpResp.Body.Close() + raw, err := io.ReadAll(httpResp.Body) + if err != nil { + return nil, err + } + json := jsoniter.ConfigCompatibleWithStandardLibrary + err = json.Unmarshal(raw, resp) + if err != nil { + return nil, err + } + + meta, err := extractMetadata(httpResp) + if err != nil { + return nil, err + } + + return meta, nil +} + +type serviceEntry struct { + Node *struct { + Address string + } + Service *struct { + Address string + Port int + } + Checks []*struct { + Status string + } +} + +type queryParams struct { + Namespace string + Filter string +} + +type queryMetadata struct { + LastIndex uint64 +} + +func extractMetadata(resp *http.Response) (*queryMetadata, error) { + meta := queryMetadata{} + indexStr := resp.Header.Get("X-Consul-Index") + if indexStr != "" { + lastIndex, err := strconv.ParseUint(indexStr, 10, 64) + if err != nil { + return nil, err + } + meta.LastIndex = lastIndex + } + return &meta, nil +} diff --git a/discovery/service_discovery.go b/discovery/service_discovery.go new file mode 100644 index 00000000..8951768b --- /dev/null +++ b/discovery/service_discovery.go @@ -0,0 +1,122 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "context" + "errors" + + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/dataplaneapi/haproxy" +) + +// ServiceDiscoveryParams configuration for a specific service discovery +type ServiceDiscoveryParams any + +// ServiceDiscovery represents the required methods for a service discovery +type ServiceDiscovery interface { + AddNode(id string, params ServiceDiscoveryParams) error + GetNode(id string) (ServiceDiscoveryParams, error) + GetNodes() (ServiceDiscoveryParams, error) + RemoveNode(id string) error + UpdateNode(id string, params ServiceDiscoveryParams) error +} + +// ServiceDiscoveries manages all registered service discovery services +type ServiceDiscoveries interface { + AddNode(serviceName string, id string, params ServiceDiscoveryParams) error + AddService(serviceName string, serviceImpl ServiceDiscovery) error + GetNode(serviceName string, id string) (ServiceDiscoveryParams, error) + GetNodes(serviceName string) (ServiceDiscoveryParams, error) + RemoveNode(serviceName string, id string) error + RemoveService(serviceName string) error + UpdateNode(serviceName string, id string, params ServiceDiscoveryParams) error +} + +// ServiceDiscoveriesParams contain the parameters for the service discovery initialization +type ServiceDiscoveriesParams struct { + Client configuration.Configuration + ReloadAgent haproxy.IReloadAgent + Context context.Context +} + +// NewServiceDiscoveries creates a new ServiceDiscoveries instance +func NewServiceDiscoveries(params ServiceDiscoveriesParams) ServiceDiscoveries { + sd := &serviceDiscoveryImpl{ + services: NewInstanceStore(), + } + sd.AddService("consul", NewConsulDiscoveryService(params)) + _ = sd.AddService("aws", NewAWSDiscoveryService(params)) + return sd +} + +type serviceDiscoveryImpl struct { + services Store +} + +func (s *serviceDiscoveryImpl) AddNode(serviceName string, id string, params ServiceDiscoveryParams) error { + sd, err := s.services.Read(serviceName) + if err != nil { + return errors.New("service not found") + } + return sd.(ServiceDiscovery).AddNode(id, params) +} + +func (s *serviceDiscoveryImpl) AddService(serviceName string, serviceImpl ServiceDiscovery) error { + if err := s.services.Create(serviceName, serviceImpl); err != nil { + return errors.New("service already exists") + } + return nil +} + +func (s *serviceDiscoveryImpl) GetNode(serviceName string, id string) (ServiceDiscoveryParams, error) { + sd, err := s.services.Read(serviceName) + if err != nil { + return nil, errors.New("service not found") + } + return sd.(ServiceDiscovery).GetNode(id) +} + +func (s *serviceDiscoveryImpl) GetNodes(serviceName string) (ServiceDiscoveryParams, error) { + sd, err := s.services.Read(serviceName) + if err != nil { + return nil, errors.New("service not found") + } + return sd.(ServiceDiscovery).GetNodes() +} + +func (s *serviceDiscoveryImpl) RemoveNode(serviceName string, id string) error { + sd, err := s.services.Read(serviceName) + if err != nil { + return errors.New("service not found") + } + return sd.(ServiceDiscovery).RemoveNode(id) +} + +func (s *serviceDiscoveryImpl) RemoveService(serviceName string) error { + if err := s.services.Delete(serviceName); err != nil { + return errors.New("service not found") + } + return nil +} + +func (s *serviceDiscoveryImpl) UpdateNode(serviceName string, id string, params ServiceDiscoveryParams) error { + sd, err := s.services.Read(serviceName) + if err != nil { + return errors.New("service not found") + } + return sd.(ServiceDiscovery).UpdateNode(id, params) +} diff --git a/discovery/service_discovery_instance.go b/discovery/service_discovery_instance.go new file mode 100644 index 00000000..b031398b --- /dev/null +++ b/discovery/service_discovery_instance.go @@ -0,0 +1,229 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "slices" + "sync" + + "github.com/haproxytech/client-native/v6/configuration" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/log" +) + +// Using a simple mutex to avoid race conditions when multiple Service Discovery instances are trying to commit +// changes at the same time: need to be refactored. +var mutex = &sync.Mutex{} + +// ServiceInstance specifies the needed information required from the service to provide for the ServiceDiscoveryInstance. +type ServiceInstance interface { + GetName() string + GetBackendName() string + GetFrom() string + Changed() bool + GetServers() []configuration.ServiceServer +} + +type confService struct { + confService *configuration.Service + cleanup bool +} + +type discoveryInstanceParams struct { + LogFields map[string]any + SlotsGrowthType string + Allowlist []string + Denylist []string + ServerSlotsBase int + SlotsIncrement int +} + +// ServiceDiscoveryInstance manages and updates all services of a single service discovery. +type ServiceDiscoveryInstance struct { + client configuration.Configuration + reloadAgent haproxy.IReloadAgent + services map[string]*confService + transactionID string + params discoveryInstanceParams +} + +// NewServiceDiscoveryInstance creates a new ServiceDiscoveryInstance. +func NewServiceDiscoveryInstance(client configuration.Configuration, reloadAgent haproxy.IReloadAgent, params discoveryInstanceParams) *ServiceDiscoveryInstance { + return &ServiceDiscoveryInstance{ + client: client, + reloadAgent: reloadAgent, + params: params, + services: make(map[string]*confService), + } +} + +// UpdateParams updates the scaling params for each service associated with the service discovery. +func (s *ServiceDiscoveryInstance) UpdateParams(params discoveryInstanceParams) error { + s.params = params + for _, se := range s.services { + err := se.confService.UpdateScalingParams(configuration.ScalingParams{ + BaseSlots: s.params.ServerSlotsBase, + SlotsGrowthType: s.params.SlotsGrowthType, + SlotsIncrement: s.params.SlotsIncrement, + }) + if err != nil { + return err + } + } + return nil +} + +// UpdateServices updates each service and persists the changes inside a single transaction. +func (s *ServiceDiscoveryInstance) UpdateServices(services []ServiceInstance) error { + mutex.Lock() + defer mutex.Unlock() + + err := s.startTransaction() + if err != nil { + return err + } + reload := false + s.markForCleanUp() + for _, service := range services { + if s.serviceNotTracked(service.GetName()) { + continue + } + if !service.Changed() { + if se, ok := s.services[service.GetName()]; ok { + se.cleanup = false + } + continue + } + r, err := s.initService(service) + if err != nil { + s.deleteTransaction() + return err + } + reload = reload || r + se := s.services[service.GetName()] + r, err = se.confService.Update(service.GetServers()) + if err != nil { + s.deleteTransaction() + return err + } + reload = reload || r + } + r := s.cleanup() + reload = reload || r + if reload { + if err := s.commitTransaction(); err != nil { + return err + } + s.reloadAgent.Reload() + return nil + } + s.deleteTransaction() + return nil +} + +func (s *ServiceDiscoveryInstance) startTransaction() error { + version, err := s.client.GetVersion("") + if err != nil { + return err + } + transaction, err := s.client.StartTransaction(version) + if err != nil { + return err + } + s.transactionID = transaction.ID + return nil +} + +func (s *ServiceDiscoveryInstance) markForCleanUp() { + for id := range s.services { + s.services[id].cleanup = true + } +} + +func (s *ServiceDiscoveryInstance) serviceNotTracked(service string) bool { + if len(s.params.Allowlist) > 0 { + return !slices.Contains(s.params.Allowlist, service) + } + return slices.Contains(s.params.Denylist, service) +} + +func (s *ServiceDiscoveryInstance) initService(service ServiceInstance) (bool, error) { + if se, ok := s.services[service.GetName()]; ok { + se.confService.SetTransactionID(s.transactionID) + se.cleanup = false + return false, nil + } + se, err := s.client.NewService(service.GetBackendName(), configuration.ScalingParams{ + BaseSlots: s.params.ServerSlotsBase, + SlotsGrowthType: s.params.SlotsGrowthType, + SlotsIncrement: s.params.SlotsIncrement, + }) + if err != nil { + return false, err + } + reload, err := se.Init(s.transactionID, service.GetFrom()) + if err != nil { + return false, err + } + s.services[service.GetName()] = &confService{ + confService: se, + cleanup: false, + } + return reload, nil +} + +func (s *ServiceDiscoveryInstance) cleanup() (reload bool) { + for service := range s.services { + if s.services[service].cleanup { + s.services[service].confService.SetTransactionID(s.transactionID) + changed, err := s.services[service].confService.Update([]configuration.ServiceServer{}) + if err != nil { + s.logErrorf("service %s marked for clean-up cannot be updated, %s", service, err.Error()) + continue + } + + if changed { + s.logWarningf("service %s marked for clean-up, has not any more backend servers", service) + } + + reload = reload || changed + } + } + + return reload +} + +func (s *ServiceDiscoveryInstance) deleteTransaction() { + if err := s.client.DeleteTransaction(s.transactionID); err != nil { + s.logWarningf("cannot delete transaction due to an error: %s", err.Error()) + } + s.transactionID = "" +} + +func (s *ServiceDiscoveryInstance) commitTransaction() error { + _, err := s.client.CommitTransaction(s.transactionID) + s.transactionID = "" + return err +} + +func (s *ServiceDiscoveryInstance) logWarningf(format string, args ...any) { + log.WithFieldsf(s.params.LogFields, log.WarnLevel, format, args...) +} + +func (s *ServiceDiscoveryInstance) logErrorf(format string, args ...any) { + log.WithFieldsf(s.params.LogFields, log.ErrorLevel, format, args...) +} diff --git a/discovery/service_discovery_instance_test.go b/discovery/service_discovery_instance_test.go new file mode 100644 index 00000000..e5d30202 --- /dev/null +++ b/discovery/service_discovery_instance_test.go @@ -0,0 +1,307 @@ +//go:build aws +// +build aws + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "context" + "fmt" + "io/ioutil" + "os" + "testing" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/credentials" + "github.com/aws/aws-sdk-go-v2/service/autoscaling" + "github.com/aws/aws-sdk-go-v2/service/autoscaling/types" + "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/google/uuid" + "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/client-native/v6/models" + "github.com/stretchr/testify/assert" + + "github.com/haproxytech/dataplaneapi/haproxy" +) + +var ( + AWSSecretAccessKey string + AWSAccessKeyID string +) + +const ( + region = "us-east-1" + ami = "ami-0742b4e673072066f" + additionalTag = "HAProxy:Integration:Test" + serviceName = "my-app" + servicePort = 8080 +) + +func TestAWS(t *testing.T) { + if len(AWSSecretAccessKey) == 0 { + t.Fatal("missing AWS Secret Access Key, cannot test on AWS") + } + if len(AWSAccessKeyID) == 0 { + t.Fatal("missing AWS Access Key ID, cannot test on AWS") + } + + var tmp string + var err error + tmp, err = ioutil.TempDir("", "haproxy") + assert.Nil(t, err) + t.Cleanup(func() { + _ = os.RemoveAll(tmp) + _ = os.Remove(tmp) + }) + + cfgFile := fmt.Sprintf("%s/haproxy.cfg", tmp) + _, err = os.Create(cfgFile) + assert.Nil(t, err) + + confClient := &configuration.Client{} + confParams := configuration.ClientParams{ + ConfigurationFile: cfgFile, + TransactionDir: tmp, + } + + err = confClient.Init(confParams) + assert.Nil(t, err) + + var ra haproxy.IReloadAgent + + ra, err = haproxy.NewReloadAgent(haproxy.ReloadAgentParams{ + Delay: 1, + ReloadCmd: "true", + RestartCmd: "true", + ConfigFile: cfgFile, + BackupDir: tmp, + Retention: 0, + Ctx: context.Background(), + }) + assert.Nil(t, err) + + var instance *awsInstance + instance, err = newAWSRegionInstance(context.Background(), &models.AwsRegion{ + AccessKeyID: AWSAccessKeyID, + Allowlist: []*models.AwsFilters{ + { + Key: aws.String("tag-key"), + Value: aws.String(additionalTag), + }, + }, + Denylist: []*models.AwsFilters{}, + Description: "just an integration test on AWS", + Enabled: aws.Bool(true), + IPV4Address: aws.String(models.AwsRegionIPV4AddressPrivate), + ID: aws.String(uuid.New().String()), + Name: aws.String("integration-test"), + Region: aws.String(region), + RetryTimeout: aws.Int64(1), + SecretAccessKey: AWSSecretAccessKey, + ServerSlotsBase: aws.Int64(10), + ServerSlotsGrowthIncrement: 10, + ServerSlotsGrowthType: aws.String("linear"), + }, confClient, ra) + assert.Nil(t, err) + + var cfg aws.Config + cfg, err = config.LoadDefaultConfig( + context.Background(), + config.WithRegion(*instance.params.Region), + config.WithCredentialsProvider(credentials.StaticCredentialsProvider{ + Value: aws.Credentials{ + AccessKeyID: instance.params.AccessKeyID, + SecretAccessKey: instance.params.SecretAccessKey, + }, + }), + ) + assert.Nil(t, err) + + asg := autoscaling.NewFromConfig(cfg) + + err = createLaunchConfiguration(instance.params.ID, asg) + + assert.Nil(t, err) + t.Cleanup(func() { + _, _ = asg.DeleteLaunchConfiguration(context.Background(), &autoscaling.DeleteLaunchConfigurationInput{ + LaunchConfigurationName: instance.params.ID, + }) + }) + + err = createAutoScalingGroup(instance.params.ID, asg) + assert.Nil(t, err) + t.Cleanup(func() { + _, _ = asg.DeleteAutoScalingGroup(context.Background(), &autoscaling.DeleteAutoScalingGroupInput{ + AutoScalingGroupName: aws.String(*instance.params.ID), + ForceDelete: aws.Bool(true), + }) + }) + + instance.start() + t.Cleanup(func() { + instance.stop() + }) + + run := func(t *testing.T, dc int32) { + err = scaleAutoScalingGroup(instance.params.ID, dc, asg) + assert.Nil(t, err) + + err = checkAutoScalingGroupCapacity(instance.params.ID, dc, asg) + assert.Nil(t, err) + + backendName := fmt.Sprintf("aws-%s-%s-%s-%d", region, *instance.params.Name, serviceName, servicePort) + ec2Client, _ := instance.setAPIClient() + assert.Eventually(t, func() bool { + return checkBackendServers(instance.params.ID, backendName, asg, ec2Client, confClient) + }, 2*time.Minute, time.Second) + } + + for _, dc := range []int32{1, 5, 10} { + t.Run(fmt.Sprintf("scaling capacity out of %d servers", dc), func(t *testing.T) { + run(t, dc) + }) + } + for _, dc := range []int32{5, 1, 0} { + t.Run(fmt.Sprintf("scaling capacity in of %d servers", dc), func(t *testing.T) { + run(t, dc) + }) + } +} + +func createLaunchConfiguration(name *string, client *autoscaling.Client) (err error) { + _, err = client.CreateLaunchConfiguration(context.Background(), &autoscaling.CreateLaunchConfigurationInput{ + LaunchConfigurationName: name, + AssociatePublicIpAddress: aws.Bool(false), + ImageId: aws.String(ami), + InstanceType: aws.String("t2.micro"), + }) + return err +} + +func createAutoScalingGroup(instanceId *string, client *autoscaling.Client) (err error) { + _, err = client.CreateAutoScalingGroup(context.Background(), &autoscaling.CreateAutoScalingGroupInput{ + AutoScalingGroupName: instanceId, + MaxSize: aws.Int32(10), + MinSize: aws.Int32(0), + DesiredCapacity: aws.Int32(0), + AvailabilityZones: []string{region + "a"}, + LaunchConfigurationName: instanceId, + Tags: []types.Tag{ + { + PropagateAtLaunch: aws.Bool(true), + Key: aws.String(HAProxyServiceNameTag), + Value: aws.String(serviceName), + }, + { + PropagateAtLaunch: aws.Bool(true), + Key: aws.String(HAProxyServicePortTag), + Value: aws.String(fmt.Sprintf("%d", servicePort)), + }, + { + PropagateAtLaunch: aws.Bool(true), + Key: aws.String(additionalTag), + Value: aws.String("true"), + }, + }, + }) + return err +} + +func checkBackendServers(asgName *string, backendName string, asg *autoscaling.Client, ec2Client *ec2.Client, confClient *configuration.Client) (ok bool) { + var out *autoscaling.DescribeAutoScalingGroupsOutput + var err error + out, err = asg.DescribeAutoScalingGroups(context.Background(), &autoscaling.DescribeAutoScalingGroupsInput{ + AutoScalingGroupNames: []string{*asgName}, + }) + if err != nil { + return false + } + + _, _, err = confClient.GetBackend(backendName, "") + if err != nil { + return false + } + + var servers models.Servers + _, servers, err = confClient.GetServers(backendName, "") + if err != nil { + return false + } + + instanceIDs := make([]string, len(out.AutoScalingGroups[0].Instances)) + for k, i := range out.AutoScalingGroups[0].Instances { + instanceIDs[k] = aws.ToString(i.InstanceId) + } + + set := make(map[string]string) + + if len(instanceIDs) > 0 { + instances, _ := ec2Client.DescribeInstances(context.Background(), &ec2.DescribeInstancesInput{ + InstanceIds: instanceIDs, + }) + for _, r := range instances.Reservations { + for _, i := range r.Instances { + id := aws.ToString(i.PrivateIpAddress) + set[id] = aws.ToString(i.InstanceId) + } + } + } + + var counter int + for ip := range set { + for _, server := range servers { + if ip == server.Address { + counter++ + } + } + } + + return counter == len(set) +} + +func scaleAutoScalingGroup(asgName *string, desiredCapacity int32, asg *autoscaling.Client) (err error) { + _, err = asg.SetDesiredCapacity(context.Background(), &autoscaling.SetDesiredCapacityInput{ + AutoScalingGroupName: asgName, + DesiredCapacity: aws.Int32(desiredCapacity), + }) + return err +} + +func checkAutoScalingGroupCapacity(asgName *string, desiredCapacity int32, asg *autoscaling.Client) (err error) { + var out *autoscaling.DescribeAutoScalingGroupsOutput + ctx, c := context.WithTimeout(context.Background(), 2*time.Minute) + defer c() + for { + select { + case <-ctx.Done(): + return fmt.Errorf("the desired capacity is not matched") + case <-time.After(time.Second): + out, err = asg.DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{ + AutoScalingGroupNames: []string{*asgName}, + }) + if err != nil { + continue + } + if len(out.AutoScalingGroups[0].Instances) != int(desiredCapacity) { + continue + } + return err + } + } +} diff --git a/discovery/store.go b/discovery/store.go new file mode 100644 index 00000000..db96c767 --- /dev/null +++ b/discovery/store.go @@ -0,0 +1,109 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "errors" + "fmt" + "sync" +) + +type Store interface { + Create(name string, service any) error + Read(name string) (any, error) + Update(name string, mutateFn func(obj any) error) (err error) + Delete(name string) error + List() []any +} + +type instanceStore struct { + store map[string]any + mu sync.RWMutex +} + +func (s *instanceStore) Update(name string, mutateFn func(obj any) error) (err error) { + s.mu.Lock() + defer s.mu.Unlock() + + var o any + if o, err = s.get(name); err != nil { + return fmt.Errorf("cannot update resource: %w", err) + } + + if err = mutateFn(o); err != nil { + return fmt.Errorf("cannot update resource: %w", err) + } + + s.store[name] = o + return err +} + +func (s *instanceStore) List() (list []any) { + s.mu.RLock() + defer s.mu.RUnlock() + + for _, i := range s.store { + list = append(list, i) + } + return list +} + +func NewInstanceStore() Store { + return &instanceStore{ + store: map[string]any{}, + mu: sync.RWMutex{}, + } +} + +func (s *instanceStore) Create(name string, service any) error { + s.mu.Lock() + defer s.mu.Unlock() + + if _, err := s.get(name); err == nil { + return errors.New("instance already exists") + } + + s.store[name] = service + return nil +} + +func (s *instanceStore) Delete(name string) (err error) { + s.mu.Lock() + defer s.mu.Unlock() + + if _, err = s.get(name); err != nil { + return err + } + + delete(s.store, name) + return nil +} + +func (s *instanceStore) Read(name string) (sd any, err error) { + s.mu.RLock() + defer s.mu.RUnlock() + + return s.get(name) +} + +func (s *instanceStore) get(name string) (sd any, err error) { + var ok bool + sd, ok = s.store[name] + if !ok { + return nil, errors.New("instance not found") + } + return sd, err +} diff --git a/discovery/utils.go b/discovery/utils.go new file mode 100644 index 00000000..40dcacec --- /dev/null +++ b/discovery/utils.go @@ -0,0 +1,84 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +import ( + "errors" + + "github.com/go-openapi/strfmt" + "github.com/google/uuid" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/misc" +) + +const ( + minimumServerSlotsBase = 10 +) + +func ValidateAWSData(data *models.AwsRegion, useValidation bool) error { + if useValidation { + validationErr := data.Validate(strfmt.Default) + if validationErr != nil { + return validationErr + } + } + if data.ID == nil || *data.ID == "" { + return errors.New("missing ID") + } + if _, err := uuid.Parse(*data.ID); err != nil { + return err + } + if data.ServerSlotsBase == nil || *data.ServerSlotsBase < minimumServerSlotsBase { + data.ServerSlotsBase = misc.Int64P(10) + } + if data.ServerSlotsGrowthType == nil { + data.ServerSlotsGrowthType = misc.StringP(models.AwsRegionServerSlotsGrowthTypeExponential) + } + if *data.ServerSlotsGrowthType == models.AwsRegionServerSlotsGrowthTypeLinear && (data.ServerSlotsGrowthIncrement == 0 || data.ServerSlotsGrowthIncrement < minimumServerSlotsBase) { + data.ServerSlotsGrowthIncrement = minimumServerSlotsBase + } + return nil +} + +func ValidateConsulData(data *models.Consul, useValidation bool) error { + if useValidation { + validationErr := data.Validate(strfmt.Default) + if validationErr != nil { + return validationErr + } + } + if data.ID == nil || *data.ID == "" { + return errors.New("missing ID") + } + if _, err := uuid.Parse(*data.ID); err != nil { + return err + } + if data.ServerSlotsBase == nil || *data.ServerSlotsBase < minimumServerSlotsBase { + data.ServerSlotsBase = misc.Int64P(minimumServerSlotsBase) + } + if data.ServerSlotsGrowthType == nil { + data.ServerSlotsGrowthType = misc.StringP(models.ConsulServerSlotsGrowthTypeLinear) + } + if *data.ServerSlotsGrowthType == models.ConsulServerSlotsGrowthTypeLinear && (data.ServerSlotsGrowthIncrement == 0 || data.ServerSlotsGrowthIncrement < minimumServerSlotsBase) { + data.ServerSlotsGrowthIncrement = minimumServerSlotsBase + } + return nil +} + +func NewServiceDiscoveryUUID() *string { + id := uuid.New().String() + return &id +} diff --git a/doc.go b/doc.go index 3f9fb53a..f3ba061d 100644 --- a/doc.go +++ b/doc.go @@ -1,5 +1,4 @@ // Code generated by go-swagger; DO NOT EDIT. - // Copyright 2019 HAProxy Technologies // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,28 +14,28 @@ // limitations under the License. // -/* -Package dataplaneapi HAProxy Data Plane API -API for editing and managing haproxy instances. Provides process information, configuration management, -haproxy stats and logs. - - - - Schemes: - http - Host: localhost - BasePath: /v2 - Version: 2.0 - Contact: HAProxy Support https://my.haproxy.com/portal/cust/login - - Consumes: - - application/json - - text/plain - - Produces: - - application/json - - text/plain - -swagger:meta -*/ +// Package dataplaneapi HAProxy Data Plane API +// +// API for editing and managing haproxy instances. Provides process information, configuration management, +// haproxy stats and logs. +// +// Schemes: +// http +// https +// Host: localhost +// BasePath: /v3 +// Version: 3.3 +// Contact: HAProxy Support https://my.haproxy.com/portal/cust/login +// +// Consumes: +// - application/json +// - multipart/form-data +// - text/plain +// +// Produces: +// - application/octet-stream +// - application/json +// - text/plain +// +// swagger:meta package dataplaneapi diff --git a/e2e/README.md b/e2e/README.md new file mode 100644 index 00000000..7a13c4d0 --- /dev/null +++ b/e2e/README.md @@ -0,0 +1,140 @@ +# Dataplane API E2E test suite + +## Requirements + +- [Docker](https://www.docker.com/) +- [BATS](https://github.com/sstephenson/bats) +- [cURL](https://github.com/curl/curl) +- [jq](https://github.com/stedolan/jq) + +## Run the test suite + +You can use the recipe `e2e` available in the root `Makefile`: +this will compile the latest build according to local changes, injecting +the compiled binary into a HAProxy container instance. + +```bash +$ make e2e +# mkdir -p /path/to/haproxytech/dataplaneapi/build +# CGO_ENABLED=0 go build -ldflags REDACTED +# ./e2e/run.bash +# >>> Provisioning the e2e environment +# >>> Starting test suite +# 1..81 +# REDACTED +# >>> Stopping dataplaneapi-e2e docker container +``` + +In any case, at the end of execution, a clean-up will occur, removing the +Docker container. + +### Run specific tests +When adding new tests, you may not want to run all tests at once. +To run tests in specific directory, you can use the following command: +```bash +TESTNAME="dir_name" make e2e +``` +### Run only one test in specific dir +To run only one test by its description: +```bash +TESTNAME="dir_name" TESTDESCRIPTION="Test description" make e2e +``` + +Alternatively, you can run it by its BATS number ($BATS_TEST_NUMBER is used): +```bash +TESTNAME="dir_name" TESTNUMBER=2 make e2e +``` + +Prerequisite to run test like this is to use BATS convenient `setup` function +in tests and invoke `run_only` function inside of that function + +### Parameters + +#### Host port + +The E2E container will map the host port `8042`: in case it's already +allocated, you can prepend the environment variable `E2E_PORT` to specify a +different one. + +```bash +$ E2E_PORT=8081 make e2e +``` + +#### HAProxy version + +By default, test suite is running against HAProxy 2.7 release: this can be +configured using the environment variable `HAPROXY_VERSION`. + +```bash +$ HAPROXY_VERSION=2.2 make e2e +``` + +#### Base Docker image + +The suite is running on `haproxytech/haproxy-alpine` Docker image: this +can be overridden using the environment variable `DOCKER_BASE_IMAGE`. + +```bash +$ DOCKER_BASE_IMAGE=registry.tld/repository/image make e2e +``` + +## Debug a failed test + +You can redirect output as any bash script using the redirection `&> 3`. + +## Writing test cases + +We require grouping tests per feature or API group, documenting the expected +behavior and result as normal code would. + +Each test should be self-contained and without any external dependency or +pre-condition: if you need this, use the `setup` and `teardown` functions. + +```bash +#!/usr/bin/env bats + +setup() { + # executed before each test + echo "setup" >&3 +} + +teardown() { + # executed after each test + echo "teardown" >&3 +} + +@test "test_name" { + [ true = true] +} +``` + +If you need some assets as a request payload, put these fixtures in the same +test folder in order to load it locally: try to avoid inline declaration. +`/path/to/post/endpoint` is without base path (currently `/v2`) + +```bash +@test "Add a new TCP Request Rule to backend" { + read -r SC _ < <(dataplaneapi POST "/path/to/post/endpoint" payload.json) + [ "${SC}" = 201 ] +} +``` + +## Libraries + +Some utilities have been developed to make test expectation and execution +smoother. + +- [`dataplaneapi`](./libs/dataplaneapi.bash) +- [`auth_curl`](./libs/auth_curl.bash#) +- [`get_json_path`](./libs/get_json_path.bash) +- [`version`](./libs/version.bash) +- [`haproxy_config_setup`](./libs/haproxy_config_setup.bash) + +Each library can be loaded using the relative path according to test file +location, as following: + +```bash +`load '../../libs/${LIB_NAME}' +``` + +> The placeholder `${LIB_NAME}` doesn't need to contain the file extension. diff --git a/e2e/fixtures/dataplaneapi-master-socket.yaml b/e2e/fixtures/dataplaneapi-master-socket.yaml new file mode 100644 index 00000000..522b9347 --- /dev/null +++ b/e2e/fixtures/dataplaneapi-master-socket.yaml @@ -0,0 +1,24 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + master_runtime: /var/lib/haproxy/master + master_worker_mode: true + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug diff --git a/e2e/fixtures/dataplaneapi.yaml b/e2e/fixtures/dataplaneapi.yaml new file mode 100644 index 00000000..92b57a25 --- /dev/null +++ b/e2e/fixtures/dataplaneapi.yaml @@ -0,0 +1,22 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug diff --git a/e2e/fixtures/haproxy.cfg b/e2e/fixtures/haproxy.cfg new file mode 100755 index 00000000..fa739868 --- /dev/null +++ b/e2e/fixtures/haproxy.cfg @@ -0,0 +1,28 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 diff --git a/e2e/fixtures/pebble/README.md b/e2e/fixtures/pebble/README.md new file mode 100644 index 00000000..7cde76f5 --- /dev/null +++ b/e2e/fixtures/pebble/README.md @@ -0,0 +1,25 @@ +# certs/ + +This directory contains a CA certificate (`pebble.minica.pem`) and a private key +(`pebble.minica.key.pem`) that are used to issue a end-entity certificate (See +`certs/localhost`) for the Pebble HTTPS server. + +To get your **testing code** to use Pebble without HTTPS errors you should +configure your ACME client to trust the `pebble.minica.pem` CA certificate. Your +ACME client should offer a runtime option to specify a list of root CAs that you +can configure to include the `pebble.minica.pem` file. + +**Do not** add this CA certificate to the system trust store or in production +code!!! The CA's private key is **public** and anyone can use it to issue +certificates that will be trusted by a system with the Pebble CA in the trust +store. + +To re-create all of the Pebble certificates run: + + minica -ca-cert pebble.minica.pem \ + -ca-key pebble.minica.key.pem \ + -domains localhost,pebble \ + -ip-addresses 127.0.0.1 + +From the `test/certs/` directory after [installing +MiniCA](https://github.com/jsha/minica#installation) diff --git a/e2e/fixtures/pebble/localhost/README.md b/e2e/fixtures/pebble/localhost/README.md new file mode 100644 index 00000000..efa49ae2 --- /dev/null +++ b/e2e/fixtures/pebble/localhost/README.md @@ -0,0 +1,5 @@ +# certs/localhost + +This directory contains an end-entity (leaf) certificate (`cert.pem`) and +a private key (`key.pem`) for the Pebble HTTPS server. It includes `127.0.0.1` +as an IP address SAN, and `[localhost, pebble]` as DNS SANs. diff --git a/e2e/fixtures/pebble/localhost/cert.pem b/e2e/fixtures/pebble/localhost/cert.pem new file mode 100644 index 00000000..2866a2b4 --- /dev/null +++ b/e2e/fixtures/pebble/localhost/cert.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDGzCCAgOgAwIBAgIIbEfayDFsBtwwDQYJKoZIhvcNAQELBQAwIDEeMBwGA1UE +AxMVbWluaWNhIHJvb3QgY2EgMjRlMmRiMCAXDTE3MTIwNjE5NDIxMFoYDzIxMDcx +MjA2MTk0MjEwWjAUMRIwEAYDVQQDEwlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCbFMW3DXXdErvQf2lCZ0qz0DGEWadDoF0O2neM5mVa +VQ7QGW0xc5Qwvn3Tl62C0JtwLpF0pG2BICIN+DHdVaIUwkf77iBS2doH1I3waE1I +8GkV9JrYmFY+j0dA1SwBmqUZNXhLNwZGq1a91nFSI59DZNy/JciqxoPX2K++ojU2 +FPpuXe2t51NmXMsszpa+TDqF/IeskA9A/ws6UIh4Mzhghx7oay2/qqj2IIPjAmJj +i73kdUvtEry3wmlkBvtVH50+FscS9WmPC5h3lDTk5nbzSAXKuFusotuqy3XTgY5B +PiRAwkZbEY43JNfqenQPHo7mNTt29i+NVVrBsnAa5ovrAgMBAAGjYzBhMA4GA1Ud +DwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0T +AQH/BAIwADAiBgNVHREEGzAZgglsb2NhbGhvc3SCBnBlYmJsZYcEfwAAATANBgkq +hkiG9w0BAQsFAAOCAQEAYIkXff8H28KS0KyLHtbbSOGU4sujHHVwiVXSATACsNAE +D0Qa8hdtTQ6AUqA6/n8/u1tk0O4rPE/cTpsM3IJFX9S3rZMRsguBP7BSr1Lq/XAB +7JP/CNHt+Z9aKCKcg11wIX9/B9F7pyKM3TdKgOpqXGV6TMuLjg5PlYWI/07lVGFW +/mSJDRs8bSCFmbRtEqc4lpwlrpz+kTTnX6G7JDLfLWYw/xXVqwFfdengcDTHCc8K +wtgGq/Gu6vcoBxIO3jaca+OIkMfxxXmGrcNdseuUCa3RMZ8Qy03DqGu6Y6XQyK4B +W8zIG6H9SVKkAznM2yfYhW8v2ktcaZ95/OBHY97ZIw== +-----END CERTIFICATE----- diff --git a/e2e/fixtures/pebble/localhost/key.pem b/e2e/fixtures/pebble/localhost/key.pem new file mode 100644 index 00000000..66be6daa --- /dev/null +++ b/e2e/fixtures/pebble/localhost/key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAmxTFtw113RK70H9pQmdKs9AxhFmnQ6BdDtp3jOZlWlUO0Blt +MXOUML5905etgtCbcC6RdKRtgSAiDfgx3VWiFMJH++4gUtnaB9SN8GhNSPBpFfSa +2JhWPo9HQNUsAZqlGTV4SzcGRqtWvdZxUiOfQ2TcvyXIqsaD19ivvqI1NhT6bl3t +redTZlzLLM6Wvkw6hfyHrJAPQP8LOlCIeDM4YIce6Gstv6qo9iCD4wJiY4u95HVL +7RK8t8JpZAb7VR+dPhbHEvVpjwuYd5Q05OZ280gFyrhbrKLbqst104GOQT4kQMJG +WxGONyTX6np0Dx6O5jU7dvYvjVVawbJwGuaL6wIDAQABAoIBAGW9W/S6lO+DIcoo +PHL+9sg+tq2gb5ZzN3nOI45BfI6lrMEjXTqLG9ZasovFP2TJ3J/dPTnrwZdr8Et/ +357YViwORVFnKLeSCnMGpFPq6YEHj7mCrq+YSURjlRhYgbVPsi52oMOfhrOIJrEG +ZXPAwPRi0Ftqu1omQEqz8qA7JHOkjB2p0i2Xc/uOSJccCmUDMlksRYz8zFe8wHuD +XvUL2k23n2pBZ6wiez6Xjr0wUQ4ESI02x7PmYgA3aqF2Q6ECDwHhjVeQmAuypMF6 +IaTjIJkWdZCW96pPaK1t+5nTNZ+Mg7tpJ/PRE4BkJvqcfHEOOl6wAE8gSk5uVApY +ZRKGmGkCgYEAzF9iRXYo7A/UphL11bR0gqxB6qnQl54iLhqS/E6CVNcmwJ2d9pF8 +5HTfSo1/lOXT3hGV8gizN2S5RmWBrc9HBZ+dNrVo7FYeeBiHu+opbX1X/C1HC0m1 +wJNsyoXeqD1OFc1WbDpHz5iv4IOXzYdOdKiYEcTv5JkqE7jomqBLQk8CgYEAwkG/ +rnwr4ThUo/DG5oH+l0LVnHkrJY+BUSI33g3eQ3eM0MSbfJXGT7snh5puJW0oXP7Z +Gw88nK3Vnz2nTPesiwtO2OkUVgrIgWryIvKHaqrYnapZHuM+io30jbZOVaVTMR9c +X/7/d5/evwXuP7p2DIdZKQKKFgROm1XnhNqVgaUCgYBD/ogHbCR5RVsOVciMbRlG +UGEt3YmUp/vfMuAsKUKbT2mJM+dWHVlb+LZBa4pC06QFgfxNJi/aAhzSGvtmBEww +xsXbaceauZwxgJfIIUPfNZCMSdQVIVTi2Smcx6UofBz6i/Jw14MEwlvhamaa7qVf +kqflYYwelga1wRNCPopLaQKBgQCWsZqZKQqBNMm0Q9yIhN+TR+2d7QFjqeePoRPl +1qxNejhq25ojE607vNv1ff9kWUGuoqSZMUC76r6FQba/JoNbefI4otd7x/GzM9uS +8MHMJazU4okwROkHYwgLxxkNp6rZuJJYheB4VDTfyyH/ng5lubmY7rdgTQcNyZ5I +majRYQKBgAMKJ3RlII0qvAfNFZr4Y2bNIq+60Z+Qu2W5xokIHCFNly3W1XDDKGFe +CCPHSvQljinke3P9gPt2HVdXxcnku9VkTti+JygxuLkVg7E0/SWwrWfGsaMJs+84 +fK+mTZay2d3v24r9WKEKwLykngYPyZw5+BdWU0E+xx5lGUd3U4gG +-----END RSA PRIVATE KEY----- diff --git a/e2e/fixtures/pebble/pebble-config.json b/e2e/fixtures/pebble/pebble-config.json new file mode 100644 index 00000000..af79b396 --- /dev/null +++ b/e2e/fixtures/pebble/pebble-config.json @@ -0,0 +1,26 @@ +{ + "pebble": { + "listenAddress": "0.0.0.0:14000", + "managementListenAddress": "0.0.0.0:15000", + "certificate": "/mnt/localhost/cert.pem", + "privateKey": "/mnt/localhost/key.pem", + "httpPort": 1080, + "tlsPort": 1443, + "ocspResponderURL": "", + "externalAccountBindingRequired": false, + "retryAfter": { + "authz": 1, + "order": 1 + }, + "profiles": { + "default": { + "description": "The profile you know and love", + "validityPeriod": 7776000 + }, + "shortlived": { + "description": "A short-lived cert profile, without actual enforcement", + "validityPeriod": 518400 + } + } + } +} diff --git a/e2e/fixtures/pebble/pebble.minica.key.pem b/e2e/fixtures/pebble/pebble.minica.key.pem new file mode 100644 index 00000000..6a7fcd9d --- /dev/null +++ b/e2e/fixtures/pebble/pebble.minica.key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAuVoGTaFSWp3Y+N5JC8lOdL8wmWpaM73UaNzhYiqA7ZqijzVk +TTtoQvQFDcUwyXKOdWHONrv1ld3z224Us504jjlbZwI5uoquCOZ2WJbRhmXrRgzk +Fq+/MtoFmPkhtO/DLjjtocgyIirVXN8Yl2APvB5brvRfCm6kktYeecsWfW/O3ikf +gdM7tmocwQiBypiloHOjdd5e2g8cWNw+rqvILSUVNLaLpsi23cxnLqVb424wz9dZ +5dO0REg1gSxtf4N5LSb6iGuAVoFNhzIeKzQ+svDg9x8tx/DGOghJS/jDgmxSY1qo +bTsXhcmWVfat5GJ5PQgLkCSjBBrjeBlOrc4VtQIDAQABAoIBAQCAoRoou6C0ZEDU +DScyN8TrvlcS0LzClaWYFFmRT5/jxOG1cr8l3elwNXpgYQ2Hb6mvim2ajHxVQg/e +oxlYwO4jvWhSJzg63c0DPjS5LAlCNO6+0Wlk2RheSPGDhLlAoPeZ10YKdS1dis5B +Qk4Fl1O0IHlOBCcEzV4GzPOfYDI+X6/f4xY7qz1s+CgoIxjIeiG+1/WpZQpYhobY +7CfSDdYDKtksXi7iQkc5earUAHBqZ1gQTq6e5LVm9AjRzENhMctFgcPs5zOjp2ak +PluixrA8LTAfu9wQzvxDkPl0UarZVxCerw6nlAziILpQ+U6PtoPZj49VpntTc+cq +1qjzkbhBAoGBANElJmFWY2X6LgBpszeqt0ZOSbkFg2bC0wHCJrMlRzUMEn83w9e8 +Z2Fqml9eCC5qxJcyxWDVQeoAX6090m0qgP8xNmGdafcVic2cUlrqtkqhhst2OHCO +MCQEB7cdsjiidNNrOgLbQ3i1bYID8BVLf/TDhEbRgvTewDaz6XPdoSIRAoGBAOLg +RuOec5gn50SrVycx8BLFO8AXjXojpZb1Xg26V5miz1IavSfDcgae/699ppSz+UWi +jGMFr/PokY2JxDVs3PyQLu7ahMzyFHr16Agvp5g5kq056XV+uI/HhqLHOWSQ09DS +1Vrj7FOYpKRzge3/AC7ty9Vr35uMiebpm4/CLFVlAoGALnsIJZfSbWaFdLgJCXUa +WDir77/G7T6dMIXanfPJ+IMfVUCqeLa5bxAHEOzP+qjl2giBjzy18nB00warTnGk +y5I/WMBoPW5++sAkGWqSatGtKGi0sGcZUdfHcy3ZXvbT6eyprtrWCuyfUsbXQ5RM +8rPFIQwNA6jBpSak2ohF+FECgYEAn+6IKncNd6pRfnfmdSvf1+uPxkcUJZCxb2xC +xByjGhvKWE+fHkPJwt8c0SIbZuJEC5Gds0RUF/XPfV4roZm/Yo9ldl02lp7kTxXA +XtzxIP8c5d5YM8qD4l8+Csu0Kq9pkeC+JFddxkRpc8A1TIehInPhZ+6mb6mvoMb3 +MW0pAX0CgYATT74RYuIYWZvx0TK4ZXIKTw2i6HObLF63Y6UwyPXXdEVie/ToYRNH +JIxE1weVpHvnHZvVD6D3yGk39ZsCIt31VvKpatWXlWBm875MbBc6kuIGsYT+mSSj +y9TXaE89E5zfL27nZe15QLJ+Xw8Io6PMLZ/jtC5TYoEixSZ9J8v6HA== +-----END RSA PRIVATE KEY----- diff --git a/e2e/fixtures/pebble/pebble.minica.pem b/e2e/fixtures/pebble/pebble.minica.pem new file mode 100644 index 00000000..a69a4c41 --- /dev/null +++ b/e2e/fixtures/pebble/pebble.minica.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDCTCCAfGgAwIBAgIIJOLbes8sTr4wDQYJKoZIhvcNAQELBQAwIDEeMBwGA1UE +AxMVbWluaWNhIHJvb3QgY2EgMjRlMmRiMCAXDTE3MTIwNjE5NDIxMFoYDzIxMTcx +MjA2MTk0MjEwWjAgMR4wHAYDVQQDExVtaW5pY2Egcm9vdCBjYSAyNGUyZGIwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5WgZNoVJandj43kkLyU50vzCZ +alozvdRo3OFiKoDtmqKPNWRNO2hC9AUNxTDJco51Yc42u/WV3fPbbhSznTiOOVtn +Ajm6iq4I5nZYltGGZetGDOQWr78y2gWY+SG078MuOO2hyDIiKtVc3xiXYA+8Hluu +9F8KbqSS1h55yxZ9b87eKR+B0zu2ahzBCIHKmKWgc6N13l7aDxxY3D6uq8gtJRU0 +toumyLbdzGcupVvjbjDP11nl07RESDWBLG1/g3ktJvqIa4BWgU2HMh4rND6y8OD3 +Hy3H8MY6CElL+MOCbFJjWqhtOxeFyZZV9q3kYnk9CAuQJKMEGuN4GU6tzhW1AgMB +AAGjRTBDMA4GA1UdDwEB/wQEAwIChDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYB +BQUHAwIwEgYDVR0TAQH/BAgwBgEB/wIBADANBgkqhkiG9w0BAQsFAAOCAQEAF85v +d40HK1ouDAtWeO1PbnWfGEmC5Xa478s9ddOd9Clvp2McYzNlAFfM7kdcj6xeiNhF +WPIfaGAi/QdURSL/6C1KsVDqlFBlTs9zYfh2g0UXGvJtj1maeih7zxFLvet+fqll +xseM4P9EVJaQxwuK/F78YBt0tCNfivC6JNZMgxKF59h0FBpH70ytUSHXdz7FKwix +Mfn3qEb9BXSk0Q3prNV5sOV3vgjEtB4THfDxSz9z3+DepVnW3vbbqwEbkXdk3j82 +2muVldgOUgTwK8eT+XdofVdntzU/kzygSAtAQwLJfn51fS1GvEcYGBc1bDryIqmF +p9BI7gVKtWSZYegicA== +-----END CERTIFICATE----- diff --git a/e2e/fixtures/userlist.cfg b/e2e/fixtures/userlist.cfg new file mode 100644 index 00000000..2373ac9d --- /dev/null +++ b/e2e/fixtures/userlist.cfg @@ -0,0 +1,2 @@ +userlist controller + user dataplaneapi insecure-password mypassword diff --git a/e2e/libs/acme.bash b/e2e/libs/acme.bash new file mode 100644 index 00000000..c81499d7 --- /dev/null +++ b/e2e/libs/acme.bash @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This module will launch 2 extra containers needed for ACME tests: +# - pebble - the "official" ACME test server from LetsEncrypt +# - challserv - pebble's companion used to fake DNS challenges +# +# Those containers can be accessed via their respective variables: +# - ACME_DIR_CONTAINER_NAME=pebble +# - ACME_DNS_CONTAINER_NAME=challtestsrv + +load '../../libs/haproxy_version' + +# ACME is available starting with HAProxy 3.2, +# but became compatible with pebble in version 3.3. +ACME=false +if haproxy_version_ge 3.3; then + ACME=true + ACME_DIR_CONTAINER_NAME=pebble + ACME_DNS_CONTAINER_NAME=challtestsrv + PEBBLE_IMAGE="ghcr.io/letsencrypt/pebble:latest" + CHALLTESTSRV_IMAGE="ghcr.io/letsencrypt/pebble-challtestsrv:latest" +fi + +setup_file() { + $ACME || return 0 + + echo '>>> Setting up ACME challtestsrv' >&3 + # Start challtestsrv -- https://github.com/letsencrypt/pebble/blob/main/cmd/pebble-challtestsrv/README.md + docker pull "$CHALLTESTSRV_IMAGE" >/dev/null + docker run -d --name "$ACME_DNS_CONTAINER_NAME" --net "$DOCKER_NETWORK" \ + -p 5001:5001 -p 5002:5002 -p 5003:5003 -p 8053:8053 -p 8055:8055 \ + "$CHALLTESTSRV_IMAGE" + + echo '>>> Setting up ACME directory: pebble' >&3 + docker pull "$PEBBLE_IMAGE" >/dev/null + docker run -d --name "$ACME_DIR_CONTAINER_NAME" --net "$DOCKER_NETWORK" \ + -p 14000:14000 -p 15000:15000 -v "${E2E_DIR}/fixtures/pebble:/mnt:ro" \ + -e PEBBLE_VA_NOSLEEP=1 -e PEBBLE_VA_ALWAYS_VALID=1 -e PEBBLE_WFE_NONCEREJECT=0 \ + "$PEBBLE_IMAGE" -config /mnt/pebble-config.json -strict -dnsserver $ACME_DNS_CONTAINER_NAME:8053 + sleep 1 + + # Allow HAProxy's HTTPS client to connect to Pebble (the fake ACME server) + docker cp "${E2E_DIR}/fixtures/pebble/pebble.minica.pem" ${DOCKER_CONTAINER_NAME}:/var/lib/haproxy/pebble.minica.pem +} + +teardown_file() { + $ACME || return 0 + + for c in "$ACME_DIR_CONTAINER_NAME" "$ACME_DNS_CONTAINER_NAME"; do + echo ">>> Shutting down ACME container $c" >&3 + mkdir -p "$E2E_DIR/logs" + docker logs "$c" &> "$E2E_DIR/logs/$c.log" + docker stop "$c" + docker rm -f "$c" + done +} diff --git a/e2e/libs/bats-assert/.gitignore b/e2e/libs/bats-assert/.gitignore new file mode 100644 index 00000000..418531e5 --- /dev/null +++ b/e2e/libs/bats-assert/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/package-lock.json +/yarn.lock +/bats-assert-*.tgz diff --git a/e2e/libs/bats-assert/.travis.yml b/e2e/libs/bats-assert/.travis.yml new file mode 100644 index 00000000..965fe2d3 --- /dev/null +++ b/e2e/libs/bats-assert/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: node +cache: npm diff --git a/e2e/libs/bats-assert/LICENSE b/e2e/libs/bats-assert/LICENSE new file mode 100644 index 00000000..670154e3 --- /dev/null +++ b/e2e/libs/bats-assert/LICENSE @@ -0,0 +1,116 @@ +CC0 1.0 Universal + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator and +subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for the +purpose of contributing to a commons of creative, cultural and scientific +works ("Commons") that the public can reliably and without fear of later +claims of infringement build upon, modify, incorporate in other works, reuse +and redistribute as freely as possible in any form whatsoever and for any +purposes, including without limitation commercial purposes. These owners may +contribute to the Commons to promote the ideal of a free culture and the +further production of creative, cultural and scientific works, or to gain +reputation or greater distribution for their Work in part through the use and +efforts of others. + +For these and/or other purposes and motivations, and without any expectation +of additional consideration or compensation, the person associating CC0 with a +Work (the "Affirmer"), to the extent that he or she is an owner of Copyright +and Related Rights in the Work, voluntarily elects to apply CC0 to the Work +and publicly distribute the Work under its terms, with knowledge of his or her +Copyright and Related Rights in the Work and the meaning and intended legal +effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not limited +to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, communicate, + and translate a Work; + + ii. moral rights retained by the original author(s) and/or performer(s); + + iii. publicity and privacy rights pertaining to a person's image or likeness + depicted in a Work; + + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + + v. rights protecting the extraction, dissemination, use and reuse of data in + a Work; + + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation thereof, + including any amended or successor version of such directive); and + + vii. other similar, equivalent or corresponding rights throughout the world + based on applicable law or treaty, and any national implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, +applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and +unconditionally waives, abandons, and surrenders all of Affirmer's Copyright +and Related Rights and associated claims and causes of action, whether now +known or unknown (including existing as well as future claims and causes of +action), in the Work (i) in all territories worldwide, (ii) for the maximum +duration provided by applicable law or treaty (including future time +extensions), (iii) in any current or future medium and for any number of +copies, and (iv) for any purpose whatsoever, including without limitation +commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes +the Waiver for the benefit of each member of the public at large and to the +detriment of Affirmer's heirs and successors, fully intending that such Waiver +shall not be subject to revocation, rescission, cancellation, termination, or +any other legal or equitable action to disrupt the quiet enjoyment of the Work +by the public as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be +judged legally invalid or ineffective under applicable law, then the Waiver +shall be preserved to the maximum extent permitted taking into account +Affirmer's express Statement of Purpose. In addition, to the extent the Waiver +is so judged Affirmer hereby grants to each affected person a royalty-free, +non transferable, non sublicensable, non exclusive, irrevocable and +unconditional license to exercise Affirmer's Copyright and Related Rights in +the Work (i) in all territories worldwide, (ii) for the maximum duration +provided by applicable law or treaty (including future time extensions), (iii) +in any current or future medium and for any number of copies, and (iv) for any +purpose whatsoever, including without limitation commercial, advertising or +promotional purposes (the "License"). The License shall be deemed effective as +of the date CC0 was applied by Affirmer to the Work. Should any part of the +License for any reason be judged legally invalid or ineffective under +applicable law, such partial invalidity or ineffectiveness shall not +invalidate the remainder of the License, and in such case Affirmer hereby +affirms that he or she will not (i) exercise any of his or her remaining +Copyright and Related Rights in the Work or (ii) assert any associated claims +and causes of action with respect to the Work, in either case contrary to +Affirmer's express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + + b. Affirmer offers the Work as-is and makes no representations or warranties + of any kind concerning the Work, express, implied, statutory or otherwise, + including without limitation warranties of title, merchantability, fitness + for a particular purpose, non infringement, or the absence of latent or + other defects, accuracy, or the present or absence of errors, whether or not + discoverable, all to the greatest extent permissible under applicable law. + + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without limitation + any person's Copyright and Related Rights in the Work. Further, Affirmer + disclaims responsibility for obtaining any necessary consents, permissions + or other rights required for any use of the Work. + + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to this + CC0 or use of the Work. + +For more information, please see + diff --git a/e2e/libs/bats-assert/README.md b/e2e/libs/bats-assert/README.md new file mode 100644 index 00000000..f9805376 --- /dev/null +++ b/e2e/libs/bats-assert/README.md @@ -0,0 +1,661 @@ +# bats-assert + +[![License](https://img.shields.io/npm/l/bats-assert.svg)](https://github.com/bats-core/bats-assert/blob/master/LICENSE) +[![GitHub release](https://img.shields.io/github/release/bats-core/bats-assert.svg)](https://github.com/bats-core/bats-assert/releases/latest) +[![npm release](https://img.shields.io/npm/v/bats-assert.svg)](https://www.npmjs.com/package/bats-assert) +[![Build Status](https://travis-ci.org/bats-core/bats-assert.svg?branch=master)](https://travis-ci.org/bats-core/bats-assert) + +`bats-assert` is a helper library providing common assertions for [Bats][bats]. + +Assertions are functions that perform a test and output relevant information on failure to help debugging. +They return 1 on failure and 0 otherwise. +Output, [formatted][bats-support-output] for readability, is sent to the standard error to make assertions usable outside of `@test` blocks too. + +Assertions testing exit code and output operate on the results of the most recent invocation of `run`. + +Dependencies: +- [`bats-support`][bats-support] (formerly `bats-core`) - output formatting + +See the [shared documentation][bats-docs] to learn how to install and load this library. + + +## Usage + +### `assert` + +Fail if the given expression evaluates to false. + +***Note:*** +*The expression must be a simple command. +[Compound commands][bash-comp-cmd], such as `[[`, can be used only when executed with `bash -c`.* + +```bash +@test 'assert()' { + touch '/var/log/test.log' + assert [ -e '/var/log/test.log' ] +} +``` + +On failure, the failed expression is displayed. + +``` +-- assertion failed -- +expression : [ -e /var/log/test.log ] +-- +``` + + +### `refute` + +Fail if the given expression evaluates to true. + +***Note:*** +*The expression must be a simple command. +[Compound commands][bash-comp-cmd], such as `[[`, can be used only when executed with `bash -c`.* + +```bash +@test 'refute()' { + rm -f '/var/log/test.log' + refute [ -e '/var/log/test.log' ] +} +``` + +On failure, the successful expression is displayed. + +``` +-- assertion succeeded, but it was expected to fail -- +expression : [ -e /var/log/test.log ] +-- +``` + + +### `assert_equal` + +Fail if the two parameters, actual and expected value respectively, do not equal. + +```bash +@test 'assert_equal()' { + assert_equal 'have' 'want' +} +``` + +On failure, the expected and actual values are displayed. + +``` +-- values do not equal -- +expected : want +actual : have +-- +``` + +If either value is longer than one line both are displayed in *multi-line* format. + + +### `assert_success` + +Fail if `$status` is not 0. + +```bash +@test 'assert_success() status only' { + run bash -c "echo 'Error!'; exit 1" + assert_success +} +``` + +On failure, `$status` and `$output` are displayed. + +``` +-- command failed -- +status : 1 +output : Error! +-- +``` + +If `$output` is longer than one line, it is displayed in *multi-line* format. + + +### `assert_failure` + +Fail if `$status` is 0. + +```bash +@test 'assert_failure() status only' { + run echo 'Success!' + assert_failure +} +``` + +On failure, `$output` is displayed. + +``` +-- command succeeded, but it was expected to fail -- +output : Success! +-- +``` + +If `$output` is longer than one line, it is displayed in *multi-line* format. + +#### Expected status + +When one parameter is specified, fail if `$status` does not equal the expected status specified by the parameter. + +```bash +@test 'assert_failure() with expected status' { + run bash -c "echo 'Error!'; exit 1" + assert_failure 2 +} +``` + +On failure, the expected and actual status, and `$output` are displayed. + +``` +-- command failed as expected, but status differs -- +expected : 2 +actual : 1 +output : Error! +-- +``` + +If `$output` is longer than one line, it is displayed in *multi-line* format. + + +### `assert_output` + +This function helps to verify that a command or function produces the correct output by checking that the specified expected output matches the actual output. +Matching can be literal (default), partial or regular expression. +This function is the logical complement of `refute_output`. + +#### Literal matching + +By default, literal matching is performed. +The assertion fails if `$output` does not equal the expected output. + +```bash +@test 'assert_output()' { + run echo 'have' + assert_output 'want' +} +``` + +On failure, the expected and actual output are displayed. + +``` +-- output differs -- +expected : want +actual : have +-- +``` + +If either value is longer than one line both are displayed in *multi-line* format. + +#### Existence + +To assert that any (non-empty) output exists at all, simply omit the matching argument. + +```bash +@test 'assert_output()' { + run echo 'have' + assert_output +} +``` + +On failure, an error message is displayed. + +``` +-- no output -- +expected non-empty output, but output was empty +-- +``` + +#### Partial matching + +Partial matching can be enabled with the `--partial` option (`-p` for short). +When used, the assertion fails if the expected *substring* is not found in `$output`. + +```bash +@test 'assert_output() partial matching' { + run echo 'ERROR: no such file or directory' + assert_output --partial 'SUCCESS' +} +``` + +On failure, the substring and the output are displayed. + +``` +-- output does not contain substring -- +substring : SUCCESS +output : ERROR: no such file or directory +-- +``` + +This option and regular expression matching (`--regexp` or `-e`) are mutually exclusive. +An error is displayed when used simultaneously. + +#### Regular expression matching + +Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +When used, the assertion fails if the *extended regular expression* does not match `$output`. + +*Note: The anchors `^` and `$` bind to the beginning and the end of the entire output (not individual lines), respectively.* + +```bash +@test 'assert_output() regular expression matching' { + run echo 'Foobar 0.1.0' + assert_output --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' +} +``` + +On failure, the regular expression and the output are displayed. + +``` +-- regular expression does not match output -- +regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ +output : Foobar 0.1.0 +-- +``` + +An error is displayed if the specified extended regular expression is invalid. + +This option and partial matching (`--partial` or `-p`) are mutually exclusive. +An error is displayed when used simultaneously. + +#### Standard Input, HereDocs and HereStrings + +The expected output can be specified via standard input (also heredoc/herestring) with the `-`/`--stdin` option. + +```bash +@test 'assert_output() with pipe' { + run echo 'hello' + echo 'hello' | assert_output - +} + +@test 'assert_output() with herestring' { + run echo 'hello' + assert_output - <<< hello +} +``` + + +### `refute_output` + +This function helps to verify that a command or function produces the correct output by checking that the specified unexpected output does not match the actual output. +Matching can be literal (default), partial or regular expression. +This function is the logical complement of `assert_output`. + +#### Literal matching + +By default, literal matching is performed. +The assertion fails if `$output` equals the unexpected output. + +```bash +@test 'refute_output()' { + run echo 'want' + refute_output 'want' +} +``` + +On failure, the output is displayed. + +``` +-- output equals, but it was expected to differ -- +output : want +-- +``` + +If output is longer than one line it is displayed in *multi-line* format. + +#### Existence + +To assert that there is no output at all, simply omit the matching argument. + +```bash +@test 'refute_output()' { + run foo --silent + refute_output +} +``` + +On failure, an error message is displayed. + +``` +-- unexpected output -- +expected no output, but output was non-empty +-- +``` + +#### Partial matching + +Partial matching can be enabled with the `--partial` option (`-p` for short). +When used, the assertion fails if the unexpected *substring* is found in `$output`. + +```bash +@test 'refute_output() partial matching' { + run echo 'ERROR: no such file or directory' + refute_output --partial 'ERROR' +} +``` + +On failure, the substring and the output are displayed. + +``` +-- output should not contain substring -- +substring : ERROR +output : ERROR: no such file or directory +-- +``` + +This option and regular expression matching (`--regexp` or `-e`) are mutually exclusive. +An error is displayed when used simultaneously. + +#### Regular expression matching + +Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +When used, the assertion fails if the *extended regular expression* matches `$output`. + +*Note: The anchors `^` and `$` bind to the beginning and the end of the entire output (not individual lines), respectively.* + +```bash +@test 'refute_output() regular expression matching' { + run echo 'Foobar v0.1.0' + refute_output --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' +} +``` + +On failure, the regular expression and the output are displayed. + +``` +-- regular expression should not match output -- +regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ +output : Foobar v0.1.0 +-- +``` + +An error is displayed if the specified extended regular expression is invalid. + +This option and partial matching (`--partial` or `-p`) are mutually exclusive. +An error is displayed when used simultaneously. + +#### Standard Input, HereDocs and HereStrings + +The unexpected output can be specified via standard input (also heredoc/herestring) with the `-`/`--stdin` option. + +```bash +@test 'refute_output() with pipe' { + run echo 'hello' + echo 'world' | refute_output - +} + +@test 'refute_output() with herestring' { + run echo 'hello' + refute_output - <<< world +} +``` + + +### `assert_line` + +Similarly to `assert_output`, this function helps to verify that a command or function produces the correct output. +It checks that the expected line appears in the output (default) or in a specific line of it. +Matching can be literal (default), partial or regular expression. +This function is the logical complement of `refute_line`. + +***Warning:*** +*Due to a [bug in Bats][bats-93], empty lines are discarded from `${lines[@]}`, causing line indices to change and preventing testing for empty lines.* + +[bats-93]: https://github.com/sstephenson/bats/pull/93 + +#### Looking for a line in the output + +By default, the entire output is searched for the expected line. +The assertion fails if the expected line is not found in `${lines[@]}`. + +```bash +@test 'assert_line() looking for line' { + run echo $'have-0\nhave-1\nhave-2' + assert_line 'want' +} +``` + +On failure, the expected line and the output are displayed. + +***Warning:*** +*The output displayed does not contain empty lines. +See the Warning above for more.* + +``` +-- output does not contain line -- +line : want +output (3 lines): + have-0 + have-1 + have-2 +-- +``` + +If output is not longer than one line, it is displayed in *two-column* format. + +#### Matching a specific line + +When the `--index ` option is used (`-n ` for short), the expected line is matched only against the line identified by the given index. +The assertion fails if the expected line does not equal `${lines[]}`. + +```bash +@test 'assert_line() specific line' { + run echo $'have-0\nhave-1\nhave-2' + assert_line --index 1 'want-1' +} +``` + +On failure, the index and the compared lines are displayed. + +``` +-- line differs -- +index : 1 +expected : want-1 +actual : have-1 +-- +``` + +#### Partial matching + +Partial matching can be enabled with the `--partial` option (`-p` for short). +When used, a match fails if the expected *substring* is not found in the matched line. + +```bash +@test 'assert_line() partial matching' { + run echo $'have 1\nhave 2\nhave 3' + assert_line --partial 'want' +} +``` + +On failure, the same details are displayed as for literal matching, except that the substring replaces the expected line. + +``` +-- no output line contains substring -- +substring : want +output (3 lines): + have 1 + have 2 + have 3 +-- +``` + +This option and regular expression matching (`--regexp` or `-e`) are mutually exclusive. +An error is displayed when used simultaneously. + +#### Regular expression matching + +Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +When used, a match fails if the *extended regular expression* does not match the line being tested. + +*Note: As expected, the anchors `^` and `$` bind to the beginning and the end of the matched line, respectively.* + +```bash +@test 'assert_line() regular expression matching' { + run echo $'have-0\nhave-1\nhave-2' + assert_line --index 1 --regexp '^want-[0-9]$' +} +``` + +On failure, the same details are displayed as for literal matching, except that the regular expression replaces the expected line. + +``` +-- regular expression does not match line -- +index : 1 +regexp : ^want-[0-9]$ +line : have-1 +-- +``` + +An error is displayed if the specified extended regular expression is invalid. + +This option and partial matching (`--partial` or `-p`) are mutually exclusive. +An error is displayed when used simultaneously. + + +### `refute_line` + +Similarly to `refute_output`, this function helps to verify that a command or function produces the correct output. +It checks that the unexpected line does not appear in the output (default) or in a specific line of it. +Matching can be literal (default), partial or regular expression. +This function is the logical complement of `assert_line`. + +***Warning:*** +*Due to a [bug in Bats][bats-93], empty lines are discarded from `${lines[@]}`, causing line indices to change and preventing testing for empty lines.* + +[bats-93]: https://github.com/sstephenson/bats/pull/93 + +#### Looking for a line in the output + +By default, the entire output is searched for the unexpected line. +The assertion fails if the unexpected line is found in `${lines[@]}`. + +```bash +@test 'refute_line() looking for line' { + run echo $'have-0\nwant\nhave-2' + refute_line 'want' +} +``` + +On failure, the unexpected line, the index of its first match and the output with the matching line highlighted are displayed. + +***Warning:*** +*The output displayed does not contain empty lines. +See the Warning above for more.* + +``` +-- line should not be in output -- +line : want +index : 1 +output (3 lines): + have-0 +> want + have-2 +-- +``` + +If output is not longer than one line, it is displayed in *two-column* format. + +#### Matching a specific line + +When the `--index ` option is used (`-n ` for short), the unexpected line is matched only against the line identified by the given index. +The assertion fails if the unexpected line equals `${lines[]}`. + +```bash +@test 'refute_line() specific line' { + run echo $'have-0\nwant-1\nhave-2' + refute_line --index 1 'want-1' +} +``` + +On failure, the index and the unexpected line are displayed. + +``` +-- line should differ -- +index : 1 +line : want-1 +-- +``` + +#### Partial matching + +Partial matching can be enabled with the `--partial` option (`-p` for short). +When used, a match fails if the unexpected *substring* is found in the matched line. + +```bash +@test 'refute_line() partial matching' { + run echo $'have 1\nwant 2\nhave 3' + refute_line --partial 'want' +} +``` + +On failure, in addition to the details of literal matching, the substring is also displayed. +When used with `--index ` the substring replaces the unexpected line. + +``` +-- no line should contain substring -- +substring : want +index : 1 +output (3 lines): + have 1 +> want 2 + have 3 +-- +``` + +This option and regular expression matching (`--regexp` or `-e`) are mutually exclusive. +An error is displayed when used simultaneously. + +#### Regular expression matching + +Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +When used, a match fails if the *extended regular expression* matches the line being tested. + +*Note: As expected, the anchors `^` and `$` bind to the beginning and the end of the matched line, respectively.* + +```bash +@test 'refute_line() regular expression matching' { + run echo $'Foobar v0.1.0\nRelease date: 2015-11-29' + refute_line --index 0 --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' +} +``` + +On failure, in addition to the details of literal matching, the regular expression is also displayed. +When used with `--index ` the regular expression replaces the unexpected line. + +``` +-- regular expression should not match line -- +index : 0 +regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ +line : Foobar v0.1.0 +-- +``` + +An error is displayed if the specified extended regular expression is invalid. + +This option and partial matching (`--partial` or `-p`) are mutually exclusive. +An error is displayed when used simultaneously. + + +## Options + +For functions that have options, `--` disables option parsing for the remaining arguments to allow using arguments identical to one of the allowed options. + +```bash +assert_output -- '-p' +``` + +Specifying `--` as an argument is similarly simple. + +```bash +refute_line -- '--' +``` + + + + +[bats]: https://github.com/sstephenson/bats +[bats-support-output]: https://github.com/ztombol/bats-support#output-formatting +[bats-support]: https://github.com/ztombol/bats-support +[bats-docs]: https://github.com/ztombol/bats-docs +[bash-comp-cmd]: https://www.gnu.org/software/bash/manual/bash.html#Compound-Commands diff --git a/e2e/libs/bats-assert/load.bash b/e2e/libs/bats-assert/load.bash new file mode 100644 index 00000000..38bffe03 --- /dev/null +++ b/e2e/libs/bats-assert/load.bash @@ -0,0 +1,30 @@ +# bats-assert - Common assertions for Bats +# +# Written in 2016 by Zoltan Tombol +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication +# along with this software. If not, see +# . +# +# Assertions are functions that perform a test and output relevant +# information on failure to help debugging. They return 1 on failure +# and 0 otherwise. +# +# All output is formatted for readability using the functions of +# `output.bash' and sent to the standard error. + +# shellcheck disable=1090 +source "$(dirname "${BASH_SOURCE[0]}")/src/assert.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/refute.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/assert_equal.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/assert_success.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/assert_failure.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/assert_output.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/refute_output.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/assert_line.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/refute_line.bash" diff --git a/e2e/libs/bats-assert/package.json b/e2e/libs/bats-assert/package.json new file mode 100644 index 00000000..3c9bdda0 --- /dev/null +++ b/e2e/libs/bats-assert/package.json @@ -0,0 +1,48 @@ +{ + "name": "bats-assert", + "version": "2.0.0", + "description": "Common assertions for Bats", + "homepage": "https://github.com/jasonkarns/bats-assert-1", + "license": "CC0-1.0", + "author": "Zoltán Tömböl (https://github.com/ztombol)", + "contributors": [ + "Sam Stephenson (http://sstephenson.us/)", + "Jason Karns (http://jason.karns.name)", + "Mislav Marohnić (http://mislav.net/)", + "Tim Pope (https://github.com/tpope)" + ], + "repository": "github:jasonkarns/bats-assert-1", + "bugs": "https://github.com/jasonkarns/bats-assert-1/issues", + "directories": { + "lib": "src", + "test": "test" + }, + "files": [ + "load.bash", + "src" + ], + "scripts": { + "test": "bats ${CI+-t} test", + "postversion": "npm publish", + "prepublishOnly": "npm run publish:github", + "publish:github": "git push --follow-tags" + }, + "devDependencies": { + "bats": "^1", + "bats-support": "^0.3" + }, + "peerDependencies": { + "bats": "0.4 || ^1", + "bats-support": "^0.3" + }, + "keywords": [ + "bats", + "bash", + "shell", + "test", + "unit", + "assert", + "assertion", + "helper" + ] +} diff --git a/e2e/libs/bats-assert/src/assert.bash b/e2e/libs/bats-assert/src/assert.bash new file mode 100644 index 00000000..0260ce23 --- /dev/null +++ b/e2e/libs/bats-assert/src/assert.bash @@ -0,0 +1,42 @@ +# assert +# ====== +# +# Summary: Fail if the given expression evaluates to false. +# +# Usage: assert + +# Options: +# The expression to evaluate for truthiness. +# *__Note:__ The expression must be a simple command. +# [Compound commands](https://www.gnu.org/software/bash/manual/bash.html#Compound-Commands), +# such as `[[`, can be used only when executed with `bash -c`.* +# +# IO: +# STDERR - the failed expression, on failure +# Globals: +# none +# Returns: +# 0 - if expression evaluates to true +# 1 - otherwise +# +# ```bash +# @test 'assert()' { +# touch '/var/log/test.log' +# assert [ -e '/var/log/test.log' ] +# } +# ``` +# +# On failure, the failed expression is displayed. +# +# ``` +# -- assertion failed -- +# expression : [ -e /var/log/test.log ] +# -- +# ``` +assert() { + if ! "$@"; then + batslib_print_kv_single 10 'expression' "$*" \ + | batslib_decorate 'assertion failed' \ + | fail + fi +} diff --git a/e2e/libs/bats-assert/src/assert_equal.bash b/e2e/libs/bats-assert/src/assert_equal.bash new file mode 100644 index 00000000..4ef1297e --- /dev/null +++ b/e2e/libs/bats-assert/src/assert_equal.bash @@ -0,0 +1,42 @@ +# assert_equal +# ============ +# +# Summary: Fail if the actual and expected values are not equal. +# +# Usage: assert_equal +# +# Options: +# The value being compared. +# The value to compare against. +# +# ```bash +# @test 'assert_equal()' { +# assert_equal 'have' 'want' +# } +# ``` +# +# IO: +# STDERR - expected and actual values, on failure +# Globals: +# none +# Returns: +# 0 - if values equal +# 1 - otherwise +# +# On failure, the expected and actual values are displayed. +# +# ``` +# -- values do not equal -- +# expected : want +# actual : have +# -- +# ``` +assert_equal() { + if [[ $1 != "$2" ]]; then + batslib_print_kv_single_or_multi 8 \ + 'expected' "$2" \ + 'actual' "$1" \ + | batslib_decorate 'values do not equal' \ + | fail + fi +} diff --git a/e2e/libs/bats-assert/src/assert_failure.bash b/e2e/libs/bats-assert/src/assert_failure.bash new file mode 100644 index 00000000..d9060591 --- /dev/null +++ b/e2e/libs/bats-assert/src/assert_failure.bash @@ -0,0 +1,78 @@ +# assert_failure +# ============== +# +# Summary: Fail if `$status` is 0; or is not equal to the optionally provided status. +# +# Usage: assert_failure [] +# +# Options: +# The specific status code to check against. +# If not provided, simply asserts status is != 0. +# +# IO: +# STDERR - `$output`, on failure; +# - also, `$status` and `expected_status`, if provided +# Globals: +# status +# output +# Returns: +# 0 - if `$status' is 0, +# or if expected_status is provided but does not equal `$status' +# 1 - otherwise +# +# ```bash +# @test 'assert_failure() status only' { +# run echo 'Success!' +# assert_failure +# } +# ``` +# +# On failure, `$output` is displayed. +# +# ``` +# -- command succeeded, but it was expected to fail -- +# output : Success! +# -- +# ``` +# +# ## Expected status +# +# When `expected_status` is provided, fail if `$status` does not equal the `expected_status`. +# +# ```bash +# @test 'assert_failure() with expected status' { +# run bash -c "echo 'Error!'; exit 1" +# assert_failure 2 +# } +# ``` +# +# On failure, both the expected and actual statuses, and `$output` are displayed. +# +# ``` +# -- command failed as expected, but status differs -- +# expected : 2 +# actual : 1 +# output : Error! +# -- +# ``` +assert_failure() { + : "${output?}" + : "${status?}" + + (( $# > 0 )) && local -r expected="$1" + if (( status == 0 )); then + batslib_print_kv_single_or_multi 6 'output' "$output" \ + | batslib_decorate 'command succeeded, but it was expected to fail' \ + | fail + elif (( $# > 0 )) && (( status != expected )); then + { local -ir width=8 + batslib_print_kv_single "$width" \ + 'expected' "$expected" \ + 'actual' "$status" + batslib_print_kv_single_or_multi "$width" \ + 'output' "$output" + } \ + | batslib_decorate 'command failed as expected, but status differs' \ + | fail + fi +} diff --git a/e2e/libs/bats-assert/src/assert_line.bash b/e2e/libs/bats-assert/src/assert_line.bash new file mode 100644 index 00000000..c0f68de1 --- /dev/null +++ b/e2e/libs/bats-assert/src/assert_line.bash @@ -0,0 +1,248 @@ +# assert_line +# =========== +# +# Summary: Fail if the expected line is not found in the output (default) or at a specific line number. +# +# Usage: assert_line [-n index] [-p | -e] [--] +# +# Options: +# -n, --index Match the th line +# -p, --partial Match if `expected` is a substring of `$output` or line +# -e, --regexp Treat `expected` as an extended regular expression +# The expected line string, substring, or regular expression +# +# IO: +# STDERR - details, on failure +# error message, on error +# Globals: +# output +# lines +# Returns: +# 0 - if matching line found +# 1 - otherwise +# +# Similarly to `assert_output`, this function verifies that a command or function produces the expected output. +# (It is the logical complement of `refute_line`.) +# It checks that the expected line appears in the output (default) or at a specific line number. +# Matching can be literal (default), partial or regular expression. +# +# *__Warning:__ +# Due to a [bug in Bats][bats-93], empty lines are discarded from `${lines[@]}`, +# causing line indices to change and preventing testing for empty lines.* +# +# [bats-93]: https://github.com/sstephenson/bats/pull/93 +# +# ## Looking for a line in the output +# +# By default, the entire output is searched for the expected line. +# The assertion fails if the expected line is not found in `${lines[@]}`. +# +# ```bash +# @test 'assert_line() looking for line' { +# run echo $'have-0\nhave-1\nhave-2' +# assert_line 'want' +# } +# ``` +# +# On failure, the expected line and the output are displayed. +# +# ``` +# -- output does not contain line -- +# line : want +# output (3 lines): +# have-0 +# have-1 +# have-2 +# -- +# ``` +# +# ## Matching a specific line +# +# When the `--index ` option is used (`-n ` for short), the expected line is matched only against the line identified by the given index. +# The assertion fails if the expected line does not equal `${lines[]}`. +# +# ```bash +# @test 'assert_line() specific line' { +# run echo $'have-0\nhave-1\nhave-2' +# assert_line --index 1 'want-1' +# } +# ``` +# +# On failure, the index and the compared lines are displayed. +# +# ``` +# -- line differs -- +# index : 1 +# expected : want-1 +# actual : have-1 +# -- +# ``` +# +# ## Partial matching +# +# Partial matching can be enabled with the `--partial` option (`-p` for short). +# When used, a match fails if the expected *substring* is not found in the matched line. +# +# ```bash +# @test 'assert_line() partial matching' { +# run echo $'have 1\nhave 2\nhave 3' +# assert_line --partial 'want' +# } +# ``` +# +# On failure, the same details are displayed as for literal matching, except that the substring replaces the expected line. +# +# ``` +# -- no output line contains substring -- +# substring : want +# output (3 lines): +# have 1 +# have 2 +# have 3 +# -- +# ``` +# +# ## Regular expression matching +# +# Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +# When used, a match fails if the *extended regular expression* does not match the line being tested. +# +# *__Note__: +# As expected, the anchors `^` and `$` bind to the beginning and the end (respectively) of the matched line.* +# +# ```bash +# @test 'assert_line() regular expression matching' { +# run echo $'have-0\nhave-1\nhave-2' +# assert_line --index 1 --regexp '^want-[0-9]$' +# } +# ``` +# +# On failure, the same details are displayed as for literal matching, except that the regular expression replaces the expected line. +# +# ``` +# -- regular expression does not match line -- +# index : 1 +# regexp : ^want-[0-9]$ +# line : have-1 +# -- +# ``` +# FIXME(ztombol): Display `${lines[@]}' instead of `$output'! +assert_line() { + local -i is_match_line=0 + local -i is_mode_partial=0 + local -i is_mode_regexp=0 + : "${lines?}" + + # Handle options. + while (( $# > 0 )); do + case "$1" in + -n|--index) + if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then + echo "\`--index' requires an integer argument: \`$2'" \ + | batslib_decorate 'ERROR: assert_line' \ + | fail + return $? + fi + is_match_line=1 + local -ri idx="$2" + shift 2 + ;; + -p|--partial) is_mode_partial=1; shift ;; + -e|--regexp) is_mode_regexp=1; shift ;; + --) shift; break ;; + *) break ;; + esac + done + + if (( is_mode_partial )) && (( is_mode_regexp )); then + echo "\`--partial' and \`--regexp' are mutually exclusive" \ + | batslib_decorate 'ERROR: assert_line' \ + | fail + return $? + fi + + # Arguments. + local -r expected="$1" + + if (( is_mode_regexp == 1 )) && [[ '' =~ $expected ]] || (( $? == 2 )); then + echo "Invalid extended regular expression: \`$expected'" \ + | batslib_decorate 'ERROR: assert_line' \ + | fail + return $? + fi + + # Matching. + if (( is_match_line )); then + # Specific line. + if (( is_mode_regexp )); then + if ! [[ ${lines[$idx]} =~ $expected ]]; then + batslib_print_kv_single 6 \ + 'index' "$idx" \ + 'regexp' "$expected" \ + 'line' "${lines[$idx]}" \ + | batslib_decorate 'regular expression does not match line' \ + | fail + fi + elif (( is_mode_partial )); then + if [[ ${lines[$idx]} != *"$expected"* ]]; then + batslib_print_kv_single 9 \ + 'index' "$idx" \ + 'substring' "$expected" \ + 'line' "${lines[$idx]}" \ + | batslib_decorate 'line does not contain substring' \ + | fail + fi + else + if [[ ${lines[$idx]} != "$expected" ]]; then + batslib_print_kv_single 8 \ + 'index' "$idx" \ + 'expected' "$expected" \ + 'actual' "${lines[$idx]}" \ + | batslib_decorate 'line differs' \ + | fail + fi + fi + else + # Contained in output. + if (( is_mode_regexp )); then + local -i idx + for (( idx = 0; idx < ${#lines[@]}; ++idx )); do + [[ ${lines[$idx]} =~ $expected ]] && return 0 + done + { local -ar single=( 'regexp' "$expected" ) + local -ar may_be_multi=( 'output' "$output" ) + local -ir width="$( batslib_get_max_single_line_key_width "${single[@]}" "${may_be_multi[@]}" )" + batslib_print_kv_single "$width" "${single[@]}" + batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}" + } \ + | batslib_decorate 'no output line matches regular expression' \ + | fail + elif (( is_mode_partial )); then + local -i idx + for (( idx = 0; idx < ${#lines[@]}; ++idx )); do + [[ ${lines[$idx]} == *"$expected"* ]] && return 0 + done + { local -ar single=( 'substring' "$expected" ) + local -ar may_be_multi=( 'output' "$output" ) + local -ir width="$( batslib_get_max_single_line_key_width "${single[@]}" "${may_be_multi[@]}" )" + batslib_print_kv_single "$width" "${single[@]}" + batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}" + } \ + | batslib_decorate 'no output line contains substring' \ + | fail + else + local -i idx + for (( idx = 0; idx < ${#lines[@]}; ++idx )); do + [[ ${lines[$idx]} == "$expected" ]] && return 0 + done + { local -ar single=( 'line' "$expected" ) + local -ar may_be_multi=( 'output' "$output" ) + local -ir width="$( batslib_get_max_single_line_key_width "${single[@]}" "${may_be_multi[@]}" )" + batslib_print_kv_single "$width" "${single[@]}" + batslib_print_kv_single_or_multi "$width" "${may_be_multi[@]}" + } \ + | batslib_decorate 'output does not contain line' \ + | fail + fi + fi +} diff --git a/e2e/libs/bats-assert/src/assert_output.bash b/e2e/libs/bats-assert/src/assert_output.bash new file mode 100644 index 00000000..82d0a0c2 --- /dev/null +++ b/e2e/libs/bats-assert/src/assert_output.bash @@ -0,0 +1,197 @@ +# assert_output +# ============= +# +# Summary: Fail if `$output' does not match the expected output. +# +# Usage: assert_output [-p | -e] [- | [--] ] +# +# Options: +# -p, --partial Match if `expected` is a substring of `$output` +# -e, --regexp Treat `expected` as an extended regular expression +# -, --stdin Read `expected` value from STDIN +# The expected value, substring or regular expression +# +# IO: +# STDIN - [=$1] expected output +# STDERR - details, on failure +# error message, on error +# Globals: +# output +# Returns: +# 0 - if output matches the expected value/partial/regexp +# 1 - otherwise +# +# This function verifies that a command or function produces the expected output. +# (It is the logical complement of `refute_output`.) +# Output matching can be literal (the default), partial or by regular expression. +# The expected output can be specified either by positional argument or read from STDIN by passing the `-`/`--stdin` flag. +# +# ## Literal matching +# +# By default, literal matching is performed. +# The assertion fails if `$output` does not equal the expected output. +# +# ```bash +# @test 'assert_output()' { +# run echo 'have' +# assert_output 'want' +# } +# +# @test 'assert_output() with pipe' { +# run echo 'hello' +# echo 'hello' | assert_output - +# } +# +# @test 'assert_output() with herestring' { +# run echo 'hello' +# assert_output - <<< hello +# } +# ``` +# +# On failure, the expected and actual output are displayed. +# +# ``` +# -- output differs -- +# expected : want +# actual : have +# -- +# ``` +# +# ## Existence +# +# To assert that any output exists at all, omit the `expected` argument. +# +# ```bash +# @test 'assert_output()' { +# run echo 'have' +# assert_output +# } +# ``` +# +# On failure, an error message is displayed. +# +# ``` +# -- no output -- +# expected non-empty output, but output was empty +# -- +# ``` +# +# ## Partial matching +# +# Partial matching can be enabled with the `--partial` option (`-p` for short). +# When used, the assertion fails if the expected _substring_ is not found in `$output`. +# +# ```bash +# @test 'assert_output() partial matching' { +# run echo 'ERROR: no such file or directory' +# assert_output --partial 'SUCCESS' +# } +# ``` +# +# On failure, the substring and the output are displayed. +# +# ``` +# -- output does not contain substring -- +# substring : SUCCESS +# output : ERROR: no such file or directory +# -- +# ``` +# +# ## Regular expression matching +# +# Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +# When used, the assertion fails if the *extended regular expression* does not match `$output`. +# +# *__Note__: +# The anchors `^` and `$` bind to the beginning and the end (respectively) of the entire output; +# not individual lines.* +# +# ```bash +# @test 'assert_output() regular expression matching' { +# run echo 'Foobar 0.1.0' +# assert_output --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' +# } +# ``` +# +# On failure, the regular expression and the output are displayed. +# +# ``` +# -- regular expression does not match output -- +# regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ +# output : Foobar 0.1.0 +# -- +# ``` +assert_output() { + local -i is_mode_partial=0 + local -i is_mode_regexp=0 + local -i is_mode_nonempty=0 + local -i use_stdin=0 + : "${output?}" + + # Handle options. + if (( $# == 0 )); then + is_mode_nonempty=1 + fi + + while (( $# > 0 )); do + case "$1" in + -p|--partial) is_mode_partial=1; shift ;; + -e|--regexp) is_mode_regexp=1; shift ;; + -|--stdin) use_stdin=1; shift ;; + --) shift; break ;; + *) break ;; + esac + done + + if (( is_mode_partial )) && (( is_mode_regexp )); then + echo "\`--partial' and \`--regexp' are mutually exclusive" \ + | batslib_decorate 'ERROR: assert_output' \ + | fail + return $? + fi + + # Arguments. + local expected + if (( use_stdin )); then + expected="$(cat -)" + else + expected="${1-}" + fi + + # Matching. + if (( is_mode_nonempty )); then + if [ -z "$output" ]; then + echo 'expected non-empty output, but output was empty' \ + | batslib_decorate 'no output' \ + | fail + fi + elif (( is_mode_regexp )); then + if [[ '' =~ $expected ]] || (( $? == 2 )); then + echo "Invalid extended regular expression: \`$expected'" \ + | batslib_decorate 'ERROR: assert_output' \ + | fail + elif ! [[ $output =~ $expected ]]; then + batslib_print_kv_single_or_multi 6 \ + 'regexp' "$expected" \ + 'output' "$output" \ + | batslib_decorate 'regular expression does not match output' \ + | fail + fi + elif (( is_mode_partial )); then + if [[ $output != *"$expected"* ]]; then + batslib_print_kv_single_or_multi 9 \ + 'substring' "$expected" \ + 'output' "$output" \ + | batslib_decorate 'output does not contain substring' \ + | fail + fi + else + if [[ $output != "$expected" ]]; then + batslib_print_kv_single_or_multi 8 \ + 'expected' "$expected" \ + 'actual' "$output" \ + | batslib_decorate 'output differs' \ + | fail + fi + fi +} diff --git a/e2e/libs/bats-assert/src/assert_success.bash b/e2e/libs/bats-assert/src/assert_success.bash new file mode 100644 index 00000000..a8b2a38a --- /dev/null +++ b/e2e/libs/bats-assert/src/assert_success.bash @@ -0,0 +1,44 @@ +# assert_success +# ============== +# +# Summary: Fail if `$status` is not 0. +# +# Usage: assert_success +# +# IO: +# STDERR - `$status` and `$output`, on failure +# Globals: +# status +# output +# Returns: +# 0 - if `$status' is 0 +# 1 - otherwise +# +# ```bash +# @test 'assert_success() status only' { +# run bash -c "echo 'Error!'; exit 1" +# assert_success +# } +# ``` +# +# On failure, `$status` and `$output` are displayed. +# +# ``` +# -- command failed -- +# status : 1 +# output : Error! +# -- +# ``` +assert_success() { + : "${output?}" + : "${status?}" + + if (( status != 0 )); then + { local -ir width=6 + batslib_print_kv_single "$width" 'status' "$status" + batslib_print_kv_single_or_multi "$width" 'output' "$output" + } \ + | batslib_decorate 'command failed' \ + | fail + fi +} diff --git a/e2e/libs/bats-assert/src/refute.bash b/e2e/libs/bats-assert/src/refute.bash new file mode 100644 index 00000000..e7c47da8 --- /dev/null +++ b/e2e/libs/bats-assert/src/refute.bash @@ -0,0 +1,42 @@ +# refute +# ====== +# +# Summary: Fail if the given expression evaluates to true. +# +# Usage: refute +# +# Options: +# The expression to evaluate for falsiness. +# *__Note:__ The expression must be a simple command. +# [Compound commands](https://www.gnu.org/software/bash/manual/bash.html#Compound-Commands), +# such as `[[`, can be used only when executed with `bash -c`.* +# +# IO: +# STDERR - the successful expression, on failure +# Globals: +# none +# Returns: +# 0 - if expression evaluates to false +# 1 - otherwise +# +# ```bash +# @test 'refute()' { +# rm -f '/var/log/test.log' +# refute [ -e '/var/log/test.log' ] +# } +# ``` +# +# On failure, the successful expression is displayed. +# +# ``` +# -- assertion succeeded, but it was expected to fail -- +# expression : [ -e /var/log/test.log ] +# -- +# ``` +refute() { + if "$@"; then + batslib_print_kv_single 10 'expression' "$*" \ + | batslib_decorate 'assertion succeeded, but it was expected to fail' \ + | fail + fi +} diff --git a/e2e/libs/bats-assert/src/refute_line.bash b/e2e/libs/bats-assert/src/refute_line.bash new file mode 100644 index 00000000..c9aa47fe --- /dev/null +++ b/e2e/libs/bats-assert/src/refute_line.bash @@ -0,0 +1,271 @@ +# refute_line +# =========== +# +# Summary: Fail if the unexpected line is found in the output (default) or at a specific line number. +# +# Usage: refute_line [-n index] [-p | -e] [--] +# +# Options: +# -n, --index Match the th line +# -p, --partial Match if `unexpected` is a substring of `$output` or line +# -e, --regexp Treat `unexpected` as an extended regular expression +# The unexpected line string, substring, or regular expression. +# +# IO: +# STDERR - details, on failure +# error message, on error +# Globals: +# output +# lines +# Returns: +# 0 - if match not found +# 1 - otherwise +# +# Similarly to `refute_output`, this function verifies that a command or function does not produce the unexpected output. +# (It is the logical complement of `assert_line`.) +# It checks that the unexpected line does not appear in the output (default) or at a specific line number. +# Matching can be literal (default), partial or regular expression. +# +# *__Warning:__ +# Due to a [bug in Bats][bats-93], empty lines are discarded from `${lines[@]}`, +# causing line indices to change and preventing testing for empty lines.* +# +# [bats-93]: https://github.com/sstephenson/bats/pull/93 +# +# ## Looking for a line in the output +# +# By default, the entire output is searched for the unexpected line. +# The assertion fails if the unexpected line is found in `${lines[@]}`. +# +# ```bash +# @test 'refute_line() looking for line' { +# run echo $'have-0\nwant\nhave-2' +# refute_line 'want' +# } +# ``` +# +# On failure, the unexpected line, the index of its first match and the output with the matching line highlighted are displayed. +# +# ``` +# -- line should not be in output -- +# line : want +# index : 1 +# output (3 lines): +# have-0 +# > want +# have-2 +# -- +# ``` +# +# ## Matching a specific line +# +# When the `--index ` option is used (`-n ` for short), the unexpected line is matched only against the line identified by the given index. +# The assertion fails if the unexpected line equals `${lines[]}`. +# +# ```bash +# @test 'refute_line() specific line' { +# run echo $'have-0\nwant-1\nhave-2' +# refute_line --index 1 'want-1' +# } +# ``` +# +# On failure, the index and the unexpected line are displayed. +# +# ``` +# -- line should differ -- +# index : 1 +# line : want-1 +# -- +# ``` +# +# ## Partial matching +# +# Partial matching can be enabled with the `--partial` option (`-p` for short). +# When used, a match fails if the unexpected *substring* is found in the matched line. +# +# ```bash +# @test 'refute_line() partial matching' { +# run echo $'have 1\nwant 2\nhave 3' +# refute_line --partial 'want' +# } +# ``` +# +# On failure, in addition to the details of literal matching, the substring is also displayed. +# When used with `--index ` the substring replaces the unexpected line. +# +# ``` +# -- no line should contain substring -- +# substring : want +# index : 1 +# output (3 lines): +# have 1 +# > want 2 +# have 3 +# -- +# ``` +# +# ## Regular expression matching +# +# Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +# When used, a match fails if the *extended regular expression* matches the line being tested. +# +# *__Note__: +# As expected, the anchors `^` and `$` bind to the beginning and the end (respectively) of the matched line.* +# +# ```bash +# @test 'refute_line() regular expression matching' { +# run echo $'Foobar v0.1.0\nRelease date: 2015-11-29' +# refute_line --index 0 --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' +# } +# ``` +# +# On failure, in addition to the details of literal matching, the regular expression is also displayed. +# When used with `--index ` the regular expression replaces the unexpected line. +# +# ``` +# -- regular expression should not match line -- +# index : 0 +# regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ +# line : Foobar v0.1.0 +# -- +# ``` +# FIXME(ztombol): Display `${lines[@]}' instead of `$output'! +refute_line() { + local -i is_match_line=0 + local -i is_mode_partial=0 + local -i is_mode_regexp=0 + : "${lines?}" + + # Handle options. + while (( $# > 0 )); do + case "$1" in + -n|--index) + if (( $# < 2 )) || ! [[ $2 =~ ^([0-9]|[1-9][0-9]+)$ ]]; then + echo "\`--index' requires an integer argument: \`$2'" \ + | batslib_decorate 'ERROR: refute_line' \ + | fail + return $? + fi + is_match_line=1 + local -ri idx="$2" + shift 2 + ;; + -p|--partial) is_mode_partial=1; shift ;; + -e|--regexp) is_mode_regexp=1; shift ;; + --) shift; break ;; + *) break ;; + esac + done + + if (( is_mode_partial )) && (( is_mode_regexp )); then + echo "\`--partial' and \`--regexp' are mutually exclusive" \ + | batslib_decorate 'ERROR: refute_line' \ + | fail + return $? + fi + + # Arguments. + local -r unexpected="$1" + + if (( is_mode_regexp == 1 )) && [[ '' =~ $unexpected ]] || (( $? == 2 )); then + echo "Invalid extended regular expression: \`$unexpected'" \ + | batslib_decorate 'ERROR: refute_line' \ + | fail + return $? + fi + + # Matching. + if (( is_match_line )); then + # Specific line. + if (( is_mode_regexp )); then + if [[ ${lines[$idx]} =~ $unexpected ]]; then + batslib_print_kv_single 6 \ + 'index' "$idx" \ + 'regexp' "$unexpected" \ + 'line' "${lines[$idx]}" \ + | batslib_decorate 'regular expression should not match line' \ + | fail + fi + elif (( is_mode_partial )); then + if [[ ${lines[$idx]} == *"$unexpected"* ]]; then + batslib_print_kv_single 9 \ + 'index' "$idx" \ + 'substring' "$unexpected" \ + 'line' "${lines[$idx]}" \ + | batslib_decorate 'line should not contain substring' \ + | fail + fi + else + if [[ ${lines[$idx]} == "$unexpected" ]]; then + batslib_print_kv_single 5 \ + 'index' "$idx" \ + 'line' "${lines[$idx]}" \ + | batslib_decorate 'line should differ' \ + | fail + fi + fi + else + # Line contained in output. + if (( is_mode_regexp )); then + local -i idx + for (( idx = 0; idx < ${#lines[@]}; ++idx )); do + if [[ ${lines[$idx]} =~ $unexpected ]]; then + { local -ar single=( 'regexp' "$unexpected" 'index' "$idx" ) + local -a may_be_multi=( 'output' "$output" ) + local -ir width="$( batslib_get_max_single_line_key_width "${single[@]}" "${may_be_multi[@]}" )" + batslib_print_kv_single "$width" "${single[@]}" + if batslib_is_single_line "${may_be_multi[1]}"; then + batslib_print_kv_single "$width" "${may_be_multi[@]}" + else + may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" | batslib_prefix | batslib_mark '>' "$idx" )" + batslib_print_kv_multi "${may_be_multi[@]}" + fi + } \ + | batslib_decorate 'no line should match the regular expression' \ + | fail + return $? + fi + done + elif (( is_mode_partial )); then + local -i idx + for (( idx = 0; idx < ${#lines[@]}; ++idx )); do + if [[ ${lines[$idx]} == *"$unexpected"* ]]; then + { local -ar single=( 'substring' "$unexpected" 'index' "$idx" ) + local -a may_be_multi=( 'output' "$output" ) + local -ir width="$( batslib_get_max_single_line_key_width "${single[@]}" "${may_be_multi[@]}" )" + batslib_print_kv_single "$width" "${single[@]}" + if batslib_is_single_line "${may_be_multi[1]}"; then + batslib_print_kv_single "$width" "${may_be_multi[@]}" + else + may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" | batslib_prefix | batslib_mark '>' "$idx" )" + batslib_print_kv_multi "${may_be_multi[@]}" + fi + } \ + | batslib_decorate 'no line should contain substring' \ + | fail + return $? + fi + done + else + local -i idx + for (( idx = 0; idx < ${#lines[@]}; ++idx )); do + if [[ ${lines[$idx]} == "$unexpected" ]]; then + { local -ar single=( 'line' "$unexpected" 'index' "$idx" ) + local -a may_be_multi=( 'output' "$output" ) + local -ir width="$( batslib_get_max_single_line_key_width "${single[@]}" "${may_be_multi[@]}" )" + batslib_print_kv_single "$width" "${single[@]}" + if batslib_is_single_line "${may_be_multi[1]}"; then + batslib_print_kv_single "$width" "${may_be_multi[@]}" + else + may_be_multi[1]="$( printf '%s' "${may_be_multi[1]}" | batslib_prefix | batslib_mark '>' "$idx" )" + batslib_print_kv_multi "${may_be_multi[@]}" + fi + } \ + | batslib_decorate 'line should not be in output' \ + | fail + return $? + fi + done + fi + fi +} diff --git a/e2e/libs/bats-assert/src/refute_output.bash b/e2e/libs/bats-assert/src/refute_output.bash new file mode 100644 index 00000000..92d7e8f6 --- /dev/null +++ b/e2e/libs/bats-assert/src/refute_output.bash @@ -0,0 +1,199 @@ +# refute_output +# ============= +# +# Summary: Fail if `$output' matches the unexpected output. +# +# Usage: refute_output [-p | -e] [- | [--] ] +# +# Options: +# -p, --partial Match if `unexpected` is a substring of `$output` +# -e, --regexp Treat `unexpected` as an extended regular expression +# -, --stdin Read `unexpected` value from STDIN +# The unexpected value, substring, or regular expression +# +# IO: +# STDIN - [=$1] unexpected output +# STDERR - details, on failure +# error message, on error +# Globals: +# output +# Returns: +# 0 - if output matches the unexpected value/partial/regexp +# 1 - otherwise +# +# This function verifies that a command or function does not produce the unexpected output. +# (It is the logical complement of `assert_output`.) +# Output matching can be literal (the default), partial or by regular expression. +# The unexpected output can be specified either by positional argument or read from STDIN by passing the `-`/`--stdin` flag. +# +# ## Literal matching +# +# By default, literal matching is performed. +# The assertion fails if `$output` equals the unexpected output. +# +# ```bash +# @test 'refute_output()' { +# run echo 'want' +# refute_output 'want' +# } +# +# @test 'refute_output() with pipe' { +# run echo 'hello' +# echo 'world' | refute_output - +# } +# +# @test 'refute_output() with herestring' { +# run echo 'hello' +# refute_output - <<< world +# } +# ``` +# +# On failure, the output is displayed. +# +# ``` +# -- output equals, but it was expected to differ -- +# output : want +# -- +# ``` +# +# ## Existence +# +# To assert that there is no output at all, omit the matching argument. +# +# ```bash +# @test 'refute_output()' { +# run foo --silent +# refute_output +# } +# ``` +# +# On failure, an error message is displayed. +# +# ``` +# -- unexpected output -- +# expected no output, but output was non-empty +# -- +# ``` +# +# ## Partial matching +# +# Partial matching can be enabled with the `--partial` option (`-p` for short). +# When used, the assertion fails if the unexpected _substring_ is found in `$output`. +# +# ```bash +# @test 'refute_output() partial matching' { +# run echo 'ERROR: no such file or directory' +# refute_output --partial 'ERROR' +# } +# ``` +# +# On failure, the substring and the output are displayed. +# +# ``` +# -- output should not contain substring -- +# substring : ERROR +# output : ERROR: no such file or directory +# -- +# ``` +# +# ## Regular expression matching +# +# Regular expression matching can be enabled with the `--regexp` option (`-e` for short). +# When used, the assertion fails if the *extended regular expression* matches `$output`. +# +# *__Note__: +# The anchors `^` and `$` bind to the beginning and the end (respectively) of the entire output; +# not individual lines.* +# +# ```bash +# @test 'refute_output() regular expression matching' { +# run echo 'Foobar v0.1.0' +# refute_output --regexp '^Foobar v[0-9]+\.[0-9]+\.[0-9]$' +# } +# ``` +# +# On failure, the regular expression and the output are displayed. +# +# ``` +# -- regular expression should not match output -- +# regexp : ^Foobar v[0-9]+\.[0-9]+\.[0-9]$ +# output : Foobar v0.1.0 +# -- +# ``` +refute_output() { + local -i is_mode_partial=0 + local -i is_mode_regexp=0 + local -i is_mode_empty=0 + local -i use_stdin=0 + : "${output?}" + + # Handle options. + if (( $# == 0 )); then + is_mode_empty=1 + fi + + while (( $# > 0 )); do + case "$1" in + -p|--partial) is_mode_partial=1; shift ;; + -e|--regexp) is_mode_regexp=1; shift ;; + -|--stdin) use_stdin=1; shift ;; + --) shift; break ;; + *) break ;; + esac + done + + if (( is_mode_partial )) && (( is_mode_regexp )); then + echo "\`--partial' and \`--regexp' are mutually exclusive" \ + | batslib_decorate 'ERROR: refute_output' \ + | fail + return $? + fi + + # Arguments. + local unexpected + if (( use_stdin )); then + unexpected="$(cat -)" + else + unexpected="${1-}" + fi + + if (( is_mode_regexp == 1 )) && [[ '' =~ $unexpected ]] || (( $? == 2 )); then + echo "Invalid extended regular expression: \`$unexpected'" \ + | batslib_decorate 'ERROR: refute_output' \ + | fail + return $? + fi + + # Matching. + if (( is_mode_empty )); then + if [ -n "$output" ]; then + batslib_print_kv_single_or_multi 6 \ + 'output' "$output" \ + | batslib_decorate 'output non-empty, but expected no output' \ + | fail + fi + elif (( is_mode_regexp )); then + if [[ $output =~ $unexpected ]]; then + batslib_print_kv_single_or_multi 6 \ + 'regexp' "$unexpected" \ + 'output' "$output" \ + | batslib_decorate 'regular expression should not match output' \ + | fail + fi + elif (( is_mode_partial )); then + if [[ $output == *"$unexpected"* ]]; then + batslib_print_kv_single_or_multi 9 \ + 'substring' "$unexpected" \ + 'output' "$output" \ + | batslib_decorate 'output should not contain substring' \ + | fail + fi + else + if [[ $output == "$unexpected" ]]; then + batslib_print_kv_single_or_multi 6 \ + 'output' "$output" \ + | batslib_decorate 'output equals, but it was expected to differ' \ + | fail + fi + fi +} diff --git a/e2e/libs/bats-assert/test/assert.bats b/e2e/libs/bats-assert/test/assert.bats new file mode 100755 index 00000000..d1a34a29 --- /dev/null +++ b/e2e/libs/bats-assert/test/assert.bats @@ -0,0 +1,19 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'assert() : returns 0 if evaluates to TRUE' { + run assert true + assert_test_pass +} + +@test 'assert() : returns 1 and displays if it evaluates to FALSE' { + run assert false + + assert_test_fail <<'ERR_MSG' + +-- assertion failed -- +expression : false +-- +ERR_MSG +} diff --git a/e2e/libs/bats-assert/test/assert_equal.bats b/e2e/libs/bats-assert/test/assert_equal.bats new file mode 100755 index 00000000..7d3fc869 --- /dev/null +++ b/e2e/libs/bats-assert/test/assert_equal.bats @@ -0,0 +1,62 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'assert_equal() : returns 0 if equals ' { + run assert_equal 'a' 'a' + assert_test_pass +} + +@test 'assert_equal() : returns 1 and displays details if does not equal ' { + run assert_equal 'a' 'b' + + assert_test_fail <<'ERR_MSG' + +-- values do not equal -- +expected : b +actual : a +-- +ERR_MSG +} + +@test 'assert_equal() : displays details in multi-line format if is longer than one line' { + run assert_equal $'a 0\na 1' 'b' + + assert_test_fail <<'ERR_MSG' + +-- values do not equal -- +expected (1 lines): + b +actual (2 lines): + a 0 + a 1 +-- +ERR_MSG +} + +@test 'assert_equal() : displays details in multi-line format if is longer than one line' { + run assert_equal 'a' $'b 0\nb 1' + + assert_test_fail <<'ERR_MSG' + +-- values do not equal -- +expected (2 lines): + b 0 + b 1 +actual (1 lines): + a +-- +ERR_MSG +} + +@test 'assert_equal() : performs literal matching' { + run assert_equal 'a' '*' + + assert_test_fail <<'ERR_MSG' + +-- values do not equal -- +expected : * +actual : a +-- +ERR_MSG +} diff --git a/e2e/libs/bats-assert/test/assert_failure.bats b/e2e/libs/bats-assert/test/assert_failure.bats new file mode 100755 index 00000000..6291afe1 --- /dev/null +++ b/e2e/libs/bats-assert/test/assert_failure.bats @@ -0,0 +1,75 @@ +#!/usr/bin/env bats + +load test_helper + +@test "assert_failure(): returns 0 if \`\$status' is not 0" { + run false + run assert_failure + assert_test_pass +} + +@test "assert_failure(): returns 1 and displays details if \`\$status' is 0" { + run bash -c 'echo "a" + exit 0' + run assert_failure + + assert_test_fail <<'ERR_MSG' + +-- command succeeded, but it was expected to fail -- +output : a +-- +ERR_MSG +} + +@test "assert_failure(): displays \`\$output' in multi-line format if it is longer then one line" { + run bash -c 'printf "a 0\na 1" + exit 0' + run assert_failure + + assert_test_fail <<'ERR_MSG' + +-- command succeeded, but it was expected to fail -- +output (2 lines): + a 0 + a 1 +-- +ERR_MSG +} + +@test "assert_failure() : returns 0 if \`\$status' equals " { + run bash -c 'exit 1' + run assert_failure 1 + assert_test_pass +} + +@test "assert_failure() : returns 1 and displays details if \`\$status' does not equal " { + run bash -c 'echo "a" + exit 1' + run assert_failure 2 + + assert_test_fail <<'ERR_MSG' + +-- command failed as expected, but status differs -- +expected : 2 +actual : 1 +output : a +-- +ERR_MSG +} + +@test "assert_failure() : displays \`\$output' in multi-line format if it is longer then one line" { + run bash -c 'printf "a 0\na 1" + exit 1' + run assert_failure 2 + + assert_test_fail <<'ERR_MSG' + +-- command failed as expected, but status differs -- +expected : 2 +actual : 1 +output (2 lines): + a 0 + a 1 +-- +ERR_MSG +} diff --git a/e2e/libs/bats-assert/test/assert_line.bats b/e2e/libs/bats-assert/test/assert_line.bats new file mode 100755 index 00000000..151f6885 --- /dev/null +++ b/e2e/libs/bats-assert/test/assert_line.bats @@ -0,0 +1,351 @@ +#!/usr/bin/env bats + +load test_helper + + +############################################################################### +# Containing a line +############################################################################### + +# +# Literal matching +# + +# Correctness +@test "assert_line() : returns 0 if is a line in \`\${lines[@]}'" { + run printf 'a\nb\nc' + run assert_line 'b' + assert_test_pass +} + +@test "assert_line() : returns 1 and displays details if is not a line in \`\${lines[@]}'" { + run echo 'b' + run assert_line 'a' + + assert_test_fail <<'ERR_MSG' + +-- output does not contain line -- +line : a +output : b +-- +ERR_MSG +} + +# Output formatting +@test "assert_line() : displays \`\$output' in multi-line format if it is longer than one line" { + run printf 'b 0\nb 1' + run assert_line 'a' + + assert_test_fail <<'ERR_MSG' + +-- output does not contain line -- +line : a +output (2 lines): + b 0 + b 1 +-- +ERR_MSG +} + +# Options +@test 'assert_line() : performs literal matching by default' { + run echo 'a' + run assert_line '*' + + assert_test_fail <<'ERR_MSG' + +-- output does not contain line -- +line : * +output : a +-- +ERR_MSG +} + + +# +# Partial matching: `-p' and `--partial' +# + +# Options +@test 'assert_line() -p : enables partial matching' { + run printf 'a\n_b_\nc' + run assert_line -p 'b' + assert_test_pass +} + +@test 'assert_line() --partial : enables partial matching' { + run printf 'a\n_b_\nc' + run assert_line --partial 'b' + assert_test_pass +} + +# Correctness +@test "assert_line() --partial : returns 0 if is a substring in any line in \`\${lines[@]}'" { + run printf 'a\n_b_\nc' + run assert_line --partial 'b' + assert_test_pass +} + +@test "assert_line() --partial : returns 1 and displays details if is not a substring in any lines in \`\${lines[@]}'" { + run echo 'b' + run assert_line --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- no output line contains substring -- +substring : a +output : b +-- +ERR_MSG +} + +# Output formatting +@test "assert_line() --partial : displays \`\$output' in multi-line format if it is longer than one line" { + run printf 'b 0\nb 1' + run assert_line --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- no output line contains substring -- +substring : a +output (2 lines): + b 0 + b 1 +-- +ERR_MSG +} + + +# +# Regular expression matching: `-e' and `--regexp' +# + +# Options +@test 'assert_line() -e : enables regular expression matching' { + run printf 'a\n_b_\nc' + run assert_line -e '^.b' + assert_test_pass +} + +@test 'assert_line() --regexp : enables regular expression matching' { + run printf 'a\n_b_\nc' + run assert_line --regexp '^.b' + assert_test_pass +} + +# Correctness +@test "assert_line() --regexp : returns 0 if matches any line in \`\${lines[@]}'" { + run printf 'a\n_b_\nc' + run assert_line --regexp '^.b' + assert_test_pass +} + +@test "assert_line() --regexp : returns 1 and displays details if does not match any lines in \`\${lines[@]}'" { + run echo 'b' + run assert_line --regexp '^.a' + + assert_test_fail <<'ERR_MSG' + +-- no output line matches regular expression -- +regexp : ^.a +output : b +-- +ERR_MSG +} + +# Output formatting +@test "assert_line() --regexp : displays \`\$output' in multi-line format if longer than one line" { + run printf 'b 0\nb 1' + run assert_line --regexp '^.a' + + assert_test_fail <<'ERR_MSG' + +-- no output line matches regular expression -- +regexp : ^.a +output (2 lines): + b 0 + b 1 +-- +ERR_MSG +} + + +############################################################################### +# Matching single line: `-n' and `--index' +############################################################################### + +# Options +@test 'assert_line() -n : matches against the -th line only' { + run printf 'a\nb\nc' + run assert_line -n 1 'b' + assert_test_pass +} + +@test 'assert_line() --index : matches against the -th line only' { + run printf 'a\nb\nc' + run assert_line --index 1 'b' + assert_test_pass +} + +@test 'assert_line() --index : returns 1 and displays an error message if is not an integer' { + run assert_line --index 1a + + assert_test_fail <<'ERR_MSG' + +-- ERROR: assert_line -- +`--index' requires an integer argument: `1a' +-- +ERR_MSG +} + + +# +# Literal matching +# + +# Correctness +@test "assert_line() --index : returns 0 if equals \`\${lines[]}'" { + run printf 'a\nb\nc' + run assert_line --index 1 'b' + assert_test_pass +} + +@test "assert_line() --index : returns 1 and displays details if does not equal \`\${lines[]}'" { + run printf 'a\nb\nc' + run assert_line --index 1 'a' + + assert_test_fail <<'ERR_MSG' + +-- line differs -- +index : 1 +expected : a +actual : b +-- +ERR_MSG +} + +# Options +@test 'assert_line() --index : performs literal matching by default' { + run printf 'a\nb\nc' + run assert_line --index 1 '*' + + assert_test_fail <<'ERR_MSG' + +-- line differs -- +index : 1 +expected : * +actual : b +-- +ERR_MSG +} + + +# +# Partial matching: `-p' and `--partial' +# + +# Options +@test 'assert_line() --index -p : enables partial matching' { + run printf 'a\n_b_\nc' + run assert_line --index 1 -p 'b' + assert_test_pass +} + +@test 'assert_line() --index --partial : enables partial matching' { + run printf 'a\n_b_\nc' + run assert_line --index 1 --partial 'b' + assert_test_pass +} + +# Correctness +@test "assert_line() --index --partial : returns 0 if is a substring in \`\${lines[]}'" { + run printf 'a\n_b_\nc' + run assert_line --index 1 --partial 'b' + assert_test_pass +} + +@test "assert_line() --index --partial : returns 1 and displays details if is not a substring in \`\${lines[]}'" { + run printf 'b 0\nb 1' + run assert_line --index 1 --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- line does not contain substring -- +index : 1 +substring : a +line : b 1 +-- +ERR_MSG +} + + +# +# Regular expression matching: `-e' and `--regexp' +# + +# Options +@test 'assert_line() --index -e : enables regular expression matching' { + run printf 'a\n_b_\nc' + run assert_line --index 1 -e '^.b' + assert_test_pass +} + +@test 'assert_line() --index --regexp : enables regular expression matching' { + run printf 'a\n_b_\nc' + run assert_line --index 1 --regexp '^.b' + assert_test_pass +} + +# Correctness +@test "assert_line() --index --regexp : returns 0 if matches \`\${lines[]}'" { + run printf 'a\n_b_\nc' + run assert_line --index 1 --regexp '^.b' + assert_test_pass +} + +@test "assert_line() --index --regexp : returns 1 and displays details if does not match \`\${lines[]}'" { + run printf 'a\nb\nc' + run assert_line --index 1 --regexp '^.a' + + assert_test_fail <<'ERR_MSG' + +-- regular expression does not match line -- +index : 1 +regexp : ^.a +line : b +-- +ERR_MSG +} + + +############################################################################### +# Common +############################################################################### + +@test "assert_line(): \`--partial' and \`--regexp' are mutually exclusive" { + run assert_line --partial --regexp + + assert_test_fail <<'ERR_MSG' + +-- ERROR: assert_line -- +`--partial' and `--regexp' are mutually exclusive +-- +ERR_MSG +} + +@test 'assert_line() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { + run assert_line --regexp '[.*' + + assert_test_fail <<'ERR_MSG' + +-- ERROR: assert_line -- +Invalid extended regular expression: `[.*' +-- +ERR_MSG +} + +@test "assert_line(): \`--' stops parsing options" { + run printf 'a\n-p\nc' + run assert_line -- '-p' + assert_test_pass +} diff --git a/e2e/libs/bats-assert/test/assert_output.bats b/e2e/libs/bats-assert/test/assert_output.bats new file mode 100755 index 00000000..e9609e07 --- /dev/null +++ b/e2e/libs/bats-assert/test/assert_output.bats @@ -0,0 +1,285 @@ +#!/usr/bin/env bats + +load test_helper + +# +# Literal matching +# + +# Correctness +@test "assert_output() : returns 0 if equals \`\$output'" { + run echo 'a' + run assert_output 'a' + assert_test_pass +} + +@test "assert_output() : returns 1 and displays details if does not equal \`\$output'" { + run echo 'b' + run assert_output 'a' + + assert_test_fail <<'ERR_MSG' + +-- output differs -- +expected : a +actual : b +-- +ERR_MSG +} + +@test 'assert_output(): succeeds if output is non-empty' { + run echo 'a' + run assert_output + + assert_test_pass +} + +@test 'assert_output(): fails if output is empty' { + run echo '' + run assert_output + + assert_test_fail <<'ERR_MSG' + +-- no output -- +expected non-empty output, but output was empty +-- +ERR_MSG +} + +@test 'assert_output() - : reads from STDIN' { + run echo 'a' + run assert_output - < from STDIN' { + run echo 'a' + run assert_output --stdin <: displays details in multi-line format if \`\$output' is longer than one line" { + run printf 'b 0\nb 1' + run assert_output 'a' + + assert_test_fail <<'ERR_MSG' + +-- output differs -- +expected (1 lines): + a +actual (2 lines): + b 0 + b 1 +-- +ERR_MSG +} + +@test 'assert_output() : displays details in multi-line format if is longer than one line' { + run echo 'b' + run assert_output $'a 0\na 1' + + assert_test_fail <<'ERR_MSG' + +-- output differs -- +expected (2 lines): + a 0 + a 1 +actual (1 lines): + b +-- +ERR_MSG +} + +# Options +@test 'assert_output() : performs literal matching by default' { + run echo 'a' + run assert_output '*' + + assert_test_fail <<'ERR_MSG' + +-- output differs -- +expected : * +actual : a +-- +ERR_MSG +} + + +# +# Partial matching: `-p' and `--partial' +# + +@test 'assert_output() -p : enables partial matching' { + run echo 'abc' + run assert_output -p 'b' + assert_test_pass +} + +@test 'assert_output() --partial : enables partial matching' { + run echo 'abc' + run assert_output --partial 'b' + assert_test_pass +} + +# Correctness +@test "assert_output() --partial : returns 0 if is a substring in \`\$output'" { + run printf 'a\nb\nc' + run assert_output --partial 'b' + assert_test_pass +} + +@test "assert_output() --partial : returns 1 and displays details if is not a substring in \`\$output'" { + run echo 'b' + run assert_output --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- output does not contain substring -- +substring : a +output : b +-- +ERR_MSG +} + +# Output formatting +@test "assert_output() --partial : displays details in multi-line format if \`\$output' is longer than one line" { + run printf 'b 0\nb 1' + run assert_output --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- output does not contain substring -- +substring (1 lines): + a +output (2 lines): + b 0 + b 1 +-- +ERR_MSG +} + +@test 'assert_output() --partial : displays details in multi-line format if is longer than one line' { + run echo 'b' + run assert_output --partial $'a 0\na 1' + + assert_test_fail <<'ERR_MSG' + +-- output does not contain substring -- +substring (2 lines): + a 0 + a 1 +output (1 lines): + b +-- +ERR_MSG +} + + +# +# Regular expression matching: `-e' and `--regexp' +# + +@test 'assert_output() -e : enables regular expression matching' { + run echo 'abc' + run assert_output -e '^a' + assert_test_pass +} + +@test 'assert_output() --regexp : enables regular expression matching' { + run echo 'abc' + run assert_output --regexp '^a' + assert_test_pass +} + +# Correctness +@test "assert_output() --regexp : returns 0 if matches \`\$output'" { + run printf 'a\nb\nc' + run assert_output --regexp '.*b.*' + assert_test_pass +} + +@test "assert_output() --regexp : returns 1 and displays details if does not match \`\$output'" { + run echo 'b' + run assert_output --regexp '.*a.*' + + assert_test_fail <<'ERR_MSG' + +-- regular expression does not match output -- +regexp : .*a.* +output : b +-- +ERR_MSG +} + +# Output formatting +@test "assert_output() --regexp : displays details in multi-line format if \`\$output' is longer than one line" { + run printf 'b 0\nb 1' + run assert_output --regexp '.*a.*' + + assert_test_fail <<'ERR_MSG' + +-- regular expression does not match output -- +regexp (1 lines): + .*a.* +output (2 lines): + b 0 + b 1 +-- +ERR_MSG +} + +@test 'assert_output() --regexp : displays details in multi-line format if is longer than one line' { + run echo 'b' + run assert_output --regexp $'.*a\nb.*' + + assert_test_fail <<'ERR_MSG' + +-- regular expression does not match output -- +regexp (2 lines): + .*a + b.* +output (1 lines): + b +-- +ERR_MSG +} + +# Error handling +@test 'assert_output() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { + run assert_output --regexp '[.*' + + assert_test_fail <<'ERR_MSG' + +-- ERROR: assert_output -- +Invalid extended regular expression: `[.*' +-- +ERR_MSG +} + + +# +# Common +# + +@test "assert_output(): \`--partial' and \`--regexp' are mutually exclusive" { + run assert_output --partial --regexp + + assert_test_fail <<'ERR_MSG' + +-- ERROR: assert_output -- +`--partial' and `--regexp' are mutually exclusive +-- +ERR_MSG +} + +@test "assert_output(): \`--' stops parsing options" { + run echo '-p' + run assert_output -- '-p' + assert_test_pass +} diff --git a/e2e/libs/bats-assert/test/assert_success.bats b/e2e/libs/bats-assert/test/assert_success.bats new file mode 100755 index 00000000..66f5aa72 --- /dev/null +++ b/e2e/libs/bats-assert/test/assert_success.bats @@ -0,0 +1,40 @@ +#!/usr/bin/env bats + +load test_helper + +@test "assert_success(): returns 0 if \`\$status' is 0" { + run true + run assert_success + + assert_test_pass +} + +@test "assert_success(): returns 1 and displays details if \`\$status' is not 0" { + run bash -c 'echo "a" + exit 1' + run assert_success + + assert_test_fail <<'ERR_MSG' + +-- command failed -- +status : 1 +output : a +-- +ERR_MSG +} + +@test "assert_success(): displays \`\$output' in multi-line format if it is longer than one line" { + run bash -c 'printf "a 0\na 1" + exit 1' + run assert_success + + assert_test_fail <<'ERR_MSG' + +-- command failed -- +status : 1 +output (2 lines): + a 0 + a 1 +-- +ERR_MSG +} diff --git a/e2e/libs/bats-assert/test/refute.bats b/e2e/libs/bats-assert/test/refute.bats new file mode 100755 index 00000000..f9e2737f --- /dev/null +++ b/e2e/libs/bats-assert/test/refute.bats @@ -0,0 +1,18 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'refute() : returns 0 if evaluates to FALSE' { + run refute false + assert_test_pass +} + +@test 'refute() : returns 1 and displays if it evaluates to TRUE' { + run refute true + assert_test_fail <<'ERR_MSG' + +-- assertion succeeded, but it was expected to fail -- +expression : true +-- +ERR_MSG +} diff --git a/e2e/libs/bats-assert/test/refute_line.bats b/e2e/libs/bats-assert/test/refute_line.bats new file mode 100755 index 00000000..fd6221cc --- /dev/null +++ b/e2e/libs/bats-assert/test/refute_line.bats @@ -0,0 +1,344 @@ +#!/usr/bin/env bats + +load test_helper + + +############################################################################### +# Containing a line +############################################################################### + +# +# Literal matching +# + +# Correctness +@test "refute_line() : returns 0 if is not a line in \`\${lines[@]}'" { + run printf 'a\nb\nc' + run refute_line 'd' + assert_test_pass +} + +@test "refute_line() : returns 1 and displays details if is not a line in \`\${lines[@]}'" { + run echo 'a' + run refute_line 'a' + + assert_test_fail <<'ERR_MSG' + +-- line should not be in output -- +line : a +index : 0 +output : a +-- +ERR_MSG +} + +# Output formatting +@test "refute_line() : displays \`\$output' in multi-line format if it is longer than one line" { + run printf 'a 0\na 1\na 2' + run refute_line 'a 1' + + assert_test_fail <<'ERR_MSG' + +-- line should not be in output -- +line : a 1 +index : 1 +output (3 lines): + a 0 +> a 1 + a 2 +-- +ERR_MSG +} + +# Options +@test 'refute_line() : performs literal matching by default' { + run echo 'a' + run refute_line '*' + assert_test_pass +} + + +# +# Partial matching: `-p' and `--partial' +# + +# Options +@test 'refute_line() -p : enables partial matching' { + run printf 'a\nb\nc' + run refute_line -p 'd' + assert_test_pass +} + +@test 'refute_line() --partial : enables partial matching' { + run printf 'a\nb\nc' + run refute_line --partial 'd' + assert_test_pass +} + +# Correctness +@test "refute_line() --partial : returns 0 if is not a substring in any line in \`\${lines[@]}'" { + run printf 'a\nb\nc' + run refute_line --partial 'd' + assert_test_pass +} + +@test "refute_line() --partial : returns 1 and displays details if is a substring in any line in \`\${lines[@]}'" { + run echo 'a' + run refute_line --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- no line should contain substring -- +substring : a +index : 0 +output : a +-- +ERR_MSG +} + +# Output formatting +@test "refute_line() --partial : displays \`\$output' in multi-line format if it is longer than one line" { + run printf 'a\nabc\nc' + run refute_line --partial 'b' + + assert_test_fail <<'ERR_MSG' + +-- no line should contain substring -- +substring : b +index : 1 +output (3 lines): + a +> abc + c +-- +ERR_MSG +} + + +# +# Regular expression matching: `-e' and `--regexp' +# + +# Options +@test 'refute_line() -e : enables regular expression matching' { + run printf 'a\nb\nc' + run refute_line -e '^.d' + assert_test_pass +} + +@test 'refute_line() --regexp : enables regular expression matching' { + run printf 'a\nb\nc' + run refute_line --regexp '^.d' + assert_test_pass +} + +# Correctness +@test "refute_line() --regexp : returns 0 if does not match any line in \`\${lines[@]}'" { + run printf 'a\nb\nc' + run refute_line --regexp '.*d.*' + assert_test_pass +} + +@test "refute_line() --regexp : returns 1 and displays details if matches any lines in \`\${lines[@]}'" { + run echo 'a' + run refute_line --regexp '.*a.*' + + assert_test_fail <<'ERR_MSG' + +-- no line should match the regular expression -- +regexp : .*a.* +index : 0 +output : a +-- +ERR_MSG +} + +# Output formatting +@test "refute_line() --regexp : displays \`\$output' in multi-line format if longer than one line" { + run printf 'a\nabc\nc' + run refute_line --regexp '.*b.*' + + assert_test_fail <<'ERR_MSG' + +-- no line should match the regular expression -- +regexp : .*b.* +index : 1 +output (3 lines): + a +> abc + c +-- +ERR_MSG +} + + +############################################################################### +# Matching single line: `-n' and `--index' +############################################################################### + +# Options +@test 'refute_line() -n : matches against the -th line only' { + run printf 'a\nb\nc' + run refute_line -n 1 'd' + assert_test_pass +} + +@test 'refute_line() --index : matches against the -th line only' { + run printf 'a\nb\nc' + run refute_line --index 1 'd' + assert_test_pass +} + +@test 'refute_line() --index : returns 1 and displays an error message if is not an integer' { + run refute_line --index 1a + + assert_test_fail <<'ERR_MSG' + +-- ERROR: refute_line -- +`--index' requires an integer argument: `1a' +-- +ERR_MSG +} + + +# +# Literal matching +# + +# Correctness +@test "refute_line() --index : returns 0 if does not equal \`\${lines[]}'" { + run printf 'a\nb\nc' + run refute_line --index 1 'd' + assert_test_pass +} + +@test "refute_line() --index : returns 1 and displays details if equals \`\${lines[]}'" { + run printf 'a\nb\nc' + run refute_line --index 1 'b' + + assert_test_fail <<'ERR_MSG' + +-- line should differ -- +index : 1 +line : b +-- +ERR_MSG +} + +# Options +@test 'refute_line() --index : performs literal matching by default' { + run printf 'a\nb\nc' + run refute_line --index 1 '*' + assert_test_pass +} + + +# +# Partial matching: `-p' and `--partial' +# + +# Options +@test 'refute_line() --index -p : enables partial matching' { + run printf 'a\nb\nc' + run refute_line --index 1 -p 'd' + assert_test_pass +} + +@test 'refute_line() --index --partial : enables partial matching' { + run printf 'a\nb\nc' + run refute_line --index 1 --partial 'd' + assert_test_pass +} + +# Correctness +@test "refute_line() --index --partial : returns 0 if is not a substring in \`\${lines[]}'" { + run printf 'a\nabc\nc' + run refute_line --index 1 --partial 'd' + assert_test_pass +} + +@test "refute_line() --index --partial : returns 1 and displays details if is a substring in \`\${lines[]}'" { + run printf 'a\nabc\nc' + run refute_line --index 1 --partial 'b' + + assert_test_fail <<'ERR_MSG' + +-- line should not contain substring -- +index : 1 +substring : b +line : abc +-- +ERR_MSG +} + + +# +# Regular expression matching: `-e' and `--regexp' +# + +# Options +@test 'refute_line() --index -e : enables regular expression matching' { + run printf 'a\nb\nc' + run refute_line --index 1 -e '^.b' + assert_test_pass +} + +@test 'refute_line() --index --regexp : enables regular expression matching' { + run printf 'a\nb\nc' + run refute_line --index 1 --regexp '^.b' + assert_test_pass +} + +# Correctness +@test "refute_line() --index --regexp : returns 0 if does not match \`\${lines[]}'" { + run printf 'a\nabc\nc' + run refute_line --index 1 --regexp '.*d.*' + assert_test_pass +} + +@test "refute_line() --index --regexp : returns 1 and displays details if matches \`\${lines[]}'" { + run printf 'a\nabc\nc' + run refute_line --index 1 --regexp '.*b.*' + + assert_test_fail <<'ERR_MSG' + +-- regular expression should not match line -- +index : 1 +regexp : .*b.* +line : abc +-- +ERR_MSG +} + + +############################################################################### +# Common +############################################################################### + +@test "refute_line(): \`--partial' and \`--regexp' are mutually exclusive" { + run refute_line --partial --regexp + + assert_test_fail <<'ERR_MSG' + +-- ERROR: refute_line -- +`--partial' and `--regexp' are mutually exclusive +-- +ERR_MSG +} + +@test 'refute_line() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { + run refute_line --regexp '[.*' + + assert_test_fail <<'ERR_MSG' + +-- ERROR: refute_line -- +Invalid extended regular expression: `[.*' +-- +ERR_MSG +} + +@test "refute_line(): \`--' stops parsing options" { + run printf 'a\n--\nc' + run refute_line -- '-p' + assert_test_pass +} diff --git a/e2e/libs/bats-assert/test/refute_output.bats b/e2e/libs/bats-assert/test/refute_output.bats new file mode 100755 index 00000000..9d8711d5 --- /dev/null +++ b/e2e/libs/bats-assert/test/refute_output.bats @@ -0,0 +1,230 @@ +#!/usr/bin/env bats + +load test_helper + + +# +# Literal matching +# + +# Correctness +@test "refute_output() : returns 0 if does not equal \`\$output'" { + run echo 'b' + run refute_output 'a' + assert_test_pass +} + +@test "refute_output() : returns 1 and displays details if equals \`\$output'" { + run echo 'a' + run refute_output 'a' + + assert_test_fail <<'ERR_MSG' + +-- output equals, but it was expected to differ -- +output : a +-- +ERR_MSG +} + +@test 'refute_output(): succeeds if output is empty' { + run echo '' + run refute_output + + assert_test_pass +} + +@test 'refute_output(): fails if output is non-empty' { + run echo 'a' + run refute_output + + assert_test_fail <<'ERR_MSG' + +-- output non-empty, but expected no output -- +output : a +-- +ERR_MSG +} + +@test 'refute_output() - : reads from STDIN' { + run echo '-' + run refute_output - < from STDIN' { + run echo '--stdin' + run refute_output --stdin <: displays details in multi-line format if necessary' { + run printf 'a 0\na 1' + run refute_output $'a 0\na 1' + + assert_test_fail <<'ERR_MSG' + +-- output equals, but it was expected to differ -- +output (2 lines): + a 0 + a 1 +-- +ERR_MSG +} + +# Options +@test 'refute_output() : performs literal matching by default' { + run echo 'a' + run refute_output '*' + assert_test_pass +} + + +# +# Partial matching: `-p' and `--partial' +# + +# Options +@test 'refute_output() -p : enables partial matching' { + run echo 'abc' + run refute_output -p 'd' + assert_test_pass +} + +@test 'refute_output() --partial : enables partial matching' { + run echo 'abc' + run refute_output --partial 'd' + assert_test_pass +} + +# Correctness +@test "refute_output() --partial : returns 0 if is not a substring in \`\$output'" { + run printf 'a\nb\nc' + run refute_output --partial 'd' + assert_test_pass +} + +@test "refute_output() --partial : returns 1 and displays details if is a substring in \`\$output'" { + run echo 'a' + run refute_output --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- output should not contain substring -- +substring : a +output : a +-- +ERR_MSG +} + +# Output formatting +@test 'refute_output() --partial : displays details in multi-line format if necessary' { + run printf 'a 0\na 1' + run refute_output --partial 'a' + + assert_test_fail <<'ERR_MSG' + +-- output should not contain substring -- +substring (1 lines): + a +output (2 lines): + a 0 + a 1 +-- +ERR_MSG +} + + +# +# Regular expression matching: `-e' and `--regexp' +# + +# Options +@test 'refute_output() -e : enables regular expression matching' { + run echo 'abc' + run refute_output -e '^d' + assert_test_pass +} + +@test 'refute_output() --regexp : enables regular expression matching' { + run echo 'abc' + run refute_output --regexp '^d' + assert_test_pass +} + +# Correctness +@test "refute_output() --regexp : returns 0 if does not match \`\$output'" { + run printf 'a\nb\nc' + run refute_output --regexp '.*d.*' + assert_test_pass +} + +@test "refute_output() --regexp : returns 1 and displays details if matches \`\$output'" { + run echo 'a' + run refute_output --regexp '.*a.*' + + assert_test_fail <<'ERR_MSG' + +-- regular expression should not match output -- +regexp : .*a.* +output : a +-- +ERR_MSG +} + +# Output formatting +@test 'refute_output() --regexp : displays details in multi-line format if necessary' { + run printf 'a 0\na 1' + run refute_output --regexp '.*a.*' + + assert_test_fail <<'ERR_MSG' + +-- regular expression should not match output -- +regexp (1 lines): + .*a.* +output (2 lines): + a 0 + a 1 +-- +ERR_MSG +} + +# Error handling +@test 'refute_output() --regexp : returns 1 and displays an error message if is not a valid extended regular expression' { + run refute_output --regexp '[.*' + + assert_test_fail <<'ERR_MSG' + +-- ERROR: refute_output -- +Invalid extended regular expression: `[.*' +-- +ERR_MSG +} + + +# +# Common +# + +@test "refute_output(): \`--partial' and \`--regexp' are mutually exclusive" { + run refute_output --partial --regexp + + assert_test_fail <<'ERR_MSG' + +-- ERROR: refute_output -- +`--partial' and `--regexp' are mutually exclusive +-- +ERR_MSG +} + +@test "refute_output(): \`--' stops parsing options" { + run echo '--' + run refute_output -- '-p' + assert_test_pass +} diff --git a/e2e/libs/bats-assert/test/test_helper.bash b/e2e/libs/bats-assert/test/test_helper.bash new file mode 100644 index 00000000..65d366fd --- /dev/null +++ b/e2e/libs/bats-assert/test/test_helper.bash @@ -0,0 +1,27 @@ +# Load dependencies. +load "${BATS_TEST_DIRNAME}/../node_modules/bats-support/load.bash" + +# Load library. +load '../load' + +# validate that bats-assert is safe to use under -u +set -u + +: "${status:=}" +: "${lines:=}" +: "${output:=}" + +assert_test_pass() { + test "$status" -eq 0 + test "${#lines[@]}" -eq 0 +} + +assert_test_fail() { + local err_msg="${1-$(cat -)}" + local num_lines + num_lines="$(printf '%s' "$err_msg" | wc -l)" + + test "$status" -eq 1 + test "${#lines[@]}" -eq "$num_lines" + test "$output" == "$err_msg" +} diff --git a/e2e/libs/bats-support/.gitignore b/e2e/libs/bats-support/.gitignore new file mode 100644 index 00000000..05f900ce --- /dev/null +++ b/e2e/libs/bats-support/.gitignore @@ -0,0 +1,4 @@ +/node_modules +/package-lock.json +/yarn.lock +/bats-support-*.tgz diff --git a/e2e/libs/bats-support/.travis.yml b/e2e/libs/bats-support/.travis.yml new file mode 100644 index 00000000..965fe2d3 --- /dev/null +++ b/e2e/libs/bats-support/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: node +cache: npm diff --git a/e2e/libs/bats-support/CHANGELOG.md b/e2e/libs/bats-support/CHANGELOG.md new file mode 100644 index 00000000..324d247a --- /dev/null +++ b/e2e/libs/bats-support/CHANGELOG.md @@ -0,0 +1,46 @@ +# Change Log + +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + + +## [0.3.0] - 2016-11-29 + +### Added + +- Restricting invocation to specific locations with + `batslib_is_caller()` + + +## [0.2.0] - 2016-03-22 + +### Added + +- `npm` support +- Reporting arbitrary failures with `fail()` (moved from `bats-assert`) + +### Changed + +- Library renamed to `bats-support` + + +## 0.1.0 - 2016-02-16 + +### Added + +- Two-column key-value formatting with `batslib_print_kv_single()` +- Multi-line key-value formatting with `batslib_print_kv_multi()` +- Mixed formatting with `batslib_print_kv_single_or_multi()` +- Header and footer decoration with `batslib_decorate()` +- Prefixing lines with `batslib_prefix()` +- Marking lines with `batslib_mark()` +- Common output function `batslib_err()` +- Line counting with `batslib_count_lines()` +- Checking whether a text is one line long with + `batslib_is_single_line()` +- Determining key width for two-column and mixed formatting with + `batslib_get_max_single_line_key_width()` + + +[0.3.0]: https://github.com/ztombol/bats-support/compare/v0.2.0...v0.3.0 +[0.2.0]: https://github.com/ztombol/bats-support/compare/v0.1.0...v0.2.0 diff --git a/e2e/libs/bats-support/LICENSE b/e2e/libs/bats-support/LICENSE new file mode 100644 index 00000000..670154e3 --- /dev/null +++ b/e2e/libs/bats-support/LICENSE @@ -0,0 +1,116 @@ +CC0 1.0 Universal + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator and +subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for the +purpose of contributing to a commons of creative, cultural and scientific +works ("Commons") that the public can reliably and without fear of later +claims of infringement build upon, modify, incorporate in other works, reuse +and redistribute as freely as possible in any form whatsoever and for any +purposes, including without limitation commercial purposes. These owners may +contribute to the Commons to promote the ideal of a free culture and the +further production of creative, cultural and scientific works, or to gain +reputation or greater distribution for their Work in part through the use and +efforts of others. + +For these and/or other purposes and motivations, and without any expectation +of additional consideration or compensation, the person associating CC0 with a +Work (the "Affirmer"), to the extent that he or she is an owner of Copyright +and Related Rights in the Work, voluntarily elects to apply CC0 to the Work +and publicly distribute the Work under its terms, with knowledge of his or her +Copyright and Related Rights in the Work and the meaning and intended legal +effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not limited +to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, communicate, + and translate a Work; + + ii. moral rights retained by the original author(s) and/or performer(s); + + iii. publicity and privacy rights pertaining to a person's image or likeness + depicted in a Work; + + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + + v. rights protecting the extraction, dissemination, use and reuse of data in + a Work; + + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation thereof, + including any amended or successor version of such directive); and + + vii. other similar, equivalent or corresponding rights throughout the world + based on applicable law or treaty, and any national implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, +applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and +unconditionally waives, abandons, and surrenders all of Affirmer's Copyright +and Related Rights and associated claims and causes of action, whether now +known or unknown (including existing as well as future claims and causes of +action), in the Work (i) in all territories worldwide, (ii) for the maximum +duration provided by applicable law or treaty (including future time +extensions), (iii) in any current or future medium and for any number of +copies, and (iv) for any purpose whatsoever, including without limitation +commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes +the Waiver for the benefit of each member of the public at large and to the +detriment of Affirmer's heirs and successors, fully intending that such Waiver +shall not be subject to revocation, rescission, cancellation, termination, or +any other legal or equitable action to disrupt the quiet enjoyment of the Work +by the public as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be +judged legally invalid or ineffective under applicable law, then the Waiver +shall be preserved to the maximum extent permitted taking into account +Affirmer's express Statement of Purpose. In addition, to the extent the Waiver +is so judged Affirmer hereby grants to each affected person a royalty-free, +non transferable, non sublicensable, non exclusive, irrevocable and +unconditional license to exercise Affirmer's Copyright and Related Rights in +the Work (i) in all territories worldwide, (ii) for the maximum duration +provided by applicable law or treaty (including future time extensions), (iii) +in any current or future medium and for any number of copies, and (iv) for any +purpose whatsoever, including without limitation commercial, advertising or +promotional purposes (the "License"). The License shall be deemed effective as +of the date CC0 was applied by Affirmer to the Work. Should any part of the +License for any reason be judged legally invalid or ineffective under +applicable law, such partial invalidity or ineffectiveness shall not +invalidate the remainder of the License, and in such case Affirmer hereby +affirms that he or she will not (i) exercise any of his or her remaining +Copyright and Related Rights in the Work or (ii) assert any associated claims +and causes of action with respect to the Work, in either case contrary to +Affirmer's express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + + b. Affirmer offers the Work as-is and makes no representations or warranties + of any kind concerning the Work, express, implied, statutory or otherwise, + including without limitation warranties of title, merchantability, fitness + for a particular purpose, non infringement, or the absence of latent or + other defects, accuracy, or the present or absence of errors, whether or not + discoverable, all to the greatest extent permissible under applicable law. + + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without limitation + any person's Copyright and Related Rights in the Work. Further, Affirmer + disclaims responsibility for obtaining any necessary consents, permissions + or other rights required for any use of the Work. + + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to this + CC0 or use of the Work. + +For more information, please see + diff --git a/e2e/libs/bats-support/README.md b/e2e/libs/bats-support/README.md new file mode 100644 index 00000000..71c02ba9 --- /dev/null +++ b/e2e/libs/bats-support/README.md @@ -0,0 +1,189 @@ +*__Important:__ `bats-core` has been renamed to `bats-support`. GitHub +automatically redirects all references, e.g. submodules and clones will +continue to work, but you are encouraged to [update][github-rename] +them. Version numbering continues where `bats-core` left off.* + +[github-rename]: https://help.github.com/articles/renaming-a-repository/ + +- - - - - + +# bats-support + +[![GitHub license](https://img.shields.io/badge/license-CC0-blue.svg)](https://raw.githubusercontent.com/ztombol/bats-support/master/LICENSE) +[![GitHub release](https://img.shields.io/github/release/ztombol/bats-support.svg)](https://github.com/ztombol/bats-support/releases/latest) +[![Build Status](https://travis-ci.org/ztombol/bats-support.svg?branch=master)](https://travis-ci.org/ztombol/bats-support) + +`bats-support` is a supporting library providing common functions to +test helper libraries written for [Bats][bats]. + +Features: +- [error reporting](#error-reporting) +- [output formatting](#output-formatting) +- [language tools](#language-and-execution) + +See the [shared documentation][bats-docs] to learn how to install and +load this library. + +If you want to use this library in your own helpers or just want to +learn about its internals see the developer documentation in the [source +files](src). + + +## Error reporting + +### `fail` + +Display an error message and fail. This function provides a convenient +way to report failure in arbitrary situations. You can use it to +implement your own helpers when the ones available do not meet your +needs. Other functions use it internally as well. + +```bash +@test 'fail()' { + fail 'this test always fails' +} +``` + +The message can also be specified on the standard input. + +```bash +@test 'fail() with pipe' { + echo 'this test always fails' | fail +} +``` + +This function always fails and simply outputs the given message. + +``` +this test always fails +``` + + +## Output formatting + +Many test helpers need to produce human readable output. This library +provides a simple way to format simple messages and key value pairs, and +display them on the standard error. + + +### Simple message + +Simple messages without structure, e.g. one-line error messages, are +simply wrapped in a header and a footer to help them stand out. + +``` +-- ERROR: assert_output -- +`--partial' and `--regexp' are mutually exclusive +-- +``` + + +### Key-Value pairs + +Some helpers, e.g. [assertions][bats-assert], structure output as +key-value pairs. This library provides two ways to format them. + +When the value is one line long, a pair can be displayed in a columnar +fashion called ***two-column*** format. + +``` +-- output differs -- +expected : want +actual : have +-- +``` + +When the value is longer than one line, the key and value must be +displayed on separate lines. First, the key is displayed along with the +number of lines in the value. Then, the value, indented by two spaces +for added readability, starting on the next line. This is called +***multi-line*** format. + +``` +-- command failed -- +status : 1 +output (2 lines): + Error! Something went terribly wrong! + Our engineers are panicing... \`>`;/ +-- +``` + +Sometimes, for clarity, it is a good idea to display related values also +in this format, even if they are just one line long. + +``` +-- output differs -- +expected (1 lines): + want +actual (3 lines): + have 1 + have 2 + have 3 +-- +``` + +## Language and Execution + +### Restricting invocation to specific locations + +Sometimes a helper may work properly only when called from a certain +location. Because it depends on variables to be set or some other side +effect. + +A good example is cleaning up temporary files only if the test has +succeeded. The outcome of a test is only available in `teardown`. Thus, +to avoid programming mistakes, it makes sense to restrict such a +clean-up helper to that function. + +`batslib_is_caller` checks the call stack and returns `0` if the caller +was invoked from a given function, and `1` otherwise. This function +becomes really useful with the `--indirect` option, which allows calls +through intermediate functions, e.g. the calling function may be called +from a function that was called from the given function. + +Staying with the example above, the following code snippet implements a +helper that is restricted to `teardown` or any function called +indirectly from it. + +```shell +clean_up() { + # Check caller. + if batslib_is_caller --indirect 'teardown'; then + echo "Must be called from \`teardown'" \ + | batslib_decorate 'ERROR: clean_up' \ + | fail + return $? + fi + + # Body goes here... +} +``` + +In some cases a helper may be called from multiple locations. For +example, a logging function that uses the test name, description or +number, information only available in `setup`, `@test` or `teardown`, to +distinguish entries. The following snippet implements this restriction. + +```shell +log_test() { + # Check caller. + if ! ( batslib_is_caller --indirect 'setup' \ + || batslib_is_caller --indirect "$BATS_TEST_NAME" \ + || batslib_is_caller --indirect 'teardown' ) + then + echo "Must be called from \`setup', \`@test' or \`teardown'" \ + | batslib_decorate 'ERROR: log_test' \ + | fail + return $? + fi + + # Body goes here... +} +``` + + + + +[bats]: https://github.com/sstephenson/bats +[bats-docs]: https://github.com/ztombol/bats-docs +[bats-assert]: https://github.com/ztombol/bats-assert diff --git a/e2e/libs/bats-support/load.bash b/e2e/libs/bats-support/load.bash new file mode 100644 index 00000000..0727aeba --- /dev/null +++ b/e2e/libs/bats-support/load.bash @@ -0,0 +1,3 @@ +source "$(dirname "${BASH_SOURCE[0]}")/src/output.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/error.bash" +source "$(dirname "${BASH_SOURCE[0]}")/src/lang.bash" diff --git a/e2e/libs/bats-support/package.json b/e2e/libs/bats-support/package.json new file mode 100644 index 00000000..50156877 --- /dev/null +++ b/e2e/libs/bats-support/package.json @@ -0,0 +1,30 @@ +{ + "name": "bats-support", + "version": "0.3.0", + "description": "Supporting library for Bats test helpers", + "homepage": "https://github.com/jasonkarns/bats-support", + "license": "CC0-1.0", + "author": "Zoltán Tömböl (https://github.com/ztombol)", + "contributors": [ + "Jason Karns (http://jason.karns.name)" + ], + "repository": "github:jasonkarns/bats-support", + "bugs": "https://github.com/jasonkarns/bats-support/issues", + "directories": { + "lib": "src", + "test": "test" + }, + "files": [ + "load.bash", + "src" + ], + "scripts": { + "test": "bats ${CI+-t} test" + }, + "devDependencies": { + "bats": "^1" + }, + "peerDependencies": { + "bats": "0.4 || ^1" + } +} diff --git a/e2e/libs/bats-support/src/error.bash b/e2e/libs/bats-support/src/error.bash new file mode 100644 index 00000000..e5d97912 --- /dev/null +++ b/e2e/libs/bats-support/src/error.bash @@ -0,0 +1,41 @@ +# +# bats-support - Supporting library for Bats test helpers +# +# Written in 2016 by Zoltan Tombol +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication +# along with this software. If not, see +# . +# + +# +# error.bash +# ---------- +# +# Functions implementing error reporting. Used by public helper +# functions or test suits directly. +# + +# Fail and display a message. When no parameters are specified, the +# message is read from the standard input. Other functions use this to +# report failure. +# +# Globals: +# none +# Arguments: +# $@ - [=STDIN] message +# Returns: +# 1 - always +# Inputs: +# STDIN - [=$@] message +# Outputs: +# STDERR - message +fail() { + (( $# == 0 )) && batslib_err || batslib_err "$@" + return 1 +} diff --git a/e2e/libs/bats-support/src/lang.bash b/e2e/libs/bats-support/src/lang.bash new file mode 100644 index 00000000..c57e299c --- /dev/null +++ b/e2e/libs/bats-support/src/lang.bash @@ -0,0 +1,73 @@ +# +# bats-util - Various auxiliary functions for Bats +# +# Written in 2016 by Zoltan Tombol +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication +# along with this software. If not, see +# . +# + +# +# lang.bash +# --------- +# +# Bash language and execution related functions. Used by public helper +# functions. +# + +# Check whether the calling function was called from a given function. +# +# By default, direct invocation is checked. The function succeeds if the +# calling function was called directly from the given function. In other +# words, if the given function is the next element on the call stack. +# +# When `--indirect' is specified, indirect invocation is checked. The +# function succeeds if the calling function was called from the given +# function with any number of intermediate calls. In other words, if the +# given function can be found somewhere on the call stack. +# +# Direct invocation is a form of indirect invocation with zero +# intermediate calls. +# +# Globals: +# FUNCNAME +# Options: +# -i, --indirect - check indirect invocation +# Arguments: +# $1 - calling function's name +# Returns: +# 0 - current function was called from the given function +# 1 - otherwise +batslib_is_caller() { + local -i is_mode_direct=1 + + # Handle options. + while (( $# > 0 )); do + case "$1" in + -i|--indirect) is_mode_direct=0; shift ;; + --) shift; break ;; + *) break ;; + esac + done + + # Arguments. + local -r func="$1" + + # Check call stack. + if (( is_mode_direct )); then + [[ $func == "${FUNCNAME[2]}" ]] && return 0 + else + local -i depth + for (( depth=2; depth<${#FUNCNAME[@]}; ++depth )); do + [[ $func == "${FUNCNAME[$depth]}" ]] && return 0 + done + fi + + return 1 +} diff --git a/e2e/libs/bats-support/src/output.bash b/e2e/libs/bats-support/src/output.bash new file mode 100644 index 00000000..c6cf6a6b --- /dev/null +++ b/e2e/libs/bats-support/src/output.bash @@ -0,0 +1,279 @@ +# +# bats-support - Supporting library for Bats test helpers +# +# Written in 2016 by Zoltan Tombol +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. +# +# You should have received a copy of the CC0 Public Domain Dedication +# along with this software. If not, see +# . +# + +# +# output.bash +# ----------- +# +# Private functions implementing output formatting. Used by public +# helper functions. +# + +# Print a message to the standard error. When no parameters are +# specified, the message is read from the standard input. +# +# Globals: +# none +# Arguments: +# $@ - [=STDIN] message +# Returns: +# none +# Inputs: +# STDIN - [=$@] message +# Outputs: +# STDERR - message +batslib_err() { + { if (( $# > 0 )); then + echo "$@" + else + cat - + fi + } >&2 +} + +# Count the number of lines in the given string. +# +# TODO(ztombol): Fix tests and remove this note after #93 is resolved! +# NOTE: Due to a bug in Bats, `batslib_count_lines "$output"' does not +# give the same result as `${#lines[@]}' when the output contains +# empty lines. +# See PR #93 (https://github.com/sstephenson/bats/pull/93). +# +# Globals: +# none +# Arguments: +# $1 - string +# Returns: +# none +# Outputs: +# STDOUT - number of lines +batslib_count_lines() { + local -i n_lines=0 + local line + while IFS='' read -r line || [[ -n $line ]]; do + (( ++n_lines )) + done < <(printf '%s' "$1") + echo "$n_lines" +} + +# Determine whether all strings are single-line. +# +# Globals: +# none +# Arguments: +# $@ - strings +# Returns: +# 0 - all strings are single-line +# 1 - otherwise +batslib_is_single_line() { + for string in "$@"; do + (( $(batslib_count_lines "$string") > 1 )) && return 1 + done + return 0 +} + +# Determine the length of the longest key that has a single-line value. +# +# This function is useful in determining the correct width of the key +# column in two-column format when some keys may have multi-line values +# and thus should be excluded. +# +# Globals: +# none +# Arguments: +# $odd - key +# $even - value of the previous key +# Returns: +# none +# Outputs: +# STDOUT - length of longest key +batslib_get_max_single_line_key_width() { + local -i max_len=-1 + while (( $# != 0 )); do + local -i key_len="${#1}" + batslib_is_single_line "$2" && (( key_len > max_len )) && max_len="$key_len" + shift 2 + done + echo "$max_len" +} + +# Print key-value pairs in two-column format. +# +# Keys are displayed in the first column, and their corresponding values +# in the second. To evenly line up values, the key column is fixed-width +# and its width is specified with the first parameter (possibly computed +# using `batslib_get_max_single_line_key_width'). +# +# Globals: +# none +# Arguments: +# $1 - width of key column +# $even - key +# $odd - value of the previous key +# Returns: +# none +# Outputs: +# STDOUT - formatted key-value pairs +batslib_print_kv_single() { + local -ir col_width="$1"; shift + while (( $# != 0 )); do + printf '%-*s : %s\n' "$col_width" "$1" "$2" + shift 2 + done +} + +# Print key-value pairs in multi-line format. +# +# The key is displayed first with the number of lines of its +# corresponding value in parenthesis. Next, starting on the next line, +# the value is displayed. For better readability, it is recommended to +# indent values using `batslib_prefix'. +# +# Globals: +# none +# Arguments: +# $odd - key +# $even - value of the previous key +# Returns: +# none +# Outputs: +# STDOUT - formatted key-value pairs +batslib_print_kv_multi() { + while (( $# != 0 )); do + printf '%s (%d lines):\n' "$1" "$( batslib_count_lines "$2" )" + printf '%s\n' "$2" + shift 2 + done +} + +# Print all key-value pairs in either two-column or multi-line format +# depending on whether all values are single-line. +# +# If all values are single-line, print all pairs in two-column format +# with the specified key column width (identical to using +# `batslib_print_kv_single'). +# +# Otherwise, print all pairs in multi-line format after indenting values +# with two spaces for readability (identical to using `batslib_prefix' +# and `batslib_print_kv_multi') +# +# Globals: +# none +# Arguments: +# $1 - width of key column (for two-column format) +# $even - key +# $odd - value of the previous key +# Returns: +# none +# Outputs: +# STDOUT - formatted key-value pairs +batslib_print_kv_single_or_multi() { + local -ir width="$1"; shift + local -a pairs=( "$@" ) + + local -a values=() + local -i i + for (( i=1; i < ${#pairs[@]}; i+=2 )); do + values+=( "${pairs[$i]}" ) + done + + if batslib_is_single_line "${values[@]}"; then + batslib_print_kv_single "$width" "${pairs[@]}" + else + local -i i + for (( i=1; i < ${#pairs[@]}; i+=2 )); do + pairs[$i]="$( batslib_prefix < <(printf '%s' "${pairs[$i]}") )" + done + batslib_print_kv_multi "${pairs[@]}" + fi +} + +# Prefix each line read from the standard input with the given string. +# +# Globals: +# none +# Arguments: +# $1 - [= ] prefix string +# Returns: +# none +# Inputs: +# STDIN - lines +# Outputs: +# STDOUT - prefixed lines +batslib_prefix() { + local -r prefix="${1:- }" + local line + while IFS='' read -r line || [[ -n $line ]]; do + printf '%s%s\n' "$prefix" "$line" + done +} + +# Mark select lines of the text read from the standard input by +# overwriting their beginning with the given string. +# +# Usually the input is indented by a few spaces using `batslib_prefix' +# first. +# +# Globals: +# none +# Arguments: +# $1 - marking string +# $@ - indices (zero-based) of lines to mark +# Returns: +# none +# Inputs: +# STDIN - lines +# Outputs: +# STDOUT - lines after marking +batslib_mark() { + local -r symbol="$1"; shift + # Sort line numbers. + set -- $( sort -nu <<< "$( printf '%d\n' "$@" )" ) + + local line + local -i idx=0 + while IFS='' read -r line || [[ -n $line ]]; do + if (( ${1:--1} == idx )); then + printf '%s\n' "${symbol}${line:${#symbol}}" + shift + else + printf '%s\n' "$line" + fi + (( ++idx )) + done +} + +# Enclose the input text in header and footer lines. +# +# The header contains the given string as title. The output is preceded +# and followed by an additional newline to make it stand out more. +# +# Globals: +# none +# Arguments: +# $1 - title +# Returns: +# none +# Inputs: +# STDIN - text +# Outputs: +# STDOUT - decorated text +batslib_decorate() { + echo + echo "-- $1 --" + cat - + echo '--' + echo +} diff --git a/e2e/libs/bats-support/test/50-output-10-batslib_err.bats b/e2e/libs/bats-support/test/50-output-10-batslib_err.bats new file mode 100755 index 00000000..8c27fd12 --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-10-batslib_err.bats @@ -0,0 +1,16 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_err() : displays ' { + run batslib_err 'm1' 'm2' + [ "$status" -eq 0 ] + [ "$output" == 'm1 m2' ] +} + +@test 'batslib_err(): reads from STDIN' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + echo 'm1' 'm2' | batslib_err" + [ "$status" -eq 0 ] + [ "$output" == 'm1 m2' ] +} diff --git a/e2e/libs/bats-support/test/50-output-11-batslib_count_lines.bats b/e2e/libs/bats-support/test/50-output-11-batslib_count_lines.bats new file mode 100755 index 00000000..ea172c3e --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-11-batslib_count_lines.bats @@ -0,0 +1,21 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_count_lines() : displays the number of lines in ' { + run batslib_count_lines $'a\nb\nc\n' + [ "$status" -eq 0 ] + [ "$output" == '3' ] +} + +@test 'batslib_count_lines() : counts the last line when it is not terminated by a newline' { + run batslib_count_lines $'a\nb\nc' + [ "$status" -eq 0 ] + [ "$output" == '3' ] +} + +@test 'batslib_count_lines() : counts empty lines' { + run batslib_count_lines $'\n\n\n' + [ "$status" -eq 0 ] + [ "$output" == '3' ] +} diff --git a/e2e/libs/bats-support/test/50-output-12-batslib_is_single_line.bats b/e2e/libs/bats-support/test/50-output-12-batslib_is_single_line.bats new file mode 100755 index 00000000..484b64da --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-12-batslib_is_single_line.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_is_single_line() : returns 0 if all are single-line' { + run batslib_is_single_line 'a' $'b\n' 'c' + [ "$status" -eq 0 ] +} + +@test 'batslib_is_single_line() : returns 1 if at least one of is longer than one line' { + run batslib_is_single_line 'a' $'b\nb' 'c' + [ "$status" -eq 1 ] +} diff --git a/e2e/libs/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats b/e2e/libs/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats new file mode 100755 index 00000000..e6af161f --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-13-batslib_get_max_single_line_key_width.bats @@ -0,0 +1,21 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_get_max_single_line_key_width() : displays the length of the longest key' { + local -ar pairs=( 'k _1' 'v 1' + 'k 2' 'v 2' + 'k __3' 'v 3' ) + run batslib_get_max_single_line_key_width "${pairs[@]}" + [ "$status" -eq 0 ] + [ "$output" == '5' ] +} + +@test 'batslib_get_max_single_line_key_width() : only considers keys with single-line values' { + local -ar pairs=( 'k _1' 'v 1' + 'k 2' 'v 2' + 'k __3' $'v\n3' ) + run batslib_get_max_single_line_key_width "${pairs[@]}" + [ "$status" -eq 0 ] + [ "$output" == '4' ] +} diff --git a/e2e/libs/bats-support/test/50-output-14-batslib_print_kv_single.bats b/e2e/libs/bats-support/test/50-output-14-batslib_print_kv_single.bats new file mode 100755 index 00000000..7637897c --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-14-batslib_print_kv_single.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_print_kv_single() : displays in two-column format with wide key column' { + local -ar pairs=( 'k _1' 'v 1' + 'k 2 ' 'v 2' + 'k __3' 'v 3' ) + run batslib_print_kv_single 5 "${pairs[@]}" + [ "$status" -eq 0 ] + [ "${#lines[@]}" == '3' ] + [ "${lines[0]}" == 'k _1 : v 1' ] + [ "${lines[1]}" == 'k 2 : v 2' ] + [ "${lines[2]}" == 'k __3 : v 3' ] +} + +@test 'batslib_print_kv_single() : does not truncate keys when the column is too narrow' { + local -ar pairs=( 'k _1' 'v 1' + 'k 2' 'v 2' + 'k __3' 'v 3' ) + run batslib_print_kv_single 0 "${pairs[@]}" + [ "$status" -eq 0 ] + [ "${#lines[@]}" == '3' ] + [ "${lines[0]}" == 'k _1 : v 1' ] + [ "${lines[1]}" == 'k 2 : v 2' ] + [ "${lines[2]}" == 'k __3 : v 3' ] +} diff --git a/e2e/libs/bats-support/test/50-output-15-batslib_print_kv_multi.bats b/e2e/libs/bats-support/test/50-output-15-batslib_print_kv_multi.bats new file mode 100755 index 00000000..6ad4b3db --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-15-batslib_print_kv_multi.bats @@ -0,0 +1,19 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_print_kv_multi() : displays in multi-line format' { + local -ar pairs=( 'k _1' 'v 1' + 'k 2' $'v 2-1\nv 2-2' + 'k __3' 'v 3' ) + run batslib_print_kv_multi "${pairs[@]}" + [ "$status" -eq 0 ] + [ "${#lines[@]}" == '7' ] + [ "${lines[0]}" == 'k _1 (1 lines):' ] + [ "${lines[1]}" == 'v 1' ] + [ "${lines[2]}" == 'k 2 (2 lines):' ] + [ "${lines[3]}" == 'v 2-1' ] + [ "${lines[4]}" == 'v 2-2' ] + [ "${lines[5]}" == 'k __3 (1 lines):' ] + [ "${lines[6]}" == 'v 3' ] +} diff --git a/e2e/libs/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats b/e2e/libs/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats new file mode 100755 index 00000000..c20d1017 --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-16-batslib_print_kv_single_or_multi.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_print_kv_single_or_multi() : displays in two-column format if all values are one line long' { + local -ar pairs=( 'k _1' 'v 1' + 'k 2 ' 'v 2' + 'k __3' 'v 3' ) + run batslib_print_kv_single_or_multi 5 "${pairs[@]}" + [ "$status" -eq 0 ] + [ "${#lines[@]}" == '3' ] + [ "${lines[0]}" == 'k _1 : v 1' ] + [ "${lines[1]}" == 'k 2 : v 2' ] + [ "${lines[2]}" == 'k __3 : v 3' ] +} + +@test 'batslib_print_kv_single_or_multi() : displays in multi-line format if at least one value is longer than one line' { + local -ar pairs=( 'k _1' 'v 1' + 'k 2' $'v 2-1\nv 2-2' + 'k __3' 'v 3' ) + run batslib_print_kv_single_or_multi 5 "${pairs[@]}" + [ "$status" -eq 0 ] + [ "${#lines[@]}" == '7' ] + [ "${lines[0]}" == 'k _1 (1 lines):' ] + [ "${lines[1]}" == ' v 1' ] + [ "${lines[2]}" == 'k 2 (2 lines):' ] + [ "${lines[3]}" == ' v 2-1' ] + [ "${lines[4]}" == ' v 2-2' ] + [ "${lines[5]}" == 'k __3 (1 lines):' ] + [ "${lines[6]}" == ' v 3' ] +} diff --git a/e2e/libs/bats-support/test/50-output-17-batslib_prefix.bats b/e2e/libs/bats-support/test/50-output-17-batslib_prefix.bats new file mode 100755 index 00000000..817fd334 --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-17-batslib_prefix.bats @@ -0,0 +1,43 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_prefix() : prefixes each line of the input with ' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf 'a\nb\nc\n' | batslib_prefix '_'" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == '_a' ] + [ "${lines[1]}" == '_b' ] + [ "${lines[2]}" == '_c' ] +} + +@test 'batslib_prefix() : prefixes the last line when it is not terminated by a newline' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf 'a\nb\nc' | batslib_prefix '_'" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == '_a' ] + [ "${lines[1]}" == '_b' ] + [ "${lines[2]}" == '_c' ] +} + +@test 'batslib_prefix() : prefixes empty lines' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf '\n\n\n' | batslib_prefix '_'" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == '_' ] + [ "${lines[1]}" == '_' ] + [ "${lines[2]}" == '_' ] +} + +@test 'batslib_prefix(): default to two spaces' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf 'a\nb\nc\n' | batslib_prefix" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == ' a' ] + [ "${lines[1]}" == ' b' ] + [ "${lines[2]}" == ' c' ] +} diff --git a/e2e/libs/bats-support/test/50-output-18-batslib_mark.bats b/e2e/libs/bats-support/test/50-output-18-batslib_mark.bats new file mode 100755 index 00000000..c5d0975d --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-18-batslib_mark.bats @@ -0,0 +1,72 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_mark() : marks the -th line of the input with ' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf ' a\n b\n c\n' | batslib_mark '>' 0" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == '>a' ] + [ "${lines[1]}" == ' b' ] + [ "${lines[2]}" == ' c' ] +} + +@test 'batslib_mark() : marks multiple lines when is in ascending order' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf ' a\n b\n c\n' | batslib_mark '>' 1 2" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == ' a' ] + [ "${lines[1]}" == '>b' ] + [ "${lines[2]}" == '>c' ] +} + +@test 'batslib_mark() : marks multiple lines when is in random order' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf ' a\n b\n c\n d\n' | batslib_mark '>' 2 1 3" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 4 ] + [ "${lines[0]}" == ' a' ] + [ "${lines[1]}" == '>b' ] + [ "${lines[2]}" == '>c' ] + [ "${lines[3]}" == '>d' ] +} + +@test 'batslib_mark() : ignores duplicate indices' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf ' a\n b\n c\n' | batslib_mark '>' 1 2 1" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == ' a' ] + [ "${lines[1]}" == '>b' ] + [ "${lines[2]}" == '>c' ] +} + +@test 'batslib_mark() : outputs the input untouched if is the empty string' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf ' a\n b\n c\n' | batslib_mark '' 1" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == ' a' ] + [ "${lines[1]}" == ' b' ] + [ "${lines[2]}" == ' c' ] +} + +@test 'batslib_mark() : marks the last line when it is not terminated by a newline' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf ' a\n b\n c' | batslib_mark '>' 2" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == ' a' ] + [ "${lines[1]}" == ' b' ] + [ "${lines[2]}" == '>c' ] +} + +@test 'batslib_mark() : does not truncate if it is longer than the marked line' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + printf '\n' | batslib_mark '>' 0" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 1 ] + [ "${lines[0]}" == '>' ] +} diff --git a/e2e/libs/bats-support/test/50-output-19-batslib_decorate.bats b/e2e/libs/bats-support/test/50-output-19-batslib_decorate.bats new file mode 100755 index 00000000..02d55add --- /dev/null +++ b/e2e/libs/bats-support/test/50-output-19-batslib_decorate.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'batslib_decorate() : encloses the input in a footer line and a header line containing <title>' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + echo 'body' | batslib_decorate 'title'" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [ "${lines[0]}" == '-- title --' ] + [ "${lines[1]}" == 'body' ] + [ "${lines[2]}" == '--' ] +} diff --git a/e2e/libs/bats-support/test/51-error-10-fail.bats b/e2e/libs/bats-support/test/51-error-10-fail.bats new file mode 100755 index 00000000..1d8691a3 --- /dev/null +++ b/e2e/libs/bats-support/test/51-error-10-fail.bats @@ -0,0 +1,16 @@ +#!/usr/bin/env bats + +load test_helper + +@test 'fail() <message>: returns 1 and displays <message>' { + run fail 'message' + [ "$status" -eq 1 ] + [ "$output" == 'message' ] +} + +@test 'fail(): reads <message> from STDIN' { + run bash -c "source '${TEST_MAIN_DIR}/load.bash' + echo 'message' | fail" + [ "$status" -eq 1 ] + [ "$output" == 'message' ] +} diff --git a/e2e/libs/bats-support/test/52-lang-10-batslib_is_caller.bats b/e2e/libs/bats-support/test/52-lang-10-batslib_is_caller.bats new file mode 100755 index 00000000..68fd59b3 --- /dev/null +++ b/e2e/libs/bats-support/test/52-lang-10-batslib_is_caller.bats @@ -0,0 +1,88 @@ +#!/usr/bin/env bats + +load 'test_helper' + + +# Test functions +test_func_lvl_2() { + test_func_lvl_1 "$@" +} + +test_func_lvl_1() { + test_func_lvl_0 "$@" +} + +test_func_lvl_0() { + batslib_is_caller "$@" +} + + +# +# Direct invocation +# + +# Interface +@test 'batslib_is_caller() <function>: returns 0 if the current function was called directly from <function>' { + run test_func_lvl_1 test_func_lvl_1 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 0 ] +} + +@test 'batslib_is_caller() <function>: returns 1 if the current function was not called directly from <function>' { + run test_func_lvl_0 test_func_lvl_1 + [ "$status" -eq 1 ] + [ "${#lines[@]}" -eq 0 ] +} + +# Correctness +@test 'batslib_is_caller() <function>: the current function does not appear on the call stack' { + run test_func_lvl_0 test_func_lvl_0 + [ "$status" -eq 1 ] + [ "${#lines[@]}" -eq 0 ] +} + + +# +# Indirect invocation +# + +# Options +test_i_indirect() { + run test_func_lvl_2 "$@" + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 0 ] +} + +@test 'batslib_is_caller() -i <function>: enables indirect checking' { + test_i_indirect -i test_func_lvl_2 +} + +@test 'batslib_is_caller() --indirect <function>: enables indirect checking' { + test_i_indirect --indirect test_func_lvl_2 +} + +# Interface +@test 'batslib_is_caller() --indirect <function>: returns 0 if the current function was called indirectly from <function>' { + run test_func_lvl_2 --indirect test_func_lvl_2 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 0 ] +} + +@test 'batslib_is_caller() --indirect <function>: returns 1 if the current function was not called indirectly from <function>' { + run test_func_lvl_1 --indirect test_func_lvl_2 + [ "$status" -eq 1 ] + [ "${#lines[@]}" -eq 0 ] +} + +# Correctness +@test 'batslib_is_caller() --indirect <function>: direct invocation is a special case of indirect invocation with zero intermediate calls' { + run test_func_lvl_1 --indirect test_func_lvl_1 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 0 ] +} + +@test 'batslib_is_caller() --indirect <function>: the current function does not appear on the call stack' { + run test_func_lvl_0 --indirect test_func_lvl_0 + [ "$status" -eq 1 ] + [ "${#lines[@]}" -eq 0 ] +} diff --git a/e2e/libs/bats-support/test/test_helper.bash b/e2e/libs/bats-support/test/test_helper.bash new file mode 100644 index 00000000..ca16775b --- /dev/null +++ b/e2e/libs/bats-support/test/test_helper.bash @@ -0,0 +1,6 @@ +setup() { + export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." + + # Load library. + load '../load' +} diff --git a/e2e/libs/cleanup.bash b/e2e/libs/cleanup.bash new file mode 100644 index 00000000..312b6b0c --- /dev/null +++ b/e2e/libs/cleanup.bash @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# Copyright 2019 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +function cleanup() { + echo ">>> Stopping ${1} docker container" + docker stop "$1" > /dev/null + docker rm "$1" > /dev/null + + echo ">>> Removing docker network $DOCKER_NETWORK" + docker network rm "$DOCKER_NETWORK" >/dev/null +} diff --git a/e2e/libs/dataplaneapi.bash b/e2e/libs/dataplaneapi.bash new file mode 100644 index 00000000..b6d8d58a --- /dev/null +++ b/e2e/libs/dataplaneapi.bash @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +# +# Copyright 2020 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/bats-support/load' +load '../../libs/bats-assert/load' + +# dpa_curl is going to return the response status code along with the body +# these values can be easily read as following +# +# read -r SC BODY < <(api GET /services/haproxy/runtime/info) +# echo "Status Code: ${SC}" +# echo "Body: ${BODY}" +# +# Arguments: +# - HTTP verb +# - original URL +# - HTTP POST data +function dpa_curl() { + verb=$1; shift + endpoint=$1; shift + data="@${BATS_TEST_DIRNAME}/$1"; + if [ -z "$1" ]; then + data="/dev/null" + fi + curl -m 10 -s -H 'content-type: application/json' --user dataplaneapi:mypassword "-X${verb}" -w "\n%{http_code}" "-d${data}" "http://${LOCAL_IP_ADDRESS}:${E2E_PORT}${BASE_PATH}${endpoint}" +} + +# dpa_curl_text_plain behaves in same manner as api, but uses content-type: text/plain +function dpa_curl_text_plain() { + verb=$1; shift + endpoint=$1; shift + data=${1:-"/dev/null"} + curl -m 10 -s -H 'content-type: text/plain' --user dataplaneapi:mypassword "-X${verb}" -w "\n%{http_code}" --data-binary "${data}" "http://${LOCAL_IP_ADDRESS}:${E2E_PORT}${BASE_PATH}${endpoint}" +} + +function dpa_curl_file_upload() { + verb=$1; shift + endpoint=$1; shift + data=${1:-"/dev/null"} + curl -m 10 -s -H "Content-type: multipart/form-data" --user dataplaneapi:mypassword "-X${verb}" -w "\n%{http_code}" --form "file_upload=${data}" "http://${LOCAL_IP_ADDRESS}:${E2E_PORT}${BASE_PATH}${endpoint}" +} + +# function dpa_curl_download returns values differently to allow for multiline body contents, it should be used as follows: +# local BODY; +# local SC; +# dpa_curl_download GET "/services/haproxy/storage/maps/mapfile_example.map" +# echo "Status Code: ${SC}" +# echo "Body: ${BODY}" +function dpa_curl_download() { + verb=$1; shift + endpoint=$1; shift + data=${1:-"/dev/null"} + curl -m 10 -v -s -H 'content-type: application/json' --user dataplaneapi:mypassword "-X${verb}" -w "\n%{http_code}" "-d${data}" "http://${LOCAL_IP_ADDRESS}:${E2E_PORT}${BASE_PATH}${endpoint}" 2>/tmp/headers +} + +# extracts the resulting http status code and body from dpa_curl_* functions into variables +# note: will not work properly if body contains ' characters +function dpa_curl_status_body() { + eval response=$1 + assert [ ! -z "$response" ] + echo "> dpa_curl_status_body argument is" + echo "$response" + status_code=$(tail -n1 <<< "$response") + body=$(head -n -1 <<< "$response") + eval SC="'$status_code'" + eval BODY="'$body'" +} + +# behaves like dpa_curl_status_body but handles ' in contents safely +function dpa_curl_status_body_safe() { + eval response=$1 + assert [ ! -z "$response" ] + echo "> dpa_curl_status_body argument is" + echo "$response" + status_code=$(tail -n1 <<< "$response") + body=$(head -n -1 <<< "$response" | sed -e "s/'//g") + eval SC="'$status_code'" + eval BODY="'$body'" +} + +# compare contents of a variable and a local file with diff +function dpa_diff_var_file() { + eval arg1=$1 + eval arg2=$2 + echo "> dpa_diff_var_file arg1 is $arg1" + echo "> dpa_diff_var_file arg2 is $arg2" + diff <(echo -e "${arg1}") "${BATS_TEST_DIRNAME}/${arg2}" +} + +function dpa_docker_exec() { + docker exec "${DOCKER_CONTAINER_NAME}" sh -c "$@" +} + +# compare contents of a file in docker container and a local file with diff +function dpa_diff_docker_file() { + eval arg1=$1 + eval arg2=$2 + echo "> dpa_diff_docker_file arg1 is $arg1" + echo "> dpa_diff_docker_file arg2 is $arg2" + diff <(dpa_docker_exec "cat ${arg1}") "${BATS_TEST_DIRNAME}/${arg2}" +} + +# version return the current HAProxy configuration file version, useful to +# avoid keeping track of it at each POST/PUT call. +# +# Any argument is required. +# +# Example: +# version +# >>> 10 +function version() { + read -r SC RES < <(dpa_curl GET "/services/haproxy/configuration/global") + V="$(RES=${RES} jq -n 'env.RES | fromjson | ._version')" + echo "$V" +} diff --git a/e2e/libs/debug.bash b/e2e/libs/debug.bash new file mode 100644 index 00000000..1ca18f18 --- /dev/null +++ b/e2e/libs/debug.bash @@ -0,0 +1,27 @@ + +#!/usr/bin/env bash +# +# Copyright 2020 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# debug function prints out debug statements, which makes it easier to +# debug failing tests. +# +# Example: +# debug "I am here" +# >>> ### DEBUG I am here +function debug() { + echo "### DEBUG $@" >&3 +} diff --git a/e2e/libs/get_json_path.bash b/e2e/libs/get_json_path.bash new file mode 100644 index 00000000..9bfd0054 --- /dev/null +++ b/e2e/libs/get_json_path.bash @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Copyright 2019 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# get_json_path is a tiny wrapper to return content of a JSON from a variable. +# In case of missing +# +# Arguments: +# 1. the raw JSON +# 2. the JSON path according to jq syntax +# +# Example: +# get_json_path '[{"sites": [{"name": "foo"}, {"name": "bar"}]}]' '.[0].sites[1].name' +# >>> bar +function get_json_path() { + local body path + body=${1} + path=${2} + + echo "$(JSON=${body} jq -rn "env.JSON | fromjson | ${path}")" +} diff --git a/e2e/libs/haproxy_config_setup.bash b/e2e/libs/haproxy_config_setup.bash new file mode 100644 index 00000000..2c988246 --- /dev/null +++ b/e2e/libs/haproxy_config_setup.bash @@ -0,0 +1,142 @@ +#!/usr/bin/env bash +# +# Copyright 2020 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# NOTE: in order to use this haproxy.cfg must be created in data test folder + +# setup puts configuration from test folder as the one active in dataplane +setup() { + + # allow for running just one test in a directory + if [[ -n $TESTNUMBER ]] && [[ "$BATS_TEST_NUMBER" -ne $TESTNUMBER ]]; then + skip + fi + + if [[ -n "$TESTDESCRIPTION" ]] && [[ "$BATS_TEST_DESCRIPTION" != "$TESTDESCRIPTION" ]]; then + skip + fi + + # replace the default haproxy config file + local haproxy_cfg_file="${BATS_TEST_DIRNAME}/data/haproxy_*.cfg" + local haproxy_file_version="" + local copy_haproxy_file=true + + if ls $haproxy_cfg_file 1> /dev/null 2>&1; then + haproxy_file_version=$(echo $haproxy_cfg_file | sed 's/.*_\([0-9]\+\.[0-9]\+\)\.cfg/\1/') + major_file_version=$(echo $haproxy_file_version | cut -d '.' -f 1) + minor_file_version=$(echo $haproxy_file_version | cut -d '.' -f 2) + major_cfg_version=$(echo $HAPROXY_VERSION | cut -d '.' -f 1) + minor_cfg_version=$(echo $HAPROXY_VERSION | cut -d '.' -f 2) + if [[ -f "${BATS_TEST_DIRNAME}/data/haproxy_${haproxy_file_version}.cfg" ]] ; then + if [[ $major_cfg_version -eq $major_file_version && $minor_cfg_version -ge $minor_file_version || $major_cfg_version -gt $major_file_version ]] ; then + run docker cp "${BATS_TEST_DIRNAME}/data/haproxy_${haproxy_file_version}.cfg" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg" + copy_haproxy_file=false + assert_success + fi + fi + fi + + if [[ "$copy_haproxy_file" = true ]] ; then + if [ -f "${BATS_TEST_DIRNAME}/data/haproxy.cfg" ]; then + run docker cp "${BATS_TEST_DIRNAME}/data/haproxy.cfg" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg" + assert_success + else + run docker cp "${E2E_DIR}/fixtures/haproxy.cfg" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg" + assert_success + fi + fi + + # replace the default dataplaneapi config file + if [ -f "${BATS_TEST_DIRNAME}/dataplaneapi.yaml" ]; then + run docker cp "${BATS_TEST_DIRNAME}/dataplaneapi.yaml" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplaneapi.yaml" + else + # TODO: we should respect $VARIANT here + run docker cp "${E2E_DIR}/fixtures/dataplaneapi.yaml" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplaneapi.yaml" + fi + assert_success + + if [ -d "${BATS_TEST_DIRNAME}/data/container" ]; then + run docker cp "${BATS_TEST_DIRNAME}/data/container/." "${DOCKER_CONTAINER_NAME}:/" + assert_success + fi + + run dpa_docker_exec 'kill -s 12 1' + assert_success + + if [ -z "$DONT_RESTART_DPAPI" ]; then + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + if [ -x "${BATS_TEST_DIRNAME}/custom_dataplane_launch.sh" ]; then + run "${BATS_TEST_DIRNAME}/custom_dataplane_launch.sh" + else + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + fi + assert_success + fi + + local restart_retry_count=0 + + until dpa_curl GET "/info"; do + # 5 seconds wait + if [[ restart_retry_count -eq 50 ]]; then + echo -e "\nerror restarting: no response from dataplane on /info" + echo -e "\nhaproxy stderr:" + docker logs -n 42 ${DOCKER_CONTAINER_NAME} + echo -e "\ndataplane log output:" + docker exec ${DOCKER_CONTAINER_NAME} sh -c "tail -n 42 /var/log/dataplaneapi.log" + exit 1 + fi + + sleep 0.1 + restart_retry_count=$((restart_retry_count+1)) + done +} + +# teardown returns original configuration to dataplane +teardown() { + run docker cp "${E2E_DIR}/fixtures/haproxy.cfg" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg" + assert_success + + run docker cp "${E2E_DIR}/fixtures/dataplaneapi.yaml" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplaneapi.yaml" + assert_success + + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + assert_success + + local restart_retry_count=0 + + until dpa_curl GET "/info"; do + # 5 seconds wait + if [[ restart_retry_count -eq 50 ]]; then + echo -e "\nerror restarting: no response from dataplane on /info" + echo -e "\nhaproxy stderr:" + docker logs -n 42 ${DOCKER_CONTAINER_NAME} + echo -e "\ndataplane log output:" + docker exec ${DOCKER_CONTAINER_NAME} sh -c "tail -n 42 /var/log/dataplaneapi.log" + exit 1 + fi + + sleep 0.1 + restart_retry_count=$((restart_retry_count+1)) + done +} diff --git a/e2e/libs/haproxy_version.bash b/e2e/libs/haproxy_version.bash new file mode 100644 index 00000000..3f7ff8df --- /dev/null +++ b/e2e/libs/haproxy_version.bash @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# +# Copyright 2020 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# haproxy_version_ge returns 1 if the haproxy version is greater or +# equal to the given version, otherwise 0. Given version must be in format +# MAJOR.MINOR without the patch and commit numbers (e.g. 1.9, 2.2, etc.). +# +# Arguments: +# 1. the target MAJOR.MINOR version +# +# Example: +# haproxy_version_ge "2.1" +# >>> 1 +function haproxy_version_ge() { + target=$1; shift + + IFS='.' read -ra version_parts <<< "$HAPROXY_VERSION" + haproxy_major="${version_parts[0]}" + haproxy_minor="${version_parts[1]}" + + IFS='.' read -ra version_parts_target <<< "$target" + target_major="${version_parts_target[0]}" + target_minor="${version_parts_target[1]}" + + if [[ "$haproxy_major" -eq "$target_major" && "$haproxy_minor" -ge "$target_minor" || "$haproxy_major" -gt "$target_major" ]] ; then + return 0 + else + return 1 + fi +} diff --git a/e2e/libs/resource_client.bash b/e2e/libs/resource_client.bash new file mode 100644 index 00000000..74900064 --- /dev/null +++ b/e2e/libs/resource_client.bash @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +function resource_post() { + local endpoint; endpoint="$1"; shift + local data; data="$1"; shift + local qs_params; qs_params="$1" + get_version + run dpa_curl POST "$endpoint?$qs_params&version=${VERSION}" "$data" + assert_success + dpa_curl_status_body '$output' +} + +function resource_post_no_data() { + local endpoint="$1"; shift + get_version + run dpa_curl POST "$endpoint?version=${VERSION}" + assert_success + dpa_curl_status_body '$output' +} + +function resource_put() { + local endpoint; endpoint="$1"; shift + local data; data="$1"; shift + local qs_params; qs_params="$1" + get_version + run dpa_curl PUT "$endpoint?$qs_params&version=${VERSION}" "$data" + assert_success + dpa_curl_status_body '$output' +} + +function resource_put_no_data() { + local endpoint="$1"; shift + get_version + run dpa_curl PUT "$endpoint?version=${VERSION}" + assert_success + dpa_curl_status_body '$output' +} + +function resource_delete() { + local endpoint; endpoint="$1"; shift + local qs_params; qs_params="$1" + get_version + run dpa_curl DELETE "$endpoint?$qs_params&version=${VERSION}" + assert_success + dpa_curl_status_body '$output' +} + +function resource_get() { + local endpoint; endpoint="$1"; shift + local qs_params; qs_params="$1" + run dpa_curl GET "$endpoint?$qs_params" + assert_success + dpa_curl_status_body_safe '$output' +} diff --git a/e2e/libs/run_only.bash b/e2e/libs/run_only.bash new file mode 100644 index 00000000..4e67820e --- /dev/null +++ b/e2e/libs/run_only.bash @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# +# Copyright 2019 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# run_only run one test by its $BATS_TEST_NUMBER or $BATS_TEST_DESCRIPTION +# and skip running other tests. +# This function should be used as first statement inside BATS `setup` func +function run_only() { + if [ -n "$TESTNUMBER" ] && [ "$BATS_TEST_NUMBER" -ne $TESTNUMBER ]; then + skip + fi + + if [ -n "$TESTDESCRIPTION" ] && [ "$BATS_TEST_DESCRIPTION" != "$TESTDESCRIPTION" ]; then + skip + fi +} diff --git a/e2e/libs/version.bash b/e2e/libs/version.bash new file mode 100644 index 00000000..7bc5a689 --- /dev/null +++ b/e2e/libs/version.bash @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# Copyright 2019 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# auth_curl is going to return the response status code along with the body +# these values can be easily read as following +# +# read -r SC BODY < <(auth_curl GET /v3/services/haproxy/runtime/info) +# echo "Status Code: ${SC}" +# echo "Body: ${BODY}" +# +# Arguments: +# - HTTP verb +# - original URL +# - HTTP POST data +function deprecated_auth_curl() { + verb=$1; shift + endpoint=$1; shift + data=${1:-"/dev/null"} + response=$(curl -m 10 -s -H 'content-type: application/json' --user dataplaneapi:mypassword "-X${verb}" -w "\n%{http_code}" "-d${data}" "http://${LOCAL_IP_ADDRESS}:${E2E_PORT}${endpoint}") + status_code=$(tail -n1 <<< "$response") + response=$(sed '$ d' <<< "$response") + echo "$status_code $response" +} + + +function get_version() { + resource_get "/services/haproxy/configuration/version" + eval VERSION="'$BODY'" +} diff --git a/e2e/libs/version_spoe.bash b/e2e/libs/version_spoe.bash new file mode 100644 index 00000000..06a9c083 --- /dev/null +++ b/e2e/libs/version_spoe.bash @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# +# Copyright 2019 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# auth_curl is going to return the response status code along with the body +# these values can be easily read as following +# +# read -r SC BODY < <(auth_curl GET /v3/services/haproxy/runtime/info) +# echo "Status Code: ${SC}" +# echo "Body: ${BODY}" +# +# Arguments: +# - HTTP verb +# - original URL +# - HTTP POST data +function deprecated_auth_curl() { + verb=$1; shift + endpoint=$1; shift + data=${1:-"/dev/null"} + response=$(curl -m 10 -s -H 'content-type: application/json' --user dataplaneapi:mypassword "-X${verb}" -w "\n%{http_code}" "-d${data}" "http://${LOCAL_IP_ADDRESS}:${E2E_PORT}${endpoint}") + status_code=$(tail -n1 <<< "$response") + response=$(sed '$ d' <<< "$response") + echo "$status_code $response" +} + +function get_version() { + resource_get "/services/haproxy/spoe/$SPOE_FILE/version" + eval VERSION="'$BODY'" +} diff --git a/e2e/run.bash b/e2e/run.bash new file mode 100755 index 00000000..9d3bf956 --- /dev/null +++ b/e2e/run.bash @@ -0,0 +1,144 @@ +#!/usr/bin/env bash +# +# Copyright 2019 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +set -eo pipefail + +export BASE_PATH="/v3" + +HAPROXY_VERSION=${HAPROXY_VERSION:-3.4} +DOCKER_BASE_IMAGE="${DOCKER_BASE_IMAGE:-haproxytech/haproxy-debian}:${HAPROXY_VERSION}" +DOCKER_CONTAINER_NAME="dataplaneapi-e2e" +export DOCKER_CONTAINER_NAME +export DOCKER_NETWORK="dpapi-e2e-$$-$RANDOM" + +ROOT_DIR=$(git rev-parse --show-toplevel) +export E2E_PORT=${E2E_PORT:-8042} +export E2E_DIR=${ROOT_DIR}/e2e +export LOCAL_IP_ADDRESS=${LOCAL_IP_ADDRESS:-127.0.0.1} + +source "${E2E_DIR}/libs/cleanup.bash" + +dump_logs() { + echo ">>> dumping container logs" + mkdir -p "${E2E_DIR}/logs" + docker logs "${DOCKER_CONTAINER_NAME}" &> "${E2E_DIR}/logs/haproxy.log" + docker cp -q "${DOCKER_CONTAINER_NAME}:/var/log/dataplaneapi.log" "${E2E_DIR}/logs/dataplaneapi.log" +} + +if ! docker version > /dev/null 2>&1; then + echo '>>> Docker is not installed: cannot proceed for e2e test suite' +fi + +if ! docker inspect "${DOCKER_BASE_IMAGE}" > /dev/null 2>&1; then + echo '>>> Downloading base Docker image' + docker pull "${DOCKER_BASE_IMAGE}" +fi + +if [ ! -z $PREWIPE ] && [ "$PREWIPE" == "y" ]; then + cleanup ${DOCKER_CONTAINER_NAME} +fi + +echo ">>> Creating docker network $DOCKER_NETWORK" +docker network create "$DOCKER_NETWORK" + +# Custom configuration to run tests with the master socket. +IFS='.' read -ra version_parts <<< "$HAPROXY_VERSION" +major="${version_parts[0]}" +minor="${version_parts[1]}" + +if [[ "$major" -eq "2" && "$minor" -ge "7" || "$major" -gt "2" ]] ; then + HAPROXY_FLAGS="-W -db -S /var/lib/haproxy/master -f /usr/local/etc/haproxy/haproxy.cfg" + VARIANT="-master-socket" +fi + + +if [ ! -z $(docker ps -q -f name=${DOCKER_CONTAINER_NAME}) ]; then + echo ">>> Skipping provisioning the e2e environment, ${DOCKER_CONTAINER_NAME} already present" +else + echo '>>> Provisioning the e2e environment' + docker create \ + --name ${DOCKER_CONTAINER_NAME} \ + --net "$DOCKER_NETWORK" \ + --publish "${E2E_PORT}":8080 \ + --security-opt seccomp=unconfined \ + --env CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 \ + "${DOCKER_BASE_IMAGE}" $HAPROXY_FLAGS >/dev/null + docker cp "${E2E_DIR}/fixtures/haproxy.cfg" ${DOCKER_CONTAINER_NAME}:/etc/haproxy/haproxy.cfg + docker cp "${E2E_DIR}/fixtures/userlist.cfg" ${DOCKER_CONTAINER_NAME}:/etc/haproxy/userlist.cfg + docker start ${DOCKER_CONTAINER_NAME} >/dev/null + sleep 1 # sometimes 'docker start' returns too fast and the exec fails + docker cp "${ROOT_DIR}/build/dataplaneapi" ${DOCKER_CONTAINER_NAME}:/usr/local/bin/dataplaneapi + docker cp "${E2E_DIR}/fixtures/dataplaneapi${VARIANT}.yaml" ${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplaneapi.yaml + docker exec -d ${DOCKER_CONTAINER_NAME} sh -c "dataplaneapi -f /etc/haproxy/dataplaneapi.yaml 2>>/var/log/dataplaneapi.log" +fi + +echo '>>> Waiting dataplane API to be up and running' +count=1 +DATAPLANE_USER=$(grep insecure-password ${E2E_DIR}/fixtures/userlist.cfg | awk '{print $2}') +DATAPLANE_PASS=$(grep insecure-password ${E2E_DIR}/fixtures/userlist.cfg | awk '{print $4}') +until curl -sS "${DATAPLANE_USER}:${DATAPLANE_PASS}@${LOCAL_IP_ADDRESS}":"${E2E_PORT}${BASE_PATH}/specification" >/dev/null; do + sleep 1; + ((count++)) + if [ $count -eq 10 ]; then + echo ">>> timeout waiting for dataplaneapi to start" + dump_logs + exit 1 + fi +done + +# deferring Docker container removal +# shellcheck disable=SC1090 + +if [ ! -z $SKIP_CLEANUP ] && [ "$SKIP_CLEANUP" == "y" ]; then + echo ">>> Container will be left running: ${DOCKER_CONTAINER_NAME}" +else + trap 'cleanup ${DOCKER_CONTAINER_NAME}' EXIT +fi + +# Print logs after test failure. +trap dump_logs ERR + +echo '>>> Starting test suite' +if [ -n "$TESTNAME" ]; then + # Small hack to allow selecting multiple test directories. + pfx() { for i;do echo "$E2E_DIR/tests/$i"; done; } + bats -t $(pfx $TESTNAME) +elif [ ! -z $TESTPART ]; then + set +e + echo $TESTPART | grep -q -e "[[:digit:]]/[[:digit:]]" + if [ $? != 0 ]; then + echo "invalid TESTPART argument: ${TESTPART}" + exit 1 + fi + set -e + PARALLEL_RUNS=$(echo $TESTPART | cut -d\/ -f 2) + THIS_RUN=$(($(echo $TESTPART | cut -d\/ -f 1) - 1)) + + declare -a SELECTED_TESTS + + echo ">>> Selected partial run via TESTPART variable, running ${TESTPART} of tests:" + ALL_TESTS=($(ls "${E2E_DIR}"/tests)) + ALL_TESTS_COUNT=${#ALL_TESTS[@]} + for TESTNR in $(seq 0 $(( $ALL_TESTS_COUNT - 1 )) ); do + if [ $(($TESTNR % $PARALLEL_RUNS)) == $THIS_RUN ]; then + echo ">>> -> ${ALL_TESTS[$TESTNR]}" + SELECTED_TESTS+=("${E2E_DIR}"/tests/${ALL_TESTS[$TESTNR]}) + fi + done + bats -t ${SELECTED_TESTS[*]} +else + bats -t "${E2E_DIR}"/tests/* +fi diff --git a/e2e/tests/acl_files/acl_file.bats b/e2e/tests/acl_files/acl_file.bats new file mode 100644 index 00000000..ab32e7f7 --- /dev/null +++ b/e2e/tests/acl_files/acl_file.bats @@ -0,0 +1,43 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + + +load 'utils/_helpers' + +@test "acl_runtime: Return ACL files list" { + resource_get "$_RUNTIME_ACL_BASE_PATH" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" " .[0].storage_name" )" "path_beg" + assert_equal "$(get_json_path "${BODY}" " .[1].storage_name" )" "path_end" +} + +@test "acl_runtime: Return ACL file by its ID" { + resource_get "$_RUNTIME_ACL_BASE_PATH/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" " .storage_name" )" "path_beg" + + resource_get "$_RUNTIME_ACL_BASE_PATH/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" " .storage_name" )" "path_end" +} diff --git a/e2e/tests/acl_files/acl_file_entries.bats b/e2e/tests/acl_files/acl_file_entries.bats new file mode 100644 index 00000000..5d1588f8 --- /dev/null +++ b/e2e/tests/acl_files/acl_file_entries.bats @@ -0,0 +1,82 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/haproxy_version' +load '../../libs/version' + +load 'utils/_helpers' + +@test "acl_runtime: Return ACL file entries list" { + PARENT_NAME="0" + resource_get "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" " .[0].value" )" "/static" + assert_equal "$(get_json_path "${BODY}" " .[1].value" )" "/images" + assert_equal "$(get_json_path "${BODY}" " .[2].value" )" "/javascript" + assert_equal "$(get_json_path "${BODY}" " .[3].value" )" "/stylesheets" +} + +@test "acl_runtime: Return ACL file entries by their ID" { + PARENT_NAME="0" + resource_get "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries" + assert_equal "$SC" 200 + + local list; list=$BODY + + for index in {0..3}; do + local id; id="$(get_json_path "${list}" ".[${index}].id" )" + local value; value="$(get_json_path "${list}" ".[${index}].value" )" + + resource_get "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries/$id" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".value" )" "$value" + done +} + +@test "acl_runtime: Add an ACL file entry" { + PARENT_NAME="0" + resource_post "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries" "data/post.json" + assert_equal "$SC" 201 + assert_equal "$(get_json_path "${BODY}" " .value" )" "/js" +} + +@test "acl_runtime: Delete an ACL file entry by its ID" { + PARENT_NAME="1" + if haproxy_version_ge "2.9"; then + skip "cause: bug in HAPRoxy 2.9" + fi + # checking items and retrieving first ID + resource_get "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ". | length" )" "5" + + local id; id="$(get_json_path "$BODY" ".[0].id")" + + # deleting the entry file by its ID + resource_delete "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries/$id" + assert_equal "$SC" 204 + + # checking the file entry has been deleted counting the items + resource_get "$_RUNTIME_ACL_BASE_PATH/$PARENT_NAME/entries" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ". | length" )" "4" +} diff --git a/e2e/tests/acl_files/data/acl_1.json b/e2e/tests/acl_files/data/acl_1.json new file mode 100644 index 00000000..b1db395e --- /dev/null +++ b/e2e/tests/acl_files/data/acl_1.json @@ -0,0 +1,6 @@ +{ + "acl_name": "url_static", + "criterion": "path_beg", + "index": 1, + "value": "-i /static /images /javascript /stylesheets" +} \ No newline at end of file diff --git a/e2e/tests/acl_files/data/acl_2.json b/e2e/tests/acl_files/data/acl_2.json new file mode 100644 index 00000000..6495b648 --- /dev/null +++ b/e2e/tests/acl_files/data/acl_2.json @@ -0,0 +1,6 @@ +{ + "acl_name": "url_static", + "criterion": "path_end", + "index": 2, + "value": "-i .jpg .gif .png .css .js" +} \ No newline at end of file diff --git a/e2e/tests/acl_files/data/haproxy.cfg b/e2e/tests/acl_files/data/haproxy.cfg new file mode 100644 index 00000000..a5fdaf45 --- /dev/null +++ b/e2e/tests/acl_files/data/haproxy.cfg @@ -0,0 +1,36 @@ +# _version=1 +defaults mydefaults + mode http + log global + option httplog + option dontlognull + timeout connect 5000 + timeout client 50000 + timeout server 50000 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +frontend main + bind *:5000 + acl url_static path_beg -i /static /images /javascript /stylesheets + acl url_static path_end -i .jpg .gif .png .css .js + use_backend static if url_static + default_backend app + +backend static + balance roundrobin + server static 127.0.0.1:4331 check + +backend app + balance roundrobin + server app1 127.0.0.1:5001 check + server app2 127.0.0.1:5002 check + server app3 127.0.0.1:5003 check + server app4 127.0.0.1:5004 check diff --git a/e2e/tests/acl_files/data/post.json b/e2e/tests/acl_files/data/post.json new file mode 100644 index 00000000..aab33978 --- /dev/null +++ b/e2e/tests/acl_files/data/post.json @@ -0,0 +1,3 @@ +{ + "value": "/js" +} \ No newline at end of file diff --git a/e2e/tests/acl_files/utils/_helpers.bash b/e2e/tests/acl_files/utils/_helpers.bash new file mode 100644 index 00000000..4cba593b --- /dev/null +++ b/e2e/tests/acl_files/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RUNTIME_ACL_BASE_PATH="/services/haproxy/runtime/acls" diff --git a/e2e/tests/acls/add.bats b/e2e/tests/acls/add.bats new file mode 100644 index 00000000..a21e2176 --- /dev/null +++ b/e2e/tests/acls/add.bats @@ -0,0 +1,48 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "acls: Add a new ACL" { + PARENT_NAME="fe_acl" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/2" "data/post.json" + assert_equal "$SC" 202 + # + # verify that ACL is actually added + # + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/2" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ".")" "$(cat ${BATS_TEST_DIRNAME}/data/post.json)" +} + +@test "acls: Add a newACL for fcgi-app" { + PARENT_NAME="test_1" + resource_post "$_FCGIAPP_BASE_PATH/$PARENT_NAME/acls/0" "data/post.json" + assert_equal "$SC" 202 + + resource_get "$_FCGIAPP_BASE_PATH/$PARENT_NAME/acls/0" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ".")" "$(cat ${BATS_TEST_DIRNAME}/data/post.json)" +} diff --git a/e2e/tests/acls/data/haproxy.cfg b/e2e/tests/acls/data/haproxy.cfg new file mode 100644 index 00000000..ce21d882 --- /dev/null +++ b/e2e/tests/acls/data/haproxy.cfg @@ -0,0 +1,31 @@ +# _version=60 +defaults mydefaults + mode http + log global + option httplog + option dontlognull + timeout connect 5000 + timeout client 50000 + timeout server 50000 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +frontend fe_acl + bind *:1234 + mode http + acl invalid_src src 0.0.0.0/7 224.0.0.0/3 + acl invalid_src src_port 0:1023 + acl local_dst hdr(host) -i localhost + +fcgi-app test_1 + docroot /path/to/chroot + index index.php + log-stderr global + acl local_dst hdr(host) -i localhost diff --git a/e2e/tests/acls/data/post.json b/e2e/tests/acls/data/post.json new file mode 100644 index 00000000..49c5a30d --- /dev/null +++ b/e2e/tests/acls/data/post.json @@ -0,0 +1,5 @@ +{ + "acl_name": "new_acl", + "criterion": "src_port", + "value": "0:1048" +} diff --git a/e2e/tests/acls/data/put.json b/e2e/tests/acls/data/put.json new file mode 100644 index 00000000..5a1a9f1c --- /dev/null +++ b/e2e/tests/acls/data/put.json @@ -0,0 +1,5 @@ +{ + "acl_name": "put_acl", + "criterion": "src_port", + "value": "0:1122" +} diff --git a/e2e/tests/acls/data/replace-all.json b/e2e/tests/acls/data/replace-all.json new file mode 100644 index 00000000..a6c9f5f1 --- /dev/null +++ b/e2e/tests/acls/data/replace-all.json @@ -0,0 +1,17 @@ +[ + { + "acl_name": "replace_0", + "criterion": "src_port", + "value": "0:1110" + }, + { + "acl_name": "replace_1", + "criterion": "src_port", + "value": "0:1111" + }, + { + "acl_name": "replace_2", + "criterion": "src_port", + "value": "0:1112" + } +] diff --git a/e2e/tests/acls/delete.bats b/e2e/tests/acls/delete.bats new file mode 100644 index 00000000..464402cf --- /dev/null +++ b/e2e/tests/acls/delete.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "acls: Delete one ACL by its index" { + PARENT_NAME="fe_acl" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/1" + assert_equal "$SC" 202 +} + +@test "acls: Delete one ACL by its index and force reload" { + PARENT_NAME="fe_acl" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/0" "force_reload=true" + assert_equal "$SC" 204 +} diff --git a/e2e/tests/acls/get.bats b/e2e/tests/acls/get.bats new file mode 100644 index 00000000..de5c499f --- /dev/null +++ b/e2e/tests/acls/get.bats @@ -0,0 +1,50 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "acls: Return one ACL" { + PARENT_NAME="fe_acl" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/2" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" " .acl_name")" "local_dst" + assert_equal "$(get_json_path "$BODY" " .criterion")" "hdr(host)" + assert_equal "$(get_json_path "$BODY" " .value")" "-i localhost" +} + +@test "acls: Return an error when ACL doesn't exists at a given index" { + PARENT_NAME="fe_acl" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/100" + assert_equal "$SC" 404 +} + +@test "acls: Return one ACL for fcgi-app" { + PARENT_NAME="test_1" + resource_get "$_FCGIAPP_BASE_PATH/$PARENT_NAME/acls/0" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" " .acl_name")" "local_dst" + assert_equal "$(get_json_path "$BODY" " .criterion")" "hdr(host)" + assert_equal "$(get_json_path "$BODY" " .value")" "-i localhost" +} diff --git a/e2e/tests/acls/list.bats b/e2e/tests/acls/list.bats new file mode 100644 index 00000000..faab0ac6 --- /dev/null +++ b/e2e/tests/acls/list.bats @@ -0,0 +1,43 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "acls: Return ACL list" { + PARENT_NAME="fe_acl" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls" + assert_equal $SC "200" + + assert_equal "$(get_json_path "$BODY" " . | .[2].acl_name" )" "local_dst" + assert_equal "$(get_json_path "$BODY" " . | .[2].criterion" )" "hdr(host)" + assert_equal "$(get_json_path "$BODY" " . | .[2].value" )" "-i localhost" +} + +@test "acls: Return ACL list by its name" { + PARENT_NAME="fe_acl" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls" "acl_name=invalid_src" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" " . | .[1].acl_name" )" "invalid_src" + assert_equal "$(get_json_path "$BODY" " . | .[1].criterion" )" "src_port" + assert_equal "$(get_json_path "$BODY" " . | .[1].value" )" "0:1023" +} diff --git a/e2e/tests/acls/replace.bats b/e2e/tests/acls/replace.bats new file mode 100644 index 00000000..0d922c28 --- /dev/null +++ b/e2e/tests/acls/replace.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "acls: Replace one ACL" { + PARENT_NAME="fe_acl" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/2" "data/put.json" + assert_equal "$SC" 202 + # + # verify that ACL is actually changed + # + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls/2" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" " ." )" "$(cat "$BATS_TEST_DIRNAME/data/put.json")" +} + +@test "acls: Return an error when trying to replace non existing ACL" { + PARENT_NAME="fe_acl" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/200" "data/put.json" + assert_equal "$SC" 404 +} + +@test "acls: Replace all ACLs" { + PARENT_NAME="fe_acl" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls" "data/replace-all.json" + assert_equal "$SC" 202 + # + # verify that ACL is actually changed + # + # + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/acls" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + +} diff --git a/e2e/tests/acls/utils/_helpers.bash b/e2e/tests/acls/utils/_helpers.bash new file mode 100644 index 00000000..9ad581ca --- /dev/null +++ b/e2e/tests/acls/utils/_helpers.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_ACL_BASE_PATH="/services/haproxy/configuration/acls" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" +_FCGIAPP_BASE_PATH="/services/haproxy/configuration/fcgi_apps" diff --git a/e2e/tests/acme/data/edit_acme.json b/e2e/tests/acme/data/edit_acme.json new file mode 100644 index 00000000..3b30d293 --- /dev/null +++ b/e2e/tests/acme/data/edit_acme.json @@ -0,0 +1,7 @@ +{ + "name": "letsencrypt", + "contact": "me@example.com", + "directory": "https://acme-v02.api.letsencrypt.org/directory", + "keytype": "RSA", + "bits": 4096 +} diff --git a/e2e/tests/acme/data/haproxy.cfg b/e2e/tests/acme/data/haproxy.cfg new file mode 100644 index 00000000..b8f8eff7 --- /dev/null +++ b/e2e/tests/acme/data/haproxy.cfg @@ -0,0 +1,29 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + expose-experimental-directives + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 diff --git a/e2e/tests/acme/data/new_acme.json b/e2e/tests/acme/data/new_acme.json new file mode 100644 index 00000000..305e7cf1 --- /dev/null +++ b/e2e/tests/acme/data/new_acme.json @@ -0,0 +1,5 @@ +{ + "name": "letsencrypt", + "contact": "me@example.com", + "directory": "https://acme-staging-v02.api.letsencrypt.org/directory" +} diff --git a/e2e/tests/acme/tests.bats b/e2e/tests/acme/tests.bats new file mode 100644 index 00000000..2b43b057 --- /dev/null +++ b/e2e/tests/acme/tests.bats @@ -0,0 +1,65 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +_ACME_PATH="/services/haproxy/configuration/acme" +_ACME_NAME="letsencrypt" + +@test "acme: all tests (>=3.2)" { + haproxy_version_ge "3.2" || skip + + resource_post "$_ACME_PATH" "data/new_acme.json" "force_reload=true" + assert_equal "$SC" "201" + + resource_get "$_ACME_PATH/$_ACME_NAME" + assert_equal "$SC" "200" + assert_equal "$(get_json_path "$BODY" .name)" "$_ACME_NAME" + assert_equal "$(get_json_path "$BODY" .contact)" "me@example.com" + assert_equal "$(get_json_path "$BODY" .directory)" "https://acme-staging-v02.api.letsencrypt.org/directory" + + resource_put "$_ACME_PATH/$_ACME_NAME" "data/edit_acme.json" "force_reload=true" + assert_equal "$SC" "200" + resource_get "$_ACME_PATH/$_ACME_NAME" + assert_equal "$(get_json_path "$BODY" .directory)" "https://acme-v02.api.letsencrypt.org/directory" + assert_equal "$(get_json_path "$BODY" .keytype)" "RSA" + assert_equal "$(get_json_path "$BODY" .bits)" 4096 + + resource_get "$_ACME_PATH" + assert_equal "$SC" "200" + assert_equal "$(get_json_path "$BODY" '.|length')" 1 + assert_equal "$(get_json_path "$BODY" .[0].name)" "$_ACME_NAME" + + # back to the original + resource_put "$_ACME_PATH/$_ACME_NAME" "data/new_acme.json" "force_reload=true" + assert_equal "$SC" "200" + resource_get "$_ACME_PATH/$_ACME_NAME" + assert_equal "$(get_json_path "$BODY" .directory)" "https://acme-staging-v02.api.letsencrypt.org/directory" + assert_equal "$(get_json_path "$BODY" .keytype)" null + assert_equal "$(get_json_path "$BODY" .bits)" null + + resource_delete "$_ACME_PATH/$_ACME_NAME" "force_reload=true" + assert_equal "$SC" "204" + resource_get "$_ACME_PATH/$_ACME_NAME" + assert_equal "$SC" "404" +} diff --git a/e2e/tests/backend_switching_rules/add.bats b/e2e/tests/backend_switching_rules/add.bats new file mode 100644 index 00000000..ca32db4f --- /dev/null +++ b/e2e/tests/backend_switching_rules/add.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "backend_switching_rules: Add a new Backend Switching Rule" { + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + # + # Checking the presence of applied backend switching rule + # + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat $BATS_TEST_DIRNAME/data/post.json)" ".")" +} diff --git a/e2e/tests/backend_switching_rules/data/haproxy.cfg b/e2e/tests/backend_switching_rules/data/haproxy.cfg new file mode 100644 index 00000000..fd227d43 --- /dev/null +++ b/e2e/tests/backend_switching_rules/data/haproxy.cfg @@ -0,0 +1,48 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode tcp + maxconn 1000 + option httpclose + use_backend first_backend if { req_ssl_sni -i first.example.com } + use_backend second_backend if { req_ssl_sni -i second.example.com } + +backend first_backend + mode http + balance roundrobin + option forwardfor + +backend second_backend + mode http + balance roundrobin + option forwardfor + +backend test_backend + mode http + balance roundrobin + option forwardfor diff --git a/e2e/tests/backend_switching_rules/data/post.json b/e2e/tests/backend_switching_rules/data/post.json new file mode 100644 index 00000000..32a7d285 --- /dev/null +++ b/e2e/tests/backend_switching_rules/data/post.json @@ -0,0 +1,5 @@ +{ + "cond": "if", + "cond_test": "{ req_ssl_sni -i www.example.com }", + "name": "test_backend" +} diff --git a/e2e/tests/backend_switching_rules/data/put.json b/e2e/tests/backend_switching_rules/data/put.json new file mode 100644 index 00000000..fbbc008e --- /dev/null +++ b/e2e/tests/backend_switching_rules/data/put.json @@ -0,0 +1,5 @@ +{ + "cond": "if", + "cond_test": "{ req_ssl_sni -i example.com }", + "name": "test_backend" +} diff --git a/e2e/tests/backend_switching_rules/data/replace-all.json b/e2e/tests/backend_switching_rules/data/replace-all.json new file mode 100644 index 00000000..1d74bf0b --- /dev/null +++ b/e2e/tests/backend_switching_rules/data/replace-all.json @@ -0,0 +1,17 @@ +[ + { + "cond": "if", + "cond_test": "{ req_ssl_sni -i example1.com }", + "name": "first_backend" + }, + { + "cond": "if", + "cond_test": "TRUE", + "name": "second_backend" + }, + { + "cond": "if", + "cond_test": "{ req_ssl_sni -i example2.com }", + "name": "test_backend" + } +] diff --git a/e2e/tests/backend_switching_rules/delete.bats b/e2e/tests/backend_switching_rules/delete.bats new file mode 100644 index 00000000..9b03336c --- /dev/null +++ b/e2e/tests/backend_switching_rules/delete.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "backend_switching_rules: Delete a Backend Switching Rule" { + PARENT_NAME="test_frontend" + # + # Deleting first + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting second + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # No more backend switching rules, not found + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/backend_switching_rules/get.bats b/e2e/tests/backend_switching_rules/get.bats new file mode 100644 index 00000000..d08685b6 --- /dev/null +++ b/e2e/tests/backend_switching_rules/get.bats @@ -0,0 +1,45 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/version' + +load 'utils/_helpers' + +@test "backend_switching_rules: Replace a Backend Switching Rule" { + # + # Retrieving the first + # + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ req_ssl_sni -i first.example.com }" + # + # Retrieving the second + # + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ req_ssl_sni -i second.example.com }" + # + # Not found for non existing + # + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/2" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/backend_switching_rules/list.bats b/e2e/tests/backend_switching_rules/list.bats new file mode 100644 index 00000000..37da6fbd --- /dev/null +++ b/e2e/tests/backend_switching_rules/list.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/version' + +load 'utils/_helpers' + +@test "backend_switching_rules: Replace a Backend Switching Rule" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".[0].cond_test")" "{ req_ssl_sni -i first.example.com }" + assert_equal "$(get_json_path "$BODY" ".[1].cond_test")" "{ req_ssl_sni -i second.example.com }" +} diff --git a/e2e/tests/backend_switching_rules/missing_frontend.bats b/e2e/tests/backend_switching_rules/missing_frontend.bats new file mode 100644 index 00000000..b9141cae --- /dev/null +++ b/e2e/tests/backend_switching_rules/missing_frontend.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "backend_switching_rules: Fail creating a Backend Switching Rule rule when frontend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/backend_switching_rules/replace.bats b/e2e/tests/backend_switching_rules/replace.bats new file mode 100644 index 00000000..57d95fc0 --- /dev/null +++ b/e2e/tests/backend_switching_rules/replace.bats @@ -0,0 +1,41 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "backend_switching_rules: Replace a Backend Switching Rule" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/put.json")" ".")" +} + +@test "backend_switching_rules: Replace all Backend Switching Rule" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules" "data/replace-all.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/backend_switching_rules" + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} diff --git a/e2e/tests/backend_switching_rules/utils/_helpers.bash b/e2e/tests/backend_switching_rules/utils/_helpers.bash new file mode 100644 index 00000000..476c8902 --- /dev/null +++ b/e2e/tests/backend_switching_rules/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/backends/data/post.json b/e2e/tests/backends/data/post.json new file mode 100644 index 00000000..b384dc28 --- /dev/null +++ b/e2e/tests/backends/data/post.json @@ -0,0 +1,16 @@ +{ + "adv_check": "httpchk", + "balance": { + "algorithm": "roundrobin" + }, + "forwardfor": { + "enabled": "enabled" + }, + "httpchk_params": { + "method": "GET", + "uri": "/check", + "version": "HTTP/1.1" + }, + "mode": "http", + "name": "test_backend" +} diff --git a/e2e/tests/backends/data/post_2.2.json b/e2e/tests/backends/data/post_2.2.json new file mode 100644 index 00000000..b384dc28 --- /dev/null +++ b/e2e/tests/backends/data/post_2.2.json @@ -0,0 +1,16 @@ +{ + "adv_check": "httpchk", + "balance": { + "algorithm": "roundrobin" + }, + "forwardfor": { + "enabled": "enabled" + }, + "httpchk_params": { + "method": "GET", + "uri": "/check", + "version": "HTTP/1.1" + }, + "mode": "http", + "name": "test_backend" +} diff --git a/e2e/tests/backends/data/post_invalid_send_method_1.json b/e2e/tests/backends/data/post_invalid_send_method_1.json new file mode 100644 index 00000000..3e9ffbab --- /dev/null +++ b/e2e/tests/backends/data/post_invalid_send_method_1.json @@ -0,0 +1,23 @@ +{ + "adv_check": "httpchk", + "balance": { + "algorithm": "roundrobin" + }, + "forwardfor": { + "enabled": "enabled" + }, + "httpchk_params": { + "method": "invalid", + "uri": "/check", + "version": "HTTP/1.1" + }, + "http-check": { + "index": 0, + "method": "OPTIONS", + "uri": "/", + "version": "HTTP/1.1", + "type": "send" + }, + "mode": "http", + "name": "test_backend" +} diff --git a/e2e/tests/backends/data/put.json b/e2e/tests/backends/data/put.json new file mode 100644 index 00000000..c4d2b446 --- /dev/null +++ b/e2e/tests/backends/data/put.json @@ -0,0 +1,13 @@ +{ + "adv_check": "httpchk", + "balance": { + "algorithm": "static-rr" + }, + "httpchk_params": { + "method": "GET", + "uri": "/healthz", + "version": "HTTP/1.1" + }, + "mode": "tcp", + "name": "test_backend" +} diff --git a/e2e/tests/backends/test.bats b/e2e/tests/backends/test.bats new file mode 100644 index 00000000..a94193e8 --- /dev/null +++ b/e2e/tests/backends/test.bats @@ -0,0 +1,68 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "backends: Add a backend" { + resource_post "$_BACKEND_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" "201" + + resource_get "$_BACKEND_BASE_PATH/test_backend" assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".adv_check")" "httpchk" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.method")" "GET" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.uri")" "/check" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.version")" "HTTP/1.1" +} + +@test "backends: fail adding a backend (invalid send method in httpchk_params)" { + resource_post "$_BACKEND_BASE_PATH" "data/post_invalid_send_method_1.json" "force_reload=true" + assert_equal "$SC" 422 + assert_equal "$(get_json_path "$BODY" ".code")" "606" +} + +@test "backends: Return a backend" { + resource_get "$_BACKEND_BASE_PATH/test_backend" + assert_equal "$SC" 200 + assert_equal "test_backend" "$(get_json_path "$BODY" '.name')" +} + +@test "backends: Replace a backend" { + resource_put "$_BACKEND_BASE_PATH/test_backend" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/test_backend" assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".adv_check")" "httpchk" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.method")" "GET" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.uri")" "/healthz" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.version")" "HTTP/1.1" +} + +@test "backends: Return an array of backends" { + resource_get "$_BACKEND_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "test_backend" "$(get_json_path "$BODY" '.[0].name')" +} + +@test "backends: Delete a backend" { + resource_delete "$_BACKEND_BASE_PATH/test_backend" "force_reload=true" + assert_equal "$SC" 204 +} diff --git a/e2e/tests/backends/test_2.2.bats b/e2e/tests/backends/test_2.2.bats new file mode 100644 index 00000000..bac3e3a1 --- /dev/null +++ b/e2e/tests/backends/test_2.2.bats @@ -0,0 +1,61 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + + +@test "backends: Add a backend (>=2.2)" { + if haproxy_version_ge "2.2" + then + resource_post "$_BACKEND_BASE_PATH" "data/post_2.2.json" "force_reload=true" + assert_equal "$SC" "201" + + resource_get "$_BACKEND_BASE_PATH/test_backend" assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".adv_check")" "httpchk" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.method")" "GET" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.uri")" "/check" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.version")" "HTTP/1.1" + fi +} + +@test "backends: Replace a backend (>=2.2)" { + if haproxy_version_ge "2.2" + then + resource_put "$_BACKEND_BASE_PATH/test_backend" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/test_backend" assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".adv_check")" "httpchk" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.method")" "GET" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.uri")" "/healthz" + assert_equal "$(get_json_path "$BODY" ".httpchk_params.version")" "HTTP/1.1" + fi +} + +@test "backends: Delete a backend" { + if haproxy_version_ge "2.2" + then + resource_delete "$_BACKEND_BASE_PATH/test_backend" "force_reload=true" + assert_equal "$SC" 204 + fi +} diff --git a/e2e/tests/backends/utils/_helpers.bash b/e2e/tests/backends/utils/_helpers.bash new file mode 100644 index 00000000..b16dc165 --- /dev/null +++ b/e2e/tests/backends/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" diff --git a/e2e/tests/binds/add.bats b/e2e/tests/binds/add.bats new file mode 100644 index 00000000..4f26c494 --- /dev/null +++ b/e2e/tests/binds/add.bats @@ -0,0 +1,75 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "binds: Add a new bind" { + PARENT_NAME="test_frontend" + if haproxy_version_ge "2.5" + then + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds" "data/post_2.5.json" "force_reload=true" + else + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds" "data/post.json" "force_reload=true" + fi + assert_equal "$SC" 201 + if haproxy_version_ge "2.5" + then + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/test_bind" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "test_bind" + assert_equal "1/all" "$(get_json_path "$BODY" ".thread")" + assert_equal "$(get_json_path "$BODY" '.ca_verify_file')" "/certs/ca-verify.pem" + fi +} + +@test "binds: Add a new bind for log_forward" { + PARENT_NAME="sylog-loadb" + if haproxy_version_ge "2.5" + then + resource_post "$_LOGFORWARD_BASE_PATH/$PARENT_NAME/binds" "data/post_2.5.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_LOGFORWARD_BASE_PATH/$PARENT_NAME/binds/test_bind" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "test_bind" + assert_equal "1/all" "$(get_json_path "$BODY" ".thread")" + assert_equal "$(get_json_path "$BODY" '.ca_verify_file')" "/certs/ca-verify.pem" + fi +} + +@test "binds: Add a new bind for peers" { + PARENT_NAME="fusion" + # segfault in v3.3 + if haproxy_version_ge "2.5" && !haproxy_version_ge "3.3" + then + resource_post "$_PEER_BASE_PATH/$PARENT_NAME/binds" "data/post_2.5.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_PEER_BASE_PATH/$PARENT_NAME/binds/test_bind" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "test_bind" + assert_equal "1/all" "$(get_json_path "$BODY" ".thread")" + assert_equal "$(get_json_path "$BODY" '.ca_verify_file')" "/certs/ca-verify.pem" + fi +} diff --git a/e2e/tests/binds/add_2.8.bats b/e2e/tests/binds/add_2.8.bats new file mode 100644 index 00000000..e62af1f1 --- /dev/null +++ b/e2e/tests/binds/add_2.8.bats @@ -0,0 +1,40 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "binds: Add a new bind (>=2.8)" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds" "data/post_2.8.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/test_bind" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "test_bind" + assert_equal "$(get_json_path "$BODY" ".no_alpn")" "true" + assert_equal "$(get_json_path "$BODY" '.ca_verify_file')" "/certs/ca-verify.pem" + fi +} diff --git a/e2e/tests/binds/data/container/certs/ca-verify.pem b/e2e/tests/binds/data/container/certs/ca-verify.pem new file mode 100644 index 00000000..0595a48a --- /dev/null +++ b/e2e/tests/binds/data/container/certs/ca-verify.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/binds/data/haproxy.cfg b/e2e/tests/binds/data/haproxy.cfg new file mode 100644 index 00000000..39ecdecd --- /dev/null +++ b/e2e/tests/binds/data/haproxy.cfg @@ -0,0 +1,32 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode tcp + maxconn 1000 + bind localhost:9000 name fixture ca-verify-file /certs/ca-verify.pem + bind localhost:9090 name loopback + option httpclose diff --git a/e2e/tests/binds/data/haproxy_2.5.cfg b/e2e/tests/binds/data/haproxy_2.5.cfg new file mode 100644 index 00000000..d92bb689 --- /dev/null +++ b/e2e/tests/binds/data/haproxy_2.5.cfg @@ -0,0 +1,41 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode tcp + maxconn 1000 + bind localhost:9000 name fixture thread all ca-verify-file /certs/ca-verify.pem + bind localhost:9090 name loopback thread 1/1 + bind localhost:9091 name loopback1 thread 1/1-1 + option httpclose + +log-forward sylog-loadb + dgram-bind 127.0.0.1:1514 + bind 127.0.0.1:1514 + timeout client 50000 + +peers fusion + server server_01 10.1.1.1:8080 check weight 80 diff --git a/e2e/tests/binds/data/post.json b/e2e/tests/binds/data/post.json new file mode 100644 index 00000000..73a57b7f --- /dev/null +++ b/e2e/tests/binds/data/post.json @@ -0,0 +1,7 @@ +{ + "address": "127.0.0.1", + "name": "test_bind", + "port": 10000, + "defer_accept": true, + "allow_0rtt": true +} diff --git a/e2e/tests/binds/data/post_2.5.json b/e2e/tests/binds/data/post_2.5.json new file mode 100644 index 00000000..8e89b559 --- /dev/null +++ b/e2e/tests/binds/data/post_2.5.json @@ -0,0 +1,9 @@ +{ + "address": "127.0.0.2", + "name": "test_bind", + "port": 10000, + "defer_accept": true, + "allow_0rtt": true, + "thread": "1/all", + "ca_verify_file": "/certs/ca-verify.pem" +} diff --git a/e2e/tests/binds/data/post_2.8.json b/e2e/tests/binds/data/post_2.8.json new file mode 100644 index 00000000..a685d0b5 --- /dev/null +++ b/e2e/tests/binds/data/post_2.8.json @@ -0,0 +1,10 @@ +{ + "address": "127.0.0.2", + "name": "test_bind", + "port": 10000, + "defer_accept": true, + "allow_0rtt": true, + "thread": "1/all", + "no_alpn": true, + "ca_verify_file": "/certs/ca-verify.pem" +} diff --git a/e2e/tests/binds/data/put.json b/e2e/tests/binds/data/put.json new file mode 100644 index 00000000..65cbd425 --- /dev/null +++ b/e2e/tests/binds/data/put.json @@ -0,0 +1,6 @@ +{ + "level": "user", + "address": "127.0.0.1", + "name": "fixture", + "port": 10001 +} diff --git a/e2e/tests/binds/data/put_2.8.json b/e2e/tests/binds/data/put_2.8.json new file mode 100644 index 00000000..023e4cd7 --- /dev/null +++ b/e2e/tests/binds/data/put_2.8.json @@ -0,0 +1,7 @@ +{ + "level": "user", + "no_alpn": true, + "address": "127.0.0.1", + "name": "fixture", + "port": 10001 +} diff --git a/e2e/tests/binds/delete.bats b/e2e/tests/binds/delete.bats new file mode 100644 index 00000000..a1da05f5 --- /dev/null +++ b/e2e/tests/binds/delete.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "binds: Delete a bind" { + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/fixture" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/loopback" "force_reload=true" + assert_equal "$SC" 204 +} diff --git a/e2e/tests/binds/get.bats b/e2e/tests/binds/get.bats new file mode 100644 index 00000000..a3fda7ad --- /dev/null +++ b/e2e/tests/binds/get.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "binds: Return one bind" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/fixture" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "fixture" + if haproxy_version_ge "2.5" + then + assert_equal "all" "$(get_json_path "$BODY" ".thread")" + assert_equal "$(get_json_path "$BODY" '.ca_verify_file')" "/certs/ca-verify.pem" + fi +} diff --git a/e2e/tests/binds/list.bats b/e2e/tests/binds/list.bats new file mode 100644 index 00000000..71897743 --- /dev/null +++ b/e2e/tests/binds/list.bats @@ -0,0 +1,47 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "binds: Return an array of binds" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds" + assert_equal "$SC" 200 + + if haproxy_version_ge "2.5" + then + assert_equal 3 "$(get_json_path "$BODY" ". | length")" + else + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + fi + assert_equal "fixture" "$(get_json_path "$BODY" ".[0].name")" + assert_equal "loopback" "$(get_json_path "$BODY" ".[1].name")" + if haproxy_version_ge "2.5" + then + assert_equal "all" "$(get_json_path "$BODY" ".[0].thread")" + assert_equal "1/1" "$(get_json_path "$BODY" ".[1].thread")" + assert_equal "loopback1" "$(get_json_path "$BODY" ".[2].name")" + assert_equal "1/1-1" "$(get_json_path "$BODY" ".[2].thread")" + fi +} diff --git a/e2e/tests/binds/replace.bats b/e2e/tests/binds/replace.bats new file mode 100644 index 00000000..712de73f --- /dev/null +++ b/e2e/tests/binds/replace.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "binds: Replace a bind" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/fixture" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/fixture" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.')" "$(cat "$BATS_TEST_DIRNAME/data/put.json")" +} diff --git a/e2e/tests/binds/replace_2.8.bats b/e2e/tests/binds/replace_2.8.bats new file mode 100644 index 00000000..f0537b4c --- /dev/null +++ b/e2e/tests/binds/replace_2.8.bats @@ -0,0 +1,40 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "binds: Replace a bind (>=2.8)" { + if haproxy_version_ge "2.8" + then + PUT_FILE="data/put_2.8.json" + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/fixture" "$PUT_FILE" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/binds/fixture" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.')" "$(cat "$BATS_TEST_DIRNAME/$PUT_FILE")" + fi +} diff --git a/e2e/tests/binds/utils/_helpers.bash b/e2e/tests/binds/utils/_helpers.bash new file mode 100644 index 00000000..2377b0b7 --- /dev/null +++ b/e2e/tests/binds/utils/_helpers.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_BIND_BASE_PATH="/services/haproxy/configuration/binds" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" +_LOGFORWARD_BASE_PATH="/services/haproxy/configuration/log_forwards" +_PEER_BASE_PATH="/services/haproxy/configuration/peers" diff --git a/e2e/tests/cache/data/cache.json b/e2e/tests/cache/data/cache.json new file mode 100644 index 00000000..89713d76 --- /dev/null +++ b/e2e/tests/cache/data/cache.json @@ -0,0 +1,5 @@ +{ + "name": "cache_created", + "max_object_size": 1, + "total_max_size": 1000 +} diff --git a/e2e/tests/cache/data/cache_same_name.json b/e2e/tests/cache/data/cache_same_name.json new file mode 100644 index 00000000..ef55a6c7 --- /dev/null +++ b/e2e/tests/cache/data/cache_same_name.json @@ -0,0 +1,5 @@ +{ + "name": "test_cache", + "max_object_size": 1, + "total_max_size": 1000 +} diff --git a/e2e/tests/cache/data/cache_unvalid.json b/e2e/tests/cache/data/cache_unvalid.json new file mode 100644 index 00000000..df1d6298 --- /dev/null +++ b/e2e/tests/cache/data/cache_unvalid.json @@ -0,0 +1,5 @@ +{ + "name": "cache_created", + "max_object_size": "1", + "test": 1000 +} diff --git a/e2e/tests/cache/data/haproxy.cfg b/e2e/tests/cache/data/haproxy.cfg new file mode 100644 index 00000000..6b8e1ed0 --- /dev/null +++ b/e2e/tests/cache/data/haproxy.cfg @@ -0,0 +1,35 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +cache test_cache + total-max-size 1024 + max-object-size 8 + max-age 60 + +cache test_cache2 + total-max-size 1024 diff --git a/e2e/tests/cache/test.bats b/e2e/tests/cache/test.bats new file mode 100644 index 00000000..287b43d4 --- /dev/null +++ b/e2e/tests/cache/test.bats @@ -0,0 +1,84 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "cache: All Cache Tests" { + resource_post "$_CACHE_BASE_PATH" "data/cache.json" + assert_equal "$SC" 202 + + resource_get "$_CACHE_BASE_PATH/cache_created" + assert_equal "$SC" 200 + + assert_equal "cache_created" "$(get_json_path "$BODY" ".name")" + assert_equal 1 "$(get_json_path "$BODY" ".max_object_size")" + assert_equal 1000 "$(get_json_path "$BODY" ".total_max_size")" + + resource_post "$_CACHE_BASE_PATH" "data/cache_same_name.json" + assert_equal "$SC" 409 + + resource_post "$_CACHE_BASE_PATH" "data/cache_unvalid.json" + assert_equal "$SC" 400 + + + resource_delete "$_CACHE_BASE_PATH/test_cache2" + assert_equal "$SC" 202 + + resource_get "$_CACHE_BASE_PATH/test_cache2" + assert_equal "$SC" 404 + + resource_delete "$_CACHE_BASE_PATH/i_am_not_here" + assert_equal "$SC" 404 + + resource_get "$_CACHE_BASE_PATH/test_cache" + assert_equal "$SC" 200 + assert_equal "test_cache" "$(get_json_path "$BODY" ".name")" + assert_equal 60 "$(get_json_path "$BODY" ".max_age")" + assert_equal 8 "$(get_json_path "$BODY" ".max_object_size")" + assert_equal 1024 "$(get_json_path "$BODY" ".total_max_size")" + + + resource_get "$_CACHE_BASE_PATH/i_am_not_here" + assert_equal "$SC" 404 + + resource_get "$_CACHE_BASE_PATH" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + + resource_put "$_CACHE_BASE_PATH/test_cache" "data/cache_same_name.json" + assert_equal "$SC" 202 + + resource_get "$_CACHE_BASE_PATH/test_cache" + assert_equal "$SC" 200 + assert_equal "test_cache" "$(get_json_path "$BODY" ".name")" + assert_equal 1 "$(get_json_path "$BODY" ".max_object_size")" + assert_equal 1000 "$(get_json_path "$BODY" ".total_max_size")" + + resource_put "$_CACHE_BASE_PATH/i_am_not_here" "data/cache_same_name.json" + assert_equal "$SC" 404 + + resource_put "$_CACHE_BASE_PATH/test_cache" "data/cache_unvalid.json" + assert_equal "$SC" 400 + +} diff --git a/e2e/tests/cache/utils/_helpers.bash b/e2e/tests/cache/utils/_helpers.bash new file mode 100644 index 00000000..c15fcaa8 --- /dev/null +++ b/e2e/tests/cache/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_CACHE_BASE_PATH="/services/haproxy/configuration/caches" diff --git a/e2e/tests/captures/add.bats b/e2e/tests/captures/add.bats new file mode 100644 index 00000000..2e477ced --- /dev/null +++ b/e2e/tests/captures/add.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "captures: Add a new declare capture" { + PARENT_NAME="test_add" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "data/add.json" + assert_equal "$SC" 202 +} + +@test "captures: Add a new declare capture with empty data" { + PARENT_NAME="test_add" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "data/empty.json" + assert_equal "$SC" 422 +} + +@test "captures: Add a new declare capture to a non existing frontend" { + PARENT_NAME="fake" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "data/add.json" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/captures/data/add.json b/e2e/tests/captures/data/add.json new file mode 100644 index 00000000..af9d9015 --- /dev/null +++ b/e2e/tests/captures/data/add.json @@ -0,0 +1,4 @@ +{ + "type": "request", + "length": 12345 +} diff --git a/e2e/tests/captures/data/empty.json b/e2e/tests/captures/data/empty.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/e2e/tests/captures/data/empty.json @@ -0,0 +1 @@ +{} diff --git a/e2e/tests/captures/data/haproxy.cfg b/e2e/tests/captures/data/haproxy.cfg new file mode 100644 index 00000000..bf07a350 --- /dev/null +++ b/e2e/tests/captures/data/haproxy.cfg @@ -0,0 +1,30 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +frontend test + declare capture request len 1 + declare capture response len 2 + +frontend test_second + declare capture request len 111 + declare capture response len 222 + declare capture request len 8888 + declare capture response len 9999 + +frontend test_replace + declare capture request len 1 + declare capture response len 2 + +frontend test_add + +frontend test_delete + declare capture request len 1 + declare capture response len 2 + +frontend test_empty diff --git a/e2e/tests/captures/data/replace-all.json b/e2e/tests/captures/data/replace-all.json new file mode 100644 index 00000000..4c7749c7 --- /dev/null +++ b/e2e/tests/captures/data/replace-all.json @@ -0,0 +1,13 @@ +[ + { + "length": 10, + "type": "request" + }, + { + "length": 11, + "type": "response" + }, { + "length": 12, + "type": "request" + } +] diff --git a/e2e/tests/captures/data/replace.json b/e2e/tests/captures/data/replace.json new file mode 100644 index 00000000..ad9a3168 --- /dev/null +++ b/e2e/tests/captures/data/replace.json @@ -0,0 +1,5 @@ +{ + "index": 0, + "type": "response", + "length": 123456789 +} diff --git a/e2e/tests/captures/delete.bats b/e2e/tests/captures/delete.bats new file mode 100644 index 00000000..81970a56 --- /dev/null +++ b/e2e/tests/captures/delete.bats @@ -0,0 +1,48 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "captures: Delete a declare capture by it's index" { + PARENT_NAME="test_delete" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/1" + assert_equal "$SC" 202 +} + +@test "captures: Delete a declare capture by it's index and reload" { + PARENT_NAME="test_delete" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "force_reload=true" + assert_equal "$SC" 204 +} + +@test "captures: Delete a non existing declare capture by it's index" { + PARENT_NAME="test_delete" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/1000" + assert_equal "$SC" 404 +} + +@test "captures: Delete a non existing declare capture in a non existant frotnend by it's index" { + PARENT_NAME="fake" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/captures/get.bats b/e2e/tests/captures/get.bats new file mode 100644 index 00000000..1f628685 --- /dev/null +++ b/e2e/tests/captures/get.bats @@ -0,0 +1,89 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "captures: Get one declare capture request" { + PARENT_NAME="test" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "frontend=test" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".type")" "request" + assert_equal "$(get_json_path "${BODY}" ".length")" 1 +} + +@test "captures: Get one declare capture response" { + PARENT_NAME="test" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".type")" "response" + assert_equal "$(get_json_path "${BODY}" ".length")" 2 +} + +@test "captures: Get one non existing declare capture" { + PARENT_NAME="test" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/1000" "frontend=test" + assert_equal "$SC" 404 +} + +@test "captures: Get one non existing declare capture from a non existant frontend" { + PARENT_NAME="fake" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/1000" + assert_equal "$SC" 404 +} + +@test "captures: Get first declare capture request" { + PARENT_NAME="test_second" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".type")" "request" + assert_equal "$(get_json_path "${BODY}" ".length")" 111 +} + +@test "captures: Get second declare capture request" { + PARENT_NAME="test_second" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".type")" "response" + assert_equal "$(get_json_path "${BODY}" ".length")" 222 +} + +@test "captures: Get third declare capture request" { + PARENT_NAME="test_second" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/2" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".type")" "request" + assert_equal "$(get_json_path "${BODY}" ".length")" 8888 +} + +@test "captures: Get fourth declare capture request" { + PARENT_NAME="test_second" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/3" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".type")" "response" + assert_equal "$(get_json_path "${BODY}" ".length")" 9999 +} + +@test "captures: Get fifth declare capture request" { + resource_get "$_CAPTURES_BASE_PATH/4" "frontend=test_second" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/captures/list.bats b/e2e/tests/captures/list.bats new file mode 100644 index 00000000..857848db --- /dev/null +++ b/e2e/tests/captures/list.bats @@ -0,0 +1,51 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "captures: Return an array of all declare captures from the test frontend" { + PARENT_NAME="test" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 +} + +@test "captures: Return an array of all declare captures from the test_second frontend" { + PARENT_NAME="test_second" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 4 +} + +@test "captures: Return an array of all declare captures from the test_empty frontend" { + PARENT_NAME="test_empty" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 0 +} + +@test "captures: Return an array of all declare captures from a non existing frontend" { + PARENT_NAME="fake" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/captures/replace.bats b/e2e/tests/captures/replace.bats new file mode 100644 index 00000000..ab93b3b7 --- /dev/null +++ b/e2e/tests/captures/replace.bats @@ -0,0 +1,52 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "captures: Replace an existing declare capture" { + PARENT_NAME="test_replace" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "data/replace.json" + assert_equal "$SC" 202 +} + +@test "captures: Replace an existing declare capture with an empty one" { + PARENT_NAME="test_replace" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "data/empty.json" + assert_equal "$SC" 422 +} + +@test "captures: Replace a non existing declare capture in a non existing frontend" { + PARENT_NAME="fake" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures/0" "data/replace.json" + assert_equal "$SC" 404 +} + +@test "captures: Replace all existing declare capture" { + PARENT_NAME="test_replace" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures" "data/replace-all.json" + assert_equal "$SC" 202 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/captures" + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} diff --git a/e2e/tests/captures/utils/_helpers.bash b/e2e/tests/captures/utils/_helpers.bash new file mode 100644 index 00000000..476c8902 --- /dev/null +++ b/e2e/tests/captures/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/cluster_to_single/data/ca.crt b/e2e/tests/cluster_to_single/data/ca.crt new file mode 100644 index 00000000..43b6b015 --- /dev/null +++ b/e2e/tests/cluster_to_single/data/ca.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDFTCCAf2gAwIBAgIUQQ6qd1y9nRmzbdfk6rRDeVvyNoQwDQYJKoZIhvcNAQEL +BQAwGTEXMBUGA1UEAwwOZGFwaS1lMmUtdGVzdHMwIBcNMjQwNzI5MDkwNzA1WhgP +MjEyNDA3MDUwOTA3MDVaMBkxFzAVBgNVBAMMDmRhcGktZTJlLXRlc3RzMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzCKc5MDHaVrq0lQK32rZAbKuhsrX +BtRXnkPWkmbdzGUBHW50OwjLTbbeOrIR5UW1W/erRV2Kxin4b4z/m8pyqIr6Can2 +bU4K8ZSXt4d0XocfaBFby4gZxGwBhEPPoqWupPNinnXSeedENzoxcfuPAF5+Tt9U +ymKTa6WvVdMwkT1hrXi38qg16l2f65bKyEBEAxK9cv5JbSzJpnCYiRqI6Na+ulUF +z5bj6y6eplTjhyvNMGAIni12DrR9i/z1ps8Kzo47hyuSbV5YzyGYxIbZTkXzhS21 +KYtLDzhR/EW+m3MSSL11jsznBbwHQUaQrb8t1E7pUEeW71vYbpt6KTFSxQIDAQAB +o1MwUTAdBgNVHQ4EFgQUuwxGY3tKxken6mFv9UJrfEn1um8wHwYDVR0jBBgwFoAU +uwxGY3tKxken6mFv9UJrfEn1um8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B +AQsFAAOCAQEATCfmd5O7h8WzqQoqOBJnACX3pbTcAnglwU3kXEI4WpNgAc+4puXy +ev/PZK+CJHk4EZIOpcszE/oTr+Y1/ztaLotDGCv4Lfp6TnhoM7s9hBVnu/3r9rrz +8Ubfwu2gpFOHC25rXbze5nYYzl5wvNzfONXL3deSMbbLa9sjHzJCPDQ60reca+pb +NIOwl3j7TTk9nC6jJ1myTJfAjy/dzdxdmiXBhbrnJqDUGhWYUgx7T9HHTvpOMLjE +mjxVQAaQaWr/yOUSmDr6o433xFzgEm+6Q10gnvbCfCB2DmP2iZsef5+dQ+4hvxWB +c6JsXvCcqtMMZaya9gAdUUqJls2pDVe3VQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/cluster_to_single/data/ca.key b/e2e/tests/cluster_to_single/data/ca.key new file mode 100644 index 00000000..c2440f17 --- /dev/null +++ b/e2e/tests/cluster_to_single/data/ca.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDMIpzkwMdpWurS +VArfatkBsq6GytcG1FeeQ9aSZt3MZQEdbnQ7CMtNtt46shHlRbVb96tFXYrGKfhv +jP+bynKoivoJqfZtTgrxlJe3h3Rehx9oEVvLiBnEbAGEQ8+ipa6k82KeddJ550Q3 +OjFx+48AXn5O31TKYpNrpa9V0zCRPWGteLfyqDXqXZ/rlsrIQEQDEr1y/kltLMmm +cJiJGojo1r66VQXPluPrLp6mVOOHK80wYAieLXYOtH2L/PWmzwrOjjuHK5JtXljP +IZjEhtlORfOFLbUpi0sPOFH8Rb6bcxJIvXWOzOcFvAdBRpCtvy3UTulQR5bvW9hu +m3opMVLFAgMBAAECggEAFLsJIuP+/FCK21xElGbV7em29qJfzuY+lah/AHQo3yp8 +v//pFtuwRc6l5+EQly+KmPHgd1VmE/TMMYvoo2oeVcZzWQrlJzmPO/RiqfU8GKNx +SZDFuTgzobJ0Pvnh+rsHruG2qK//dXjKgS9MOS6aWae+/QSKKFl1bi+vzC/71Svv +r5U8NRd2Y0LTgNdiXPkTZybo95HqCYqK2ueVtWXGiR/aJ4LBEsBJLz9Gbf7gAmV3 +B/QHWG6zXA01FzYWUQvtLlG1F2lvhFRRBlmx5zFM4CQIdrqt3+t8SM95C6YjFEe8 +rK7NItxwAPNNM3Bft00mnkIzeIFGLrzEKwyyrhXhIQKBgQDfgBEYaPp3+g1sDvSs +VlZChpD+mELRPpzcUyid2tukymHx2r6ovlHQwf7RkiF3h37oDKGH1woO7dHF/ov0 +iZ+F7fUQzSATUiommCRiyFxLtmlBdqNoPqoX63QiBgwtzAgZPVSHBmWpxRyGHBHh +ryzwUGTxRBTKkKyAyQLWT3MrVQKBgQDp0auPN2CkCyc6UUMB/J6BQaTqqop7G12K +6oaOdi8zPoBeCx0GNu6SIXT4+cObB8D+2zKsYPmZmnMqKQ/I0PCVHn3rFS9xusyZ +CwQMPHiObCaZ1VaP0pNXBAELKnjF7srskOHj3zbzzxVkYkjQUS3BTENLMydKTU0M +1zOHB6DpsQKBgQDUVAFptEnHc2oO74JouzkFyHu1M4e+7AHvmp0qokIqow47y3l4 +LB7j+XkRNgfPW40n/N/0gkmO90ZkGDhz388KWI+KH6XKVTOwKLfglMKCN1B1nbUO +EwJa6RgSPraRR5WmDMrh4CTzDUzU55PhWR+TSn0rbGdoLduEGfM1EJO0ZQKBgQDN +4jSJX/61k6iP/jvdhP5g3FeF1nMnoVoF1ypySPiYy8EmjeyZq0b434LrNKobWYGE +J6kABkfiDBC6H/vpHKmq9HV1yWrEXvKHFB8VUy3oYqy+qg6Vh5r7dOgiV9yOlQyT +r6NoDgWKO18fzDdHTyPV3/wlPD6te1GMK/YQQRRckQKBgQC3LjWRdEiXSmKr6MED +h5kzI1u5BTMJFgKcxiNTRoCw9hMShmbNK4fN/JInIo0Q3y89nbvTwF6t+RLQTuQq +wx7b94ct9/h+suhXQuiQ26VIeNMDr88F7wbKAG93NXs+tm82YRbEW+0HWnZ73G3w +UvH76edcHgcpOAjeBpn8KJlKeA== +-----END PRIVATE KEY----- diff --git a/e2e/tests/cluster_to_single/data/cluster.json b/e2e/tests/cluster_to_single/data/cluster.json new file mode 100644 index 00000000..9c98c6ee --- /dev/null +++ b/e2e/tests/cluster_to_single/data/cluster.json @@ -0,0 +1,29 @@ +{ + "users": [ + { + "name": "dpapi-c-vU9DIiJH", + "insecure": false, + "password": "$6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0" + } + ], + "status": "active", + "cluster": { + "api_nodes_path": "/nodes", + "token": "01J3MCAA2W7QREFKXW6XVDNYX4", + "cluster_tls_dir": "/var/lib/dataplaneapi/storage", + "active_bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "api_register_path": "/clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes", + "url": "http://127.0.0.1", + "port": 4449, + "storage_dir": "/etc/haproxy", + "bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "id": "01J3MCAA2WAVV294QGPG750BYA", + "api_base_path": "/v1", + "cert_path": "/var/lib/dataplaneapi/storage/certs-cluster", + "cert_fetched": true, + "use_hash_storage": false, + "name": "hd-laptop", + "description": "", + "cluster_id": "ab8d85c5-4f12-4eec-b270-79bf53d48d44" + } + } diff --git a/e2e/tests/cluster_to_single/data/dataplaneapi-before-migration.yaml b/e2e/tests/cluster_to_single/data/dataplaneapi-before-migration.yaml new file mode 100644 index 00000000..16876d31 --- /dev/null +++ b/e2e/tests/cluster_to_single/data/dataplaneapi-before-migration.yaml @@ -0,0 +1,59 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + user: + - name: dpapi-c-vU9DIiJH + insecure: false + password: >- + $6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0 + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe + waf_dir: /etc/haproxy/waf +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true +status: active +cluster: + api_nodes_path: /nodes + token: 01J3MCAA2W7QREFKXW6XVDNYX4 + cluster_tls_dir: /var/lib/dataplaneapi/storage + active_bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + api_register_path: /clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes + url: 'http://127.0.0.1' + port: 4449 + storage_dir: /etc/haproxy + bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + id: 01J3MCAA2WAVV294QGPG750BYA + api_base_path: /v1 + cert_path: /var/lib/dataplaneapi/storage/certs-cluster + cert_fetched: true + use_hash_storage: false + name: hd-laptop + description: '' + cluster_id: ab8d85c5-4f12-4eec-b270-79bf53d48d44 diff --git a/e2e/tests/cluster_to_single/data/dataplaneapi.yaml b/e2e/tests/cluster_to_single/data/dataplaneapi.yaml new file mode 100644 index 00000000..cadc0f7c --- /dev/null +++ b/e2e/tests/cluster_to_single/data/dataplaneapi.yaml @@ -0,0 +1,33 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe + waf_dir: /etc/haproxy/waf +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true diff --git a/e2e/tests/cluster_to_single/migration.bats b/e2e/tests/cluster_to_single/migration.bats new file mode 100644 index 00000000..cf68ec83 --- /dev/null +++ b/e2e/tests/cluster_to_single/migration.bats @@ -0,0 +1,102 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/resource_client' +load 'utils/_helpers' + + +## This tests that we can switch from cluster mode to single mode +## using the cluster + user defined in dataplaneapi.yaml and that should be migrated to cluster.json + +setup() { + # Stop dapi + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + # Set up everything for running in cluster mode + # BUT in migration context, i.e. cluster and users defined in dataplaneapi.yaml and not in cluster.json + run dpa_docker_exec 'mkdir -p /var/lib/dataplaneapi/storage/certs-cluster' + assert_success + + run docker cp "${BATS_TEST_DIRNAME}/data/ca.crt" "${DOCKER_CONTAINER_NAME}:/var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.crt" + assert_success + + run docker cp "${BATS_TEST_DIRNAME}/data/ca.key" "${DOCKER_CONTAINER_NAME}:/var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.key" + assert_success + + # Copy to dataplaneapi.yaml the version that contains the cluster and cluster user + run docker cp "${BATS_TEST_DIRNAME}/data/dataplaneapi-before-migration.yaml" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplaneapi.yaml" + assert_success + + # Start dapi + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + assert_success + + # Wait for dapi to be ready with cluster user + # using the cluster mode user in this call (see dpa_curl_clustermode in utils/_helpers.bash) + until dpa_curl_clustermode GET "/info"; do + sleep 0.1 + done + +} + +# teardown returns original configuration to dataplane +teardown() { + # Stop dapi + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + run dpa_docker_exec 'rm /var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.key' + assert_success + run dpa_docker_exec 'rm /var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.crt' + assert_success + run dpa_docker_exec 'rm /etc/haproxy/dataplane/cluster.json' + assert_success + + # copy original one + run docker cp "${BATS_TEST_DIRNAME}/data/dataplaneapi.yaml" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplaneapi.yaml" + assert_success + + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + assert_success + + until dpa_curl GET "/info"; do + sleep 0.1 + done + +} + +@test "cluster to single: migration from cluster and users defined in dataplaneapi.yaml" { + # DELETE cluster and check that we get back to single mode user + # using the cluster mode user in this call (see dpa_curl_clustermode in utils/_helpers.bash) + run dpa_curl_clustermode DELETE "/cluster" + dpa_curl_status_body '$output' + assert_equal "$SC" 204 + + # Check that single mode user is now ok + until dpa_curl GET "/info"; do + sleep 0.1 + done +} diff --git a/e2e/tests/cluster_to_single/tests.bats b/e2e/tests/cluster_to_single/tests.bats new file mode 100644 index 00000000..64c0c8bc --- /dev/null +++ b/e2e/tests/cluster_to_single/tests.bats @@ -0,0 +1,96 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/resource_client' +load 'utils/_helpers' + + +## This tests that we can switch from cluster mode to single mode +## using the cluster + user defined in cluster.json + +setup() { + # Stop dapi + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + # Set up everything for running in cluster mode + run dpa_docker_exec 'mkdir -p /var/lib/dataplaneapi/storage/certs-cluster' + assert_success + + run docker cp "${BATS_TEST_DIRNAME}/data/ca.crt" "${DOCKER_CONTAINER_NAME}:/var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.crt" + assert_success + + run docker cp "${BATS_TEST_DIRNAME}/data/ca.key" "${DOCKER_CONTAINER_NAME}:/var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.key" + assert_success + + run docker cp "${BATS_TEST_DIRNAME}/data/cluster.json" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplane/cluster.json" + assert_success + + # Start dapi + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + assert_success + + # Wait for dapi to be ready with cluster user + # using the cluster mode user in this call (see dpa_curl_clustermode in utils/_helpers.bash) + until dpa_curl_clustermode GET "/info"; do + sleep 0.1 + done + +} + +# teardown returns original configuration to dataplane +teardown() { + # Stop dapi + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + run dpa_docker_exec 'rm /var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.key' + assert_success + run dpa_docker_exec 'rm /var/lib/dataplaneapi/storage/certs-cluster/dataplane-famous_condor.crt' + assert_success + run dpa_docker_exec 'rm /etc/haproxy/dataplane/cluster.json' + assert_success + + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + assert_success + + until dpa_curl GET "/info"; do + sleep 0.1 + done + +} + +@test "cluster to single: with cluster.json" { + # DELETE cluster and check that we get back to single mode user + # using the cluster mode user in this call (see dpa_curl_clustermode in utils/_helpers.bash) + run dpa_curl_clustermode DELETE "/cluster" + dpa_curl_status_body '$output' + assert_equal "$SC" 204 + + # Check that single mode user is now ok + until dpa_curl GET "/info"; do + sleep 0.1 + done +} diff --git a/e2e/tests/cluster_to_single/utils/_helpers.bash b/e2e/tests/cluster_to_single/utils/_helpers.bash new file mode 100644 index 00000000..fa13b2f3 --- /dev/null +++ b/e2e/tests/cluster_to_single/utils/_helpers.bash @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_ACL_BASE_PATH="/services/haproxy/configuration/acls" + + +function dpa_curl_clustermode() { + verb=$1; shift + endpoint=$1; shift + data="@${BATS_TEST_DIRNAME}/$1"; + if [ -z "$1" ]; then + data="/dev/null" + fi + curl -k -m 10 -s -H 'content-type: application/json' --user dpapi-c-vU9DIiJH:WLKrmlnvOxyHSAmtSi0xRue3 "-X${verb}" -w "\n%{http_code}" "-d${data}" "https://${LOCAL_IP_ADDRESS}:${E2E_PORT}${BASE_PATH}${endpoint}" +} diff --git a/e2e/tests/crt_store/crt_store.bats b/e2e/tests/crt_store/crt_store.bats new file mode 100644 index 00000000..83e5424f --- /dev/null +++ b/e2e/tests/crt_store/crt_store.bats @@ -0,0 +1,89 @@ +#!/usr/bin/env bats +# +# Copyright 2024 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +# We are using "haproxy_config_setup" here because we need the files +# from data/container. HAProxy will actually load those PEM files when +# checking if the configuration is valid. + +@test "crt_store: all tests (>=3.0)" { + haproxy_version_ge "3.0" || skip + + resource_post "$_CRT_STORE_PATH" "data/new_store.json" "force_reload=true" + assert_equal "$SC" "201" + + resource_get "$_CRT_STORE_PATH/$_STORE_NAME" + assert_equal "$SC" "200" + assert_equal "$_STORE_NAME" "$(get_json_path "$BODY" .name)" + assert_equal "/secure/certs" "$(get_json_path "$BODY" .crt_base)" + assert_equal "/secure/keys" "$(get_json_path "$BODY" .key_base)" + + resource_put "$_CRT_STORE_PATH/$_STORE_NAME" "data/edit_store.json" "force_reload=true" + assert_equal "$SC" "200" + resource_get "$_CRT_STORE_PATH/$_STORE_NAME" + assert_equal "/sec" "$(get_json_path "$BODY" .key_base)" + + resource_get "$_CRT_STORE_PATH" + assert_equal "$SC" "200" + assert_equal "$_STORE_NAME" "$(get_json_path "$BODY" .[0].name)" + + resource_post "$_CRT_LOAD_PATH" "data/post_entry1.json" "crt_store=$_STORE_NAME" + assert_equal "$SC" "202" + resource_post "$_CRT_LOAD_PATH" "data/post_entry2.json" "crt_store=$_STORE_NAME" + assert_equal "$SC" "202" + + resource_get "$_CRT_LOAD_PATH/c1.pem" "crt_store=$_STORE_NAME" + assert_equal "$SC" "200" + assert_equal "c1.pem" "$(get_json_path "$BODY" .certificate)" + assert_equal "k1.pem" "$(get_json_path "$BODY" .key)" + assert_equal "disabled" "$(get_json_path "$BODY" .ocsp_update)" + + resource_get "$_CRT_LOAD_PATH" "crt_store=$_STORE_NAME" + assert_equal "$SC" "200" + assert_equal "2" "$(get_json_path "$BODY" '.|length')" + assert_equal "c1.pem" "$(get_json_path "$BODY" .[0].certificate)" + assert_equal "c2.pem" "$(get_json_path "$BODY" .[1].certificate)" + + resource_put "$_CRT_LOAD_PATH/c2.pem" "data/put_entry.json" \ + "crt_store=$_STORE_NAME" "force_reload=true" + assert_equal "$SC" "202" + resource_get "$_CRT_LOAD_PATH/c2.pem" "crt_store=$_STORE_NAME" + assert_equal "c2.pem" "$(get_json_path "$BODY" .certificate)" + assert_equal "disabled" "$(get_json_path "$BODY" .ocsp_update)" + assert_equal "example.com" "$(get_json_path "$BODY" .alias)" + + resource_delete "$_CRT_LOAD_PATH/c1.pem" "crt_store=$_STORE_NAME" "force_reload=true" + assert_equal "$SC" "202" + resource_delete "$_CRT_LOAD_PATH/c2.pem" "crt_store=$_STORE_NAME" "force_reload=true" + assert_equal "$SC" "202" + resource_get "$_CRT_LOAD_PATH/c2.pem" "crt_store=$_STORE_NAME" + assert_equal "$SC" "404" + + resource_delete "$_CRT_STORE_PATH/$_STORE_NAME" "force_reload=true" + assert_equal "$SC" "204" + resource_get "$_CRT_STORE_PATH/$_STORE_NAME" + assert_equal "$SC" "404" +} diff --git a/e2e/tests/crt_store/data/container/sec/c1.pem b/e2e/tests/crt_store/data/container/sec/c1.pem new file mode 100644 index 00000000..2ad75e65 --- /dev/null +++ b/e2e/tests/crt_store/data/container/sec/c1.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICVjCCAb8CAg37MA0GCSqGSIb3DQEBBQUAMIGbMQswCQYDVQQGEwJKUDEOMAwG +A1UECBMFVG9reW8xEDAOBgNVBAcTB0NodW8ta3UxETAPBgNVBAoTCEZyYW5rNERE +MRgwFgYDVQQLEw9XZWJDZXJ0IFN1cHBvcnQxGDAWBgNVBAMTD0ZyYW5rNEREIFdl +YiBDQTEjMCEGCSqGSIb3DQEJARYUc3VwcG9ydEBmcmFuazRkZC5jb20wHhcNMTIw +ODIyMDUyNzIzWhcNMTcwODIxMDUyNzIzWjBKMQswCQYDVQQGEwJKUDEOMAwGA1UE +CAwFVG9reW8xETAPBgNVBAoMCEZyYW5rNEREMRgwFgYDVQQDDA93d3cuZXhhbXBs +ZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMYBBrx5PlP0WNI/ZdzD ++6Pktmurn+F2kQYbtc7XQh8/LTBvCo+P6iZoLEmUA9e7EXLRxgU1CVqeAi7QcAn9 +MwBlc8ksFJHB0rtf9pmf8Oza9E0Bynlq/4/Kb1x+d+AyhL7oK9tQwB24uHOueHi1 +C/iVv8CSWKiYe6hzN1txYe8rAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAASPdjigJ +kXCqKWpnZ/Oc75EUcMi6HztaW8abUMlYXPIgkV2F7YanHOB7K4f7OOLjiz8DTPFf +jC9UeuErhaA/zzWi8ewMTFZW/WshOrm3fNvcMrMLKtH534JKvcdMg6qIdjTFINIr +evnAhf0cwULaebn+lMs8Pdl7y37+sfluVok= +-----END CERTIFICATE----- diff --git a/e2e/tests/crt_store/data/container/sec/c2.pem b/e2e/tests/crt_store/data/container/sec/c2.pem new file mode 100644 index 00000000..2ad75e65 --- /dev/null +++ b/e2e/tests/crt_store/data/container/sec/c2.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICVjCCAb8CAg37MA0GCSqGSIb3DQEBBQUAMIGbMQswCQYDVQQGEwJKUDEOMAwG +A1UECBMFVG9reW8xEDAOBgNVBAcTB0NodW8ta3UxETAPBgNVBAoTCEZyYW5rNERE +MRgwFgYDVQQLEw9XZWJDZXJ0IFN1cHBvcnQxGDAWBgNVBAMTD0ZyYW5rNEREIFdl +YiBDQTEjMCEGCSqGSIb3DQEJARYUc3VwcG9ydEBmcmFuazRkZC5jb20wHhcNMTIw +ODIyMDUyNzIzWhcNMTcwODIxMDUyNzIzWjBKMQswCQYDVQQGEwJKUDEOMAwGA1UE +CAwFVG9reW8xETAPBgNVBAoMCEZyYW5rNEREMRgwFgYDVQQDDA93d3cuZXhhbXBs +ZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMYBBrx5PlP0WNI/ZdzD ++6Pktmurn+F2kQYbtc7XQh8/LTBvCo+P6iZoLEmUA9e7EXLRxgU1CVqeAi7QcAn9 +MwBlc8ksFJHB0rtf9pmf8Oza9E0Bynlq/4/Kb1x+d+AyhL7oK9tQwB24uHOueHi1 +C/iVv8CSWKiYe6hzN1txYe8rAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAASPdjigJ +kXCqKWpnZ/Oc75EUcMi6HztaW8abUMlYXPIgkV2F7YanHOB7K4f7OOLjiz8DTPFf +jC9UeuErhaA/zzWi8ewMTFZW/WshOrm3fNvcMrMLKtH534JKvcdMg6qIdjTFINIr +evnAhf0cwULaebn+lMs8Pdl7y37+sfluVok= +-----END CERTIFICATE----- diff --git a/e2e/tests/crt_store/data/container/sec/k1.pem b/e2e/tests/crt_store/data/container/sec/k1.pem new file mode 100644 index 00000000..727a03ba --- /dev/null +++ b/e2e/tests/crt_store/data/container/sec/k1.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICWwIBAAKBgQDGAQa8eT5T9FjSP2Xcw/uj5LZrq5/hdpEGG7XO10IfPy0wbwqP +j+omaCxJlAPXuxFy0cYFNQlangIu0HAJ/TMAZXPJLBSRwdK7X/aZn/Ds2vRNAcp5 +av+Pym9cfnfgMoS+6CvbUMAduLhzrnh4tQv4lb/AkliomHuoczdbcWHvKwIDAQAB +AoGAXzxrIwgmBHeIqUe5FOBnDsOZQlyAQA+pXYjCf8Rll2XptFwUdkzAUMzWUGWT +G5ZspA9l8Wc7IozRe/bhjMxuVK5yZhPDKbjqRdWICA95Jd7fxlIirHOVMQRdzI7x +NKqMNQN05MLJfsEHUYtOLhZE+tfhJTJnnmB7TMwnJgc4O5ECQQD8oOJ45tyr46zc +OAt6ao7PefVLiW5Qu+PxfoHmZmDV2UQqeM5XtZg4O97VBSugOs3+quIdAC6LotYl +/6N+E4y3AkEAyKWD2JNCrAgtjk2bfF1HYt24tq8+q7x2ek3/cUhqwInkrZqOFoke +x3+yBB879TuUOadvBXndgMHHcJQKSAJlLQJAXRuGnHyptAhTe06EnHeNbtZKG67p +I4Q8PJMdmSb+ZZKP1v9zPUxGb+NQ+z3OmF1T8ppUf8/DV9+KAbM4NI1L/QJAdGBs +BKYFObrUkYE5+fwwd4uao3sponqBTZcH3jDemiZg2MCYQUHu9E+AdRuYrziLVJVk +s4xniVLb1tRG0lVxUQJASfjdGT81HDJSzTseigrM+JnBKPPrzpeEp0RbTP52Lm23 +YARjLCwmPMMdAwYZsvqeTuHEDQcOHxLHWuyN/zgP2A== +-----END RSA PRIVATE KEY----- diff --git a/e2e/tests/crt_store/data/edit_store.json b/e2e/tests/crt_store/data/edit_store.json new file mode 100644 index 00000000..74aecea0 --- /dev/null +++ b/e2e/tests/crt_store/data/edit_store.json @@ -0,0 +1,5 @@ +{ + "name": "test_store1", + "crt_base": "/sec", + "key_base": "/sec" +} \ No newline at end of file diff --git a/e2e/tests/crt_store/data/new_store.json b/e2e/tests/crt_store/data/new_store.json new file mode 100644 index 00000000..1ff1388c --- /dev/null +++ b/e2e/tests/crt_store/data/new_store.json @@ -0,0 +1,5 @@ +{ + "name": "test_store1", + "crt_base": "/secure/certs", + "key_base": "/secure/keys" +} \ No newline at end of file diff --git a/e2e/tests/crt_store/data/post_entry1.json b/e2e/tests/crt_store/data/post_entry1.json new file mode 100644 index 00000000..1e636bc9 --- /dev/null +++ b/e2e/tests/crt_store/data/post_entry1.json @@ -0,0 +1,5 @@ +{ + "certificate": "c1.pem", + "key": "k1.pem", + "ocsp_update": "disabled" +} diff --git a/e2e/tests/crt_store/data/post_entry2.json b/e2e/tests/crt_store/data/post_entry2.json new file mode 100644 index 00000000..37d44571 --- /dev/null +++ b/e2e/tests/crt_store/data/post_entry2.json @@ -0,0 +1,4 @@ +{ + "certificate": "c2.pem", + "ocsp_update": "enabled" +} \ No newline at end of file diff --git a/e2e/tests/crt_store/data/put_entry.json b/e2e/tests/crt_store/data/put_entry.json new file mode 100644 index 00000000..96e8a824 --- /dev/null +++ b/e2e/tests/crt_store/data/put_entry.json @@ -0,0 +1,5 @@ +{ + "certificate": "c2.pem", + "ocsp_update": "disabled", + "alias": "example.com" +} \ No newline at end of file diff --git a/e2e/tests/crt_store/utils/_helpers.bash b/e2e/tests/crt_store/utils/_helpers.bash new file mode 100644 index 00000000..1f173716 --- /dev/null +++ b/e2e/tests/crt_store/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2024 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_STORE_NAME="test_store1" +_CRT_STORE_PATH="/services/haproxy/configuration/crt_stores" +_CRT_LOAD_PATH="/services/haproxy/configuration/crt_loads" diff --git a/e2e/tests/defaults/create.bats b/e2e/tests/defaults/create.bats new file mode 100644 index 00000000..3d852d7c --- /dev/null +++ b/e2e/tests/defaults/create.bats @@ -0,0 +1,66 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/debug' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "defaults: Create a named defaults configuration" { + resource_post "$_DEFAULTS_BASE_PATH" "data/post.json" "" + assert_equal "$SC" 202 + + resource_get "$_DEFAULTS_BASE_PATH/created" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" '.name')" "created" + assert_equal "$(get_json_path "$BODY" '.server_timeout')" "20000" + assert_equal "$(get_json_path "$BODY" '.client_timeout')" "20000" + assert_equal "$(get_json_path "$BODY" '.mode')" "http" +} + +@test "defaults: Create a named defaults configuration that already exists" { + resource_post "$_DEFAULTS_BASE_PATH" "data/post_existing.json" "" + assert_equal "$SC" 409 +} + +@test "defaults: Create a named defaults configuration with from" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + resource_post "$_DEFAULTS_BASE_PATH" "data/post.json" "" + assert_equal "$SC" 202 + + resource_get "$_DEFAULTS_BASE_PATH/created" + assert_equal "$SC" 200 + + resource_post "$_DEFAULTS_BASE_PATH" "data/post_with_from.json" "" + assert_equal "$SC" 202 + + resource_get "$_DEFAULTS_BASE_PATH/created_with_from" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" '.name')" "created_with_from" + assert_equal "$(get_json_path "$BODY" '.from')" "created" + assert_equal "$(get_json_path "$BODY" '.server_timeout')" "20000" + assert_equal "$(get_json_path "$BODY" '.client_timeout')" "20000" + assert_equal "$(get_json_path "$BODY" '.mode')" "http" +} diff --git a/e2e/tests/defaults/data/haproxy.cfg b/e2e/tests/defaults/data/haproxy.cfg new file mode 100644 index 00000000..5430760b --- /dev/null +++ b/e2e/tests/defaults/data/haproxy.cfg @@ -0,0 +1,23 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults + mode http + log global + option httplog + option dontlognull + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout connect 10s + timeout client 300s + timeout server 300s + maxconn 5000 diff --git a/e2e/tests/defaults/data/post.json b/e2e/tests/defaults/data/post.json new file mode 100644 index 00000000..a3aef62b --- /dev/null +++ b/e2e/tests/defaults/data/post.json @@ -0,0 +1,6 @@ +{ + "name": "created", + "client_timeout": 20000, + "server_timeout": 20000, + "mode": "http" +} diff --git a/e2e/tests/defaults/data/post_existing.json b/e2e/tests/defaults/data/post_existing.json new file mode 100644 index 00000000..390fa514 --- /dev/null +++ b/e2e/tests/defaults/data/post_existing.json @@ -0,0 +1,6 @@ +{ + "name": "unnamed_defaults_1", + "client_timeout": 20000, + "server_timeout": 20000, + "mode": "http" +} diff --git a/e2e/tests/defaults/data/post_with_from.json b/e2e/tests/defaults/data/post_with_from.json new file mode 100644 index 00000000..a2c5f988 --- /dev/null +++ b/e2e/tests/defaults/data/post_with_from.json @@ -0,0 +1,7 @@ +{ + "name": "created_with_from", + "from": "created", + "client_timeout": 20000, + "server_timeout": 20000, + "mode": "http" +} diff --git a/e2e/tests/defaults/data/put.json b/e2e/tests/defaults/data/put.json new file mode 100644 index 00000000..528dded3 --- /dev/null +++ b/e2e/tests/defaults/data/put.json @@ -0,0 +1,6 @@ +{ + "name": "unnamed_defaults_1", + "client_timeout": 25000, + "server_timeout": 25000, + "mode": "tcp" +} diff --git a/e2e/tests/defaults/delete.bats b/e2e/tests/defaults/delete.bats new file mode 100644 index 00000000..1c1bc0c7 --- /dev/null +++ b/e2e/tests/defaults/delete.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "defaults: Delete a named defaults configuration" { + resource_delete "$_DEFAULTS_BASE_PATH/unnamed_defaults_1" + assert_equal "$SC" 202 +} + +@test "defaults: Delete a named defaults configuration that does not exist" { + resource_delete "$_DEFAULTS_BASE_PATH/nothing_to_see_here" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/defaults/get.bats b/e2e/tests/defaults/get.bats new file mode 100644 index 00000000..1168c499 --- /dev/null +++ b/e2e/tests/defaults/get.bats @@ -0,0 +1,64 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + + +@test "defaults: Return a list of defaults configurations" { + resource_get "$_DEFAULTS_BASE_PATH" + assert_equal "$SC" 200 + + # log_target_list is a child resource, it should not be filled when full_section=false + assert_equal "$(get_json_path "$BODY" ".[] | select(.name | contains(\"unnamed_defaults_1\")).log_target_list.[0].global")" "null" +} + +@test "default: return a list of defaults configurations with full section" { + resource_get "$_DEFAULTS_BASE_PATH" "full_section=true" + assert_equal "$SC" 200 + + # log_target_list is a child resource, it should be filled when full_section=true + assert_equal "$(get_json_path "$BODY" ".[] | select(.name | contains(\"unnamed_defaults_1\")).log_target_list.[0].global")" "true" +} + +@test "defaults: Return a defaults configuration" { + resource_get "$_DEFAULTS_BASE_PATH/unnamed_defaults_1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "unnamed_defaults_1" + + # log_target_list is a child resource, it should not be filled when full_section=false + assert_equal "$(get_json_path "$BODY" ".log_target_list.[0].global")" "null" +} + +@test "defaults: Return a defaults configuration with full section" { + resource_get "$_DEFAULTS_BASE_PATH/unnamed_defaults_1" "full_section=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "unnamed_defaults_1" + + # log_target_list is a child resource, it should be filled when full_section=true + assert_equal "$(get_json_path "$BODY" ".log_target_list.[0].global")" "true" +} + +@test "defaults: Return a named defaults configuration that does not exist" { + resource_get "$_DEFAULTS_BASE_PATH/nothing_to_see_here" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/defaults/replace.bats b/e2e/tests/defaults/replace.bats new file mode 100644 index 00000000..dbc524d2 --- /dev/null +++ b/e2e/tests/defaults/replace.bats @@ -0,0 +1,41 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + + +@test "backends: Replace a defaults" { + resource_put "$_DEFAULTS_BASE_PATH/unnamed_defaults_1" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_DEFAULTS_BASE_PATH/unnamed_defaults_1" assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "unnamed_defaults_1" + assert_equal "$(get_json_path "$BODY" ".mode")" "tcp" + assert_equal "$(get_json_path "$BODY" ".client_timeout")" 25000 + assert_equal "$(get_json_path "$BODY" ".server_timeout")" 25000 +} + +@test "defaults: Replace a defaults configuration that doesn't exist" { + resource_get "$_DEFAULTS_BASE_PATH/these_arent_the_droids_youre_looking_for" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/defaults/utils/_helpers.bash b/e2e/tests/defaults/utils/_helpers.bash new file mode 100644 index 00000000..4e2db65d --- /dev/null +++ b/e2e/tests/defaults/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_DEFAULTS_BASE_PATH="/services/haproxy/configuration/defaults" + +_ERR_SUPPORTED_HAPROXY_VERSION="2.4" diff --git a/e2e/tests/dgram_binds/data/haproxy.cfg b/e2e/tests/dgram_binds/data/haproxy.cfg new file mode 100644 index 00000000..b602af0a --- /dev/null +++ b/e2e/tests/dgram_binds/data/haproxy.cfg @@ -0,0 +1,26 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +backend test_backend_add + mode tcp + option tcp-check + +log-forward sylog-loadb + dgram-bind 127.0.0.1:1514 name test_dgram_bind + bind 127.0.0.1:1514 + timeout client 50000 + # all messages on stderr + log global + # all messages on local tcp syslog server + log ring@myring local0 + # load balance messages on 4 udp syslog servers + log 127.0.0.1:10001 sample 1:4 local0 + log 127.0.0.1:10002 sample 2:4 local0 + log 127.0.0.1:10003 sample 3:4 local0 + log 127.0.0.1:10004 sample 4:4 local0 diff --git a/e2e/tests/dgram_binds/data/post.json b/e2e/tests/dgram_binds/data/post.json new file mode 100644 index 00000000..4e8dd988 --- /dev/null +++ b/e2e/tests/dgram_binds/data/post.json @@ -0,0 +1,7 @@ +{ + "address": "127.0.0.1", + "name": "sylog-loadb", + "port": 1622, + "interface": "eth0", + "transparent": true +} diff --git a/e2e/tests/dgram_binds/data/put.json b/e2e/tests/dgram_binds/data/put.json new file mode 100644 index 00000000..bf6fb4be --- /dev/null +++ b/e2e/tests/dgram_binds/data/put.json @@ -0,0 +1,7 @@ +{ + "address": "127.0.0.1", + "name": "sylog-loadb2", + "port": 1500, + "interface": "eth0", + "transparent": true +} diff --git a/e2e/tests/dgram_binds/test.bats b/e2e/tests/dgram_binds/test.bats new file mode 100644 index 00000000..0e869b0c --- /dev/null +++ b/e2e/tests/dgram_binds/test.bats @@ -0,0 +1,72 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "dgram_binds: Add a dgram bind" { + if haproxy_version_ge "2.3" + then + PARENT_NAME="sylog-loadb" + resource_post "$_LOGFORWARD_BASE_PATH/$PARENT_NAME/dgram_binds" "data/post.json" "force_reload=true" + assert_equal "$SC" "201" + fi +} + +@test "dgram_binds: Return a dgram bind" { + if haproxy_version_ge "2.3" + then + PARENT_NAME="sylog-loadb" + resource_get "$_LOGFORWARD_BASE_PATH/$PARENT_NAME/dgram_binds/test_dgram_bind" + assert_equal "$SC" 200 + assert_equal "test_dgram_bind" "$(get_json_path "$BODY" '.name')" + fi +} + +@test "dgram_binds: Replace a dgram bind" { + if haproxy_version_ge "2.3" + then + PARENT_NAME="sylog-loadb" + resource_put "$_LOGFORWARD_BASE_PATH/$PARENT_NAME/dgram_binds/test_dgram_bind" "data/put.json" "log_forward=sylog-loadb&force_reload=true" + assert_equal "$SC" 200 + fi +} + +@test "dgram_binds: Return an array of dgram binds" { + if haproxy_version_ge "2.3" + then + PARENT_NAME="sylog-loadb" + resource_get "$_LOGFORWARD_BASE_PATH/$PARENT_NAME/dgram_binds" + assert_equal "$SC" 200 + assert_equal "test_dgram_bind" "$(get_json_path "$BODY" '.[0].name')" + fi +} + +@test "dgram_binds: Delete a dgram bind" { + if haproxy_version_ge "2.3" + then + PARENT_NAME="sylog-loadb" + resource_delete "$_LOGFORWARD_BASE_PATH/$PARENT_NAME/dgram_binds/test_dgram_bind" "force_reload=true" + assert_equal "$SC" 204 + fi +} diff --git a/e2e/tests/dgram_binds/utils/_helpers.bash b/e2e/tests/dgram_binds/utils/_helpers.bash new file mode 100644 index 00000000..5bf97bcb --- /dev/null +++ b/e2e/tests/dgram_binds/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_LOGFORWARD_BASE_PATH="/services/haproxy/configuration/log_forwards" diff --git a/e2e/tests/fcgi_app/create.bats b/e2e/tests/fcgi_app/create.bats new file mode 100644 index 00000000..00afaa0b --- /dev/null +++ b/e2e/tests/fcgi_app/create.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "fcgi-app: Create one new app" { + resource_post "$_FCGIAPP_BASE_PATH" "data/app.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_FCGIAPP_BASE_PATH/app_created" + assert_equal "$SC" 200 + assert_equal "app_created" "$(get_json_path "$BODY" ".name")" + assert_equal "/path/to/chroot" "$(get_json_path "$BODY" ".docroot")" +} + +@test "fcgi-app: Fail creating app with same name" { + resource_post "$_FCGIAPP_BASE_PATH" "data/app_duplicated.json" "force_reload=true" + assert_equal "$SC" 409 +} + +@test "fcgi-app: Fail creating app that isn't valid" { + resource_post "$_FCGIAPP_BASE_PATH" "data/app_unvalid.json" "force_reload=true" + assert_equal "$SC" 422 +} diff --git a/e2e/tests/fcgi_app/data/app.json b/e2e/tests/fcgi_app/data/app.json new file mode 100644 index 00000000..84038ecc --- /dev/null +++ b/e2e/tests/fcgi_app/data/app.json @@ -0,0 +1,10 @@ +{ + "name": "app_created", + "docroot": "/path/to/chroot", + "index": "index.php", + "log_stderrs": [ + { + "global": true + } + ] +} diff --git a/e2e/tests/fcgi_app/data/app_duplicated.json b/e2e/tests/fcgi_app/data/app_duplicated.json new file mode 100644 index 00000000..a9a30071 --- /dev/null +++ b/e2e/tests/fcgi_app/data/app_duplicated.json @@ -0,0 +1,5 @@ +{ + "name": "test_1", + "docroot": "/path/to/chroot", + "index": "index.php" +} diff --git a/e2e/tests/fcgi_app/data/app_unvalid.json b/e2e/tests/fcgi_app/data/app_unvalid.json new file mode 100644 index 00000000..31f0e3bb --- /dev/null +++ b/e2e/tests/fcgi_app/data/app_unvalid.json @@ -0,0 +1,4 @@ +{ + "name": "app_created", + "index": "index.php" +} \ No newline at end of file diff --git a/e2e/tests/fcgi_app/data/haproxy.cfg b/e2e/tests/fcgi_app/data/haproxy.cfg new file mode 100644 index 00000000..5c875c5d --- /dev/null +++ b/e2e/tests/fcgi_app/data/haproxy.cfg @@ -0,0 +1,38 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +fcgi-app test_1 + docroot /path/to/chroot + index index.php + log-stderr global + +fcgi-app test_2 + docroot /path/to/chroot + index index.php + log-stderr global diff --git a/e2e/tests/fcgi_app/delete.bats b/e2e/tests/fcgi_app/delete.bats new file mode 100644 index 00000000..ab36cecd --- /dev/null +++ b/e2e/tests/fcgi_app/delete.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "fcgi-app: Delete one app by name" { + resource_delete "$_FCGIAPP_BASE_PATH/test_1" "force_reload=true" + assert_equal "$SC" 204 + + resource_get "$_FCGIAPP_BASE_PATH/test_1" + assert_equal "$SC" 404 +} + +@test "fcgi-app: Fail deleting app that doesn't exist" { + resource_delete "$_FCGIAPP_BASE_PATH/i_am_not_here" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/fcgi_app/get.bats b/e2e/tests/fcgi_app/get.bats new file mode 100644 index 00000000..879e23b6 --- /dev/null +++ b/e2e/tests/fcgi_app/get.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "fcgi-app: Return one app by name" { + resource_get "$_FCGIAPP_BASE_PATH/test_1" + assert_equal "$SC" 200 + assert_equal "test_1" "$(get_json_path "$BODY" ".name")" + assert_equal "index.php" "$(get_json_path "$BODY" ".index")" +} + +@test "fcgi-app: Fail returning app that doesn't exist" { + resource_get "$_FCGIAPP_BASE_PATH/i_am_not_here" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/fcgi_app/list.bats b/e2e/tests/fcgi_app/list.bats new file mode 100644 index 00000000..0caba181 --- /dev/null +++ b/e2e/tests/fcgi_app/list.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "fcgi-app: Return an array of apps" { + resource_get "$_FCGIAPP_BASE_PATH" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" +} diff --git a/e2e/tests/fcgi_app/replace.bats b/e2e/tests/fcgi_app/replace.bats new file mode 100644 index 00000000..6da093a1 --- /dev/null +++ b/e2e/tests/fcgi_app/replace.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "fcgi-app: Replace one app" { + resource_put "$_FCGIAPP_BASE_PATH/test_1" "data/app_duplicated.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FCGIAPP_BASE_PATH/test_1" + assert_equal "$SC" 200 + assert_equal "test_1" "$(get_json_path "$BODY" ".name")" + assert_equal "$(get_json_path "${BODY}" ".log_stder | length")" 0 +} + +@test "fcgi-app: Fail replacing app that doesn't exist" { + resource_put "$_FCGIAPP_BASE_PATH/i_am_not_here" "data/app_duplicated.json" "force_reload=true" + assert_equal "$SC" 409 +} diff --git a/e2e/tests/fcgi_app/utils/_helpers.bash b/e2e/tests/fcgi_app/utils/_helpers.bash new file mode 100644 index 00000000..b6438c4f --- /dev/null +++ b/e2e/tests/fcgi_app/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_FCGIAPP_BASE_PATH="/services/haproxy/configuration/fcgi_apps" diff --git a/e2e/tests/frontends/data/post.json b/e2e/tests/frontends/data/post.json new file mode 100644 index 00000000..6e7fbc5f --- /dev/null +++ b/e2e/tests/frontends/data/post.json @@ -0,0 +1,6 @@ +{ + "http_connection_mode": "httpclose", + "maxconn": 1000, + "mode": "tcp", + "name": "test_frontend" +} diff --git a/e2e/tests/frontends/data/put.json b/e2e/tests/frontends/data/put.json new file mode 100644 index 00000000..40e8b6fa --- /dev/null +++ b/e2e/tests/frontends/data/put.json @@ -0,0 +1,6 @@ +{ + "http_connection_mode": "http-keep-alive", + "maxconn": 2000, + "mode": "http", + "name": "test_frontend" +} diff --git a/e2e/tests/frontends/test.bats b/e2e/tests/frontends/test.bats new file mode 100644 index 00000000..8c926ea0 --- /dev/null +++ b/e2e/tests/frontends/test.bats @@ -0,0 +1,61 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "frontends: Add a frontend" { + resource_post "$_FRONTEND_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" "201" +} + +@test "frontends: Return a frontend" { + resource_get "$_FRONTEND_BASE_PATH/test_frontend" + assert_equal "$SC" 200 + assert_equal "test_frontend" "$(get_json_path "$BODY" '.name')" +} + +@test "frontends: Replace a frontend" { + resource_put "$_FRONTEND_BASE_PATH/test_frontend" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + # + # Retrieving the current data + # + resource_get "$_FRONTEND_BASE_PATH/test_frontend" + assert_equal "http-keep-alive" "$(get_json_path "$BODY" '.http_connection_mode')" + assert_equal "http" "$(get_json_path "$BODY" '.mode')" +} + +@test "frontends: Return an array of frontends" { + resource_get "$_FRONTEND_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.[0].name')" "test_frontend" +} + +@test "frontends: Delete a frontend" { + resource_delete "$_FRONTEND_BASE_PATH/test_frontend" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleted frontend should be not found + # + resource_get "$_FRONTEND_BASE_PATH/test_frontend" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/frontends/utils/_helpers.bash b/e2e/tests/frontends/utils/_helpers.bash new file mode 100644 index 00000000..476c8902 --- /dev/null +++ b/e2e/tests/frontends/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/global/data/haproxy.cfg b/e2e/tests/global/data/haproxy.cfg new file mode 100644 index 00000000..17939d32 --- /dev/null +++ b/e2e/tests/global/data/haproxy.cfg @@ -0,0 +1,7 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin diff --git a/e2e/tests/global/data/haproxy_2.8.cfg b/e2e/tests/global/data/haproxy_2.8.cfg new file mode 100644 index 00000000..2a335fb8 --- /dev/null +++ b/e2e/tests/global/data/haproxy_2.8.cfg @@ -0,0 +1,13 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + tune.ssl.ocsp-update.mindelay 10 + tune.stick-counters 50 + tune.h2.be.initial-window-size 10 + tune.h2.be.max-concurrent-streams 11 + tune.h2.fe.initial-window-size 12 + tune.h2.fe.max-concurrent-streams 13 diff --git a/e2e/tests/global/data/put.json b/e2e/tests/global/data/put.json new file mode 100644 index 00000000..2cad8b8c --- /dev/null +++ b/e2e/tests/global/data/put.json @@ -0,0 +1,14 @@ +{ + "runtime_apis": [ + { + "address": "/var/lib/haproxy/stats", + "level": "admin" + } + ], + "daemon": true, + "master-worker": true, + "performance_options": { + "maxconn": 5000 + }, + "pidfile": "/var/run/haproxy.pid" +} diff --git a/e2e/tests/global/data/put_2.8.json b/e2e/tests/global/data/put_2.8.json new file mode 100644 index 00000000..087ba99e --- /dev/null +++ b/e2e/tests/global/data/put_2.8.json @@ -0,0 +1,20 @@ +{ + "runtime_apis": [ + { + "address": "/var/lib/haproxy/stats", + "level": "admin" + } + ], + "tune_options": { + "h2_be_initial_window_size": 20, + "h2_be_max_concurrent_streams": 21, + "h2_fe_initial_window_size": 22, + "h2_fe_max_concurrent_streams": 23 + }, + "performance_options": { + "maxconn": 5000 + }, + "daemon": true, + "master-worker": true, + "pidfile": "/var/run/haproxy.pid" +} diff --git a/e2e/tests/global/data/put_socket.json b/e2e/tests/global/data/put_socket.json new file mode 100644 index 00000000..e72ab532 --- /dev/null +++ b/e2e/tests/global/data/put_socket.json @@ -0,0 +1,14 @@ +{ + "runtime_apis": [ + { + "address": "/var/lib/haproxy/stats-new", + "level": "admin" + } + ], + "daemon": true, + "master-worker": true, + "performance_options": { + "maxconn": 5000 + }, + "pidfile": "/var/run/haproxy.pid" +} diff --git a/e2e/tests/global/get.bats b/e2e/tests/global/get.bats new file mode 100644 index 00000000..4c31aee4 --- /dev/null +++ b/e2e/tests/global/get.bats @@ -0,0 +1,45 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "global: Return a global configuration" { + resource_get "$_GLOBAL_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.chroot')" "/var/lib/haproxy" + assert_equal "$(get_json_path "$BODY" '.user')" "haproxy" + assert_equal "$(get_json_path "$BODY" '.group')" "haproxy" + assert_equal "$(get_json_path "$BODY" '.performance_options.maxconn')" "4000" + assert_equal "$(get_json_path "$BODY" '.pidfile')" "/var/run/haproxy.pid" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].address')" "/var/lib/haproxy/stats" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].level')" "admin" + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" '.tune_ssl_options.ocsp_update_min_delay')" "10" + assert_equal "$(get_json_path "$BODY" '.tune_options.stick_counters')" "50" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_be_initial_window_size')" "10" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_be_max_concurrent_streams')" "11" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_fe_initial_window_size')" "12" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_fe_max_concurrent_streams')" "13" + fi +} diff --git a/e2e/tests/global/replace.bats b/e2e/tests/global/replace.bats new file mode 100644 index 00000000..a47da3bf --- /dev/null +++ b/e2e/tests/global/replace.bats @@ -0,0 +1,117 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "global: Replace a global configuration" { + resource_put "$_GLOBAL_BASE_PATH" "data/put.json" "" + assert_equal "$SC" 202 + + resource_get "$_GLOBAL_BASE_PATH" "" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.performance_options.maxconn')" "5000" + assert_equal "$(get_json_path "$BODY" '.daemon')" "true" + assert_equal "$(get_json_path "$BODY" '.pidfile')" "/var/run/haproxy.pid" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].address')" "/var/lib/haproxy/stats" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].level')" "admin" +} + + +@test "global: Replace a global configuration with socket path changed" { + resource_put "$_GLOBAL_BASE_PATH" "data/put_socket.json" "" + assert_equal "$SC" 202 + + resource_get "$_GLOBAL_BASE_PATH" "" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.performance_options.maxconn')" "5000" + assert_equal "$(get_json_path "$BODY" '.daemon')" "true" + assert_equal "$(get_json_path "$BODY" '.pidfile')" "/var/run/haproxy.pid" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].address')" "/var/lib/haproxy/stats-new" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].level')" "admin" + + # check that runtime client has been reconfigured with the new socket + sleep 5 + resource_get "$_RUNTIME_MAP_FILES_BASE_PATH" "" + assert_equal "$SC" 200 +} + +@test "global: Replace a global configuration with socket path changed (using transaction)" { + # create transaction + resource_post "$_TRANSACTIONS_BASE_PATH" "" + assert_equal "$SC" 201 + local transaction_id; transaction_id=$(get_json_path "${BODY}" ".id") + + # PUT new configuration + run dpa_curl PUT "${_GLOBAL_BASE_PATH}?transaction_id=${transaction_id}" "data/put_socket.json" + assert_success + dpa_curl_status_body '$output' + assert_equal "$SC" 202 + + # commit transaction + resource_put "$_TRANSACTIONS_BASE_PATH/$transaction_id" "" + assert_equal "$SC" 202 + + # check configuration has been applied + resource_get "$_GLOBAL_BASE_PATH" "" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.performance_options.maxconn')" "5000" + assert_equal "$(get_json_path "$BODY" '.daemon')" "true" + assert_equal "$(get_json_path "$BODY" '.pidfile')" "/var/run/haproxy.pid" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].address')" "/var/lib/haproxy/stats-new" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].level')" "admin" + + # check that runtime client has been reconfigured with the new socket + sleep 5 + resource_get "$_RUNTIME_MAP_FILES_BASE_PATH" "" + assert_equal "$SC" 200 +} + + +@test "global: Manually replace a global configuration with socket path changed" { + # check HAPRoxy is configured with the expected socket + resource_get "$_GLOBAL_BASE_PATH" "" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].address')" "/var/lib/haproxy/stats" + + pre_logs_count=$(dpa_docker_exec 'cat /var/log/dataplaneapi.log' | wc -l) + + # manually change configuration + run dpa_docker_exec "sed -i 's@/var/lib/haproxy/stats@/var/lib/haproxy/stats-new@' /etc/haproxy/haproxy.cfg" + + sleep 5 + # check configuration has been reloaded + resource_get "$_GLOBAL_BASE_PATH" "" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].address')" "/var/lib/haproxy/stats-new" + + # check that runtime client has been reconfigured with the new socket + post_logs_count=$(dpa_docker_exec 'sh /var/log/dataplaneapi.log' | wc -l) + new_logs_count=$(( $pre_logs_count - $post_logs_count )) + new_logs=$(dpa_docker_exec 'cat /var/log/dataplaneapi.log' | tail -n $new_logs_count) + + echo "$new_logs" # this will help debugging if the test fails + assert echo -e "$new_logs" | grep -q "reload callback completed, runtime API reconfigured" + + resource_get "$_RUNTIME_MAP_FILES_BASE_PATH" "" + assert_equal "$SC" 200 +} diff --git a/e2e/tests/global/replace_2.8.bats b/e2e/tests/global/replace_2.8.bats new file mode 100644 index 00000000..b755f55d --- /dev/null +++ b/e2e/tests/global/replace_2.8.bats @@ -0,0 +1,45 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "global: Replace a global configuration (>=2.8)" { + if haproxy_version_ge "2.8" + then + resource_put "$_GLOBAL_BASE_PATH" "data/put_2.8.json" "" + assert_equal "$SC" 202 + + resource_get "$_GLOBAL_BASE_PATH" "" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.performance_options.maxconn')" "5000" + assert_equal "$(get_json_path "$BODY" '.daemon')" "true" + assert_equal "$(get_json_path "$BODY" '.pidfile')" "/var/run/haproxy.pid" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].address')" "/var/lib/haproxy/stats" + assert_equal "$(get_json_path "$BODY" '.runtime_apis[0].level')" "admin" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_be_initial_window_size')" "20" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_be_max_concurrent_streams')" "21" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_fe_initial_window_size')" "22" + assert_equal "$(get_json_path "$BODY" '.tune_options.h2_fe_max_concurrent_streams')" "23" + fi +} diff --git a/e2e/tests/global/utils/_helpers.bash b/e2e/tests/global/utils/_helpers.bash new file mode 100644 index 00000000..23904db9 --- /dev/null +++ b/e2e/tests/global/utils/_helpers.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_GLOBAL_BASE_PATH="/services/haproxy/configuration/global" +_RUNTIME_MAP_FILES_BASE_PATH="/services/haproxy/runtime/maps" +_TRANSACTIONS_BASE_PATH="/services/haproxy/transactions" + diff --git a/e2e/tests/groups/add.bats b/e2e/tests/groups/add.bats new file mode 100644 index 00000000..48a756cc --- /dev/null +++ b/e2e/tests/groups/add.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "groups: Add a group" { + resource_post "$_GROUPS_BASE_PATH" "data/post.json" "userlist=first&=force_reload=true" + assert_equal "$SC" 202 +} + +@test "groups: Add a group to a non existing user list" { + resource_post "$_GROUPS_BASE_PATH" "data/post.json" "userlist=fake&=force_reload=true" + assert_equal "$SC" 404 +} + +@test "groups: Add a malformed group" { + resource_post "$_GROUPS_BASE_PATH" "data/empty.json" "userlist=first&force_reload=true" + assert_equal "$SC" 422 +} diff --git a/e2e/tests/groups/data/empty.json b/e2e/tests/groups/data/empty.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/e2e/tests/groups/data/empty.json @@ -0,0 +1 @@ +{} diff --git a/e2e/tests/groups/data/haproxy.cfg b/e2e/tests/groups/data/haproxy.cfg new file mode 100644 index 00000000..e66e3303 --- /dev/null +++ b/e2e/tests/groups/data/haproxy.cfg @@ -0,0 +1,38 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +userlist first + group G1 users tiger,scott + group G2 users scott + user tiger password $6$k6y3o.eP$JlKBx9za9667qe4xHSwRv6J.C0/D7cV91 + user scott insecure-password elgato + +userlist second + group one + group two + group three + user neo password JlKBxxHSwRv6J.C0/D7cV91 groups one + user thomas insecure-password white-rabbit groups one,two + user anderson insecure-password hello groups two + +userlist empty + +userlist add_test + group G3 + group G4 + +userlist replace_test + group zion + group io + user trinity insecure-password the-one groups zion + +userlist delete_test + group antivirus + group virus + user smith insecure-password cloning groups virus diff --git a/e2e/tests/groups/data/post.json b/e2e/tests/groups/data/post.json new file mode 100644 index 00000000..38edecdf --- /dev/null +++ b/e2e/tests/groups/data/post.json @@ -0,0 +1,4 @@ +{ + "name": "new", + "users": null +} diff --git a/e2e/tests/groups/data/replace.json b/e2e/tests/groups/data/replace.json new file mode 100644 index 00000000..7381bcae --- /dev/null +++ b/e2e/tests/groups/data/replace.json @@ -0,0 +1,4 @@ +{ + "name": "zion", + "users": "trinity" +} diff --git a/e2e/tests/groups/delete.bats b/e2e/tests/groups/delete.bats new file mode 100644 index 00000000..8f62b806 --- /dev/null +++ b/e2e/tests/groups/delete.bats @@ -0,0 +1,49 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "groups: Delete a group" { + resource_delete "$_GROUPS_BASE_PATH/antivirus" "userlist=delete_test" + assert_equal "$SC" 202 +} + +@test "groups: Delete a group and reload" { + resource_delete "$_GROUPS_BASE_PATH/antivirus" "userlist=delete_test&force_reload=true" + assert_equal "$SC" 204 +} + +@test "groups: Delete a group that is assigned to an existing user" { + # resource_delete "$_GROUPS_BASE_PATH/virus" "userlist=delete_test&force_reload=true" + # assert_equal "$SC" 400 +} + +@test "groups: Delete a non existing group" { + resource_delete "$_GROUPS_BASE_PATH/fake" "userlist=delete_test&force_reload=true" + assert_equal "$SC" 404 +} + +@test "groups: Delete a non existing group in a non existing userlist" { + resource_delete "$_GROUPS_BASE_PATH/fake" "userlist=fake&force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/groups/get.bats b/e2e/tests/groups/get.bats new file mode 100644 index 00000000..d4488ed0 --- /dev/null +++ b/e2e/tests/groups/get.bats @@ -0,0 +1,69 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "groups: Return group G1 from a userlist" { + resource_get "$_GROUPS_BASE_PATH/G1" "userlist=first" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "G1" + assert_equal "$(get_json_path "$BODY" ".users")" "tiger,scott" +} + +@test "groups: Return group G2 from a userlist" { + resource_get "$_GROUPS_BASE_PATH/G2" "userlist=first" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "G2" + assert_equal "$(get_json_path "$BODY" ".users")" "scott" +} + +@test "groups: Return a non existing group from a userlist" { + resource_get "$_GROUPS_BASE_PATH/fake" "userlist=first" + assert_equal "$SC" 404 +} + +@test "groups: Return a non existing group from a non existing userlist" { + resource_get "$_GROUPS_BASE_PATH/fake" "userlist=fake" + assert_equal "$SC" 400 +} + +@test "groups: Return group one from a userlist" { + resource_get "$_GROUPS_BASE_PATH/one" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "one" + assert_equal "$(get_json_path "$BODY" ".users")" null +} + +@test "groups: Return group two from a userlist" { + resource_get "$_GROUPS_BASE_PATH/two" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "two" + assert_equal "$(get_json_path "$BODY" ".users")" null +} + +@test "groups: Return group three from a userlist" { + resource_get "$_GROUPS_BASE_PATH/three" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "three" + assert_equal "$(get_json_path "$BODY" ".users")" null +} diff --git a/e2e/tests/groups/list.bats b/e2e/tests/groups/list.bats new file mode 100644 index 00000000..4171acbc --- /dev/null +++ b/e2e/tests/groups/list.bats @@ -0,0 +1,62 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "groups: Return an array of groups from userlist first" { + resource_get "$_GROUPS_BASE_PATH" "userlist=first" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + + assert_equal "$(get_json_path "${BODY}" ".[0].name" )" "G1" + assert_equal "$(get_json_path "${BODY}" ".[0].users" )" "tiger,scott" + + assert_equal "$(get_json_path "${BODY}" ".[1].name" )" "G2" + assert_equal "$(get_json_path "${BODY}" ".[1].users" )" "scott" +} + +@test "groups: Return an array of groups from userlist second" { + resource_get "$_GROUPS_BASE_PATH" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + + assert_equal "$(get_json_path "${BODY}" ".[0].name" )" "one" + assert_equal "$(get_json_path "${BODY}" ".[0].users" )" null + + assert_equal "$(get_json_path "${BODY}" ".[1].name" )" "two" + assert_equal "$(get_json_path "${BODY}" ".[1].users" )" null + + assert_equal "$(get_json_path "${BODY}" ".[2].name" )" "three" + assert_equal "$(get_json_path "${BODY}" ".[2].users" )" null +} + +@test "groups: Return an array of groups from userlist empty" { + resource_get "$_GROUPS_BASE_PATH" "userlist=empty" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 0 +} + +@test "groups: Return an array of groups from non existing userlist" { + resource_get "$_GROUPS_BASE_PATH" "userlist=fake" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/groups/replace.bats b/e2e/tests/groups/replace.bats new file mode 100644 index 00000000..39671f12 --- /dev/null +++ b/e2e/tests/groups/replace.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "groups: Replace a group" { + resource_put "$_GROUPS_BASE_PATH/zion" "data/replace.json" "userlist=replace_test&force_reload=true" + assert_equal "$SC" 200 +} + +@test "groups: Replace a group with malformed data" { + resource_put "$_GROUPS_BASE_PATH/io" "data/empty.json" "userlist=replace_test&force_reload=true" + assert_equal "$SC" 422 +} + +@test "groups: Replace a non existing group" { + resource_put "$_GROUPS_BASE_PATH/fake" "data/replace.json" "userlist=replace_test&force_reload=true" + assert_equal "$SC" 404 +} + +@test "groups: Replace a non existing group in a non existing user list" { + resource_put "$_GROUPS_BASE_PATH/1000" "data/replace.json" "userlist=fake&force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/groups/utils/_helpers.bash b/e2e/tests/groups/utils/_helpers.bash new file mode 100644 index 00000000..41db9e2c --- /dev/null +++ b/e2e/tests/groups/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_GROUPS_BASE_PATH="/services/haproxy/configuration/groups" diff --git a/e2e/tests/haproxy/test.bats b/e2e/tests/haproxy/test.bats new file mode 100644 index 00000000..cb8ef4fa --- /dev/null +++ b/e2e/tests/haproxy/test.bats @@ -0,0 +1,25 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load 'utils/_helpers' + +@test "haproxy: Return HAProxy process information" { + resource_get "$_HAPROXY_BASE_PATH" + assert_equal "$SC" 200 +} diff --git a/e2e/tests/haproxy/utils/_helpers.bash b/e2e/tests/haproxy/utils/_helpers.bash new file mode 100644 index 00000000..2693bb6f --- /dev/null +++ b/e2e/tests/haproxy/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_HAPROXY_BASE_PATH="/services/haproxy/runtime/info" diff --git a/e2e/tests/http_after_response_rules/add.bats b/e2e/tests/http_after_response_rules/add.bats new file mode 100644 index 00000000..c76fca6f --- /dev/null +++ b/e2e/tests/http_after_response_rules/add.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_after_response_rules: Add a new HTTP After Response Rule to frontend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "http_after_response_rules: Add a new HTTP After Response Rule to backend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} diff --git a/e2e/tests/http_after_response_rules/data/haproxy.cfg b/e2e/tests/http_after_response_rules/data/haproxy.cfg new file mode 100644 index 00000000..1807ea49 --- /dev/null +++ b/e2e/tests/http_after_response_rules/data/haproxy.cfg @@ -0,0 +1,41 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + http-after-response add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 } + http-after-response del-header X-Del-Frontend if { src 10.1.0.0/16 } + +backend test_backend + mode http + balance roundrobin + option forwardfor + http-after-response add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 } + http-after-response del-header X-Del-Backend if { src 10.1.0.0/16 } diff --git a/e2e/tests/http_after_response_rules/data/haproxy_2.8.cfg b/e2e/tests/http_after_response_rules/data/haproxy_2.8.cfg new file mode 100644 index 00000000..8e88bb2f --- /dev/null +++ b/e2e/tests/http_after_response_rules/data/haproxy_2.8.cfg @@ -0,0 +1,50 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + http-after-response add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 } + http-after-response del-header X-Del-Frontend if { src 10.1.0.0/16 } + http-after-response set-map(map.lst) %[src] %[res.hdr(X-Value)] + http-after-response del-map(map.lst) %[src] if FALSE + http-after-response del-acl(map.lst) %[src] if FALSE + http-after-response sc-inc-gpc(0,1) if FALSE + http-after-response sc-inc-gpc0(0) if FALSE + http-after-response sc-inc-gpc1(0) if FALSE + http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE + http-after-response sc-set-gpt0(1) 20 if FALSE + http-after-response set-log-level silent if FALSE + +backend test_backend + mode http + balance roundrobin + option forwardfor + http-after-response add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 } + http-after-response del-header X-Del-Backend if { src 10.1.0.0/16 } diff --git a/e2e/tests/http_after_response_rules/data/post.json b/e2e/tests/http_after_response_rules/data/post.json new file mode 100644 index 00000000..cef79f42 --- /dev/null +++ b/e2e/tests/http_after_response_rules/data/post.json @@ -0,0 +1,7 @@ +{ + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" +} diff --git a/e2e/tests/http_after_response_rules/data/put.json b/e2e/tests/http_after_response_rules/data/put.json new file mode 100644 index 00000000..166c7e8e --- /dev/null +++ b/e2e/tests/http_after_response_rules/data/put.json @@ -0,0 +1,7 @@ +{ + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" +} diff --git a/e2e/tests/http_after_response_rules/data/replace-all.json b/e2e/tests/http_after_response_rules/data/replace-all.json new file mode 100644 index 00000000..f59d726b --- /dev/null +++ b/e2e/tests/http_after_response_rules/data/replace-all.json @@ -0,0 +1,23 @@ +[ + { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" + }, + { + "cond": "if", + "cond_test": "{ src 192.168.0.1/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" + }, + { + "cond": "if", + "cond_test": "{ src 192.168.0.2/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" + } +] diff --git a/e2e/tests/http_after_response_rules/delete.bats b/e2e/tests/http_after_response_rules/delete.bats new file mode 100644 index 00000000..40872f52 --- /dev/null +++ b/e2e/tests/http_after_response_rules/delete.bats @@ -0,0 +1,118 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_after_response_rules: Delete a HTTP After Response Rule from frontend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + # + # Deleting the first one + # + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the second one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + if haproxy_version_ge "2.8"; then + # Deleting the third one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the fourth one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the fifth one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the sixth one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the seventh one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the eighth one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the ninth one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the tenth one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the eleventh one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + fi + # No more HTTP after response rules, not found! + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_after_response_rules: Delete a HTTP After Response Rule from backend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + # + # Deleting the first one + # + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the second one + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # No more HTTP after response rules, not found! + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_after_response_rules/get.bats b/e2e/tests/http_after_response_rules/get.bats new file mode 100644 index 00000000..5e96adf1 --- /dev/null +++ b/e2e/tests/http_after_response_rules/get.bats @@ -0,0 +1,66 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_after_response_rules: Return one HTTP After Response Rule from frontend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Add-Frontend" + assert_equal "$(get_json_path "$BODY" ".cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Del-Frontend" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 10.1.0.0/16 }" +} + +@test "http_after_response_rules: Return one HTTP After Response Rule from backend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Add-Backend" + assert_equal "$(get_json_path "$BODY" ".cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Del-Backend" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 10.1.0.0/16 }" +} diff --git a/e2e/tests/http_after_response_rules/list.bats b/e2e/tests/http_after_response_rules/list.bats new file mode 100644 index 00000000..48acd718 --- /dev/null +++ b/e2e/tests/http_after_response_rules/list.bats @@ -0,0 +1,107 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_after_response_rules: Return an array of all HTTP After Response Rules from frontend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules" + assert_equal "$SC" 200 + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ". | length")" 11 + else + assert_equal "$(get_json_path "$BODY" ". | length")" 2 + fi + assert_equal "$(get_json_path "$BODY" ".[0].type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".[0].hdr_name")" "X-Add-Frontend" + assert_equal "$(get_json_path "$BODY" ".[0].cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".[0].cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".[1].hdr_name")" "X-Del-Frontend" + assert_equal "$(get_json_path "$BODY" ".[1].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[1].cond_test")" "{ src 10.1.0.0/16 }" + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ".[2].type")" "set-map" + assert_equal "$(get_json_path "$BODY" ".[2].map_file")" "map.lst" + assert_equal "$(get_json_path "$BODY" ".[2].map_keyfmt")" "%[src]" + assert_equal "$(get_json_path "$BODY" ".[2].map_valuefmt")" "%[res.hdr(X-Value)]" + assert_equal "$(get_json_path "$BODY" ".[3].type")" "del-map" + assert_equal "$(get_json_path "$BODY" ".[3].map_file")" "map.lst" + assert_equal "$(get_json_path "$BODY" ".[3].map_keyfmt")" "%[src]" + assert_equal "$(get_json_path "$BODY" ".[3].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[3].cond_test")" "FALSE" + assert_equal "$(get_json_path "$BODY" ".[4].type")" "del-acl" + assert_equal "$(get_json_path "$BODY" ".[4].acl_file")" "map.lst" + assert_equal "$(get_json_path "$BODY" ".[4].acl_keyfmt")" "%[src]" + assert_equal "$(get_json_path "$BODY" ".[4].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[4].cond_test")" "FALSE" + assert_equal "$(get_json_path "$BODY" ".[5].type")" "sc-inc-gpc" + assert_equal "$(get_json_path "$BODY" ".[5].sc_id")" "1" + assert_equal "$(get_json_path "$BODY" ".[5].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[5].cond_test")" "FALSE" + assert_equal "$(get_json_path "$BODY" ".[6].type")" "sc-inc-gpc0" + assert_equal "$(get_json_path "$BODY" ".[6].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[6].cond_test")" "FALSE" + assert_equal "$(get_json_path "$BODY" ".[7].type")" "sc-inc-gpc1" + assert_equal "$(get_json_path "$BODY" ".[7].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[7].cond_test")" "FALSE" + assert_equal "$(get_json_path "$BODY" ".[8].type")" "sc-set-gpt0" + assert_equal "$(get_json_path "$BODY" ".[8].sc_id")" "1" + assert_equal "$(get_json_path "$BODY" ".[8].sc_expr")" "hdr(Host),lower" + assert_equal "$(get_json_path "$BODY" ".[8].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[8].cond_test")" "FALSE" + assert_equal "$(get_json_path "$BODY" ".[9].type")" "sc-set-gpt0" + assert_equal "$(get_json_path "$BODY" ".[9].sc_id")" "1" + assert_equal "$(get_json_path "$BODY" ".[9].sc_int")" "20" + assert_equal "$(get_json_path "$BODY" ".[9].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[9].cond_test")" "FALSE" + assert_equal "$(get_json_path "$BODY" ".[10].type")" "set-log-level" + assert_equal "$(get_json_path "$BODY" ".[10].log_level")" "silent" + assert_equal "$(get_json_path "$BODY" ".[10].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[10].cond_test")" "FALSE" + fi +} + +@test "http_after_response_rules: Return one HTTP After Response Rule from backend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + assert_equal "$(get_json_path "$BODY" ".[0].type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".[0].hdr_name")" "X-Add-Backend" + assert_equal "$(get_json_path "$BODY" ".[0].cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".[0].cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".[1].hdr_name")" "X-Del-Backend" + assert_equal "$(get_json_path "$BODY" ".[1].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[1].cond_test")" "{ src 10.1.0.0/16 }" +} diff --git a/e2e/tests/http_after_response_rules/missing_parent.bats b/e2e/tests/http_after_response_rules/missing_parent.bats new file mode 100644 index 00000000..fe234292 --- /dev/null +++ b/e2e/tests/http_after_response_rules/missing_parent.bats @@ -0,0 +1,43 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_after_response_rules: Fail creating a HTTP After Response rule when frontend doesn't exist" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="ghost" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} + +@test "http_after_response_rules: Fail creating a HTTP After Response rule when backend doesn't exist" { + if $HAPROXY_VERSION == "2.1"; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/http_after_response_rules/replace.bats b/e2e/tests/http_after_response_rules/replace.bats new file mode 100644 index 00000000..d940320a --- /dev/null +++ b/e2e/tests/http_after_response_rules/replace.bats @@ -0,0 +1,73 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_after_response_rules: Replace a HTTP After Response Rule of frontend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Haproxy-Current-Date" + assert_equal "$(get_json_path "$BODY" ".hdr_format")" "%T" +} + +@test "http_after_response_rules: Replace a HTTP After Response Rule of backend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Haproxy-Current-Date" + assert_equal "$(get_json_path "$BODY" ".hdr_format")" "%T" +} + +@test "http_after_response_rules: Replace all HTTP After Response Rules of backend" { + if [[ "$HAPROXY_VERSION" == "2.1" ]]; then + skip "http-after-response is not supported in HAProxy 2.1" + fi + + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules" "data/replace-all.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_after_response_rules" + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} diff --git a/e2e/tests/http_after_response_rules/utils/_helpers.bash b/e2e/tests/http_after_response_rules/utils/_helpers.bash new file mode 100644 index 00000000..9b18caf2 --- /dev/null +++ b/e2e/tests/http_after_response_rules/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RES_RULES_BASE_PATH="/services/haproxy/configuration/http_after_response_rules" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/http_checks/add.bats b/e2e/tests/http_checks/add.bats new file mode 100644 index 00000000..c01f5579 --- /dev/null +++ b/e2e/tests/http_checks/add.bats @@ -0,0 +1,50 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_checks: Add a new HTTP Check to defaults" { + PARENT_NAME="mydefaults" + resource_post "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/2" "data/post_defaults.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/2" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "disable-on-404" +} + +@test "http_checks: Add a new HTTP Check to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/2" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/2" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "disable-on-404" +} + +@test "http_checks: fail adding an unvalid HTTP Check to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" "data/post_unvalid.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/http_checks/add_2.2.bats b/e2e/tests/http_checks/add_2.2.bats new file mode 100644 index 00000000..a8b3aaed --- /dev/null +++ b/e2e/tests/http_checks/add_2.2.bats @@ -0,0 +1,67 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_checks: Add a new HTTP Check (send) to defaults (>=2.2)" { + if haproxy_version_ge "2.2" + then + PARENT_NAME="mydefaults" + resource_post "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/2" "data/post_defaults_send.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/2" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".method")" "OPTIONS" + assert_equal "$(get_json_path "$BODY" ".uri")" "/" + assert_equal "$(get_json_path "$BODY" ".version")" "HTTP/1.1" + fi +} + + +@test "http_checks: Add a new HTTP Check (send) to backend (>=2.2)" { + if haproxy_version_ge "2.2" + then + PARENT_NAME="test_backend_2" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" "data/post_send.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".method")" "OPTIONS" + assert_equal "$(get_json_path "$BODY" ".uri")" "/" + assert_equal "$(get_json_path "$BODY" ".version")" "HTTP/1.1" + fi +} + + +@test "http_checks: fail adding an invalid HTTP Check (send method) to backend (>=2.2)" { + if haproxy_version_ge "2.2" + then + PARENT_NAME="test_backend_2" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" "data/post_invalid_send_method.json" "force_reload=true" + assert_equal "$SC" 422 + assert_equal "$(get_json_path "$BODY" ".code")" "606" + fi +} diff --git a/e2e/tests/http_checks/data/haproxy.cfg b/e2e/tests/http_checks/data/haproxy.cfg new file mode 100644 index 00000000..63d51873 --- /dev/null +++ b/e2e/tests/http_checks/data/haproxy.cfg @@ -0,0 +1,43 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option httpchk + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + http-check send-state + http-check disable-on-404 + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + +backend test_backend + mode http + balance roundrobin + option forwardfor + option httpchk + http-check send hdr host haproxy.1wt.eu + http-check expect status 200-399 diff --git a/e2e/tests/http_checks/data/haproxy_2.2.cfg b/e2e/tests/http_checks/data/haproxy_2.2.cfg new file mode 100644 index 00000000..4e265461 --- /dev/null +++ b/e2e/tests/http_checks/data/haproxy_2.2.cfg @@ -0,0 +1,46 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option httpchk + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + http-check send-state + http-check disable-on-404 + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + +backend test_backend + mode http + balance roundrobin + option forwardfor + option httpchk + http-check send meth OPTIONS uri / ver HTTP/1.1 hdr host haproxy.1wt.eu + http-check expect status 200-399 + +backend test_backend_2 +http-check expect status 200-399 diff --git a/e2e/tests/http_checks/data/post.json b/e2e/tests/http_checks/data/post.json new file mode 100644 index 00000000..954e42b4 --- /dev/null +++ b/e2e/tests/http_checks/data/post.json @@ -0,0 +1,3 @@ +{ + "type": "disable-on-404" +} diff --git a/e2e/tests/http_checks/data/post_defaults.json b/e2e/tests/http_checks/data/post_defaults.json new file mode 100644 index 00000000..65409151 --- /dev/null +++ b/e2e/tests/http_checks/data/post_defaults.json @@ -0,0 +1,3 @@ +{ + "type": "disable-on-404" +} diff --git a/e2e/tests/http_checks/data/post_defaults_send.json b/e2e/tests/http_checks/data/post_defaults_send.json new file mode 100644 index 00000000..f8e6c476 --- /dev/null +++ b/e2e/tests/http_checks/data/post_defaults_send.json @@ -0,0 +1,6 @@ +{ + "type": "send", + "method": "OPTIONS", + "uri": "/", + "version": "HTTP/1.1" +} diff --git a/e2e/tests/http_checks/data/post_invalid_send_method.json b/e2e/tests/http_checks/data/post_invalid_send_method.json new file mode 100644 index 00000000..d0131680 --- /dev/null +++ b/e2e/tests/http_checks/data/post_invalid_send_method.json @@ -0,0 +1,6 @@ +{ + "type": "send", + "method": "invalid", + "uri": "/", + "version": "HTTP/1.1" +} diff --git a/e2e/tests/http_checks/data/post_send.json b/e2e/tests/http_checks/data/post_send.json new file mode 100644 index 00000000..f8e6c476 --- /dev/null +++ b/e2e/tests/http_checks/data/post_send.json @@ -0,0 +1,6 @@ +{ + "type": "send", + "method": "OPTIONS", + "uri": "/", + "version": "HTTP/1.1" +} diff --git a/e2e/tests/http_checks/data/post_unvalid.json b/e2e/tests/http_checks/data/post_unvalid.json new file mode 100644 index 00000000..48a68c24 --- /dev/null +++ b/e2e/tests/http_checks/data/post_unvalid.json @@ -0,0 +1,6 @@ +{ + "type": "send", + "method": "URI", + "URI": "/", + "headers": "bla" +} diff --git a/e2e/tests/http_checks/data/put.json b/e2e/tests/http_checks/data/put.json new file mode 100644 index 00000000..b8de2427 --- /dev/null +++ b/e2e/tests/http_checks/data/put.json @@ -0,0 +1,3 @@ +{ + "type": "send-state" +} diff --git a/e2e/tests/http_checks/data/put_defaults.json b/e2e/tests/http_checks/data/put_defaults.json new file mode 100644 index 00000000..b8de2427 --- /dev/null +++ b/e2e/tests/http_checks/data/put_defaults.json @@ -0,0 +1,3 @@ +{ + "type": "send-state" +} diff --git a/e2e/tests/http_checks/data/put_unvalid.json b/e2e/tests/http_checks/data/put_unvalid.json new file mode 100644 index 00000000..5a3ddc53 --- /dev/null +++ b/e2e/tests/http_checks/data/put_unvalid.json @@ -0,0 +1,3 @@ +{ + "type": "add-header" +} diff --git a/e2e/tests/http_checks/data/replace-all.json b/e2e/tests/http_checks/data/replace-all.json new file mode 100644 index 00000000..4d4f77d7 --- /dev/null +++ b/e2e/tests/http_checks/data/replace-all.json @@ -0,0 +1,11 @@ +[ + { + "type": "send-state" + }, + { + "method": "OPTIONS", + "type": "send", + "uri": "/", + "version": "HTTP/1.1" + } +] diff --git a/e2e/tests/http_checks/delete.bats b/e2e/tests/http_checks/delete.bats new file mode 100644 index 00000000..996e17a1 --- /dev/null +++ b/e2e/tests/http_checks/delete.bats @@ -0,0 +1,62 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_checks: Delete a HTTP Check from defaults" { + # + # Deleting first + # + PARENT_NAME="mydefaults" + resource_delete "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting second + # + resource_delete "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Not found + # + resource_delete "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_checks: Delete a HTTP Check from backend" { + # + # Deleting second + # + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting first + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Not found + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_checks/get.bats b/e2e/tests/http_checks/get.bats new file mode 100644 index 00000000..f3a895bc --- /dev/null +++ b/e2e/tests/http_checks/get.bats @@ -0,0 +1,67 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_checks: Return one HTTP Check from defaults" { + PARENT_NAME="mydefaults" + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "send-state" + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "disable-on-404" +} + +@test "http_checks: Return one HTTP Check from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" + assert_equal "$(get_json_path "$BODY" ".type")" "send" + assert_equal 1 "$(get_json_path "$BODY" ".headers | length")" + assert_equal "$(get_json_path "$BODY" ".headers[0].name")" "host" + assert_equal "$(get_json_path "$BODY" ".headers[0].fmt")" "haproxy.1wt.eu" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1" + assert_equal "$(get_json_path "$BODY" ".type")" "expect" + assert_equal "$(get_json_path "$BODY" ".match")" "status" + assert_equal "$(get_json_path "$BODY" ".pattern")" "200-399" +} + +@test "http_checks: Return 404 when fetching HTTP Check from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_checks/0" + assert_equal "$SC" 404 +} + +@test "http_checks: Return 400 when fetching HTTP Check from unexisting backend" { + PARENT_NAME="i_am_not_here" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" + assert_equal "$SC" 400 +} + +@test "http_checks: Return 404 when fetching unexisting HTTP Check" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1000" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_checks/get_2.2.bats b/e2e/tests/http_checks/get_2.2.bats new file mode 100644 index 00000000..3f361d2d --- /dev/null +++ b/e2e/tests/http_checks/get_2.2.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + + +@test "http_checks: Return one HTTP Check from backend (>=2.2)" { + if haproxy_version_ge "2.2" + then + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/0" + assert_equal "$(get_json_path "$BODY" ".type")" "send" + assert_equal 1 "$(get_json_path "$BODY" ".headers | length")" + assert_equal "$(get_json_path "$BODY" ".headers[0].name")" "host" + assert_equal "$(get_json_path "$BODY" ".headers[0].fmt")" "haproxy.1wt.eu" + assert_equal "$(get_json_path "$BODY" ".method")" "OPTIONS" + assert_equal "$(get_json_path "$BODY" ".uri")" "/" + assert_equal "$(get_json_path "$BODY" ".version")" "HTTP/1.1" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1" + assert_equal "$(get_json_path "$BODY" ".type")" "expect" + assert_equal "$(get_json_path "$BODY" ".match")" "status" + assert_equal "$(get_json_path "$BODY" ".pattern")" "200-399" + fi +} diff --git a/e2e/tests/http_checks/list.bats b/e2e/tests/http_checks/list.bats new file mode 100644 index 00000000..72d5f39b --- /dev/null +++ b/e2e/tests/http_checks/list.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_checks: Return an array of all HTTP Checks from defaults" { + PARENT_NAME="mydefaults" + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + + assert_equal "$(get_json_path "$BODY" ".[0].type")" "send-state" + + assert_equal "$(get_json_path "$BODY" ".[1].type")" "disable-on-404" +} + +@test "http_checks: Return an array of HTTP Checks from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + + assert_equal "$(get_json_path "$BODY" ".[0].type")" "send" + assert_equal 1 "$(get_json_path "$BODY" ".[0].headers | length")" + assert_equal "$(get_json_path "$BODY" ".[0].headers[0].name")" "host" + assert_equal "$(get_json_path "$BODY" ".[0].headers[0].fmt")" "haproxy.1wt.eu" + + assert_equal "$(get_json_path "$BODY" ".[1].type")" "expect" + assert_equal "$(get_json_path "$BODY" ".[1].match")" "status" + assert_equal "$(get_json_path "$BODY" ".[1].pattern")" "200-399" +} + +@test "http_checks: Return 404 for frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_check" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_checks/replace.bats b/e2e/tests/http_checks/replace.bats new file mode 100644 index 00000000..363576b3 --- /dev/null +++ b/e2e/tests/http_checks/replace.bats @@ -0,0 +1,92 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_checks: Replace a HTTP Check of defaults" { + PARENT_NAME="mydefaults" + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/1" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "send-state" +} + +@test "http_checks: Replace a HTTP Check of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "send-state" +} + +@test "http_checks: Fail replacing a HTTP Check of unexisting backend" { + PARENT_NAME="i_am_not_here" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1" "data/put.json" "force_reload=true" + assert_equal "$SC" 400 +} + +@test "http_checks: Fail replacing an unvalid HTTP Check of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_checks/1" "data/put_unvalid.json" "parent_type=backend&parent_name=test_backend&force_reload=true" + assert_equal "$SC" 422 +} + +@test "http_checks: Fail replacing an unexisting HTTP Check of backend" { + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/1000" "data/put.json" "parent_type=backend&parent_name=test_backend&force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_checks: Fail replacing a HTTP Check of frontend" { + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks/1000" "data/put.json" "parent_type=frontend&parent_name=test_frontend&force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_checks: Replace all HTTP Checks of backend (>=2.2)" { + if haproxy_version_ge "2.2" + then + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks" "data/replace-all.json" "parent_type=backend&parent_name=test_backend" + assert_equal "$SC" 202 + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks" "parent_type=backend&parent_name=test_backend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + fi +} + +@test "http_checks: Replace all HTTP Checks for defaults (>=2.2)" { + if haproxy_version_ge "2.2" + then + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks" "data/replace-all.json" "parent_type=defaults&parent_name=mydefaults" + assert_equal "$SC" 202 + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_checks" "parent_type=defaults&parent_name=mydefaults" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + fi +} diff --git a/e2e/tests/http_checks/utils/_helpers.bash b/e2e/tests/http_checks/utils/_helpers.bash new file mode 100644 index 00000000..ef3cab69 --- /dev/null +++ b/e2e/tests/http_checks/utils/_helpers.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_CHECKS_BASE_PATH="/services/haproxy/configuration/http_checks" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_DEFAULTS_BASE_PATH="/services/haproxy/configuration/defaults" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/http_error_rules/add.bats b/e2e/tests/http_error_rules/add.bats new file mode 100644 index 00000000..75f4f15c --- /dev/null +++ b/e2e/tests/http_error_rules/add.bats @@ -0,0 +1,77 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_error_rules: Add a new HTTP Error Rule to frontend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".status")" 425 +} + +@test "http_error_rules: Add a new HTTP Error Rule to backend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "parent_type=backend&parent_name=test_backend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".status")" 425 +} + +@test "http_error_rules: Add a new HTTP Error Rule to defaults" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="mydefaults" + resource_post "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".status")" 425 +} + +@test "http_error_rules: Fail to add a new HTTP Error Rule without status code to backend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/invalid_no_status_code.json" "force_reload=true" + assert_equal "$SC" 422 +} + +@test "http_error_rules: Fail to add a new HTTP Error Rule with unsupported status code to frontend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/invalid_bad_status_code.json" "parent_type=frontend&parent_name=test_frontend&force_reload=true" + assert_equal "$SC" 422 +} diff --git a/e2e/tests/http_error_rules/data/haproxy.cfg b/e2e/tests/http_error_rules/data/haproxy.cfg new file mode 100644 index 00000000..7da91a97 --- /dev/null +++ b/e2e/tests/http_error_rules/data/haproxy.cfg @@ -0,0 +1,41 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + http-error status 503 content-type "application/json" string "Default 503 content" + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + http-error status 400 + +backend test_backend + mode http + balance roundrobin + option forwardfor + http-error status 200 content-type "text/plain" string "My content" hdr Some-Header value + http-error status 503 content-type application/json string "My content" hdr Additional-Header value1 hdr Some-Header value diff --git a/e2e/tests/http_error_rules/data/invalid_bad_status_code.json b/e2e/tests/http_error_rules/data/invalid_bad_status_code.json new file mode 100644 index 00000000..f0be2396 --- /dev/null +++ b/e2e/tests/http_error_rules/data/invalid_bad_status_code.json @@ -0,0 +1,4 @@ +{ + "type": "status", + "status": 402 +} diff --git a/e2e/tests/http_error_rules/data/invalid_no_status_code.json b/e2e/tests/http_error_rules/data/invalid_no_status_code.json new file mode 100644 index 00000000..a9d80385 --- /dev/null +++ b/e2e/tests/http_error_rules/data/invalid_no_status_code.json @@ -0,0 +1,3 @@ +{ + "type": "status" +} diff --git a/e2e/tests/http_error_rules/data/post.json b/e2e/tests/http_error_rules/data/post.json new file mode 100644 index 00000000..bf626824 --- /dev/null +++ b/e2e/tests/http_error_rules/data/post.json @@ -0,0 +1,4 @@ +{ + "type": "status", + "status": 425 +} diff --git a/e2e/tests/http_error_rules/data/put.json b/e2e/tests/http_error_rules/data/put.json new file mode 100644 index 00000000..c6a10bb5 --- /dev/null +++ b/e2e/tests/http_error_rules/data/put.json @@ -0,0 +1,17 @@ +{ + "type": "status", + "status": 429, + "return_content_type": "application/json", + "return_content_format": "string", + "return_content": "\"My content\"", + "return_hdrs": [ + { + "name": "Additional-Header", + "fmt": "value1" + }, + { + "name": "Some-Header", + "fmt": "value" + } + ] +} diff --git a/e2e/tests/http_error_rules/data/replace-all-empty.json b/e2e/tests/http_error_rules/data/replace-all-empty.json new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/e2e/tests/http_error_rules/data/replace-all-empty.json @@ -0,0 +1 @@ +[] diff --git a/e2e/tests/http_error_rules/data/replace-all.json b/e2e/tests/http_error_rules/data/replace-all.json new file mode 100644 index 00000000..f931ba30 --- /dev/null +++ b/e2e/tests/http_error_rules/data/replace-all.json @@ -0,0 +1,23 @@ +[ + {"return_hdrs": [ + { + "fmt": "value1", + "name": "Additional-Header" + }, + { + "fmt": "value", + "name": "Some-Header" + } + ], + "return_content": "\"My content\"", + "return_content_format": "string", + "return_content_type": "application/json", + "status": 429, + "type": "status" + }, + { + "return_content_type": "", + "status": 425, + "type": "status" + } +] diff --git a/e2e/tests/http_error_rules/delete.bats b/e2e/tests/http_error_rules/delete.bats new file mode 100644 index 00000000..74725ad9 --- /dev/null +++ b/e2e/tests/http_error_rules/delete.bats @@ -0,0 +1,78 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_error_rules: Delete a HTTP Error Rule from frontend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + # + # Deleting first + # + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Not found + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_error_rules: Delete a HTTP Error Rule from backend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + # + # Deleting first + # + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting second + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Not found + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_error_rules: Delete a HTTP Error Rule from defaults" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + # + # Deleting first + # + PARENT_NAME="mydefaults" + resource_delete "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Not found + # + resource_delete "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_error_rules/get.bats b/e2e/tests/http_error_rules/get.bats new file mode 100644 index 00000000..6f106907 --- /dev/null +++ b/e2e/tests/http_error_rules/get.bats @@ -0,0 +1,91 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_error_rules: Return one HTTP Error Rule from frontend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "status" + assert_equal "$(get_json_path "$BODY" ".status")" 400 +} + +@test "http_error_rules: Return one HTTP Error Rule from backend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "status" + assert_equal "$(get_json_path "$BODY" ".status")" 200 + assert_equal "$(get_json_path "$BODY" ".return_content_type")" "\"text/plain\"" + assert_equal "$(get_json_path "$BODY" ".return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".return_content")" "\"My content\"" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].name")" "Some-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].fmt")" "value" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "status" + assert_equal "$(get_json_path "$BODY" ".status")" 503 + assert_equal "$(get_json_path "$BODY" ".return_content_type")" "application/json" + assert_equal "$(get_json_path "$BODY" ".return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".return_content")" "\"My content\"" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].name")" "Additional-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].fmt")" "value1" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].name")" "Some-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].fmt")" "value" +} + +@test "http_error_rules: Return one HTTP Error Rule from defaults" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="mydefaults" + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "status" + assert_equal "$(get_json_path "$BODY" ".status")" 503 + assert_equal "$(get_json_path "$BODY" ".return_content_type")" "\"application/json\"" + assert_equal "$(get_json_path "$BODY" ".return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".return_content")" "\"Default 503 content\"" +} + +@test "http_error_rules: Fail to return a HTTP Error Rule when backend does not exist" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="ghost" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" + assert_equal "$SC" 400 +} + +@test "http_error_rules: Fail to return a backend HTTP Error Rule that does not exist" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/1000" "parent_type=backend&parent_name=test_backend" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_error_rules/list.bats b/e2e/tests/http_error_rules/list.bats new file mode 100644 index 00000000..c2dab5b5 --- /dev/null +++ b/e2e/tests/http_error_rules/list.bats @@ -0,0 +1,75 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_error_rules: Return an array of all HTTP Error Rules from defaults" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="mydefaults" + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules" + assert_equal "$SC" 200 + assert_equal 1 "$(get_json_path "$BODY" ". | length")" + assert_equal "$(get_json_path "$BODY" ".[0].type")" "status" + assert_equal "$(get_json_path "$BODY" ".[0].status")" 503 + assert_equal "$(get_json_path "$BODY" ".[0].return_content_type")" "\"application/json\"" + assert_equal "$(get_json_path "$BODY" ".[0].return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".[0].return_content")" "\"Default 503 content\"" +} + +@test "http_error_rules: Return an array of all HTTP Error Rules from frontend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules" + assert_equal "$SC" 200 + assert_equal 1 "$(get_json_path "$BODY" ". | length")" + assert_equal "$(get_json_path "$BODY" ".[0].type")" "status" + assert_equal "$(get_json_path "$BODY" ".[0].status")" 400 +} + +@test "http_error_rules: Return an array of all HTTP Error Rules from backend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + assert_equal "$(get_json_path "$BODY" ".[0].type")" "status" + assert_equal "$(get_json_path "$BODY" ".[0].status")" 200 + assert_equal "$(get_json_path "$BODY" ".[0].return_content_type")" "\"text/plain\"" + assert_equal "$(get_json_path "$BODY" ".[0].return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".[0].return_content")" "\"My content\"" + assert_equal "$(get_json_path "$BODY" ".[0].return_hdrs[0].name")" "Some-Header" + assert_equal "$(get_json_path "$BODY" ".[0].return_hdrs[0].fmt")" "value" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "status" + assert_equal "$(get_json_path "$BODY" ".[1].status")" 503 + assert_equal "$(get_json_path "$BODY" ".[1].return_content_type")" "application/json" + assert_equal "$(get_json_path "$BODY" ".[1].return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".[1].return_content")" "\"My content\"" + assert_equal "$(get_json_path "$BODY" ".[1].return_hdrs[0].name")" "Additional-Header" + assert_equal "$(get_json_path "$BODY" ".[1].return_hdrs[0].fmt")" "value1" + assert_equal "$(get_json_path "$BODY" ".[1].return_hdrs[1].name")" "Some-Header" + assert_equal "$(get_json_path "$BODY" ".[1].return_hdrs[1].fmt")" "value" +} diff --git a/e2e/tests/http_error_rules/missing_parent.bats b/e2e/tests/http_error_rules/missing_parent.bats new file mode 100644 index 00000000..fcf300a8 --- /dev/null +++ b/e2e/tests/http_error_rules/missing_parent.bats @@ -0,0 +1,40 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_error_rules: Fail creating a HTTP Error rule when frontend does not exist" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="ghost" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/post.json" "orce_reload=true" + assert_equal "$SC" 400 +} + +@test "http_error_rules: Fail creating a HTTP Error rule when backend does not exist" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/http_error_rules/replace.bats b/e2e/tests/http_error_rules/replace.bats new file mode 100644 index 00000000..83eda489 --- /dev/null +++ b/e2e/tests/http_error_rules/replace.bats @@ -0,0 +1,168 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_error_rules: Replace a HTTP Error Rule of frontend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "parent_type=frontend&parent_name=test_frontend&force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "status" + assert_equal "$(get_json_path "$BODY" ".status")" 429 + assert_equal "$(get_json_path "$BODY" ".return_content_type")" "application/json" + assert_equal "$(get_json_path "$BODY" ".return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".return_content")" "\"My content\"" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].name")" "Additional-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].fmt")" "value1" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].name")" "Some-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].fmt")" "value" +} + +@test "http_error_rules: Replace a HTTP Error Rule of backend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/1" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/1" "parent_type=backend&parent_name=test_backend&force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "status" + assert_equal "$(get_json_path "$BODY" ".status")" 429 + assert_equal "$(get_json_path "$BODY" ".return_content_type")" "application/json" + assert_equal "$(get_json_path "$BODY" ".return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".return_content")" "\"My content\"" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].name")" "Additional-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].fmt")" "value1" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].name")" "Some-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].fmt")" "value" +} + +@test "http_error_rules: Replace a HTTP Error Rule of defaults" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="mydefaults" + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules/0" "parent_type=defaults&parent_name=mydefaults" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "status" + assert_equal "$(get_json_path "$BODY" ".status")" 429 + assert_equal "$(get_json_path "$BODY" ".return_content_type")" "application/json" + assert_equal "$(get_json_path "$BODY" ".return_content_format")" "string" + assert_equal "$(get_json_path "$BODY" ".return_content")" "\"My content\"" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].name")" "Additional-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[0].fmt")" "value1" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].name")" "Some-Header" + assert_equal "$(get_json_path "$BODY" ".return_hdrs[1].fmt")" "value" +} + +@test "http_error_rules: Fail to replace a HTTP Error rule when backend does not exist" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="ghost" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 400 +} + +@test "http_error_rules: Fail to replace a frontend HTTP Error Rule with no status code" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/invalid_no_status_code.json" "force_reload=true" + assert_equal "$SC" 422 +} + +@test "http_error_rules: Fail to replace a backend HTTP Error Rule with unsupported status code" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/0" "data/invalid_bad_status_code.json" "force_reload=true" + assert_equal "$SC" 422 +} + +@test "http_error_rules: Fail to replace a frontend HTTP Error Rule that does not exist" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules/1" "data/put.json" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_error_rules: Fail to replace a backend HTTP Error Rule that does not exist" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules/1000" "data/put.json" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_error_rules: Replace all HTTP Error Rule of frontend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules" "data/replace-all.json" + assert_equal "$SC" 202 + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules" "parent_type=frontend&parent_name=test_frontend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + + # empty + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules" "data/replace-all-empty.json" "parent_type=frontend&parent_name=test_frontend" + assert_equal "$SC" 202 + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_error_rules" "parent_type=frontend&parent_name=test_frontend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 0 +} + +@test "http_error_rules: Replace all HTTP Error Rule of backend" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules" "data/replace-all.json" + assert_equal "$SC" 202 + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_error_rules" "parent_type=backend&parent_name=test_backend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} + +@test "http_error_rules: Replace all HTTP Error Rule of defaults" { + haproxy_version_ge $_ERR_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SUPPORTED_HAPROXY_VERSION+" + + PARENT_NAME="mydefaults" + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules" "data/replace-all.json" "parent_type=defaults&parent_name=mydefaults" + assert_equal "$SC" 202 + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/http_error_rules" "parent_type=defaults&parent_name=mydefaults" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} diff --git a/e2e/tests/http_error_rules/utils/_helpers.bash b/e2e/tests/http_error_rules/utils/_helpers.bash new file mode 100644 index 00000000..f82240d7 --- /dev/null +++ b/e2e/tests/http_error_rules/utils/_helpers.bash @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_ERR_RULES_BASE_PATH="/services/haproxy/configuration/http_error_rules" +_ERR_SUPPORTED_HAPROXY_VERSION="2.2" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" +_DEFAULTS_BASE_PATH="/services/haproxy/configuration/defaults" diff --git a/e2e/tests/http_errors/data/haproxy.cfg b/e2e/tests/http_errors/data/haproxy.cfg new file mode 100644 index 00000000..c755f952 --- /dev/null +++ b/e2e/tests/http_errors/data/haproxy.cfg @@ -0,0 +1,38 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +http-errors website-1 + errorfile 400 /dev/null + errorfile 404 /dev/null + errorfile 408 /dev/null + +http-errors website-2 + errorfile 500 /dev/null + errorfile 404 /dev/null + errorfile 503 /dev/null diff --git a/e2e/tests/http_errors/data/section.json b/e2e/tests/http_errors/data/section.json new file mode 100644 index 00000000..df815f73 --- /dev/null +++ b/e2e/tests/http_errors/data/section.json @@ -0,0 +1,13 @@ +{ + "name": "website-3", + "error_files": [ + { + "code": 500, + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_entries_missing.json b/e2e/tests/http_errors/data/section_entries_missing.json new file mode 100644 index 00000000..56ea3595 --- /dev/null +++ b/e2e/tests/http_errors/data/section_entries_missing.json @@ -0,0 +1,3 @@ +{ + "name": "website-1" +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_errorfile_no_code.json b/e2e/tests/http_errors/data/section_errorfile_no_code.json new file mode 100644 index 00000000..f77352c6 --- /dev/null +++ b/e2e/tests/http_errors/data/section_errorfile_no_code.json @@ -0,0 +1,12 @@ +{ + "name": "website-3", + "error_files": [ + { + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_errorfile_no_file.json b/e2e/tests/http_errors/data/section_errorfile_no_file.json new file mode 100644 index 00000000..cf9045f9 --- /dev/null +++ b/e2e/tests/http_errors/data/section_errorfile_no_file.json @@ -0,0 +1,12 @@ +{ + "name": "website-3", + "error_files": [ + { + "code": 500 + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_errorfile_unsupported_code.json b/e2e/tests/http_errors/data/section_errorfile_unsupported_code.json new file mode 100644 index 00000000..8ab5155c --- /dev/null +++ b/e2e/tests/http_errors/data/section_errorfile_unsupported_code.json @@ -0,0 +1,13 @@ +{ + "name": "website-3", + "error_files": [ + { + "code": 402, + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_name_does_not_exist.json b/e2e/tests/http_errors/data/section_name_does_not_exist.json new file mode 100644 index 00000000..b9fc7b2d --- /dev/null +++ b/e2e/tests/http_errors/data/section_name_does_not_exist.json @@ -0,0 +1,13 @@ +{ + "name": "i_am_not_there", + "error_files": [ + { + "code": 500, + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_name_exists.json b/e2e/tests/http_errors/data/section_name_exists.json new file mode 100644 index 00000000..53d5f19b --- /dev/null +++ b/e2e/tests/http_errors/data/section_name_exists.json @@ -0,0 +1,13 @@ +{ + "name": "website-1", + "error_files": [ + { + "code": 500, + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_name_missing.json b/e2e/tests/http_errors/data/section_name_missing.json new file mode 100644 index 00000000..c3cb2b2a --- /dev/null +++ b/e2e/tests/http_errors/data/section_name_missing.json @@ -0,0 +1,12 @@ +{ + "error_files": [ + { + "code": 400, + "file": "/dev/null" + }, + { + "code": 404, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_replace.json b/e2e/tests/http_errors/data/section_replace.json new file mode 100644 index 00000000..53d5f19b --- /dev/null +++ b/e2e/tests/http_errors/data/section_replace.json @@ -0,0 +1,13 @@ +{ + "name": "website-1", + "error_files": [ + { + "code": 500, + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_replace_errorfile_no_code.json b/e2e/tests/http_errors/data/section_replace_errorfile_no_code.json new file mode 100644 index 00000000..cd791a8d --- /dev/null +++ b/e2e/tests/http_errors/data/section_replace_errorfile_no_code.json @@ -0,0 +1,12 @@ +{ + "name": "website-1", + "error_files": [ + { + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_replace_errorfile_no_file.json b/e2e/tests/http_errors/data/section_replace_errorfile_no_file.json new file mode 100644 index 00000000..e7c371b9 --- /dev/null +++ b/e2e/tests/http_errors/data/section_replace_errorfile_no_file.json @@ -0,0 +1,12 @@ +{ + "name": "website-1", + "error_files": [ + { + "code": 500 + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/data/section_replace_errorfile_unsupported_code.json b/e2e/tests/http_errors/data/section_replace_errorfile_unsupported_code.json new file mode 100644 index 00000000..3e3aeca0 --- /dev/null +++ b/e2e/tests/http_errors/data/section_replace_errorfile_unsupported_code.json @@ -0,0 +1,13 @@ +{ + "name": "website-1", + "error_files": [ + { + "code": 402, + "file": "/dev/null" + }, + { + "code": 502, + "file": "/dev/null" + } + ] +} \ No newline at end of file diff --git a/e2e/tests/http_errors/http_errors.bats b/e2e/tests/http_errors/http_errors.bats new file mode 100644 index 00000000..cc989e84 --- /dev/null +++ b/e2e/tests/http_errors/http_errors.bats @@ -0,0 +1,165 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_error_sections: Return all sections" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_get "$_ERR_SECTIONS_BASE_PATH" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ". | length")" 2 +} + +@test "http_error_sections: Return one section by name" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_get "$_ERR_SECTIONS_BASE_PATH/website-2" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ".name")" "website-2" + assert_equal "$(get_json_path "$BODY" ".error_files | length")" 3 + assert_equal "$(get_json_path "$BODY" ".error_files[0].code")" 500 + assert_equal "$(get_json_path "$BODY" ".error_files[0].file")" "/dev/null" + assert_equal "$(get_json_path "$BODY" ".error_files[1].code")" 404 + assert_equal "$(get_json_path "$BODY" ".error_files[1].file")" "/dev/null" + assert_equal "$(get_json_path "$BODY" ".error_files[2].code")" 503 + assert_equal "$(get_json_path "$BODY" ".error_files[2].file")" "/dev/null" +} + +@test "http_error_sections: Fail to return a section that does not exist" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_get "$_ERR_SECTIONS_BASE_PATH/i_am_not_here" + assert_equal "$SC" 404 +} + +@test "http_error_sections: Delete one section by name" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_delete "$_ERR_SECTIONS_BASE_PATH/website-2" + assert_equal "$SC" 202 + + resource_get "$_ERR_SECTIONS_BASE_PATH/website-2" + assert_equal "$SC" "404" +} + +@test "http_error_sections: Fail to delete a section that does not exist" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_delete "$_ERR_SECTIONS_BASE_PATH/i_am_not_here" + assert_equal "$SC" 404 +} + +@test "http_error_sections: Create a new section" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_post "$_ERR_SECTIONS_BASE_PATH" "data/section.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_ERR_SECTIONS_BASE_PATH/website-3" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".error_files | length")" 2 + assert_equal "$(get_json_path "$BODY" ".error_files[0].code")" 500 + assert_equal "$(get_json_path "$BODY" ".error_files[0].file")" "/dev/null" + assert_equal "$(get_json_path "$BODY" ".error_files[1].code")" 502 + assert_equal "$(get_json_path "$BODY" ".error_files[1].file")" "/dev/null" +} + +@test "http_error_sections: Fail to create a section with an existing name" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_post "$_ERR_SECTIONS_BASE_PATH" "data/section_name_exists.json" "force_reload=true" + assert_equal "$SC" 409 +} + +@test "http_error_sections: Fail to create a section with missing data" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_post "$_ERR_SECTIONS_BASE_PATH" "data/section_name_missing.json" "force_reload=true" + assert_equal "$SC" 422 + + resource_post "$_ERR_SECTIONS_BASE_PATH" "data/section_entries_missing.json" "force_reload=true" + assert_equal "$SC" 422 +} + +@test "http_error_sections: Fail to create a section with invalid data" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_post "$_ERR_SECTIONS_BASE_PATH" "data/section_errorfile_no_file.json" "force_reload=true" + assert_equal "$SC" 400 + + resource_post "$_ERR_SECTIONS_BASE_PATH" "data/section_errorfile_no_code.json" "force_reload=true" + assert_equal "$SC" 400 + + resource_post "$_ERR_SECTIONS_BASE_PATH" "data/section_errorfile_unsupported_code.json" "force_reload=true" + assert_equal "$SC" 422 +} + +@test "http_error_sections: Replace one section" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_put "$_ERR_SECTIONS_BASE_PATH/website-1" "data/section_replace.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_ERR_SECTIONS_BASE_PATH/website-1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "website-1" + assert_equal "$(get_json_path "$BODY" ".error_files | length")" 2 + assert_equal "$(get_json_path "$BODY" ".error_files[0].code")" 500 + assert_equal "$(get_json_path "$BODY" ".error_files[0].file")" "/dev/null" + assert_equal "$(get_json_path "$BODY" ".error_files[1].code")" 502 + assert_equal "$(get_json_path "$BODY" ".error_files[1].file")" "/dev/null" +} + +@test "http_error_sections: Fail to replace a section that does not exist" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_put "$_ERR_SECTIONS_BASE_PATH/i_am_not_there" "data/section_replace.json" "force_reload=true" + assert_equal "$SC" 409 +} + +@test "http_error_sections: Fail to replace a section with missing data" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_put "$_ERR_SECTIONS_BASE_PATH/website-1" "data/section_name_missing.json" "force_reload=true" + assert_equal "$SC" 422 + + resource_put "$_ERR_SECTIONS_BASE_PATH/website-1" "data/section_entries_missing.json" "force_reload=true" + assert_equal "$SC" 422 +} + +@test "http_error_sections: Fail to replace a section with invalid data" { + haproxy_version_ge $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION || skip "requires HAProxy $_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION+" + + resource_put "$_ERR_SECTIONS_BASE_PATH/website-1" "data/section_replace_errorfile_no_file.json" "force_reload=true" + assert_equal "$SC" 400 + + resource_put "$_ERR_SECTIONS_BASE_PATH/website-1" "data/section_replace_errorfile_no_code.json" "force_reload=true" + assert_equal "$SC" 400 + + resource_put "$_ERR_SECTIONS_BASE_PATH/website-1" "data/section_replace_errorfile_unsupported_code.json" "force_reload=true" + assert_equal "$SC" 422 +} diff --git a/e2e/tests/http_errors/utils/_helpers.bash b/e2e/tests/http_errors/utils/_helpers.bash new file mode 100644 index 00000000..3670dce4 --- /dev/null +++ b/e2e/tests/http_errors/utils/_helpers.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_ERR_SECTIONS_BASE_PATH="/services/haproxy/configuration/http_errors_sections" +_ERR_SECTIONS_SUPPORTED_HAPROXY_VERSION="2.2" diff --git a/e2e/tests/http_request_rules/add.bats b/e2e/tests/http_request_rules/add.bats new file mode 100644 index 00000000..4f1dd8e5 --- /dev/null +++ b/e2e/tests/http_request_rules/add.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_request_rules: Add a new HTTP Request Rule to frontend" { + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "http_request_rules: Add a new HTTP Request Rule to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} diff --git a/e2e/tests/http_request_rules/add_2.8.bats b/e2e/tests/http_request_rules/add_2.8.bats new file mode 100644 index 00000000..5df96894 --- /dev/null +++ b/e2e/tests/http_request_rules/add_2.8.bats @@ -0,0 +1,56 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +## tune.stick-counters is a haproxy >= 2.8 global parameter +@test "http_request_rules: Add a new HTTP Request Rule track-sc to backend" { + if haproxy_version_ge "2.8" + then + # Using new track-sc with track_sc_stick_counter + PARENT_NAME="test_sticksc" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/post-track-sc.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 5 + fi +} + +@test "http_request_rules: Fail - Add a new HTTP Request Rule track-sc to backend - when track_sc_stick_counter is missing" { + # Using new track-sc with track_sc_stick_counter + # Fail due to missing track_sc_stick_counter + if haproxy_version_ge "2.8" + then + PARENT_NAME="test_sticksc" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/post-track-sc-fail.json" "force_reload=true" + assert_equal "$SC" 400 + fi +} diff --git a/e2e/tests/http_request_rules/data/haproxy.cfg b/e2e/tests/http_request_rules/data/haproxy.cfg new file mode 100644 index 00000000..a76dff09 --- /dev/null +++ b/e2e/tests/http_request_rules/data/haproxy.cfg @@ -0,0 +1,41 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + http-request add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 } + http-request del-header X-Del-Frontend if { src 10.1.0.0/16 } + +backend test_backend + mode http + balance roundrobin + option forwardfor + http-request add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 } + http-request del-header X-Del-Backend if { src 10.1.0.0/16 } diff --git a/e2e/tests/http_request_rules/data/haproxy_2.8.cfg b/e2e/tests/http_request_rules/data/haproxy_2.8.cfg new file mode 100644 index 00000000..d659323b --- /dev/null +++ b/e2e/tests/http_request_rules/data/haproxy_2.8.cfg @@ -0,0 +1,55 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + tune.stick-counters 6 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + http-request add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 } + http-request del-header X-Del-Frontend if { src 10.1.0.0/16 } + http-request sc-add-gpc(0,1) 1 if FALSE + +frontend front_sticksc + bind *:1248 + default_backend test_sticksc + http-request track-sc0 src table test_sticksc if TRUE + http-request track-sc5 src table test_sticksc if TRUE + +backend test_backend + mode http + balance roundrobin + option forwardfor + http-request add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 } + http-request del-header X-Del-Backend if { src 10.1.0.0/16 } + +backend test_sticksc + http-request track-sc0 src table test_sticksc if TRUE + http-request track-sc5 src table test_sticksc if TRUE + stick-table type ip size 1m expire 5m store gpc0,conn_rate(30s) + server app1 127.0.0.1:4444 check diff --git a/e2e/tests/http_request_rules/data/post-track-sc-fail.json b/e2e/tests/http_request_rules/data/post-track-sc-fail.json new file mode 100644 index 00000000..82d8eab6 --- /dev/null +++ b/e2e/tests/http_request_rules/data/post-track-sc-fail.json @@ -0,0 +1,7 @@ +{ + "cond": "if", + "cond_test": "TRUE", + "type": "track-sc", + "track_sc_table": "test_sticksc", + "track_sc_key": "src" +} diff --git a/e2e/tests/http_request_rules/data/post-track-sc.json b/e2e/tests/http_request_rules/data/post-track-sc.json new file mode 100644 index 00000000..211e96ff --- /dev/null +++ b/e2e/tests/http_request_rules/data/post-track-sc.json @@ -0,0 +1,8 @@ +{ + "cond": "if", + "cond_test": "TRUE", + "type": "track-sc", + "track_sc_table": "test_sticksc", + "track_sc_key": "src", + "track_sc_stick_counter": 5 +} diff --git a/e2e/tests/http_request_rules/data/post.json b/e2e/tests/http_request_rules/data/post.json new file mode 100644 index 00000000..cef79f42 --- /dev/null +++ b/e2e/tests/http_request_rules/data/post.json @@ -0,0 +1,7 @@ +{ + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" +} diff --git a/e2e/tests/http_request_rules/data/put.json b/e2e/tests/http_request_rules/data/put.json new file mode 100644 index 00000000..166c7e8e --- /dev/null +++ b/e2e/tests/http_request_rules/data/put.json @@ -0,0 +1,7 @@ +{ + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" +} diff --git a/e2e/tests/http_request_rules/data/replace-all.json b/e2e/tests/http_request_rules/data/replace-all.json new file mode 100644 index 00000000..5417ccba --- /dev/null +++ b/e2e/tests/http_request_rules/data/replace-all.json @@ -0,0 +1,19 @@ +[ + { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "type": "allow" + }, + { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" + }, + { + "cond": "if", + "cond_test": "{ src 3.3.3.3/16 }", + "type": "allow" + } +] diff --git a/e2e/tests/http_request_rules/delete.bats b/e2e/tests/http_request_rules/delete.bats new file mode 100644 index 00000000..67470cfe --- /dev/null +++ b/e2e/tests/http_request_rules/delete.bats @@ -0,0 +1,70 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_request_rules: Delete a HTTP Request Rule from frontend" { + # + # Deleting first + # + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting second + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + if haproxy_version_ge "2.8"; then + # Deleting third + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + fi + # Not found + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_request_rules: Delete a HTTP Request Rule from backend" { + # + # Deleting first + # + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting second + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Not found + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_request_rules/get.bats b/e2e/tests/http_request_rules/get.bats new file mode 100644 index 00000000..ad98049b --- /dev/null +++ b/e2e/tests/http_request_rules/get.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_request_rules: Return one HTTP Request Rule from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Add-Frontend" + assert_equal "$(get_json_path "$BODY" ".cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Del-Frontend" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 10.1.0.0/16 }" +} + +@test "http_request_rules: Return one HTTP Request Rule from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Add-Backend" + assert_equal "$(get_json_path "$BODY" ".cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/1" + assert_equal "$(get_json_path "$BODY" ".type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Del-Backend" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 10.1.0.0/16 }" +} diff --git a/e2e/tests/http_request_rules/get_2.8.bats b/e2e/tests/http_request_rules/get_2.8.bats new file mode 100644 index 00000000..75afbaa4 --- /dev/null +++ b/e2e/tests/http_request_rules/get_2.8.bats @@ -0,0 +1,73 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_request_rules: Return one track-sc HTTP Request Rule from frontend" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="front_sticksc" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 0 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 5 + fi +} + +@test "http_request_rules: Return one track-sc HTTP Request Rule from backend" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="test_sticksc" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 0 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 5 + fi +} diff --git a/e2e/tests/http_request_rules/list.bats b/e2e/tests/http_request_rules/list.bats new file mode 100644 index 00000000..07856aab --- /dev/null +++ b/e2e/tests/http_request_rules/list.bats @@ -0,0 +1,66 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_request_rules: Return an array of all HTTP Request Rules from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules" + assert_equal "$SC" 200 + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ". | length")" 3 + else + assert_equal "$(get_json_path "$BODY" ". | length")" 2 + fi + assert_equal "$(get_json_path "$BODY" ".[0].type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".[0].hdr_name")" "X-Add-Frontend" + assert_equal "$(get_json_path "$BODY" ".[0].cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".[0].cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".[1].hdr_name")" "X-Del-Frontend" + assert_equal "$(get_json_path "$BODY" ".[1].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[1].cond_test")" "{ src 10.1.0.0/16 }" + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ".[2].type")" "sc-add-gpc" + assert_equal "$(get_json_path "$BODY" ".[2].sc_id")" "1" + assert_equal "$(get_json_path "$BODY" ".[2].sc_int")" "1" + assert_equal "$(get_json_path "$BODY" ".[2].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[2].cond_test")" "FALSE" + fi +} + +@test "http_request_rules: Return one HTTP Request Rule from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + assert_equal "$(get_json_path "$BODY" ".[0].type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".[0].hdr_name")" "X-Add-Backend" + assert_equal "$(get_json_path "$BODY" ".[0].cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".[0].cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".[1].hdr_name")" "X-Del-Backend" + assert_equal "$(get_json_path "$BODY" ".[1].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[1].cond_test")" "{ src 10.1.0.0/16 }" +} diff --git a/e2e/tests/http_request_rules/missing_parent.bats b/e2e/tests/http_request_rules/missing_parent.bats new file mode 100644 index 00000000..063f0e3f --- /dev/null +++ b/e2e/tests/http_request_rules/missing_parent.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_request_rules: Fail creating a HTTP request rule when frontend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} + +@test "http_request_rules: Fail creating a HTTP request rule when backend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/http_request_rules/replace.bats b/e2e/tests/http_request_rules/replace.bats new file mode 100644 index 00000000..869d58b6 --- /dev/null +++ b/e2e/tests/http_request_rules/replace.bats @@ -0,0 +1,75 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_request_rules: Replace a HTTP Request Rule of frontend" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".hdr_format")" "%T" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Haproxy-Current-Date" + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" +} + +@test "http_request_rules: Replace a HTTP Request Rule of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".hdr_format")" "%T" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Haproxy-Current-Date" + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" +} + +@test "http_request_rules: Replace all HTTP Request Rule of frontend" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules" "data/replace-all.json" + assert_equal "$SC" 202 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_request_rules" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + +} + +@test "http_request_rules: Replace all HTTP Request Rule of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules" "data/replace-all.json" + assert_equal "$SC" 202 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_request_rules" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} diff --git a/e2e/tests/http_request_rules/utils/_helpers.bash b/e2e/tests/http_request_rules/utils/_helpers.bash new file mode 100644 index 00000000..57e037d2 --- /dev/null +++ b/e2e/tests/http_request_rules/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_REQ_RULES_BASE_PATH="/services/haproxy/configuration/http_request_rules" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/http_response_rules/add.bats b/e2e/tests/http_response_rules/add.bats new file mode 100644 index 00000000..c9089d31 --- /dev/null +++ b/e2e/tests/http_response_rules/add.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_response_rules: Add a new HTTP Response Rule to frontend" { + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "http_response_rules: Add a new HTTP Response Rule to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} diff --git a/e2e/tests/http_response_rules/add_2.8.bats b/e2e/tests/http_response_rules/add_2.8.bats new file mode 100644 index 00000000..8f729d6b --- /dev/null +++ b/e2e/tests/http_response_rules/add_2.8.bats @@ -0,0 +1,56 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +## tune.stick-counters is a haproxy >= 2.8 global parameter +@test "http_response_rules: Add a new HTTP Response Rule track-sc to backend" { + if haproxy_version_ge "2.8" + then + # Using new track-sc with track_sc_stick_counter + PARENT_NAME="test_sticksc" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/post-track-sc.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 5 + fi +} + +@test "http_response_rules: Fail - Add a new HTTP Response Rule track-sc to backend - when track_sc_stick_counter is missing" { + if haproxy_version_ge "2.8" + then + # Using new track-sc with track_sc_stick_counter + # Fail due to missing track_sc_stick_counter + PARENT_NAME="test_sticksc" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/post-track-sc-fail.json" "force_reload=true" + assert_equal "$SC" 400 + fi +} diff --git a/e2e/tests/http_response_rules/data/haproxy.cfg b/e2e/tests/http_response_rules/data/haproxy.cfg new file mode 100644 index 00000000..be1cd1ff --- /dev/null +++ b/e2e/tests/http_response_rules/data/haproxy.cfg @@ -0,0 +1,41 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + http-response add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 } + http-response del-header X-Del-Frontend if { src 10.1.0.0/16 } + +backend test_backend + mode http + balance roundrobin + option forwardfor + http-response add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 } + http-response del-header X-Del-Backend if { src 10.1.0.0/16 } diff --git a/e2e/tests/http_response_rules/data/haproxy_2.8.cfg b/e2e/tests/http_response_rules/data/haproxy_2.8.cfg new file mode 100644 index 00000000..60f41d76 --- /dev/null +++ b/e2e/tests/http_response_rules/data/haproxy_2.8.cfg @@ -0,0 +1,55 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + tune.stick-counters 6 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode http + bind :80 + maxconn 1000 + option httpclose + http-response add-header X-Add-Frontend CustomValue unless { src 192.168.0.0/16 } + http-response del-header X-Del-Frontend if { src 10.1.0.0/16 } + http-response sc-add-gpc(0,1) 1 if FALSE + +frontend front_sticksc + bind *:1248 + default_backend test_sticksc + http-response track-sc0 src table test_sticksc if TRUE + http-response track-sc5 src table test_sticksc if TRUE + +backend test_backend + mode http + balance roundrobin + option forwardfor + http-response add-header X-Add-Backend CustomValue unless { src 192.168.0.0/16 } + http-response del-header X-Del-Backend if { src 10.1.0.0/16 } + +backend test_sticksc + http-response track-sc0 src table test_sticksc if TRUE + http-response track-sc5 src table test_sticksc if TRUE + stick-table type ip size 1m expire 5m store gpc0,conn_rate(30s) + server app1 127.0.0.1:4444 check diff --git a/e2e/tests/http_response_rules/data/post-track-sc-fail.json b/e2e/tests/http_response_rules/data/post-track-sc-fail.json new file mode 100644 index 00000000..82d8eab6 --- /dev/null +++ b/e2e/tests/http_response_rules/data/post-track-sc-fail.json @@ -0,0 +1,7 @@ +{ + "cond": "if", + "cond_test": "TRUE", + "type": "track-sc", + "track_sc_table": "test_sticksc", + "track_sc_key": "src" +} diff --git a/e2e/tests/http_response_rules/data/post-track-sc.json b/e2e/tests/http_response_rules/data/post-track-sc.json new file mode 100644 index 00000000..211e96ff --- /dev/null +++ b/e2e/tests/http_response_rules/data/post-track-sc.json @@ -0,0 +1,8 @@ +{ + "cond": "if", + "cond_test": "TRUE", + "type": "track-sc", + "track_sc_table": "test_sticksc", + "track_sc_key": "src", + "track_sc_stick_counter": 5 +} diff --git a/e2e/tests/http_response_rules/data/post.json b/e2e/tests/http_response_rules/data/post.json new file mode 100644 index 00000000..cef79f42 --- /dev/null +++ b/e2e/tests/http_response_rules/data/post.json @@ -0,0 +1,7 @@ +{ + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" +} diff --git a/e2e/tests/http_response_rules/data/put.json b/e2e/tests/http_response_rules/data/put.json new file mode 100644 index 00000000..166c7e8e --- /dev/null +++ b/e2e/tests/http_response_rules/data/put.json @@ -0,0 +1,7 @@ +{ + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" +} diff --git a/e2e/tests/http_response_rules/data/replace-all.json b/e2e/tests/http_response_rules/data/replace-all.json new file mode 100644 index 00000000..5417ccba --- /dev/null +++ b/e2e/tests/http_response_rules/data/replace-all.json @@ -0,0 +1,19 @@ +[ + { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "type": "allow" + }, + { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "type": "add-header" + }, + { + "cond": "if", + "cond_test": "{ src 3.3.3.3/16 }", + "type": "allow" + } +] diff --git a/e2e/tests/http_response_rules/delete.bats b/e2e/tests/http_response_rules/delete.bats new file mode 100644 index 00000000..869f504c --- /dev/null +++ b/e2e/tests/http_response_rules/delete.bats @@ -0,0 +1,70 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_response_rules: Delete a HTTP Response Rule from frontend" { + # + # Deleting the first one + # + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the second one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + if haproxy_version_ge "2.8"; then + # Deleting the third one + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + fi + # No more HTTP response rules, not found! + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "http_response_rules: Delete a HTTP Response Rule from backend" { +# + # Deleting the first one + # + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting the second one + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + # + # No more HTTP response rules, not found! + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/http_response_rules/get.bats b/e2e/tests/http_response_rules/get.bats new file mode 100644 index 00000000..4d30e69c --- /dev/null +++ b/e2e/tests/http_response_rules/get.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_response_rules: Return one HTTP Response Rule from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Add-Frontend" + assert_equal "$(get_json_path "$BODY" ".cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Del-Frontend" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 10.1.0.0/16 }" +} + +@test "http_response_rules: Return one HTTP Response Rule from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Add-Backend" + assert_equal "$(get_json_path "$BODY" ".cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Del-Backend" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 10.1.0.0/16 }" +} diff --git a/e2e/tests/http_response_rules/get_2.8.bats b/e2e/tests/http_response_rules/get_2.8.bats new file mode 100644 index 00000000..40551448 --- /dev/null +++ b/e2e/tests/http_response_rules/get_2.8.bats @@ -0,0 +1,74 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +## tune.stick-counters is a haproxy >= 2.8 global parameter +@test "http_response_rules: Return one track-sc HTTP Response Rule from frontend" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="front_sticksc" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 0 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 5 + fi +} + +@test "http_response_rules: Return one track-sc HTTP Response Rule from backend" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="test_sticksc" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 0 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".type")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_sc_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_sc_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_sc_stick_counter")" 5 + fi +} diff --git a/e2e/tests/http_response_rules/list.bats b/e2e/tests/http_response_rules/list.bats new file mode 100644 index 00000000..2388541e --- /dev/null +++ b/e2e/tests/http_response_rules/list.bats @@ -0,0 +1,66 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "http_response_rules: Return an array of all HTTP Response Rules from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules" + assert_equal "$SC" 200 + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ". | length")" 3 + else + assert_equal "$(get_json_path "$BODY" ". | length")" 2 + fi + assert_equal "$(get_json_path "$BODY" ".[0].type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".[0].hdr_name")" "X-Add-Frontend" + assert_equal "$(get_json_path "$BODY" ".[0].cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".[0].cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".[1].hdr_name")" "X-Del-Frontend" + assert_equal "$(get_json_path "$BODY" ".[1].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[1].cond_test")" "{ src 10.1.0.0/16 }" + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ".[2].type")" "sc-add-gpc" + assert_equal "$(get_json_path "$BODY" ".[2].sc_id")" "1" + assert_equal "$(get_json_path "$BODY" ".[2].sc_int")" "1" + assert_equal "$(get_json_path "$BODY" ".[2].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[2].cond_test")" "FALSE" + fi +} + +@test "http_response_rules: Return one HTTP Response Rule from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules" + assert_equal "$SC" 200 + assert_equal 2 "$(get_json_path "$BODY" ". | length")" + assert_equal "$(get_json_path "$BODY" ".[0].type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".[0].hdr_name")" "X-Add-Backend" + assert_equal "$(get_json_path "$BODY" ".[0].cond")" "unless" + assert_equal "$(get_json_path "$BODY" ".[0].cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "del-header" + assert_equal "$(get_json_path "$BODY" ".[1].hdr_name")" "X-Del-Backend" + assert_equal "$(get_json_path "$BODY" ".[1].cond")" "if" + assert_equal "$(get_json_path "$BODY" ".[1].cond_test")" "{ src 10.1.0.0/16 }" +} diff --git a/e2e/tests/http_response_rules/missing_parent.bats b/e2e/tests/http_response_rules/missing_parent.bats new file mode 100644 index 00000000..6970edf2 --- /dev/null +++ b/e2e/tests/http_response_rules/missing_parent.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_response_rules: Fail creating a HTTP Response rule when frontend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} + +@test "http_response_rules: Fail creating a HTTP Response rule when backend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/post.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/http_response_rules/replace.bats b/e2e/tests/http_response_rules/replace.bats new file mode 100644 index 00000000..f8e26b6a --- /dev/null +++ b/e2e/tests/http_response_rules/replace.bats @@ -0,0 +1,75 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "http_response_rules: Replace a HTTP Response Rule of frontend" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Haproxy-Current-Date" + assert_equal "$(get_json_path "$BODY" ".hdr_format")" "%T" +} + +@test "http_response_rules: Replace a HTTP Response Rule of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".type")" "add-header" + assert_equal "$(get_json_path "$BODY" ".hdr_name")" "X-Haproxy-Current-Date" + assert_equal "$(get_json_path "$BODY" ".hdr_format")" "%T" +} + +@test "http_request_rules: Replace all HTTP Response Rule of frontend" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules" "data/replace-all.json" "test_frontend" + assert_equal "$SC" 202 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/http_response_rules" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + +} + +@test "http_request_rules: Replace all HTTP Reponse Rule of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules" "data/replace-all.json" + assert_equal "$SC" 202 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/http_response_rules" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} diff --git a/e2e/tests/http_response_rules/utils/_helpers.bash b/e2e/tests/http_response_rules/utils/_helpers.bash new file mode 100644 index 00000000..e0635e7a --- /dev/null +++ b/e2e/tests/http_response_rules/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RES_RULES_BASE_PATH="/services/haproxy/configuration/http_response_rules" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/log_forwards/data/haproxy.cfg b/e2e/tests/log_forwards/data/haproxy.cfg new file mode 100644 index 00000000..354bf8f5 --- /dev/null +++ b/e2e/tests/log_forwards/data/haproxy.cfg @@ -0,0 +1,26 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +backend test_backend_add + mode tcp + option tcp-check + +log-forward sylog-loadb + dgram-bind 127.0.0.1:1514 + bind 127.0.0.1:1514 + timeout client 50000 + # all messages on stderr + log global + # all messages on local tcp syslog server + log ring@myring local0 + # load balance messages on 4 udp syslog servers + log 127.0.0.1:10001 sample 1:4 local0 + log 127.0.0.1:10002 sample 2:4 local0 + log 127.0.0.1:10003 sample 3:4 local0 + log 127.0.0.1:10004 sample 4:4 local0 diff --git a/e2e/tests/log_forwards/data/post.json b/e2e/tests/log_forwards/data/post.json new file mode 100644 index 00000000..8ae72286 --- /dev/null +++ b/e2e/tests/log_forwards/data/post.json @@ -0,0 +1,6 @@ +{ + "backlog": 10, + "maxconn": 20, + "name": "test_log_forward", + "timeout_client": 50000 +} diff --git a/e2e/tests/log_forwards/data/put.json b/e2e/tests/log_forwards/data/put.json new file mode 100644 index 00000000..f3fce861 --- /dev/null +++ b/e2e/tests/log_forwards/data/put.json @@ -0,0 +1,6 @@ +{ + "backlog": 100, + "maxconn": 200, + "name": "sylog-loadb", + "timeout_client": 40000 +} diff --git a/e2e/tests/log_forwards/test.bats b/e2e/tests/log_forwards/test.bats new file mode 100644 index 00000000..ad3836ea --- /dev/null +++ b/e2e/tests/log_forwards/test.bats @@ -0,0 +1,67 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "log_forwards: Add a log forward" { + if haproxy_version_ge "2.3" + then + resource_post "$_LOG_FORWARD_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" "201" + fi +} + +@test "log_forwards: Return a log forward" { + if haproxy_version_ge "2.3" + then + resource_get "$_LOG_FORWARD_BASE_PATH/sylog-loadb" + assert_equal "$SC" 200 + assert_equal "sylog-loadb" "$(get_json_path "$BODY" '.name')" + fi +} + +@test "log_forwards: Replace a log forward" { + if haproxy_version_ge "2.3" + then + resource_put "$_LOG_FORWARD_BASE_PATH/sylog-loadb" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + fi +} + +@test "log_forwards: Return an array of log_forwards" { + if haproxy_version_ge "2.3" + then + resource_get "$_LOG_FORWARD_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "sylog-loadb" "$(get_json_path "$BODY" '.[0].name')" + fi +} + +@test "log_forwards: Delete a log forward" { + if haproxy_version_ge "2.3" + then + resource_delete "$_LOG_FORWARD_BASE_PATH/sylog-loadb" "force_reload=true" + assert_equal "$SC" 204 + fi +} diff --git a/e2e/tests/log_forwards/utils/_helpers.bash b/e2e/tests/log_forwards/utils/_helpers.bash new file mode 100644 index 00000000..c91386bc --- /dev/null +++ b/e2e/tests/log_forwards/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_LOG_FORWARD_BASE_PATH="/services/haproxy/configuration/log_forwards" diff --git a/e2e/tests/log_profile/data/edit_profile.json b/e2e/tests/log_profile/data/edit_profile.json new file mode 100644 index 00000000..693e393b --- /dev/null +++ b/e2e/tests/log_profile/data/edit_profile.json @@ -0,0 +1,17 @@ +{ + "name": "logp1", + "log_tag": "tag2", + "steps": [ + { + "step": "connect", + "drop": "disabled", + "format": "new connection" + }, + { + "step": "error", + "drop": "disabled", + "format": "%ci: error", + "sd": "%T %H sd" + } + ] +} diff --git a/e2e/tests/log_profile/data/new_profile.json b/e2e/tests/log_profile/data/new_profile.json new file mode 100644 index 00000000..5a63a5ca --- /dev/null +++ b/e2e/tests/log_profile/data/new_profile.json @@ -0,0 +1,21 @@ +{ + "name": "logp1", + "log_tag": "tag1", + "steps": [ + { + "step": "connect", + "drop": "enabled" + }, + { + "step": "error", + "drop": "disabled", + "format": "%ci: error", + "sd": "%T %H sd" + }, + { + "step": "any", + "drop": "disabled", + "sd": "custom sd" + } + ] +} diff --git a/e2e/tests/log_profile/log_profile.bats b/e2e/tests/log_profile/log_profile.bats new file mode 100644 index 00000000..791dceed --- /dev/null +++ b/e2e/tests/log_profile/log_profile.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/get_json_path' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "log_profile: all tests (>=3.1)" { + haproxy_version_ge "3.1" || skip + + resource_post "$_LOG_PROFILE_PATH" "data/new_profile.json" "force_reload=true" + assert_equal "$SC" "201" + + resource_get "$_LOG_PROFILE_PATH/$_PROFILE_NAME" + assert_equal "$SC" "200" + assert_equal "$_PROFILE_NAME" "$(get_json_path "$BODY" .name)" + assert_equal "tag1" "$(get_json_path "$BODY" .log_tag)" + assert_equal "enabled" "$(get_json_path "$BODY" .steps.[0].drop)" + assert_equal "any" "$(get_json_path "$BODY" .steps.[2].step)" + + resource_put "$_LOG_PROFILE_PATH/$_PROFILE_NAME" "data/edit_profile.json" "force_reload=true" + assert_equal "$SC" "200" + resource_get "$_LOG_PROFILE_PATH/$_PROFILE_NAME" + assert_equal "tag2" "$(get_json_path "$BODY" .log_tag)" + assert_equal "disabled" "$(get_json_path "$BODY" .steps.[0].drop)" + assert_equal 2 "$(get_json_path "$BODY" '.steps|length')" + + resource_get "$_LOG_PROFILE_PATH" + assert_equal "$SC" "200" + assert_equal "$_PROFILE_NAME" "$(get_json_path "$BODY" .[0].name)" + + resource_delete "$_LOG_PROFILE_PATH/$_PROFILE_NAME" "force_reload=true" + assert_equal "$SC" "204" + resource_get "$_LOG_PROFILE_PATH/$_PROFILE_NAME" + assert_equal "$SC" "404" +} diff --git a/e2e/tests/log_profile/utils/_helpers.bash b/e2e/tests/log_profile/utils/_helpers.bash new file mode 100644 index 00000000..cf8eec8d --- /dev/null +++ b/e2e/tests/log_profile/utils/_helpers.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_PROFILE_NAME="logp1" +_LOG_PROFILE_PATH="/services/haproxy/configuration/log_profiles" diff --git a/e2e/tests/log_targets/add.bats b/e2e/tests/log_targets/add.bats new file mode 100644 index 00000000..e583f051 --- /dev/null +++ b/e2e/tests/log_targets/add.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "log_targets: Add a new Log Target to frontend" { + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" "data/nolog.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "log_targets: Add a new Log Target to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "data/nolog.json" "force_reload=true" + assert_equal "$SC" 201 +} + + +@test "log_targets: Add a new Log Target to global" { + PARENT_NAME="test_backend" + resource_post "$_GLOBAL_BASE_PATH/log_targets/0" "data/nolog.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_GLOBAL_BASE_PATH/log_targets/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".nolog")" "true" +} + +@test "log_targets: Add a new Log Target to defaults" { + PARENT_NAME="mydefaults" + resource_post "$_DEFAULT_BASE_PATH/$PARENT_NAME/log_targets/0" "data/nolog.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_DEFAULT_BASE_PATH/$PARENT_NAME/log_targets/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".nolog")" "true" +} diff --git a/e2e/tests/log_targets/data/haproxy.cfg b/e2e/tests/log_targets/data/haproxy.cfg new file mode 100644 index 00000000..87f2f0e6 --- /dev/null +++ b/e2e/tests/log_targets/data/haproxy.cfg @@ -0,0 +1,40 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode tcp + maxconn 1000 + log localhost format raw user warning + log 10.0.0.1 format raw user info + option httpclose + +backend test_backend + mode http + balance roundrobin + option forwardfor + log localhost format raw user warning + log 10.0.0.1 format raw user info diff --git a/e2e/tests/log_targets/data/nolog.json b/e2e/tests/log_targets/data/nolog.json new file mode 100644 index 00000000..f45f09b8 --- /dev/null +++ b/e2e/tests/log_targets/data/nolog.json @@ -0,0 +1,3 @@ +{ + "nolog": true +} diff --git a/e2e/tests/log_targets/data/put.json b/e2e/tests/log_targets/data/put.json new file mode 100644 index 00000000..f46930e2 --- /dev/null +++ b/e2e/tests/log_targets/data/put.json @@ -0,0 +1,7 @@ +{ + "address": "localhost", + "format": "raw", + "facility": "user", + "level": "warning", + "index": 0 +} diff --git a/e2e/tests/log_targets/data/replace-all.json b/e2e/tests/log_targets/data/replace-all.json new file mode 100644 index 00000000..246f1e9c --- /dev/null +++ b/e2e/tests/log_targets/data/replace-all.json @@ -0,0 +1,20 @@ +[ + { + "address": "1.1.1.1", + "facility": "user", + "format": "raw", + "level": "warning" + }, + { + "address": "2.2.2.2", + "facility": "user", + "format": "raw", + "level": "warning" + }, + { + "address": "3.3.3.3", + "facility": "user", + "format": "raw", + "level": "warning" + } +] diff --git a/e2e/tests/log_targets/delete.bats b/e2e/tests/log_targets/delete.bats new file mode 100644 index 00000000..34ac0842 --- /dev/null +++ b/e2e/tests/log_targets/delete.bats @@ -0,0 +1,62 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "log_targets: Delete a Log Target from frontend" { + # + # Deleting first entry + # + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting second entry + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 204 + # + # No further log target, not found! + # + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "log_targets: Delete a Log Target from backend" { + # + # Deleting first entry + # + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 204 + # + # Deleting second entry + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 204 + # + # No further log target, not found! + # + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/log_targets/get.bats b/e2e/tests/log_targets/get.bats new file mode 100644 index 00000000..a938529a --- /dev/null +++ b/e2e/tests/log_targets/get.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "log_targets: Return one Log Target from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".address")" "localhost" + assert_equal "$(get_json_path "$BODY" ".facility")" "user" + assert_equal "$(get_json_path "$BODY" ".format")" "raw" + assert_equal "$(get_json_path "$BODY" ".level")" "warning" + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".address")" "10.0.0.1" + assert_equal "$(get_json_path "${BODY}" ".facility")" "user" + assert_equal "$(get_json_path "${BODY}" ".format")" "raw" + assert_equal "$(get_json_path "${BODY}" ".level")" "info" +} + +@test "log_targets: Return one Log Target from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "parent_type=backend&parent_name=test_backend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".address")" "localhost" + assert_equal "$(get_json_path "$BODY" ".facility")" "user" + assert_equal "$(get_json_path "$BODY" ".format")" "raw" + assert_equal "$(get_json_path "$BODY" ".level")" "warning" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".address")" "10.0.0.1" + assert_equal "$(get_json_path "$BODY" ".facility")" "user" + assert_equal "$(get_json_path "$BODY" ".format")" "raw" + assert_equal "$(get_json_path "$BODY" ".level")" "info" +} diff --git a/e2e/tests/log_targets/list.bats b/e2e/tests/log_targets/list.bats new file mode 100644 index 00000000..5d09b227 --- /dev/null +++ b/e2e/tests/log_targets/list.bats @@ -0,0 +1,60 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "log_targets: Return an array of all Log Targets from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + + assert_equal "$(get_json_path "${BODY}" ".[0].address")" "localhost" + assert_equal "$(get_json_path "${BODY}" ".[0].facility")" "user" + assert_equal "$(get_json_path "${BODY}" ".[0].format")" "raw" + assert_equal "$(get_json_path "${BODY}" ".[0].level")" "warning" + + assert_equal "$(get_json_path "${BODY}" ".[1].address")" "10.0.0.1" + assert_equal "$(get_json_path "${BODY}" ".[1].facility")" "user" + assert_equal "$(get_json_path "${BODY}" ".[1].format")" "raw" + assert_equal "$(get_json_path "${BODY}" ".[1].level")" "info" +} + +@test "log_targets: Return an array of all Log Targets from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets" "parent_type=backend&parent_name=test_backend" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + + assert_equal "$(get_json_path "${BODY}" ".[0].address")" "localhost" + assert_equal "$(get_json_path "${BODY}" ".[0].facility")" "user" + assert_equal "$(get_json_path "${BODY}" ".[0].format")" "raw" + assert_equal "$(get_json_path "${BODY}" ".[0].level")" "warning" + + assert_equal "$(get_json_path "${BODY}" ".[1].address")" "10.0.0.1" + assert_equal "$(get_json_path "${BODY}" ".[1].facility")" "user" + assert_equal "$(get_json_path "${BODY}" ".[1].format")" "raw" + assert_equal "$(get_json_path "${BODY}" ".[1].level")" "info" +} diff --git a/e2e/tests/log_targets/missing_parent.bats b/e2e/tests/log_targets/missing_parent.bats new file mode 100644 index 00000000..54dad726 --- /dev/null +++ b/e2e/tests/log_targets/missing_parent.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "log_targets: Fail creating a Log Target when frontend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" "data/nolog.json" "force_reload=true" + assert_equal "$SC" 400 +} + +@test "log_targets: Fail creating a Log Target when backend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "data/nolog.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/log_targets/replace.bats b/e2e/tests/log_targets/replace.bats new file mode 100644 index 00000000..6df5a2a3 --- /dev/null +++ b/e2e/tests/log_targets/replace.bats @@ -0,0 +1,64 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "log_targets: Replace a Log Target of frontend" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".address")" "localhost" + assert_equal "$(get_json_path "$BODY" ".format")" "raw" + assert_equal "$(get_json_path "$BODY" ".facility")" "user" + assert_equal "$(get_json_path "$BODY" ".level")" "warning" +} + +@test "log_targets: Replace a Log Target of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets/0" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".address")" "localhost" + assert_equal "$(get_json_path "$BODY" ".format")" "raw" + assert_equal "$(get_json_path "$BODY" ".facility")" "user" + assert_equal "$(get_json_path "$BODY" ".level")" "warning" +} + + +@test "log_targets: Replace all Log Targets of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets" "data/replace-all.json" "force_reload=true" + assert_equal "$SC" 200 + # + # verify that Log Targets is actually changed + # + # + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/log_targets" + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} diff --git a/e2e/tests/log_targets/utils/_helpers.bash b/e2e/tests/log_targets/utils/_helpers.bash new file mode 100644 index 00000000..c9e410a5 --- /dev/null +++ b/e2e/tests/log_targets/utils/_helpers.bash @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" +_DEFAULT_BASE_PATH="/services/haproxy/configuration/defaults" +_LOGFORWARD_BASE_PATH="/services/haproxy/configuration/log_forwards" +_PEER_BASE_PATH="/services/haproxy/configuration/peers" +_GLOBAL_BASE_PATH="/services/haproxy/configuration/global" diff --git a/e2e/tests/mailers/data/post_entry1.json b/e2e/tests/mailers/data/post_entry1.json new file mode 100644 index 00000000..07f69947 --- /dev/null +++ b/e2e/tests/mailers/data/post_entry1.json @@ -0,0 +1,5 @@ +{ + "name": "smtp1", + "address": "10.0.10.1", + "port": 587 +} diff --git a/e2e/tests/mailers/data/post_entry2.json b/e2e/tests/mailers/data/post_entry2.json new file mode 100644 index 00000000..c799775f --- /dev/null +++ b/e2e/tests/mailers/data/post_entry2.json @@ -0,0 +1,5 @@ +{ + "name": "smtp2", + "address": "10.0.10.2", + "port": 587 +} \ No newline at end of file diff --git a/e2e/tests/mailers/data/post_section.json b/e2e/tests/mailers/data/post_section.json new file mode 100644 index 00000000..9f2e42f6 --- /dev/null +++ b/e2e/tests/mailers/data/post_section.json @@ -0,0 +1,4 @@ +{ + "name": "test_mailers", + "timeout": 15000 +} \ No newline at end of file diff --git a/e2e/tests/mailers/data/put_entry.json b/e2e/tests/mailers/data/put_entry.json new file mode 100644 index 00000000..9a2e7234 --- /dev/null +++ b/e2e/tests/mailers/data/put_entry.json @@ -0,0 +1,5 @@ +{ + "name": "smtp2", + "address": "10.0.10.88", + "port": 8587 + } \ No newline at end of file diff --git a/e2e/tests/mailers/data/put_section.json b/e2e/tests/mailers/data/put_section.json new file mode 100644 index 00000000..a69cc74b --- /dev/null +++ b/e2e/tests/mailers/data/put_section.json @@ -0,0 +1,4 @@ +{ + "name": "test_mailers", + "timeout": 30000 +} \ No newline at end of file diff --git a/e2e/tests/mailers/mailers.bats b/e2e/tests/mailers/mailers.bats new file mode 100644 index 00000000..87957861 --- /dev/null +++ b/e2e/tests/mailers/mailers.bats @@ -0,0 +1,99 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# We test both mailers sections and entries in the same file. +# If they were separated in 2 files, bats would run them +# in parrallel, making some tests fail. + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "mailers: add a section" { + resource_post "$_MAILERS_SECTION_PATH" "data/post_section.json" "force_reload=true" + assert_equal "$SC" "201" +} + +@test "mailers: get a section" { + resource_get "$_MAILERS_SECTION_PATH/$_SECTION_NAME" + assert_equal "$SC" "200" + assert_equal "$_SECTION_NAME" "$(get_json_path "$BODY" .name)" + assert_equal "15000" "$(get_json_path "$BODY" .timeout)" +} + +@test "mailers: edit a section" { + resource_put "$_MAILERS_SECTION_PATH/$_SECTION_NAME" "data/put_section.json" "force_reload=true" + assert_equal "$SC" "200" + resource_get "$_MAILERS_SECTION_PATH/$_SECTION_NAME" + assert_equal "30000" "$(get_json_path "$BODY" .timeout)" +} + +@test "mailers: get a list of sections" { + resource_get "$_MAILERS_SECTION_PATH" + assert_equal "$SC" "200" + assert_equal "$_SECTION_NAME" "$(get_json_path "$BODY" .[0].name)" +} + +@test "mailers: add entries" { + resource_post "$_MAILER_ENTRIES_PATH" "data/post_entry1.json" "mailers_section=$_SECTION_NAME" + assert_equal "$SC" "202" + resource_post "$_MAILER_ENTRIES_PATH" "data/post_entry2.json" "mailers_section=$_SECTION_NAME" + assert_equal "$SC" "202" +} + +@test "mailers: get an entry" { + resource_get "$_MAILER_ENTRIES_PATH/smtp1" "mailers_section=$_SECTION_NAME" + assert_equal "$SC" "200" + assert_equal "smtp1" "$(get_json_path "$BODY" .name)" + assert_equal "10.0.10.1" "$(get_json_path "$BODY" .address)" + assert_equal "587" "$(get_json_path "$BODY" .port)" +} + +@test "mailers: get all entries" { + resource_get "$_MAILER_ENTRIES_PATH" "mailers_section=$_SECTION_NAME" + assert_equal "$SC" "200" + assert_equal "2" "$(get_json_path "$BODY" '.|length')" + assert_equal "smtp1" "$(get_json_path "$BODY" .[0].name)" + assert_equal "smtp2" "$(get_json_path "$BODY" .[1].name)" +} + +@test "mailers: modify an entry" { + resource_put "$_MAILER_ENTRIES_PATH/smtp2" "data/put_entry.json" \ + "mailers_section=$_SECTION_NAME" "force_reload=true" + assert_equal "$SC" "202" + resource_get "$_MAILER_ENTRIES_PATH/smtp2" "mailers_section=$_SECTION_NAME" + assert_equal "smtp2" "$(get_json_path "$BODY" .name)" + assert_equal "10.0.10.88" "$(get_json_path "$BODY" .address)" + assert_equal "8587" "$(get_json_path "$BODY" .port)" +} + +@test "mailers: delete an entry" { + resource_delete "$_MAILER_ENTRIES_PATH/smtp2" "mailers_section=$_SECTION_NAME" "force_reload=true" + assert_equal "$SC" "202" + resource_get "$_MAILER_ENTRIES_PATH/smtp2" "mailers_section=$_SECTION_NAME" + assert_equal "$SC" "404" +} + +@test "mailers: delete a section" { + resource_delete "$_MAILERS_SECTION_PATH/$_SECTION_NAME" "force_reload=true" + assert_equal "$SC" "204" + resource_get "$_MAILERS_SECTION_PATH/$_SECTION_NAME" + assert_equal "$SC" "404" +} diff --git a/e2e/tests/mailers/utils/_helpers.bash b/e2e/tests/mailers/utils/_helpers.bash new file mode 100644 index 00000000..bb48ac69 --- /dev/null +++ b/e2e/tests/mailers/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SECTION_NAME="test_mailers" +_MAILER_ENTRIES_PATH="/services/haproxy/configuration/mailer_entries" +_MAILERS_SECTION_PATH="/services/haproxy/configuration/mailers_section" diff --git a/e2e/tests/process_manager/create.bats b/e2e/tests/process_manager/create.bats new file mode 100644 index 00000000..5ea8efe9 --- /dev/null +++ b/e2e/tests/process_manager/create.bats @@ -0,0 +1,52 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "process-manager: Create one new program" { + if haproxy_version_ge "3.3"; then skip "programs have been removed in haproxy 3.3"; fi + + resource_post "$_PROGRAMS_BASE_PATH" "data/program.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_PROGRAMS_BASE_PATH/test" + assert_equal "$SC" 200 + assert_equal "test" "$(get_json_path "$BODY" ".name")" + assert_equal "haproxy" "$(get_json_path "$BODY" ".user")" + assert_equal "haproxy" "$(get_json_path "$BODY" ".group")" +} + +@test "process-manager: Fail creating program with same name" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_post "$_PROGRAMS_BASE_PATH" "data/program_duplicated.json" "force_reload=true" + assert_equal "$SC" 409 +} + +@test "process-manager: Fail creating program that isn't valid" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_post "$_PROGRAMS_BASE_PATH" "data/program_invalid.json" "force_reload=true" + assert_equal "$SC" 422 +} diff --git a/e2e/tests/process_manager/data/haproxy.cfg b/e2e/tests/process_manager/data/haproxy.cfg new file mode 100644 index 00000000..28d98f25 --- /dev/null +++ b/e2e/tests/process_manager/data/haproxy.cfg @@ -0,0 +1,32 @@ +# _version=42 + +global + master-worker + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +program echo + command echo "Hello, World!" diff --git a/e2e/tests/process_manager/data/haproxy_3.0.cfg b/e2e/tests/process_manager/data/haproxy_3.0.cfg new file mode 100644 index 00000000..3137650c --- /dev/null +++ b/e2e/tests/process_manager/data/haproxy_3.0.cfg @@ -0,0 +1,33 @@ +# _version=42 + +global + expose-deprecated-directives + master-worker + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +program echo + command echo "Hello, World!" diff --git a/e2e/tests/process_manager/data/program.json b/e2e/tests/process_manager/data/program.json new file mode 100644 index 00000000..c07209ac --- /dev/null +++ b/e2e/tests/process_manager/data/program.json @@ -0,0 +1,7 @@ +{ + "name": "test", + "command": "echo true", + "start-on-reload": "disabled", + "user": "haproxy", + "group": "haproxy" +} diff --git a/e2e/tests/process_manager/data/program_duplicated.json b/e2e/tests/process_manager/data/program_duplicated.json new file mode 100644 index 00000000..bb3e417a --- /dev/null +++ b/e2e/tests/process_manager/data/program_duplicated.json @@ -0,0 +1,4 @@ +{ + "name": "echo", + "command": "echo \"Hello Universe\"" +} diff --git a/e2e/tests/process_manager/data/program_invalid.json b/e2e/tests/process_manager/data/program_invalid.json new file mode 100644 index 00000000..d6c06107 --- /dev/null +++ b/e2e/tests/process_manager/data/program_invalid.json @@ -0,0 +1,5 @@ +{ + "name": "program_created", + "user": "haproxy", + "group": "group" +} \ No newline at end of file diff --git a/e2e/tests/process_manager/delete.bats b/e2e/tests/process_manager/delete.bats new file mode 100644 index 00000000..7a6b9e9a --- /dev/null +++ b/e2e/tests/process_manager/delete.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "process-manager: Delete one program by name" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_delete "$_PROGRAMS_BASE_PATH/echo" "force_reload=true" + assert_equal "$SC" 204 + + resource_get "$_PROGRAMS_BASE_PATH/echo" + assert_equal "$SC" 404 +} + +@test "process-manager: Fail deleting app that doesn't exist" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_delete "$_PROGRAMS_BASE_PATH/i_am_not_here" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/process_manager/get.bats b/e2e/tests/process_manager/get.bats new file mode 100644 index 00000000..223ec6ef --- /dev/null +++ b/e2e/tests/process_manager/get.bats @@ -0,0 +1,40 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "process-manager: Return one program by name" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_get "$_PROGRAMS_BASE_PATH/echo" + assert_equal "$SC" 200 + assert_equal "echo" "$(get_json_path "$BODY" ".name")" +} + +@test "process-manager: Fail returning program that doesn't exist" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_get "$_PROGRAMS_BASE_PATH/i_am_not_here" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/process_manager/list.bats b/e2e/tests/process_manager/list.bats new file mode 100644 index 00000000..defb9523 --- /dev/null +++ b/e2e/tests/process_manager/list.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "process-manager: Return an array of programs" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_get "$_PROGRAMS_BASE_PATH" + assert_equal "$SC" 200 + assert_equal 1 "$(get_json_path "$BODY" ". | length")" +} diff --git a/e2e/tests/process_manager/replace.bats b/e2e/tests/process_manager/replace.bats new file mode 100644 index 00000000..fa4ca59b --- /dev/null +++ b/e2e/tests/process_manager/replace.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "process-manager: Replace one program" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_put "$_PROGRAMS_BASE_PATH/echo" "data/program_duplicated.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_PROGRAMS_BASE_PATH/echo" + assert_equal "$SC" 200 + assert_equal "echo" "$(get_json_path "$BODY" ".name")" + assert_equal "echo \"Hello Universe\"" "$(get_json_path "$BODY" ".command")" +} + +@test "process-manager: Fail replacing program that doesn't exist" { + if haproxy_version_ge "3.3"; then skip; fi + + resource_put "$_PROGRAMS_BASE_PATH/i_am_not_here" "data/program_duplicated.json" "force_reload=true" + assert_equal "$SC" 409 +} diff --git a/e2e/tests/process_manager/utils/_helpers.bash b/e2e/tests/process_manager/utils/_helpers.bash new file mode 100644 index 00000000..efe22634 --- /dev/null +++ b/e2e/tests/process_manager/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2022 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_PROGRAMS_BASE_PATH="/services/haproxy/configuration/programs" diff --git a/e2e/tests/raw/data/haproxy.cfg b/e2e/tests/raw/data/haproxy.cfg new file mode 100644 index 00000000..39c30798 --- /dev/null +++ b/e2e/tests/raw/data/haproxy.cfg @@ -0,0 +1,34 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +backend test_backend + mode http + balance roundrobin + option forwardfor + server server_01 10.1.1.1:8080 check weight 80 + server server_02 10.1.1.2:8080 check weight 80 + server server_03 10.1.1.2:8080 check weight 80 diff --git a/e2e/tests/raw/data/haproxy.cfg.json b/e2e/tests/raw/data/haproxy.cfg.json new file mode 100644 index 00000000..e889d11c --- /dev/null +++ b/e2e/tests/raw/data/haproxy.cfg.json @@ -0,0 +1 @@ +"global\n chroot /var/lib/haproxy\n user haproxy\n group haproxy\n maxconn 4000\n pidfile /var/run/haproxy.pid\n stats socket /var/lib/haproxy/stats level admin\n log 127.0.0.1 local2\n\ndefaults mydefaults\n mode http\n maxconn 3000\n log global\n option httplog\n option redispatch\n option dontlognull\n option http-server-close\n option forwardfor except 127.0.0.0/8\n timeout http-request 10s\n timeout check 10s\n timeout connect 10s\n timeout client 1m\n timeout queue 1m\n timeout server 1m\n timeout http-keep-alive 10s\n retries 3\n\nbackend test_backend\n mode http\n balance roundrobin\n option forwardfor\n server server_01 10.1.1.1:8080 check weight 80\n server server_02 10.1.1.2:8080 check weight 80\n server server_03 10.1.1.2:8080 check weight 80\n" diff --git a/e2e/tests/raw/data/haproxy_socket.cfg.json b/e2e/tests/raw/data/haproxy_socket.cfg.json new file mode 100644 index 00000000..28fc85e3 --- /dev/null +++ b/e2e/tests/raw/data/haproxy_socket.cfg.json @@ -0,0 +1 @@ +"global\n chroot /var/lib/haproxy\n user haproxy\n group haproxy\n maxconn 4000\n pidfile /var/run/haproxy.pid\n stats socket /var/lib/haproxy/stats-new level admin\n log 127.0.0.1 local2\n\ndefaults mydefaults\n mode http\n maxconn 3000\n log global\n option httplog\n option redispatch\n option dontlognull\n option http-server-close\n option forwardfor except 127.0.0.0/8\n timeout http-request 10s\n timeout check 10s\n timeout connect 10s\n timeout client 1m\n timeout queue 1m\n timeout server 1m\n timeout http-keep-alive 10s\n retries 3\n\nbackend test_backend\n mode http\n balance roundrobin\n option forwardfor\n server server_01 10.1.1.1:8080 check weight 80\n server server_02 10.1.1.2:8080 check weight 80\n server server_03 10.1.1.2:8080 check weight 80\n" diff --git a/e2e/tests/raw/get.bats b/e2e/tests/raw/get.bats new file mode 100644 index 00000000..3483f792 --- /dev/null +++ b/e2e/tests/raw/get.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' + +load 'utils/_helpers' + +@test "raw: Download configuration" { + resource_get "$_RAW_BASE_PATH" + assert_equal "$SC" 200 + test -n "$BODY" || + fail "failed to download raw config. BODY: '$BODY'" +} diff --git a/e2e/tests/raw/post.bats b/e2e/tests/raw/post.bats new file mode 100644 index 00000000..1706b190 --- /dev/null +++ b/e2e/tests/raw/post.bats @@ -0,0 +1,59 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "raw: Post new configuration" { + resource_post "$_RAW_BASE_PATH" 'data/haproxy.cfg.json' + assert_equal "$SC" 202 +} + +@test "raw: Post new configuration incorrectly (bug 1219)" { + resource_post_text "$_RAW_BASE_PATH" 'data/haproxy.cfg.json' + assert_equal "$SC" 400 + assert_equal "$(get_json_path "$BODY" '.message')" "invalid configuration: no newline character found" +} + + +@test "raw: Post new configuration with socket path changed" { + resource_post "$_RAW_BASE_PATH" 'data/haproxy_socket.cfg.json' + assert_equal "$SC" 202 + + resource_get "$_RAW_BASE_PATH" "" + assert_equal "$SC" 200 + + local socket; socket='stats socket /var/lib/haproxy/stats-new' + if [[ "$BODY" != *"$socket"* ]]; then + batslib_print_kv_single_or_multi 8 \ + 'configuration' "$BODY" \ + 'expected socket' "$socket" \ + | batslib_decorate 'configuration does not contains the new socket' \ + | fail + fi + + # check that runtime client has been reconfigured with the new socket + sleep 5 + resource_get "$_RUNTIME_MAP_FILES_BASE_PATH" "" + assert_equal "$SC" 200 +} diff --git a/e2e/tests/raw/utils/_helpers.bash b/e2e/tests/raw/utils/_helpers.bash new file mode 100644 index 00000000..41c05a74 --- /dev/null +++ b/e2e/tests/raw/utils/_helpers.bash @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RAW_BASE_PATH="/services/haproxy/configuration/raw" + +# Identical to resource_post() but with the text/plain content type. +function resource_post_text() { + local endpoint="$1" data="@${BATS_TEST_DIRNAME}/$2" qs_params="$3" + resource_get "/services/haproxy/configuration/version" + version=${BODY} + run curl -m 10 -s -H 'content-type: text/plain' --user dataplaneapi:mypassword \ + "-XPOST" -w "\n%{http_code}" "-d${data}" \ + "http://${LOCAL_IP_ADDRESS}:${E2E_PORT}${BASE_PATH}${endpoint}?$qs_params&version=$version" + assert_success + dpa_curl_status_body '$output' +} diff --git a/e2e/tests/rings/data/post-ring2.json b/e2e/tests/rings/data/post-ring2.json new file mode 100644 index 00000000..a6f9248c --- /dev/null +++ b/e2e/tests/rings/data/post-ring2.json @@ -0,0 +1,9 @@ +{ + "description": "My Second local buffer", + "format": "rfc3164", + "maxlen": 1200, + "name": "test_ring_2", + "size": 32764, + "timeout_connect": 5, + "timeout_server": 10 +} diff --git a/e2e/tests/rings/data/post.json b/e2e/tests/rings/data/post.json new file mode 100644 index 00000000..baa4efc2 --- /dev/null +++ b/e2e/tests/rings/data/post.json @@ -0,0 +1,9 @@ +{ + "description": "My local buffer", + "format": "rfc3164", + "maxlen": 1200, + "name": "test_ring", + "size": 32764, + "timeout_connect": 5, + "timeout_server": 10 +} diff --git a/e2e/tests/rings/data/put.json b/e2e/tests/rings/data/put.json new file mode 100644 index 00000000..84318520 --- /dev/null +++ b/e2e/tests/rings/data/put.json @@ -0,0 +1,9 @@ +{ + "description": "My local buffer update", + "format": "iso", + "maxlen": 1400, + "name": "test_ring", + "size": 32740, + "timeout_connect": 15, + "timeout_server": 20 +} diff --git a/e2e/tests/rings/test.bats b/e2e/tests/rings/test.bats new file mode 100644 index 00000000..9830466f --- /dev/null +++ b/e2e/tests/rings/test.bats @@ -0,0 +1,70 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "rings: Add a ring" { + if haproxy_version_ge "2.2" + then + resource_post "$_RING_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" "201" + + resource_post "$_RING_BASE_PATH" "data/post-ring2.json" "force_reload=true" + assert_equal "$SC" "201" + fi +} + +@test "rings: Return a ring" { + if haproxy_version_ge "2.2" + then + resource_get "$_RING_BASE_PATH/test_ring" + assert_equal "$SC" 200 + assert_equal "test_ring" "$(get_json_path "$BODY" '.name')" + fi +} + +@test "rings: Replace a ring" { + if haproxy_version_ge "2.2" + then + resource_put "$_RING_BASE_PATH/test_ring" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + fi +} + +@test "rings: Return an array of rings" { + if haproxy_version_ge "2.2" + then + resource_get "$_RING_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".[] | select(.name | contains(\"test_ring_2\") ).name")" "test_ring_2" + fi +} + +@test "rings: Delete a ring" { + if haproxy_version_ge "2.2" + then + resource_delete "$_RING_BASE_PATH/test_ring" "force_reload=true" + assert_equal "$SC" 204 + fi +} diff --git a/e2e/tests/rings/utils/_helpers.bash b/e2e/tests/rings/utils/_helpers.bash new file mode 100644 index 00000000..65f92e5a --- /dev/null +++ b/e2e/tests/rings/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RING_BASE_PATH="/services/haproxy/configuration/rings" diff --git a/e2e/tests/runtime_acme/custom_dataplane_launch.sh b/e2e/tests/runtime_acme/custom_dataplane_launch.sh new file mode 100755 index 00000000..cd8c8cf6 --- /dev/null +++ b/e2e/tests/runtime_acme/custom_dataplane_launch.sh @@ -0,0 +1,2 @@ +#!/bin/sh +docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 DPAPI_ACME_PROPAGTIMEOUT_SEC=-1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" diff --git a/e2e/tests/runtime_acme/data/container/var/lib/haproxy/dns01.sh b/e2e/tests/runtime_acme/data/container/var/lib/haproxy/dns01.sh new file mode 100755 index 00000000..f18b7fb3 --- /dev/null +++ b/e2e/tests/runtime_acme/data/container/var/lib/haproxy/dns01.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -eu + +case "$ACTION" in +append|set) + printf '{"host":"%s","value":"%s"}' "$REC_NAME" "$REC_DATA" | + curl -v -fsS -d @- "http://challtestsrv:8055/set-txt" + break;; +get|delete) + # not implemented + break;; +*) + echo "$0: error: invalid ACTION '$ACTION'" >&2 + exit 1;; +esac diff --git a/e2e/tests/runtime_acme/data/container/var/lib/haproxy/haproxy.pem b/e2e/tests/runtime_acme/data/container/var/lib/haproxy/haproxy.pem new file mode 100644 index 00000000..95455ae6 --- /dev/null +++ b/e2e/tests/runtime_acme/data/container/var/lib/haproxy/haproxy.pem @@ -0,0 +1,86 @@ +-----BEGIN PRIVATE KEY----- +MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCo55THv+XIARRP +Avj1tO3I6gI96/wCx4uOXwZlmQ+wG42M6a2IF4U1eXFfyvIoqqwGoEeFhP71+3tA +bJ5We18oRkEG6CcR35J2UiRxgt3zkvnGBxkoMpWpGP0L/w+WZkw86CAbR9eRf/zB +LOUfKqAXzatXfqdvlfQxF1OjeU6CemcBpPNxHkML73FBRgVezkhj2q0Rdo5sn9TF +b7/nO6biXrV1s4Rkv5Jf70zCKQKIHGNttM0RR13AcDEuY2pqawxVuDTECqlGNMKg +XOc2XKu9OQ1aLytyCKNxwPGC+Ugf9Tu9TD/U0eviUtMCDqn/c4wTa7vVyR7wA4+R +NFPHFwTTxCVkTuAiaU2zaTLGM/sNt8oFu/FXSeTVnnivAwDRtBIRwolw1ZQezDVb +uYKPfSScJ3LvkuBFPfR0Sbhvp5eJ0Ls5yQvXcYurs1BK1SVrS+UFadn5zOwlOOYW +6Q6vw4uVSD5m71eSBEkSy74l1kEiIPzkST6KPlEOOj3g/00YCaRNld/O84hL1O7q +8gS7yyd5viveGd0bDEMjKLnXgEJO6dsCx+mRq1oSNqNvdVFJLMAFHoHRTd/c10uE +Pse2aas1prAy27ocpBpKFo1r8/xivf8iTbl4ymlnWTM5T0mxW0eOqESQrhEO8Slf +nIAxePOOJBbjKDucMLzke4LsHv+FPQIDAQABAoICABFvsrq6MzDl96A+eM/4qRF0 +It4clev9iIkegy0K04VFGuRAnVLuxqgiDNOsQjpzgAXBFxEQDTf8iZk5fVEFNGoW +cpERdzMPpvGDAlMbhOkns5Q/WFf/fNazhy/tWUEX92fUOLhIPtc85K1WgqKohlVe +vIDwSL2qt8Y3l8FI/RNYKnkPe7giPR6mzcTEwzopxmxUf0hNul85UsA9DI0E6fH1 +f/sSGKlD44r2y7BBhorhj1wcbY0KloGOs20MA0jQGzpgJUZVqWrfeHYQkSfaAjqr +AJdeRjhj7ueH2QbB0DHIYa3liLNiJl07WqAcPm1qErxQg1gLBqAVZgVB5yIm3K8K +x/pDmXuhfstSlxU3ofBqbgp1tyE1zgOrlGToLr5PjpoY1q+H672Lq47/aL2ZNmKt +QuEiNDJs4eQj5oOERZG2ySPOnzK9B01IHYKYuh111noFl1j63JN958X5tqQYH4wW +f6b5oF/4M5aM/TFBxcBrnCWOFBLZln4BJhdouH6w+HqaOMIMFTKVLJGzJ7EOMoKP +XL61Pz/SrOa+UVn+ufTJ9/YICQeRyEjV2zf1DVYQhIqrgj+DQqMCMAM/USJp0Up7 +RF/x8Y14HqvlqtXdnlY5aVt/fFxkAnQkUDCYHcGxk9rl9nD4w80MeRI0smjLyrft +XdZ216HKVcYeCG3e0+zhAoIBAQDe2FIIzUTOs4WJlXlWuKQ2K83knx1UKhQp7qbr +hWCGD2YdHOaVcNOCYSbIaJTplKvca+1i42wT0/EeGo94nlM1QGbdSoyRFXpaFcXa +XXrN32xPXljRcvzaFmzg7yfhL382d40mcuyaz6cCvczQZJm/MOoYxV5rANBFZo5W +fhhroXNMUQ3QxfFzb/vwsakieB2JEro4p2+rxdnH38+h1r6F9XoSrWoVaGedMJhm +TrQwbRk8iapxfaCTaKHB2R4GuWkU9M8NnFSOyvrC0pWLy7zYV8o/jFTf54y1lhRP +/Memo788/Z+pt62zGUxmCn/ThiErWsGpkt6OoSIkZlmo9nVxAoIBAQDCCMoEZQsW +VrgVvyxov0Kc3SE0IxAX7XEoQNUeoMob6GKtBNjba0Pk7V0IklNZO+b/f5/cDFan +m7JOiUte5LSA2LykirIwDfjqLcwqL3DmnIFlDLhNWtXTQDO1pgl0OU3cglzxdld6 +yJIc+dSDDTSS4/Es1f45KcZvvRkms+Ph7P9043wavzmd+c0+iIM3IKjRP5T7HLFq +QyZoIdGHbhlBwZ/w9irY1Hzw997JVlpqlTVTi9sMz+H85kE+UBkFqd/r9vDDLlIO +iALSmGca7xkNANFatgvuVbpfCXZW8Pijr6eeiUHB+BpNg/gg9nq3GQR0/P5MMnhG +iRjKdk+gqzaNAoIBAE2sQrO0sIYHhsUU5401oG8NR5+nYjai0BJpj57KB4HSvjnp +h+mQwPhR2o3B/h2IZ3rV15E/Sb2DgyiGA3n8XW5TO0doo6QyQ0pBCox5RsOZW4wy +i2y90qpFZL/mPBU+U+3tL7K2Hgg71q+a7le4qOo+J2po6OcNCosWGwjEvMhPJvvz +yIf7ZpRg9QTJN/W+vjS35Va37bGGrckAFsQHMLNKg7kc3rwFfxAIDyahyiaS8Ffs +eA9ExYJ71t3VSqT3XUwjpEPPOJ3o3AyqD9wBMJqLxv/tbuv4LlBgtkXHCuPncVHV +6R/j2NRzPfDXOgTFXKxa3uO3QIGgYmEjl57QANECggEBAJLVyeMXgBNwnrA+UuIV +0tgYc3ccDaK92gMnROB/t1L1Qi9C2sT5YJDOm7fP2+lMbpvtPdFtOOpv5biPJ41x +L7PN0LwIBZ5eBH9bFwTZj+vEhhstTA+l7OiHzlnpg4ADmYuEz8ce0kaloATzfsGJ +7b43ZxyR+GfT2EpY5L6oJYykKBGR0SoAih6lmo93CS1ftsFbB2gcp5oNpPPqm8CM +LerYFyxnbbdW3hIQ0fS1N4kuzwMhdCw26QLUUI1SWg0yJ7VO05Yw6IH8pX4vPN9i +DygK9WNbHp5HG9mttHNIujBMzmEn565dDbKZat2vCOCkuv25MswA6YofV7ZnYAzr +ZEUCggEAEASYgAZW7FXo13wO/B3GPn4VSo9AwbbFXUYxV2MguID8HKI92uc5xKpF +o+3f7NJiLR7xp6kt8JMzcErFI27tkIE5qerj4j/YOwiAtmSdsYDGZgCORKWGvk3Q +Uvmic0ChydNaTRo+Nb46NAGx/28JZ1X/OHsnw2mazsjCbkTGavsHyuAHSZ8FjaO/ +zzS+X5FG/5xWmd6bBNjqIsy5dzrDY7dtgDbylwscO0ZjZ2jPHUZqcN/0wCecwmcI +s5ylOwxZTUJvoaUfxJJChhx3Aa09Og4VB6Tu5xuwPSCQSCs7BYYVsZOOXyLAxUJQ +Z9dGRClyR8L6zGyIx9IfiHIVbaY2yg== +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIF2zCCA8OgAwIBAgIURRBDOMWHU/lCFak3Tp/efWcNBDQwDQYJKoZIhvcNAQEL +BQAwfTELMAkGA1UEBhMCWFgxEjAQBgNVBAgMCVN0YXRlTmFtZTERMA8GA1UEBwwI +Q2l0eU5hbWUxFDASBgNVBAoMC0NvbXBhbnlOYW1lMRswGQYDVQQLDBJDb21wYW55 +U2VjdGlvbk5hbWUxFDASBgNVBAMMC2hhcHJveHkub3JnMB4XDTI1MDYyNjA5MzMx +MVoXDTQ0MDgyNTA5MzMxMVowfTELMAkGA1UEBhMCWFgxEjAQBgNVBAgMCVN0YXRl +TmFtZTERMA8GA1UEBwwIQ2l0eU5hbWUxFDASBgNVBAoMC0NvbXBhbnlOYW1lMRsw +GQYDVQQLDBJDb21wYW55U2VjdGlvbk5hbWUxFDASBgNVBAMMC2hhcHJveHkub3Jn +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqOeUx7/lyAEUTwL49bTt +yOoCPev8AseLjl8GZZkPsBuNjOmtiBeFNXlxX8ryKKqsBqBHhYT+9ft7QGyeVntf +KEZBBugnEd+SdlIkcYLd85L5xgcZKDKVqRj9C/8PlmZMPOggG0fXkX/8wSzlHyqg +F82rV36nb5X0MRdTo3lOgnpnAaTzcR5DC+9xQUYFXs5IY9qtEXaObJ/UxW+/5zum +4l61dbOEZL+SX+9MwikCiBxjbbTNEUddwHAxLmNqamsMVbg0xAqpRjTCoFznNlyr +vTkNWi8rcgijccDxgvlIH/U7vUw/1NHr4lLTAg6p/3OME2u71cke8AOPkTRTxxcE +08QlZE7gImlNs2kyxjP7DbfKBbvxV0nk1Z54rwMA0bQSEcKJcNWUHsw1W7mCj30k +nCdy75LgRT30dEm4b6eXidC7OckL13GLq7NQStUla0vlBWnZ+czsJTjmFukOr8OL +lUg+Zu9XkgRJEsu+JdZBIiD85Ek+ij5RDjo94P9NGAmkTZXfzvOIS9Tu6vIEu8sn +eb4r3hndGwxDIyi514BCTunbAsfpkataEjajb3VRSSzABR6B0U3f3NdLhD7Htmmr +NaawMtu6HKQaShaNa/P8Yr3/Ik25eMppZ1kzOU9JsVtHjqhEkK4RDvEpX5yAMXjz +jiQW4yg7nDC85HuC7B7/hT0CAwEAAaNTMFEwHQYDVR0OBBYEFM/sK4V6m+TDCTtj +vESjXas889RLMB8GA1UdIwQYMBaAFM/sK4V6m+TDCTtjvESjXas889RLMA8GA1Ud +EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggIBAKHnZkv9bd8O9+90ymOA4vLQ +iuPrcOgMXD9ibC7BgempOCLzFbKL3FMGulJZJy4JLzKhaHVICSITswN81Rsd8NIM +hpGg0Ih/jg25rzNPLKpDe7MSTS73ufTyRtseusQrvIYihAsZrPGl2XR1InuooQ08 +zXqO9mFQbfs7mgFWYbPxqgk/2hm6GG/a0M9asC2oH45mWygOELS05EMh+at97EUD +s7KtM/uJ7+09TjcUD0zcf0c777YL5B050CbedZciObH03AU2P7Qc5LEZck8TEMrw +0i655wWMTuI7wGbVDz1qdBUzc/Q75WKQiRPLVyLixsJmWA+cpZYbWCV0l2hmp2wJ +7l8dV5UwrEwHWwGQbrOzuSjYyzfNXRbNIbnL1UySCMtHFBtOy/RHb2VbAiEZnrMe +xmmNQx+3t7a0OW97iPKRh6K95KdsLaUlyoBCY7Ku3pXd9osj1JjsrDfglWx2PDcc +ENUrBSbJHdf+cK9USNhl8L0FH6U3OSb+iSshznCRfH9i5siKwns0n9nePM6WQXQz +gR0E1E1yeNd/E/lET08RnTwWtlPjZyo7GAkjgOOEAnk1QZqM3/L34ZAXS0+/am+x +lCz4wr3hRdeG/4dfZluPud8fi6Y2ardGUwhlBhlNZKt1d01p8OrAhuuvVRulUKMi +fUlFmL0ypMsujAx1WJxz +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_acme/data/container/var/lib/haproxy/haproxy2.pem b/e2e/tests/runtime_acme/data/container/var/lib/haproxy/haproxy2.pem new file mode 100644 index 00000000..95455ae6 --- /dev/null +++ b/e2e/tests/runtime_acme/data/container/var/lib/haproxy/haproxy2.pem @@ -0,0 +1,86 @@ +-----BEGIN PRIVATE KEY----- +MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCo55THv+XIARRP +Avj1tO3I6gI96/wCx4uOXwZlmQ+wG42M6a2IF4U1eXFfyvIoqqwGoEeFhP71+3tA +bJ5We18oRkEG6CcR35J2UiRxgt3zkvnGBxkoMpWpGP0L/w+WZkw86CAbR9eRf/zB +LOUfKqAXzatXfqdvlfQxF1OjeU6CemcBpPNxHkML73FBRgVezkhj2q0Rdo5sn9TF +b7/nO6biXrV1s4Rkv5Jf70zCKQKIHGNttM0RR13AcDEuY2pqawxVuDTECqlGNMKg +XOc2XKu9OQ1aLytyCKNxwPGC+Ugf9Tu9TD/U0eviUtMCDqn/c4wTa7vVyR7wA4+R +NFPHFwTTxCVkTuAiaU2zaTLGM/sNt8oFu/FXSeTVnnivAwDRtBIRwolw1ZQezDVb +uYKPfSScJ3LvkuBFPfR0Sbhvp5eJ0Ls5yQvXcYurs1BK1SVrS+UFadn5zOwlOOYW +6Q6vw4uVSD5m71eSBEkSy74l1kEiIPzkST6KPlEOOj3g/00YCaRNld/O84hL1O7q +8gS7yyd5viveGd0bDEMjKLnXgEJO6dsCx+mRq1oSNqNvdVFJLMAFHoHRTd/c10uE +Pse2aas1prAy27ocpBpKFo1r8/xivf8iTbl4ymlnWTM5T0mxW0eOqESQrhEO8Slf +nIAxePOOJBbjKDucMLzke4LsHv+FPQIDAQABAoICABFvsrq6MzDl96A+eM/4qRF0 +It4clev9iIkegy0K04VFGuRAnVLuxqgiDNOsQjpzgAXBFxEQDTf8iZk5fVEFNGoW +cpERdzMPpvGDAlMbhOkns5Q/WFf/fNazhy/tWUEX92fUOLhIPtc85K1WgqKohlVe +vIDwSL2qt8Y3l8FI/RNYKnkPe7giPR6mzcTEwzopxmxUf0hNul85UsA9DI0E6fH1 +f/sSGKlD44r2y7BBhorhj1wcbY0KloGOs20MA0jQGzpgJUZVqWrfeHYQkSfaAjqr +AJdeRjhj7ueH2QbB0DHIYa3liLNiJl07WqAcPm1qErxQg1gLBqAVZgVB5yIm3K8K +x/pDmXuhfstSlxU3ofBqbgp1tyE1zgOrlGToLr5PjpoY1q+H672Lq47/aL2ZNmKt +QuEiNDJs4eQj5oOERZG2ySPOnzK9B01IHYKYuh111noFl1j63JN958X5tqQYH4wW +f6b5oF/4M5aM/TFBxcBrnCWOFBLZln4BJhdouH6w+HqaOMIMFTKVLJGzJ7EOMoKP +XL61Pz/SrOa+UVn+ufTJ9/YICQeRyEjV2zf1DVYQhIqrgj+DQqMCMAM/USJp0Up7 +RF/x8Y14HqvlqtXdnlY5aVt/fFxkAnQkUDCYHcGxk9rl9nD4w80MeRI0smjLyrft +XdZ216HKVcYeCG3e0+zhAoIBAQDe2FIIzUTOs4WJlXlWuKQ2K83knx1UKhQp7qbr +hWCGD2YdHOaVcNOCYSbIaJTplKvca+1i42wT0/EeGo94nlM1QGbdSoyRFXpaFcXa +XXrN32xPXljRcvzaFmzg7yfhL382d40mcuyaz6cCvczQZJm/MOoYxV5rANBFZo5W +fhhroXNMUQ3QxfFzb/vwsakieB2JEro4p2+rxdnH38+h1r6F9XoSrWoVaGedMJhm +TrQwbRk8iapxfaCTaKHB2R4GuWkU9M8NnFSOyvrC0pWLy7zYV8o/jFTf54y1lhRP +/Memo788/Z+pt62zGUxmCn/ThiErWsGpkt6OoSIkZlmo9nVxAoIBAQDCCMoEZQsW +VrgVvyxov0Kc3SE0IxAX7XEoQNUeoMob6GKtBNjba0Pk7V0IklNZO+b/f5/cDFan +m7JOiUte5LSA2LykirIwDfjqLcwqL3DmnIFlDLhNWtXTQDO1pgl0OU3cglzxdld6 +yJIc+dSDDTSS4/Es1f45KcZvvRkms+Ph7P9043wavzmd+c0+iIM3IKjRP5T7HLFq +QyZoIdGHbhlBwZ/w9irY1Hzw997JVlpqlTVTi9sMz+H85kE+UBkFqd/r9vDDLlIO +iALSmGca7xkNANFatgvuVbpfCXZW8Pijr6eeiUHB+BpNg/gg9nq3GQR0/P5MMnhG +iRjKdk+gqzaNAoIBAE2sQrO0sIYHhsUU5401oG8NR5+nYjai0BJpj57KB4HSvjnp +h+mQwPhR2o3B/h2IZ3rV15E/Sb2DgyiGA3n8XW5TO0doo6QyQ0pBCox5RsOZW4wy +i2y90qpFZL/mPBU+U+3tL7K2Hgg71q+a7le4qOo+J2po6OcNCosWGwjEvMhPJvvz +yIf7ZpRg9QTJN/W+vjS35Va37bGGrckAFsQHMLNKg7kc3rwFfxAIDyahyiaS8Ffs +eA9ExYJ71t3VSqT3XUwjpEPPOJ3o3AyqD9wBMJqLxv/tbuv4LlBgtkXHCuPncVHV +6R/j2NRzPfDXOgTFXKxa3uO3QIGgYmEjl57QANECggEBAJLVyeMXgBNwnrA+UuIV +0tgYc3ccDaK92gMnROB/t1L1Qi9C2sT5YJDOm7fP2+lMbpvtPdFtOOpv5biPJ41x +L7PN0LwIBZ5eBH9bFwTZj+vEhhstTA+l7OiHzlnpg4ADmYuEz8ce0kaloATzfsGJ +7b43ZxyR+GfT2EpY5L6oJYykKBGR0SoAih6lmo93CS1ftsFbB2gcp5oNpPPqm8CM +LerYFyxnbbdW3hIQ0fS1N4kuzwMhdCw26QLUUI1SWg0yJ7VO05Yw6IH8pX4vPN9i +DygK9WNbHp5HG9mttHNIujBMzmEn565dDbKZat2vCOCkuv25MswA6YofV7ZnYAzr +ZEUCggEAEASYgAZW7FXo13wO/B3GPn4VSo9AwbbFXUYxV2MguID8HKI92uc5xKpF +o+3f7NJiLR7xp6kt8JMzcErFI27tkIE5qerj4j/YOwiAtmSdsYDGZgCORKWGvk3Q +Uvmic0ChydNaTRo+Nb46NAGx/28JZ1X/OHsnw2mazsjCbkTGavsHyuAHSZ8FjaO/ +zzS+X5FG/5xWmd6bBNjqIsy5dzrDY7dtgDbylwscO0ZjZ2jPHUZqcN/0wCecwmcI +s5ylOwxZTUJvoaUfxJJChhx3Aa09Og4VB6Tu5xuwPSCQSCs7BYYVsZOOXyLAxUJQ +Z9dGRClyR8L6zGyIx9IfiHIVbaY2yg== +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIF2zCCA8OgAwIBAgIURRBDOMWHU/lCFak3Tp/efWcNBDQwDQYJKoZIhvcNAQEL +BQAwfTELMAkGA1UEBhMCWFgxEjAQBgNVBAgMCVN0YXRlTmFtZTERMA8GA1UEBwwI +Q2l0eU5hbWUxFDASBgNVBAoMC0NvbXBhbnlOYW1lMRswGQYDVQQLDBJDb21wYW55 +U2VjdGlvbk5hbWUxFDASBgNVBAMMC2hhcHJveHkub3JnMB4XDTI1MDYyNjA5MzMx +MVoXDTQ0MDgyNTA5MzMxMVowfTELMAkGA1UEBhMCWFgxEjAQBgNVBAgMCVN0YXRl +TmFtZTERMA8GA1UEBwwIQ2l0eU5hbWUxFDASBgNVBAoMC0NvbXBhbnlOYW1lMRsw +GQYDVQQLDBJDb21wYW55U2VjdGlvbk5hbWUxFDASBgNVBAMMC2hhcHJveHkub3Jn +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqOeUx7/lyAEUTwL49bTt +yOoCPev8AseLjl8GZZkPsBuNjOmtiBeFNXlxX8ryKKqsBqBHhYT+9ft7QGyeVntf +KEZBBugnEd+SdlIkcYLd85L5xgcZKDKVqRj9C/8PlmZMPOggG0fXkX/8wSzlHyqg +F82rV36nb5X0MRdTo3lOgnpnAaTzcR5DC+9xQUYFXs5IY9qtEXaObJ/UxW+/5zum +4l61dbOEZL+SX+9MwikCiBxjbbTNEUddwHAxLmNqamsMVbg0xAqpRjTCoFznNlyr +vTkNWi8rcgijccDxgvlIH/U7vUw/1NHr4lLTAg6p/3OME2u71cke8AOPkTRTxxcE +08QlZE7gImlNs2kyxjP7DbfKBbvxV0nk1Z54rwMA0bQSEcKJcNWUHsw1W7mCj30k +nCdy75LgRT30dEm4b6eXidC7OckL13GLq7NQStUla0vlBWnZ+czsJTjmFukOr8OL +lUg+Zu9XkgRJEsu+JdZBIiD85Ek+ij5RDjo94P9NGAmkTZXfzvOIS9Tu6vIEu8sn +eb4r3hndGwxDIyi514BCTunbAsfpkataEjajb3VRSSzABR6B0U3f3NdLhD7Htmmr +NaawMtu6HKQaShaNa/P8Yr3/Ik25eMppZ1kzOU9JsVtHjqhEkK4RDvEpX5yAMXjz +jiQW4yg7nDC85HuC7B7/hT0CAwEAAaNTMFEwHQYDVR0OBBYEFM/sK4V6m+TDCTtj +vESjXas889RLMB8GA1UdIwQYMBaAFM/sK4V6m+TDCTtjvESjXas889RLMA8GA1Ud +EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggIBAKHnZkv9bd8O9+90ymOA4vLQ +iuPrcOgMXD9ibC7BgempOCLzFbKL3FMGulJZJy4JLzKhaHVICSITswN81Rsd8NIM +hpGg0Ih/jg25rzNPLKpDe7MSTS73ufTyRtseusQrvIYihAsZrPGl2XR1InuooQ08 +zXqO9mFQbfs7mgFWYbPxqgk/2hm6GG/a0M9asC2oH45mWygOELS05EMh+at97EUD +s7KtM/uJ7+09TjcUD0zcf0c777YL5B050CbedZciObH03AU2P7Qc5LEZck8TEMrw +0i655wWMTuI7wGbVDz1qdBUzc/Q75WKQiRPLVyLixsJmWA+cpZYbWCV0l2hmp2wJ +7l8dV5UwrEwHWwGQbrOzuSjYyzfNXRbNIbnL1UySCMtHFBtOy/RHb2VbAiEZnrMe +xmmNQx+3t7a0OW97iPKRh6K95KdsLaUlyoBCY7Ku3pXd9osj1JjsrDfglWx2PDcc +ENUrBSbJHdf+cK9USNhl8L0FH6U3OSb+iSshznCRfH9i5siKwns0n9nePM6WQXQz +gR0E1E1yeNd/E/lET08RnTwWtlPjZyo7GAkjgOOEAnk1QZqM3/L34ZAXS0+/am+x +lCz4wr3hRdeG/4dfZluPud8fi6Y2ardGUwhlBhlNZKt1d01p8OrAhuuvVRulUKMi +fUlFmL0ypMsujAx1WJxz +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_acme/data/haproxy.cfg b/e2e/tests/runtime_acme/data/haproxy.cfg new file mode 100644 index 00000000..5cd325ab --- /dev/null +++ b/e2e/tests/runtime_acme/data/haproxy.cfg @@ -0,0 +1,68 @@ +# _version=42 + +global + log stderr local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + + expose-experimental-directives + httpclient.resolvers.prefer ipv4 + httpclient.resolvers.id docker + httpclient.ssl.ca-file /var/lib/haproxy/pebble.minica.pem + #httpclient.ssl.verify none + #nbthread 2 + warn-blocked-traffic-after 1000ms + +resolvers docker + nameserver dns 127.0.0.11:53 + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +acme pebble + directory https://pebble:14000/dir + account-key /var/lib/haproxy/acme.account.key + contact john.doe@example.com + challenge HTTP-01 + keytype RSA + bits 4096 + map virt@acme + +acme dnschall + directory https://pebble:14000/dir + account-key /var/lib/haproxy/acme.account.key + contact john.doe@example.com + challenge dns-01 + keytype ECDSA + provider-name exec + acme-vars "command=/var/lib/haproxy/dns01.sh" + +frontend web + bind *:1080 + bind *:1443 ssl + http-request return status 200 content-type text/plain lf-string "%[path,field(-1,/)].%[path,field(-1,/),map(virt@acme)]\n" if { path_beg '/.well-known/acme-challenge/' } + ssl-f-use crt "/var/lib/haproxy/haproxy.pem" acme pebble domains "dataplaneapi-e2e" + +frontend web2 + bind *:1444 ssl + http-request return status 200 + ssl-f-use crt "/var/lib/haproxy/haproxy2.pem" acme dnschall domains "dns01.test" diff --git a/e2e/tests/runtime_acme/dataplaneapi.yaml b/e2e/tests/runtime_acme/dataplaneapi.yaml new file mode 100644 index 00000000..47188505 --- /dev/null +++ b/e2e/tests/runtime_acme/dataplaneapi.yaml @@ -0,0 +1,25 @@ +# This file is just here to force dpapi to run in master-worker mode. +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + master_runtime: /var/lib/haproxy/master + master_worker_mode: true + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug diff --git a/e2e/tests/runtime_acme/tests.bats b/e2e/tests/runtime_acme/tests.bats new file mode 100644 index 00000000..6e3b1d43 --- /dev/null +++ b/e2e/tests/runtime_acme/tests.bats @@ -0,0 +1,83 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' +if haproxy_version_ge "3.3"; then + load '../../libs/haproxy_config_setup' + load '../../libs/acme' +fi + +_RUNTIME_ACME_PATH="/services/haproxy/runtime/acme" + +@test "acme_runtime: Renew a certificate" { + haproxy_version_ge "3.3" || skip + + cert_name="/var/lib/haproxy/haproxy.pem" + + # Send an 'acme renew' message to HAProxy. + run dpa_curl PUT "$_RUNTIME_ACME_PATH?certificate=$cert_name" + assert_success + dpa_curl_status_body '$output' + assert_equal "$SC" 200 + + # Wait until the status of our certificate is in state "Scheduled", + # meaning it was renewed successfully. + state=unknown trials=10 + while [ "$state" != "Scheduled" ] && (( trials > 0 )); do + sleep 2 + resource_get "$_RUNTIME_ACME_PATH" + state="$(jq -r .[0].state <<< "$BODY")" + : $((trials--)) + done + assert_equal "$state" "Scheduled" + + # HAProxy will then send an event to dpapi to store the cert to disk. + timeout=8 elapsed=0 inc=1 found=false + while ((elapsed < timeout)); do + sleep $inc && elapsed=$((elapsed + inc)) + if dpa_docker_exec 'ls -l /etc/haproxy/ssl/haproxy.pem'; then + found=true + break + fi + done + assert_equal "$found" true +} + +@test "acme_runtime: dns-01 challenge" { + haproxy_version_ge "3.3" || skip + + cert_name="/var/lib/haproxy/haproxy2.pem" + + run dpa_curl PUT "$_RUNTIME_ACME_PATH?certificate=$cert_name" + assert_success + dpa_curl_status_body '$output' + assert_equal "$SC" 200 + + timeout=20 elapsed=0 inc=2 found=false + while ((elapsed < timeout)); do + sleep $inc && elapsed=$((elapsed + inc)) + if dpa_docker_exec 'ls -l /etc/haproxy/ssl/haproxy2.pem'; then + found=true + break + fi + done + [ -n "$CI" ] || assert_equal "$found" true +} diff --git a/e2e/tests/runtime_maps_entries/add_one_entry.bats b/e2e/tests/runtime_maps_entries/add_one_entry.bats new file mode 100644 index 00000000..2fc24478 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/add_one_entry.bats @@ -0,0 +1,41 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "runtime_maps_entries: Adds an entry into the map file" { + PARENT_NAME="mapfile1.map" + resource_post "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries" "data/post.json" + assert_equal "$SC" 201 + # + # verify that entry is actually added + # + resource_get "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/newkey" + assert_equal "$SC" 200 +} + +@test "runtime_maps_entries: Refuse adding an existing map entry into the map file" { + PARENT_NAME="mapfile1.map" + resource_post "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries" "data/existing.json" + assert_equal "$SC" 409 +} diff --git a/e2e/tests/runtime_maps_entries/custom_dataplane_launch.sh b/e2e/tests/runtime_maps_entries/custom_dataplane_launch.sh new file mode 100755 index 00000000..b9f4706d --- /dev/null +++ b/e2e/tests/runtime_maps_entries/custom_dataplane_launch.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml --maps-dir=/tmp/maps" diff --git a/e2e/tests/runtime_maps_entries/data/container/tmp/maps/empty.map b/e2e/tests/runtime_maps_entries/data/container/tmp/maps/empty.map new file mode 100644 index 00000000..16c8958c --- /dev/null +++ b/e2e/tests/runtime_maps_entries/data/container/tmp/maps/empty.map @@ -0,0 +1 @@ +# this is an empty map file diff --git a/e2e/tests/runtime_maps_entries/data/container/tmp/maps/mapfile1.map b/e2e/tests/runtime_maps_entries/data/container/tmp/maps/mapfile1.map new file mode 100644 index 00000000..bd3d6087 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/data/container/tmp/maps/mapfile1.map @@ -0,0 +1,2 @@ +key1 value1 +api.example.com be_api diff --git a/e2e/tests/runtime_maps_entries/data/container/tmp/maps/mapfile2.map b/e2e/tests/runtime_maps_entries/data/container/tmp/maps/mapfile2.map new file mode 100644 index 00000000..60677112 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/data/container/tmp/maps/mapfile2.map @@ -0,0 +1,2 @@ +key1 val1 +key2 val2 diff --git a/e2e/tests/runtime_maps_entries/data/existing.json b/e2e/tests/runtime_maps_entries/data/existing.json new file mode 100644 index 00000000..2f2877b6 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/data/existing.json @@ -0,0 +1,4 @@ +{ + "key": "key1", + "value": "value1" + } diff --git a/e2e/tests/runtime_maps_entries/data/haproxy.cfg b/e2e/tests/runtime_maps_entries/data/haproxy.cfg new file mode 100644 index 00000000..6811d222 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/data/haproxy.cfg @@ -0,0 +1,31 @@ +# _version=60 +defaults mydefaults + mode http + log global + option httplog + option dontlognull + timeout connect 5000 + timeout client 50000 + timeout server 50000 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +frontend fe_map + bind *:1234 + use_backend %[str(example.com),map(/tmp/maps/mapfile1.map)] + mode http + +frontend fe_map2 + bind *:2358 + use_backend %[str(example.com),map(/tmp/maps/mapfile2.map)] + +frontend fe_map_empty + bind *:5678 + use_backend %[str(example.com),map(/tmp/maps/empty.map)] diff --git a/e2e/tests/runtime_maps_entries/data/post.json b/e2e/tests/runtime_maps_entries/data/post.json new file mode 100644 index 00000000..6564e4b6 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/data/post.json @@ -0,0 +1,4 @@ +{ + "key": "newkey", + "value": "newvalue" + } diff --git a/e2e/tests/runtime_maps_entries/data/put.json b/e2e/tests/runtime_maps_entries/data/put.json new file mode 100644 index 00000000..de7b7ea0 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/data/put.json @@ -0,0 +1,4 @@ +{ + "key": "key1", + "value": "replacedvalue" + } diff --git a/e2e/tests/runtime_maps_entries/delete_one_entry.bats b/e2e/tests/runtime_maps_entries/delete_one_entry.bats new file mode 100644 index 00000000..1b9e7ef4 --- /dev/null +++ b/e2e/tests/runtime_maps_entries/delete_one_entry.bats @@ -0,0 +1,47 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "runtime_maps_entries: Deletes all the map entries from the map by its id" { + PARENT_NAME="mapfile1.map" + resource_delete "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/key1" + assert_equal "$SC" 204 + # + # verify that entry is actually deleted + # + resource_get "$_RUNTIME_MAPS_BASE_PATH/$PARENT_NAME/entries/key1" + assert_equal "$SC" 404 +} + +@test "runtime_maps_entries: https://github.com/haproxytech/dataplaneapi/issues/160 with non existing key" { + PARENT_NAME="mapfile1.map" + resource_delete "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/not-exists" + assert_equal "$SC" 404 +} + +@test "runtime_maps_entries: https://github.com/haproxytech/dataplaneapi/issues/160 with non existing map file" { + PARENT_NAME="not-exists.map" + resource_delete "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/key1" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/runtime_maps_entries/get_entries.bats b/e2e/tests/runtime_maps_entries/get_entries.bats new file mode 100644 index 00000000..bdc6ecdc --- /dev/null +++ b/e2e/tests/runtime_maps_entries/get_entries.bats @@ -0,0 +1,49 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "runtime_maps_entries: Return one map runtime entries" { + PARENT_NAME="mapfile1.map" + resource_get "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" " .[] | select(.key | contains(\"key1\") ).key" )" "key1" + assert_equal "$(get_json_path "$BODY" " .[] | select(.value | contains(\"value1\") ).value" )" "value1" + + assert_equal "$(get_json_path "$BODY" " .[] | select(.key | contains(\"api.example.com\") ).key" )" "api.example.com" + assert_equal "$(get_json_path "$BODY" " .[] | select(.value | contains(\"be_api\") ).value" )" "be_api" +} + +@test "runtime_maps_entries: https://github.com/haproxytech/dataplaneapi/issues/159" { + PARENT_NAME="not-exists.map" + resource_get "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries" + assert_equal "$SC" 404 +} + +@test "runtime_maps_entries: https://github.com/haproxytech/dataplaneapi/issues/234" { + PARENT_NAME="empty.map" + resource_get "$_RUNTIME_MAP_BASE_PATH"/"$PARENT_NAME/entries" + assert_equal "$SC" 200 + assert_equal "$($BODY)" "" +} diff --git a/e2e/tests/runtime_maps_entries/get_one_entry.bats b/e2e/tests/runtime_maps_entries/get_one_entry.bats new file mode 100644 index 00000000..d90018ff --- /dev/null +++ b/e2e/tests/runtime_maps_entries/get_one_entry.bats @@ -0,0 +1,40 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + + +@test "runtime_maps_entries: Return one map runtime setting" { + PARENT_NAME="mapfile1.map" + resource_get "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/key1" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" " select(.key | contains(\"key1\") ).key" )" "key1" + assert_equal "$(get_json_path "${BODY}" " select(.value | contains(\"value1\") ).value" )" "value1" +} + +@test "runtime_maps_entries: Return an error when one map runtime setting doesn't exists" { + PARENT_NAME="mapfile1.map" + resource_get "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/not-exists" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/runtime_maps_entries/replace_one_entry.bats b/e2e/tests/runtime_maps_entries/replace_one_entry.bats new file mode 100644 index 00000000..7a122dba --- /dev/null +++ b/e2e/tests/runtime_maps_entries/replace_one_entry.bats @@ -0,0 +1,43 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "runtime_maps_entries: Replace the value corresponding to each id in a map" { + PARENT_NAME="mapfile1.map" + resource_put "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/key1" "data/put.json" "force_sync=true" + assert_equal "$SC" 200 + # + # verify that entry is actually changed + # + resource_get "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/key1" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" " select(.value | contains(\"replacedvalue\") ).value" )" "replacedvalue" +} + +@test "runtime_maps_entries: Return an error when trying to replace non existing map key" { + PARENT_NAME="mapfile1.map" + resource_put "$_RUNTIME_MAP_BASE_PATH/$PARENT_NAME/entries/not-exists" "data/put.json" "force_sync=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/runtime_maps_entries/utils/_helpers.bash b/e2e/tests/runtime_maps_entries/utils/_helpers.bash new file mode 100644 index 00000000..9024434d --- /dev/null +++ b/e2e/tests/runtime_maps_entries/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RUNTIME_MAP_BASE_PATH="/services/haproxy/runtime/maps" diff --git a/e2e/tests/runtime_maps_files/custom_dataplane_launch.sh b/e2e/tests/runtime_maps_files/custom_dataplane_launch.sh new file mode 100755 index 00000000..b9f4706d --- /dev/null +++ b/e2e/tests/runtime_maps_files/custom_dataplane_launch.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml --maps-dir=/tmp/maps" diff --git a/e2e/tests/runtime_maps_files/data/container/tmp/maps/mapfile1.map b/e2e/tests/runtime_maps_files/data/container/tmp/maps/mapfile1.map new file mode 100644 index 00000000..bd3d6087 --- /dev/null +++ b/e2e/tests/runtime_maps_files/data/container/tmp/maps/mapfile1.map @@ -0,0 +1,2 @@ +key1 value1 +api.example.com be_api diff --git a/e2e/tests/runtime_maps_files/data/container/tmp/maps/mapfile2.map b/e2e/tests/runtime_maps_files/data/container/tmp/maps/mapfile2.map new file mode 100644 index 00000000..60677112 --- /dev/null +++ b/e2e/tests/runtime_maps_files/data/container/tmp/maps/mapfile2.map @@ -0,0 +1,2 @@ +key1 val1 +key2 val2 diff --git a/e2e/tests/runtime_maps_files/data/haproxy.cfg b/e2e/tests/runtime_maps_files/data/haproxy.cfg new file mode 100644 index 00000000..11a34dae --- /dev/null +++ b/e2e/tests/runtime_maps_files/data/haproxy.cfg @@ -0,0 +1,27 @@ +# _version=60 +defaults mydefaults + mode http + log global + option httplog + option dontlognull + timeout connect 5000 + timeout client 50000 + timeout server 50000 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +frontend fe_map + bind *:1234 + use_backend %[str(example.com),map(/tmp/maps/mapfile1.map)] + mode http + +frontend fe_map2 + bind *:2358 + use_backend %[str(example.com),map(/tmp/maps/mapfile2.map)] diff --git a/e2e/tests/runtime_maps_files/delete.bats b/e2e/tests/runtime_maps_files/delete.bats new file mode 100644 index 00000000..ff5e49d0 --- /dev/null +++ b/e2e/tests/runtime_maps_files/delete.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "runtime_maps_files: Remove all map entries from the map file" { + resource_delete "$_RUNTIME_MAP_FILES_BASE_PATH/mapfile1.map" "force_delete=true&force_sync=true" + assert_equal "$SC" 204 +} + +@test "runtime_maps_files: Return an error when trying to delete non existing runtime map file" { + resource_delete "$_RUNTIME_MAP_FILES_BASE_PATH/not-exists.map" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/runtime_maps_files/get_files.bats b/e2e/tests/runtime_maps_files/get_files.bats new file mode 100644 index 00000000..c2831cfb --- /dev/null +++ b/e2e/tests/runtime_maps_files/get_files.bats @@ -0,0 +1,32 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "runtime_maps_files: Return runtime map files" { + resource_get "$_RUNTIME_MAP_FILES_BASE_PATH" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" " .[] | select(.file | contains(\"/tmp/maps/mapfile1.map\") ).file" )" "/tmp/maps/mapfile1.map" + assert_equal "$(get_json_path "${BODY}" " .[] | select(.file | contains(\"/tmp/maps/mapfile2.map\") ).file" )" "/tmp/maps/mapfile2.map" +} diff --git a/e2e/tests/runtime_maps_files/get_one_file.bats b/e2e/tests/runtime_maps_files/get_one_file.bats new file mode 100644 index 00000000..4b56b67b --- /dev/null +++ b/e2e/tests/runtime_maps_files/get_one_file.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "runtime_maps_files: Return one runtime map file" { + resource_get "$_RUNTIME_MAP_FILES_BASE_PATH/mapfile1.map" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" " select(.file | contains(\"/tmp/maps/mapfile1.map\") ).file" )" "/tmp/maps/mapfile1.map" +} + +@test "runtime_maps_files: Return an error when one map runtime file doesn't exists" { + resource_get "$_RUNTIME_MAP_FILES_BASE_PATH/not-exists.map" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/runtime_maps_files/utils/_helpers.bash b/e2e/tests/runtime_maps_files/utils/_helpers.bash new file mode 100644 index 00000000..ce3035d2 --- /dev/null +++ b/e2e/tests/runtime_maps_files/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RUNTIME_MAP_FILES_BASE_PATH="/services/haproxy/runtime/maps" diff --git a/e2e/tests/runtime_ssl_ca_files/data/1.pem b/e2e/tests/runtime_ssl_ca_files/data/1.pem new file mode 100644 index 00000000..cbd77a21 --- /dev/null +++ b/e2e/tests/runtime_ssl_ca_files/data/1.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_ca_files/data/2.pem b/e2e/tests/runtime_ssl_ca_files/data/2.pem new file mode 100644 index 00000000..7236b82b --- /dev/null +++ b/e2e/tests/runtime_ssl_ca_files/data/2.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_ca_files/data/3.pem b/e2e/tests/runtime_ssl_ca_files/data/3.pem new file mode 100644 index 00000000..1fbe4790 --- /dev/null +++ b/e2e/tests/runtime_ssl_ca_files/data/3.pem @@ -0,0 +1,79 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_ca_files/data/4.pem b/e2e/tests/runtime_ssl_ca_files/data/4.pem new file mode 100644 index 00000000..fa8fe909 --- /dev/null +++ b/e2e/tests/runtime_ssl_ca_files/data/4.pem @@ -0,0 +1,45 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_ca_files/test.bats b/e2e/tests/runtime_ssl_ca_files/test.bats new file mode 100644 index 00000000..c2826633 --- /dev/null +++ b/e2e/tests/runtime_ssl_ca_files/test.bats @@ -0,0 +1,95 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "ssl_ca_files_runtime: Create and delete an ssl CA file" { + haproxy_version_ge "2.6" || skip + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CA_FILES_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=cafile.pem" + dpa_curl_status_body '$output' + assert_equal $SC 201 + + resource_get "$_RUNTIME_SSL_CA_FILES_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 2 + assert_equal "$(get_json_path "$BODY" '.[1].storage_name')" "cafile.pem" + assert_equal "$(get_json_path "$BODY" '.[1].count')" "3 certificate(s)" + + resource_get "$_RUNTIME_SSL_CA_FILES_BASE_PATH/cafile.pem/entries/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 9 + assert_equal "$(get_json_path "$BODY" '.storage_name')" "cafile.pem" + assert_equal "$(get_json_path "$BODY" '.algorithm')" "RSA2048" + + resource_delete "$_RUNTIME_SSL_CA_FILES_BASE_PATH/cafile.pem" + assert_equal $SC 204 + + resource_get "$_RUNTIME_SSL_CA_FILES_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 1 + # The name can change depending on systems. + #assert_equal "$(get_json_path "$BODY" '.[0].storage_name')" "@system-ca" +} + +@test "ssl_ca_files_runtime: Add a ssl certificate entry to a CA file" { + haproxy_version_ge "2.8" || skip + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CA_FILES_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=cafile.pem" + dpa_curl_status_body '$output' + assert_equal $SC 201 + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CA_FILES_BASE_PATH/cafile.pem/entries" "@${BATS_TEST_DIRNAME}/data/4.pem" + dpa_curl_status_body '$output' + assert_equal $SC 201 + + resource_get "$_RUNTIME_SSL_CA_FILES_BASE_PATH/cafile.pem" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 2 + + resource_get "$_RUNTIME_SSL_CA_FILES_BASE_PATH/cafile.pem/entries/2" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 9 + assert_equal "$(get_json_path "$BODY" '.storage_name')" "cafile.pem" + assert_equal "$(get_json_path "$BODY" '.algorithm')" "RSA2048" +} + +@test "ssl_ca_files_runtime: Replace the contents of a CA file" { + haproxy_version_ge "2.6" || skip + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CA_FILES_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=cafile.pem" + dpa_curl_status_body '$output' + assert_equal $SC 201 + + run dpa_curl_file_upload PUT "$_RUNTIME_SSL_CA_FILES_BASE_PATH/cafile.pem" "@${BATS_TEST_DIRNAME}/data/4.pem;filename=cafile.pem" + assert_success + + resource_get "$_RUNTIME_SSL_CA_FILES_BASE_PATH/cafile.pem/entries/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 9 + assert_equal "$(get_json_path "$BODY" '.storage_name')" "cafile.pem" + assert_equal "$(get_json_path "$BODY" '.algorithm')" "RSA2048" + assert_equal "$(get_json_path "$BODY" '.issuers')" "/CN=Interm2." + assert_equal "$(get_json_path "$BODY" '.serial')" "1002" +} diff --git a/e2e/tests/runtime_ssl_ca_files/utils/_helpers.bash b/e2e/tests/runtime_ssl_ca_files/utils/_helpers.bash new file mode 100644 index 00000000..510e3bf7 --- /dev/null +++ b/e2e/tests/runtime_ssl_ca_files/utils/_helpers.bash @@ -0,0 +1 @@ +_RUNTIME_SSL_CA_FILES_BASE_PATH="/services/haproxy/runtime/ssl_ca_files" diff --git a/e2e/tests/runtime_ssl_certs/data/1.pem b/e2e/tests/runtime_ssl_certs/data/1.pem new file mode 100644 index 00000000..cbd77a21 --- /dev/null +++ b/e2e/tests/runtime_ssl_certs/data/1.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_certs/data/2.pem b/e2e/tests/runtime_ssl_certs/data/2.pem new file mode 100644 index 00000000..7236b82b --- /dev/null +++ b/e2e/tests/runtime_ssl_certs/data/2.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_certs/data/3.pem b/e2e/tests/runtime_ssl_certs/data/3.pem new file mode 100644 index 00000000..1fbe4790 --- /dev/null +++ b/e2e/tests/runtime_ssl_certs/data/3.pem @@ -0,0 +1,79 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_certs/data/4.pem b/e2e/tests/runtime_ssl_certs/data/4.pem new file mode 100644 index 00000000..fa8fe909 --- /dev/null +++ b/e2e/tests/runtime_ssl_certs/data/4.pem @@ -0,0 +1,45 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_certs/test.bats b/e2e/tests/runtime_ssl_certs/test.bats new file mode 100644 index 00000000..b1eb50fd --- /dev/null +++ b/e2e/tests/runtime_ssl_certs/test.bats @@ -0,0 +1,92 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "ssl_certs_runtime: Create a new ssl certificate entry" { + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=cert.pem" + assert_success + + resource_get "$_RUNTIME_SSL_CERTS_BASE_PATH/cert.pem" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.storage_name')" "cert.pem" + assert_equal "$(get_json_path "$BODY" '.algorithm')" "RSA2048" + assert_equal "$(get_json_path "$BODY" '.issuers')" "/CN=Interm2." + assert_equal "$(get_json_path "$BODY" '.serial')" "1002" + assert_equal "$(get_json_path "$BODY" '.chain_issuer')" "/CN=Interm1." + assert_equal "$(get_json_path "$BODY" '.chain_subject')" "/CN=Interm2." + assert_equal "$(get_json_path "$BODY" '.not_after')" "2021-11-25T12:12:04.000Z" + assert_equal "$(get_json_path "$BODY" '.not_before')" "2020-11-25T12:12:04.000Z" + assert_equal "$(get_json_path "$BODY" '.sha1_finger_print')" "BC215F40136157964B69114E3D934934749798D5" + assert_equal "$(get_json_path "$BODY" '.status')" "Unused" + assert_equal "$(get_json_path "$BODY" '.subject')" "/CN=1.example.com" +} + +@test "ssl_certs_runtime: Set a payload to the ssl certificate entry" { + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=cert.pem" + assert_success + + run dpa_curl_file_upload PUT "$_RUNTIME_SSL_CERTS_BASE_PATH/cert.pem" "@${BATS_TEST_DIRNAME}/data/2.pem" + assert_success + + resource_get "$_RUNTIME_SSL_CERTS_BASE_PATH/cert.pem" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 11 + assert_equal "$(get_json_path "$BODY" '.storage_name')" "cert.pem" + assert_equal "$(get_json_path "$BODY" '.algorithm')" "RSA2048" + assert_equal "$(get_json_path "$BODY" '.issuers')" "/CN=Interm2." + assert_equal "$(get_json_path "$BODY" '.serial')" "1002" + assert_equal "$(get_json_path "$BODY" '.chain_issuer')" "/CN=Interm1." + assert_equal "$(get_json_path "$BODY" '.chain_subject')" "/CN=Interm2." + assert_equal "$(get_json_path "$BODY" '.not_after')" "2021-11-25T12:12:04.000Z" + assert_equal "$(get_json_path "$BODY" '.not_before')" "2020-11-25T12:12:04.000Z" + assert_equal "$(get_json_path "$BODY" '.sha1_finger_print')" "BC215F40136157964B69114E3D934934749798D5" + assert_equal "$(get_json_path "$BODY" '.status')" "Unused" + assert_equal "$(get_json_path "$BODY" '.subject')" "/CN=1.example.com" +} + +@test "ssl_certs_runtime: Get all the certs" { + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=cert1.pem" + assert_success + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/3.pem;filename=cert2.pem" + assert_success + + resource_get "$_RUNTIME_SSL_CERTS_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 2 + assert_equal "$(get_json_path "$BODY" '.[0].storage_name')" "cert1.pem" + assert_equal "$(get_json_path "$BODY" '.[1].storage_name')" "cert2.pem" +} + +@test "ssl_certs_runtime: Delete a ssl certificate entry" { + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=cert.pem" + assert_success + + resource_delete "$_RUNTIME_SSL_CERTS_BASE_PATH/cert.pem" + assert_equal $SC 204 + + resource_get "$_RUNTIME_SSL_CERTS_BASE_PATH/cert.pem" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/runtime_ssl_certs/utils/_helpers.bash b/e2e/tests/runtime_ssl_certs/utils/_helpers.bash new file mode 100644 index 00000000..5d65d523 --- /dev/null +++ b/e2e/tests/runtime_ssl_certs/utils/_helpers.bash @@ -0,0 +1 @@ +_RUNTIME_SSL_CERTS_BASE_PATH="/services/haproxy/runtime/ssl_certs" diff --git a/e2e/tests/runtime_ssl_crl_files/data/1.pem b/e2e/tests/runtime_ssl_crl_files/data/1.pem new file mode 100644 index 00000000..e0ba70f6 --- /dev/null +++ b/e2e/tests/runtime_ssl_crl_files/data/1.pem @@ -0,0 +1,66 @@ +-----BEGIN X509 CRL----- +MIIL3zCCCscCAQEwDQYJKoZIhvcNAQEFBQAwXjELMAkGA1UEBhMCQ04xDDAKBgNV +BAoTA0hFUDFBMD8GA1UEAxM4SW5zdGl0dXRlIG9mIEhpZ2ggRW5lcmd5IFBoeXNp +Y3MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkXDTIzMDUwOTA4NTUxNloXDTIzMDYw +ODA4NTUxNlowggoiMBICAQQXDTEzMDUwODA3MjQ0MlowEgIBBRcNMTMwNTA4MTEz +MjIyWjASAgEIFw0xMzA1MTAwNzAyMzVaMBICAQkXDTEzMDYxOTA3MDMyM1owEgIB +DBcNMTMxMTA2MDIyMDIzWjASAgENFw0xNDA1MTMxMTEzMTJaMBICAQ4XDTEzMTEw +NjAyMjAwOFowEgIBEBcNMTMxMTA2MDIxOTUxWjASAgEVFw0xMzA3MTcwNjU0MTRa +MBICARgXDTEzMDcxNjA2MTc0MlowEgIBGRcNMTQwNDMwMDk1MTE0WjASAgEaFw0x +MzA3MTcwNzI1MTNaMBICASAXDTEzMDgxMjA4NDIzNFowEgIBIxcNMTQwNzIyMDcx +MDQwWjASAgEpFw0xMzA4MjYwNTEzMjdaMBICASoXDTEzMDgyNjA1MTM0M1owEgIB +MBcNMTQwODE5MDk0NDIzWjASAgE4Fw0xMzExMTMwNjAwNTVaMBsCCgHG3janfKJg +5qAXDTE4MTIxNzA4MDcyN1owGwIKA7Oowf0wPnWn9xcNMTgxMjE3MDgwNjUxWjAb +AgoIcNo89ZduCtmRFw0xNDA4MjEwNzA2NTNaMBsCCgmvINTcNuQIujsXDTE3MTEw +ODEwNDE0MFowGwIKC9JLjtYGaQENrBcNMTUwMTA3MTEwODQ5WjAbAgoPwq+WuBYn +7EMdFw0xNDA4MjUwOTE2NThaMBsCChK4ALY8wHunvPMXDTE3MTAyNjA5MjUwNFow +GwIKExw65+MhS4uhIhcNMTUxMDE2MDM0ODM3WjAbAgoTQX//xVWmXlSJFw0yMDEw +MjkwOTM4MjVaMBsCChONNkoyUPca+k4XDTE0MTIxMDA3MzQyNlowGwIKFAT7j/f4 +ovIfKBcNMTQxMjA1MTEyNjQ0WjAbAgocadSEBkG3168BFw0xODEyMjYwOTU1NTda +MBsCCh1m+l4/g2XZnf8XDTE3MTAxNjEzNDkzOFowGwIKHgN0xRq+YRHb4RcNMTQx +MjI5MDgzNjQ5WjAbAgof9ZOBd/xpb1dxFw0xODEwMjYwODAwMjFaMBsCCiD8f4po +9/bVNeYXDTE0MDQzMDA5NTEyN1owGwIKIQ8mUWDG9FvgzBcNMjAwNTA2MTMyOTEw +WjAbAgoiM0WdApguYXyqFw0yMDEwMjkwOTM5MDFaMBsCCiJU9a6zeQTbb5sXDTE4 +MTIxNzA4MDc0MlowGwIKJJggGkb/bQY4nhcNMTcxMDI2MDkyNDQ5WjAbAgom+GdQ +FuK02IeEFw0xNTA5MTQwNDA4MTFaMBsCCimorxcjJciwI+QXDTE3MTAxNjEzNDkx +OFowGwIKLu/LHE1ao/jWUhcNMTYwNTI0MDgzNTA3WjAbAgoy4vaTmsXaoACqFw0x +NzA2MTIwMTM4MjlaMBsCCjs3USKKs49skJsXDTE4MTAyNTA4MDQ1N1owGwIKO7dQ +wt8+wKaiTxcNMTQwOTE1MTA0MDU1WjAbAgo7ypUmfYwRanB5Fw0xODAxMzEwMjE4 +MjlaMBsCCkA57NcigZzglq4XDTE0MTIyOTA4MzcwOFowGwIKRAB8looS8QIoKxcN +MTkxMTEyMDgyMzQ3WjAbAgpHQ2uOgR4nOThWFw0xNDA2MTMxMDE4NDBaMBsCCktL +QuOeclt9+gAXDTE1MTAxNjAzNDcyNlowGwIKUEUHaRPJmlEjLxcNMTcxMDE2MTM0 +OTUyWjAbAgpgYdjKIjOfl6V1Fw0xNDA4MjAwOTI3MDlaMBsCCmN9X+EbCxLPeLcX +DTE4MDQyMzAxNDMyMlowGwIKY5dBtUJKkh+k3xcNMTgxMDMxMTgzMjI0WjAbAgpo +f1cl+dCHclpUFw0xNTEwMTYwMzQ4MThaMBsCCm2hyLS0M9qqy9gXDTIwMTAyOTA5 +Mzg0M1owGwIKb1PO+a1if8E7vBcNMTkxMTEyMDgyNTAxWjAbAgpvuMtct8KUlnb+ +Fw0xODAxMTgxMDEzMDdaMBsCCnPhNV+SbqDbR0YXDTE5MDMxNTA4MjY1NlowGwIK +dgTBQMXCKITWfhcNMTQxMjI5MDgzNzIwWjAbAgp3N9IomZVxRUSOFw0xNzEwMTMw +MTEwMTlaMBsCCng7tqAlCgrYTdEXDTE1MDIyODA1MjMyMFowGwIKefr3IO1hoviV +yRcNMTYwNTE3MDgzNDIwWjAbAgp6nm4sQSE2WI3vFw0xODEyMTcwODA4MDFaMBsC +Cnr3SgL2AU8oLOUXDTE0MDQzMDA5NTE0OFowHAILAIFx9AZn+ueccYIXDTE3MTAx +NjEzNTAwNFowHAILAInrktgaUCoLtgkXDTIyMDQyMDE1MzIwNVowHAILAI01Hwhw +tCVEQ7IXDTE0MDgyMTA3MDcxMlowHAILAJGH/ueMGr1GgnMXDTE0MTIwNTExMjcw +MFowHAILAJUbzm/FPpuuIa0XDTE1MDkxNDA0MDg1MFowHAILAJY89Pr0cAbKS6sX +DTE0MDQzMDA5NTIxNFowHAILAJocz+EKhHrfMXEXDTE5MDMyNzE3NTUyMVowHAIL +AJ2O//eZEyE9Hk8XDTE3MDQwNjEyMjYyMVowHAILAKFL1anhAXvuniwXDTE0MTEy +NjA1MzQ1N1owHAILAKosxAlwtpEa/GsXDTE0MDgyMDA5MjY0NVowHAILAK3UFI9v +uf1AjMIXDTE1MTAyOTAyMTIyMVowHAILAK41Jud+8jXzg6cXDTE0MDgyNTA5MTcw +OVowHAILAK8Aelvw/fmsbKAXDTE4MTEwMTE2NTgwNlowHAILALR6D63mwFC3QYIX +DTE0MDgyMTA3MDcyOVowHAILALVcJJBtPGTWyLYXDTE1MDkxNDA0MDgyOVowHAIL +ALmwHA5dSfrNCBMXDTE4MTAxOTA4MDI0M1owHAILALrsWHo8fsJUEqUXDTE0MDQz +MDA5NTA0OVowHAILAL0JjOpQG388n2MXDTE5MTExMjA4MjQwN1owHAILAMBqqKsb +T09ZQ0EXDTE4MTIxNzA4MDcxMVowHAILAMGxcazgHh1TkF8XDTE0MDQzMDA5NTEw +MlowHAILAMdkRWD5HXF5kuwXDTIwMDIyODEwNTAzMlowHAILAM+sIQTDDvhJy4oX +DTE0MDUwNjEwNTkzMFowHAILANlQnRRyq7MsT5oXDTE4MDExNTAxMjQwNlowHAIL +AN8yw+G5J2QkHmIXDTE5MDUxNDA3NDE1M1owHAILAOh+BI/gxaEmfu8XDTE2MDUw +NDA4MTcwMFowHAILAOy91O6AsE6hN2wXDTE0MDQzMDA5NTEzOFowHAILAO/k9uLa +tHFc2iIXDTE0MDQzMDA5NTIwMlowHAILAPlD/u4eRPxk6YsXDTIwMDUyMTA2MDEz +M1owHAILAPosm0pR+3q8DqMXDTE0MTAzMDAyMTUwMlowHAILAP4dtO0fhjX56YgX +DTE1MDQwODAyMTU1NVqgDzANMAsGA1UdFAQEAgIBHjANBgkqhkiG9w0BAQUFAAOC +AQEAaIO3skF74Os6S3FNCMFijNaFx2uojwTnWXO8UHp2U6q7qFrko+tojzRToOmg +UtcIM7ihXZGvO8YFqE9vaRd4nmtr+b4wlU86Zn2T1bK2ob5hoi59+WnTh4xlJGkT +Ld5D/lsqyBXvwEHkDMuTHsIrkGKo2QRhLoY6LNkRYlZ444WF5j974++mtcu+Rhuq +PH5KmJ66w9q0+rm1xExrIc2AUVgXrqbRoPSS4Z8gq1tRpn/6KPAj9JvpbiJHqbtR +OGF7P2HLXtVLJtmDH+GWV/Y01cKFIOyjKR5n0JFgmiC9yYufJry0Pa03zKEBB5b3 +0VquSqFKVvxLrxLK34pCIPxD5A== +-----END X509 CRL----- diff --git a/e2e/tests/runtime_ssl_crl_files/data/2.pem b/e2e/tests/runtime_ssl_crl_files/data/2.pem new file mode 100644 index 00000000..fd4153ac --- /dev/null +++ b/e2e/tests/runtime_ssl_crl_files/data/2.pem @@ -0,0 +1,14 @@ +-----BEGIN X509 CRL----- +MIICMzCCARsCAQEwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCVVMxFTATBgNV +BAoTDERpZ2lDZXJ0IEluYzEnMCUGA1UEAxMeRGlnaUNlcnQgU0hBMiBTZWN1cmUg +U2VydmVyIENBFw0yMzA1MTcwMzQ2MjRaFw0yMzA1MjQwMzQ2MjRaoIGZMIGWMB8G +A1UdIwQYMBaAFA+AYRyCMWHVLyjnjUY4tCzhxtniMAsGA1UdFAQEAgIHzTBmBgNV +HRwBAf8EXDBaoFigVoYpaHR0cDovL2NybDMuZGlnaWNlcnQuY29tL3NzY2Etc2hh +Mi1nNi5jcmyGKWh0dHA6Ly9jcmw0LmRpZ2ljZXJ0LmNvbS9zc2NhLXNoYTItZzYu +Y3JsMA0GCSqGSIb3DQEBCwUAA4IBAQDHOqTWgeqZcABeseQNdWzoYpm8jCKisRwO +WGdKaepR505Lp9ap7b7ymXdJqdmCIchTh+iI/Hh4upnN64U9GdWu1xoJ1MXjBO3U +inICb9kG+pjWyFRlhlHJzQXHOsjlXf/FlCJTlsEXDj1MiDJpGdbK8g3XvaMqHIga +afqfKsdWrF8i9p0+E4YTNP+rB7OkCGANgSPSyO2yfloAaN+sKuOQ8Go7tTXNkQnt +ZEpEwOpMcSSLdsZcjNHvurbCm61DpzVfFkAEssiEVVcmKf+Y0A/+1AuUh3p/SuJb +mDewXE/LDjRI6+gFgeJDX2CseYOQPkCRnd2vU7OrzUUPazIGb5xi +-----END X509 CRL----- diff --git a/e2e/tests/runtime_ssl_crl_files/test.bats b/e2e/tests/runtime_ssl_crl_files/test.bats new file mode 100644 index 00000000..fdd8a079 --- /dev/null +++ b/e2e/tests/runtime_ssl_crl_files/test.bats @@ -0,0 +1,87 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "ssl_crl_files_runtime: Create a new ssl crl file" { + haproxy_version_ge "2.6" || skip + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CRL_FILES_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=crlfile.pem" + assert_success + + resource_get "$_RUNTIME_SSL_CRL_FILES_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 1 + assert_equal "$(get_json_path "$BODY" '.[0].storage_name')" "crlfile.pem" + + resource_get "$_RUNTIME_SSL_CRL_FILES_BASE_PATH/crlfile.pem" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 1 + assert_equal "$(get_json_path "$BODY" '.[0]|length')" 8 + assert_equal "$(get_json_path "$BODY" '.[0].storage_name')" "crlfile.pem" + assert_equal "$(get_json_path "$BODY" '.[0].issuer')" "/C=CN/O=HEP/CN=Institute of High Energy Physics Certification Authority" + assert_equal "$(get_json_path "$BODY" '.[0].next_update')" "2023-06-08" + assert_equal "$(get_json_path "$BODY" '.[0].revoked_certificates[0].serial_number')" "04" + assert_equal "$(get_json_path "$BODY" '.[0].revoked_certificates[0].revocation_date')" "2013-05-08" + assert_equal "$(get_json_path "$BODY" '.[0].revoked_certificates[1].serial_number')" "05" + assert_equal "$(get_json_path "$BODY" '.[0].revoked_certificates[1].revocation_date')" "2013-05-08" + assert_equal "$(get_json_path "$BODY" '.[0].revoked_certificates[2].serial_number')" "08" + assert_equal "$(get_json_path "$BODY" '.[0].revoked_certificates[2].revocation_date')" "2013-05-10" + assert_equal "$(get_json_path "$BODY" '.[0].signature_algorithm')" "sha1WithRSAEncryption" + assert_equal "$(get_json_path "$BODY" '.[0].status')" "Unused" + assert_equal "$(get_json_path "$BODY" '.[0].version')" "2" +} + +@test "ssl_crl_files_runtime: Update an ssl crl file" { + haproxy_version_ge "2.6" || skip + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CRL_FILES_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=crlfile.pem" + assert_success + + run dpa_curl_file_upload PUT "$_RUNTIME_SSL_CRL_FILES_BASE_PATH/crlfile.pem" "@${BATS_TEST_DIRNAME}/data/2.pem;filename=2.pem" + assert_success + + resource_get "$_RUNTIME_SSL_CRL_FILES_BASE_PATH/crlfile.pem" "index=1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.[0]|length')" 7 + assert_equal "$(get_json_path "$BODY" '.[0].storage_name')" "crlfile.pem" + assert_equal "$(get_json_path "$BODY" '.[0].issuer')" "/C=US/O=DigiCert Inc/CN=DigiCert SHA2 Secure Server CA" + assert_equal "$(get_json_path "$BODY" '.[0].next_update')" "2023-05-24" + assert_equal "$(get_json_path "$BODY" '.[0].signature_algorithm')" "sha256WithRSAEncryption" + assert_equal "$(get_json_path "$BODY" '.[0].status')" "Unused" +} + +@test "ssl_crl_files_runtime: Delete an ssl crl file" { + haproxy_version_ge "2.6" || skip + + run dpa_curl_file_upload POST "$_RUNTIME_SSL_CRL_FILES_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=crlfile.pem" + assert_success + + resource_delete "$_RUNTIME_SSL_CRL_FILES_BASE_PATH/crlfile.pem" + assert_equal $SC 204 + + resource_get "$_RUNTIME_SSL_CRL_FILES_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 0 +} diff --git a/e2e/tests/runtime_ssl_crl_files/utils/_helpers.bash b/e2e/tests/runtime_ssl_crl_files/utils/_helpers.bash new file mode 100644 index 00000000..e7be9130 --- /dev/null +++ b/e2e/tests/runtime_ssl_crl_files/utils/_helpers.bash @@ -0,0 +1 @@ +_RUNTIME_SSL_CRL_FILES_BASE_PATH="/services/haproxy/runtime/ssl_crl_files" diff --git a/e2e/tests/runtime_ssl_crt_lists/data/container/ssl/1.pem b/e2e/tests/runtime_ssl_crt_lists/data/container/ssl/1.pem new file mode 100644 index 00000000..cbd77a21 --- /dev/null +++ b/e2e/tests/runtime_ssl_crt_lists/data/container/ssl/1.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/runtime_ssl_crt_lists/data/container/ssl/crt-list.txt b/e2e/tests/runtime_ssl_crt_lists/data/container/ssl/crt-list.txt new file mode 100644 index 00000000..9c345acc --- /dev/null +++ b/e2e/tests/runtime_ssl_crt_lists/data/container/ssl/crt-list.txt @@ -0,0 +1 @@ +/ssl/1.pem diff --git a/e2e/tests/runtime_ssl_crt_lists/data/haproxy.cfg b/e2e/tests/runtime_ssl_crt_lists/data/haproxy.cfg new file mode 100644 index 00000000..2a6a2ee7 --- /dev/null +++ b/e2e/tests/runtime_ssl_crt_lists/data/haproxy.cfg @@ -0,0 +1,32 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin expose-fd listeners + +defaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +frontend fe_sitea + mode http + bind :443 ssl crt-list /ssl/crt-list.txt diff --git a/e2e/tests/runtime_ssl_crt_lists/data/post.json b/e2e/tests/runtime_ssl_crt_lists/data/post.json new file mode 100644 index 00000000..54cce4af --- /dev/null +++ b/e2e/tests/runtime_ssl_crt_lists/data/post.json @@ -0,0 +1,5 @@ +{ + "sni_filter": [ "mysite.local" ], + "ssl_bind_config": "alpn h2", + "file": "/ssl/1.pem" +} \ No newline at end of file diff --git a/e2e/tests/runtime_ssl_crt_lists/test.bats b/e2e/tests/runtime_ssl_crt_lists/test.bats new file mode 100644 index 00000000..22d6d99b --- /dev/null +++ b/e2e/tests/runtime_ssl_crt_lists/test.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "ssl_crt_lists_runtime: Get all crt lists" { + resource_post "$_RUNTIME_SSL_CRT_LISTS_BASE_PATH/entries" "data/post.json" "name=/ssl/crt-list.txt" + assert_equal "$SC" 201 + resource_get "$_RUNTIME_SSL_CRT_LISTS_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 1 + assert_equal "$(get_json_path "$BODY" '.[0].file')" "/ssl/crt-list.txt" +} + +@test "ssl_crt_lists_runtime: Get a crt list entry" { + resource_post "$_RUNTIME_SSL_CRT_LISTS_BASE_PATH/entries" "data/post.json" "name=/ssl/crt-list.txt" + dpa_curl_status_body '$output' + assert_equal "$SC" 201 + resource_get "$_RUNTIME_SSL_CRT_LISTS_BASE_PATH/entries" "name=/ssl/crt-list.txt" + dpa_curl_status_body '$output' + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 2 + assert_equal "$(get_json_path "$BODY" '.[0].file')" "/ssl/1.pem" + assert_equal "$(get_json_path "$BODY" '.[0].line_number')" "1" + assert_equal "$(get_json_path "$BODY" '.[1].file')" "/ssl/1.pem" + assert_equal "$(get_json_path "$BODY" '.[1].line_number')" "2" + assert_equal "$(get_json_path "$BODY" '.[1].ssl_bind_config')" "alpn h2" + assert_equal "$(get_json_path "$BODY" '.[1].sni_filter[0]')" "mysite.local" +} + +@test "ssl_crt_lists_runtime: Delete a crt list entry" { + resource_post "$_RUNTIME_SSL_CRT_LISTS_BASE_PATH/entries" "data/post.json" "name=/ssl/crt-list.txt" + dpa_curl_status_body '$output' + assert_equal "$SC" 201 + resource_delete "$_RUNTIME_SSL_CRT_LISTS_BASE_PATH/entries" "name=/ssl/crt-list.txt&cert_file=/ssl/1.pem&line_number=2" + assert_equal "$SC" 204 +} diff --git a/e2e/tests/runtime_ssl_crt_lists/utils/_helpers.bash b/e2e/tests/runtime_ssl_crt_lists/utils/_helpers.bash new file mode 100644 index 00000000..cd0be537 --- /dev/null +++ b/e2e/tests/runtime_ssl_crt_lists/utils/_helpers.bash @@ -0,0 +1 @@ +_RUNTIME_SSL_CRT_LISTS_BASE_PATH="/services/haproxy/runtime/ssl_crt_lists" diff --git a/e2e/tests/server_templates/create.bats b/e2e/tests/server_templates/create.bats new file mode 100644 index 00000000..95a45538 --- /dev/null +++ b/e2e/tests/server_templates/create.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "server_templates: Add a new server template 1" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates" "data/first/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/first" + assert_equal "$SC" 200 + + assert_equal "first" "$(get_json_path "$BODY" '.prefix')" + assert_equal "1-50" "$(get_json_path "$BODY" '.num_or_range')" + assert_equal "first.com" "$(get_json_path "$BODY" '.fqdn')" + assert_equal "443" "$(get_json_path "$BODY" '.port')" +} + +@test "server_templates: Add a new server template 2" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates" "data/second/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/second" + assert_equal "$SC" 200 + + assert_equal "second" "$(get_json_path "$BODY" '.prefix')" + assert_equal "1-3" "$(get_json_path "$BODY" '.num_or_range')" + assert_equal "second.com" "$(get_json_path "$BODY" '.fqdn')" + assert_equal "8080" "$(get_json_path "$BODY" '.port')" +} + +@test "server_templates: Add a new server template when missing frontend" { + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates" "data/second/post.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/server_templates/data/first/post.json b/e2e/tests/server_templates/data/first/post.json new file mode 100644 index 00000000..5c48b4eb --- /dev/null +++ b/e2e/tests/server_templates/data/first/post.json @@ -0,0 +1,6 @@ +{ + "prefix": "first", + "num_or_range": "1-50", + "fqdn": "first.com", + "port": 443 + } diff --git a/e2e/tests/server_templates/data/first/put.json b/e2e/tests/server_templates/data/first/put.json new file mode 100644 index 00000000..fa3920c0 --- /dev/null +++ b/e2e/tests/server_templates/data/first/put.json @@ -0,0 +1,6 @@ +{ + "prefix": "first", + "num_or_range": "51-100", + "fqdn": "first.com", + "port": 444 + } diff --git a/e2e/tests/server_templates/data/haproxy.cfg b/e2e/tests/server_templates/data/haproxy.cfg new file mode 100644 index 00000000..7d7ee933 --- /dev/null +++ b/e2e/tests/server_templates/data/haproxy.cfg @@ -0,0 +1,33 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +backend test_backend + mode http + balance roundrobin + option forwardfor + server-template srv_google 0-9 google.com:443 + server-template srv_bing 10-19 bing.com:8080 diff --git a/e2e/tests/server_templates/data/second/post.json b/e2e/tests/server_templates/data/second/post.json new file mode 100644 index 00000000..3f7bb0b1 --- /dev/null +++ b/e2e/tests/server_templates/data/second/post.json @@ -0,0 +1,6 @@ +{ + "prefix": "second", + "num_or_range": "1-3", + "fqdn": "second.com", + "port": 8080 + } diff --git a/e2e/tests/server_templates/data/second/put.json b/e2e/tests/server_templates/data/second/put.json new file mode 100644 index 00000000..a264dbd5 --- /dev/null +++ b/e2e/tests/server_templates/data/second/put.json @@ -0,0 +1,6 @@ +{ + "prefix": "second", + "num_or_range": "4-6", + "fqdn": "site.com", + "port": 8081 + } diff --git a/e2e/tests/server_templates/data/srv_google/put.json b/e2e/tests/server_templates/data/srv_google/put.json new file mode 100644 index 00000000..c09ce715 --- /dev/null +++ b/e2e/tests/server_templates/data/srv_google/put.json @@ -0,0 +1,6 @@ +{ + "prefix": "srv_google", + "num_or_range": "1-100", + "fqdn": "google.com", + "port": 8080 + } diff --git a/e2e/tests/server_templates/delete.bats b/e2e/tests/server_templates/delete.bats new file mode 100644 index 00000000..acb8e6e1 --- /dev/null +++ b/e2e/tests/server_templates/delete.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "server_templates: Delete a server template 1" { + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/srv_google" "force_reload=true" + assert_equal "$SC" 204 +} + +@test "server_templates: Delete a server template 2" { + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/srv_bing" "force_reload=true" + assert_equal "$SC" 204 +} + +@test "server_templates: Delete a non existing server template" { + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/ghost" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/server_templates/get.bats b/e2e/tests/server_templates/get.bats new file mode 100644 index 00000000..1a8b264e --- /dev/null +++ b/e2e/tests/server_templates/get.bats @@ -0,0 +1,49 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "server_templates: Return one server template" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/srv_google" + assert_equal "$SC" 200 + + assert_equal "srv_google" "$(get_json_path "$BODY" '.prefix')" + assert_equal "0-9" "$(get_json_path "$BODY" '.num_or_range')" + assert_equal "google.com" "$(get_json_path "$BODY" '.fqdn')" + assert_equal "443" "$(get_json_path "$BODY" '.port')" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/srv_bing" + assert_equal "$SC" 200 + + assert_equal "srv_bing" "$(get_json_path "$BODY" '.prefix')" + assert_equal "10-19" "$(get_json_path "$BODY" '.num_or_range')" + assert_equal "bing.com" "$(get_json_path "$BODY" '.fqdn')" + assert_equal "8080" "$(get_json_path "$BODY" '.port')" +} + +@test "server_templates: Return a non existing server template" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/ghost" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/server_templates/replace.bats b/e2e/tests/server_templates/replace.bats new file mode 100644 index 00000000..35ac4854 --- /dev/null +++ b/e2e/tests/server_templates/replace.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "server_templates: Replace a server template" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/srv_google" "data/srv_google/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/srv_google" + assert_equal "$SC" 200 + + assert_equal "srv_google" "$(get_json_path "$BODY" '.prefix')" + assert_equal "1-100" "$(get_json_path "$BODY" '.num_or_range')" + assert_equal "google.com" "$(get_json_path "$BODY" '.fqdn')" + assert_equal "8080" "$(get_json_path "$BODY" '.port')" +} + +@test "server_templates: Replacing a non existing server template" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/server_templates/ghost" "data/srv_google/put.json" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/server_templates/utils/_helpers.bash b/e2e/tests/server_templates/utils/_helpers.bash new file mode 100644 index 00000000..b16dc165 --- /dev/null +++ b/e2e/tests/server_templates/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" diff --git a/e2e/tests/servers/create.bats b/e2e/tests/servers/create.bats new file mode 100644 index 00000000..2d71daad --- /dev/null +++ b/e2e/tests/servers/create.bats @@ -0,0 +1,79 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/haproxy_version' +load '../../libs/version' + +load 'utils/_helpers' + +@test "servers: Add a new server to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "servers: Add a new server to backend through runtime with deprecated backend param" { + haproxy_version_ge 2.6 || skip "requires HAProxy 2.6+" + + pre_logs_count=$(dpa_docker_exec 'cat /var/log/dataplaneapi.log' | wc -l) + + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/post.json" + assert_equal "$SC" 201 + + # check that server has been added through runtime socket + post_logs_count=$(dpa_docker_exec 'sh /var/log/dataplaneapi.log' | wc -l) + new_logs_count=$(( $pre_logs_count - $post_logs_count )) + new_logs=$(dpa_docker_exec 'cat /var/log/dataplaneapi.log' | tail -n $new_logs_count) + + echo "$new_logs" # this will help debugging if the test fails + assert echo -e "$new_logs" | grep -q "backend test_backend: server test_server added though runtime" +} + +@test "servers: Add a new server to backend through runtime with parent_type/ parent_name" { + haproxy_version_ge 2.6 || skip "requires HAProxy 2.6+" + pre_logs_count=$(dpa_docker_exec 'cat /var/log/dataplaneapi.log' | wc -l) + + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/post.json" + assert_equal "$SC" 201 + + # check that server has been added through runtime socket + post_logs_count=$(dpa_docker_exec 'sh /var/log/dataplaneapi.log' | wc -l) + new_logs_count=$(( $pre_logs_count - $post_logs_count )) + new_logs=$(dpa_docker_exec 'cat /var/log/dataplaneapi.log' | tail -n $new_logs_count) + + echo "$new_logs" # this will help debugging if the test fails + assert echo -e "$new_logs" | grep -q "backend test_backend: server test_server added though runtime" +} + +@test "servers: Add a new server to peer" { + PARENT_NAME="fusion" + resource_post "$_PEER_BASE_PATH/$PARENT_NAME/servers" "data/post.json" + assert_equal "$SC" 202 +} + +@test "servers: Add a new server to ring" { + haproxy_version_ge 2.2 || skip "requires HAProxy 2.2+" + PARENT_NAME=logbuffer + resource_post "$_RING_BASE_PATH/$PARENT_NAME/servers" "data/post.json" + assert_equal "$SC" 202 +} diff --git a/e2e/tests/servers/data/haproxy.cfg b/e2e/tests/servers/data/haproxy.cfg new file mode 100644 index 00000000..a5382ed9 --- /dev/null +++ b/e2e/tests/servers/data/haproxy.cfg @@ -0,0 +1,40 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +peers fusion + peer peer1 127.0.0.1:5108 + server server_01 10.1.1.1:8080 check weight 80 + +backend test_backend + mode http + balance roundrobin + option forwardfor + server server_01 10.1.1.1:8080 check weight 80 + server server_02 10.1.1.2:8080 check weight 80 + server server_03 10.1.1.2:8080 check weight 80 + server server_ipv6 [fd00:6:48:c85:deb:f:62:4]:80 check + server server_04 192.168.1.1:80 check resolve-opts allow-dup-ip,ignore-weight resolve-net 10.0.0.0/8,10.200.200.0/12 diff --git a/e2e/tests/servers/data/haproxy_2.2.cfg b/e2e/tests/servers/data/haproxy_2.2.cfg new file mode 100644 index 00000000..2113e73e --- /dev/null +++ b/e2e/tests/servers/data/haproxy_2.2.cfg @@ -0,0 +1,51 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +peers fusion + peer peer1 127.0.0.1:5108 + server server_01 10.1.1.1:8080 check weight 80 + +ring logbuffer + description "buffer for logs" + format rfc5424 + maxlen 1500 + size 65536 + timeout connect 10s + timeout server 20s + + # Sends outgoing messages via TCP + server logserver 192.168.1.100:514 + +backend test_backend + mode http + balance roundrobin + option forwardfor + server server_01 10.1.1.1:8080 check weight 80 + server server_02 10.1.1.2:8080 check weight 80 + server server_03 10.1.1.2:8080 check weight 80 + server server_ipv6 [fd00:6:48:c85:deb:f:62:4]:80 check + server server_04 192.168.1.1:80 check resolve-opts allow-dup-ip,ignore-weight resolve-net 10.0.0.0/8,10.200.200.0/12 diff --git a/e2e/tests/servers/data/post.json b/e2e/tests/servers/data/post.json new file mode 100644 index 00000000..d8a85c7e --- /dev/null +++ b/e2e/tests/servers/data/post.json @@ -0,0 +1,9 @@ +{ + "address": "10.1.0.1", + "check": "enabled", + "name": "test_server", + "port": 8080, + "weight": 80, + "resolve-net": "10.0.0.0/8,10.200.200.0/12", + "resolve_opts": "allow-dup-ip,ignore-weight" +} diff --git a/e2e/tests/servers/data/put.json b/e2e/tests/servers/data/put.json new file mode 100644 index 00000000..9dfb86e1 --- /dev/null +++ b/e2e/tests/servers/data/put.json @@ -0,0 +1,9 @@ +{ + "check": "enabled", + "resolve-net": "10.0.0.0/8", + "resolve_opts": "allow-dup-ip", + "weight": 10, + "address": "10.1.1.2", + "name": "server_01", + "port": 8081 +} diff --git a/e2e/tests/servers/data/runtime_add_server.json b/e2e/tests/servers/data/runtime_add_server.json new file mode 100644 index 00000000..a1afacdd --- /dev/null +++ b/e2e/tests/servers/data/runtime_add_server.json @@ -0,0 +1,7 @@ +{ + "name": "rt_server", + "address": "10.11.12.13", + "port": 8088, + "check": "disabled", + "maxconn": 100 +} \ No newline at end of file diff --git a/e2e/tests/servers/data/transient.json b/e2e/tests/servers/data/transient.json new file mode 100644 index 00000000..6ca2e508 --- /dev/null +++ b/e2e/tests/servers/data/transient.json @@ -0,0 +1,4 @@ +{ + "admin_state": "ready", + "operational_state": "up" +} diff --git a/e2e/tests/servers/delete.bats b/e2e/tests/servers/delete.bats new file mode 100644 index 00000000..7038fc5d --- /dev/null +++ b/e2e/tests/servers/delete.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "servers: Delete a server" { + PARENT_NAME="test_backend" + for name in "server_01" "server_02" "server_03" "server_04"; do + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/servers/$name" "force_reload=true" + assert_equal "$SC" 204 + done +} + +@test "servers: Delete a non existing server" { + PARENT_NAME=test_backend + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/servers/ghost" + assert_equal "$SC" 404 +} + +@test "servers: Delete a server on a non existing backend" { + PARENT_NAME=ghost + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/servers/server_01" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/servers/get.bats b/e2e/tests/servers/get.bats new file mode 100644 index 00000000..166801a8 --- /dev/null +++ b/e2e/tests/servers/get.bats @@ -0,0 +1,44 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "servers: Return one server" { + PARENT_NAME="test_backend" + for name in "server_01" "server_02" "server_03"; do + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/servers/$name" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "$name" + done +} + + +@test "servers: Return one IPv6 server" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/servers/server_ipv6" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.address')" "fd00:6:48:c85:deb:f:62:4" + assert_equal "$(get_json_path "$BODY" '.check')" "enabled" + assert_equal "$(get_json_path "$BODY" '.name')" "server_ipv6" + assert_equal "$(get_json_path "$BODY" '.port')" "80" +} diff --git a/e2e/tests/servers/list.bats b/e2e/tests/servers/list.bats new file mode 100644 index 00000000..4976ef00 --- /dev/null +++ b/e2e/tests/servers/list.bats @@ -0,0 +1,62 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/haproxy_version' +load '../../libs/version' + +load 'utils/_helpers' + +@test "servers: Return an array of backend servers" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/servers" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ". | length")" "5" + + INDEX=0 + for name in "server_01" "server_02" "server_03" "server_ipv6" "server_04"; do + assert_equal "$(get_json_path "$BODY" ".[] | select(.name | contains(\"$name\") ).name")" "$name" + if [[ "$(get_json_path "$BODY" ".[] | select(.name | contains(\"$name\") ).name")" == "server_04" ]]; then + assert_equal "$(get_json_path "$BODY" ".[${INDEX}].check")" "enabled" + assert_equal "$(get_json_path "$BODY" ".[${INDEX}].resolve_opts")" "allow-dup-ip,ignore-weight" + assert_equal "$(get_json_path "$BODY" ".[${INDEX}].\"resolve-net\"")" "10.0.0.0/8,10.200.200.0/12" + fi + let INDEX=${INDEX}+1 + done +} + +@test "servers: Return an array of peers servers" { + PARENT_NAME="fusion" + resource_get "$_PEER_BASE_PATH/$PARENT_NAME/servers" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ". | length")" "1" +} + +@test "servers: Return an array of ring servers" { + haproxy_version_ge 2.2 || skip "requires HAProxy 2.2+" + + PARENT_NAME="logbuffer" + resource_get "$_RING_BASE_PATH/$PARENT_NAME/servers" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ". | length")" "1" +} diff --git a/e2e/tests/servers/replace.bats b/e2e/tests/servers/replace.bats new file mode 100644 index 00000000..0a051e5b --- /dev/null +++ b/e2e/tests/servers/replace.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "servers: Replace a server" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/servers/server_01" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/servers/server_01" "backend=test_backend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat $BATS_TEST_DIRNAME/data/put.json)" ".")" +} diff --git a/e2e/tests/servers/runtime.bats b/e2e/tests/servers/runtime.bats new file mode 100644 index 00000000..8f21cafa --- /dev/null +++ b/e2e/tests/servers/runtime.bats @@ -0,0 +1,107 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "servers: Return an array of runtime servers' settings" { + PARENT_NAME="test_backend" + resource_get "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers" + assert_equal "$SC" 200 + + for name in "server_01" "server_02" "server_03" "server_04"; do + assert_equal "$(get_json_path "$BODY" ".[] | select(.name | contains(\"$name\") ).name")" "$name" + done +} + +@test "servers: Replace server transient settings" { + PARENT_NAME="test_backend" + resource_put "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers/server_01" "data/transient.json" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "server_01" +} + +@test "servers: Return one server runtime settings" { + PARENT_NAME="test_backend" + resource_get "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers/server_01" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "server_01" +} + +@test "servers: Add a server via runtime" { + PARENT_NAME="test_backend" + haproxy_version_ge 2.6 || skip "requires HAProxy 2.6+" + + resource_post "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/runtime_add_server.json" + assert_equal "$SC" 201 + assert_equal "$(get_json_path "$BODY" '.name')" "rt_server" + + resource_get "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers/rt_server" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.name')" "rt_server" + assert_equal "$(get_json_path "$BODY" '.address')" "10.11.12.13" + assert_equal "$(get_json_path "$BODY" '.port')" 8088 +} + +@test "servers: Add an existing server via runtime" { + PARENT_NAME="test_backend" + haproxy_version_ge 2.6 || skip "requires HAProxy 2.6+" + + resource_post "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/runtime_add_server.json" + assert_equal "$SC" 201 + + resource_post "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/runtime_add_server.json" + assert_equal "$SC" 409 +} + +@test "servers: Add a server to a wrong backend via runtime" { + PARENT_NAME="does_not_exist" + haproxy_version_ge 2.6 || skip "requires HAProxy 2.6+" + + resource_post "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/runtime_add_server.json" + assert_equal "$SC" 404 +} + +@test "servers: Delete a server via runtime" { + PARENT_NAME="test_backend" + haproxy_version_ge 2.6 || skip "requires HAProxy 2.6+" + + resource_post "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers" "data/runtime_add_server.json" + assert_equal "$SC" 201 + + resource_delete "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers/rt_server" + assert_equal "$SC" 204 +} + +@test "servers: Delete a non-existant server via runtime" { + PARENT_NAME="test_backend" + haproxy_version_ge 2.6 || skip "requires HAProxy 2.6+" + + resource_delete "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers/rt_server1" + assert_equal "$SC" 404 + + # wrong backend + PARENT_NAME="does_not_exist" + resource_delete "$_RUNTIME_BACKEND_BASE_PATH/$PARENT_NAME/servers/rt_server2" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/servers/utils/_helpers.bash b/e2e/tests/servers/utils/_helpers.bash new file mode 100644 index 00000000..fb978ab9 --- /dev/null +++ b/e2e/tests/servers/utils/_helpers.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_RUNTIME_BACKEND_BASE_PATH="/services/haproxy/runtime/backends" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_PEER_BASE_PATH="/services/haproxy/configuration/peers" +_RING_BASE_PATH="/services/haproxy/configuration/rings" diff --git a/e2e/tests/service_discovery/data/consul.json b/e2e/tests/service_discovery/data/consul.json new file mode 100644 index 00000000..bff8fd90 --- /dev/null +++ b/e2e/tests/service_discovery/data/consul.json @@ -0,0 +1,14 @@ +{ + "consuls": [ + { + "address": "ADDRESS", + "enabled": true, + "id": "c586426f-60b2-4d45-a0fc-4a1f8ef4365b", + "port": 8500, + "retry_timeout": 10, + "server_slots_base": 10, + "server_slots_growth_increment": 10, + "server_slots_growth_type": "linear" + } + ] + } diff --git a/e2e/tests/service_discovery/data/sd_3_2.json b/e2e/tests/service_discovery/data/sd_3_2.json new file mode 100644 index 00000000..99cf8b23 --- /dev/null +++ b/e2e/tests/service_discovery/data/sd_3_2.json @@ -0,0 +1,40 @@ +{ + "services": [ + { + "id": "host-0-0", + "name": "test-service-0", + "address": "182.242.119.47", + "port": 8000 + }, + { + "id": "host-0-1", + "name": "test-service-0", + "address": "250.84.2.31", + "port": 8000 + }, + { + "id": "host-0-2", + "name": "test-service-0", + "address": "66.78.40.63", + "port": 8000 + }, + { + "id": "host-1-0", + "name": "test-service-1", + "address": "14.116.78.122", + "port": 8000 + }, + { + "id": "host-1-1", + "name": "test-service-1", + "address": "175.14.89.148", + "port": 8000 + }, + { + "id": "host-1-2", + "name": "test-service-1", + "address": "210.83.16.45", + "port": 8000 + } + ] + } diff --git a/e2e/tests/service_discovery/tests.bats b/e2e/tests/service_discovery/tests.bats new file mode 100644 index 00000000..c269adca --- /dev/null +++ b/e2e/tests/service_discovery/tests.bats @@ -0,0 +1,117 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/resource_client' +load '../../libs/cleanup' + +CONSUL_CONTAINER_NAME=consul-server +CONSUL_NETWORK=my-consul-net + +setup() { + # Stop dapi + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + ## consul + run docker network create ${CONSUL_NETWORK} + assert_success + + # start consul + docker run -d --name ${CONSUL_CONTAINER_NAME} --net=${CONSUL_NETWORK} -p 8500:8500 -p 8600:8600/udp hashicorp/consul agent -server -ui -bootstrap-expect=1 -client=0.0.0.0 + assert_success + + CONSUL_ADDR=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${CONSUL_CONTAINER_NAME}) + debug "Local Consul IP: ${CONSUL_ADDR}" + + run docker network connect ${CONSUL_NETWORK} ${DOCKER_CONTAINER_NAME} + assert_success + + # register services + run docker cp "${BATS_TEST_DIRNAME}/data/sd_3_2.json" "${CONSUL_CONTAINER_NAME}:./" + assert_success + run docker exec -d ${CONSUL_CONTAINER_NAME} /bin/sh -c "consul services register ./sd_3_2.json" + + #### dapi #### + CONSUL_CONF=$(mktemp) + RES=$(cat ${BATS_TEST_DIRNAME}/data/consul.json | sed "s/ADDRESS/${CONSUL_ADDR}/g") + echo $RES > ${CONSUL_CONF} + + run dpa_docker_exec 'mkdir -p /var/lib/dataplaneapi/storage/service_discovery' + assert_success + + #run docker cp "${BATS_TEST_DIRNAME}/data/consul.json" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplane/service_discovery/consul.json" + run docker cp "${CONSUL_CONF}" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/dataplane/service_discovery/consul.json" + assert_success + + # Start dapi + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + assert_success + + # Wait for dapi to be ready with single user + until dpa_curl GET "/info"; do + sleep 0.1 + done + +} + +# teardown returns original configuration to dataplane +teardown() { + # Stop dapi + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + cleanup ${CONSUL_CONTAINER_NAME} + run docker rm ${CONSUL_CONTAINER_NAME} + assert_success + + run docker network disconnect ${CONSUL_NETWORK} ${DOCKER_CONTAINER_NAME} + + run docker network rm ${CONSUL_NETWORK} + assert_success + + run dpa_docker_exec 'rm /etc/haproxy/dataplane/service_discovery/consul.json' + assert_success + + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /etc/haproxy/dataplaneapi.yaml" + assert_success + + until dpa_curl GET "/info"; do + sleep 0.1 + done + +} + +@test "check consul" { + + backend_nb=0 + until [ "$backend_nb" -eq 2 ]; do + backend_nb=$(dpa_docker_exec 'cat /etc/haproxy/haproxy.cfg' | grep backend | wc -l) + sleep 1s + done + # check first SRV, if this one is found, all should be there + srv1=$(dpa_docker_exec 'cat /etc/haproxy/haproxy.cfg' | grep 182.242.119.47 | wc -l) + assert_equal "$srv1" 1 + +} diff --git a/e2e/tests/set_uid/dataplaneapi.yaml b/e2e/tests/set_uid/dataplaneapi.yaml new file mode 100644 index 00000000..79217efc --- /dev/null +++ b/e2e/tests/set_uid/dataplaneapi.yaml @@ -0,0 +1,20 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + uid: 1500 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + resources: + maps_dir: /home/testuiduser/maps + ssl_certs_dir: /home/testuiduser/ssl + general_storage_dir: /home/testuiduser/general + spoe_dir: /home/testuiduser/spoe + spoe_transaction_dir: /home/testuiduser/spoe-td + dataplane_storage_dir: /home/testuiduser/dataplane +haproxy: + config_file: /home/testuiduser/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 diff --git a/e2e/tests/set_uid/test.bats b/e2e/tests/set_uid/test.bats new file mode 100644 index 00000000..95420ab5 --- /dev/null +++ b/e2e/tests/set_uid/test.bats @@ -0,0 +1,67 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' + +setup() { + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + run dpa_docker_exec 'adduser -u 1500 testuiduser || useradd -m -u 1500 testuiduser' + #assert_success ignore error since we do not plan to insert password, user will be created + + run docker cp "${BATS_TEST_DIRNAME}/dataplaneapi.yaml" "${DOCKER_CONTAINER_NAME}:/home/testuiduser/dataplaneapi.yaml" + assert_success + + run dpa_docker_exec 'chown testuiduser /home/testuiduser/dataplaneapi.yaml' + assert_success + + run dpa_docker_exec 'cp /etc/haproxy/haproxy.cfg /home/testuiduser/haproxy.cfg' + assert_success + + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /home/testuiduser/dataplaneapi.yaml" + assert_success + until dpa_curl GET "/info"; do + sleep 0.1 + done +} + +# teardown returns original configuration to dataplane +teardown() { + run docker cp "${E2E_DIR}/fixtures/dataplaneapi.yaml" "${DOCKER_CONTAINER_NAME}:/usr/local/bin/dataplaneapi.yaml" + assert_success + + run dpa_docker_exec 'kill -s 12 1' + assert_success + + run dpa_docker_exec 'pkill -9 dataplaneapi' + assert_success + + run docker exec -d ${DOCKER_CONTAINER_NAME} /bin/sh -c "CI_DATAPLANE_RELOAD_DELAY_OVERRIDE=1 dataplaneapi -f /usr/local/bin/dataplaneapi.yaml" + assert_success + until dpa_curl GET "/info"; do + sleep 0.1 + done +} + +@test "set_uid: check if running user is testuiduser for dataplane" { + run dpa_docker_exec "ps -eo ruser,user,comm | grep dataplaneapi" + assert_output --regexp '^testuid.* testuid.* dataplaneapi$' +} diff --git a/e2e/tests/sites/create.bats b/e2e/tests/sites/create.bats new file mode 100644 index 00000000..e2d86e41 --- /dev/null +++ b/e2e/tests/sites/create.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "sites: Add a site" { + resource_post "$_SITE_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + # + # Ensure it's found + # + resource_get "$_SITE_BASE_PATH/site" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/post.json")" ".")" +} diff --git a/e2e/tests/sites/data/haproxy.cfg b/e2e/tests/sites/data/haproxy.cfg new file mode 100644 index 00000000..98a6d66c --- /dev/null +++ b/e2e/tests/sites/data/haproxy.cfg @@ -0,0 +1,40 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend myfrontend + mode http + maxconn 2000 + bind 127.0.0.1:9001 + bind 127.0.0.1:9002 + option httpclose + default_backend www_backend + +backend www_backend + mode http + balance roundrobin + server www_server 127.0.1.1:4567 weight 30 + server www_server_new 127.0.1.2:4567 weight 70 diff --git a/e2e/tests/sites/data/post.json b/e2e/tests/sites/data/post.json new file mode 100644 index 00000000..bcfdbeff --- /dev/null +++ b/e2e/tests/sites/data/post.json @@ -0,0 +1,44 @@ +{ + "farms": [ + { + "balance": { + "algorithm": "roundrobin" + }, + "mode": "http", + "name": "site_backend", + "servers": [ + { + "weight": 30, + "address": "127.0.1.1", + "name": "site_server_01", + "port": 4567 + }, + { + "weight": 70, + "address": "127.0.1.2", + "name": "site_server_02", + "port": 4567 + } + ], + "use_as": "default" + } + ], + "name": "site", + "service": { + "http_connection_mode": "httpclose", + "listeners": [ + { + "address": "127.0.0.1", + "name": "site_listener_1", + "port": 80 + }, + { + "address": "127.0.0.1", + "name": "site_listener_2", + "port": 8081 + } + ], + "maxconn": 2000, + "mode": "http" + } +} diff --git a/e2e/tests/sites/data/put.json b/e2e/tests/sites/data/put.json new file mode 100644 index 00000000..058589fb --- /dev/null +++ b/e2e/tests/sites/data/put.json @@ -0,0 +1,44 @@ +{ + "farms": [ + { + "balance": { + "algorithm": "leastconn" + }, + "mode": "tcp", + "name": "tcp_backend", + "servers": [ + { + "weight": 30, + "address": "127.0.1.1", + "name": "tcp_server_01", + "port": 4567 + }, + { + "weight": 70, + "address": "127.0.1.2", + "name": "tcp_server_02", + "port": 4567 + } + ], + "use_as": "default" + } + ], + "name": "site", + "service": { + "http_connection_mode": "http-keep-alive", + "listeners": [ + { + "address": "127.0.0.1", + "name": "site_listener_1", + "port": 8081 + }, + { + "address": "127.0.0.1", + "name": "site_listener_2", + "port": 8082 + } + ], + "maxconn": 3000, + "mode": "tcp" + } +} diff --git a/e2e/tests/sites/delete.bats b/e2e/tests/sites/delete.bats new file mode 100644 index 00000000..51edaba4 --- /dev/null +++ b/e2e/tests/sites/delete.bats @@ -0,0 +1,32 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "sites: Delete a site" { + resource_delete "$_SITE_BASE_PATH/myfrontend" "force_reload=true" + assert_equal "$SC" 204 + + resource_get "$_SITE_BASE_PATH/site" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/sites/list.bats b/e2e/tests/sites/list.bats new file mode 100644 index 00000000..8df4a9d2 --- /dev/null +++ b/e2e/tests/sites/list.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "sites: Return an array of sites" { + resource_post "$_SITE_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_SITE_BASE_PATH" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" " .[] | select(.name | contains(\"myfrontend\") ).name" )" "myfrontend" + assert_equal "$(get_json_path "$BODY" " .[] | select(.name | contains(\"site\") ).name" )" "site" +} diff --git a/e2e/tests/sites/replace.bats b/e2e/tests/sites/replace.bats new file mode 100644 index 00000000..238dfbce --- /dev/null +++ b/e2e/tests/sites/replace.bats @@ -0,0 +1,38 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "sites: Replace a site" { + resource_post "$_SITE_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_put "$_SITE_BASE_PATH/site" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + # + # Ensure it's found + # + resource_get "$_SITE_BASE_PATH/site" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/put.json")" ".")" +} diff --git a/e2e/tests/sites/utils/_helpers.bash b/e2e/tests/sites/utils/_helpers.bash new file mode 100644 index 00000000..a1705e0a --- /dev/null +++ b/e2e/tests/sites/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SITE_BASE_PATH="/services/haproxy/sites" diff --git a/e2e/tests/specification/check.bats b/e2e/tests/specification/check.bats new file mode 100644 index 00000000..d697f516 --- /dev/null +++ b/e2e/tests/specification/check.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/version' +load '../../libs/get_json_path' + +@test "specification: specification v2" { + run dpa_curl GET "/specification" + assert_success + + dpa_curl_status_body_safe '$output' + assert_equal $SC 200 +} diff --git a/e2e/tests/spoe/data/spoefile_example.cfg b/e2e/tests/spoe/data/spoefile_example.cfg new file mode 100644 index 00000000..04f2e744 --- /dev/null +++ b/e2e/tests/spoe/data/spoefile_example.cfg @@ -0,0 +1,18 @@ +# _version=1 +[ip-reputation] +spoe-agent iprep-agent + messages check-client-ip + option var-prefix iprep + timeout hello 2s + timeout idle 2m + timeout processing 10ms + use-backend agents + log global + option async + +spoe-message check-client-ip + args ip=src + event on-client-session if ! { src -f /etc/haproxy/whitelist.lst } + +spoe-group mygroup + messages mymessage diff --git a/e2e/tests/spoe/test.bats b/e2e/tests/spoe/test.bats new file mode 100644 index 00000000..53232b41 --- /dev/null +++ b/e2e/tests/spoe/test.bats @@ -0,0 +1,74 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version' + +load 'utils/_helpers' + +setup() { + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' + + # adding a spoe file case handled here + run dpa_curl_file_upload POST "$_SPOE_FILES_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/spoefile_example.cfg;filename=spoefile_example.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 + + assert dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example.cfg' +} + +@test "spoe: Get a list of spoefiles" { + resource_get "$_SPOE_FILES_BASE_PATH" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" '. | length')" 1 + assert_equal "$(get_json_path "$BODY" '.[0]')" "/etc/haproxy/spoe/spoefile_example.cfg" +} + +@test "spoe: Get a spoefile contents" { + run dpa_curl_download GET "$_SPOE_FILES_BASE_PATH/spoefile_example.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal "$SC" 200 + + assert dpa_diff_docker_file '/etc/haproxy/spoe/spoefile_example.cfg' "data/spoefile_example.cfg" +} + +@test "spoe: Try to get unavailable spoefile contents" { + resource_get "$_SPOE_FILES_BASE_PATH/not_here.cfg" + dpa_curl_status_body_safe '$output' + assert_equal "$SC" 404 +} + +@test "spoe: Delete a spoefile" { + resource_delete "$_SPOE_FILES_BASE_PATH/spoefile_example.cfg" + assert_equal "$SC" 204 + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' +} diff --git a/e2e/tests/spoe/utils/_helpers.bash b/e2e/tests/spoe/utils/_helpers.bash new file mode 100644 index 00000000..e403a085 --- /dev/null +++ b/e2e/tests/spoe/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SPOE_FILES_BASE_PATH="/services/haproxy/spoe/spoe_files" diff --git a/e2e/tests/spoe_agents/add.bats b/e2e/tests/spoe_agents/add.bats new file mode 100644 index 00000000..ab387453 --- /dev/null +++ b/e2e/tests/spoe_agents/add.bats @@ -0,0 +1,63 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' +load '../../libs/debug' + +setup() { + SPOE_FILE="spoefile_example.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example.cfg;filename=spoefile_example.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example.cfg' +} + +@test "spoe_agents: Add a spoe agent" { + PARENT_NAME="spoefile_example.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/agents" "data/post.json" "version=1" + assert_equal "$SC" 201 + + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/agents/post_agent1" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME"/data/post.json)" ".")" + + # refuse adding an existing spoe agent + SCOPE_NAME="%5Bip-reputation%5D" + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/agents" "/data/post.json" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 409 +} diff --git a/e2e/tests/spoe_agents/data/post.json b/e2e/tests/spoe_agents/data/post.json new file mode 100644 index 00000000..c51896a7 --- /dev/null +++ b/e2e/tests/spoe_agents/data/post.json @@ -0,0 +1,29 @@ +{ + "async": "enabled", + "continue-on-error": "enabled", + "dontlog-normal": "disabled", + "force-set-var": "enabled", + "groups": "mygroup", + "hello_timeout": 3000, + "idle_timeout": 14000, + "log": [ + { + "global": true + } + ], + "max-frame-size": 5, + "max-waiting-frames": 8, + "maxconnrate": 5000, + "maxerrrate": 3, + "messages": "msg1", + "name": "post_agent1", + "option_set-on-error": "seterr1", + "option_set-process-time": "setproc1", + "option_set-total-time": "settotalname1", + "option_var-prefix": "pref1", + "pipelining": "disabled", + "processing_timeout": 300, + "register-var-names": "regvarname1", + "send-frag-payload": "disabled", + "use-backend": "backend1" + } diff --git a/e2e/tests/spoe_agents/data/put.json b/e2e/tests/spoe_agents/data/put.json new file mode 100644 index 00000000..3d68cb93 --- /dev/null +++ b/e2e/tests/spoe_agents/data/put.json @@ -0,0 +1,28 @@ +{ + "async": "enabled", + "dontlog-normal": "enabled", + "engine-name": "engine2", + "groups": "mygroup", + "hello_timeout": 3000, + "idle_timeout": 14000, + "log": [ + { + "global": true + } + ], + "max-frame-size": 15, + "max-waiting-frames": 18, + "maxconnrate": 6000, + "maxerrrate": 4, + "messages": "msg2", + "name": "iprep-agent", + "option_set-on-error": "seterr2", + "option_set-process-time": "setproc2", + "option_set-total-time": "settotalname2", + "option_var-prefix": "pref2", + "pipelining": "enabled", + "processing_timeout": 600, + "register-var-names": "regvarname2", + "send-frag-payload": "disabled", + "use-backend": "backend2" + } diff --git a/e2e/tests/spoe_agents/data/spoefile_example.cfg b/e2e/tests/spoe_agents/data/spoefile_example.cfg new file mode 100644 index 00000000..499596e6 --- /dev/null +++ b/e2e/tests/spoe_agents/data/spoefile_example.cfg @@ -0,0 +1,2 @@ +# _version=1 +[ip-reputation] diff --git a/e2e/tests/spoe_agents/data/spoefile_example2.cfg b/e2e/tests/spoe_agents/data/spoefile_example2.cfg new file mode 100644 index 00000000..df142b17 --- /dev/null +++ b/e2e/tests/spoe_agents/data/spoefile_example2.cfg @@ -0,0 +1,35 @@ +# _version=1 +[ip-reputation] +spoe-agent iprep-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async + +spoe-message check-ip + args ip=src + event on-client-session if ! { src -f /etc/haproxy/blacklist.lst } + +spoe-group newgroup + messages message1 + +spoe-agent secondary + messages check-ip2 + option var-prefix iprep2 + timeout hello 25s + timeout idle 35m + +[my-agent] +spoe-agent my-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async diff --git a/e2e/tests/spoe_agents/delete.bats b/e2e/tests/spoe_agents/delete.bats new file mode 100644 index 00000000..32a882b0 --- /dev/null +++ b/e2e/tests/spoe_agents/delete.bats @@ -0,0 +1,60 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + run_only + + SPOE_FILE="spoefile_example2.cfg" + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_agents: Delete a spoe agent" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_delete "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents/iprep-agent" + assert_equal "$SC" 204 + + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents/iprep-agent" + dpa_curl_status_body '$output' + assert_equal "$SC" 404 +} + +@test "spoe_agents: Return an error when trying to delete non existing spoe agent" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_delete "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents/not-exists" + assert_equal $SC "404" +} diff --git a/e2e/tests/spoe_agents/get.bats b/e2e/tests/spoe_agents/get.bats new file mode 100644 index 00000000..c4bc52c1 --- /dev/null +++ b/e2e/tests/spoe_agents/get.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_agents: Get one spoe agent" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents/iprep-agent" + assert_equal "$SC" 200 + + assert_equal $(get_json_path "$BODY" ". | .[]") $(cat ${BATS_TEST_DIRNAME}/data/post.json) +} + +@test "spoe_agents: Return an error when trying to get non existing spoe agent" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents/not-exists" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/spoe_agents/list.bats b/e2e/tests/spoe_agents/list.bats new file mode 100644 index 00000000..7bfb2820 --- /dev/null +++ b/e2e/tests/spoe_agents/list.bats @@ -0,0 +1,49 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_agents: List all spoe agents" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 +} diff --git a/e2e/tests/spoe_agents/replace.bats b/e2e/tests/spoe_agents/replace.bats new file mode 100644 index 00000000..3c5b89d3 --- /dev/null +++ b/e2e/tests/spoe_agents/replace.bats @@ -0,0 +1,54 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_agents: Replace a spoe agent" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_put "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents/iprep-agent" "data/put.json" + assert_equal "$SC" 200 + + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/${SCOPE_NAME}/agents/iprep-agent" + assert_equal "$SC" 200 + + assert_equal $(get_json_path "${BODY}" ". | .[]") $(cat ${BATS_TEST_DIRNAME}/data/put.json) +} diff --git a/e2e/tests/spoe_agents/utils/_helpers.bash b/e2e/tests/spoe_agents/utils/_helpers.bash new file mode 100644 index 00000000..6620b779 --- /dev/null +++ b/e2e/tests/spoe_agents/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SPOE_BASE_PATH="/services/haproxy/spoe/spoe_files" diff --git a/e2e/tests/spoe_groups/add.bats b/e2e/tests/spoe_groups/add.bats new file mode 100644 index 00000000..f7a3f636 --- /dev/null +++ b/e2e/tests/spoe_groups/add.bats @@ -0,0 +1,61 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example.cfg;filename=spoefile_example.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example.cfg' +} + +@test "spoe_groups: Add a spoe group" { + PARENT_NAME="spoefile_example.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups" "data/post.json" + assert_equal "$SC" 201 + + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/group1" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ".")" "$(cat ${BATS_TEST_DIRNAME}/data/post.json)" + + # refuse adding an existing spoe group + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups" "/data/post.json" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 409 +} diff --git a/e2e/tests/spoe_groups/data/get.json b/e2e/tests/spoe_groups/data/get.json new file mode 100644 index 00000000..b4158b8c --- /dev/null +++ b/e2e/tests/spoe_groups/data/get.json @@ -0,0 +1,4 @@ +{ + "messages": "message1", + "name": "newgroup" +} diff --git a/e2e/tests/spoe_groups/data/post.json b/e2e/tests/spoe_groups/data/post.json new file mode 100644 index 00000000..d2fefdff --- /dev/null +++ b/e2e/tests/spoe_groups/data/post.json @@ -0,0 +1,4 @@ +{ + "messages": "msg1", + "name": "group1" +} diff --git a/e2e/tests/spoe_groups/data/put.json b/e2e/tests/spoe_groups/data/put.json new file mode 100644 index 00000000..5b778751 --- /dev/null +++ b/e2e/tests/spoe_groups/data/put.json @@ -0,0 +1,4 @@ +{ + "messages": "msg2", + "name": "newgroup" +} diff --git a/e2e/tests/spoe_groups/data/spoefile_example.cfg b/e2e/tests/spoe_groups/data/spoefile_example.cfg new file mode 100644 index 00000000..499596e6 --- /dev/null +++ b/e2e/tests/spoe_groups/data/spoefile_example.cfg @@ -0,0 +1,2 @@ +# _version=1 +[ip-reputation] diff --git a/e2e/tests/spoe_groups/data/spoefile_example2.cfg b/e2e/tests/spoe_groups/data/spoefile_example2.cfg new file mode 100644 index 00000000..df142b17 --- /dev/null +++ b/e2e/tests/spoe_groups/data/spoefile_example2.cfg @@ -0,0 +1,35 @@ +# _version=1 +[ip-reputation] +spoe-agent iprep-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async + +spoe-message check-ip + args ip=src + event on-client-session if ! { src -f /etc/haproxy/blacklist.lst } + +spoe-group newgroup + messages message1 + +spoe-agent secondary + messages check-ip2 + option var-prefix iprep2 + timeout hello 25s + timeout idle 35m + +[my-agent] +spoe-agent my-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async diff --git a/e2e/tests/spoe_groups/delete.bats b/e2e/tests/spoe_groups/delete.bats new file mode 100644 index 00000000..f6e6b0f2 --- /dev/null +++ b/e2e/tests/spoe_groups/delete.bats @@ -0,0 +1,59 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_groups: Delete a spoe group" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_delete "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/newgroup" + assert_equal "$SC" 204 + + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/newgroup" + assert_equal "$SC" 404 +} + +@test "spoe_groups: Return an error when trying to delete non existing spoe group" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_delete "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/not-exists" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/spoe_groups/get.bats b/e2e/tests/spoe_groups/get.bats new file mode 100644 index 00000000..e1cc203f --- /dev/null +++ b/e2e/tests/spoe_groups/get.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_groups: Get one spoe group" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/newgroup" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ".")" "$(cat "${BATS_TEST_DIRNAME}"/data/get.json)" +} + +@test "spoe_groups: Return an error when trying to get non existing spoe group" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/not-exists" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/spoe_groups/list.bats b/e2e/tests/spoe_groups/list.bats new file mode 100644 index 00000000..04e64f53 --- /dev/null +++ b/e2e/tests/spoe_groups/list.bats @@ -0,0 +1,51 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_groups: List all spoe groups" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ". | length")" 1 +} diff --git a/e2e/tests/spoe_groups/replace.bats b/e2e/tests/spoe_groups/replace.bats new file mode 100644 index 00000000..08866e54 --- /dev/null +++ b/e2e/tests/spoe_groups/replace.bats @@ -0,0 +1,54 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_groups: Replace a spoe group" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_put "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/newgroup" "data/put.json" + assert_equal "$SC" 200 + + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/groups/newgroup" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ".")" "$(cat ${BATS_TEST_DIRNAME}/data/put.json)" +} diff --git a/e2e/tests/spoe_groups/utils/_helpers.bash b/e2e/tests/spoe_groups/utils/_helpers.bash new file mode 100644 index 00000000..6620b779 --- /dev/null +++ b/e2e/tests/spoe_groups/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SPOE_BASE_PATH="/services/haproxy/spoe/spoe_files" diff --git a/e2e/tests/spoe_messages/add.bats b/e2e/tests/spoe_messages/add.bats new file mode 100644 index 00000000..6abd133c --- /dev/null +++ b/e2e/tests/spoe_messages/add.bats @@ -0,0 +1,61 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example.cfg;filename=spoefile_example.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example.cfg' +} + +@test "spoe_messages: Add a spoe message" { + PARENT_NAME="spoefile_example.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages" "data/post.json" + assert_equal "$SC" 201 + + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/message1" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ".")" "$(cat ${BATS_TEST_DIRNAME}/data/post.json)" + + # refuse adding an existing spoe message + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages" "/data/post.json" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 409 +} diff --git a/e2e/tests/spoe_messages/data/get.json b/e2e/tests/spoe_messages/data/get.json new file mode 100644 index 00000000..381edcd4 --- /dev/null +++ b/e2e/tests/spoe_messages/data/get.json @@ -0,0 +1,9 @@ +{ + "args": "ip=src", + "event": { + "cond": "if", + "cond_test": "! { src -f /etc/haproxy/blacklist.lst }", + "name": "on-client-session" + }, + "name": "check-ip" +} diff --git a/e2e/tests/spoe_messages/data/post.json b/e2e/tests/spoe_messages/data/post.json new file mode 100644 index 00000000..0eb81a5f --- /dev/null +++ b/e2e/tests/spoe_messages/data/post.json @@ -0,0 +1,16 @@ +{ + "acl": [ + { + "acl_name": "h_xff_exists", + "criterion": "req.hdr(X-Forwarded-For)", + "value": "-m found" + } + ], + "args": "ip=src", + "event": { + "cond": "unless", + "cond_test": "{ src -f /etc/haproxy/blacklist.lst }", + "name": "on-frontend-tcp-request" + }, + "name": "message1" +} diff --git a/e2e/tests/spoe_messages/data/put.json b/e2e/tests/spoe_messages/data/put.json new file mode 100644 index 00000000..beec7f70 --- /dev/null +++ b/e2e/tests/spoe_messages/data/put.json @@ -0,0 +1,16 @@ +{ + "acl": [ + { + "acl_name": "careful_ips", + "criterion": "src", + "value": "127.0.0.1/32" + } + ], + "args": "ip=src", + "event": { + "cond": "if", + "cond_test": "{ src -f /etc/haproxy/whitelist.lst }", + "name": "on-tcp-response" + }, + "name": "check-ip" +} diff --git a/e2e/tests/spoe_messages/data/spoefile_example.cfg b/e2e/tests/spoe_messages/data/spoefile_example.cfg new file mode 100644 index 00000000..499596e6 --- /dev/null +++ b/e2e/tests/spoe_messages/data/spoefile_example.cfg @@ -0,0 +1,2 @@ +# _version=1 +[ip-reputation] diff --git a/e2e/tests/spoe_messages/data/spoefile_example2.cfg b/e2e/tests/spoe_messages/data/spoefile_example2.cfg new file mode 100644 index 00000000..df142b17 --- /dev/null +++ b/e2e/tests/spoe_messages/data/spoefile_example2.cfg @@ -0,0 +1,35 @@ +# _version=1 +[ip-reputation] +spoe-agent iprep-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async + +spoe-message check-ip + args ip=src + event on-client-session if ! { src -f /etc/haproxy/blacklist.lst } + +spoe-group newgroup + messages message1 + +spoe-agent secondary + messages check-ip2 + option var-prefix iprep2 + timeout hello 25s + timeout idle 35m + +[my-agent] +spoe-agent my-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async diff --git a/e2e/tests/spoe_messages/delete.bats b/e2e/tests/spoe_messages/delete.bats new file mode 100644 index 00000000..240ceddf --- /dev/null +++ b/e2e/tests/spoe_messages/delete.bats @@ -0,0 +1,59 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_messages: Delete a spoe message" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_delete "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/check-ip" + assert_equal "$SC" 204 + + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/check-ip" + assert_equal "$SC" 404 +} + +@test "spoe_messages: Return an error when trying to delete non existing spoe message" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/not-exists" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/spoe_messages/get.bats b/e2e/tests/spoe_messages/get.bats new file mode 100644 index 00000000..4ddcec55 --- /dev/null +++ b/e2e/tests/spoe_messages/get.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_messages: Get one spoe message" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/check-ip" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ".")" "$(cat "${BATS_TEST_DIRNAME}"/data/get.json)" +} + +@test "spoe_messages: Return an error when trying to get non existing spoe message" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/not-exists" + assert_equal $SC 404 +} diff --git a/e2e/tests/spoe_messages/list.bats b/e2e/tests/spoe_messages/list.bats new file mode 100644 index 00000000..8638e66c --- /dev/null +++ b/e2e/tests/spoe_messages/list.bats @@ -0,0 +1,51 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_messages: List all spoe messages" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ". | length")" 1 +} diff --git a/e2e/tests/spoe_messages/replace.bats b/e2e/tests/spoe_messages/replace.bats new file mode 100644 index 00000000..140b4b70 --- /dev/null +++ b/e2e/tests/spoe_messages/replace.bats @@ -0,0 +1,54 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_messages: Replace a spoe message" { + PARENT_NAME="spoefile_example2.cfg" + SCOPE_NAME="%5Bip-reputation%5D" + resource_put "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/check-ip" "data/put.json" + assert_equal "$SC" 200 + + resource_get "$_SPOE_BASE_PATH/$PARENT_NAME/scopes/$SCOPE_NAME/messages/check-ip" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ".")" "$(cat ${BATS_TEST_DIRNAME}/data/put.json)" +} diff --git a/e2e/tests/spoe_messages/utils/_helpers.bash b/e2e/tests/spoe_messages/utils/_helpers.bash new file mode 100644 index 00000000..6620b779 --- /dev/null +++ b/e2e/tests/spoe_messages/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SPOE_BASE_PATH="/services/haproxy/spoe/spoe_files" diff --git a/e2e/tests/spoe_scopes/add.bats b/e2e/tests/spoe_scopes/add.bats new file mode 100644 index 00000000..6803fae1 --- /dev/null +++ b/e2e/tests/spoe_scopes/add.bats @@ -0,0 +1,69 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example.cfg;filename=spoefile_example.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example.cfg' +} + +@test "spoe_scopes: Add a spoe scope" { + PARENT_NAME="spoefile_example.cfg" + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes" "data/add_scope.txt" + assert_equal "$SC" 201 + + # refuse adding an existing spoe scope + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes" "/data/add_scope.txt" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 409 +} + +@test "spoe_scopes: Return an error when spoe file doesn't exists" { + PARENT_NAME="not_exists.cfg" + resource_post "$_SPOE_BASE_PATH/$PARENT_NAME/scopes" "data/add_scope.txt" + assert_equal "$SC" 500 +} + +@test "spoe_scopes: Return an error when version not matched" { + PARENT_NAME="spoefile_example.cfg" + run dpa_curl POST "$_SPOE_BASE_PATH/$PARENT_NAME/scopes&version=10000" "/data/new_scope.txt" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 404 +} diff --git a/e2e/tests/spoe_scopes/data/add_scope.txt b/e2e/tests/spoe_scopes/data/add_scope.txt new file mode 100644 index 00000000..e768f7d6 --- /dev/null +++ b/e2e/tests/spoe_scopes/data/add_scope.txt @@ -0,0 +1 @@ +"[new-scope]" diff --git a/e2e/tests/spoe_scopes/data/new_scope.txt b/e2e/tests/spoe_scopes/data/new_scope.txt new file mode 100644 index 00000000..e3403cbd --- /dev/null +++ b/e2e/tests/spoe_scopes/data/new_scope.txt @@ -0,0 +1 @@ +"[new-scope-2]" diff --git a/e2e/tests/spoe_scopes/data/spoefile_example.cfg b/e2e/tests/spoe_scopes/data/spoefile_example.cfg new file mode 100644 index 00000000..04f2e744 --- /dev/null +++ b/e2e/tests/spoe_scopes/data/spoefile_example.cfg @@ -0,0 +1,18 @@ +# _version=1 +[ip-reputation] +spoe-agent iprep-agent + messages check-client-ip + option var-prefix iprep + timeout hello 2s + timeout idle 2m + timeout processing 10ms + use-backend agents + log global + option async + +spoe-message check-client-ip + args ip=src + event on-client-session if ! { src -f /etc/haproxy/whitelist.lst } + +spoe-group mygroup + messages mymessage diff --git a/e2e/tests/spoe_scopes/data/spoefile_example2.cfg b/e2e/tests/spoe_scopes/data/spoefile_example2.cfg new file mode 100644 index 00000000..524b5314 --- /dev/null +++ b/e2e/tests/spoe_scopes/data/spoefile_example2.cfg @@ -0,0 +1,29 @@ +# _version=1 +[ip-reputation] +spoe-agent iprep-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async + +spoe-message check-ip + args ip=src + event on-client-session if ! { src -f /etc/haproxy/blacklist.lst } + +spoe-group newgroup + messages message1 + +[my-agent] +spoe-agent my-agent + messages check-ip + option var-prefix iprep + timeout hello 5s + timeout idle 5m + timeout processing 12ms + use-backend agents + log global + option async diff --git a/e2e/tests/spoe_scopes/delete.bats b/e2e/tests/spoe_scopes/delete.bats new file mode 100644 index 00000000..ec502212 --- /dev/null +++ b/e2e/tests/spoe_scopes/delete.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_scopes: Delete a spoe scope" { + PARENT_NAME="spoefile_example2.cfg" + resource_delete "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/%5Bip-reputation%5D" + assert_equal "$SC" 204 + + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/%5Bip-reputation%5D" + assert_equal "$SC" 404 +} + +@test "spoe_scopes: Return an error when trying to delete non existing spoe scope" { + PARENT_NAME="spoefile_example2.cfg" + resource_delete "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/%5Bnot-exists%5D" "spoe=spoefile_example2.cfg" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/spoe_scopes/get.bats b/e2e/tests/spoe_scopes/get.bats new file mode 100644 index 00000000..1b4d1694 --- /dev/null +++ b/e2e/tests/spoe_scopes/get.bats @@ -0,0 +1,56 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_scopes: Get one spoe scope" { + PARENT_NAME="spoefile_example2.cfg" + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/%5Bip-reputation%5D" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ".")" "[ip-reputation]" +} + +@test "spoe_scopes: Return an error when trying to get non existing spoe scope" { + PARENT_NAME="spoefile_example2.cfg" + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes/%5Bnot-exists%5D" "spoe=spoefile_example2.cfg" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/spoe_scopes/list.bats b/e2e/tests/spoe_scopes/list.bats new file mode 100644 index 00000000..5d3688f2 --- /dev/null +++ b/e2e/tests/spoe_scopes/list.bats @@ -0,0 +1,52 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load "../../libs/run_only" +load '../../libs/version_spoe' + +load 'utils/_helpers' + +setup() { + SPOE_FILE="spoefile_example2.cfg" + + run_only + + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example2.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example2.cfg;filename=spoefile_example2.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example2.cfg' +} + +@test "spoe_scopes: List all spoe scopes" { + PARENT_NAME="spoefile_example2.cfg" + resource_get "$_SPOE_BASE_PATH/${PARENT_NAME}/scopes" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "${BODY}" ". | .[] | select( contains(\"[ip-reputation]\") )")" "[ip-reputation]" + assert_equal "$(get_json_path "${BODY}" ". | .[] | select( contains(\"[my-agent]\") )")" "[my-agent]" +} diff --git a/e2e/tests/spoe_scopes/utils/_helpers.bash b/e2e/tests/spoe_scopes/utils/_helpers.bash new file mode 100644 index 00000000..6620b779 --- /dev/null +++ b/e2e/tests/spoe_scopes/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SPOE_BASE_PATH="/services/haproxy/spoe/spoe_files" diff --git a/e2e/tests/spoe_version/data/spoefile_example.cfg b/e2e/tests/spoe_version/data/spoefile_example.cfg new file mode 100644 index 00000000..fc553846 --- /dev/null +++ b/e2e/tests/spoe_version/data/spoefile_example.cfg @@ -0,0 +1,9 @@ +# _version=12 +[ip-reputation] +spoe-agent iprep-agent + messages check-ip + option var-prefix iprep + +spoe-message check-ip + args ip=src + event on-client-session if ! { src -f /etc/haproxy/blacklist.lst } diff --git a/e2e/tests/spoe_version/tests.bats b/e2e/tests/spoe_version/tests.bats new file mode 100644 index 00000000..e33183dd --- /dev/null +++ b/e2e/tests/spoe_version/tests.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" + +load 'utils/_helpers' + +setup() { + + SPOE_FILE="spoefile_example.cfg" + refute dpa_docker_exec 'ls /etc/haproxy/spoe/spoefile_example.cfg' + + run dpa_curl_file_upload POST "/services/haproxy/spoe/spoe_files" "@${BATS_TEST_DIRNAME}/data/spoefile_example.cfg;filename=spoefile_example.cfg" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 +} + +teardown() { + run dpa_docker_exec 'rm -rf /etc/haproxy/spoe/spoefile_example.cfg' +} + +@test "spoe_version: Get a spoe version" { + PARENT_NAME="spoefile_example.cfg" + run dpa_curl GET "$_SPOE_BASE_PATH/$PARENT_NAME/version" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 200 + + assert_equal $(get_json_path "${BODY}" ".") 12 +} + +@test "spoe_version: Return error when getting version for non existing spoe transaction" { + PARENT_NAME="spoefile_example.cfg" + run dpa_curl GET "$_SPOE_BASE_PATH/$PARENT_NAME/version?transaction_id=263166c2-3093-40ff-a750-4a4d114dfd99" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 400 +} diff --git a/e2e/tests/spoe_version/utils/_helpers.bash b/e2e/tests/spoe_version/utils/_helpers.bash new file mode 100644 index 00000000..0974ed9a --- /dev/null +++ b/e2e/tests/spoe_version/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_SPOE_BASE_PATH="/services/haproxy/spoe" diff --git a/e2e/tests/ssl_front_use/data/3.pem b/e2e/tests/ssl_front_use/data/3.pem new file mode 100644 index 00000000..1fbe4790 --- /dev/null +++ b/e2e/tests/ssl_front_use/data/3.pem @@ -0,0 +1,79 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/ssl_front_use/data/haproxy.cfg b/e2e/tests/ssl_front_use/data/haproxy.cfg new file mode 100644 index 00000000..99922e0d --- /dev/null +++ b/e2e/tests/ssl_front_use/data/haproxy.cfg @@ -0,0 +1,33 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +frontend front1 + #bind ip:port + mode http + option http-server-close diff --git a/e2e/tests/ssl_front_use/data/post.json b/e2e/tests/ssl_front_use/data/post.json new file mode 100644 index 00000000..51bbce48 --- /dev/null +++ b/e2e/tests/ssl_front_use/data/post.json @@ -0,0 +1,5 @@ +{ + "certificate": "/etc/haproxy/ssl/cert.pem", + "allow_0rtt": true, + "no_alpn": true +} diff --git a/e2e/tests/ssl_front_use/data/put.json b/e2e/tests/ssl_front_use/data/put.json new file mode 100644 index 00000000..760b8a6d --- /dev/null +++ b/e2e/tests/ssl_front_use/data/put.json @@ -0,0 +1,6 @@ +{ + "certificate": "/etc/haproxy/ssl/cert.pem", + "allow_0rtt": false, + "no_alpn": true, + "verify": "none" +} diff --git a/e2e/tests/ssl_front_use/test.bats b/e2e/tests/ssl_front_use/test.bats new file mode 100644 index 00000000..19a3f78a --- /dev/null +++ b/e2e/tests/ssl_front_use/test.bats @@ -0,0 +1,63 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +cert=/etc/haproxy/ssl/cert.pem + +@test "ssl_front_uses: get/create/modify/delete (>=3.2)" { + haproxy_version_ge "3.2" || skip + + run docker cp "${BATS_TEST_DIRNAME}/data/3.pem" "${DOCKER_CONTAINER_NAME}:$cert" + + resource_post "$(ssl_front_uses_path front1)" "data/post.json" + assert_equal "$SC" "202" + + resource_get "$(ssl_front_uses_path front1)" + assert_equal "$SC" "200" + assert_equal "$(get_json_path "$BODY" '.|length')" 1 + assert_equal "$(get_json_path "$BODY" '.[0].certificate')" "$cert" + assert_equal "$(get_json_path "$BODY" '.[0].allow_0rtt')" true + + resource_get "$(ssl_front_uses_path front1 0)" + assert_equal "$SC" "200" + assert_equal "$(get_json_path "$BODY" '.certificate')" "$cert" + assert_equal "$(get_json_path "$BODY" '.allow_0rtt')" true + + resource_put "$(ssl_front_uses_path front1 0)" "data/put.json" + assert_equal "$SC" "202" + assert_equal "$(get_json_path "$BODY" '.certificate')" "$cert" + assert_equal "$(get_json_path "$BODY" '.allow_0rtt')" null + assert_equal "$(get_json_path "$BODY" '.no_alpn')" true + assert_equal "$(get_json_path "$BODY" '.verify')" none + + resource_delete "$(ssl_front_uses_path front1 0)" + assert_equal "$SC" "202" + resource_get "$(ssl_front_uses_path front1)" + assert_equal "$SC" "200" + assert_equal "$(get_json_path "$BODY" '.|length')" 0 + + run docker exec "${DOCKER_CONTAINER_NAME}" rm $cert +} diff --git a/e2e/tests/ssl_front_use/utils/_helpers.bash b/e2e/tests/ssl_front_use/utils/_helpers.bash new file mode 100644 index 00000000..ce0be5f8 --- /dev/null +++ b/e2e/tests/ssl_front_use/utils/_helpers.bash @@ -0,0 +1,4 @@ +# /services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index} +ssl_front_uses_path() { + echo "/services/haproxy/configuration/frontends/${1:?}/ssl_front_uses${2:+/$2}" +} diff --git a/e2e/tests/storage_maps/data/haproxy.cfg b/e2e/tests/storage_maps/data/haproxy.cfg new file mode 100755 index 00000000..99ea86b3 --- /dev/null +++ b/e2e/tests/storage_maps/data/haproxy.cfg @@ -0,0 +1,41 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +frontend test_empty_storage_map + use_backend %[str(active),map(/etc/haproxy/maps/mapfile_empty.map)] + +frontend test_storage_maps + bind *:1337 crt + #use_backend %[str(active),map(/etc/haproxy/maps/mapfile_example2.map)] + use_backend %[str(active),map(/etc/haproxy/maps/mapfile_example.map)] + + default_backend test_maps + +backend test_storage_maps + server appx 127.0.0.1:8080 check disabled diff --git a/e2e/tests/storage_maps/mapfile_example.map b/e2e/tests/storage_maps/mapfile_example.map new file mode 100644 index 00000000..fbc96266 --- /dev/null +++ b/e2e/tests/storage_maps/mapfile_example.map @@ -0,0 +1,7 @@ +# A comment begins with a hash sign +static.example.com be_static +www.example.com be_static + +# You can add additional comments, but they must be on a new line +example.com be_static +api.example.com be_api diff --git a/e2e/tests/storage_maps/mapfile_example2.map b/e2e/tests/storage_maps/mapfile_example2.map new file mode 100644 index 00000000..6cc6403b --- /dev/null +++ b/e2e/tests/storage_maps/mapfile_example2.map @@ -0,0 +1,7 @@ +# A comment begins with a hash sign +static.example.com be_static +www.example.com be_static + +# You can add additional comments, but they must be on a new line +example.com be_api +api.example.com be_api diff --git a/e2e/tests/storage_maps/test.bats b/e2e/tests/storage_maps/test.bats new file mode 100644 index 00000000..84e82899 --- /dev/null +++ b/e2e/tests/storage_maps/test.bats @@ -0,0 +1,99 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "storage_maps: Add a mapfile" { + + refute dpa_docker_exec 'ls /etc/haproxy/maps/mapfile_example.map' + + run dpa_curl_file_upload POST "$_STORAGE_MAPS_BASE_PATH" "@${BATS_TEST_DIRNAME}/mapfile_example.map;filename=mapfile_example.map" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 + + assert_equal $(get_json_path "$BODY" '.storage_name') "mapfile_example.map" + + assert dpa_docker_exec 'ls /etc/haproxy/maps/mapfile_example.map' +} + +@test "storage_maps: Get a list of managed mapfiles" { + + # sometimes we can't establish a connection to the haproxy stat socket + # forcing haproxy to restart seems to fix that + assert dpa_docker_exec 'kill -s 12 1' + sleep 1 + + resource_get "$_STORAGE_MAPS_BASE_PATH/" + assert_equal "$SC" 200 + + assert_equal $(get_json_path "$BODY" '.|length') 1 + + assert_equal $(get_json_path "$BODY" '.[0].storage_name') "mapfile_example.map" +} + +@test "storage_maps: Get a mapfile contents" { + + run dpa_curl_download GET "$_STORAGE_MAPS_BASE_PATH/mapfile_example.map" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 200 + + assert dpa_diff_var_file '$BODY' 'mapfile_example.map' + + assert dpa_diff_docker_file '/etc/haproxy/maps/mapfile_example.map' "mapfile_example.map" +} + +@test "storage_maps: Try to get unavailable mapfile contents" { + run dpa_curl GET "/services/haproxy/storage/maps/not_here.map" + assert_success + dpa_curl_status_body_safe '$output' + assert_equal "$SC" 404 +} + +@test "storage_maps: Replace a mapfile contents" { + + run dpa_curl_text_plain PUT "$_STORAGE_MAPS_BASE_PATH/mapfile_example.map" "@${BATS_TEST_DIRNAME}/mapfile_example2.map" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 202 + + run dpa_curl_download GET "$_STORAGE_MAPS_BASE_PATH/mapfile_example.map" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 200 + + assert dpa_diff_var_file '$BODY' 'mapfile_example2.map' + + assert dpa_diff_docker_file '/etc/haproxy/maps/mapfile_example.map' "mapfile_example2.map" +} + +@test "storage_maps: Delete a mapfile" { + resource_delete "$_STORAGE_MAPS_BASE_PATH/mapfile_example.map" + assert_equal "$SC" 204 + + refute dpa_docker_exec 'ls /etc/haproxy/maps/mapfile_example.map' +} diff --git a/e2e/tests/storage_maps/test_with_conf.bats b/e2e/tests/storage_maps/test_with_conf.bats new file mode 100644 index 00000000..9c17375e --- /dev/null +++ b/e2e/tests/storage_maps/test_with_conf.bats @@ -0,0 +1,50 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "storage_maps: Refuse to delete still used ssl certificate file" { + run docker cp "${BATS_TEST_DIRNAME}/mapfile_example.map" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/maps/" + assert_success + + resource_delete "$_STORAGE_MAPS_BASE_PATH/mapfile_example.map" + assert_equal "$SC" 409 + + assert dpa_docker_exec 'ls /etc/haproxy/maps/mapfile_example.map' + + # clean up this test + assert dpa_docker_exec 'rm /etc/haproxy/maps/mapfile_example.map' +} + +@test "storage_maps: Allow to delete ssl certificate file referenced in comments" { + run docker cp "${BATS_TEST_DIRNAME}/mapfile_example2.map" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/maps/" + assert_success + + resource_delete "$_STORAGE_MAPS_BASE_PATH/mapfile_example2.map" + assert_equal "$SC" 204 + + refute dpa_docker_exec 'ls /etc/haproxy/maps/mapfile_example2.map' + + # clean up this test + run dpa_docker_exec 'rm /etc/haproxy/maps/mapfile_example2.map' +} diff --git a/e2e/tests/storage_maps/utils/_helpers.bash b/e2e/tests/storage_maps/utils/_helpers.bash new file mode 100644 index 00000000..b16fff73 --- /dev/null +++ b/e2e/tests/storage_maps/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_STORAGE_MAPS_BASE_PATH="/services/haproxy/storage/maps" diff --git a/e2e/tests/storage_ssl_certificates/data/1.pem b/e2e/tests/storage_ssl_certificates/data/1.pem new file mode 100644 index 00000000..cbd77a21 --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/data/1.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/storage_ssl_certificates/data/2.pem b/e2e/tests/storage_ssl_certificates/data/2.pem new file mode 100644 index 00000000..7236b82b --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/data/2.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/storage_ssl_certificates/data/3.pem b/e2e/tests/storage_ssl_certificates/data/3.pem new file mode 100644 index 00000000..1fbe4790 --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/data/3.pem @@ -0,0 +1,79 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/storage_ssl_certificates/data/4.pem b/e2e/tests/storage_ssl_certificates/data/4.pem new file mode 100644 index 00000000..1fbe4790 --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/data/4.pem @@ -0,0 +1,79 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/storage_ssl_certificates/data/haproxy.cfg b/e2e/tests/storage_ssl_certificates/data/haproxy.cfg new file mode 100755 index 00000000..75fc4f5a --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/data/haproxy.cfg @@ -0,0 +1,36 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin + +defaults mydefaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +frontend test_storage_ssl_certificates + # bind *:1337 crt /etc/haproxy/ssl/4.pem + bind *:1337 crt /etc/haproxy/ssl/3.pem + default_backend test_storage_ssl_certificates + +backend test_storage_ssl_certificates + server appx 127.0.0.1:8080 check disabled diff --git a/e2e/tests/storage_ssl_certificates/test.bats b/e2e/tests/storage_ssl_certificates/test.bats new file mode 100644 index 00000000..ce4d278e --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/test.bats @@ -0,0 +1,210 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load "../../libs/get_json_path" +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +setup() { + run docker cp "${BATS_TEST_DIRNAME}/data/3.pem" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/ssl/" + assert_success +} + +@test "storage_ssl_certificates: Add a ssl certificate file" { + run docker cp "${BATS_TEST_DIRNAME}/data/3.pem" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/ssl/" + assert_success + + refute dpa_docker_exec 'ls /etc/haproxy/ssl/1.pem' + pre_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + + run dpa_curl_file_upload POST "$_STORAGE_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=1.pem" + assert_success + + dpa_curl_status_body '$output' + + assert_equal $(get_json_path "$BODY" '.storage_name') "1.pem" + + assert dpa_docker_exec 'ls /etc/haproxy/ssl/1.pem' + + post_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + new_logs_count=$(( $pre_logs_count - $post_logs_count )) + [ "$new_logs_count" != 0 ] || new_logs_count=2 + + new_logs=$(docker logs dataplaneapi-e2e 2>&1 | tail -n $new_logs_count) + + #debug "new_logs: $new_logs" + if haproxy_version_ge "2.5" + then + # This is not true anymore since we push the cert + # via the runtime socket instead of reloading. + # assert echo -e "$new_logs" | grep -q "Loading success" + : + else + # assert echo -e "$new_logs" | head -n 1 | grep -q "Reexecuting Master process" + : + fi +} + +@test "storage_ssl_certificates: Get a list of managed ssl certificate files" { + resource_get "$_STORAGE_SSL_CERTS_BASE_PATH" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" '.|length')" 2 + assert_equal "$(get_json_path "$BODY" '.[0].storage_name')" "1.pem" +} + +@test "storage_ssl_certificates: Get a ssl certificate file contents" { + + run dpa_curl_download GET "$_STORAGE_SSL_CERTS_BASE_PATH/1.pem" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 200 + + assert_output --partial "1.pem" + + # we opted to not return the certificate contents (i.e. secret keys, just the identifier) + #assert dpa_diff_var_file '$BODY' "1.pem" +} + +@test "storage_ssl_certificates: Replace a ssl certificate file contents" { + run dpa_curl_text_plain PUT "$_STORAGE_SSL_CERTS_BASE_PATH/1.pem" "@${BATS_TEST_DIRNAME}/data/2.pem" + assert_success + + dpa_curl_status_body '$output' + assert_equal "$SC" 202 + + assert dpa_diff_docker_file '/etc/haproxy/ssl/1.pem' "data/2.pem" +} + +@test "storage_ssl_certificates: Replace a ssl certificate file contents with skip reload" { + + pre_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + + run dpa_curl_text_plain PUT "$_STORAGE_SSL_CERTS_BASE_PATH/1.pem?skip_reload=true" "@${BATS_TEST_DIRNAME}/data/2.pem" + assert_success + + dpa_curl_status_body '$output' + assert_equal "$SC" 200 + + # confirm haproxy wasn't reloaded or restarted + post_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + new_logs_count=$(( $pre_logs_count - $post_logs_count )) + assert [ $new_logs_count = 0 ] +} + +@test "storage_ssl_certificates: Delete a ssl certificate file" { + resource_delete "$_STORAGE_SSL_CERTS_BASE_PATH/1.pem" + assert_equal "$SC" 202 + + refute dpa_docker_exec 'ls /etc/haproxy/ssl/1.pem' +} + +@test "storage_ssl_certificates: Delete a ssl certificate file with force reload" { + #reupload cert file + run dpa_curl_file_upload POST "$_STORAGE_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=1.pem" + assert_success + + dpa_curl_status_body '$output' + + resource_delete "$_STORAGE_SSL_CERTS_BASE_PATH/1.pem" "force_reload=true" + assert_equal "$SC" 204 + + refute dpa_docker_exec 'ls /etc/haproxy/ssl/1.pem' +} + +@test "storage_ssl_certificates: Delete a ssl certificate file with skip reload" { + #reupload cert file + run dpa_curl_file_upload POST "$_STORAGE_SSL_CERTS_BASE_PATH" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=7.pem" + assert_success + + dpa_curl_status_body '$output' + assert_success + + resource_delete "$_STORAGE_SSL_CERTS_BASE_PATH/7.pem" "skip_reload=true" + assert_equal "$SC" 204 + + refute dpa_docker_exec 'ls /etc/haproxy/ssl/7.pem' +} + +@test "storage_ssl_certificates: Add a ssl certificate file with force reload" { + run docker cp "${BATS_TEST_DIRNAME}/data/3.pem" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/ssl/" + assert_success + + refute dpa_docker_exec 'ls /etc/haproxy/ssl/1.pem?force_reload=true' + + pre_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + + run dpa_curl_file_upload POST "$_STORAGE_SSL_CERTS_BASE_PATH?force_reload=true" "@${BATS_TEST_DIRNAME}/data/1.pem;filename=1.pem" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 201 + + assert_equal $(get_json_path "$BODY" '.storage_name') "1.pem" + + assert dpa_docker_exec 'ls /etc/haproxy/ssl/1.pem' + + post_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + new_logs_count=$(( $pre_logs_count - $post_logs_count )) + + new_logs=$(docker logs dataplaneapi-e2e 2>&1 | tail -n $new_logs_count) + + echo -e "$new_logs" # this will help debugging if the test fails + if haproxy_version_ge "2.5" + then + assert echo -e "$new_logs" | grep -q "Loading success" + else + assert echo -e "$new_logs" | head -n 1 | grep -q "Reexecuting Master process" + fi +} + +@test "storage_ssl_certificates: Replace a ssl certificate file contents with force reload" { + run docker cp "${BATS_TEST_DIRNAME}/data/3.pem" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/ssl/" + assert_success + + pre_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + + run dpa_curl_text_plain PUT "$_STORAGE_SSL_CERTS_BASE_PATH/1.pem?force_reload=true" "@${BATS_TEST_DIRNAME}/data/2.pem" + assert_success + + dpa_curl_status_body '$output' + assert_equal $SC 200 + + sleep 3 + post_logs_count=$(docker logs dataplaneapi-e2e 2>&1 | wc -l) + new_logs_count=$(( $pre_logs_count - $post_logs_count )) + + new_logs=$(docker logs dataplaneapi-e2e 2>&1 | tail -n $new_logs_count) + + echo -e "debug->>>>$new_logs" # this will help debugging if the test fails + if haproxy_version_ge "2.5" + then + assert echo -e "$new_logs" | grep -q "Loading success" + else + assert echo -e "$new_logs" | head -n 1 | grep -q "Reexecuting Master process" + fi + + # clean up after the test + dpa_docker_exec 'rm /etc/haproxy/ssl/1.pem' +} diff --git a/e2e/tests/storage_ssl_certificates/test_with_conf.bats b/e2e/tests/storage_ssl_certificates/test_with_conf.bats new file mode 100644 index 00000000..d029ae58 --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/test_with_conf.bats @@ -0,0 +1,50 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "storage_ssl_certificates: Refuse to delete still used ssl certificate file" { + run docker cp "${BATS_TEST_DIRNAME}/data/3.pem" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/ssl/" + assert_success + + resource_delete "$_STORAGE_SSL_CERTS_BASE_PATH/3.pem" + assert_equal $SC 409 + + assert dpa_docker_exec 'ls /etc/haproxy/ssl/3.pem' + + # clean up this test + assert dpa_docker_exec 'rm /etc/haproxy/ssl/3.pem' +} + +@test "storage_ssl_certificates: Allow to delete ssl certificate file referenced in comments" { + run docker cp "${BATS_TEST_DIRNAME}/data/4.pem" "${DOCKER_CONTAINER_NAME}:/etc/haproxy/ssl/" + assert_success + + resource_delete "$_STORAGE_SSL_CERTS_BASE_PATH/4.pem" + assert_equal "$SC" 202 + + refute dpa_docker_exec 'ls /etc/haproxy/ssl/4.pem' + + # clean up this test + run dpa_docker_exec 'rm /etc/haproxy/ssl/4.pem' +} diff --git a/e2e/tests/storage_ssl_certificates/utils/_helpers.bash b/e2e/tests/storage_ssl_certificates/utils/_helpers.bash new file mode 100644 index 00000000..3e84c861 --- /dev/null +++ b/e2e/tests/storage_ssl_certificates/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_STORAGE_SSL_CERTS_BASE_PATH="/services/haproxy/storage/ssl_certificates" diff --git a/e2e/tests/storage_ssl_crt_lists/data/1.pem b/e2e/tests/storage_ssl_crt_lists/data/1.pem new file mode 100644 index 00000000..cbd77a21 --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/data/1.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/storage_ssl_crt_lists/data/2.pem b/e2e/tests/storage_ssl_crt_lists/data/2.pem new file mode 100644 index 00000000..7236b82b --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/data/2.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/storage_ssl_crt_lists/data/container/ssl/1.pem b/e2e/tests/storage_ssl_crt_lists/data/container/ssl/1.pem new file mode 100644 index 00000000..cbd77a21 --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/data/container/ssl/1.pem @@ -0,0 +1,79 @@ +-----BEGIN CERTIFICATE----- +MIICoDCCAYgCAhACMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCEludGVybTIu +MB4XDTIwMTEyNTEyMTIwNFoXDTIxMTEyNTEyMTIwNFowGDEWMBQGA1UEAwwNMS5l +eGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9kZegS +ZiBYvaad3jVyvWRFI8hKZbDXajy90Zk/Y4ugvwTZfwgUXqYjI3FqR2E5ggsEAMYC +sKI3Nil/RenE7Quw5YLybuVyQX4PLKHtNKZDlNzHFPwF/knG9kQDAzT0UhmihUPL +S8l6jeDELTwwiq1Npluy3K5EsqSKC7vlBae6f6qGBzFX0gw3yz8R7pfnAWyd4K8s +cWDMQtL2Bx6mEuJ4ER88sOkOHyYadSC8SbIEmMNHPpwVg4S+ypbQP7qStQN7cQud +XbRMV5gKu8E9n5kcVlahKMTdqKelAd33DQrHjDRIitgCzYA4LWpqSSuHlCMWKTLf +QOknoRTKD96W1bkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAeeAoG3xpVfAcA2ZN +aJA0uEB7ZH5BjhFsvmc1kEZylkEo6STVs1uTTvc9+v3PqzYANycbHy/3N0EUo5OX +X6tfo3SMn3c8MyZu/3960Vcs1YJApdC1P3FvHj25IQGz8qLgsmION1tijg0ySPQb +CYFXZ8T0ZYHA2X2QMieYiB9cNcmaL3Mlx04nf2Vfb+e/6kCWKkETlfSDIde9/J2M +kVAYLGWWnwWvfRvjEaZ7SZNWslBttUTEr4PiFkvdPU01UF3VAjkcAOcDzvueGdmT +d5Eg1BEWWmNBdT+Yg5hoy5Hx8R7H9ZcyoXnIMKCa9pOoIBIEk/hmcXj3smmjAMfO +wTO08w== +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/ZGXoEmYgWL2m +nd41cr1kRSPISmWw12o8vdGZP2OLoL8E2X8IFF6mIyNxakdhOYILBADGArCiNzYp +f0XpxO0LsOWC8m7lckF+Dyyh7TSmQ5TcxxT8Bf5JxvZEAwM09FIZooVDy0vJeo3g +xC08MIqtTaZbstyuRLKkigu75QWnun+qhgcxV9IMN8s/Ee6X5wFsneCvLHFgzELS +9gcephLieBEfPLDpDh8mGnUgvEmyBJjDRz6cFYOEvsqW0D+6krUDe3ELnV20TFeY +CrvBPZ+ZHFZWoSjE3ainpQHd9w0Kx4w0SIrYAs2AOC1qakkrh5QjFiky30DpJ6EU +yg/eltW5AgMBAAECggEARk1RpXpEqzMNjstEWSupZ9CBwUuaqOenrWIoQHtpTFui +btyZbdVVov8bQMjCKXNfUj6JLjLEwQE40uteOe1NCVNUKtJ0a7GZXv2h7mTcRwph +/urdyWlGK8F6qibVIblxAtuQygM99mcfAGXvG8HU3q28IsjDiPvRBuFyR/VrK12R +AY/cU5kADrRwLeswT8Clw7DhNhWEMcvAuS0R8liyXhQ8IG4WOZYIkBF3NI+GB3X+ +PE4SFZfk2CvbGSth1vvVKv7TAVczw81Ek6FJXV6A/XP3mFjuDqDU0NbEL4QQds2z +S/0JpEzx5LurN/UEIAyf/u+iEtPc56oUdAXJpHfWFQKBgQD86aOJDADg9F3HAdvG +Xkh60B6PZ63r6iw6wCsJD2olOl+XF7GdGXKGzCZQsz2fob1E4zhb8kduHNEPeBG7 +x5WyS7fqycRyz3oEyozz9KLcggfOU+yyuQ2kn/1O51/aiABlkinyj7ed/FL9jqeE +LdUM6194QEPgQnghjYMj6UcHpwKBgQDBuoFsgmA1OvtuSpijnZ/0ueI9Lkh8Quk2 +HusTKglP4KnuRCKm60PRXxxsFNxQgxuXhxEgBuMwJo1RO+CLjzh540pFnAN235QZ +F2FKio5hQT7olo8Weu6IEbLE5nzTDEcnuKZrmqEGFlsUXLBW3zYgn1PorWDRMvv6 +m+T4+NDjnwKBgDbKjwlDtnUFu8M/XdON3Xnt2JEMzxsK8mYP98LQuhgymz7qfSoh +tzQIykw1aKZKrexcpXsV8++hApGtW3oo9P9ZdBDDgXG2DSM4lmzLlPTcnsBOYjsd +6BzAJGqRqax4Rk266qeIBymM3pXb7+Ks4zkXTOmKUqok/E2YkM6Y3TCFAoGBALg2 +jscNmkpDkb4odMhwJB/jebvPfOGcBoKOF94bRMuNyEhmxcSPReebVz13AKAWa3BE +4QXhRrsMjahHFZffUkak2IUkey7YHs1VLBBjfEwCbL1iHSG1N4hvu9v7h4pvzGF6 +9dSwLpnJPEY6dPvGOIQAvRstcji7EFwXTT1p68flAoGANxFyWNiCC0LZ1t+4aS4j +cA7piBgu1bfc1LtL9wBj7LeCLW942S1yCcHd/YI3KMc8ZP8MkD2eKuMOCD48JVN7 +k1Pnh+V+/Bnin1owach62ckZjgubLQfbffiGmpEo3KqP4g8h7lst6Xbja1DatJ2Q +Ml0WvPvs/l61lp1CI36UuUA= +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIICsTCCAZmgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwEjEQMA4GA1UEAwwHUm9v +dC1jYTAeFw0yMDExMjUxMjEyMDRaFw0yMTExMjUxMjEyMDRaMBMxETAPBgNVBAMM +CEludGVybTEuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0/VPbQ2O +YERPdfjLsTn/eGu4R98iNOw3pwyOtxK5b7w/b3sheGvoA7iRdyk6TBQ6e6sGUnUj +fImyxNnWHRNBsX6NwwYk3DvFMvVgIfYi657m+7JaPYT+TcsLF223n2mDP3PHQe4B +etOdP81gC2c+l1cmPSduMwzi3Ze64gQ15PvyTjVcTRuVCFZIpdAZ2DLEFMviuc7O +vnxA+DFfN5Ve5gCJIEmxEtkHtolqZbhBIVPsfz5CofjD9bPm452ibssNoZgKU030 +9h2QPzvOhJ4iN2UDto2/Mq6xemEXxhVV7GyJ5iKtlnz1TYNAVPKkzhY+J9fnG/yT +/MOwREaq+/9AbwIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA +A4IBAQCyqfVs2oawxgymfI/Nk6aGG+EjG+aBixu9tO45hQT2mEyb5ztP49ZwFOpc ++ys1snq3gtol2r7J+Up96DJ3aF6U3OE3iDqbtfjosMmi+rQQDRK/hp6QcU5rQucY +hDiooiuajp7bhUgEdjhDW7GbV9yT1bA9WL5urFoGE0THUKLoMV4GCRQAQsodEx+B +yos50UBCHuSkeJWRGmR4lpyIprPJaQgC7E83FfLe5UDsP1bioDiW4RZk4sqryy/z +VJQNGgXYnlftf6J6WOPLdzU51R21yGCRjmNP0G9Vay9Wq7WOdDqjiQjWZyXWFf6H +bbp7qAgS2JLTieLZ3GXBg0RTi+lK +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICsjCCAZqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwEzERMA8GA1UEAwwISW50 +ZXJtMS4wHhcNMjAxMTI1MTIxMjA0WhcNMjExMTI1MTIxMjA0WjATMREwDwYDVQQD +DAhJbnRlcm0yLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKto0lJW +e+0+6u/gxG3NNfoqHWAMiDm+Ogcv1aIUTxTK8CO6dlwLTAMDg47wXgZSE+fpwtJf +OCV9uwUvoVrdBazPil13KTQKHkN3jV6TnrU92gJpb1uBCQwQQXvCaQeUrMNPC7h3 +lYaxAODH62B5Pl2PY/DXdaKNbsN0chOZmNl87FgtXH4/ITOqqHY/vLW4ikYbADHi +HLZOXFFV6VK6tNm5NgbKpDeUG5I5mjilZSfxnHHJAFIrIy19wK+wyPr9X+Eyph7Z +slYDDZ/+RRIEp3tNlaac+g+uv1CJZWdRcTb+q/fAMd/emL0ofg3XKRNtSwfDuDNh +z7i68VKL/6Xtd3cCAwEAAaMQMA4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsF +AAOCAQEAYUwKKDKMG0ZwUJwJuqXZfCrf+95t9aeb+ALcFw7gABrdSFY9VmDQj2wW +wl1afkV0jAREEnOtHJ0wioAhD86TUMoj99+UMEtp/r9QPH1XMClnCS0kp1M9ogCu +PlqFamJlKhIa3xvvKSamU6G7qlbVzi2y7x/SBhK/U/FDo4bElgwG6WVXsluOQ6fT +uUAJTqNfWcSdw2ntIGbwlbg1sco3a2JENB/5tyTSIWlwwUo6d+s2W3ZcNePWAPdr +gEAVV1yOWsb1OVse2NRye5lH3cc+x0O1XYzWiC6G3GWYUmoPhl50fsidrd6WQIt5 ++6MXQJQW+CgBnPiCdSfN58mxv49xJQ== +-----END CERTIFICATE----- diff --git a/e2e/tests/storage_ssl_crt_lists/data/container/ssl/crt-list.txt b/e2e/tests/storage_ssl_crt_lists/data/container/ssl/crt-list.txt new file mode 100644 index 00000000..c8c70afb --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/data/container/ssl/crt-list.txt @@ -0,0 +1 @@ +/etc/haproxy/ssl/1.pem diff --git a/e2e/tests/storage_ssl_crt_lists/data/crt-list2.txt b/e2e/tests/storage_ssl_crt_lists/data/crt-list2.txt new file mode 100644 index 00000000..45dda033 --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/data/crt-list2.txt @@ -0,0 +1 @@ +/etc/haproxy/ssl/1.pem \ No newline at end of file diff --git a/e2e/tests/storage_ssl_crt_lists/data/haproxy.cfg b/e2e/tests/storage_ssl_crt_lists/data/haproxy.cfg new file mode 100644 index 00000000..4ae98e2d --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/data/haproxy.cfg @@ -0,0 +1,32 @@ +# _version=42 + +global + log 127.0.0.1 local2 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + stats socket /var/lib/haproxy/stats level admin expose-fd listeners + +defaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +frontend fe_sitea + mode http + bind :443 ssl crt-list /etc/haproxy/ssl/crt-list.txt diff --git a/e2e/tests/storage_ssl_crt_lists/data/post.json b/e2e/tests/storage_ssl_crt_lists/data/post.json new file mode 100644 index 00000000..1e5b3fcb --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/data/post.json @@ -0,0 +1,5 @@ +{ + "sni_filter": [ "mysite.local" ], + "ssl_bind_config": "allow-0rtt alpn h2", + "file": "/etc/haproxy/ssl/1.pem" +} \ No newline at end of file diff --git a/e2e/tests/storage_ssl_crt_lists/test.bats b/e2e/tests/storage_ssl_crt_lists/test.bats new file mode 100644 index 00000000..06727c55 --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/test.bats @@ -0,0 +1,87 @@ +#!/usr/bin/env bats +# +# Copyright 2025 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load "../../libs/get_json_path" +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +# Doing all the tests in a single @tests runs faster. + +@test "storage crt-list files: all tests" { + # This is needed because docker cp cannot copy stuff + # to /etc/haproxy/ssl during setup for some reason. + dpa_docker_exec 'mv /ssl/* /etc/haproxy/ssl' + + assert dpa_docker_exec 'ls /etc/haproxy/ssl/crt-list.txt' + refute dpa_docker_exec 'ls /etc/haproxy/ssl/crt-list2.txt' + run dpa_curl_file_upload POST "$_STORAGE_SSL_CRT_LIST_PATH" "@$BATS_TEST_DIRNAME/data/crt-list2.txt;filename=crt-list2.txt" + assert_success + dpa_curl_status_body '$output' + assert_equal "$SC" 202 + assert_equal "$(get_json_path "$BODY" '.storage_name')" 'crt-list2.txt' + assert dpa_docker_exec 'ls /etc/haproxy/ssl/crt-list2.txt' + + run dpa_curl_text_plain PUT "$_STORAGE_SSL_CRT_LIST_PATH/crt-list2.txt" "@$BATS_TEST_DIRNAME/data/crt-list2.txt" + assert_success + dpa_curl_status_body '$output' + assert_equal "$SC" 202 + + resource_get "$_STORAGE_SSL_CRT_LIST_PATH" + assert_equal "$SC" 200 + # [{"description":"managed certificate list","file":"/etc/haproxy/ssl/crt-list2.txt","storage_name":"crt-list2.txt"}] + assert_equal "$(get_json_path "$BODY" '.[0].file')" '/etc/haproxy/ssl/crt-list.txt' + assert_equal "$(get_json_path "$BODY" '.|length')" 2 + + resource_get "$_STORAGE_SSL_CRT_LIST_PATH/crt-list2.txt" + test "$BODY" = "$(cat $BATS_TEST_DIRNAME/data/crt-list2.txt)" || fail + + resource_delete "$_STORAGE_SSL_CRT_LIST_PATH/crt-list2.txt" + assert_equal "$SC" 202 + + resource_get "$_STORAGE_SSL_CRT_LIST_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 1 +} + +@test "storage crt-list entries: all tests" { + dpa_docker_exec 'mv /ssl/* /etc/haproxy/ssl' + + resource_get "$_STORAGE_SSL_CRT_LIST_PATH/crt-list.txt/entries" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 1 + + resource_post "$_STORAGE_SSL_CRT_LIST_PATH/crt-list.txt/entries" "data/post.json" + assert_equal "$SC" 201 + assert_equal "$(get_json_path "$BODY" '.file')" '/etc/haproxy/ssl/1.pem' + + resource_get "$_STORAGE_SSL_CRT_LIST_PATH/crt-list.txt/entries" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 2 + + resource_delete "$_STORAGE_SSL_CRT_LIST_PATH/crt-list.txt/entries" "certificate=/etc/haproxy/ssl/1.pem&line_number=1" + assert_equal "$SC" 204 + + resource_get "$_STORAGE_SSL_CRT_LIST_PATH/crt-list.txt/entries" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" '.|length')" 1 +} diff --git a/e2e/tests/storage_ssl_crt_lists/utils/_helpers.bash b/e2e/tests/storage_ssl_crt_lists/utils/_helpers.bash new file mode 100644 index 00000000..ca97dc0b --- /dev/null +++ b/e2e/tests/storage_ssl_crt_lists/utils/_helpers.bash @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +_STORAGE_SSL_CRT_LIST_PATH="/services/haproxy/storage/ssl_crt_lists" diff --git a/e2e/tests/table/add.bats b/e2e/tests/table/add.bats new file mode 100644 index 00000000..c63be565 --- /dev/null +++ b/e2e/tests/table/add.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "table: Add a new table to peers" { + PARENT_NAME="mycluster" + resource_post "$_PEERS_BASE_PATH/$PARENT_NAME/tables" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} diff --git a/e2e/tests/table/data/haproxy.cfg b/e2e/tests/table/data/haproxy.cfg new file mode 100644 index 00000000..740d792a --- /dev/null +++ b/e2e/tests/table/data/haproxy.cfg @@ -0,0 +1,30 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +peers mycluster + enabled + table t1 type string len 1000 size 200k expire 5m nopurge store gpc0,conn_rate(30s) diff --git a/e2e/tests/table/data/post.json b/e2e/tests/table/data/post.json new file mode 100644 index 00000000..71dcec6c --- /dev/null +++ b/e2e/tests/table/data/post.json @@ -0,0 +1,6 @@ +{ + "name": "t2", + "type": "ip", + "size": "2k", + "store": "gpc0,gpc1,conn_rate(30s)" +} diff --git a/e2e/tests/table/data/put.json b/e2e/tests/table/data/put.json new file mode 100644 index 00000000..ab2f285b --- /dev/null +++ b/e2e/tests/table/data/put.json @@ -0,0 +1,6 @@ +{ + "name": "t1", + "type": "ip", + "size": "2m", + "store": "gpc0,gpc1,conn_rate(30s)" +} diff --git a/e2e/tests/table/delete.bats b/e2e/tests/table/delete.bats new file mode 100644 index 00000000..e0c8348c --- /dev/null +++ b/e2e/tests/table/delete.bats @@ -0,0 +1,38 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "table: Delete a table from peers" { + # + # Deleting first + # + PARENT_NAME="mycluster" + resource_delete "$_PEERS_BASE_PATH/$PARENT_NAME/tables/t1" "force_reload=true" + assert_equal "$SC" 204 + # + # Not found + # + resource_delete "$_PEERS_BASE_PATH/$PARENT_NAME/tables/t1" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/table/get.bats b/e2e/tests/table/get.bats new file mode 100644 index 00000000..cb7cd738 --- /dev/null +++ b/e2e/tests/table/get.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "table: Return one table from peers" { + PARENT_NAME="mycluster" + resource_get "$_PEERS_BASE_PATH/$PARENT_NAME/tables/t1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "t1" + assert_equal "$(get_json_path "$BODY" ".type")" "string" + assert_equal "$(get_json_path "$BODY" ".type_len")" "1000" + assert_equal "$(get_json_path "$BODY" ".size")" "200k" + assert_equal "$(get_json_path "$BODY" ".expire")" "5m" + assert_equal "$(get_json_path "$BODY" ".no_purge")" "true" + assert_equal "$(get_json_path "$BODY" ".store")" "gpc0,conn_rate(30s)" +} diff --git a/e2e/tests/table/list.bats b/e2e/tests/table/list.bats new file mode 100644 index 00000000..1d56cf37 --- /dev/null +++ b/e2e/tests/table/list.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "table: Return an array of all tables from peers" { + PARENT_NAME="mycluster" + resource_get "$_PEERS_BASE_PATH/$PARENT_NAME/tables" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".[0].name")" "t1" + assert_equal "$(get_json_path "$BODY" ".[0].type")" "string" + assert_equal "$(get_json_path "$BODY" ".[0].type_len")" "1000" + assert_equal "$(get_json_path "$BODY" ".[0].size")" "200k" + assert_equal "$(get_json_path "$BODY" ".[0].expire")" "5m" + assert_equal "$(get_json_path "$BODY" ".[0].no_purge")" "true" + assert_equal "$(get_json_path "$BODY" ".[0].store")" "gpc0,conn_rate(30s)" +} diff --git a/e2e/tests/table/replace.bats b/e2e/tests/table/replace.bats new file mode 100644 index 00000000..53b32caa --- /dev/null +++ b/e2e/tests/table/replace.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2023 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "table: Replace table values in peers" { + PARENT_NAME="mycluster" + resource_put "$_PEERS_BASE_PATH/$PARENT_NAME/tables/t1" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + resource_get "$_PEERS_BASE_PATH/$PARENT_NAME/tables/t1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".name")" "t1" + assert_equal "$(get_json_path "$BODY" ".type")" "ip" + assert_equal "$(get_json_path "$BODY" ".size")" "2m" + assert_equal "$(get_json_path "$BODY" ".store")" "gpc0,gpc1,conn_rate(30s)" +} diff --git a/e2e/tests/table/utils/_helpers.bash b/e2e/tests/table/utils/_helpers.bash new file mode 100644 index 00000000..bbc27c11 --- /dev/null +++ b/e2e/tests/table/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_PEERS_BASE_PATH="/services/haproxy/configuration/peers" diff --git a/e2e/tests/tcp_checks/add.bats b/e2e/tests/tcp_checks/add.bats new file mode 100644 index 00000000..e27032e4 --- /dev/null +++ b/e2e/tests/tcp_checks/add.bats @@ -0,0 +1,109 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' +load '../../libs/get_json_path' + +load 'utils/_helpers' + +@test "tcp_checks: Add a new connect TCP check to a backend" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/connect.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "tcp_checks: Add a new send TCP check to a backend" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/send.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "tcp_checks: Add a new expect TCP check to a backend" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/expect.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "tcp_checks: Add a new send-binary TCP check to a backend" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/send_binary.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "tcp_checks: Add a new comment TCP check to a backend" { + if haproxy_version_ge "2.2" + then + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/comment.json" "force_reload=true" + assert_equal "$SC" 201 + fi +} + +@test "tcp_checks: Add a new send-lf TCP check to a backend" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/send_lf.json" "force_reload=true" + if haproxy_version_ge "2.2" + then + assert_equal "$SC" 201 + else + assert_equal "$SC" 400 + fi +} + +@test "tcp_checks: Add a new send-binary-lf TCP check to a backend" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/send_binary_lf.json" "force_reload=true" + if haproxy_version_ge "2.2" + then + assert_equal "$SC" 201 + else + assert_equal "$SC" 400 + fi +} + +@test "tcp_checks: Add a new set-var and uset-var TCP check to a backend" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/set_var.json" "force_reload=true" + if haproxy_version_ge "2.2" + then + assert_equal "$SC" 201 + else + assert_equal "$SC" 400 + fi + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/unset_var.json" "force_reload=true" + if haproxy_version_ge "2.2" + then + assert_equal "$SC" 201 + else + assert_equal "$SC" 400 + fi +} + +@test "tcp_checks: Add an empty TCP check to a backend/0" { + PARENT_NAME="test_backend_add" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/empty.json" "force_reload=true" + if haproxy_version_ge "2.2" + then + assert_equal "$SC" 422 + else + assert_equal "$SC" 422 + fi +} diff --git a/e2e/tests/tcp_checks/data/comment.json b/e2e/tests/tcp_checks/data/comment.json new file mode 100644 index 00000000..32777650 --- /dev/null +++ b/e2e/tests/tcp_checks/data/comment.json @@ -0,0 +1,4 @@ +{ + "action": "comment", + "check_comment": "a check comment" +} diff --git a/e2e/tests/tcp_checks/data/connect.json b/e2e/tests/tcp_checks/data/connect.json new file mode 100644 index 00000000..f57ca0c1 --- /dev/null +++ b/e2e/tests/tcp_checks/data/connect.json @@ -0,0 +1,3 @@ +{ + "action": "connect" +} diff --git a/e2e/tests/tcp_checks/data/empty.json b/e2e/tests/tcp_checks/data/empty.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/e2e/tests/tcp_checks/data/empty.json @@ -0,0 +1 @@ +{} diff --git a/e2e/tests/tcp_checks/data/expect.json b/e2e/tests/tcp_checks/data/expect.json new file mode 100644 index 00000000..f2c479b4 --- /dev/null +++ b/e2e/tests/tcp_checks/data/expect.json @@ -0,0 +1,5 @@ +{ + "action": "expect", + "match": "string", + "pattern": "role:master" + } diff --git a/e2e/tests/tcp_checks/data/haproxy.cfg b/e2e/tests/tcp_checks/data/haproxy.cfg new file mode 100644 index 00000000..79b99a37 --- /dev/null +++ b/e2e/tests/tcp_checks/data/haproxy.cfg @@ -0,0 +1,56 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option httpchk + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + tcp-check comment acomment + retries 3 + +backend test_backend_add + mode tcp + option tcp-check + +backend test_backend_replace + mode tcp + option tcp-check + tcp-check connect + tcp-check send PING\r\n + tcp-check expect string +PONG + tcp-check send-binary 50494e470d0a + +backend test_backend_get + mode tcp + option tcp-check + tcp-check connect + tcp-check send PING\r\n + tcp-check expect string +PONG + tcp-check send-binary 50494e470d0a + +backend test_backend_delete + mode tcp + option tcp-check + tcp-check connect + tcp-check send PING\r\n + tcp-check expect string +PONG + tcp-check send-binary 50494e470d0a diff --git a/e2e/tests/tcp_checks/data/put.json b/e2e/tests/tcp_checks/data/put.json new file mode 100644 index 00000000..443db466 --- /dev/null +++ b/e2e/tests/tcp_checks/data/put.json @@ -0,0 +1,4 @@ +{ + "action": "comment", + "check_comment": "test-comment-replace" + } diff --git a/e2e/tests/tcp_checks/data/replace/connect.json b/e2e/tests/tcp_checks/data/replace/connect.json new file mode 100644 index 00000000..d5887e0c --- /dev/null +++ b/e2e/tests/tcp_checks/data/replace/connect.json @@ -0,0 +1,4 @@ +{ + "action": "connect", + "check_comment": "replace" +} diff --git a/e2e/tests/tcp_checks/data/replace/expect.json b/e2e/tests/tcp_checks/data/replace/expect.json new file mode 100644 index 00000000..12a4cedc --- /dev/null +++ b/e2e/tests/tcp_checks/data/replace/expect.json @@ -0,0 +1,5 @@ +{ + "action": "expect", + "match": "string", + "pattern": "replace" +} diff --git a/e2e/tests/tcp_checks/data/replace/replace-all.json b/e2e/tests/tcp_checks/data/replace/replace-all.json new file mode 100644 index 00000000..63659a6c --- /dev/null +++ b/e2e/tests/tcp_checks/data/replace/replace-all.json @@ -0,0 +1,23 @@ +[ + { + "action": "connect", + "check_comment": "replace" + }, + { + "action": "comment", + "check_comment": "replace" + }, + { + "action": "send", + "data": "replace" + }, + { + "action": "send-binary", + "hex_string": "50494e470d0a12" + }, + { + "action": "expect", + "match": "string", + "pattern": "replace" + } +] diff --git a/e2e/tests/tcp_checks/data/replace/send.json b/e2e/tests/tcp_checks/data/replace/send.json new file mode 100644 index 00000000..96703685 --- /dev/null +++ b/e2e/tests/tcp_checks/data/replace/send.json @@ -0,0 +1,4 @@ +{ + "action": "send", + "data": "replace" + } diff --git a/e2e/tests/tcp_checks/data/replace/send_binary.json b/e2e/tests/tcp_checks/data/replace/send_binary.json new file mode 100644 index 00000000..b7c9e2fc --- /dev/null +++ b/e2e/tests/tcp_checks/data/replace/send_binary.json @@ -0,0 +1,4 @@ +{ + "action": "send-binary", + "hex_string": "50494e470d0a12" +} diff --git a/e2e/tests/tcp_checks/data/send.json b/e2e/tests/tcp_checks/data/send.json new file mode 100644 index 00000000..4e701089 --- /dev/null +++ b/e2e/tests/tcp_checks/data/send.json @@ -0,0 +1,4 @@ +{ + "action": "send", + "data": "PING\r\n" + } diff --git a/e2e/tests/tcp_checks/data/send_binary.json b/e2e/tests/tcp_checks/data/send_binary.json new file mode 100644 index 00000000..88033dce --- /dev/null +++ b/e2e/tests/tcp_checks/data/send_binary.json @@ -0,0 +1,4 @@ +{ + "action": "send-binary", + "hex_string": "50494e470d0a" + } diff --git a/e2e/tests/tcp_checks/data/send_binary_lf.json b/e2e/tests/tcp_checks/data/send_binary_lf.json new file mode 100644 index 00000000..d52d1081 --- /dev/null +++ b/e2e/tests/tcp_checks/data/send_binary_lf.json @@ -0,0 +1,4 @@ +{ + "action": "send-binary-lf", + "hex_fmt": "hex-fmt" +} diff --git a/e2e/tests/tcp_checks/data/send_binary_malformed.json b/e2e/tests/tcp_checks/data/send_binary_malformed.json new file mode 100644 index 00000000..363e9c89 --- /dev/null +++ b/e2e/tests/tcp_checks/data/send_binary_malformed.json @@ -0,0 +1,3 @@ +{ + "action": "send-binary" + } diff --git a/e2e/tests/tcp_checks/data/send_lf.json b/e2e/tests/tcp_checks/data/send_lf.json new file mode 100644 index 00000000..9a55b014 --- /dev/null +++ b/e2e/tests/tcp_checks/data/send_lf.json @@ -0,0 +1,4 @@ +{ + "action": "send-lf", + "fmt": "fmt-replaced" + } diff --git a/e2e/tests/tcp_checks/data/send_lf_malformed.json b/e2e/tests/tcp_checks/data/send_lf_malformed.json new file mode 100644 index 00000000..4d1010d1 --- /dev/null +++ b/e2e/tests/tcp_checks/data/send_lf_malformed.json @@ -0,0 +1,3 @@ +{ + "action": "send-lf" + } diff --git a/e2e/tests/tcp_checks/data/set_var.json b/e2e/tests/tcp_checks/data/set_var.json new file mode 100644 index 00000000..e22dbef0 --- /dev/null +++ b/e2e/tests/tcp_checks/data/set_var.json @@ -0,0 +1,6 @@ +{ + "action": "set-var", + "var_scope": "check", + "var_name": "port", + "var_expr": "int(1234)" +} diff --git a/e2e/tests/tcp_checks/data/unset_var.json b/e2e/tests/tcp_checks/data/unset_var.json new file mode 100644 index 00000000..82a2d666 --- /dev/null +++ b/e2e/tests/tcp_checks/data/unset_var.json @@ -0,0 +1,5 @@ +{ + "action": "unset-var", + "var_scope": "check", + "var_name": "port" +} diff --git a/e2e/tests/tcp_checks/delete.bats b/e2e/tests/tcp_checks/delete.bats new file mode 100644 index 00000000..1cdd9884 --- /dev/null +++ b/e2e/tests/tcp_checks/delete.bats @@ -0,0 +1,55 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_checks: Delete some TCP checks" { + PARENT_NAME="test_backend_delete" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/1" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/1000" "force_reload=true" + assert_equal "$SC" 404 + + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_checks/1000" "force_reload=true" + assert_equal "$SC" 404 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 +} + +@test "tcp_checks: Delete a non existant backend TCP check" { + PARENT_NAME="test_backend_delete" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/1000" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "tcp_checks: Delete a non existant frontend TCP check" { + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_checks/1000" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/tcp_checks/get.bats b/e2e/tests/tcp_checks/get.bats new file mode 100644 index 00000000..02fd1d8d --- /dev/null +++ b/e2e/tests/tcp_checks/get.bats @@ -0,0 +1,71 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_checks: Return connect TCP check from a backend" { + PARENT_NAME="test_backend_get" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "connect" +} + +@test "tcp_checks: Return send TCP check from a backend" { + PARENT_NAME="test_backend_get" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "send" +} + +@test "tcp_checks: Return expect TCP check from a backend" { + PARENT_NAME="test_backend_get" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/2" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "expect" +} + +@test "tcp_checks: Return send-binary TCP check from a backend" { + PARENT_NAME="test_backend_get" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/3" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "send-binary" + assert_equal "$(get_json_path "$BODY" ".hex_string")" "50494e470d0a" +} + +@test "tcp_checks: Return a non existing TCP check from a backend" { + PARENT_NAME="test_backend_get" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/1000" + assert_equal "$SC" 404 +} + +@test "tcp_checks: Return a TCP check from a non existing backend" { + PARENT_NAME="unknown" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" + assert_equal "$SC" 400 +} + +@test "tcp_checks: Return a TCP check from a frontend" { + PARENT_NAME="unknown" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/tcp_checks/list.bats b/e2e/tests/tcp_checks/list.bats new file mode 100644 index 00000000..2b8473a0 --- /dev/null +++ b/e2e/tests/tcp_checks/list.bats @@ -0,0 +1,32 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_checks: Return an array of all TCP checks from a backend" { + PARENT_NAME="test_backend_get" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "${BODY}" ". | length")" 4 +} diff --git a/e2e/tests/tcp_checks/replace.bats b/e2e/tests/tcp_checks/replace.bats new file mode 100644 index 00000000..e1bda1bf --- /dev/null +++ b/e2e/tests/tcp_checks/replace.bats @@ -0,0 +1,70 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_checks: Replace a TCP check connect" { + PARENT_NAME="test_backend_replace" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/0" "data/replace/connect.json" "force_reload=true" + assert_equal "$SC" 200 +} + +@test "tcp_checks: Replace a TCP check send" { + PARENT_NAME="test_backend_replace" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/1" "data/replace/send.json" "force_reload=true" + assert_equal "$SC" 200 +} + +@test "tcp_checks: Replace a TCP check expect" { + PARENT_NAME="test_backend_replace" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/2" "data/replace/expect.json" "force_reload=true" + assert_equal "$SC" 200 +} + +@test "tcp_checks: Replace a TCP check send-binary" { + PARENT_NAME="test_backend_replace" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks/3" "data/replace/send_binary.json" "force_reload=true" + assert_equal "$SC" 200 +} + +@test "tcp_checks: replace all TCP Checks for a backend" { + PARENT_NAME="test_backend_replace" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks" "data/replace/replace-all.json" + assert_equal "$SC" 202 + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_checks" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 5 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace/replace-all.json")" ".")" + +} + +@test "tcp_checks: replace all TCP Checks for a defaults" { + PARENT_NAME="mydefaults" + resource_put "$_DEFAULTS_BASE_PATH/$PARENT_NAME/tcp_checks" "data/replace/replace-all.json" + assert_equal "$SC" 202 + resource_get "$_DEFAULTS_BASE_PATH/$PARENT_NAME/tcp_checks" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 5 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace/replace-all.json")" ".")" + +} diff --git a/e2e/tests/tcp_checks/utils/_helpers.bash b/e2e/tests/tcp_checks/utils/_helpers.bash new file mode 100644 index 00000000..96e8ac56 --- /dev/null +++ b/e2e/tests/tcp_checks/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_TCP_CHECKS_BASE_PATH="/services/haproxy/configuration/tcp_checks" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_DEFAULTS_BASE_PATH="/services/haproxy/configuration/defaults" diff --git a/e2e/tests/tcp_request_rules/add.bats b/e2e/tests/tcp_request_rules/add.bats new file mode 100644 index 00000000..f3bbff94 --- /dev/null +++ b/e2e/tests/tcp_request_rules/add.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_request_rules: Add a new TCP Request Rule to frontend" { + PARENT_NAME="test_frontend" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/accept.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "tcp_request_rules: Add a new TCP Request Rule to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/accept.json" "force_reload=true" + assert_equal "$SC" 201 +} diff --git a/e2e/tests/tcp_request_rules/add_2.8.bats b/e2e/tests/tcp_request_rules/add_2.8.bats new file mode 100644 index 00000000..655ef6ef --- /dev/null +++ b/e2e/tests/tcp_request_rules/add_2.8.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + + +## tune.stick-counters is a haproxy >= 2.8 global parameter +@test "tcp_request_rules: Add a new TCP Request Rule track-sc to backend" { + if haproxy_version_ge "2.8" + then + # Using new track-sc with track_sc_stick_counter + PARENT_NAME="test_sticksc" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/post-track-sc.json" "force_reload=true" + assert_equal "$SC" 201 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".type")" "content" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_stick_counter")" 5 + fi +} + +@test "tcp_request_rules: Fail - Add a new TCP Request Rule track-sc to backend - when track_sc_stick_counter is missing" { + if haproxy_version_ge "2.8" + then + # Using new track-sc with track_sc_stick_counter + # Fail due to missing track_sc_stick_counter + PARENT_NAME="test_sticksc" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/post-track-sc-fail.json" "force_reload=true" + assert_equal "$SC" 400 + fi +} diff --git a/e2e/tests/tcp_request_rules/data/accept.json b/e2e/tests/tcp_request_rules/data/accept.json new file mode 100644 index 00000000..f80f7e0a --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/accept.json @@ -0,0 +1,6 @@ +{ + "action": "accept", + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "type": "content" +} diff --git a/e2e/tests/tcp_request_rules/data/haproxy.cfg b/e2e/tests/tcp_request_rules/data/haproxy.cfg new file mode 100644 index 00000000..a5fb152b --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/haproxy.cfg @@ -0,0 +1,40 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode tcp + maxconn 1000 + option httpclose + tcp-request inspect-delay 5s + tcp-request content accept if HTTP + +backend test_backend + mode http + balance roundrobin + option forwardfor + tcp-request inspect-delay 1s + tcp-request content accept if { req.ssl_hello_type 1 } diff --git a/e2e/tests/tcp_request_rules/data/haproxy_2.8.cfg b/e2e/tests/tcp_request_rules/data/haproxy_2.8.cfg new file mode 100644 index 00000000..51af3303 --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/haproxy_2.8.cfg @@ -0,0 +1,57 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + tune.stick-counters 6 + + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend test_frontend + mode tcp + maxconn 1000 + option httpclose + tcp-request inspect-delay 5s + tcp-request content accept if HTTP + tcp-request connection sc-add-gpc(0,1) 1 if FALSE + tcp-request session sc-add-gpc(0,1) 1 if FALSE + tcp-request content sc-add-gpc(0,1) 1 if FALSE + +backend test_backend + mode http + balance roundrobin + option forwardfor + tcp-request inspect-delay 1s + tcp-request content accept if { req.ssl_hello_type 1 } + +frontend front_sticksc + bind *:1248 + default_backend test_sticksc + tcp-request content track-sc0 src table test_sticksc if TRUE + tcp-request content track-sc5 src table test_sticksc if TRUE + +backend test_sticksc + tcp-request content track-sc0 src table test_sticksc if TRUE + tcp-request content track-sc5 src table test_sticksc if TRUE + stick-table type ip size 1m expire 5m store gpc0,conn_rate(30s) + server app1 127.0.0.1:4444 check diff --git a/e2e/tests/tcp_request_rules/data/post-track-sc-fail.json b/e2e/tests/tcp_request_rules/data/post-track-sc-fail.json new file mode 100644 index 00000000..87ec3a67 --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/post-track-sc-fail.json @@ -0,0 +1,8 @@ +{ + "type": "content", + "action": "track-sc", + "cond": "if", + "cond_test": "TRUE", + "track_table": "test_sticksc", + "track_key": "src" +} diff --git a/e2e/tests/tcp_request_rules/data/post-track-sc.json b/e2e/tests/tcp_request_rules/data/post-track-sc.json new file mode 100644 index 00000000..9f80128e --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/post-track-sc.json @@ -0,0 +1,9 @@ +{ + "type": "content", + "action": "track-sc", + "cond": "if", + "cond_test": "TRUE", + "track_table": "test_sticksc", + "track_key": "src", + "track_stick_counter": 5 +} diff --git a/e2e/tests/tcp_request_rules/data/put.json b/e2e/tests/tcp_request_rules/data/put.json new file mode 100644 index 00000000..0b4c6834 --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/put.json @@ -0,0 +1,6 @@ +{ + "action": "reject", + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "type": "content" +} diff --git a/e2e/tests/tcp_request_rules/data/reject.json b/e2e/tests/tcp_request_rules/data/reject.json new file mode 100644 index 00000000..2443f4b9 --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/reject.json @@ -0,0 +1,6 @@ +{ + "action": "reject", + "cond": "if", + "cond_test": "{ src 10.0.0.0/8 }", + "type": "content" +} diff --git a/e2e/tests/tcp_request_rules/data/replace-all.json b/e2e/tests/tcp_request_rules/data/replace-all.json new file mode 100644 index 00000000..1990ca9f --- /dev/null +++ b/e2e/tests/tcp_request_rules/data/replace-all.json @@ -0,0 +1,17 @@ +[ + { + "action": "reject", + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "type": "content" + }, + { + "action": "track-sc", + "cond": "if", + "cond_test": "TRUE", + "track_key": "src", + "track_stick_counter": 5, + "track_table": "test_sticksc", + "type": "content" + } +] diff --git a/e2e/tests/tcp_request_rules/delete.bats b/e2e/tests/tcp_request_rules/delete.bats new file mode 100644 index 00000000..f53198d5 --- /dev/null +++ b/e2e/tests/tcp_request_rules/delete.bats @@ -0,0 +1,59 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "tcp_request_rules: Delete a TCP Request Rule from frontend" { + PARENT_NAME="test_frontend" + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + if haproxy_version_ge "2.8"; then + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + fi + + resource_delete "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} + +@test "tcp_request_rules: Delete a TCP Request Rule from backend" { + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/tcp_request_rules/get.bats b/e2e/tests/tcp_request_rules/get.bats new file mode 100644 index 00000000..c20bb95d --- /dev/null +++ b/e2e/tests/tcp_request_rules/get.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_request_rules: Return one TCP Request Rule from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ".type")" "inspect-delay" + assert_equal "$(get_json_path "$BODY" ".timeout")" 5000 +} + +@test "tcp_request_rules: Return one TCP Request Rule from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ".type")" "inspect-delay" + assert_equal "$(get_json_path "$BODY" ".timeout")" 1000 +} diff --git a/e2e/tests/tcp_request_rules/get_2.8.bats b/e2e/tests/tcp_request_rules/get_2.8.bats new file mode 100644 index 00000000..9dd77c53 --- /dev/null +++ b/e2e/tests/tcp_request_rules/get_2.8.bats @@ -0,0 +1,78 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +## tune.stick-counters is a haproxy >= 2.8 global parameter +@test "tcp_request_rules: Return one track-sc TCP Request Rule from frontend" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="front_sticksc" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".type")" "content" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_stick_counter")" 0 + + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".type")" "content" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_stick_counter")" 5 + fi +} + +@test "tcp_request_rules: Return one track-sc TCP Request Rule from backend" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="test_sticksc" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".type")" "content" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_stick_counter")" 0 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "track-sc" + assert_equal "$(get_json_path "$BODY" ".type")" "content" + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "TRUE" + assert_equal "$(get_json_path "$BODY" ".track_key")" "src" + assert_equal "$(get_json_path "$BODY" ".track_table")" "test_sticksc" + assert_equal "$(get_json_path "$BODY" ".track_stick_counter")" 5 + fi +} diff --git a/e2e/tests/tcp_request_rules/list.bats b/e2e/tests/tcp_request_rules/list.bats new file mode 100644 index 00000000..69f0b7e5 --- /dev/null +++ b/e2e/tests/tcp_request_rules/list.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_request_rules: Return an array of all TCP Request Rules from frontend" { + PARENT_NAME="test_frontend" + resource_get "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules" + assert_equal "$SC" 200 + + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "${BODY}" ". | length")" 5 + else + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + fi + assert_equal "$(get_json_path "$BODY" ".[0].type")" "inspect-delay" + assert_equal "$(get_json_path "$BODY" ".[1].type")" "content" + assert_equal "$(get_json_path "$BODY" ".[1].action")" "accept" + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ".[2].type")" "connection" + assert_equal "$(get_json_path "$BODY" ".[2].action")" "sc-add-gpc" + assert_equal "$(get_json_path "$BODY" ".[3].type")" "session" + assert_equal "$(get_json_path "$BODY" ".[3].action")" "sc-add-gpc" + assert_equal "$(get_json_path "$BODY" ".[4].type")" "content" + assert_equal "$(get_json_path "$BODY" ".[4].action")" "sc-add-gpc" + fi +} + +@test "tcp_request_rules: Return an array of all TCP Request Rules from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" ".[] | select(.type | contains(\"inspect-delay\") ).type")" "inspect-delay" + assert_equal "$(get_json_path "$BODY" ".[] | select(.type | contains(\"content\") ).type")" "content" +} diff --git a/e2e/tests/tcp_request_rules/missing_parent.bats b/e2e/tests/tcp_request_rules/missing_parent.bats new file mode 100644 index 00000000..5a068f8c --- /dev/null +++ b/e2e/tests/tcp_request_rules/missing_parent.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_request_rules: Fail creating a TCP request rule when frontend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/accept.json" "force_reload=true" + assert_equal "$SC" 400 +} + +@test "tcp_request_rules: Fail creating a TCP request rule when backend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/accept.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/tcp_request_rules/replace.bats b/e2e/tests/tcp_request_rules/replace.bats new file mode 100644 index 00000000..5bfe6bc1 --- /dev/null +++ b/e2e/tests/tcp_request_rules/replace.bats @@ -0,0 +1,65 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_request_rules: Replace a TCP Request Rule of frontend" { + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".action")" "reject" +} + +@test "tcp_request_rules: Replace a TCP Request Rule of backend" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules/0" "data/reject.json" "force_reload=true" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".action")" "reject" + assert_equal "$(get_json_path "${BODY}" ".cond_test")" "{ src 10.0.0.0/8 }" +} + +@test "tcp_request_rules: Replace all TCP Request Rule of frontend (>=2.8)" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="test_frontend" + resource_put "$_FRONTEND_BASE_PATH/$PARENT_NAME/tcp_request_rules" "data/replace-all.json" + assert_equal "$SC" 202 + resource_get "$_TCP_REQ_RULES_CERTS_BASE_PATH" "parent_name=test_frontend&parent_type=frontend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + fi +} + +@test "tcp_request_rules: Replace all TCP Request Rule of backend (>= 2.8)" { + if haproxy_version_ge "2.8" + then + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_request_rules" "data/replace-all.json" + assert_equal "$SC" 202 + resource_get "$_TCP_REQ_RULES_CERTS_BASE_PATH" "parent_name=test_backend&parent_type=backend" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" + fi +} diff --git a/e2e/tests/tcp_request_rules/utils/_helpers.bash b/e2e/tests/tcp_request_rules/utils/_helpers.bash new file mode 100644 index 00000000..2781d69c --- /dev/null +++ b/e2e/tests/tcp_request_rules/utils/_helpers.bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_TCP_REQ_RULES_CERTS_BASE_PATH="/services/haproxy/configuration/tcp_request_rules" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" +_FRONTEND_BASE_PATH="/services/haproxy/configuration/frontends" diff --git a/e2e/tests/tcp_response_rules/add.bats b/e2e/tests/tcp_response_rules/add.bats new file mode 100644 index 00000000..46e0b812 --- /dev/null +++ b/e2e/tests/tcp_response_rules/add.bats @@ -0,0 +1,29 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_response_rules: Add a new TCP Response Rule to backend" { + PARENT_NAME="test_backend" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" "data/if.json" "force_reload=true" + assert_equal "$SC" 201 +} diff --git a/e2e/tests/tcp_response_rules/data/haproxy.cfg b/e2e/tests/tcp_response_rules/data/haproxy.cfg new file mode 100644 index 00000000..50400c31 --- /dev/null +++ b/e2e/tests/tcp_response_rules/data/haproxy.cfg @@ -0,0 +1,34 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +backend test_backend + mode http + balance roundrobin + option forwardfor + acl serverhello rep_ssl_hello_type 2 + tcp-response content accept if serverhello + tcp-response content reject if { src 192.168.0.0/16 } diff --git a/e2e/tests/tcp_response_rules/data/haproxy_2.8.cfg b/e2e/tests/tcp_response_rules/data/haproxy_2.8.cfg new file mode 100644 index 00000000..72f42307 --- /dev/null +++ b/e2e/tests/tcp_response_rules/data/haproxy_2.8.cfg @@ -0,0 +1,37 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +backend test_backend + mode http + balance roundrobin + option forwardfor + acl serverhello rep_ssl_hello_type 2 + filter bwlim-in my-limit-reverse default-limit 1m default-period 1s + filter bwlim-in my-limit default-limit 1m default-period 1s + tcp-response content accept if serverhello + tcp-response content reject if { src 192.168.0.0/16 } + tcp-response content sc-add-gpc(0,1) 1 if FALSE diff --git a/e2e/tests/tcp_response_rules/data/if.json b/e2e/tests/tcp_response_rules/data/if.json new file mode 100644 index 00000000..16fa0252 --- /dev/null +++ b/e2e/tests/tcp_response_rules/data/if.json @@ -0,0 +1,6 @@ +{ + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "type": "content", + "action": "accept" +} diff --git a/e2e/tests/tcp_response_rules/data/put.json b/e2e/tests/tcp_response_rules/data/put.json new file mode 100644 index 00000000..df31153a --- /dev/null +++ b/e2e/tests/tcp_response_rules/data/put.json @@ -0,0 +1,6 @@ +{ + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "type": "content", + "action": "reject" +} diff --git a/e2e/tests/tcp_response_rules/data/replace-all-27.json b/e2e/tests/tcp_response_rules/data/replace-all-27.json new file mode 100644 index 00000000..a813df05 --- /dev/null +++ b/e2e/tests/tcp_response_rules/data/replace-all-27.json @@ -0,0 +1,28 @@ +[ + { + "action": "accept", + "cond": "if", + "cond_test": "TRUE", + "type": "content" + }, + { + "action": "reject", + "cond": "if", + "cond_test": "FALSE", + "type": "content" + }, + { + "action": "set-bandwidth-limit", + "bandwidth_limit_limit": "2m", + "bandwidth_limit_name": "my-limit-reverse", + "bandwidth_limit_period": "20s", + "type": "content" + }, + { + "action": "set-bandwidth-limit", + "bandwidth_limit_limit": "1m", + "bandwidth_limit_name": "my-limit", + "bandwidth_limit_period": "10s", + "type": "content" + } +] diff --git a/e2e/tests/tcp_response_rules/data/replace-all.json b/e2e/tests/tcp_response_rules/data/replace-all.json new file mode 100644 index 00000000..97edb5c6 --- /dev/null +++ b/e2e/tests/tcp_response_rules/data/replace-all.json @@ -0,0 +1,14 @@ +[ + { + "action": "accept", + "cond": "if", + "cond_test": "TRUE", + "type": "content" + }, + { + "action": "reject", + "cond": "if", + "cond_test": "FALSE", + "type": "content" + } +] diff --git a/e2e/tests/tcp_response_rules/data/unless.json b/e2e/tests/tcp_response_rules/data/unless.json new file mode 100644 index 00000000..8a8d0c8d --- /dev/null +++ b/e2e/tests/tcp_response_rules/data/unless.json @@ -0,0 +1,6 @@ +{ + "cond": "unless", + "cond_test": "{ src 10.0.0.0/8 }", + "type": "content", + "action": "accept" +} diff --git a/e2e/tests/tcp_response_rules/delete.bats b/e2e/tests/tcp_response_rules/delete.bats new file mode 100644 index 00000000..1cc83902 --- /dev/null +++ b/e2e/tests/tcp_response_rules/delete.bats @@ -0,0 +1,41 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "tcp_response_rules: Delete a TCP Response Rule" { + PARENT_NAME="test_backend" + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + + if haproxy_version_ge "2.8"; then + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" "force_reload=true" + assert_equal "$SC" 204 + fi + + resource_delete "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/tcp_response_rules/get.bats b/e2e/tests/tcp_response_rules/get.bats new file mode 100644 index 00000000..dede90cb --- /dev/null +++ b/e2e/tests/tcp_response_rules/get.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_response_rules: Return one TCP Response Rule" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "accept" + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".action")" "reject" +} diff --git a/e2e/tests/tcp_response_rules/list.bats b/e2e/tests/tcp_response_rules/list.bats new file mode 100644 index 00000000..461236b1 --- /dev/null +++ b/e2e/tests/tcp_response_rules/list.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' +load '../../libs/haproxy_version' + +load 'utils/_helpers' + +@test "tcp_response_rules: Return one TCP Response Rule from backend" { + PARENT_NAME="test_backend" + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules" + assert_equal "$SC" 200 + + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + else + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + fi + assert_equal "$(get_json_path "$BODY" ".[] | select(.action | contains(\"accept\") ).action")" "accept" + assert_equal "$(get_json_path "$BODY" ".[] | select(.action | contains(\"reject\") ).action")" "reject" + if haproxy_version_ge "2.8"; then + assert_equal "$(get_json_path "$BODY" ".[] | select(.action | contains(\"sc-add-gpc\") ).action")" "sc-add-gpc" + fi +} diff --git a/e2e/tests/tcp_response_rules/missing_parent.bats b/e2e/tests/tcp_response_rules/missing_parent.bats new file mode 100644 index 00000000..87121ac3 --- /dev/null +++ b/e2e/tests/tcp_response_rules/missing_parent.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_response_rules: Fail creating a TCP Response rule when backend doesn't exist" { + PARENT_NAME="ghost" + resource_post "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" "data/unless.json" "force_reload=true" + assert_equal "$SC" 400 +} diff --git a/e2e/tests/tcp_response_rules/replace.bats b/e2e/tests/tcp_response_rules/replace.bats new file mode 100644 index 00000000..ebf838e8 --- /dev/null +++ b/e2e/tests/tcp_response_rules/replace.bats @@ -0,0 +1,62 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "tcp_response_rules: Replace a TCP Response Rule" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/0" "data/put.json" "force_reload=true" + assert_equal "$SC" 200 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules/1" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".cond")" "if" + assert_equal "$(get_json_path "$BODY" ".cond_test")" "{ src 192.168.0.0/16 }" + assert_equal "$(get_json_path "$BODY" ".type")" "content" + assert_equal "$(get_json_path "$BODY" ".action")" "reject" +} + +@test "tcp_response_rules: Replace all TCP Response Rule" { + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules" "data/replace-all.json" + assert_equal "$SC" 202 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all.json")" ".")" +} + +@test "tcp_response_rules: Replace all TCP Response Rule (>=2.7)" { + if haproxy_version_ge "2.7" + then + PARENT_NAME="test_backend" + resource_put "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules" "data/replace-all-27.json" + assert_equal "$SC" 202 + + resource_get "$_BACKEND_BASE_PATH/$PARENT_NAME/tcp_response_rules" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 4 + assert_equal "$(get_json_path "$BODY" ".")" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/replace-all-27.json")" ".")" + fi +} diff --git a/e2e/tests/tcp_response_rules/utils/_helpers.bash b/e2e/tests/tcp_response_rules/utils/_helpers.bash new file mode 100644 index 00000000..a83f02e3 --- /dev/null +++ b/e2e/tests/tcp_response_rules/utils/_helpers.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_TCP_RES_RULES_CERTS_BASE_PATH="/services/haproxy/configuration/tcp_response_rules" +_BACKEND_BASE_PATH="/services/haproxy/configuration/backends" diff --git a/e2e/tests/traces/data/entry1.json b/e2e/tests/traces/data/entry1.json new file mode 100644 index 00000000..e6c7de9c --- /dev/null +++ b/e2e/tests/traces/data/entry1.json @@ -0,0 +1 @@ +{"trace": "peers sink stderr level developer verbosity quiet start now"} diff --git a/e2e/tests/traces/data/entry2.json b/e2e/tests/traces/data/entry2.json new file mode 100644 index 00000000..6e2e6ce2 --- /dev/null +++ b/e2e/tests/traces/data/entry2.json @@ -0,0 +1 @@ +{"trace": "check sink stderr level developer verbosity quiet start now"} diff --git a/e2e/tests/traces/data/new_section.json b/e2e/tests/traces/data/new_section.json new file mode 100644 index 00000000..066394ad --- /dev/null +++ b/e2e/tests/traces/data/new_section.json @@ -0,0 +1,6 @@ +{ + "entries": [ + {"trace": "h1 sink stderr level developer verbosity complete start now"}, + {"trace": "h2 sink stderr level developer verbosity complete start now"} + ] +} diff --git a/e2e/tests/traces/data/replace_section.json b/e2e/tests/traces/data/replace_section.json new file mode 100644 index 00000000..66d8e319 --- /dev/null +++ b/e2e/tests/traces/data/replace_section.json @@ -0,0 +1,5 @@ +{ + "entries": [ + {"trace": "fcgi sink stderr level developer verbosity quiet start now"} + ] +} diff --git a/e2e/tests/traces/traces.bats b/e2e/tests/traces/traces.bats new file mode 100644 index 00000000..62e75200 --- /dev/null +++ b/e2e/tests/traces/traces.bats @@ -0,0 +1,69 @@ +#!/usr/bin/env bats +# +# Copyright 2024 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/debug' +load '../../libs/get_json_path' +load '../../libs/haproxy_version' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + + +@test "traces: get/create/modify/delete (>=3.1)" { + haproxy_version_ge "3.1" || skip + + resource_post "$_TRACES_PATH" "data/new_section.json" "force_reload=true" + assert_equal "$SC" "201" + + resource_get "$_TRACES_PATH" + assert_equal "$SC" "200" + assert_equal "h1 sink stderr level developer verbosity complete start now" \ + "$(get_json_path "$BODY" .entries[0].trace)" + assert_equal "h2 sink stderr level developer verbosity complete start now" \ + "$(get_json_path "$BODY" .entries[1].trace)" + + resource_put "$_TRACES_PATH" "data/replace_section.json" "force_reload=true" + assert_equal "$SC" "200" + resource_get "$_TRACES_PATH" + assert_equal "fcgi sink stderr level developer verbosity quiet start now" \ + "$(get_json_path "$BODY" .entries[0].trace)" + + + resource_post "$_TRACE_ENTRIES_PATH" "data/entry1.json" + assert_equal "$SC" "202" + resource_post "$_TRACE_ENTRIES_PATH" "data/entry2.json" + assert_equal "$SC" "202" + resource_get "$_TRACES_PATH" + assert_equal "fcgi sink stderr level developer verbosity quiet start now" \ + "$(get_json_path "$BODY" .entries[0].trace)" + assert_equal "peers sink stderr level developer verbosity quiet start now" \ + "$(get_json_path "$BODY" .entries[1].trace)" + assert_equal "check sink stderr level developer verbosity quiet start now" \ + "$(get_json_path "$BODY" .entries[2].trace)" + + resource_delete_body "$_TRACE_ENTRIES_PATH" "data/entry1.json" "force_reload=true" + assert_equal "$SC" "204" + resource_delete_body "$_TRACE_ENTRIES_PATH" "data/entry2.json" "force_reload=true" + assert_equal "$SC" "204" + + resource_delete "$_TRACES_PATH" "force_reload=true" + assert_equal "$SC" "204" + resource_get "$_TRACES_PATH" + assert_equal "$SC" "404" +} diff --git a/e2e/tests/traces/utils/_helpers.bash b/e2e/tests/traces/utils/_helpers.bash new file mode 100644 index 00000000..1ff3ec61 --- /dev/null +++ b/e2e/tests/traces/utils/_helpers.bash @@ -0,0 +1,10 @@ +_TRACES_PATH="/services/haproxy/configuration/traces" +_TRACE_ENTRIES_PATH="/services/haproxy/configuration/traces/entries" + +function resource_delete_body() { + local endpoint="$1" data="$2" qs_params="$3" + get_version + run dpa_curl DELETE "$endpoint?$qs_params&version=${VERSION}" "$data" + assert_success + dpa_curl_status_body '$output' +} diff --git a/e2e/tests/transactions/commit.bats b/e2e/tests/transactions/commit.bats new file mode 100644 index 00000000..7771290a --- /dev/null +++ b/e2e/tests/transactions/commit.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/haproxy_config_setup' +load '../../libs/version' + +load 'utils/_helpers' + +@test "transactions: Outdated transactions cannot be committed" { + resource_post "$_TRANSACTIONS_BASE_PATH" "" + assert_equal "$SC" 201 + local first_id; first_id=$(get_json_path "${BODY}" ".id") + + resource_post "$_TRANSACTIONS_BASE_PATH" "" + assert_equal "$SC" 201 + local second_id; second_id=$(get_json_path "${BODY}" ".id") + + # commit first one, must succeed + resource_put "$_TRANSACTIONS_BASE_PATH/$first_id" "" + assert_equal "$SC" 202 + + # try to commit second one, must be outdated + resource_put "$_TRANSACTIONS_BASE_PATH/$second_id" "" + assert_equal "$SC" 406 +} diff --git a/e2e/tests/transactions/utils/_helpers.bash b/e2e/tests/transactions/utils/_helpers.bash new file mode 100644 index 00000000..52020da4 --- /dev/null +++ b/e2e/tests/transactions/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_TRANSACTIONS_BASE_PATH="/services/haproxy/transactions" diff --git a/e2e/tests/userlists/add.bats b/e2e/tests/userlists/add.bats new file mode 100644 index 00000000..817f312a --- /dev/null +++ b/e2e/tests/userlists/add.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "userlists: Add a userlist" { + resource_post "$_USERLISTS_BASE_PATH" "data/post.json" "force_reload=true" + assert_equal "$SC" 201 +} + +@test "userlists: Add a malformed userlist" { + resource_post "$_USERLISTS_BASE_PATH" "data/empty.json" "force_reload=true" + assert_equal "$SC" 422 +} diff --git a/e2e/tests/userlists/data/empty.json b/e2e/tests/userlists/data/empty.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/e2e/tests/userlists/data/empty.json @@ -0,0 +1 @@ +{} diff --git a/e2e/tests/userlists/data/haproxy.cfg b/e2e/tests/userlists/data/haproxy.cfg new file mode 100644 index 00000000..c2af9f9a --- /dev/null +++ b/e2e/tests/userlists/data/haproxy.cfg @@ -0,0 +1,37 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +userlist first + group G1 users tiger,scott + group G2 users scott + user tiger password $6$k6y3o.eP$JlKBx9za9667qe4xHSwRv6J.C0/D7cV91 + user scott insecure-password elgato + +userlist second + group one + group two + group three + user neo password $6$k6y3o.eP$JlKBxxHSwRv6J.C0/D7cV91 groups one + user thomas insecure-password white-rabbit groups one,two + user anderson insecure-password hello groups two + +userlist empty + +userlist add_test + group G3 + group G4 + +userlist replace_test + group zion + group io + user trinity insecure-password the-one groups zion + +userlist delete_test + group virus + user smith insecure-password cloning groups virus diff --git a/e2e/tests/userlists/data/post.json b/e2e/tests/userlists/data/post.json new file mode 100644 index 00000000..62e73988 --- /dev/null +++ b/e2e/tests/userlists/data/post.json @@ -0,0 +1,3 @@ +{ + "name": "new-user-list" +} diff --git a/e2e/tests/userlists/delete.bats b/e2e/tests/userlists/delete.bats new file mode 100644 index 00000000..3b780615 --- /dev/null +++ b/e2e/tests/userlists/delete.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "userlists: Delete a userlist" { + resource_delete "$_USERLISTS_BASE_PATH/delete_test" "force_reload=true" + assert_equal "$SC" 204 + resource_get "$_USERLISTS_BASE_PATH/delete_test" + assert_equal "$SC" 404 +} + +@test "userlists: Delete a non existing userlist" { + resource_delete "$_USERLISTS_BASE_PATH/fake" "force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/userlists/get.bats b/e2e/tests/userlists/get.bats new file mode 100644 index 00000000..c92f3132 --- /dev/null +++ b/e2e/tests/userlists/get.bats @@ -0,0 +1,75 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "userlists: Return userlist first" { + resource_get "$_USERLISTS_BASE_PATH/first" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".name")" "first" +} + +@test "userlists: Return userlist second" { + resource_get "$_USERLISTS_BASE_PATH/second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".name")" "second" +} + +@test "userlists: Return userlist empty" { + resource_get "$_USERLISTS_BASE_PATH/empty" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".name")" "empty" +} + +@test "userlists: Return userlist add_test" { + resource_get "$_USERLISTS_BASE_PATH/add_test" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".name")" "add_test" +} + +@test "userlists: Return userlist replace_test" { + resource_get "$_USERLISTS_BASE_PATH/replace_test" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".name")" "replace_test" +} + +@test "userlists: Return userlist delete_test" { + resource_get "$_USERLISTS_BASE_PATH/delete_test" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ".name")" "delete_test" +} + +@test "userlists: Return userlist 0" { + resource_get "$_USERLISTS_BASE_PATH/0" + assert_equal "$SC" 404 +} + +@test "userlists: Return userlist 1000" { + resource_get "$_USERLISTS_BASE_PATH/1000" + assert_equal "$SC" 404 +} + +@test "userlists: Return userlist fake" { + resource_get "$_USERLISTS_BASE_PATH/fake" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/userlists/list.bats b/e2e/tests/userlists/list.bats new file mode 100644 index 00000000..7c055f82 --- /dev/null +++ b/e2e/tests/userlists/list.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "userlists: Return an array of userlists" { + resource_get "$_USERLISTS_BASE_PATH" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 6 +} diff --git a/e2e/tests/userlists/utils/_helpers.bash b/e2e/tests/userlists/utils/_helpers.bash new file mode 100644 index 00000000..a786bccf --- /dev/null +++ b/e2e/tests/userlists/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_USERLISTS_BASE_PATH="/services/haproxy/configuration/userlists" diff --git a/e2e/tests/users/add.bats b/e2e/tests/users/add.bats new file mode 100644 index 00000000..3614b290 --- /dev/null +++ b/e2e/tests/users/add.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "users: Add a user" { + resource_post "$_USERS_BASE_PATH" "data/post.json" "userlist=first&=force_reload=true" + assert_equal "$SC" 202 +} + +@test "users: Add a user to a non existing user list" { + resource_post "$_USERS_BASE_PATH" "data/post.json" "userlist=fake&=force_reload=true" + assert_equal "$SC" 400 +} + +@test "users: Add a malformed user" { + resource_post "$_USERS_BASE_PATH" "data/empty.json" "userlist=first&force_reload=true" + assert_equal "$SC" 422 +} diff --git a/e2e/tests/users/data/empty.json b/e2e/tests/users/data/empty.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/e2e/tests/users/data/empty.json @@ -0,0 +1 @@ +{} diff --git a/e2e/tests/users/data/haproxy.cfg b/e2e/tests/users/data/haproxy.cfg new file mode 100644 index 00000000..071a71f2 --- /dev/null +++ b/e2e/tests/users/data/haproxy.cfg @@ -0,0 +1,37 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +userlist first + group G1 users tiger,scott + group G2 users scott + user tiger password $6$k6y3o.eP$JlKBx9za9667qe4xHSwRv6J.C0/D7cV91 + user scott insecure-password elgato + +userlist second + group one + group two + group three + user neo password JlKBxxHSwRv6J.C0/D7cV91 groups one + user thomas insecure-password white-rabbit groups one,two + user anderson insecure-password hello groups two + +userlist empty + +userlist add_test + group G3 + group G4 + +userlist replace_test + group zion + group io + user trinity insecure-password the-one groups zion + +userlist delete_test + group virus + user smith insecure-password cloning groups virus diff --git a/e2e/tests/users/data/post.json b/e2e/tests/users/data/post.json new file mode 100644 index 00000000..073f8ce4 --- /dev/null +++ b/e2e/tests/users/data/post.json @@ -0,0 +1,6 @@ +{ + "username": "new", + "secure_password": false, + "password": "new", + "groups": null +} diff --git a/e2e/tests/users/data/replace.json b/e2e/tests/users/data/replace.json new file mode 100644 index 00000000..2fc2177d --- /dev/null +++ b/e2e/tests/users/data/replace.json @@ -0,0 +1,6 @@ +{ + "username": "trinity", + "secure_password": false, + "password": "reality", + "groups": null +} diff --git a/e2e/tests/users/delete.bats b/e2e/tests/users/delete.bats new file mode 100644 index 00000000..a3ab8976 --- /dev/null +++ b/e2e/tests/users/delete.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "users: Delete a user" { + resource_delete "$_USERS_BASE_PATH/smith" "userlist=delete_test&force_reload=true" + assert_equal "$SC" 204 + resource_get "$_USERS_BASE_PATH/smith" "userlist=delete_test" + assert_equal "$SC" 404 +} + +@test "users: Delete a non existing user" { + resource_delete "$_USERS_BASE_PATH/fake" "userlist=fake&force_reload=true" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/users/get.bats b/e2e/tests/users/get.bats new file mode 100644 index 00000000..cd71d595 --- /dev/null +++ b/e2e/tests/users/get.bats @@ -0,0 +1,77 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "users: Return user tiger from a userlist" { + resource_get "$_USERS_BASE_PATH/tiger" "userlist=first" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".username")" "tiger" + #assert_equal "$(get_json_path "$BODY" ".secure_password")" `$6$k6y3o.eP$JlKBx9za9667qe4xHSwRv6J.C0/D7cV91` + assert_equal "$(get_json_path "$BODY" ".secure_password")" true +} + +@test "users: Return user scott from a userlist" { + resource_get "$_USERS_BASE_PATH/scott" "userlist=first" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".username")" "scott" + assert_equal "$(get_json_path "$BODY" ".secure_password")" false + assert_equal "$(get_json_path "$BODY" ".password")" "elgato" +} + +@test "users: Return a non existing user from a userlist" { + resource_get "$_USERS_BASE_PATH/fake" "userlist=first" + assert_equal "$SC" 404 +} + +@test "users: Return user scott from a non existing userlist" { + resource_get "$_USERS_BASE_PATH/scott" "userlist=fake" + assert_equal "$SC" 404 +} + +@test "users: Return user neo from a userlist" { + resource_get "$_USERS_BASE_PATH/neo" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".username")" "neo" + assert_equal "$(get_json_path "$BODY" ".secure_password")" true + assert_equal "$(get_json_path "$BODY" ".password")" "JlKBxxHSwRv6J.C0/D7cV91" + assert_equal "$(get_json_path "$BODY" ".groups")" "one" +} + +@test "users: Return user thomas from a userlist" { + resource_get "$_USERS_BASE_PATH/thomas" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".username")" "thomas" + assert_equal "$(get_json_path "$BODY" ".secure_password")" false + assert_equal "$(get_json_path "$BODY" ".password")" "white-rabbit" + assert_equal "$(get_json_path "$BODY" ".groups")" "one,two" +} + +@test "users: Return user anderson from a userlist" { + resource_get "$_USERS_BASE_PATH/anderson" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "$BODY" ".username")" "anderson" + assert_equal "$(get_json_path "$BODY" ".secure_password")" false + assert_equal "$(get_json_path "$BODY" ".password")" "hello" + assert_equal "$(get_json_path "$BODY" ".groups")" "two" +} diff --git a/e2e/tests/users/list.bats b/e2e/tests/users/list.bats new file mode 100644 index 00000000..3181ae27 --- /dev/null +++ b/e2e/tests/users/list.bats @@ -0,0 +1,70 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "users: Return an array of users from userlist first" { + resource_get "$_USERS_BASE_PATH" "userlist=first" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 2 + + assert_equal "$(get_json_path "${BODY}" ".[0].username" )" "tiger" + assert_equal "$(get_json_path "${BODY}" ".[0].secure_password" )" true + assert_equal "$(get_json_path "${BODY}" ".[0].groups" )" null + + assert_equal "$(get_json_path "${BODY}" ".[1].username" )" "scott" + assert_equal "$(get_json_path "${BODY}" ".[1].secure_password" )" false + assert_equal "$(get_json_path "${BODY}" ".[1].password" )" "elgato" +} + +@test "users: Return an array of users from userlist second" { + resource_get "$_USERS_BASE_PATH" "userlist=second" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 3 + + assert_equal "$(get_json_path "${BODY}" ".[0].username" )" "neo" + assert_equal "$(get_json_path "${BODY}" ".[0].secure_password" )" true + assert_equal "$(get_json_path "${BODY}" ".[0].password" )" "JlKBxxHSwRv6J.C0/D7cV91" + assert_equal "$(get_json_path "${BODY}" ".[0].groups" )" "one" + + assert_equal "$(get_json_path "${BODY}" ".[1].username" )" "thomas" + assert_equal "$(get_json_path "${BODY}" ".[1].secure_password" )" false + assert_equal "$(get_json_path "${BODY}" ".[1].password" )" "white-rabbit" + assert_equal "$(get_json_path "${BODY}" ".[1].groups" )" "one,two" + + assert_equal "$(get_json_path "${BODY}" ".[2].username" )" "anderson" + assert_equal "$(get_json_path "${BODY}" ".[2].secure_password" )" false + assert_equal "$(get_json_path "${BODY}" ".[2].password" )" "hello" + assert_equal "$(get_json_path "${BODY}" ".[2].groups" )" "two" +} + +@test "users: Return an array of users from userlist empty" { + resource_get "$_USERS_BASE_PATH" "userlist=empty" + assert_equal "$SC" 200 + assert_equal "$(get_json_path "${BODY}" ". | length")" 0 +} + +@test "users: Return an array of users from non existing userlist" { + resource_get "$_USERS_BASE_PATH" "userlist=fake" + assert_equal "$SC" 404 +} diff --git a/e2e/tests/users/replace.bats b/e2e/tests/users/replace.bats new file mode 100644 index 00000000..26dc4c0a --- /dev/null +++ b/e2e/tests/users/replace.bats @@ -0,0 +1,45 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/haproxy_config_setup' +load '../../libs/resource_client' +load '../../libs/version' + +load 'utils/_helpers' + +@test "users: Replace a user" { + resource_put "$_USERS_BASE_PATH/trinity" "data/replace.json" "userlist=replace_test&force_reload=true" + assert_equal "$SC" 200 +} + +@test "users: Replace a user with malformed data" { + resource_put "$_USERS_BASE_PATH/trinity" "data/empty.json" "userlist=replace_test&force_reload=true" + assert_equal "$SC" 422 +} + +@test "users: Replace a non existing user" { + resource_put "$_USERS_BASE_PATH/fake" "data/replace.json" "userlist=replace_test&force_reload=true" + assert_equal "$SC" 404 +} + +@test "users: Replace a non existing user in a non existing user list" { + resource_put "$_USERS_BASE_PATH/fake" "data/replace.json" "userlist=fake&force_reload=true" + assert_equal "$SC" 404 +} + diff --git a/e2e/tests/users/utils/_helpers.bash b/e2e/tests/users/utils/_helpers.bash new file mode 100644 index 00000000..a965dc93 --- /dev/null +++ b/e2e/tests/users/utils/_helpers.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +_USERS_BASE_PATH="/services/haproxy/configuration/users" diff --git a/e2e/tests/x_issue_132/check.bats b/e2e/tests/x_issue_132/check.bats new file mode 100644 index 00000000..64b0e67c --- /dev/null +++ b/e2e/tests/x_issue_132/check.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/resource_client' +load '../../libs/haproxy_config_setup' +load '../../libs/version' + +@test "x_issue_132: https://github.com/haproxytech/dataplaneapi/issues/132" { + PARENT_NAME="bug_132_bck" + resource_post "/services/haproxy/configuration/backends/$PARENT_NAME/servers" "data/add_server.json" "force_reload=true" + assert_equal "$SC" 201 +} diff --git a/e2e/tests/x_issue_132/data/add_server.json b/e2e/tests/x_issue_132/data/add_server.json new file mode 100644 index 00000000..24235542 --- /dev/null +++ b/e2e/tests/x_issue_132/data/add_server.json @@ -0,0 +1 @@ +{"name":"app2","address":"127.0.0.1","port":8080} diff --git a/e2e/tests/x_issue_132/data/haproxy.cfg b/e2e/tests/x_issue_132/data/haproxy.cfg new file mode 100644 index 00000000..80e332fa --- /dev/null +++ b/e2e/tests/x_issue_132/data/haproxy.cfg @@ -0,0 +1,35 @@ +global + chroot /var/lib/haproxy + user haproxy + group haproxy + maxconn 4000 + pidfile /var/run/haproxy.pid + stats socket /var/lib/haproxy/stats level admin + log 127.0.0.1 local2 + +defaults mydefaults + mode http + maxconn 3000 + log global + option httplog + option redispatch + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + timeout http-request 10s + timeout check 10s + timeout connect 10s + timeout client 1m + timeout queue 1m + timeout server 1m + timeout http-keep-alive 10s + retries 3 + +frontend bug_132_fr + bind *:1132 + http-response replace-header Set-Cookie (.*) \1;\ Secure if { ssl_fc } + http-response replace-header Set-Cookie (.*);\ Secure(.*) \1\2 unless { ssl_fc } + default_backend bug_132_bck + +backend bug_132_bck + server app1 127.0.0.1:8080 diff --git a/e2e/tests/x_issue_int_247/check.bats b/e2e/tests/x_issue_int_247/check.bats new file mode 100644 index 00000000..82340d38 --- /dev/null +++ b/e2e/tests/x_issue_int_247/check.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env bats +# +# Copyright 2021 HAProxy Technologies +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +load '../../libs/dataplaneapi' +load '../../libs/get_json_path' +load '../../libs/resource_client' +load '../../libs/haproxy_config_setup' +load '../../libs/version' + +@test "x_issue_int_247: runtime admin-state of backend app2" { + PARENT_NAME="bug_int_247" + resource_get "/services/haproxy/runtime/backends/$PARENT_NAME/servers/app2" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" '.admin_state')" "maint" +} + +@test "x_issue_int_247: runtime admin-state of backend app1" { + PARENT_NAME="bug_int_247" + resource_get "/services/haproxy/runtime/backends/$PARENT_NAME/servers/app1" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" '.admin_state')" "ready" +} + +@test "x_issue_int_247: admin-state always reports admin_state of maint if disabled keyword is used" { + PARENT_NAME="bug_int_247" + resource_put "/services/haproxy/runtime/backends/$PARENT_NAME/servers/app2" "data/enable.json" + assert_equal "$SC" 200 + + assert_equal "$(get_json_path "$BODY" '.admin_state')" "ready" +} diff --git a/e2e/tests/x_issue_int_247/data/enable.json b/e2e/tests/x_issue_int_247/data/enable.json new file mode 100644 index 00000000..91a8c8a4 --- /dev/null +++ b/e2e/tests/x_issue_int_247/data/enable.json @@ -0,0 +1 @@ +{ "admin_state": "ready" } diff --git a/e2e/tests/x_issue_int_247/data/haproxy.cfg b/e2e/tests/x_issue_int_247/data/haproxy.cfg new file mode 100644 index 00000000..4e932792 --- /dev/null +++ b/e2e/tests/x_issue_int_247/data/haproxy.cfg @@ -0,0 +1,10 @@ +global + stats socket /var/lib/haproxy/stats level admin + +frontend bug_int_247_front + bind *:1247 + default_backend bug_int_247 + +backend bug_int_247 + server app1 127.0.0.1:8080 check + server app2 127.0.0.1:8080 check disabled diff --git a/embedded_spec.go b/embedded_spec.go index 3d8d4ae8..fbcd3b2a 100644 --- a/embedded_spec.go +++ b/embedded_spec.go @@ -40,7 +40,8 @@ func init() { "application/json" ], "schemes": [ - "http" + "http", + "https" ], "swagger": "2.0", "info": { @@ -51,9 +52,9 @@ func init() { "url": "https://my.haproxy.com/portal/cust/login", "email": "support@haproxy.com" }, - "version": "2.0" + "version": "3.3" }, - "basePath": "/v2", + "basePath": "/v3", "paths": { "/": { "get": { @@ -79,70 +80,190 @@ func init() { } } }, - "/info": { + "/cluster": { "get": { - "description": "Return API, hardware and OS information", + "description": "Returns cluster data", "produces": [ "application/json" ], "tags": [ - "Information" + "Cluster" ], - "summary": "Return API, hardware and OS information", - "operationId": "getInfo", + "summary": "Return cluster data", + "operationId": "getCluster", "responses": { "200": { "description": "Success", "schema": { - "$ref": "#/definitions/info" + "$ref": "#/definitions/cluster_settings" } }, "default": { "$ref": "#/responses/DefaultError" } } - } - }, - "/services": { - "get": { - "description": "Returns a list of API managed services endpoints.", - "produces": [ - "application/json" + }, + "put": { + "description": "Edit cluster settings", + "tags": [ + "Cluster" ], + "summary": "Edit cluster settings", + "operationId": "editCluster", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "200": { + "description": "Cluster settings changed", + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Post cluster settings", "tags": [ - "Discovery" + "Cluster" + ], + "summary": "Post cluster settings", + "operationId": "postCluster", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + { + "enum": [ + "keep" + ], + "type": "string", + "description": "In case of moving to single mode do we keep or clean configuration", + "name": "configuration", + "in": "query" + }, + { + "type": "string", + "description": "Force the advertised address when joining a cluster", + "name": "advertised_address", + "in": "query" + }, + { + "maximum": 65535, + "minimum": 1, + "type": "integer", + "description": "Force the advertised port when joining a cluster", + "name": "advertised_port", + "in": "query" + }, + { + "$ref": "#/parameters/version" + } ], - "summary": "Return list of service endpoints", - "operationId": "getServicesEndpoints", "responses": { "200": { - "description": "Success", + "description": "Cluster settings changed", "schema": { - "$ref": "#/definitions/endpoints" + "$ref": "#/definitions/cluster_settings" } }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Delete cluster settings and move the node back to single mode", + "tags": [ + "Cluster" + ], + "summary": "Delete cluster settings", + "operationId": "deleteCluster", + "parameters": [ + { + "enum": [ + "keep" + ], + "type": "string", + "description": "In case of moving to single mode do we keep or clean configuration", + "name": "configuration", + "in": "query" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "204": { + "description": "Cluster settings deleted and node moved to single mode" + }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy": { + "/cluster/certificate": { + "post": { + "description": "Initiates a certificate refresh", + "tags": [ + "Cluster" + ], + "summary": "Initiates a certificate refresh", + "operationId": "initiateCertificateRefresh", + "responses": { + "200": { + "description": "refresh activated" + }, + "403": { + "description": "refresh not possible" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/health": { "get": { - "description": "Returns a list of HAProxy related endpoints.", + "description": "Return managed services health", "produces": [ "application/json" ], "tags": [ - "Discovery" + "Health" ], - "summary": "Return list of HAProxy related endpoints", - "operationId": "getHaproxyEndpoints", + "summary": "Return managed services health", + "operationId": "getHealth", "responses": { "200": { "description": "Success", "schema": { - "$ref": "#/definitions/endpoints" + "$ref": "#/definitions/health" } }, "default": { @@ -151,22 +272,22 @@ func init() { } } }, - "/services/haproxy/configuration": { + "/info": { "get": { - "description": "Returns a list of endpoints to be used for advanced configuration of HAProxy objects.", + "description": "Return API, hardware and OS information", "produces": [ "application/json" ], "tags": [ - "Discovery" + "Information" ], - "summary": "Return list of HAProxy advanced configuration endpoints", - "operationId": "getConfigurationEndpoints", + "summary": "Return API, hardware and OS information", + "operationId": "getInfo", "responses": { "200": { "description": "Success", "schema": { - "$ref": "#/definitions/endpoints" + "$ref": "#/definitions/info" } }, "default": { @@ -175,62 +296,19 @@ func init() { } } }, - "/services/haproxy/configuration/acls": { + "/service_discovery/aws": { "get": { - "description": "Returns all ACL lines that are configured in specified parent.", + "description": "Return all configured AWS regions.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" - ], - "summary": "Return an array of all ACL lines", - "operationId": "getAcls", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" - } + "ServiceDiscovery" ], + "summary": "Return an array of all configured AWS regions", + "operationId": "getAWSRegions", "responses": { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/acls" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/awsRegions" } }, "default": { @@ -239,69 +317,27 @@ func init() { } }, "post": { - "description": "Adds a new ACL line of the specified type in the specified parent.", + "description": "Add a new AWS region.\nCredentials are not required in case Dataplane API is running in an EC2 instance with proper IAM role attached.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" + "ServiceDiscovery" ], - "summary": "Add a new ACL line", - "operationId": "createAcl", + "summary": "Add a new AWS region", + "operationId": "createAWSRegion", "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/acl" + "$ref": "#/definitions/awsRegion" } - }, - { - "$ref": "#/parameters/transaction_id" - }, - { - "$ref": "#/parameters/version" - }, - { - "$ref": "#/parameters/force_reload" } ], "responses": { "201": { - "description": "ACL line created", - "schema": { - "$ref": "#/definitions/acl" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", + "description": "Resource created", "schema": { - "$ref": "#/definitions/acl" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "$ref": "#/definitions/awsRegion" } }, "400": { @@ -316,66 +352,28 @@ func init() { } } }, - "/services/haproxy/configuration/acls/{id}": { + "/service_discovery/aws/{id}": { "get": { - "description": "Returns one ACL line configuration by it's ID in the specified parent.", + "description": "Return one AWS Region configuration by it's id.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" + "ServiceDiscovery" ], - "summary": "Return one ACL line", - "operationId": "getAcl", + "summary": "Return an AWS region", + "operationId": "getAWSRegion", "parameters": [ { - "type": "integer", - "description": "ACL line ID", + "type": "string", + "description": "AWS region id", "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" } ], "responses": { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/acl" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/awsRegion" } }, "404": { @@ -387,76 +385,34 @@ func init() { } }, "put": { - "description": "Replaces a ACL line configuration by it's ID in the specified parent.", + "description": "Replace an AWS region configuration by its id.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" + "ServiceDiscovery" ], - "summary": "Replace a ACL line", - "operationId": "replaceAcl", + "summary": "Replace an AWS region", + "operationId": "replaceAWSRegion", "parameters": [ { - "type": "integer", - "description": "ACL line ID", + "type": "string", + "description": "AWS Region ID", "name": "id", "in": "path", "required": true }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/acl" + "$ref": "#/definitions/awsRegion" } - }, - { - "$ref": "#/parameters/transaction_id" - }, - { - "$ref": "#/parameters/version" - }, - { - "$ref": "#/parameters/force_reload" } ], "responses": { "200": { - "description": "ACL line replaced", - "schema": { - "$ref": "#/definitions/acl" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", + "description": "Resource updated", "schema": { - "$ref": "#/definitions/acl" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "$ref": "#/definitions/awsRegion" } }, "400": { @@ -471,63 +427,24 @@ func init() { } }, "delete": { - "description": "Deletes a ACL line configuration by it's ID from the specified parent.", + "description": "Delete an AWS region configuration by it's id.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" + "ServiceDiscovery" ], - "summary": "Delete a ACL line", - "operationId": "deleteAcl", + "summary": "Delete an AWS region", + "operationId": "deleteAWSRegion", "parameters": [ { - "type": "integer", - "description": "ACL line ID", + "type": "string", + "description": "AWS region ID", "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" - }, - { - "$ref": "#/parameters/version" - }, - { - "$ref": "#/parameters/force_reload" } ], "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, "204": { - "description": "ACL line deleted" + "description": "Resource deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -538,50 +455,19 @@ func init() { } } }, - "/services/haproxy/configuration/backend_switching_rules": { + "/service_discovery/consul": { "get": { - "description": "Returns all Backend Switching Rules that are configured in specified frontend.", + "description": "Returns all configured Consul servers.", "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" - ], - "summary": "Return an array of all Backend Switching Rules", - "operationId": "getBackendSwitchingRules", - "parameters": [ - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" - } + "ServiceDiscovery" ], + "summary": "Return an array of all configured Consul servers", + "operationId": "getConsuls", "responses": { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backend_switching_rules" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/consuls" } }, "default": { @@ -590,57 +476,27 @@ func init() { } }, "post": { - "description": "Adds a new Backend Switching Rule of the specified type in the specified frontend.", + "description": "Adds a new Consul server.", "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" + "ServiceDiscovery" ], - "summary": "Add a new Backend Switching Rule", - "operationId": "createBackendSwitchingRule", + "summary": "Add a new Consul server", + "operationId": "createConsul", "parameters": [ - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/backend_switching_rule" + "$ref": "#/definitions/consul" } - }, - { - "$ref": "#/parameters/transaction_id" - }, - { - "$ref": "#/parameters/version" - }, - { - "$ref": "#/parameters/force_reload" } ], "responses": { "201": { - "description": "Backend Switching Rule created", - "schema": { - "$ref": "#/definitions/backend_switching_rule" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", + "description": "Consul created", "schema": { - "$ref": "#/definitions/backend_switching_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "$ref": "#/definitions/consul" } }, "400": { @@ -655,54 +511,28 @@ func init() { } } }, - "/services/haproxy/configuration/backend_switching_rules/{id}": { + "/service_discovery/consul/{id}": { "get": { - "description": "Returns one Backend Switching Rule configuration by it's ID in the specified frontend.", + "description": "Returns one Consul server configuration by it's id.", "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" + "ServiceDiscovery" ], - "summary": "Return one Backend Switching Rule", - "operationId": "getBackendSwitchingRule", + "summary": "Return one Consul server", + "operationId": "getConsul", "parameters": [ { - "type": "integer", - "description": "Switching Rule ID", + "type": "string", + "description": "Consul server id", "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" } ], "responses": { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backend_switching_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/consul" } }, "404": { @@ -714,64 +544,34 @@ func init() { } }, "put": { - "description": "Replaces a Backend Switching Rule configuration by it's ID in the specified frontend.", + "description": "Replaces a Consul server configuration by it's id.", "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" + "ServiceDiscovery" ], - "summary": "Replace a Backend Switching Rule", - "operationId": "replaceBackendSwitchingRule", + "summary": "Replace a Consul server", + "operationId": "replaceConsul", "parameters": [ { - "type": "integer", - "description": "Switching Rule ID", + "type": "string", + "description": "Consul Index", "name": "id", "in": "path", "required": true }, - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/backend_switching_rule" + "$ref": "#/definitions/consul" } - }, - { - "$ref": "#/parameters/transaction_id" - }, - { - "$ref": "#/parameters/version" - }, - { - "$ref": "#/parameters/force_reload" } ], "responses": { "200": { - "description": "Backend Switching Rule replaced", - "schema": { - "$ref": "#/definitions/backend_switching_rule" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", + "description": "Consul server replaced", "schema": { - "$ref": "#/definitions/backend_switching_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "$ref": "#/definitions/consul" } }, "400": { @@ -786,51 +586,24 @@ func init() { } }, "delete": { - "description": "Deletes a Backend Switching Rule configuration by it's ID from the specified frontend.", + "description": "Deletes a Consul server configuration by it's id.", "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" + "ServiceDiscovery" ], - "summary": "Delete a Backend Switching Rule", - "operationId": "deleteBackendSwitchingRule", + "summary": "Delete a Consul server", + "operationId": "deleteConsul", "parameters": [ { - "type": "integer", - "description": "Switching Rule ID", + "type": "string", + "description": "Consul server Index", "name": "id", "in": "path", "required": true - }, - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" - }, - { - "$ref": "#/parameters/version" - }, - { - "$ref": "#/parameters/force_reload" } ], "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, "204": { - "description": "Backend Switching Rule deleted" + "description": "Consul server deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -841,40 +614,100 @@ func init() { } } }, - "/services/haproxy/configuration/backends": { + "/services": { "get": { - "description": "Returns an array of all configured backends.", - "tags": [ - "Backend", - "HAProxy configuration management" + "description": "Returns a list of API managed services endpoints.", + "produces": [ + "application/json" ], - "summary": "Return an array of backends", - "operationId": "getBackends", - "parameters": [ - { - "$ref": "#/parameters/transaction_id" - } + "tags": [ + "Discovery" ], + "summary": "Return list of service endpoints", + "operationId": "getServicesEndpoints", "responses": { "200": { - "description": "Successful operation", + "description": "Success", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backends" - } - } + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy": { + "get": { + "description": "Returns a list of HAProxy related endpoints.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy related endpoints", + "operationId": "getHaproxyEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration": { + "get": { + "description": "Returns a list of endpoints to be used for advanced configuration of HAProxy objects.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy advanced configuration endpoints", + "operationId": "getConfigurationEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/acme": { + "get": { + "description": "Returns an array of all the configured ACME providers", + "tags": [ + "Acme" + ], + "summary": "Return all the ACME providers", + "operationId": "getAcmeProviders", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acme_providers" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -885,20 +718,19 @@ func init() { } }, "post": { - "description": "Adds a new backend to the configuration file.", + "description": "Creates a new acme section", "tags": [ - "Backend", - "HAProxy configuration management" + "Acme" ], - "summary": "Add a backend", - "operationId": "createBackend", + "summary": "Add a new Acme provider", + "operationId": "createAcmeProvider", "parameters": [ { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/backend" + "$ref": "#/definitions/acme_provider" } }, { @@ -913,15 +745,15 @@ func init() { ], "responses": { "201": { - "description": "Backend created", + "description": "Log Profile created", "schema": { - "$ref": "#/definitions/backend" + "$ref": "#/definitions/acme_provider" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/backend" + "$ref": "#/definitions/acme_provider" }, "headers": { "Reload-ID": { @@ -942,19 +774,18 @@ func init() { } } }, - "/services/haproxy/configuration/backends/{name}": { + "/services/haproxy/configuration/acme/{name}": { "get": { - "description": "Returns one backend configuration by it's name.", + "description": "Find an acme section by its name", "tags": [ - "Backend", - "HAProxy configuration management" + "Acme" ], - "summary": "Return a backend", - "operationId": "getBackend", + "summary": "Find an ACME provider", + "operationId": "getAcmeProvider", "parameters": [ { "type": "string", - "description": "Backend name", + "description": "acme section name", "name": "name", "in": "path", "required": true @@ -967,19 +798,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backend" - } - } + "$ref": "#/definitions/acme_provider" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -993,17 +816,16 @@ func init() { } }, "put": { - "description": "Replaces a backend configuration by it's name.", + "description": "Modifies a acme_provider's configuration by its name", "tags": [ - "Backend", - "HAProxy configuration management" + "Acme" ], - "summary": "Replace a backend", - "operationId": "replaceBackend", + "summary": "Modify an ACME provider", + "operationId": "editAcmeProvider", "parameters": [ { "type": "string", - "description": "Backend name", + "description": "acme section name", "name": "name", "in": "path", "required": true @@ -1013,7 +835,7 @@ func init() { "in": "body", "required": true, "schema": { - "$ref": "#/definitions/backend" + "$ref": "#/definitions/acme_provider" } }, { @@ -1028,15 +850,15 @@ func init() { ], "responses": { "200": { - "description": "Backend replaced", + "description": "acme_provider configuration updated", "schema": { - "$ref": "#/definitions/backend" + "$ref": "#/definitions/acme_provider" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/backend" + "$ref": "#/definitions/acme_provider" }, "headers": { "Reload-ID": { @@ -1057,17 +879,16 @@ func init() { } }, "delete": { - "description": "Deletes a frontend from the configuration by it's name.", + "description": "Deletes an acme section from the configuration", "tags": [ - "Backend", - "HAProxy configuration management" + "Acme" ], - "summary": "Delete a backend", - "operationId": "deleteBackend", + "summary": "Delete an ACME provider", + "operationId": "deleteAcmeProvider", "parameters": [ { "type": "string", - "description": "Backend name", + "description": "acme section name", "name": "name", "in": "path", "required": true @@ -1093,7 +914,7 @@ func init() { } }, "204": { - "description": "Backend deleted" + "description": "acme provider deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -1104,48 +925,31 @@ func init() { } } }, - "/services/haproxy/configuration/binds": { + "/services/haproxy/configuration/backends": { "get": { - "description": "Returns an array of all binds that are configured in specified frontend.", + "description": "Returns an array of all configured backends.", "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" + "Backend" ], - "summary": "Return an array of binds", - "operationId": "getBinds", + "summary": "Return an array of backends", + "operationId": "getBackends", "parameters": [ { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true + "$ref": "#/parameters/transaction_id" }, { - "$ref": "#/parameters/transaction_id" + "$ref": "#/parameters/full_section" } ], "responses": { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/binds" - } - } + "$ref": "#/definitions/backends" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -1156,28 +960,19 @@ func init() { } }, "post": { - "description": "Adds a new bind in the specified frontend in the configuration file.", + "description": "Adds a new backend to the configuration file.", "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" + "Backend" ], - "summary": "Add a new bind", - "operationId": "createBind", + "summary": "Add a backend", + "operationId": "createBackend", "parameters": [ - { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true - }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/bind" + "$ref": "#/definitions/backend" } }, { @@ -1188,19 +983,22 @@ func init() { }, { "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" } ], "responses": { "201": { - "description": "Bind created", + "description": "Backend created", "schema": { - "$ref": "#/definitions/bind" + "$ref": "#/definitions/backend" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/bind" + "$ref": "#/definitions/backend" }, "headers": { "Reload-ID": { @@ -1221,58 +1019,44 @@ func init() { } } }, - "/services/haproxy/configuration/binds/{name}": { + "/services/haproxy/configuration/backends/{name}": { "get": { - "description": "Returns one bind configuration by it's name in the specified frontend.", + "description": "Returns one backend configuration by it's name.", "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" + "Backend" ], - "summary": "Return one bind", - "operationId": "getBind", + "summary": "Return a backend", + "operationId": "getBackend", "parameters": [ { "type": "string", - "description": "Bind name", + "description": "Backend name", "name": "name", "in": "path", "required": true }, { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true + "$ref": "#/parameters/transaction_id" }, { - "$ref": "#/parameters/transaction_id" + "$ref": "#/parameters/full_section" } ], "responses": { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/bind" - } - } + "$ref": "#/definitions/backend" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } }, "404": { - "$ref": "#/responses/AlreadyExists" + "$ref": "#/responses/NotFound" }, "default": { "$ref": "#/responses/DefaultError" @@ -1280,35 +1064,26 @@ func init() { } }, "put": { - "description": "Replaces a bind configuration by it's name in the specified frontend.", + "description": "Replaces a backend configuration by it's name.", "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" + "Backend" ], - "summary": "Replace a bind", - "operationId": "replaceBind", + "summary": "Replace a backend", + "operationId": "replaceBackend", "parameters": [ { "type": "string", - "description": "Bind name", + "description": "Backend name", "name": "name", "in": "path", "required": true }, - { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true - }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/bind" + "$ref": "#/definitions/backend" } }, { @@ -1319,19 +1094,22 @@ func init() { }, { "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" } ], "responses": { "200": { - "description": "Bind replaced", + "description": "Backend replaced", "schema": { - "$ref": "#/definitions/bind" + "$ref": "#/definitions/backend" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/bind" + "$ref": "#/definitions/backend" }, "headers": { "Reload-ID": { @@ -1352,29 +1130,20 @@ func init() { } }, "delete": { - "description": "Deletes a bind configuration by it's name in the specified frontend.", + "description": "Deletes a backend from the configuration by it's name.", "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" + "Backend" ], - "summary": "Delete a bind", - "operationId": "deleteBind", + "summary": "Delete a backend", + "operationId": "deleteBackend", "parameters": [ { "type": "string", - "description": "Bind name", + "description": "Backend name", "name": "name", "in": "path", "required": true }, - { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true - }, { "$ref": "#/parameters/transaction_id" }, @@ -1396,7 +1165,7 @@ func init() { } }, "204": { - "description": "Bind deleted" + "description": "Backend deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -1407,16 +1176,24 @@ func init() { } } }, - "/services/haproxy/configuration/defaults": { + "/services/haproxy/configuration/backends/{parent_name}/acls": { "get": { - "description": "Returns defaults part of configuration.", + "description": "Returns all ACL lines that are configured in specified parent.", "tags": [ - "Defaults", - "HAProxy configuration management" + "ACL" ], - "summary": "Return defaults part of configuration", - "operationId": "getDefaults", + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, { "$ref": "#/parameters/transaction_id" } @@ -1425,19 +1202,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/defaults" - } - } + "$ref": "#/definitions/acls" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -1448,20 +1217,22 @@ func init() { } }, "put": { - "description": "Replace defaults part of config", + "description": "Replaces a whole list of ACLs with the list given in parameter", "tags": [ - "Defaults", - "HAProxy configuration management" + "ACL" ], - "summary": "Replace defaults", - "operationId": "replaceDefaults", + "summary": "Replace an ACL list", + "operationId": "replaceAllAclBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/defaults" + "$ref": "#/definitions/acls" } }, { @@ -1476,15 +1247,15 @@ func init() { ], "responses": { "200": { - "description": "Defaults replaced", + "description": "All ACL lines replaced", "schema": { - "$ref": "#/definitions/defaults" + "$ref": "#/definitions/acls" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/defaults" + "$ref": "#/definitions/acls" }, "headers": { "Reload-ID": { @@ -1502,35 +1273,24 @@ func init() { } } }, - "/services/haproxy/configuration/filters": { + "/services/haproxy/configuration/backends/{parent_name}/acls/{index}": { "get": { - "description": "Returns all Filters that are configured in specified parent.", + "description": "Returns one ACL line configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" + "ACL" ], - "summary": "Return an array of all Filters", - "operationId": "getFilters", + "summary": "Return one ACL line", + "operationId": "getAclBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", "required": true }, { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -1540,66 +1300,47 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/filters" - } - } + "$ref": "#/definitions/acl" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } }, + "404": { + "$ref": "#/responses/NotFound" + }, "default": { "$ref": "#/responses/DefaultError" } } }, - "post": { - "description": "Adds a new Filter of the specified type in the specified parent.", + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" + "ACL" ], - "summary": "Add a new Filter", - "operationId": "createFilter", + "summary": "Replace a ACL line", + "operationId": "replaceAclBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", "required": true }, { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/filter" + "$ref": "#/definitions/acl" } }, { @@ -1613,16 +1354,16 @@ func init() { } ], "responses": { - "201": { - "description": "Filter created", + "200": { + "description": "ACL line replaced", "schema": { - "$ref": "#/definitions/filter" + "$ref": "#/definitions/acl" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/filter" + "$ref": "#/definitions/acl" }, "headers": { "Reload-ID": { @@ -1634,77 +1375,6 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, - "default": { - "$ref": "#/responses/DefaultError" - } - } - } - }, - "/services/haproxy/configuration/filters/{id}": { - "get": { - "description": "Returns one Filter configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" - ], - "summary": "Return one Filter", - "operationId": "getFilter", - "parameters": [ - { - "type": "integer", - "description": "Filter ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/filter" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, "404": { "$ref": "#/responses/NotFound" }, @@ -1713,48 +1383,30 @@ func init() { } } }, - "put": { - "description": "Replaces a Filter configuration by it's ID in the specified parent.", + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" + "ACL" ], - "summary": "Replace a Filter", - "operationId": "replaceFilter", + "summary": "Add a new ACL line", + "operationId": "createAclBackend", "parameters": [ { "type": "integer", - "description": "Filter ID", - "name": "id", + "description": "ACL line Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/filter" + "$ref": "#/definitions/acl" } }, { @@ -1768,16 +1420,16 @@ func init() { } ], "responses": { - "200": { - "description": "Filter replaced", + "201": { + "description": "ACL line created", "schema": { - "$ref": "#/definitions/filter" + "$ref": "#/definitions/acl" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/filter" + "$ref": "#/definitions/acl" }, "headers": { "Reload-ID": { @@ -1789,8 +1441,8 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "404": { - "$ref": "#/responses/NotFound" + "409": { + "$ref": "#/responses/AlreadyExists" }, "default": { "$ref": "#/responses/DefaultError" @@ -1798,40 +1450,22 @@ func init() { } }, "delete": { - "description": "Deletes a Filter configuration by it's ID from the specified parent.", + "description": "Deletes a ACL line configuration by it's index from the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" + "ACL" ], - "summary": "Delete a Filter", - "operationId": "deleteFilter", + "summary": "Delete a ACL line", + "operationId": "deleteAclBackend", "parameters": [ { "type": "integer", - "description": "Filter ID", - "name": "id", + "description": "ACL line Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -1854,7 +1488,7 @@ func init() { } }, "204": { - "description": "Filter deleted" + "description": "ACL line deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -1865,16 +1499,18 @@ func init() { } } }, - "/services/haproxy/configuration/frontends": { + "/services/haproxy/configuration/backends/{parent_name}/filters": { "get": { - "description": "Returns an array of all configured frontends.", + "description": "Returns all Filters that are configured in specified parent.", "tags": [ - "Frontend", - "HAProxy configuration management" + "Filter" ], - "summary": "Return an array of frontends", - "operationId": "getFrontends", + "summary": "Return an array of all Filters", + "operationId": "getAllFilterBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" } @@ -1883,22 +1519,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/frontends" - } - } + "$ref": "#/definitions/filters" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -1908,21 +1533,23 @@ func init() { } } }, - "post": { - "description": "Adds a new frontend to the configuration file.", + "put": { + "description": "Replaces a whole list of Filters with the list given in parameter", "tags": [ - "Frontend", - "HAProxy configuration management" + "Filter" ], - "summary": "Add a frontend", - "operationId": "createFrontend", + "summary": "Replace a Filter list", + "operationId": "replaceAllFilterBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/frontend" + "$ref": "#/definitions/filters" } }, { @@ -1936,16 +1563,16 @@ func init() { } ], "responses": { - "201": { - "description": "Frontend created", + "200": { + "description": "All Filter lines replaced", "schema": { - "$ref": "#/definitions/frontend" + "$ref": "#/definitions/filters" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/frontend" + "$ref": "#/definitions/filters" }, "headers": { "Reload-ID": { @@ -1957,32 +1584,31 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/configuration/frontends/{name}": { + "/services/haproxy/configuration/backends/{parent_name}/filters/{index}": { "get": { - "description": "Returns one frontend configuration by it's name.", + "description": "Returns one Filter configuration by it's index in the specified parent.", "tags": [ - "Frontend", - "HAProxy configuration management" + "Filter" ], - "summary": "Return a frontend", - "operationId": "getFrontend", + "summary": "Return one Filter", + "operationId": "getFilterBackend", "parameters": [ { - "type": "string", - "description": "Frontend name", - "name": "name", + "type": "integer", + "description": "Filter Index", + "name": "index", "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" } @@ -1991,19 +1617,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/frontend" - } - } + "$ref": "#/definitions/filter" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -2017,27 +1635,29 @@ func init() { } }, "put": { - "description": "Replaces a frontend configuration by it's name.", + "description": "Replaces a Filter configuration by it's index in the specified parent.", "tags": [ - "Frontend", - "HAProxy configuration management" + "Filter" ], - "summary": "Replace a frontend", - "operationId": "replaceFrontend", + "summary": "Replace a Filter", + "operationId": "replaceFilterBackend", "parameters": [ { - "type": "string", - "description": "Frontend name", - "name": "name", + "type": "integer", + "description": "Filter Index", + "name": "index", "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/frontend" + "$ref": "#/definitions/filter" } }, { @@ -2052,15 +1672,15 @@ func init() { ], "responses": { "200": { - "description": "Frontend replaced", + "description": "Filter replaced", "schema": { - "$ref": "#/definitions/frontend" + "$ref": "#/definitions/filter" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/frontend" + "$ref": "#/definitions/filter" }, "headers": { "Reload-ID": { @@ -2080,27 +1700,95 @@ func init() { } } }, - "delete": { - "description": "Deletes a frontend from the configuration by it's name.", + "post": { + "description": "Adds a new Filter of the specified type in the specified parent.", "tags": [ - "Frontend", - "HAProxy configuration management" + "Filter" ], - "summary": "Delete a frontend", - "operationId": "deleteFrontend", + "summary": "Add a new Filter", + "operationId": "createFilterBackend", "parameters": [ { - "type": "string", - "description": "Frontend name", - "name": "name", + "type": "integer", + "description": "Filter Index", + "name": "index", "in": "path", "required": true }, { - "$ref": "#/parameters/transaction_id" + "$ref": "#/parameters/parent_name" }, { - "$ref": "#/parameters/version" + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filter" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Filter created", + "schema": { + "$ref": "#/definitions/filter" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Filter configuration by it's index from the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Delete a Filter", + "operationId": "deleteFilterBackend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" }, { "$ref": "#/parameters/force_reload" @@ -2117,7 +1805,7 @@ func init() { } }, "204": { - "description": "Frontend deleted" + "description": "Filter deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -2128,16 +1816,18 @@ func init() { } } }, - "/services/haproxy/configuration/global": { + "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules": { "get": { - "description": "Returns global part of configuration.", + "description": "Returns all HTTP After Response Rules that are configured in specified parent.", "tags": [ - "Global", - "HAProxy configuration management" + "HTTPAfterResponseRule" ], - "summary": "Return a global part of configuration", - "operationId": "getGlobal", + "summary": "Return an array of all HTTP After Response Rules", + "operationId": "getAllHTTPAfterResponseRuleBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" } @@ -2146,19 +1836,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/global" - } - } + "$ref": "#/definitions/http_after_response_rules" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -2169,20 +1851,22 @@ func init() { } }, "put": { - "description": "Replace global part of config", + "description": "Replaces a whole list of HTTP After Response Rules with the list given in parameter", "tags": [ - "Global", - "HAProxy configuration management" + "HTTPAfterResponseRule" ], - "summary": "Replace global", - "operationId": "replaceGlobal", + "summary": "Replace an HTTP After Response Rules list", + "operationId": "replaceAllHTTPAfterResponseRuleBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/global" + "$ref": "#/definitions/http_after_response_rules" } }, { @@ -2197,15 +1881,15 @@ func init() { ], "responses": { "200": { - "description": "Global replaced", + "description": "All TTP After Response Rules lines replaced", "schema": { - "$ref": "#/definitions/global" + "$ref": "#/definitions/http_after_response_rules" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/global" + "$ref": "#/definitions/http_after_response_rules" }, "headers": { "Reload-ID": { @@ -2223,35 +1907,24 @@ func init() { } } }, - "/services/haproxy/configuration/http_request_rules": { + "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}": { "get": { - "description": "Returns all HTTP Request Rules that are configured in specified parent.", + "description": "Returns one HTTP After Response Rule configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" + "HTTPAfterResponseRule" ], - "summary": "Return an array of all HTTP Request Rules", - "operationId": "getHTTPRequestRules", + "summary": "Return one HTTP After Response Rule", + "operationId": "getHTTPAfterResponseRuleBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", "required": true }, { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -2261,66 +1934,47 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/http_request_rules" - } - } + "$ref": "#/definitions/http_after_response_rule" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } }, + "404": { + "$ref": "#/responses/NotFound" + }, "default": { "$ref": "#/responses/DefaultError" } } }, - "post": { - "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", + "put": { + "description": "Replaces a HTTP After Response Rule configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" + "HTTPAfterResponseRule" ], - "summary": "Add a new HTTP Request Rule", - "operationId": "createHTTPRequestRule", + "summary": "Replace a HTTP After Response Rule", + "operationId": "replaceHTTPAfterResponseRuleBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", "required": true }, { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/http_request_rule" + "$ref": "#/definitions/http_after_response_rule" } }, { @@ -2334,16 +1988,16 @@ func init() { } ], "responses": { - "201": { - "description": "HTTP Request Rule created", + "200": { + "description": "HTTP After Response Rule replaced", "schema": { - "$ref": "#/definitions/http_request_rule" + "$ref": "#/definitions/http_after_response_rule" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/http_request_rule" + "$ref": "#/definitions/http_after_response_rule" }, "headers": { "Reload-ID": { @@ -2355,77 +2009,6 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, - "default": { - "$ref": "#/responses/DefaultError" - } - } - } - }, - "/services/haproxy/configuration/http_request_rules/{id}": { - "get": { - "description": "Returns one HTTP Request Rule configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" - ], - "summary": "Return one HTTP Request Rule", - "operationId": "getHTTPRequestRule", - "parameters": [ - { - "type": "integer", - "description": "HTTP Request Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/http_request_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, "404": { "$ref": "#/responses/NotFound" }, @@ -2434,48 +2017,30 @@ func init() { } } }, - "put": { - "description": "Replaces a HTTP Request Rule configuration by it's ID in the specified parent.", + "post": { + "description": "Adds a new HTTP After Response Rule of the specified type in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" + "HTTPAfterResponseRule" ], - "summary": "Replace a HTTP Request Rule", - "operationId": "replaceHTTPRequestRule", + "summary": "Add a new HTTP After Response Rule", + "operationId": "createHTTPAfterResponseRuleBackend", "parameters": [ { "type": "integer", - "description": "HTTP Request Rule ID", - "name": "id", + "description": "HTTP After Response Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/http_request_rule" + "$ref": "#/definitions/http_after_response_rule" } }, { @@ -2489,16 +2054,16 @@ func init() { } ], "responses": { - "200": { - "description": "HTTP Request Rule replaced", + "201": { + "description": "HTTP Response Rule created", "schema": { - "$ref": "#/definitions/http_request_rule" + "$ref": "#/definitions/http_after_response_rule" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/http_request_rule" + "$ref": "#/definitions/http_after_response_rule" }, "headers": { "Reload-ID": { @@ -2510,8 +2075,8 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "404": { - "$ref": "#/responses/NotFound" + "409": { + "$ref": "#/responses/AlreadyExists" }, "default": { "$ref": "#/responses/DefaultError" @@ -2519,40 +2084,22 @@ func init() { } }, "delete": { - "description": "Deletes a HTTP Request Rule configuration by it's ID from the specified parent.", + "description": "Deletes a HTTP After Response Rule configuration by it's index from the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" + "HTTPAfterResponseRule" ], - "summary": "Delete a HTTP Request Rule", - "operationId": "deleteHTTPRequestRule", + "summary": "Delete a HTTP After Response Rule", + "operationId": "deleteHTTPAfterResponseRuleBackend", "parameters": [ { "type": "integer", - "description": "HTTP Request Rule ID", - "name": "id", + "description": "HTTP After Response Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -2575,7 +2122,7 @@ func init() { } }, "204": { - "description": "HTTP Request Rule deleted" + "description": "HTTP After Response Rule deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -2586,35 +2133,17 @@ func init() { } } }, - "/services/haproxy/configuration/http_response_rules": { + "/services/haproxy/configuration/backends/{parent_name}/http_checks": { "get": { - "description": "Returns all HTTP Response Rules that are configured in specified parent.", + "description": "Returns all HTTP checks that are configured in specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" + "HTTPCheck" ], - "summary": "Return an array of all HTTP Response Rules", - "operationId": "getHTTPResponseRules", + "summary": "Return an array of HTTP checks", + "operationId": "getAllHTTPCheckBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -2624,22 +2153,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/http_response_rules" - } - } + "$ref": "#/definitions/http_checks" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -2649,41 +2167,23 @@ func init() { } } }, - "post": { - "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", + "put": { + "description": "Replaces a whole list of HTTP checks with the list given in parameter", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" + "HTTPCheck" ], - "summary": "Add a new HTTP Response Rule", - "operationId": "createHTTPResponseRule", + "summary": "Replace an HTTP checks list", + "operationId": "replaceAllHTTPCheckBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/http_response_rule" + "$ref": "#/definitions/http_checks" } }, { @@ -2697,16 +2197,16 @@ func init() { } ], "responses": { - "201": { - "description": "HTTP Response Rule created", + "200": { + "description": "All HTTP checks lines replaced", "schema": { - "$ref": "#/definitions/http_response_rule" + "$ref": "#/definitions/http_checks" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/http_response_rule" + "$ref": "#/definitions/http_checks" }, "headers": { "Reload-ID": { @@ -2718,51 +2218,30 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/configuration/http_response_rules/{id}": { + "/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}": { "get": { - "description": "Returns one HTTP Response Rule configuration by it's ID in the specified parent.", + "description": "Returns one HTTP check configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" + "HTTPCheck" ], - "summary": "Return one HTTP Response Rule", - "operationId": "getHTTPResponseRule", + "summary": "Return one HTTP check", + "operationId": "getHTTPCheckBackend", "parameters": [ { "type": "integer", - "description": "HTTP Response Rule ID", - "name": "id", + "description": "HTTP Check Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -2772,19 +2251,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/http_response_rule" - } - } + "$ref": "#/definitions/http_check" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -2798,47 +2269,29 @@ func init() { } }, "put": { - "description": "Replaces a HTTP Response Rule configuration by it's ID in the specified parent.", + "description": "Replaces a HTTP Check configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" + "HTTPCheck" ], - "summary": "Replace a HTTP Response Rule", - "operationId": "replaceHTTPResponseRule", + "summary": "Replace a HTTP check", + "operationId": "replaceHTTPCheckBackend", "parameters": [ { "type": "integer", - "description": "HTTP Response Rule ID", - "name": "id", + "description": "HTTP Check Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/http_response_rule" + "$ref": "#/definitions/http_check" } }, { @@ -2853,15 +2306,15 @@ func init() { ], "responses": { "200": { - "description": "HTTP Response Rule replaced", + "description": "HTTP check replaced", "schema": { - "$ref": "#/definitions/http_response_rule" + "$ref": "#/definitions/http_check" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/http_response_rule" + "$ref": "#/definitions/http_check" }, "headers": { "Reload-ID": { @@ -2881,42 +2334,90 @@ func init() { } } }, - "delete": { - "description": "Deletes a HTTP Response Rule configuration by it's ID from the specified parent.", + "post": { + "description": "Adds a new HTTP check of the specified type in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" + "HTTPCheck" ], - "summary": "Delete a HTTP Response Rule", - "operationId": "deleteHTTPResponseRule", + "summary": "Add a new HTTP check", + "operationId": "createHTTPCheckBackend", "parameters": [ { "type": "integer", - "description": "HTTP Response Rule ID", - "name": "id", + "description": "HTTP check Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_check" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP check created", + "schema": { + "$ref": "#/definitions/http_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP check configuration by it's index from the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Delete a HTTP check", + "operationId": "deleteHTTPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP check Index", + "name": "index", + "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" }, @@ -2938,7 +2439,7 @@ func init() { } }, "204": { - "description": "HTTP Response Rule deleted" + "description": "HTTP check deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -2949,35 +2450,17 @@ func init() { } } }, - "/services/haproxy/configuration/log_targets": { + "/services/haproxy/configuration/backends/{parent_name}/http_error_rules": { "get": { - "description": "Returns all Log Targets that are configured in specified parent.", + "description": "Returns all HTTP Error Rules that are configured in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" + "HTTPErrorRule" ], - "summary": "Return an array of all Log Targets", - "operationId": "getLogTargets", + "summary": "Return an array of all HTTP Error Rules", + "operationId": "getAllHTTPErrorRuleBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -2987,22 +2470,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/log_targets" - } - } + "$ref": "#/definitions/http_error_rules" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -3012,41 +2484,23 @@ func init() { } } }, - "post": { - "description": "Adds a new Log Target of the specified type in the specified parent.", + "put": { + "description": "Replaces a whole list of HTTP Error Rules with the list given in parameter", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" + "HTTPErrorRule" ], - "summary": "Add a new Log Target", - "operationId": "createLogTarget", + "summary": "Replace an HTTP Error Rules list", + "operationId": "replaceAllHTTPErrorRuleBackend", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/log_target" + "$ref": "#/definitions/http_error_rules" } }, { @@ -3060,16 +2514,16 @@ func init() { } ], "responses": { - "201": { - "description": "Log Target created", + "200": { + "description": "All HTTP Error Rules lines replaced", "schema": { - "$ref": "#/definitions/log_target" + "$ref": "#/definitions/http_error_rules" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/log_target" + "$ref": "#/definitions/http_error_rules" }, "headers": { "Reload-ID": { @@ -3081,51 +2535,30 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/configuration/log_targets/{id}": { + "/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}": { "get": { - "description": "Returns one Log Target configuration by it's ID in the specified parent.", + "description": "Returns one HTTP Error Rule configuration by its index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" + "HTTPErrorRule" ], - "summary": "Return one Log Target", - "operationId": "getLogTarget", + "summary": "Return one HTTP Error Rule", + "operationId": "getHTTPErrorRuleBackend", "parameters": [ { "type": "integer", - "description": "Log Target ID", - "name": "id", + "description": "HTTP Error Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -3135,19 +2568,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/log_target" - } - } + "$ref": "#/definitions/http_error_rule" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -3161,47 +2586,29 @@ func init() { } }, "put": { - "description": "Replaces a Log Target configuration by it's ID in the specified parent.", + "description": "Replaces a HTTP Error Rule configuration by its index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" + "HTTPErrorRule" ], - "summary": "Replace a Log Target", - "operationId": "replaceLogTarget", + "summary": "Replace a HTTP Error Rule", + "operationId": "replaceHTTPErrorRuleBackend", "parameters": [ { "type": "integer", - "description": "Log Target ID", - "name": "id", + "description": "HTTP Error Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/log_target" + "$ref": "#/definitions/http_error_rule" } }, { @@ -3216,15 +2623,15 @@ func init() { ], "responses": { "200": { - "description": "Log Target replaced", + "description": "HTTP Error Rule replaced", "schema": { - "$ref": "#/definitions/log_target" + "$ref": "#/definitions/http_error_rule" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/log_target" + "$ref": "#/definitions/http_error_rule" }, "headers": { "Reload-ID": { @@ -3244,42 +2651,90 @@ func init() { } } }, - "delete": { - "description": "Deletes a Log Target configuration by it's ID from the specified parent.", + "post": { + "description": "Adds a new HTTP Error Rule of the specified type in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" + "HTTPErrorRule" ], - "summary": "Delete a Log Target", - "operationId": "deleteLogTarget", + "summary": "Add a new HTTP Error Rule", + "operationId": "createHTTPErrorRuleBackend", "parameters": [ { "type": "integer", - "description": "Log Target ID", - "name": "id", + "description": "HTTP Error Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Error Rule created", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Error Rule configuration by its index from the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Delete a HTTP Error Rule", + "operationId": "deleteHTTPErrorRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" }, @@ -3301,7 +2756,7 @@ func init() { } }, "204": { - "description": "Log Target deleted" + "description": "HTTP Error Rule deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -3312,46 +2767,31 @@ func init() { } } }, - "/services/haproxy/configuration/raw": { + "/services/haproxy/configuration/backends/{parent_name}/http_request_rules": { "get": { - "description": "Returns HAProxy configuration file in plain text", - "produces": [ - "text/plain" - ], + "description": "Returns all HTTP Request Rules that are configured in specified parent.", "tags": [ - "Configuration", - "HAProxy configuration management" + "HTTPRequestRule" ], - "summary": "Return HAProxy configuration", - "operationId": "getHAProxyConfiguration", + "summary": "Return an array of all HTTP Request Rules", + "operationId": "getAllHTTPRequestRuleBackend", "parameters": [ { - "$ref": "#/parameters/transaction_id" + "$ref": "#/parameters/parent_name" }, { - "$ref": "#/parameters/version" + "$ref": "#/parameters/transaction_id" } ], "responses": { "200": { - "description": "Operation successful", + "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "type": "string" - } - } + "$ref": "#/definitions/http_request_rules" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -3361,29 +2801,28 @@ func init() { } } }, - "post": { - "description": "Push a new haproxy configuration file in plain text", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], + "put": { + "description": "Replaces a whole list of HTTP Request Rules with the list given in parameter", "tags": [ - "Configuration", - "HAProxy configuration management" + "HTTPRequestRule" ], - "summary": "Push new haproxy configuration", - "operationId": "postHAProxyConfiguration", + "summary": "Replace an HTTP Request Rule list", + "operationId": "replaceAllHTTPRequestRuleBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "type": "string" + "$ref": "#/definitions/http_request_rules" } }, + { + "$ref": "#/parameters/transaction_id" + }, { "$ref": "#/parameters/version" }, @@ -3392,16 +2831,16 @@ func init() { } ], "responses": { - "201": { - "description": "New HAProxy configuration pushed", + "200": { + "description": "All HTTP Request Rule lines replaced", "schema": { - "type": "string" + "$ref": "#/definitions/http_request_rules" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "type": "string" + "$ref": "#/definitions/http_request_rules" }, "headers": { "Reload-ID": { @@ -3419,24 +2858,25 @@ func init() { } } }, - "/services/haproxy/configuration/server_switching_rules": { + "/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}": { "get": { - "description": "Returns all Backend Switching Rules that are configured in specified backend.", + "description": "Returns one HTTP Request Rule configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" + "HTTPRequestRule" ], - "summary": "Return an array of all Server Switching Rules", - "operationId": "getServerSwitchingRules", + "summary": "Return one HTTP Request Rule", + "operationId": "getHTTPRequestRuleBackend", "parameters": [ { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" } @@ -3445,54 +2885,47 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/server_switching_rules" - } - } + "$ref": "#/definitions/http_request_rule" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } }, + "404": { + "$ref": "#/responses/NotFound" + }, "default": { "$ref": "#/responses/DefaultError" } } }, - "post": { - "description": "Adds a new Server Switching Rule of the specified type in the specified backend.", + "put": { + "description": "Replaces a HTTP Request Rule configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" + "HTTPRequestRule" ], - "summary": "Add a new Server Switching Rule", - "operationId": "createServerSwitchingRule", + "summary": "Replace a HTTP Request Rule", + "operationId": "replaceHTTPRequestRuleBackend", "parameters": [ { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/server_switching_rule" + "$ref": "#/definitions/http_request_rule" } }, { @@ -3506,16 +2939,16 @@ func init() { } ], "responses": { - "201": { - "description": "Server Switching Rule created", + "200": { + "description": "HTTP Request Rule replaced", "schema": { - "$ref": "#/definitions/server_switching_rule" + "$ref": "#/definitions/http_request_rule" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/server_switching_rule" + "$ref": "#/definitions/http_request_rule" }, "headers": { "Reload-ID": { @@ -3527,65 +2960,6 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, - "default": { - "$ref": "#/responses/DefaultError" - } - } - } - }, - "/services/haproxy/configuration/server_switching_rules/{id}": { - "get": { - "description": "Returns one Server Switching Rule configuration by it's ID in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" - ], - "summary": "Return one Server Switching Rule", - "operationId": "getServerSwitchingRule", - "parameters": [ - { - "type": "integer", - "description": "Switching Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "$ref": "#/parameters/transaction_id" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/server_switching_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, "404": { "$ref": "#/responses/NotFound" }, @@ -3594,36 +2968,30 @@ func init() { } } }, - "put": { - "description": "Replaces a Server Switching Rule configuration by it's ID in the specified backend.", + "post": { + "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" + "HTTPRequestRule" ], - "summary": "Replace a Server Switching Rule", - "operationId": "replaceServerSwitchingRule", + "summary": "Add a new HTTP Request Rule", + "operationId": "createHTTPRequestRuleBackend", "parameters": [ { "type": "integer", - "description": "Switching Rule ID", - "name": "id", + "description": "HTTP Request Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/server_switching_rule" + "$ref": "#/definitions/http_request_rule" } }, { @@ -3637,16 +3005,16 @@ func init() { } ], "responses": { - "200": { - "description": "Server Switching Rule replaced", + "201": { + "description": "HTTP Request Rule created", "schema": { - "$ref": "#/definitions/server_switching_rule" + "$ref": "#/definitions/http_request_rule" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/server_switching_rule" + "$ref": "#/definitions/http_request_rule" }, "headers": { "Reload-ID": { @@ -3658,8 +3026,8 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "404": { - "$ref": "#/responses/NotFound" + "409": { + "$ref": "#/responses/AlreadyExists" }, "default": { "$ref": "#/responses/DefaultError" @@ -3667,28 +3035,22 @@ func init() { } }, "delete": { - "description": "Deletes a Server Switching Rule configuration by it's ID from the specified backend.", + "description": "Deletes a HTTP Request Rule configuration by it's index from the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" + "HTTPRequestRule" ], - "summary": "Delete a Server Switching Rule", - "operationId": "deleteServerSwitchingRule", + "summary": "Delete a HTTP Request Rule", + "operationId": "deleteHTTPRequestRuleBackend", "parameters": [ { "type": "integer", - "description": "Switching Rule ID", - "name": "id", + "description": "HTTP Request Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -3711,7 +3073,7 @@ func init() { } }, "204": { - "description": "Server Switching Rule deleted" + "description": "HTTP Request Rule deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -3722,23 +3084,17 @@ func init() { } } }, - "/services/haproxy/configuration/servers": { + "/services/haproxy/configuration/backends/{parent_name}/http_response_rules": { "get": { - "description": "Returns an array of all servers that are configured in specified backend.", + "description": "Returns all HTTP Response Rules that are configured in specified parent.", "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" + "HTTPResponseRule" ], - "summary": "Return an array of servers", - "operationId": "getServers", + "summary": "Return an array of all HTTP Response Rules", + "operationId": "getAllHTTPResponseRuleBackend", "parameters": [ { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -3748,22 +3104,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/servers" - } - } + "$ref": "#/definitions/http_response_rules" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -3773,29 +3118,23 @@ func init() { } } }, - "post": { - "description": "Adds a new server in the specified backend in the configuration file.", + "put": { + "description": "Replaces a whole list of HTTP Response Rules with the list given in parameter", "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" + "HTTPResponseRule" ], - "summary": "Add a new server", - "operationId": "createServer", + "summary": "Replace an HTTP Response Rule list", + "operationId": "replaceAllHTTPResponseRuleBackend", "parameters": [ { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/server" + "$ref": "#/definitions/http_response_rules" } }, { @@ -3809,16 +3148,16 @@ func init() { } ], "responses": { - "201": { - "description": "Server created", + "200": { + "description": "All HTTP Response Rule lines replaced", "schema": { - "$ref": "#/definitions/server" + "$ref": "#/definitions/http_response_rules" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/server" + "$ref": "#/definitions/http_response_rules" }, "headers": { "Reload-ID": { @@ -3830,39 +3169,30 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/configuration/servers/{name}": { + "/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}": { "get": { - "description": "Returns one server configuration by it's name in the specified backend.", + "description": "Returns one HTTP Response Rule configuration by it's index in the specified parent.", "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" + "HTTPResponseRule" ], - "summary": "Return one server", - "operationId": "getServer", + "summary": "Return one HTTP Response Rule", + "operationId": "getHTTPResponseRuleBackend", "parameters": [ { - "type": "string", - "description": "Server name", - "name": "name", + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -3872,19 +3202,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/server" - } - } + "$ref": "#/definitions/http_response_rule" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -3898,35 +3220,29 @@ func init() { } }, "put": { - "description": "Replaces a server configuration by it's name in the specified backend.", + "description": "Replaces a HTTP Response Rule configuration by it's index in the specified parent.", "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" + "HTTPResponseRule" ], - "summary": "Replace a server", - "operationId": "replaceServer", + "summary": "Replace a HTTP Response Rule", + "operationId": "replaceHTTPResponseRuleBackend", "parameters": [ { - "type": "string", - "description": "Server name", - "name": "name", + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/server" + "$ref": "#/definitions/http_response_rule" } }, { @@ -3941,15 +3257,15 @@ func init() { ], "responses": { "200": { - "description": "Server replaced", + "description": "HTTP Response Rule replaced", "schema": { - "$ref": "#/definitions/server" + "$ref": "#/definitions/http_response_rule" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/server" + "$ref": "#/definitions/http_response_rule" }, "headers": { "Reload-ID": { @@ -3969,30 +3285,90 @@ func init() { } } }, - "delete": { - "description": "Deletes a server configuration by it's name in the specified backend.", + "post": { + "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" + "HTTPResponseRule" ], - "summary": "Delete a server", - "operationId": "deleteServer", + "summary": "Add a new HTTP Response Rule", + "operationId": "createHTTPResponseRuleBackend", "parameters": [ { - "type": "string", - "description": "Server name", - "name": "name", + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Delete a HTTP Response Rule", + "operationId": "deleteHTTPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" }, @@ -4014,7 +3390,7 @@ func init() { } }, "204": { - "description": "Server deleted" + "description": "HTTP Response Rule deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -4025,23 +3401,17 @@ func init() { } } }, - "/services/haproxy/configuration/stick_rules": { + "/services/haproxy/configuration/backends/{parent_name}/log_targets": { "get": { - "description": "Returns all Stick Rules that are configured in specified backend.", + "description": "Returns all Log Targets that are configured in specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" + "LogTarget" ], - "summary": "Return an array of all Stick Rules", - "operationId": "getStickRules", + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetBackend", "parameters": [ { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -4051,22 +3421,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/stick_rules" - } - } + "$ref": "#/definitions/log_targets" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -4076,29 +3435,23 @@ func init() { } } }, - "post": { - "description": "Adds a new Stick Rule of the specified type in the specified backend.", + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" + "LogTarget" ], - "summary": "Add a new Stick Rule", - "operationId": "createStickRule", + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetBackend", "parameters": [ { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/stick_rule" + "$ref": "#/definitions/log_targets" } }, { @@ -4112,16 +3465,16 @@ func init() { } ], "responses": { - "201": { - "description": "Stick Rule created", + "200": { + "description": "All Log Target lines replaced", "schema": { - "$ref": "#/definitions/stick_rule" + "$ref": "#/definitions/log_targets" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/stick_rule" + "$ref": "#/definitions/log_targets" }, "headers": { "Reload-ID": { @@ -4133,39 +3486,30 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/configuration/stick_rules/{id}": { + "/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}": { "get": { - "description": "Returns one Stick Rule configuration by it's ID in the specified backend.", + "description": "Returns one Log Target configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" + "LogTarget" ], - "summary": "Return one Stick Rule", - "operationId": "getStickRule", + "summary": "Return one Log Target", + "operationId": "getLogTargetBackend", "parameters": [ { "type": "integer", - "description": "Stick Rule ID", - "name": "id", + "description": "Log Target Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -4175,19 +3519,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/stick_rule" - } - } + "$ref": "#/definitions/log_target" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -4201,35 +3537,29 @@ func init() { } }, "put": { - "description": "Replaces a Stick Rule configuration by it's ID in the specified backend.", + "description": "Replaces a Log Target configuration by it's index in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" + "LogTarget" ], - "summary": "Replace a Stick Rule", - "operationId": "replaceStickRule", + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetBackend", "parameters": [ { "type": "integer", - "description": "Stick Rule ID", - "name": "id", + "description": "Log Target Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/stick_rule" + "$ref": "#/definitions/log_target" } }, { @@ -4244,15 +3574,15 @@ func init() { ], "responses": { "200": { - "description": "Stick Rule replaced", + "description": "Log Target replaced", "schema": { - "$ref": "#/definitions/stick_rule" + "$ref": "#/definitions/log_target" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/stick_rule" + "$ref": "#/definitions/log_target" }, "headers": { "Reload-ID": { @@ -4272,30 +3602,90 @@ func init() { } } }, - "delete": { - "description": "Deletes a Stick Rule configuration by it's ID from the specified backend.", + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" + "LogTarget" ], - "summary": "Delete a Stick Rule", - "operationId": "deleteStickRule", + "summary": "Add a new Log Target", + "operationId": "createLogTargetBackend", "parameters": [ { "type": "integer", - "description": "Stick Rule ID", - "name": "id", + "description": "Log Target Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetBackend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" }, @@ -4317,7 +3707,7 @@ func init() { } }, "204": { - "description": "Stick Rule deleted" + "description": "Log Target deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -4328,35 +3718,17 @@ func init() { } } }, - "/services/haproxy/configuration/tcp_request_rules": { + "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules": { "get": { - "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", + "description": "Returns all Backend Switching Rules that are configured in specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" + "ServerSwitchingRule" ], - "summary": "Return an array of all TCP Request Rules", - "operationId": "getTCPRequestRules", + "summary": "Return an array of all Server Switching Rules", + "operationId": "getServerSwitchingRules", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -4366,22 +3738,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_request_rules" - } - } + "$ref": "#/definitions/server_switching_rules" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -4391,41 +3752,23 @@ func init() { } } }, - "post": { - "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", + "put": { + "description": "Replaces a whole list of Server Switching Rules with the list given in parameter", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" + "ServerSwitchingRule" ], - "summary": "Add a new TCP Request Rule", - "operationId": "createTCPRequestRule", + "summary": "Replace an Server Switching Rule list", + "operationId": "replaceServerSwitchingRules", "parameters": [ { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/tcp_request_rule" + "$ref": "#/definitions/server_switching_rules" } }, { @@ -4439,16 +3782,16 @@ func init() { } ], "responses": { - "201": { - "description": "TCP Request Rule created", + "200": { + "description": "All Server Switching Rule lines replaced", "schema": { - "$ref": "#/definitions/tcp_request_rule" + "$ref": "#/definitions/server_switching_rules" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/tcp_request_rule" + "$ref": "#/definitions/server_switching_rules" }, "headers": { "Reload-ID": { @@ -4460,51 +3803,30 @@ func init() { "400": { "$ref": "#/responses/BadRequest" }, - "409": { - "$ref": "#/responses/AlreadyExists" - }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/configuration/tcp_request_rules/{id}": { + "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}": { "get": { - "description": "Returns one TCP Request Rule configuration by it's ID in the specified parent.", + "description": "Returns one Server Switching Rule configuration by it's index in the specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" + "ServerSwitchingRule" ], - "summary": "Return one TCP Request Rule", - "operationId": "getTCPRequestRule", + "summary": "Return one Server Switching Rule", + "operationId": "getServerSwitchingRule", "parameters": [ { "type": "integer", - "description": "TCP Request Rule ID", - "name": "id", + "description": "Switching Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -4514,19 +3836,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_request_rule" - } - } + "$ref": "#/definitions/server_switching_rule" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -4540,47 +3854,29 @@ func init() { } }, "put": { - "description": "Replaces a TCP Request Rule configuration by it's ID in the specified parent.", + "description": "Replaces a Server Switching Rule configuration by it's index in the specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" + "ServerSwitchingRule" ], - "summary": "Replace a TCP Request Rule", - "operationId": "replaceTCPRequestRule", + "summary": "Replace a Server Switching Rule", + "operationId": "replaceServerSwitchingRule", "parameters": [ { "type": "integer", - "description": "TCP Request Rule ID", - "name": "id", + "description": "Switching Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/tcp_request_rule" + "$ref": "#/definitions/server_switching_rule" } }, { @@ -4595,15 +3891,15 @@ func init() { ], "responses": { "200": { - "description": "TCP Request Rule replaced", + "description": "Server Switching Rule replaced", "schema": { - "$ref": "#/definitions/tcp_request_rule" + "$ref": "#/definitions/server_switching_rule" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/tcp_request_rule" + "$ref": "#/definitions/server_switching_rule" }, "headers": { "Reload-ID": { @@ -4623,42 +3919,90 @@ func init() { } } }, - "delete": { - "description": "Deletes a TCP Request Rule configuration by it's ID from the specified parent.", + "post": { + "description": "Adds a new Server Switching Rule of the specified type in the specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" + "ServerSwitchingRule" ], - "summary": "Delete a TCP Request Rule", - "operationId": "deleteTCPRequestRule", + "summary": "Add a new Server Switching Rule", + "operationId": "createServerSwitchingRule", "parameters": [ { "type": "integer", - "description": "TCP Request Rule ID", - "name": "id", + "description": "Switching Rule Index", + "name": "index", "in": "path", "required": true }, { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server_switching_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Server Switching Rule created", + "schema": { + "$ref": "#/definitions/server_switching_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server_switching_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Server Switching Rule configuration by it's index from the specified backend.", + "tags": [ + "ServerSwitchingRule" + ], + "summary": "Delete a Server Switching Rule", + "operationId": "deleteServerSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" }, @@ -4680,7 +4024,7 @@ func init() { } }, "204": { - "description": "TCP Request Rule deleted" + "description": "Server Switching Rule deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -4691,24 +4035,17 @@ func init() { } } }, - "/services/haproxy/configuration/tcp_response_rules": { + "/services/haproxy/configuration/backends/{parent_name}/server_templates": { "get": { - "description": "Returns all TCP Response Rules that are configured in specified backend.", + "description": "Returns an array of all server templates that are configured in specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" + "ServerTemplate" ], - "summary": "Return an array of all TCP Response Rules", - "operationId": "getTCPResponseRules", + "summary": "Return an array of server templates", + "operationId": "getServerTemplates", "parameters": [ { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -4718,22 +4055,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_response_rules" - } - } + "$ref": "#/definitions/server_templates" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -4744,29 +4070,22 @@ func init() { } }, "post": { - "description": "Adds a new TCP Response Rule of the specified type in the specified backend.", + "description": "Adds a new server template in the specified backend in the configuration file.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" + "ServerTemplate" ], - "summary": "Add a new TCP Response Rule", - "operationId": "createTCPResponseRule", + "summary": "Add a new server template", + "operationId": "createServerTemplate", "parameters": [ { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/tcp_response_rule" + "$ref": "#/definitions/server_template" } }, { @@ -4781,15 +4100,15 @@ func init() { ], "responses": { "201": { - "description": "TCP Response Rule created", + "description": "Server template created", "schema": { - "$ref": "#/definitions/tcp_response_rule" + "$ref": "#/definitions/server_template" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/tcp_response_rule" + "$ref": "#/definitions/server_template" }, "headers": { "Reload-ID": { @@ -4810,31 +4129,24 @@ func init() { } } }, - "/services/haproxy/configuration/tcp_response_rules/{id}": { + "/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}": { "get": { - "description": "Returns one TCP Response Rule configuration by it's ID in the specified backend.", + "description": "Returns one server template configuration by it's prefix in the specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" + "ServerTemplate" ], - "summary": "Return one TCP Response Rule", - "operationId": "getTCPResponseRule", + "summary": "Return one server template", + "operationId": "getServerTemplate", "parameters": [ { - "type": "integer", - "description": "TCP Response Rule ID", - "name": "id", + "type": "string", + "description": "Server template prefix", + "name": "prefix", "in": "path", "required": true }, { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -4844,19 +4156,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_response_rule" - } - } + "$ref": "#/definitions/server_template" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -4870,36 +4174,29 @@ func init() { } }, "put": { - "description": "Replaces a TCP Response Rule configuration by it's ID in the specified backend.", + "description": "Replaces a server template configuration by it's prefix in the specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" + "ServerTemplate" ], - "summary": "Replace a TCP Response Rule", - "operationId": "replaceTCPResponseRule", + "summary": "Replace a server template", + "operationId": "replaceServerTemplate", "parameters": [ { - "type": "integer", - "description": "TCP Response Rule ID", - "name": "id", + "type": "string", + "description": "Server template prefix", + "name": "prefix", "in": "path", "required": true }, { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/tcp_response_rule" + "$ref": "#/definitions/server_template" } }, { @@ -4914,15 +4211,15 @@ func init() { ], "responses": { "200": { - "description": "TCP Response Rule replaced", + "description": "Server template replaced", "schema": { - "$ref": "#/definitions/tcp_response_rule" + "$ref": "#/definitions/server_template" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/tcp_response_rule" + "$ref": "#/definitions/server_template" }, "headers": { "Reload-ID": { @@ -4943,29 +4240,22 @@ func init() { } }, "delete": { - "description": "Deletes a TCP Response Rule configuration by it's ID from the specified backend.", + "description": "Deletes a server template configuration by it's prefix in the specified backend.", "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" + "ServerTemplate" ], - "summary": "Delete a TCP Response Rule", - "operationId": "deleteTCPResponseRule", + "summary": "Delete a server template", + "operationId": "deleteServerTemplate", "parameters": [ { - "type": "integer", - "description": "TCP Response Rule ID", - "name": "id", + "type": "string", + "description": "Server template prefix", + "name": "prefix", "in": "path", "required": true }, { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "$ref": "#/parameters/parent_name" }, { "$ref": "#/parameters/transaction_id" @@ -4988,7 +4278,7 @@ func init() { } }, "204": { - "description": "TCP Response Rule deleted" + "description": "Server template deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -4999,97 +4289,18 @@ func init() { } } }, - "/services/haproxy/info": { - "get": { - "description": "Return HAProxy process information", - "produces": [ - "application/json" - ], - "tags": [ - "Information" - ], - "summary": "Return HAProxy process information", - "operationId": "getHaproxyProcessInfo", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/process_info" - } - }, - "default": { - "$ref": "#/responses/DefaultError" - } - } - } - }, - "/services/haproxy/reloads": { - "get": { - "description": "Returns a list of HAProxy reloads.", - "produces": [ - "application/json" - ], - "tags": [ - "Reloads" - ], - "summary": "Return list of HAProxy Reloads.", - "operationId": "getReloads", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/reloads" - } - }, - "default": { - "$ref": "#/responses/DefaultError" - } - } - } - }, - "/services/haproxy/reloads/{id}": { + "/services/haproxy/configuration/backends/{parent_name}/servers": { "get": { - "description": "Returns one HAProxy reload status.", + "description": "Returns an array of all servers that are configured in specified backend.", "tags": [ - "Reloads" + "Server" ], - "summary": "Return one HAProxy reload status", - "operationId": "getReload", + "summary": "Return an array of servers", + "operationId": "getAllServerBackend", "parameters": [ { - "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$", - "type": "string", - "description": "Reload id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "$ref": "#/definitions/reload" - } - }, - "404": { - "$ref": "#/responses/NotFound" + "$ref": "#/parameters/parent_name" }, - "default": { - "$ref": "#/responses/DefaultError" - } - } - } - }, - "/services/haproxy/sites": { - "get": { - "description": "Returns an array of all configured sites.", - "tags": [ - "Sites" - ], - "summary": "Return an array of sites", - "operationId": "getSites", - "parameters": [ { "$ref": "#/parameters/transaction_id" } @@ -5098,22 +4309,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/sites" - } - } + "$ref": "#/definitions/servers" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -5124,19 +4324,22 @@ func init() { } }, "post": { - "description": "Adds a new site to the configuration file.", + "description": "Adds a new server in the specified backend in the configuration file.", "tags": [ - "Sites" + "Server" ], - "summary": "Add a site", - "operationId": "createSite", + "summary": "Add a new server", + "operationId": "createServerBackend", "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/site" + "$ref": "#/definitions/server" } }, { @@ -5151,15 +4354,15 @@ func init() { ], "responses": { "201": { - "description": "Site created", + "description": "Server created", "schema": { - "$ref": "#/definitions/site" + "$ref": "#/definitions/server" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/site" + "$ref": "#/definitions/server" }, "headers": { "Reload-ID": { @@ -5180,22 +4383,25 @@ func init() { } } }, - "/services/haproxy/sites/{name}": { + "/services/haproxy/configuration/backends/{parent_name}/servers/{name}": { "get": { - "description": "Returns one site configuration by it's name.", + "description": "Returns one server configuration by it's name in the specified backend.", "tags": [ - "Sites" + "Server" ], - "summary": "Return a site", - "operationId": "getSite", + "summary": "Return one server", + "operationId": "getServerBackend", "parameters": [ { "type": "string", - "description": "Site frontend name", + "description": "Server name", "name": "name", "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" } @@ -5204,19 +4410,11 @@ func init() { "200": { "description": "Successful operation", "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/site" - } - } + "$ref": "#/definitions/server" }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -5230,26 +4428,29 @@ func init() { } }, "put": { - "description": "Replaces a site configuration by it's name.", + "description": "Replaces a server configuration by it's name in the specified backend.", "tags": [ - "Sites" + "Server" ], - "summary": "Replace a site", - "operationId": "replaceSite", + "summary": "Replace a server", + "operationId": "replaceServerBackend", "parameters": [ { "type": "string", - "description": "Site frontend name", + "description": "Server name", "name": "name", "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "name": "data", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/site" + "$ref": "#/definitions/server" } }, { @@ -5264,15 +4465,15 @@ func init() { ], "responses": { "200": { - "description": "Site replaced", + "description": "Server replaced", "schema": { - "$ref": "#/definitions/site" + "$ref": "#/definitions/server" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/site" + "$ref": "#/definitions/server" }, "headers": { "Reload-ID": { @@ -5293,20 +4494,23 @@ func init() { } }, "delete": { - "description": "Deletes a site from the configuration by it's name.", + "description": "Deletes a server configuration by it's name in the specified backend.", "tags": [ - "Sites" + "Server" ], - "summary": "Delete a site", - "operationId": "deleteSite", + "summary": "Delete a server", + "operationId": "deleteServerBackend", "parameters": [ { "type": "string", - "description": "Site frontend name", + "description": "Server name", "name": "name", "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, { "$ref": "#/parameters/transaction_id" }, @@ -5328,7 +4532,7 @@ func init() { } }, "204": { - "description": "Site deleted" + "description": "Server deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -5339,177 +4543,448 @@ func init() { } } }, - "/services/haproxy/stats": { + "/services/haproxy/configuration/backends/{parent_name}/stick_rules": { "get": { - "description": "Returns a list of HAProxy stats endpoints.", - "produces": [ - "application/json" - ], + "description": "Returns all Stick Rules that are configured in specified backend.", "tags": [ - "Discovery" + "StickRule" ], - "summary": "Return list of HAProxy stats endpoints", - "operationId": "getStatsEndpoints", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/endpoints" - } - }, + "summary": "Return an array of all Stick Rules", + "operationId": "getStickRules", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, "default": { "$ref": "#/responses/DefaultError" } } - } - }, - "/services/haproxy/stats/native": { - "get": { - "description": "Getting stats from the HAProxy.", - "produces": [ - "application/json" - ], + }, + "put": { + "description": "Replaces a whole list of Stick Rules with the list given in parameter", "tags": [ - "Stats" + "StickRule" ], - "summary": "Gets stats", - "operationId": "getStats", + "summary": "Replace a Stick Rule list", + "operationId": "replaceStickRules", "parameters": [ { - "enum": [ - "frontend", - "backend", - "server" - ], - "type": "string", - "description": "Object type to get stats for (one of frontend, backend, server)", - "name": "type", - "in": "query" + "$ref": "#/parameters/parent_name" }, { - "type": "string", - "description": "Object name to get stats for", - "name": "name", - "in": "query" + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/stick_rules" + } }, { - "type": "string", - "x-dependency": { - "query.type": "server" - }, - "description": "Object parent name to get stats for, in case the object is a server", - "name": "parent", - "in": "query" + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" } ], "responses": { "200": { - "description": "Success", + "description": "All Stick Rule lines replaced", "schema": { - "$ref": "#/definitions/native_stats" + "$ref": "#/definitions/stick_rules" } }, - "500": { - "description": "Internal Server Error", + "202": { + "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/native_stats" + "$ref": "#/definitions/stick_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, + "400": { + "$ref": "#/responses/BadRequest" + }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/transactions": { + "/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}": { "get": { - "description": "Returns a list of HAProxy configuration transactions. Transactions can be filtered by their status.", - "produces": [ - "application/json" + "description": "Returns one Stick Rule configuration by it's index in the specified backend.", + "tags": [ + "StickRule" + ], + "summary": "Return one Stick Rule", + "operationId": "getStickRule", + "parameters": [ + { + "type": "integer", + "description": "Stick Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Stick Rule configuration by it's index in the specified backend.", "tags": [ - "Transactions" + "StickRule" ], - "summary": "Return list of HAProxy configuration transactions.", - "operationId": "getTransactions", + "summary": "Replace a Stick Rule", + "operationId": "replaceStickRule", "parameters": [ { - "enum": [ - "failed", - "in_progress" - ], - "type": "string", - "description": "Filter by transaction status", - "name": "status", - "in": "query" + "type": "integer", + "description": "Stick Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/stick_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" } ], "responses": { "200": { - "description": "Success", + "description": "Stick Rule replaced", "schema": { - "$ref": "#/definitions/transactions" + "$ref": "#/definitions/stick_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/stick_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, "default": { "$ref": "#/responses/DefaultError" } } }, "post": { - "description": "Starts a new transaction and returns it's id", - "produces": [ - "application/json" - ], + "description": "Adds a new Stick Rule of the specified type in the specified backend.", "tags": [ - "Transactions" + "StickRule" ], - "summary": "Start a new transaction", - "operationId": "startTransaction", + "summary": "Add a new Stick Rule", + "operationId": "createStickRule", "parameters": [ { "type": "integer", - "description": "Configuration version on which to work on", - "name": "version", - "in": "query", + "description": "Stick Rule Index", + "name": "index", + "in": "path", "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/stick_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" } ], "responses": { "201": { - "description": "Transaction started", + "description": "Stick Rule created", "schema": { - "$ref": "#/definitions/transaction" + "$ref": "#/definitions/stick_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/stick_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Stick Rule configuration by it's index from the specified backend.", + "tags": [ + "StickRule" + ], + "summary": "Delete a Stick Rule", + "operationId": "deleteStickRule", + "parameters": [ + { + "type": "integer", + "description": "Stick Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, + "204": { + "description": "Stick Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, "default": { "$ref": "#/responses/DefaultError" } } } }, - "/services/haproxy/transactions/{id}": { + "/services/haproxy/configuration/backends/{parent_name}/tcp_checks": { "get": { - "description": "Returns one HAProxy configuration transactions.", + "description": "Returns all TCP checks that are configured in specified parent.", "tags": [ - "Transactions" + "TCPCheck" ], - "summary": "Return one HAProxy configuration transactions", - "operationId": "getTransaction", + "summary": "Return an array of TCP checks", + "operationId": "getAllTCPCheckBackend", "parameters": [ { - "type": "string", - "description": "Transaction id", - "name": "id", + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Checks with the list given in parameter", + "tags": [ + "TCPCheck" + ], + "summary": "Replace an TCP Check list", + "operationId": "replaceAllTCPCheckBackend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TCP Check lines replaced", + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}": { + "get": { + "description": "Returns one TCP check configuration by it's index in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Return one TCP check", + "operationId": "getTCPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Check Index", + "name": "index", "in": "path", "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" } ], "responses": { "200": { "description": "Successful operation", "schema": { - "$ref": "#/definitions/transaction" + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, "404": { @@ -5521,35 +4996,52 @@ func init() { } }, "put": { - "description": "Commit transaction, execute all operations in transaction and return msg", + "description": "Replaces a TCP Check configuration by it's index in the specified parent.", "tags": [ - "Transactions" + "TCPCheck" ], - "summary": "Commit transaction", - "operationId": "commitTransaction", + "summary": "Replace a TCP check", + "operationId": "replaceTCPCheckBackend", "parameters": [ { - "type": "string", - "description": "Transaction id", - "name": "id", + "type": "integer", + "description": "TCP Check Index", + "name": "index", "in": "path", "required": true }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, { "$ref": "#/parameters/force_reload" } ], "responses": { "200": { - "description": "Transaction succesfully commited", + "description": "TCP check replaced", "schema": { - "$ref": "#/definitions/transaction" + "$ref": "#/definitions/tcp_check" } }, "202": { "description": "Configuration change accepted and reload requested", "schema": { - "$ref": "#/definitions/transaction" + "$ref": "#/definitions/tcp_check" }, "headers": { "Reload-ID": { @@ -5569,25 +5061,112 @@ func init() { } } }, + "post": { + "description": "Adds a new TCP check of the specified type in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Add a new TCP check", + "operationId": "createTCPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "TCP check created", + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, "delete": { - "description": "Deletes a transaction.", + "description": "Deletes a TCP check configuration by it's index from the specified parent.", "tags": [ - "Transactions" + "TCPCheck" ], - "summary": "Delete a transaction", - "operationId": "deleteTransaction", + "summary": "Delete a TCP check", + "operationId": "deleteTCPCheckBackend", "parameters": [ { - "type": "string", - "description": "Transaction id", - "name": "id", + "type": "integer", + "description": "TCP check Index", + "name": "index", "in": "path", "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" } ], "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, "204": { - "description": "Transaction deleted" + "description": "TCP check deleted" }, "404": { "$ref": "#/responses/NotFound" @@ -5598,3510 +5177,80706 @@ func init() { } } }, - "/specification": { + "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules": { "get": { - "description": "Return Data Plane API OpenAPI specification", - "produces": [ - "application/json" - ], + "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", "tags": [ - "Specification" + "TCPRequestRule" + ], + "summary": "Return an array of all TCP Request Rules", + "operationId": "getAllTCPRequestRuleBackend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } ], - "summary": "Data Plane API Specification", - "operationId": "getSpecification", "responses": { "200": { - "description": "Success", + "description": "Successful operation", "schema": { - "type": "object" - } - }, + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, "default": { "$ref": "#/responses/DefaultError" } } - } - } - }, - "definitions": { - "acl": { - "description": "The use of Access Control Lists (ACL) provides a flexible solution to perform\ncontent switching and generally to take decisions based on content extracted\nfrom the request, the response or any environmental status.\n", - "type": "object", - "title": "ACL Lines", - "required": [ - "id", - "acl_name", - "criterion", - "value" - ], - "properties": { - "acl_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false - }, - "criterion": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "value": { - "type": "string", - "x-nullable": false - } }, - "additionalProperties": false - }, - "acls": { - "description": "HAProxy ACL lines array (corresponds to acl directives)", - "type": "array", - "title": "ACL Lines Array", - "items": { - "$ref": "#/definitions/acl" - } - }, - "backend": { - "description": "HAProxy backend configuration", - "type": "object", - "title": "Backend", - "required": [ - "name" - ], - "properties": { - "adv_check": { - "type": "string", - "enum": [ - "ssl-hello-chk", - "smtpchk", - "ldap-check", - "mysql-check", - "pgsql-check", - "tcp-check", - "redis-check" - ], - "x-display-name": "Advanced Check" - }, - "balance": { - "$ref": "#/definitions/balance" - }, - "check_timeout": { - "type": "integer", - "x-nullable": true - }, - "connect_timeout": { - "type": "integer", - "x-nullable": true - }, - "cookie": { - "x-dependency": { - "mode": { - "value": "http" + "put": { + "description": "Replaces a whole list of TCP Request Rules with the list given in parameter", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace an TCP Request Rule list", + "operationId": "replaceAllTCPRequestRuleBackend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rules" } }, - "$ref": "#/definitions/cookie" - }, - "default_server": { - "$ref": "#/definitions/default_server" - }, - "external_check": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "External Check" - }, - "external_check_command": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Command" - }, - "external_check_path": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Path" - }, - "forwardfor": { - "x-dependency": { - "mode": { - "value": "http" + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TCP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rules" } }, - "$ref": "#/definitions/forwardfor" - }, - "hash_type": { - "type": "object", - "properties": { - "function": { - "type": "string", - "enum": [ - "sdbm", - "djb2", - "wt6", - "crc32" - ] - }, - "method": { - "type": "string", - "enum": [ - "map-based", - "consistent" - ] + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rules" }, - "modifier": { - "type": "string", - "enum": [ - "avalanche" - ] + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" } - }, - "http-use-htx": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "mode": { - "value": "http" + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}": { + "get": { + "description": "Returns one TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return one TCP Request Rule", + "operationId": "getTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" } - }, - "http_connection_mode": { - "type": "string", - "enum": [ - "httpclose", - "http-server-close", - "http-keep-alive" - ], - "x-dependency": { - "mode": { - "value": "http" + } + }, + "put": { + "description": "Replaces a TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace a TCP Request Rule", + "operationId": "replaceTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" } - }, - "http_keep_alive_timeout": { - "type": "integer", - "x-dependency": { - "mode": { - "value": "http" + ], + "responses": { + "200": { + "description": "TCP Request Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rule" } }, - "x-nullable": true - }, - "http_pretend_keepalive": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "mode": { - "value": "http" + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" } - }, - "http_request_timeout": { - "type": "integer", - "x-dependency": { - "mode": { - "value": "http" + } + }, + "post": { + "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Add a new TCP Request Rule", + "operationId": "createTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" } }, - "x-nullable": true - }, - "httpchk": { - "x-dependency": { - "mode": { - "value": "http" + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "TCP Request Rule created", + "schema": { + "$ref": "#/definitions/tcp_request_rule" } }, - "$ref": "#/definitions/httpchk" - }, - "log_tag": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "mode": { - "type": "string", - "enum": [ - "http", - "tcp" - ] - }, - "name": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false - }, - "queue_timeout": { - "type": "integer", - "x-nullable": true - }, - "redispatch": { - "$ref": "#/definitions/redispatch" - }, - "retries": { - "type": "integer", - "x-nullable": true - }, - "server_timeout": { - "type": "integer", - "x-nullable": true - }, - "stick_table": { - "type": "object", - "properties": { - "expire": { - "type": "integer", - "x-nullable": true - }, - "keylen": { - "type": "integer", - "x-display-name": "Key Length", - "x-nullable": true - }, - "nopurge": { - "type": "boolean", - "x-display-name": "No Purge" - }, - "peers": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "size": { - "type": "integer", - "x-nullable": true - }, - "store": { - "type": "string", - "pattern": "^[^\\s]+$" + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" }, - "type": { - "type": "string", - "enum": [ - "ip", - "ipv6", - "integer", - "string", - "binary" - ] + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" } } }, - "additionalProperties": false, - "example": { - "balance": { - "algorithm": "roundrobin" - }, - "forwardfor": { - "enabled": true - }, - "httpchk": { - "method": "OPTIONS", - "uri": "/check", - "version": "HTTP/1.1" - }, - "mode": "http", - "name": "test_backend" - } - }, - "backend_switching_rule": { - "description": "HAProxy backend switching rule configuration (corresponds to use_backend directive)", - "type": "object", - "title": "Backend Switching Rule", - "required": [ - "id", - "name" - ], - "properties": { - "cond": { - "type": "string", - "enum": [ - "if", - "unless" - ], - "x-display-name": "Condition" - }, - "cond_test": { - "type": "string", - "x-dependency": { - "cond": { - "required": true - } + "delete": { + "description": "Deletes a TCP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Delete a TCP Request Rule", + "operationId": "deleteTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" } - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "Backend Name", - "x-dynamic-enum": { - "operation": "getBackends", - "property": "name" + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } }, - "x-nullable": false + "204": { + "description": "TCP Request Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } } - }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ req_ssl_sni -i www.example.com }", - "id": 0, - "name": "test_backend" - } - }, - "backend_switching_rules": { - "description": "HAProxy backend switching rules array (corresponds to use_backend directives)", - "type": "array", - "title": "Backend Switching Rules Array", - "items": { - "$ref": "#/definitions/backend_switching_rule" - } - }, - "backends": { - "description": "HAProxy backends array", - "type": "array", - "title": "Backends", - "items": { - "$ref": "#/definitions/backend" } }, - "balance": { - "type": "object", - "properties": { - "algorithm": { - "type": "string", - "enum": [ - "roundrobin", - "static-rr", - "leastconn", - "first", - "source", - "uri", - "url_param", - "random" - ] - }, - "arguments": { - "type": "array", - "items": { - "type": "string", - "pattern": "^[^\\s]+$" + "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules": { + "get": { + "description": "Returns all TCP Response Rules that are configured in specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return an array of all TCP Response Rules", + "operationId": "getAllTCPResponseRuleBackend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" }, - "x-dependency": { - "algorithm": { - "value": [ - "uri", - "url_param" - ] + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Response Rules with the list given in parameter", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule list", + "operationId": "replaceAllTCPResponseRuleBackend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TCP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" } } } }, - "bind": { - "description": "HAProxy frontend bind configuration", - "type": "object", - "title": "Bind", - "required": [ - "name" - ], - "properties": { - "accept_proxy": { - "type": "boolean" - }, - "address": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "allow_0rtt": { - "type": "boolean" - }, - "alpn": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "ALPN Protocols" - }, - "name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false - }, - "port": { - "type": "integer", - "maximum": 65535, - "minimum": 1, - "x-nullable": true - }, - "process": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "ssl": { - "type": "boolean" - }, - "ssl_cafile": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": true + "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}": { + "get": { + "description": "Returns one TCP Response Rule configuration by it's index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return one TCP Response Rule", + "operationId": "getTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "SSL CA File" - }, - "ssl_certificate": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": true + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a TCP Response Rule configuration by it's Index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule", + "operationId": "replaceTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" } - }, - "tcp_user_timeout": { - "type": "integer", - "x-nullable": true - }, - "transparent": { - "type": "boolean" - }, - "v4v6": { - "type": "boolean" - }, - "verify": { - "type": "string", - "enum": [ - "none", - "optional", - "required" - ], - "x-dependency": { - "ssl": { - "value": "enabled" + ], + "responses": { + "200": { + "description": "TCP Response Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" } } }, - "additionalProperties": false, - "example": { - "address": "127.0.0.1", - "name": "http", - "port": 80 + "post": { + "description": "Adds a new TCP Response Rule of the specified type in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Add a new TCP Response Rule", + "operationId": "createTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "TCP Response Rule created", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a TCP Response Rule configuration by it's index from the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Delete a TCP Response Rule", + "operationId": "deleteTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Response Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } } }, - "binds": { - "description": "HAProxy frontend binds array (corresponds to bind directives)", - "type": "array", - "title": "Binds", - "items": { - "$ref": "#/definitions/bind" + "/services/haproxy/configuration/caches": { + "get": { + "description": "Returns an array of all configured caches.", + "tags": [ + "Cache" + ], + "summary": "Return an array of caches", + "operationId": "getCaches", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/caches" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new cache section to the configuration file.", + "tags": [ + "Cache" + ], + "summary": "Add a cache", + "operationId": "createCache", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cache" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Cache created", + "schema": { + "$ref": "#/definitions/cache" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/cache" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } } }, - "cookie": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "domain": { - "type": "array", - "items": { + "/services/haproxy/configuration/caches/{name}": { + "get": { + "description": "Returns one cache section configuration by it's name.", + "tags": [ + "Cache" + ], + "summary": "Return a cache", + "operationId": "getCache", + "parameters": [ + { "type": "string", - "pattern": "^[^\\s]+$" + "description": "Cache name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" } - }, - "dynamic": { - "type": "boolean" - }, - "httponly": { - "type": "boolean" - }, - "indirect": { - "type": "boolean" - }, - "maxidle": { - "type": "integer", - "pattern": "^[^\\d+$]" - }, - "maxlife": { - "type": "integer", - "pattern": "^[^\\d+$]" - }, - "name": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "nocache": { - "type": "boolean" - }, + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/cache" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a cache configuration by it's name.", + "tags": [ + "Cache" + ], + "summary": "Replace a cache", + "operationId": "replaceCache", + "parameters": [ + { + "type": "string", + "description": "Cache name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cache" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Cache replaced", + "schema": { + "$ref": "#/definitions/cache" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/cache" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a cache from the configuration by it's name.", + "tags": [ + "Cache" + ], + "summary": "Delete a cache", + "operationId": "deleteCache", + "parameters": [ + { + "type": "string", + "description": "Cache name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Cache deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/crt_loads": { + "get": { + "description": "Returns the list of loaded certificates from the specified crt_store", + "tags": [ + "CrtLoad" + ], + "summary": "Return an array of loaded certificates", + "operationId": "getCrtLoads", + "parameters": [ + { + "type": "string", + "description": "Parent crt_store name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_loads" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new load entry to the specified crt_store section in the configuration", + "tags": [ + "CrtLoad" + ], + "summary": "Add a new certificate to load", + "operationId": "createCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Parent crt_store section name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Certificate load entry created", + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_load" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/crt_loads/{certificate}": { + "get": { + "description": "Returns one load entry by its certificate name in the specified crt_store", + "tags": [ + "CrtLoad" + ], + "summary": "Return one certificate load entry", + "operationId": "getCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Certificate filename", + "name": "certificate", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent crt_store name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_load" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a load entry by its certificate name in the specified crt_store section", + "tags": [ + "CrtLoad" + ], + "summary": "Replace a certificate load entry", + "operationId": "replaceCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Certificate filename", + "name": "certificate", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent crt_store section name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Certificate load entry replaced", + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_load" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a load entry by its certificate name in the specified crt_store section", + "tags": [ + "CrtLoad" + ], + "summary": "Delete a certificate load entry", + "operationId": "deleteCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Certificate filename", + "name": "certificate", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent crt_store section name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Certificate load entry deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/crt_stores": { + "get": { + "description": "Returns an array of all the configured crt_store sections in HAProxy", + "tags": [ + "CrtStore" + ], + "summary": "Return all the Certificate Stores", + "operationId": "getCrtStores", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_stores" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a new crt_store section", + "tags": [ + "CrtStore" + ], + "summary": "Add a new Certificate Store", + "operationId": "createCrtStore", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Certificate Store created", + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_store" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/crt_stores/{name}": { + "get": { + "description": "Returns crt_store section by its name", + "tags": [ + "CrtStore" + ], + "summary": "Return a Certificate Store", + "operationId": "getCrtStore", + "parameters": [ + { + "type": "string", + "description": "crt_store name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_store" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Modifies a crt_store's configuration by its name", + "tags": [ + "CrtStore" + ], + "summary": "Modify a Certificate Store", + "operationId": "editCrtStore", + "parameters": [ + { + "type": "string", + "description": "crt_store name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "crt_store configuration updated", + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_store" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a crt_store section from the configuration", + "tags": [ + "CrtStore" + ], + "summary": "Delete a Certificate Store", + "operationId": "deleteCrtStore", + "parameters": [ + { + "type": "string", + "description": "crt_store name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "crt_store deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults": { + "get": { + "description": "Returns an array of all configured defaults.", + "tags": [ + "Defaults" + ], + "summary": "Return an array of defaults", + "operationId": "getDefaultsSections", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/defaults_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Adds a new defaults section to the configuration file.", + "tags": [ + "Defaults" + ], + "summary": "Add a defaults section", + "operationId": "createDefaultsSection", + "deprecated": true, + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/defaults" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Defaults created", + "schema": { + "$ref": "#/definitions/defaults" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new defaults section to the configuration file.", + "tags": [ + "Defaults" + ], + "summary": "Add a defaults section", + "operationId": "addDefaultsSection", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/defaults" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Defaults created", + "schema": { + "$ref": "#/definitions/defaults" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{name}": { + "get": { + "description": "Returns one defaults section configuration by it's name.", + "tags": [ + "Defaults" + ], + "summary": "Return a defaults section", + "operationId": "getDefaultsSection", + "parameters": [ + { + "type": "string", + "description": "Defaults name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a defatults section configuration by it's name.", + "tags": [ + "Defaults" + ], + "summary": "Replace a defatults section", + "operationId": "replaceDefaultsSection", + "parameters": [ + { + "type": "string", + "description": "Defaults name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/defaults" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Defaults section replaced", + "schema": { + "$ref": "#/definitions/defaults" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a defaults section from the configuration by it's name.", + "tags": [ + "Defaults" + ], + "summary": "Delete a defaults section", + "operationId": "deleteDefaultsSection", + "parameters": [ + { + "type": "string", + "description": "Defaults name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Defaults section deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/acls": { + "get": { + "description": "Returns all ACL lines that are configured in specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of ACLs with the list given in parameter", + "tags": [ + "ACL" + ], + "summary": "Replace an ACL list", + "operationId": "replaceAllAclDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acls" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All ACL lines replaced", + "schema": { + "$ref": "#/definitions/acls" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/acls/{index}": { + "get": { + "description": "Returns one ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return one ACL line", + "operationId": "getAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Replace a ACL line", + "operationId": "replaceAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "ACL line replaced", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Add a new ACL line", + "operationId": "createAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "ACL line created", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a ACL line configuration by it's index from the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Delete a ACL line", + "operationId": "deleteAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "ACL line deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules": { + "get": { + "description": "Returns all HTTP After Response Rules that are configured in specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return an array of all HTTP After Response Rules", + "operationId": "getAllHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP After Response Rules with the list given in parameter", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace an HTTP After Response Rules list", + "operationId": "replaceAllHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}": { + "get": { + "description": "Returns one HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return one HTTP After Response Rule", + "operationId": "getHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace a HTTP After Response Rule", + "operationId": "replaceHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP After Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP After Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Add a new HTTP After Response Rule", + "operationId": "createHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP After Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Delete a HTTP After Response Rule", + "operationId": "deleteHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP After Response Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_checks": { + "get": { + "description": "Returns all HTTP checks that are configured in specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Return an array of HTTP checks", + "operationId": "getAllHTTPCheckDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_checks" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP checks with the list given in parameter", + "tags": [ + "HTTPCheck" + ], + "summary": "Replace an HTTP checks list", + "operationId": "replaceAllHTTPCheckDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_checks" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All HTTP checks lines replaced", + "schema": { + "$ref": "#/definitions/http_checks" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_checks" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}": { + "get": { + "description": "Returns one HTTP check configuration by it's index in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Return one HTTP check", + "operationId": "getHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP Check configuration by it's index in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Replace a HTTP check", + "operationId": "replaceHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_check" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP check replaced", + "schema": { + "$ref": "#/definitions/http_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP check of the specified type in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Add a new HTTP check", + "operationId": "createHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_check" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP check created", + "schema": { + "$ref": "#/definitions/http_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP check configuration by it's index from the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Delete a HTTP check", + "operationId": "deleteHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP check deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules": { + "get": { + "description": "Returns all HTTP Error Rules that are configured in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return an array of all HTTP Error Rules", + "operationId": "getAllHTTPErrorRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Error Rules with the list given in parameter", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace an HTTP Error Rules list", + "operationId": "replaceAllHTTPErrorRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All HTTP Error Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}": { + "get": { + "description": "Returns one HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return one HTTP Error Rule", + "operationId": "getHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace a HTTP Error Rule", + "operationId": "replaceHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP Error Rule replaced", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP Error Rule of the specified type in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Add a new HTTP Error Rule", + "operationId": "createHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Error Rule created", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Error Rule configuration by its index from the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Delete a HTTP Error Rule", + "operationId": "deleteHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Error Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules": { + "get": { + "description": "Returns all HTTP Request Rules that are configured in specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return an array of all HTTP Request Rules", + "operationId": "getAllHTTPRequestRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Request Rules with the list given in parameter", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace an HTTP Request Rule list", + "operationId": "replaceAllHTTPRequestRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All HTTP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}": { + "get": { + "description": "Returns one HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return one HTTP Request Rule", + "operationId": "getHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace a HTTP Request Rule", + "operationId": "replaceHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP Request Rule replaced", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Add a new HTTP Request Rule", + "operationId": "createHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Request Rule created", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Delete a HTTP Request Rule", + "operationId": "deleteHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Request Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules": { + "get": { + "description": "Returns all HTTP Response Rules that are configured in specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return an array of all HTTP Response Rules", + "operationId": "getAllHTTPResponseRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Response Rules with the list given in parameter", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace an HTTP Response Rule list", + "operationId": "replaceAllHTTPResponseRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All HTTP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}": { + "get": { + "description": "Returns one HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return one HTTP Response Rule", + "operationId": "getHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace a HTTP Response Rule", + "operationId": "replaceHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Add a new HTTP Response Rule", + "operationId": "createHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Delete a HTTP Response Rule", + "operationId": "deleteHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Response Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules": { + "get": { + "description": "Returns all QUIC Initial rules that are configured in specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return an array of all QUIC Initial rules", + "operationId": "getAllQUICInitialRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of QUIC Initial rules with the list given in parameter", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace an QUIC Initial rules list", + "operationId": "replaceAllQUICInitialRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}": { + "get": { + "description": "Returns one QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return one QUIC Initial Rule", + "operationId": "getQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace a QUIC Initial Rule", + "operationId": "replaceQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "QUIC Initial Rule replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new QUIC Initial Rule of the specified type in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Add a new QUIC Initial Rule", + "operationId": "createQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a QUIC Initial Rule configuration by it's index from the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Delete a QUIC Initial Rule", + "operationId": "deleteQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "QUIC Initial Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks": { + "get": { + "description": "Returns all TCP checks that are configured in specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Return an array of TCP checks", + "operationId": "getAllTCPCheckDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Checks with the list given in parameter", + "tags": [ + "TCPCheck" + ], + "summary": "Replace an TCP Check list", + "operationId": "replaceAllTCPCheckDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TCP Check lines replaced", + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}": { + "get": { + "description": "Returns one TCP check configuration by it's index in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Return one TCP check", + "operationId": "getTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a TCP Check configuration by it's index in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Replace a TCP check", + "operationId": "replaceTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "TCP check replaced", + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new TCP check of the specified type in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Add a new TCP check", + "operationId": "createTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "TCP check created", + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a TCP check configuration by it's index from the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Delete a TCP check", + "operationId": "deleteTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP check deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules": { + "get": { + "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return an array of all TCP Request Rules", + "operationId": "getAllTCPRequestRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Request Rules with the list given in parameter", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace an TCP Request Rule list", + "operationId": "replaceAllTCPRequestRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TCP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}": { + "get": { + "description": "Returns one TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return one TCP Request Rule", + "operationId": "getTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace a TCP Request Rule", + "operationId": "replaceTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "TCP Request Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Add a new TCP Request Rule", + "operationId": "createTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "TCP Request Rule created", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a TCP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Delete a TCP Request Rule", + "operationId": "deleteTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Request Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules": { + "get": { + "description": "Returns all TCP Response Rules that are configured in specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return an array of all TCP Response Rules", + "operationId": "getAllTCPResponseRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Response Rules with the list given in parameter", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule list", + "operationId": "replaceAllTCPResponseRuleDefaults", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TCP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}": { + "get": { + "description": "Returns one TCP Response Rule configuration by it's index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return one TCP Response Rule", + "operationId": "getTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a TCP Response Rule configuration by it's Index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule", + "operationId": "replaceTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "TCP Response Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new TCP Response Rule of the specified type in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Add a new TCP Response Rule", + "operationId": "createTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "TCP Response Rule created", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a TCP Response Rule configuration by it's index from the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Delete a TCP Response Rule", + "operationId": "deleteTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Response Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps": { + "get": { + "description": "Returns an array of all configured FCGI applications.", + "tags": [ + "FCGIApp" + ], + "summary": "Return an array of FCGI apps", + "operationId": "getFCGIApps", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/fcgi_apps" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new FCGI application to the configuration file.", + "tags": [ + "FCGIApp" + ], + "summary": "Add an FCGI app", + "operationId": "createFCGIApp", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Application created", + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/fcgi_app" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps/{name}": { + "get": { + "description": "Returns one FCGI application configuration by its name.", + "tags": [ + "FCGIApp" + ], + "summary": "Return a FCGI app", + "operationId": "getFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Application name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/fcgi_app" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a FCGI application configuration by its name.", + "tags": [ + "FCGIApp" + ], + "summary": "Replace a FCGI app", + "operationId": "replaceFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Application name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Application replaced", + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/fcgi_app" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes an FCGI application from the configuration by its name.", + "tags": [ + "FCGIApp" + ], + "summary": "Delete an FCGI app", + "operationId": "deleteFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Application name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Application deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls": { + "get": { + "description": "Returns all ACL lines that are configured in specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclFCGIApp", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of ACLs with the list given in parameter", + "tags": [ + "ACL" + ], + "summary": "Replace an ACL list", + "operationId": "replaceAllAclFCGIApp", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acls" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All ACL lines replaced", + "schema": { + "$ref": "#/definitions/acls" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}": { + "get": { + "description": "Returns one ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return one ACL line", + "operationId": "getAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Replace a ACL line", + "operationId": "replaceAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "ACL line replaced", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Add a new ACL line", + "operationId": "createAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "ACL line created", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a ACL line configuration by it's index from the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Delete a ACL line", + "operationId": "deleteAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "ACL line deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends": { + "get": { + "description": "Returns an array of all configured frontends.", + "tags": [ + "Frontend" + ], + "summary": "Return an array of frontends", + "operationId": "getFrontends", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/frontends" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new frontend to the configuration file.", + "tags": [ + "Frontend" + ], + "summary": "Add a frontend", + "operationId": "createFrontend", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/frontend" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Frontend created", + "schema": { + "$ref": "#/definitions/frontend" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/frontend" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{name}": { + "get": { + "description": "Returns one frontend configuration by it's name.", + "tags": [ + "Frontend" + ], + "summary": "Return a frontend", + "operationId": "getFrontend", + "parameters": [ + { + "type": "string", + "description": "Frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/frontend" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a frontend configuration by it's name.", + "tags": [ + "Frontend" + ], + "summary": "Replace a frontend", + "operationId": "replaceFrontend", + "parameters": [ + { + "type": "string", + "description": "Frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/frontend" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Frontend replaced", + "schema": { + "$ref": "#/definitions/frontend" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/frontend" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a frontend from the configuration by it's name.", + "tags": [ + "Frontend" + ], + "summary": "Delete a frontend", + "operationId": "deleteFrontend", + "parameters": [ + { + "type": "string", + "description": "Frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Frontend deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/acls": { + "get": { + "description": "Returns all ACL lines that are configured in specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of ACLs with the list given in parameter", + "tags": [ + "ACL" + ], + "summary": "Replace an ACL list", + "operationId": "replaceAllAclFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acls" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All ACL lines replaced", + "schema": { + "$ref": "#/definitions/acls" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/acls/{index}": { + "get": { + "description": "Returns one ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return one ACL line", + "operationId": "getAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Replace a ACL line", + "operationId": "replaceAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "ACL line replaced", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Add a new ACL line", + "operationId": "createAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "ACL line created", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a ACL line configuration by it's index from the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Delete a ACL line", + "operationId": "deleteAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "ACL line deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules": { + "get": { + "description": "Returns all Backend Switching Rules that are configured in specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Return an array of all Backend Switching Rules", + "operationId": "getBackendSwitchingRules", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/backend_switching_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of Backend Switching Rules with the list given in parameter", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Replace an Backend Switching Rule list", + "operationId": "replaceBackendSwitchingRules", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend_switching_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Backend Switching Rule lines replaced", + "schema": { + "$ref": "#/definitions/backend_switching_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend_switching_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}": { + "get": { + "description": "Returns one Backend Switching Rule configuration by it's index in the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Return one Backend Switching Rule", + "operationId": "getBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Backend Switching Rule configuration by it's index in the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Replace a Backend Switching Rule", + "operationId": "replaceBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Backend Switching Rule replaced", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new Backend Switching Rule of the specified type in the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Add a new Backend Switching Rule", + "operationId": "createBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Backend Switching Rule created", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Backend Switching Rule configuration by it's index from the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Delete a Backend Switching Rule", + "operationId": "deleteBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Backend Switching Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/binds": { + "get": { + "description": "Returns an array of all binds that are configured in specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return an array of binds", + "operationId": "getAllBindFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new bind in the specified frontend in the configuration file.", + "tags": [ + "Bind" + ], + "summary": "Add a new bind", + "operationId": "createBindFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/binds/{name}": { + "get": { + "description": "Returns one bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return one bind", + "operationId": "getBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Replace a bind", + "operationId": "replaceBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Delete a bind", + "operationId": "deleteBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/captures": { + "get": { + "description": "Returns an array of all declare capture records that are configured in specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Return an array of declare captures", + "operationId": "getDeclareCaptures", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/captures" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of declare capture with the list given in parameter", + "tags": [ + "DeclareCapture" + ], + "summary": "Replace a declare capture list", + "operationId": "replaceDeclareCaptures", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/captures" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Declare capture lines replaced", + "schema": { + "$ref": "#/definitions/captures" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/captures" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/captures/{index}": { + "get": { + "description": "Returns one declare capture configuration by it's index in the specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Return one declare capture", + "operationId": "getDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/capture" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a declare capture configuration by it's index in the specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Replace a declare capture", + "operationId": "replaceDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/capture" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Declare Capture replaced", + "schema": { + "$ref": "#/definitions/capture" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/capture" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new declare capture in the specified frontend in the configuration file.", + "tags": [ + "DeclareCapture" + ], + "summary": "Add a new declare capture", + "operationId": "createDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/capture" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Declare capture created", + "schema": { + "$ref": "#/definitions/capture" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/capture" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a declare capture configuration by it's index in the specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Delete a declare capture", + "operationId": "deleteDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Declare Capture deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/filters": { + "get": { + "description": "Returns all Filters that are configured in specified parent.", + "tags": [ + "Filter" + ], + "summary": "Return an array of all Filters", + "operationId": "getAllFilterFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/filters" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of Filters with the list given in parameter", + "tags": [ + "Filter" + ], + "summary": "Replace a Filter list", + "operationId": "replaceAllFilterFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filters" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Filter lines replaced", + "schema": { + "$ref": "#/definitions/filters" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filters" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/filters/{index}": { + "get": { + "description": "Returns one Filter configuration by it's index in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Return one Filter", + "operationId": "getFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Filter configuration by it's index in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Replace a Filter", + "operationId": "replaceFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filter" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Filter replaced", + "schema": { + "$ref": "#/definitions/filter" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new Filter of the specified type in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Add a new Filter", + "operationId": "createFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filter" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Filter created", + "schema": { + "$ref": "#/definitions/filter" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Filter configuration by it's index from the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Delete a Filter", + "operationId": "deleteFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Filter deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules": { + "get": { + "description": "Returns all HTTP After Response Rules that are configured in specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return an array of all HTTP After Response Rules", + "operationId": "getAllHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP After Response Rules with the list given in parameter", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace an HTTP After Response Rules list", + "operationId": "replaceAllHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}": { + "get": { + "description": "Returns one HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return one HTTP After Response Rule", + "operationId": "getHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace a HTTP After Response Rule", + "operationId": "replaceHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP After Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP After Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Add a new HTTP After Response Rule", + "operationId": "createHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP After Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Delete a HTTP After Response Rule", + "operationId": "deleteHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP After Response Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules": { + "get": { + "description": "Returns all HTTP Error Rules that are configured in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return an array of all HTTP Error Rules", + "operationId": "getAllHTTPErrorRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Error Rules with the list given in parameter", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace an HTTP Error Rules list", + "operationId": "replaceAllHTTPErrorRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All HTTP Error Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}": { + "get": { + "description": "Returns one HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return one HTTP Error Rule", + "operationId": "getHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace a HTTP Error Rule", + "operationId": "replaceHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP Error Rule replaced", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP Error Rule of the specified type in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Add a new HTTP Error Rule", + "operationId": "createHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Error Rule created", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Error Rule configuration by its index from the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Delete a HTTP Error Rule", + "operationId": "deleteHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Error Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules": { + "get": { + "description": "Returns all HTTP Request Rules that are configured in specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return an array of all HTTP Request Rules", + "operationId": "getAllHTTPRequestRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Request Rules with the list given in parameter", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace an HTTP Request Rule list", + "operationId": "replaceAllHTTPRequestRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All HTTP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}": { + "get": { + "description": "Returns one HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return one HTTP Request Rule", + "operationId": "getHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace a HTTP Request Rule", + "operationId": "replaceHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP Request Rule replaced", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Add a new HTTP Request Rule", + "operationId": "createHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Request Rule created", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Delete a HTTP Request Rule", + "operationId": "deleteHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Request Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules": { + "get": { + "description": "Returns all HTTP Response Rules that are configured in specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return an array of all HTTP Response Rules", + "operationId": "getAllHTTPResponseRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Response Rules with the list given in parameter", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace an HTTP Response Rule list", + "operationId": "replaceAllHTTPResponseRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All HTTP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}": { + "get": { + "description": "Returns one HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return one HTTP Response Rule", + "operationId": "getHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace a HTTP Response Rule", + "operationId": "replaceHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "HTTP Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Add a new HTTP Response Rule", + "operationId": "createHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a HTTP Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Delete a HTTP Response Rule", + "operationId": "deleteHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Response Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules": { + "get": { + "description": "Returns all QUIC Initial rules that are configured in specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return an array of all QUIC Initial rules", + "operationId": "getAllQUICInitialRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of QUIC Initial rules with the list given in parameter", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace an QUIC Initial rules list", + "operationId": "replaceAllQUICInitialRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}": { + "get": { + "description": "Returns one QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return one QUIC Initial Rule", + "operationId": "getQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace a QUIC Initial Rule", + "operationId": "replaceQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "QUIC Initial Rule replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new QUIC Initial Rule of the specified type in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Add a new QUIC Initial Rule", + "operationId": "createQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a QUIC Initial Rule configuration by it's index from the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Delete a QUIC Initial Rule", + "operationId": "deleteQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "QUIC Initial Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses": { + "get": { + "description": "Returns an array of all SSLFrontUses that are configured in specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Return an array of SSLFrontUses", + "operationId": "getAllSSLFrontUses", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_front_uses" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new SSLFrontUse in the specified frontend in the configuration file.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Add a new SSLFrontUse", + "operationId": "createSSLFrontUse", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "SSLFrontUse created", + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ssl_front_use" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}": { + "get": { + "description": "Returns one SSLFrontUse configuration by its index in the specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Return one SSLFrontUse", + "operationId": "getSSLFrontUse", + "parameters": [ + { + "type": "integer", + "description": "SSLFrontUse index (zero-based)", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_front_use" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces an SSLFrontUse configuration by its index in the specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Replace an SSLFrontUse", + "operationId": "replaceSSLFrontUse", + "parameters": [ + { + "type": "integer", + "description": "SSLFrontUse index (zero-based)", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "SSLFrontUse replaced", + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ssl_front_use" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes an SSLFrontUse configuration by its index in the specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Delete an SSLFrontUse", + "operationId": "deleteSSLFrontUse", + "parameters": [ + { + "type": "integer", + "description": "SSLFrontUse index (zero-based)", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "SSLFrontUse deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules": { + "get": { + "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return an array of all TCP Request Rules", + "operationId": "getAllTCPRequestRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Request Rules with the list given in parameter", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace an TCP Request Rule list", + "operationId": "replaceAllTCPRequestRuleFrontend", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All TCP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}": { + "get": { + "description": "Returns one TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return one TCP Request Rule", + "operationId": "getTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace a TCP Request Rule", + "operationId": "replaceTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "TCP Request Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Add a new TCP Request Rule", + "operationId": "createTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "TCP Request Rule created", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a TCP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Delete a TCP Request Rule", + "operationId": "deleteTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Request Rule deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/global": { + "get": { + "description": "Returns global part of configuration.", + "tags": [ + "Global" + ], + "summary": "Return a global part of configuration", + "operationId": "getGlobal", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/global" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replace global part of config", + "tags": [ + "Global" + ], + "summary": "Replace global", + "operationId": "replaceGlobal", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/global" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Global replaced", + "schema": { + "$ref": "#/definitions/global" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/global" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/global/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetGlobal", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetGlobal", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/global/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/groups": { + "get": { + "tags": [ + "Group" + ], + "summary": "Return an array of userlist groups", + "operationId": "getGroups", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/groups" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "tags": [ + "Group" + ], + "summary": "Add a new userlist group", + "operationId": "createGroup", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Group created", + "schema": { + "$ref": "#/definitions/group" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/group" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/groups/{name}": { + "get": { + "tags": [ + "Group" + ], + "summary": "Return one userlist group", + "operationId": "getGroup", + "parameters": [ + { + "type": "string", + "description": "Group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/group" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "tags": [ + "Group" + ], + "summary": "Replace a group", + "operationId": "replaceGroup", + "parameters": [ + { + "type": "string", + "description": "group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Group replaced", + "schema": { + "$ref": "#/definitions/group" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/group" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "tags": [ + "Group" + ], + "summary": "Delete a group", + "operationId": "deleteGroup", + "parameters": [ + { + "type": "string", + "description": "group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Group deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/http_errors_sections": { + "get": { + "description": "Returns an array of all configured http-error sections.", + "tags": [ + "HTTPErrors" + ], + "summary": "Return an array of http-error sections", + "operationId": "getHTTPErrorsSections", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_errors_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new http-error section to the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Add a new http-error section", + "operationId": "createHTTPErrorsSection", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "http-error section created", + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_errors_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/http_errors_sections/{name}": { + "get": { + "description": "Returns one http-error section with a given name from the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Return a http-error section", + "operationId": "getHTTPErrorsSection", + "parameters": [ + { + "type": "string", + "description": "http-error section name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_errors_section" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a http-error section with a given name in the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Replace a http-error section", + "operationId": "replaceHTTPErrorsSection", + "parameters": [ + { + "type": "string", + "description": "http-error section name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "http-error section updated", + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_errors_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a http-error section with a given name from the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Delete a http-error section", + "operationId": "deleteHTTPErrorsSection", + "parameters": [ + { + "type": "string", + "description": "http-error section name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "http-error section deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards": { + "get": { + "description": "Returns an array of all configured log forwards.", + "tags": [ + "LogForward" + ], + "summary": "Return an array of log forwards", + "operationId": "getLogForwards", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_forwards" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new log_forward to the configuration file.", + "tags": [ + "LogForward" + ], + "summary": "Add a log forward", + "operationId": "createLogForward", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Log Forward created", + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_forward" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{name}": { + "get": { + "description": "Returns one log forward configuration by it's name.", + "tags": [ + "LogForward" + ], + "summary": "Return a log forward", + "operationId": "getLogForward", + "parameters": [ + { + "type": "string", + "description": "Log Forward name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_forward" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a log forward configuration by it's name.", + "tags": [ + "LogForward" + ], + "summary": "Replace a log forward", + "operationId": "replaceLogForward", + "parameters": [ + { + "type": "string", + "description": "Log Forward name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Log Forward replaced", + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_forward" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a log forward from the configuration by it's name.", + "tags": [ + "LogForward" + ], + "summary": "Delete a log forward", + "operationId": "deleteLogForward", + "parameters": [ + { + "type": "string", + "description": "Log Forward name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Forward deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/binds": { + "get": { + "description": "Returns an array of all binds that are configured in specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return an array of binds", + "operationId": "getAllBindLogForward", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new bind in the specified frontend in the configuration file.", + "tags": [ + "Bind" + ], + "summary": "Add a new bind", + "operationId": "createBindLogForward", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}": { + "get": { + "description": "Returns one bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return one bind", + "operationId": "getBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Replace a bind", + "operationId": "replaceBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Delete a bind", + "operationId": "deleteBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds": { + "get": { + "description": "Returns an array of all dgram binds that are configured in specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Return an array of dgram binds", + "operationId": "getDgramBinds", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/dgram_binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new dgram bind in the specified log forward in the configuration file.", + "tags": [ + "DgramBind" + ], + "summary": "Add a new dgram bind", + "operationId": "createDgramBind", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/dgram_bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}": { + "get": { + "description": "Returns one dgram bind configuration by it's name in the specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Return one dgram bind", + "operationId": "getDgramBind", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/dgram_bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a dgram bind configuration by it's name in the specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Replace a dgram bind", + "operationId": "replaceDgramBind", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/dgram_bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a dgram bind configuration by it's name in the specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Delete a dgram bind", + "operationId": "deleteDgramBind", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetLogForward", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetLogForward", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_profiles": { + "get": { + "description": "Returns an array of all the configured log_profile sections in HAProxy", + "tags": [ + "LogProfile" + ], + "summary": "Return all the Log Profiles", + "operationId": "getLogProfiles", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_profiles" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a new log_profile section", + "tags": [ + "LogProfile" + ], + "summary": "Add a new Log Profile", + "operationId": "createLogProfile", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Log Profile created", + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_profile" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/log_profiles/{name}": { + "get": { + "description": "Find a log_profile section by its name", + "tags": [ + "LogProfile" + ], + "summary": "Return a Log Profile", + "operationId": "getLogProfile", + "parameters": [ + { + "type": "string", + "description": "log_profile name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_profile" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Modifies a log_profile's configuration by its name", + "tags": [ + "LogProfile" + ], + "summary": "Modify a Log Profile", + "operationId": "editLogProfile", + "parameters": [ + { + "type": "string", + "description": "log_profile name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "log_profile configuration updated", + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_profile" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a log_profile section from the configuration", + "tags": [ + "LogProfile" + ], + "summary": "Delete a Log Profile", + "operationId": "deleteLogProfile", + "parameters": [ + { + "type": "string", + "description": "log_profile name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "log_profile deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/mailer_entries": { + "get": { + "description": "Returns an array of all the mailer_entries configured in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Return an array of mailer_entries", + "operationId": "getMailerEntries", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailer_entries" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new mailer entry to the specified mailers section in the configuration file.", + "tags": [ + "MailerEntry" + ], + "summary": "Add a new mailer_entry", + "operationId": "createMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "MailerEntry created", + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/mailer_entries/{name}": { + "get": { + "description": "Returns one mailer_entry configuration by it's name in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Return one mailer_entry", + "operationId": "getMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "MailerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent mailers name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailer_entry" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a mailer entry configuration by it's name in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Replace a mailer_entry", + "operationId": "replaceMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "MailerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "MailerEntry replaced", + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a mailer entry configuration by it's name in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Delete a mailer_entry", + "operationId": "deleteMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "MailerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "MailerEntry deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/mailers_section": { + "get": { + "description": "Returns an array of all the configured mailers in HAProxy", + "tags": [ + "Mailers" + ], + "summary": "Return an array of mailers sections", + "operationId": "getMailersSections", + "deprecated": true, + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailers_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a new empty Mailers section", + "tags": [ + "Mailers" + ], + "summary": "Add a new Mailers section", + "operationId": "createMailersSection", + "deprecated": true, + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Mailers created", + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailers_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/mailers_section/{name}": { + "get": { + "description": "Returns one mailers configuration by it's name.", + "tags": [ + "Mailers" + ], + "summary": "Return a Mailers section", + "operationId": "getMailersSection", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Mailers name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailers_section" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Modifies a mailers configuration by it's name.", + "tags": [ + "Mailers" + ], + "summary": "Modify a Mailers section", + "operationId": "editMailersSection", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Mailers name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Mailers configuration updated", + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailers_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a mailers from the configuration by it's name.", + "tags": [ + "Mailers" + ], + "summary": "Delete a Mailers section", + "operationId": "deleteMailersSection", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Mailers name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Mailers deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/nameservers": { + "get": { + "description": "Returns an array of all configured nameservers.", + "tags": [ + "Nameserver" + ], + "summary": "Return an array of nameservers", + "operationId": "getNameservers", + "parameters": [ + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/nameservers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new nameserver to the resolvers section.", + "tags": [ + "Nameserver" + ], + "summary": "Add a nameserver", + "operationId": "createNameserver", + "parameters": [ + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Nameserver created", + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/nameserver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/nameservers/{name}": { + "get": { + "description": "Returns one nameserver configuration by it's name.", + "tags": [ + "Nameserver" + ], + "summary": "Return a nameserver", + "operationId": "getNameserver", + "parameters": [ + { + "type": "string", + "description": "Nameserver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/nameserver" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a nameserver configuration by it's name.", + "tags": [ + "Nameserver" + ], + "summary": "Replace a nameserver", + "operationId": "replaceNameserver", + "parameters": [ + { + "type": "string", + "description": "Nameserver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Nameserver replaced", + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/nameserver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a nameserver from the resolvers section by it's name.", + "tags": [ + "Nameserver" + ], + "summary": "Delete a nameserver", + "operationId": "deleteNameserver", + "parameters": [ + { + "type": "string", + "description": "Nameserver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Nameserver deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peer_entries": { + "get": { + "description": "Returns an array of all peer_entries that are configured in specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Return an array of peer_entries", + "operationId": "getPeerEntries", + "parameters": [ + { + "type": "string", + "description": "Parent peer section name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_entries" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new peer entry in the specified peer section in the configuration file.", + "tags": [ + "PeerEntry" + ], + "summary": "Add a new peer_entry", + "operationId": "createPeerEntry", + "parameters": [ + { + "type": "string", + "description": "Parent peer section name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "PeerEntry created", + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/peer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peer_entries/{name}": { + "get": { + "description": "Returns one peer_entry configuration by it's name in the specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Return one peer_entry", + "operationId": "getPeerEntry", + "parameters": [ + { + "type": "string", + "description": "PeerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent peers name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_entry" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a peer entry configuration by it's name in the specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Replace a peer_entry", + "operationId": "replacePeerEntry", + "parameters": [ + { + "type": "string", + "description": "PeerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent peers name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "PeerEntry replaced", + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/peer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a peer entry configuration by it's name in the specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Delete a peer_entry", + "operationId": "deletePeerEntry", + "parameters": [ + { + "type": "string", + "description": "PeerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent peers name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "PeerEntry deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peer_section": { + "get": { + "description": "Returns an array of all configured peer_section.", + "tags": [ + "Peer" + ], + "summary": "Return an array of peer_section", + "operationId": "getPeerSections", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new peer to the configuration file.", + "tags": [ + "Peer" + ], + "summary": "Add a peer", + "operationId": "createPeer", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/peer_section" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Peer created", + "schema": { + "$ref": "#/definitions/peer_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/peer_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peer_section/{name}": { + "get": { + "description": "Returns one peer configuration by it's name.", + "tags": [ + "Peer" + ], + "summary": "Return a peer", + "operationId": "getPeerSection", + "parameters": [ + { + "type": "string", + "description": "Peer name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_section" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a peer from the configuration by it's name.", + "tags": [ + "Peer" + ], + "summary": "Delete a peer", + "operationId": "deletePeer", + "parameters": [ + { + "type": "string", + "description": "Peer name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Peer deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/binds": { + "get": { + "description": "Returns an array of all binds that are configured in specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return an array of binds", + "operationId": "getAllBindPeer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new bind in the specified frontend in the configuration file.", + "tags": [ + "Bind" + ], + "summary": "Add a new bind", + "operationId": "createBindPeer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/binds/{name}": { + "get": { + "description": "Returns one bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return one bind", + "operationId": "getBindPeer", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Replace a bind", + "operationId": "replaceBindPeer", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Delete a bind", + "operationId": "deleteBindPeer", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetPeer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetPeer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/servers": { + "get": { + "description": "Returns an array of all servers that are configured in specified backend.", + "tags": [ + "Server" + ], + "summary": "Return an array of servers", + "operationId": "getAllServerPeer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/servers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new server in the specified backend in the configuration file.", + "tags": [ + "Server" + ], + "summary": "Add a new server", + "operationId": "createServerPeer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Server created", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/servers/{name}": { + "get": { + "description": "Returns one server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Return one server", + "operationId": "getServerPeer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Replace a server", + "operationId": "replaceServerPeer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Server replaced", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Delete a server", + "operationId": "deleteServerPeer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Server deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/tables": { + "get": { + "description": "Returns an array of all tables that are configured in specified peer section.", + "tags": [ + "Table" + ], + "summary": "Return an array of tables", + "operationId": "getTables", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tables" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new table in the specified peer section in the configuration file.", + "tags": [ + "Table" + ], + "summary": "Add a new table", + "operationId": "createTable", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/table" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Table created", + "schema": { + "$ref": "#/definitions/table" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/table" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/tables/{name}": { + "get": { + "description": "Returns one table configuration by it's name in the specified peer section.", + "tags": [ + "Table" + ], + "summary": "Return one table", + "operationId": "getTable", + "parameters": [ + { + "type": "string", + "description": "Table name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/table" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a table configuration by it's name in the specified peer section.", + "tags": [ + "Table" + ], + "summary": "Replace a table", + "operationId": "replaceTable", + "parameters": [ + { + "type": "string", + "description": "Table name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/table" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Table replaced", + "schema": { + "$ref": "#/definitions/table" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/table" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a table configuration by it's name in the specified peer section.", + "tags": [ + "Table" + ], + "summary": "Delete a table", + "operationId": "deleteTable", + "parameters": [ + { + "type": "string", + "description": "Table name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Table deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/programs": { + "get": { + "description": "Returns an array of all configured programs in the process-manager configuration file.", + "tags": [ + "ProcessManager" + ], + "summary": "Return an array of programs", + "operationId": "getPrograms", + "deprecated": true, + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/programs" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new program to the process-manager configuration file.", + "tags": [ + "ProcessManager" + ], + "summary": "Add a program", + "operationId": "createProgram", + "deprecated": true, + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/program" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Program created", + "schema": { + "$ref": "#/definitions/program" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/program" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/programs/{name}": { + "get": { + "description": "Returns one program by its name from the process-manager configuration file.", + "tags": [ + "ProcessManager" + ], + "summary": "Return a program", + "operationId": "getProgram", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Program name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/program" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a program from the process-manager configuration by its name.", + "tags": [ + "ProcessManager" + ], + "summary": "Replace a program", + "operationId": "replaceProgram", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Program name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/program" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Program replaced", + "schema": { + "$ref": "#/definitions/program" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/program" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a program from the process-manager configuration file by its name.", + "tags": [ + "ProcessManager" + ], + "summary": "Delete a program", + "operationId": "deleteProgram", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Program name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Program deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/raw": { + "get": { + "description": "Returns HAProxy configuration file in plain text", + "produces": [ + "text/plain" + ], + "tags": [ + "Configuration" + ], + "summary": "Return HAProxy configuration", + "operationId": "getHAProxyConfiguration", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "200": { + "description": "Operation successful", + "schema": { + "type": "string" + }, + "headers": { + "Cluster-Version": { + "type": "string", + "description": "Cluster configuration version" + }, + "Configuration-Checksum": { + "type": "string", + "description": "Configuration file md5 checksum" + }, + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "type": "string" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Push a new haproxy configuration file in plain text", + "consumes": [ + "text/plain" + ], + "produces": [ + "text/plain" + ], + "tags": [ + "Configuration" + ], + "summary": "Push new haproxy configuration", + "operationId": "postHAProxyConfiguration", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "type": "boolean", + "default": false, + "description": "If set, no version check will be done and the pushed config will be enforced", + "name": "skip_version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated and runtime actions from X-Runtime-Actions will be applied", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, only validates configuration, without applying it", + "name": "only_validate", + "in": "query" + }, + { + "type": "string", + "description": "List of Runtime API commands with parameters separated by ';'", + "name": "X-Runtime-Actions", + "in": "header" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "New HAProxy configuration pushed", + "schema": { + "type": "string" + }, + "headers": { + "Cluster-Version": { + "type": "string", + "description": "Cluster configuration version" + }, + "Configuration-Checksum": { + "type": "string", + "description": "Configuration file md5 checksum" + }, + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "type": "string" + }, + "headers": { + "Cluster-Version": { + "type": "string", + "description": "Cluster configuration version" + }, + "Configuration-Checksum": { + "type": "string", + "description": "Configuration file md5 checksum" + }, + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + }, + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "type": "string" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "type": "string" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/resolvers": { + "get": { + "description": "Returns an array of all configured resolvers.", + "tags": [ + "Resolver" + ], + "summary": "Return an array of resolvers", + "operationId": "getResolvers", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/resolvers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new resolver section to the configuration file.", + "tags": [ + "Resolver" + ], + "summary": "Add a resolver", + "operationId": "createResolver", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/resolver" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Resolver created", + "schema": { + "$ref": "#/definitions/resolver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/resolver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/resolvers/{name}": { + "get": { + "description": "Returns one resolver section configuration by it's name.", + "tags": [ + "Resolver" + ], + "summary": "Return a resolver", + "operationId": "getResolver", + "parameters": [ + { + "type": "string", + "description": "Resolver name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/resolver" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a resolver configuration by it's name.", + "tags": [ + "Resolver" + ], + "summary": "Replace a resolver", + "operationId": "replaceResolver", + "parameters": [ + { + "type": "string", + "description": "Resolver name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/resolver" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Resolver replaced", + "schema": { + "$ref": "#/definitions/resolver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/resolver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a resolver from the configuration by it's name.", + "tags": [ + "Resolver" + ], + "summary": "Delete a resolver", + "operationId": "deleteResolver", + "parameters": [ + { + "type": "string", + "description": "Resolver name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Resolver deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/rings": { + "get": { + "description": "Returns an array of all configured rings.", + "tags": [ + "Ring" + ], + "summary": "Return an array of rings", + "operationId": "getRings", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/rings" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new ring to the configuration file.", + "tags": [ + "Ring" + ], + "summary": "Add a ring", + "operationId": "createRing", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ring" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Ring created", + "schema": { + "$ref": "#/definitions/ring" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ring" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/rings/{name}": { + "get": { + "description": "Returns one ring configuration by it's name.", + "tags": [ + "Ring" + ], + "summary": "Return a ring", + "operationId": "getRing", + "parameters": [ + { + "type": "string", + "description": "Ring name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ring" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a ring configuration by it's name.", + "tags": [ + "Ring" + ], + "summary": "Replace a ring", + "operationId": "replaceRing", + "parameters": [ + { + "type": "string", + "description": "Ring name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ring" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Ring replaced", + "schema": { + "$ref": "#/definitions/ring" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ring" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a ring from the configuration by it's name.", + "tags": [ + "Ring" + ], + "summary": "Delete a ring", + "operationId": "deleteRing", + "parameters": [ + { + "type": "string", + "description": "Ring name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Ring deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/rings/{parent_name}/servers": { + "get": { + "description": "Returns an array of all servers that are configured in specified backend.", + "tags": [ + "Server" + ], + "summary": "Return an array of servers", + "operationId": "getAllServerRing", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/servers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new server in the specified backend in the configuration file.", + "tags": [ + "Server" + ], + "summary": "Add a new server", + "operationId": "createServerRing", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Server created", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/rings/{parent_name}/servers/{name}": { + "get": { + "description": "Returns one server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Return one server", + "operationId": "getServerRing", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Replace a server", + "operationId": "replaceServerRing", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Server replaced", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Delete a server", + "operationId": "deleteServerRing", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Server deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/traces": { + "get": { + "description": "Return the traces section contents.", + "tags": [ + "Traces" + ], + "summary": "Return the traces section contents", + "operationId": "getTraces", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/traces" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replace the traces section contents", + "tags": [ + "Traces" + ], + "summary": "Replace traces", + "operationId": "replaceTraces", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/traces" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Traces replaced", + "schema": { + "$ref": "#/definitions/traces" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/traces" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Create the traces section.", + "tags": [ + "Traces" + ], + "summary": "Create the traces section", + "operationId": "createTraces", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/traces" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Traces section created", + "schema": { + "$ref": "#/definitions/traces" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/traces" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Delete the whole traces section.", + "tags": [ + "Traces" + ], + "summary": "Delete the traces section", + "operationId": "deleteTraces", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Traces section deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/traces/entries": { + "post": { + "description": "Adds a new trace entry into the traces section. The traces section will be created if needed.", + "tags": [ + "Traces" + ], + "summary": "Add a new trace entry", + "operationId": "createTraceEntry", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/trace_entry" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Trace entry added", + "schema": { + "$ref": "#/definitions/trace_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/trace_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a trace entry from the traces section.", + "tags": [ + "Traces" + ], + "summary": "Delete a trace entry", + "operationId": "deleteTraceEntry", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/trace_entry" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Trace entry deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/userlists": { + "get": { + "description": "Returns an array of all configured userlists.", + "tags": [ + "Userlist" + ], + "summary": "Return an array of userlists", + "operationId": "getUserlists", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/userlists" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new userlist to the configuration file.", + "tags": [ + "Userlist" + ], + "summary": "Add a new userlist", + "operationId": "createUserlist", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/userlist" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "201": { + "description": "Userlist created", + "schema": { + "$ref": "#/definitions/userlist" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/userlist" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/userlists/{name}": { + "get": { + "description": "Returns one userlist configuration by it's name.", + "tags": [ + "Userlist" + ], + "summary": "Return one userlist", + "operationId": "getUserlist", + "parameters": [ + { + "type": "string", + "description": "Userlist name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/full_section" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/userlist" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a userlist configuration by it's name.", + "tags": [ + "Userlist" + ], + "summary": "Delete a userlist", + "operationId": "deleteUserlist", + "parameters": [ + { + "type": "string", + "description": "Userlist name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Userlist deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/users": { + "get": { + "tags": [ + "User" + ], + "summary": "Return an array of userlist users", + "operationId": "getUsers", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/users" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "tags": [ + "User" + ], + "summary": "Add a new userlist user", + "operationId": "createUser", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "User created", + "schema": { + "$ref": "#/definitions/user" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/user" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/users/{username}": { + "get": { + "tags": [ + "User" + ], + "summary": "Return one userlist user", + "operationId": "getUser", + "parameters": [ + { + "type": "string", + "description": "User username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/user" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "tags": [ + "User" + ], + "summary": "Replace a user", + "operationId": "replaceUser", + "parameters": [ + { + "type": "string", + "description": "User username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "User replaced", + "schema": { + "$ref": "#/definitions/user" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/user" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "tags": [ + "User" + ], + "summary": "Delete a user", + "operationId": "deleteUser", + "parameters": [ + { + "type": "string", + "description": "User username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "User deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/configuration/version": { + "get": { + "description": "Returns configuration version.", + "tags": [ + "Configuration" + ], + "summary": "Return a configuration version", + "operationId": "getConfigurationVersion", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Configuration version", + "schema": { + "type": "integer" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/reloads": { + "get": { + "description": "Returns a list of HAProxy reloads.", + "produces": [ + "application/json" + ], + "tags": [ + "Reloads" + ], + "summary": "Return list of HAProxy Reloads.", + "operationId": "getReloads", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/reloads" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/reloads/{id}": { + "get": { + "description": "Returns one HAProxy reload status.", + "tags": [ + "Reloads" + ], + "summary": "Return one HAProxy reload status", + "operationId": "getReload", + "parameters": [ + { + "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$", + "type": "string", + "description": "Reload id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/reload" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime": { + "get": { + "description": "Returns a list of endpoints to be used for advanced runtime settings of HAProxy objects.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy advanced runtime endpoints", + "operationId": "getRuntimeEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/acls": { + "get": { + "description": "Returns all ACL files using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an array of all ACL files", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_files" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/acls/{id}": { + "get": { + "description": "Returns an ACL file by id using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an ACL file", + "parameters": [ + { + "type": "string", + "description": "ACL file entry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_file" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/acls/{parent_name}/entries": { + "get": { + "description": "Returns an ACL runtime setting using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an ACL entries", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_files_entries" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Adds a new ACL payload.", + "tags": [ + "ACL Runtime" + ], + "summary": "Add a new ACL payload", + "operationId": "addPayloadRuntimeACL", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl_files_entries" + } + } + ], + "responses": { + "201": { + "description": "ACL payload added", + "schema": { + "$ref": "#/definitions/acl_files_entries" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds an entry into the ACL file using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Add entry to an ACL file", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl_file_entry" + } + } + ], + "responses": { + "201": { + "description": "ACL entry created", + "schema": { + "$ref": "#/definitions/acl_file_entry" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/acls/{parent_name}/entries/{id}": { + "get": { + "description": "Returns the ACL entry by its ID using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an ACL entry", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "File entry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_file_entry" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes the entry from the ACL by its value using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Delete an ACL entry", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "File entry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Successful operation" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/acme": { + "get": { + "description": "Returns the status of each managed ACME certificate.", + "tags": [ + "AcmeRuntime" + ], + "summary": "ACME Status", + "operationId": "getAcmeStatus", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acme_status" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Force renewal of an ACME certificate.", + "tags": [ + "AcmeRuntime" + ], + "summary": "Renew ACME certificate", + "operationId": "renewAcmeCertificate", + "parameters": [ + { + "type": "string", + "description": "Certificate file name", + "name": "certificate", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Operation started" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/backends/{parent_name}/servers": { + "get": { + "description": "Returns an array of all servers' runtime settings.", + "tags": [ + "Server" + ], + "summary": "Return an array of runtime servers' settings", + "operationId": "getAllRuntimeServer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/runtime_servers" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new server to the specified backend", + "tags": [ + "Server" + ], + "summary": "Adds a new server to a backend", + "operationId": "addRuntimeServer", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/runtime_add_server" + } + } + ], + "responses": { + "201": { + "description": "Server added", + "schema": { + "$ref": "#/definitions/runtime_add_server" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/backends/{parent_name}/servers/{name}": { + "get": { + "description": "Returns one server runtime settings by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Return one server runtime settings", + "operationId": "getRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/runtime_server" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a server transient settings by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Replace server transient settings", + "operationId": "replaceRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/runtime_server" + } + } + ], + "responses": { + "200": { + "description": "Server transient settings replaced", + "schema": { + "$ref": "#/definitions/runtime_server" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a server from the specified backend", + "tags": [ + "Server" + ], + "summary": "Deletes a server from a backend", + "operationId": "deleteRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + } + ], + "responses": { + "204": { + "description": "Server deleted" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/info": { + "get": { + "description": "Return HAProxy process information", + "produces": [ + "application/json" + ], + "tags": [ + "Information" + ], + "summary": "Return HAProxy process information", + "operationId": "getHaproxyProcessInfo", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/process_info" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/maps": { + "get": { + "description": "Returns runtime map files.", + "tags": [ + "Maps" + ], + "summary": "Return runtime map files", + "operationId": "getAllRuntimeMapFiles", + "parameters": [ + { + "type": "boolean", + "default": false, + "description": "If true, also show unmanaged map files loaded in haproxy", + "name": "include_unmanaged", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/maps" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/maps/{name}": { + "get": { + "description": "Returns one runtime map file.", + "tags": [ + "Maps" + ], + "summary": "Return one runtime map file", + "operationId": "getOneRuntimeMap", + "parameters": [ + { + "type": "string", + "description": "Map file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/map" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Adds a new map payload.", + "tags": [ + "Maps" + ], + "summary": "Add a new map payload", + "operationId": "addPayloadRuntimeMap", + "parameters": [ + { + "type": "string", + "description": "Map file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/map_entries" + } + } + ], + "responses": { + "201": { + "description": "Map payload added", + "schema": { + "$ref": "#/definitions/map_entries" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Remove all map entries from the map file.", + "tags": [ + "Maps" + ], + "summary": "Remove all map entries from the map file", + "operationId": "clearRuntimeMap", + "parameters": [ + { + "type": "string", + "description": "Map file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "If true, deletes file from disk", + "name": "forceDelete", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + } + ], + "responses": { + "204": { + "description": "All map entries deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/maps/{parent_name}/entries": { + "get": { + "description": "Returns an array of all entries in a given runtime map file.", + "tags": [ + "Maps" + ], + "summary": "Return one map runtime entries", + "operationId": "showRuntimeMap", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/map_entries" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds an entry into the map file.", + "tags": [ + "Maps" + ], + "summary": "Adds an entry into the map file", + "operationId": "addMapEntry", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/map_entry" + } + } + ], + "responses": { + "201": { + "description": "Map entry created", + "schema": { + "$ref": "#/definitions/map_entry" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/maps/{parent_name}/entries/{id}": { + "get": { + "description": "Returns one map runtime setting by it's id.", + "tags": [ + "Maps" + ], + "summary": "Return one map runtime setting", + "operationId": "getRuntimeMapEntry", + "parameters": [ + { + "type": "string", + "description": "Map id", + "name": "id", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/map_entry" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces the value corresponding to each id in a map.", + "tags": [ + "Maps" + ], + "summary": "Replace the value corresponding to each id in a map", + "operationId": "replaceRuntimeMapEntry", + "parameters": [ + { + "type": "string", + "description": "Map id", + "name": "id", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "description": "Map value", + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "Map value replaced", + "schema": { + "$ref": "#/definitions/map_entry" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Delete all the map entries from the map by its id.", + "tags": [ + "Maps" + ], + "summary": "Deletes all the map entries from the map by its id", + "operationId": "deleteRuntimeMapEntry", + "parameters": [ + { + "type": "string", + "description": "Map id", + "name": "id", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Map key/value deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files": { + "get": { + "description": "Returns all SSL CA files using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an array of all SSL CA files", + "operationId": "getAllCaFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_ca_files" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a new SSL CA file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Creates a new SSL CA file", + "operationId": "createCaFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "CA certificate file", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "SSL CA file created" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files/{name}": { + "get": { + "description": "Returns an SSL CA file by name using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an SSL CA file", + "operationId": "getCaFile", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_ca_file" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replace the contents of a CA file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Update the contents of a CA file", + "operationId": "setCaFile", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "SSL CA payload added" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a CA file", + "tags": [ + "SSLRuntime" + ], + "summary": "Deletes a CA file", + "operationId": "deleteCaFile", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "SSL CA deleted" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files/{name}/entries": { + "post": { + "description": "Adds an entry to an existing CA file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Add a certificate to a CA file", + "operationId": "addCaEntry", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "description": "Payload of the cert entry", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files/{name}/entries/{index}": { + "get": { + "description": "Returns an SSL CA file cert entry.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an SSL CA file cert entry", + "operationId": "getCaEntry", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "SSL CA file index", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_certs": { + "get": { + "description": "Returns certificate files descriptions from runtime.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return a list of SSL certificate files", + "operationId": "getAllCerts", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificates" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a new SSL certificate file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Create a new SSL certificate file", + "operationId": "createCert", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "Certificate file", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "Certificate created" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_certs/{name}": { + "get": { + "description": "Returns one structured certificate using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return one structured certificate", + "operationId": "getCert", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Sets a certificate payload using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Replace the contents of a certificate", + "operationId": "replaceCert", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "File updated" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a certificate using the runtime socket.", + "tags": [ + "SSLRuntime" + ], + "summary": "Delete a certificate", + "operationId": "deleteCert", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "File deleted" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_crl_files": { + "get": { + "description": "Returns all the certificate revocation list files using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an array of all the CRL files", + "operationId": "getAllCrl", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crls" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a new CRL file with its contents using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Create a new CRL file", + "operationId": "createCrl", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "CRL file", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "CRL file created" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_crl_files/{name}": { + "get": { + "description": "Returns one or all entries in a CRL file using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Get the contents of a CRL file", + "operationId": "getCrl", + "parameters": [ + { + "type": "string", + "description": "CRL file name", + "name": "name", + "in": "path", + "required": true + }, + { + "minimum": 1, + "type": "integer", + "x-nullable": true, + "description": "Entry index to return. Starts at 1. If not provided, all entries are returned.", + "name": "index", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crl_entries" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces the contents of a CRL file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Replace the contents of a CRL file", + "operationId": "replaceCrl", + "parameters": [ + { + "type": "string", + "description": "CRL file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "description": "CRL file contents", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "File modified" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a CRL file using the runtime socket.", + "tags": [ + "SSLRuntime" + ], + "summary": "Delete a CRL file", + "operationId": "deleteCrl", + "parameters": [ + { + "type": "string", + "description": "CRL file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "File deleted" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_crt_lists": { + "get": { + "description": "Returns an array of crt-list file descriptions from runtime.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Get the list of all crt-list files", + "operationId": "getAllCrtLists", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_lists" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/ssl_crt_lists/entries": { + "get": { + "description": "Returns an array of entries present inside the given crt-list file. Their index can be used to delete them.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Get all the entries inside a crt-list", + "operationId": "getAllCrtListEntries", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list filename", + "name": "name", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_list_entries" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Appends an entry to the given crt-list using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Add an entry into a crt-list", + "operationId": "addCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list filename", + "name": "name", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_crt_list_entry" + } + } + ], + "responses": { + "201": { + "description": "Successful operation" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a single entry from the given crt-list using the runtime socket.", + "tags": [ + "SSLRuntime" + ], + "summary": "Delete an entry from a crt-list", + "operationId": "deleteCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt list name", + "name": "name", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "SSL cert entry name", + "name": "cert_file", + "in": "query", + "required": true + }, + { + "minimum": 1, + "type": "integer", + "x-nullable": true, + "description": "The line number where the entry is located, in case several entries share the same certificate.", + "name": "line_number", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Successful operation" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/stick_tables": { + "get": { + "description": "Returns an array of all stick tables.", + "tags": [ + "StickTable" + ], + "summary": "Return Stick Tables", + "operationId": "getStickTables", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_tables" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/stick_tables/{name}": { + "get": { + "description": "Returns one stick table from runtime.", + "tags": [ + "StickTable" + ], + "summary": "Return Stick Table", + "operationId": "getStickTable", + "parameters": [ + { + "type": "string", + "description": "Stick table name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_table" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/runtime/stick_tables/{parent_name}/entries": { + "get": { + "description": "Returns an array of all entries in a given stick tables.", + "tags": [ + "StickTable" + ], + "summary": "Return Stick Table Entries", + "operationId": "getStickTableEntries", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "A list of filters in format data.\u003ctype\u003e \u003coperator\u003e \u003cvalue\u003e separated by comma", + "name": "filter", + "in": "query" + }, + { + "type": "string", + "description": "Key which we want the entries for", + "name": "key", + "in": "query" + }, + { + "type": "integer", + "description": "Max number of entries to be returned for pagination", + "name": "count", + "in": "query" + }, + { + "type": "integer", + "description": "Offset which indicates how many items we skip in pagination", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_table_entries" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Create or update a stick-table entry in the table.", + "tags": [ + "StickTable" + ], + "summary": "Set Entry to Stick Table", + "operationId": "setStickTableEntries", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "description": "Stick table entry", + "name": "stick_table_entry", + "in": "body", + "schema": { + "type": "object", + "required": [ + "key", + "data_type" + ], + "properties": { + "data_type": { + "$ref": "#/definitions/stick_table_entry" + }, + "key": { + "type": "string" + } + } + } + } + ], + "responses": { + "204": { + "description": "Successful operation" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/sites": { + "get": { + "description": "Returns an array of all configured sites.", + "tags": [ + "Sites" + ], + "summary": "Return an array of sites", + "operationId": "getSites", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/sites" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new site to the configuration file.", + "tags": [ + "Sites" + ], + "summary": "Add a site", + "operationId": "createSite", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/site" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Site created", + "schema": { + "$ref": "#/definitions/site" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/site" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/sites/{name}": { + "get": { + "description": "Returns one site configuration by it's name.", + "tags": [ + "Sites" + ], + "summary": "Return a site", + "operationId": "getSite", + "parameters": [ + { + "type": "string", + "description": "Site frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/site" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a site configuration by it's name.", + "tags": [ + "Sites" + ], + "summary": "Replace a site", + "operationId": "replaceSite", + "parameters": [ + { + "type": "string", + "description": "Site frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/site" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Site replaced", + "schema": { + "$ref": "#/definitions/site" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/site" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a site from the configuration by it's name.", + "tags": [ + "Sites" + ], + "summary": "Delete a site", + "operationId": "deleteSite", + "parameters": [ + { + "type": "string", + "description": "Site frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Site deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe": { + "get": { + "description": "Returns a list of endpoints to be used for SPOE settings of HAProxy.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy SPOE endpoints", + "operationId": "getSpoeEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files": { + "get": { + "description": "Returns all available SPOE files.", + "tags": [ + "Spoe" + ], + "summary": "Return all available SPOE files", + "operationId": "getAllSpoeFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_files" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates SPOE file with its entries.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Spoe" + ], + "summary": "Creates SPOE file with its entries", + "operationId": "createSpoe", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The spoe file to upload", + "name": "file_upload", + "in": "formData" + } + ], + "responses": { + "201": { + "description": "SPOE file created with its entries", + "schema": { + "type": "string" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{name}": { + "get": { + "description": "Returns one SPOE file.", + "tags": [ + "Spoe" + ], + "summary": "Return one SPOE file", + "operationId": "getOneSpoeFile", + "parameters": [ + { + "type": "string", + "description": "SPOE file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "string" + } + } + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes SPOE file.", + "tags": [ + "Spoe" + ], + "summary": "Delete SPOE file", + "operationId": "deleteSpoeFile", + "parameters": [ + { + "type": "string", + "description": "SPOE file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "SPOE file deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes": { + "get": { + "description": "Returns an array of all configured spoe scopes.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of spoe scopes", + "operationId": "getAllSpoeScope", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_scopes" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new spoe scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new spoe scope", + "operationId": "createSpoeScope", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_scope" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "201": { + "description": "Spoe scope created", + "schema": { + "$ref": "#/definitions/spoe_scope" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name}": { + "get": { + "description": "Returns one SPOE scope in one SPOE file.", + "tags": [ + "Spoe" + ], + "summary": "Return one SPOE scope", + "operationId": "getSpoeScope", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_scope" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a SPOE scope from the configuration file.", + "tags": [ + "Spoe" + ], + "summary": "Delete a SPOE scope", + "operationId": "deleteSpoeScope", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "204": { + "description": "Spoe scope deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents": { + "get": { + "description": "Returns an array of all configured spoe agents in one scope.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of spoe agents in one scope", + "operationId": "getAllSpoeAgent", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_agents" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new spoe agent to the spoe scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new spoe agent to scope", + "operationId": "createSpoeAgent", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "201": { + "description": "Spoe agent created", + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}": { + "get": { + "description": "Returns one spoe agent configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return a spoe agent", + "operationId": "getSpoeAgent", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe agent name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_agent" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a SPOE agent configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Replace a SPOE agent", + "operationId": "replaceSpoeAgent", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe agent name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "200": { + "description": "Spoe agent replaced", + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a SPOE agent from the configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Delete a SPOE agent", + "operationId": "deleteSpoeAgent", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe agent name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "204": { + "description": "Spoe agent deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups": { + "get": { + "description": "Returns an array of all configured SPOE groups in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of SPOE groups", + "operationId": "getAllSpoeGroup", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_groups" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new SPOE groups to the SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new SPOE groups", + "operationId": "createSpoeGroup", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "201": { + "description": "Spoe groups created", + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}": { + "get": { + "description": "Returns one SPOE groups configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return a SPOE groups", + "operationId": "getSpoeGroup", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe group name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_group" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a SPOE groups configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Replace a SPOE groups", + "operationId": "replaceSpoeGroup", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe group name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "200": { + "description": "Spoe groups replaced", + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a SPOE groups from the one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Delete a SPOE groups", + "operationId": "deleteSpoeGroup", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe group name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "204": { + "description": "Spoe group deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages": { + "get": { + "description": "Returns an array of all configured spoe messages in one scope.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of spoe messages in one scope", + "operationId": "getAllSpoeMessage", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_messages" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Adds a new spoe message to the spoe scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new spoe message to scope", + "operationId": "createSpoeMessage", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "201": { + "description": "Spoe message created", + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}": { + "get": { + "description": "Returns one spoe message configuration in SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return a spoe message", + "operationId": "getSpoeMessage", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe message name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_message" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a spoe message configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Replace a spoe message", + "operationId": "replaceSpoeMessage", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe message name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "200": { + "description": "Spoe message replaced", + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a spoe message from the SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Delete a spoe message", + "operationId": "deleteSpoeMessage", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe message name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/version" + } + ], + "responses": { + "204": { + "description": "Spoe message deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/transactions": { + "get": { + "description": "Returns a list of SPOE configuration transactions. Transactions can be filtered by their status.", + "produces": [ + "application/json" + ], + "tags": [ + "SpoeTransactions" + ], + "summary": "Return list of SPOE configuration transactions.", + "operationId": "getAllSpoeTransaction", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "enum": [ + "failed", + "in_progress" + ], + "type": "string", + "description": "Filter by transaction status", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/spoe_transactions" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Starts a new transaction and returns it's id", + "produces": [ + "application/json" + ], + "tags": [ + "SpoeTransactions" + ], + "summary": "Start a new transaction", + "operationId": "startSpoeTransaction", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "integer", + "description": "Configuration version on which to work on", + "name": "version", + "in": "query", + "required": true + } + ], + "responses": { + "201": { + "description": "Transaction started", + "schema": { + "$ref": "#/definitions/spoe_transaction" + } + }, + "429": { + "description": "Too many open transactions", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "message": { + "type": "string" + } + }, + "example": { + "code": 429, + "message": "cannot start a new transaction, reached the maximum amount of 20 active transactions available" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}": { + "get": { + "description": "Returns one SPOE configuration transactions.", + "tags": [ + "SpoeTransactions" + ], + "summary": "Return one SPOE configuration transactions", + "operationId": "getSpoeTransaction", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_transaction" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Commit transaction, execute all operations in transaction and return msg", + "tags": [ + "SpoeTransactions" + ], + "summary": "Commit transaction", + "operationId": "commitSpoeTransaction", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Transaction successfully committed", + "schema": { + "$ref": "#/definitions/spoe_transaction" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/spoe_transaction" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a transaction.", + "tags": [ + "SpoeTransactions" + ], + "summary": "Delete a transaction", + "operationId": "deleteSpoeTransaction", + "parameters": [ + { + "$ref": "#/parameters/parent_name" + }, + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Transaction deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/spoe/{parent_name}/version": { + "get": { + "description": "Returns SPOE configuration version.", + "tags": [ + "Spoe" + ], + "summary": "Return a SPOE configuration version", + "operationId": "getSpoeConfigurationVersion", + "parameters": [ + { + "$ref": "#/parameters/transaction_id" + }, + { + "$ref": "#/parameters/parent_name" + } + ], + "responses": { + "200": { + "description": "SPOE configuration version", + "schema": { + "type": "integer" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/stats": { + "get": { + "description": "Returns a list of HAProxy stats endpoints.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy stats endpoints", + "operationId": "getStatsEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/stats/native": { + "get": { + "description": "Getting stats from the HAProxy.", + "produces": [ + "application/json" + ], + "tags": [ + "Stats" + ], + "summary": "Gets stats", + "operationId": "getStats", + "parameters": [ + { + "enum": [ + "frontend", + "backend", + "server" + ], + "type": "string", + "description": "Object type to get stats for (one of frontend, backend, server)", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "Object name to get stats for", + "name": "name", + "in": "query" + }, + { + "type": "string", + "x-dependency": { + "query.type": "server" + }, + "description": "Object parent name to get stats for, in case the object is a server", + "name": "parent", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/native_stats" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/native_stats" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage": { + "get": { + "description": "Returns a list of endpoints that use HAProxy storage for persistency, e.g. maps, ssl certificates...", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy storage endpoints", + "operationId": "getStorageEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/general": { + "get": { + "description": "Returns a list of all managed general use files", + "tags": [ + "Storage" + ], + "summary": "Return a list of all managed general use files", + "operationId": "getAllStorageGeneralFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/general_files" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a managed storage general use file with contents.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Creates a managed storage general use file with contents", + "operationId": "createStorageGeneralFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "application/octet-stream", + "description": "General use file content", + "name": "file_upload", + "in": "formData" + } + ], + "responses": { + "201": { + "description": "General use file created with its contents", + "schema": { + "$ref": "#/definitions/general_file" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/general/{name}": { + "get": { + "description": "Returns the contents of one managed general use file from disk", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Storage" + ], + "summary": "Return the contents of one managed general use file from disk", + "operationId": "getOneStorageGeneralFile", + "parameters": [ + { + "type": "string", + "description": "General use file storage_name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "file" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces the contents of a managed general use file on disk", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace contents of a managed general use file on disk", + "operationId": "replaceStorageGeneralFile", + "parameters": [ + { + "type": "string", + "description": "General use file storage_name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "application/octet-stream", + "description": "General use file content", + "name": "file_upload", + "in": "formData" + }, + { + "$ref": "#/parameters/skip_reload" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "General use file replaced" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a managed general use file from disk.", + "tags": [ + "Storage" + ], + "summary": "Deletes a managed general use file from disk", + "operationId": "deleteStorageGeneralFile", + "parameters": [ + { + "type": "string", + "description": "General use file storage_name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "General use file deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/maps": { + "get": { + "description": "Returns a list of all managed map files", + "tags": [ + "Storage" + ], + "summary": "Return a list of all managed map files", + "operationId": "getAllStorageMapFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/maps" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a managed storage map file with its entries.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Creates a managed storage map file with its entries", + "operationId": "createStorageMapFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The map file contents", + "name": "file_upload", + "in": "formData" + } + ], + "responses": { + "201": { + "description": "Map file created with its entries", + "schema": { + "$ref": "#/definitions/map" + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/maps/{name}": { + "get": { + "description": "Returns the contents of one managed map file from disk", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Storage" + ], + "summary": "Return the contents of one managed map file from disk", + "operationId": "getOneStorageMap", + "parameters": [ + { + "type": "string", + "description": "Map file storage_name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "file" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces the contents of a managed map file on disk", + "consumes": [ + "text/plain" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace contents of a managed map file on disk", + "operationId": "replaceStorageMapFile", + "parameters": [ + { + "type": "string", + "description": "Map file storage_name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "$ref": "#/parameters/skip_reload" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Map file replaced" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a managed map file from disk.", + "tags": [ + "Storage" + ], + "summary": "Deletes a managed map file from disk", + "operationId": "deleteStorageMap", + "parameters": [ + { + "type": "string", + "description": "Map file storage_name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Map file deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/ssl_certificates": { + "get": { + "description": "Returns all available SSL certificates on disk.", + "tags": [ + "Storage" + ], + "summary": "Return all available SSL certificates on disk", + "operationId": "getAllStorageSSLCertificates", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificates" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates SSL certificate.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Create SSL certificate", + "operationId": "createStorageSSLCertificate", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The SSL certificate to upload", + "name": "file_upload", + "in": "formData" + }, + { + "$ref": "#/parameters/skip_reload" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "SSL certificate created", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "202": { + "description": "SSL certificate created requested", + "schema": { + "$ref": "#/definitions/ssl_certificate" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/ssl_certificates/{name}": { + "get": { + "description": "Returns one SSL certificate from disk.", + "tags": [ + "Storage" + ], + "summary": "Return one SSL certificate from disk", + "operationId": "getOneStorageSSLCertificate", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces SSL certificate on disk.", + "consumes": [ + "text/plain" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace SSL certificates on disk", + "operationId": "replaceStorageSSLCertificate", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "$ref": "#/parameters/skip_reload" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "SSL certificate replaced", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "202": { + "description": "SSL certificate replaced and reload requested", + "schema": { + "$ref": "#/definitions/ssl_certificate" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes SSL certificate from disk.", + "tags": [ + "Storage" + ], + "summary": "Delete SSL certificate from disk", + "operationId": "deleteStorageSSLCertificate", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/skip_reload" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "SSL certificate deleted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "SSL certificate deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/ssl_crt_lists": { + "get": { + "description": "Returns all available certificate lists on disk.", + "tags": [ + "Storage" + ], + "summary": "Return all available certificate lists on disk", + "operationId": "getAllStorageSSLCrtListFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_list_files" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a certificate list.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Create a certificate list", + "operationId": "createStorageSSLCrtListFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The certificate list to upload", + "name": "file_upload", + "in": "formData" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "Certificate list created", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" + } + }, + "202": { + "description": "Certificate list created requested", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/ssl_crt_lists/{name}": { + "get": { + "description": "Returns one certificate list from disk.", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Storage" + ], + "summary": "Return one certificate list from disk", + "operationId": "getOneStorageSSLCrtListFile", + "parameters": [ + { + "type": "string", + "description": "Certificate list name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "file" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Replaces a certificate list on disk.", + "consumes": [ + "text/plain" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace a certificate lists on disk", + "operationId": "replaceStorageSSLCrtListFile", + "parameters": [ + { + "type": "string", + "description": "Certificate list name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "$ref": "#/parameters/skip_reload" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Certificate list replaced", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" + } + }, + "202": { + "description": "Certificate list replaced and reload requested", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a certificate list from disk.", + "tags": [ + "Storage" + ], + "summary": "Delete a certificate list from disk", + "operationId": "deleteStorageSSLCrtListFile", + "parameters": [ + { + "type": "string", + "description": "Certificate list name", + "name": "name", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/skip_reload" + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Certificate list deleted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Certificate list deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/storage/ssl_crt_lists/{name}/entries": { + "get": { + "description": "Returns all the entries in a certificate list.", + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Returns all the entries in a CrtList", + "operationId": "GetStorageSSLCrtListEntries", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list file", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_list_entries" + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Creates a new entry in a certificate list.", + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Creates a new entry in a CrtList", + "operationId": "CreateStorageSSLCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list file", + "name": "name", + "in": "path", + "required": true + }, + { + "description": "SSL crt-list entry", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_crt_list_entry" + } + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "201": { + "description": "New entry added", + "schema": { + "$ref": "#/definitions/ssl_crt_list_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "409": { + "$ref": "#/responses/AlreadyExists" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes an entry from a certificate list.", + "tags": [ + "Storage" + ], + "summary": "Deletes an entry from CrtList file", + "operationId": "DeleteStorageSSLCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt list name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "SSL certificate filename", + "name": "certificate", + "in": "query", + "required": true + }, + { + "type": "integer", + "description": "The line number in the crt-list", + "name": "line_number", + "in": "query", + "required": true + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Successful operation" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/transactions": { + "get": { + "description": "Returns a list of HAProxy configuration transactions. Transactions can be filtered by their status.", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Return list of HAProxy configuration transactions.", + "operationId": "getTransactions", + "parameters": [ + { + "enum": [ + "failed", + "in_progress" + ], + "type": "string", + "description": "Filter by transaction status", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/transactions" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "post": { + "description": "Starts a new transaction and returns it's id", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Start a new transaction", + "operationId": "startTransaction", + "parameters": [ + { + "type": "integer", + "description": "Configuration version on which to work on", + "name": "version", + "in": "query", + "required": true + } + ], + "responses": { + "201": { + "description": "Transaction started", + "schema": { + "$ref": "#/definitions/transaction" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "429": { + "description": "Too many open transactions", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "message": { + "type": "string" + } + }, + "example": { + "code": 429, + "message": "cannot start a new transaction, reached the maximum amount of 20 active transactions available" + } + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/services/haproxy/transactions/{id}": { + "get": { + "description": "Returns one HAProxy configuration transactions.", + "tags": [ + "Transactions" + ], + "summary": "Return one HAProxy configuration transactions", + "operationId": "getTransaction", + "parameters": [ + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/transaction" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "put": { + "description": "Commit transaction, execute all operations in transaction and return msg", + "tags": [ + "Transactions" + ], + "summary": "Commit transaction", + "operationId": "commitTransaction", + "parameters": [ + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/force_reload" + } + ], + "responses": { + "200": { + "description": "Transaction successfully committed", + "schema": { + "$ref": "#/definitions/transaction" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/transaction" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + }, + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "406": { + "$ref": "#/responses/NotAcceptable" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + }, + "delete": { + "description": "Deletes a transaction.", + "tags": [ + "Transactions" + ], + "summary": "Delete a transaction", + "operationId": "deleteTransaction", + "parameters": [ + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Transaction deleted" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/specification": { + "get": { + "description": "Return Data Plane API OpenAPI specification", + "produces": [ + "application/json" + ], + "tags": [ + "Specification" + ], + "summary": "Data Plane API Specification", + "operationId": "getSpecification", + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + }, + "/specification_openapiv3": { + "get": { + "description": "Return Data Plane API OpenAPI v3 specification", + "produces": [ + "application/json" + ], + "tags": [ + "SpecificationOpenapiv3" + ], + "summary": "Data Plane API v3 Specification", + "operationId": "getOpenapiv3Specification", + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object" + } + }, + "default": { + "$ref": "#/responses/DefaultError" + } + } + } + } + }, + "definitions": { + "acl": { + "description": "The use of Access Control Lists (ACL) provides a flexible solution to perform\ncontent switching and generally to take decisions based on content extracted\nfrom the request, the response or any environmental status.\n", + "type": "object", + "title": "ACL Lines", + "required": [ + "acl_name", + "criterion" + ], + "properties": { + "acl_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "criterion": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "value": { + "type": "string", + "x-nullable": false + } + }, + "additionalProperties": false + }, + "acl_file": { + "description": "ACL File", + "type": "object", + "title": "ACL File", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "storage_name": { + "type": "string" + } + } + }, + "acl_file_entry": { + "description": "One ACL File Entry", + "type": "object", + "title": "One ACL File Entry", + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "value": { + "type": "string" + } + } + }, + "acl_files": { + "description": "Array of runtime acl files", + "type": "array", + "title": "ACL Files Array", + "items": { + "$ref": "#/definitions/acl_file" + } + }, + "acl_files_entries": { + "description": "Array of entries of one runtime acl file", + "type": "array", + "title": "ACL Files Entries", + "items": { + "$ref": "#/definitions/acl_file_entry" + } + }, + "acls": { + "description": "HAProxy ACL lines array (corresponds to acl directives)", + "type": "array", + "title": "ACL Lines Array", + "items": { + "$ref": "#/definitions/acl" + } + }, + "acme_certificate_status": { + "description": "Status of a single ACME certificate from runtime.", + "type": "object", + "title": "ACME certificate status", + "properties": { + "acme_section": { + "description": "ACME section which generated the certificate.", + "type": "string" + }, + "certificate": { + "description": "Certificate name", + "type": "string" + }, + "expiries_in": { + "description": "Duration until certificate expiry.", + "type": "string" + }, + "expiry_date": { + "description": "Certificate expiration date.", + "type": "string", + "format": "date-time" + }, + "renewal_in": { + "description": "Duration until the next planned renewal.", + "type": "string" + }, + "scheduled_renewal": { + "description": "Planned date for certificate renewal.", + "type": "string", + "format": "date-time" + }, + "state": { + "description": "State of the ACME task, either \"Running\" or \"Scheduled\".", + "type": "string" + } + } + }, + "acme_provider": { + "description": "Define an ACME provider to generate certificates automatically", + "type": "object", + "title": "ACME Provider", + "required": [ + "name", + "directory" + ], + "properties": { + "account_key": { + "description": "Path where the the ACME account key is stored", + "type": "string" + }, + "acme_provider": { + "description": "DNS provider for the dns-01 challenge", + "type": "string" + }, + "acme_vars": { + "description": "List of variables passed to the dns-01 provider (typically API keys)", + "additionalProperties": { + "type": "string" + } + }, + "bits": { + "description": "Number of bits to generate an RSA certificate", + "type": "integer", + "minimum": 1024, + "x-nullable": true, + "x-omitempty": true + }, + "challenge": { + "description": "ACME challenge type. Only http-01 and dns-01 are supported.", + "type": "string", + "enum": [ + "http-01", + "dns-01" + ] + }, + "contact": { + "description": "Contact email for the ACME account", + "type": "string" + }, + "curves": { + "description": "Curves used with the ECDSA key type", + "type": "string" + }, + "directory": { + "description": "URL to the ACME provider's directory. For example:\nhttps://acme-staging-v02.api.letsencrypt.org/directory\n", + "type": "string", + "pattern": "^https://[^\\s]+$", + "x-nullable": false + }, + "keytype": { + "description": "Type of key to generate", + "type": "string", + "enum": [ + "RSA", + "ECDSA" + ] + }, + "map": { + "description": "The map which will be used to store the ACME token (key) and thumbprint", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "description": "ACME provider's name", + "type": "string", + "x-nullable": false + }, + "reuse_key": { + "description": "Try to reuse the private key instead of generating a new one.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + } + }, + "additionalProperties": false + }, + "acme_providers": { + "description": "List of ACME sections.", + "type": "array", + "items": { + "x-omitempty": true, + "$ref": "#/definitions/acme_provider" + } + }, + "acme_status": { + "description": "Status of all the ACME certificates from runtime.", + "type": "array", + "title": "ACME status", + "items": { + "$ref": "#/definitions/acme_certificate_status" + } + }, + "awsFilters": { + "type": "object", + "required": [ + "key", + "value" + ], + "properties": { + "key": { + "description": "Key to use as filter, using the format specified at https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options", + "type": "string" + }, + "value": { + "description": "Value of the filter to use", + "type": "string" + } + } + }, + "awsRegion": { + "description": "AWS region configuration", + "type": "object", + "title": "AWS region", + "required": [ + "name", + "region", + "enabled", + "retry_timeout", + "ipv4_address" + ], + "properties": { + "access_key_id": { + "description": "AWS Access Key ID.", + "type": "string" + }, + "allowlist": { + "description": "Specify the AWS filters used to filter the EC2 instances to add", + "type": "array", + "items": { + "$ref": "#/definitions/awsFilters" + }, + "x-omitempty": true + }, + "denylist": { + "description": "Specify the AWS filters used to filter the EC2 instances to ignore", + "type": "array", + "items": { + "$ref": "#/definitions/awsFilters" + }, + "x-omitempty": true + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "id": { + "description": "Auto generated ID.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true, + "readOnly": true + }, + "ipv4_address": { + "description": "Select which IPv4 address the Service Discovery has to use for the backend server entry", + "type": "string", + "enum": [ + "private", + "public" + ] + }, + "name": { + "type": "string" + }, + "region": { + "type": "string" + }, + "retry_timeout": { + "description": "Duration in seconds in-between data pulling requests to the AWS region", + "type": "integer", + "minimum": 1 + }, + "secret_access_key": { + "description": "AWS Secret Access Key.", + "type": "string" + }, + "server_slots_base": { + "type": "integer", + "default": 10 + }, + "server_slots_growth_increment": { + "type": "integer" + }, + "server_slots_growth_type": { + "type": "string", + "default": "exponential", + "enum": [ + "linear", + "exponential" + ] + } + }, + "example": { + "access_key_id": "****************L7GT", + "allowlist": [ + { + "key": "tag-key", + "value": "Instance:Having:This:Tag" + } + ], + "denylist": [ + { + "key": "tag:Environment", + "value": "development" + } + ], + "enabled": true, + "id": "0", + "ipv4_address": "private", + "name": "frontend-service", + "region": "us-east-1", + "retry_timeout": 1, + "secret_access_key": "****************soLl" + } + }, + "awsRegions": { + "description": "AWS regions array", + "type": "array", + "title": "AWS", + "items": { + "$ref": "#/definitions/awsRegion" + } + }, + "backend": { + "description": "Backend with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/backend_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" + }, + "filter_list": { + "x-go-name": "FilterList", + "$ref": "#/definitions/filters" + }, + "http_after_response_rule_list": { + "x-go-name": "HTTPAfterResponseRuleList", + "$ref": "#/definitions/http_after_response_rules" + }, + "http_check_list": { + "x-go-name": "HTTPCheckList", + "$ref": "#/definitions/http_checks" + }, + "http_error_rule_list": { + "x-go-name": "HTTPErrorRuleList", + "$ref": "#/definitions/http_error_rules" + }, + "http_request_rule_list": { + "x-go-name": "HTTPRequestRuleList", + "$ref": "#/definitions/http_request_rules" + }, + "http_response_rule_list": { + "x-go-name": "HTTPResponseRuleList", + "$ref": "#/definitions/http_response_rules" + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + }, + "server_switching_rule_list": { + "x-go-name": "ServerSwitchingRuleList", + "$ref": "#/definitions/server_switching_rules" + }, + "server_templates": { + "additionalProperties": { + "$ref": "#/definitions/server_template" + } + }, + "servers": { + "additionalProperties": { + "$ref": "#/definitions/server" + } + }, + "stick_rule_list": { + "x-go-name": "StickRuleList", + "$ref": "#/definitions/stick_rules" + }, + "tcp_check_rule_list": { + "x-go-name": "TCPCheckRuleList", + "$ref": "#/definitions/tcp_checks" + }, + "tcp_request_rule_list": { + "x-go-name": "TCPRequestRuleList", + "$ref": "#/definitions/tcp_request_rules" + }, + "tcp_response_rule_list": { + "x-go-name": "TCPResponseRuleList", + "$ref": "#/definitions/tcp_response_rules" + } + } + } + ], + "x-go-name": "Backend" + }, + "backend_base": { + "description": "HAProxy backend configuration", + "type": "object", + "title": "Backend Base", + "required": [ + "name" + ], + "properties": { + "abortonclose": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "accept_invalid_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Response" + }, + "accept_unsafe_violations_in_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Response" + }, + "adv_check": { + "type": "string", + "enum": [ + "httpchk", + "ldap-check", + "mysql-check", + "pgsql-check", + "redis-check", + "smtpchk", + "ssl-hello-chk", + "tcp-check" + ], + "x-display-name": "Advanced Check" + }, + "allbackups": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "All Backups" + }, + "balance": { + "$ref": "#/definitions/balance" + }, + "check_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "checkcache": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Checkcache" + }, + "compression": { + "$ref": "#/definitions/compression" + }, + "connect_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "cookie": { + "x-dependency": { + "mode": { + "value": "http" + } + }, + "$ref": "#/definitions/cookie" + }, + "default_server": { + "$ref": "#/definitions/default_server" + }, + "description": { + "type": "string", + "x-display-name": "Description" + }, + "disabled": { + "type": "boolean" + }, + "dynamic_cookie_key": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "cookie.dynamic": { + "value": true + } + } + }, + "email_alert": { + "$ref": "#/definitions/email_alert" + }, + "enabled": { + "type": "boolean" + }, + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" + }, + "x-go-name": "ErrorFiles", + "x-omitempty": true + }, + "errorfiles_from_http_errors": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfiles" + }, + "x-go-name": "ErrorFilesFromHTTPErrors", + "x-omitempty": true + }, + "errorloc302": { + "$ref": "#/definitions/errorloc" + }, + "errorloc303": { + "$ref": "#/definitions/errorloc" + }, + "external_check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "External Check" + }, + "external_check_command": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Command" + }, + "external_check_path": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Path" + }, + "force_persist": { + "description": "This field is deprecated in favor of force_persist_list, and will be removed in a future release", + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + } + }, + "x-deprecated": true, + "x-go-name": "BackendForcePersist" + }, + "force_persist_list": { + "type": "array", + "items": { + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + } + }, + "x-go-name": "ForcePersist" + }, + "x-go-name": "ForcePersistList", + "x-omitempty": true + }, + "forwardfor": { + "x-dependency": { + "mode": { + "value": "http" + } + }, + "$ref": "#/definitions/forwardfor" + }, + "from": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "fullconn": { + "type": "integer", + "x-nullable": true + }, + "guid": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "h1_case_adjust_bogus_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "H1 Adjust Bogus Server" + }, + "hash_balance_factor": { + "type": "integer", + "x-nullable": true + }, + "hash_preserve_affinity": { + "type": "string", + "enum": [ + "always", + "maxconn", + "maxqueue" + ] + }, + "hash_type": { + "$ref": "#/definitions/hash_type" + }, + "http-buffer-request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "HTTP bufferrequest" + }, + "http-drop-request-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Request Trailers" + }, + "http-no-delay": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "HTTP low interactive delays" + }, + "http-use-htx": { + "type": "string", + "pattern": "^[^\\s]+$", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } + } + }, + "http_connection_mode": { + "type": "string", + "enum": [ + "httpclose", + "http-server-close", + "http-keep-alive" + ], + "x-dependency": { + "mode": { + "value": "http" + } + } + }, + "http_keep_alive_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-duration": true, + "x-nullable": true + }, + "http_pretend_keepalive": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } + } + }, + "http_proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "HTTP proxy mode" + }, + "http_request_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-duration": true, + "x-nullable": true + }, + "http_restrict_req_hdr_names": { + "type": "string", + "enum": [ + "preserve", + "delete", + "reject" + ], + "x-display-name": "Restrict HTTP Request Header Names" + }, + "http_reuse": { + "type": "string", + "enum": [ + "aggressive", + "always", + "never", + "safe" + ], + "x-dependency": { + "mode": { + "value": "http" + } + } + }, + "http_send_name_header": { + "type": "string", + "x-display-name": "The header string to use to send the server name", + "x-nullable": true + }, + "httpchk_params": { + "x-dependency": { + "adv_check": { + "value": "httpchk" + }, + "mode": { + "value": "http" + } + }, + "$ref": "#/definitions/httpchk_params" + }, + "id": { + "type": "integer", + "x-nullable": true + }, + "ignore_persist": { + "description": "This field is deprecated in favor of ignore_persist_list, and will be removed in a future release", + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + } + }, + "x-deprecated": true, + "x-go-name": "BackendIgnorePersist" + }, + "ignore_persist_list": { + "type": "array", + "items": { + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + } + }, + "x-go-name": "IgnorePersist" + }, + "x-go-name": "IgnorePersistList", + "x-omitempty": true + }, + "independent_streams": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Independent Streams" + }, + "load_server_state_from_file": { + "type": "string", + "enum": [ + "global", + "local", + "none" + ] + }, + "log_health_checks": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log Health Checks" + }, + "log_tag": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "max_keep_alive_queue": { + "type": "integer", + "x-display-name": "Maximum keep alive queue", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp", + "log" + ] + }, + "mysql_check_params": { + "x-dependency": { + "adv_check": { + "value": "mysql-check" + } + }, + "$ref": "#/definitions/mysql_check_params" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "nolinger": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Nolinger" + }, + "originalto": { + "$ref": "#/definitions/originalto" + }, + "persist": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Persist" + }, + "persist_rule": { + "$ref": "#/definitions/persist_rule" + }, + "pgsql_check_params": { + "x-dependency": { + "adv_check": { + "value": "pgsql-check" + } + }, + "$ref": "#/definitions/pgsql_check_params" + }, + "prefer_last_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Prefer Last Server" + }, + "queue_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "redispatch": { + "$ref": "#/definitions/redispatch" + }, + "retries": { + "type": "integer", + "x-nullable": true + }, + "retry_on": { + "type": "string", + "x-display-name": "Retry on" + }, + "server_fin_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "server_state_file_name": { + "type": "string", + "x-display-name": "Server state file" + }, + "server_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "smtpchk_params": { + "x-dependency": { + "adv_check": { + "value": "smtpchk" + } + }, + "$ref": "#/definitions/smtpchk_params" + }, + "source": { + "$ref": "#/definitions/source" + }, + "splice_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Auto" + }, + "splice_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Request" + }, + "splice_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Response" + }, + "spop_check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Spop Check" + }, + "srvtcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" + } + }, + "x-display-name": "Server TCP Keep Alive" + }, + "srvtcpka_cnt": { + "type": "integer", + "x-display-name": "Srvtcpka Cnt", + "x-nullable": true + }, + "srvtcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "srvtcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "stats_options": { + "$ref": "#/definitions/stats_options" + }, + "stick_table": { + "$ref": "#/definitions/config_stick_table" + }, + "tarpit_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "tcp_smart_connect": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Connect" + }, + "tcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" + } + }, + "x-display-name": "TCP Keep Alive" + }, + "transparent": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Transparent" + }, + "tunnel_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "use_fcgi_app": { + "type": "string", + "x-display-name": "FastCGI application" + } + }, + "additionalProperties": false, + "example": { + "adv_check": "httpchk", + "balance": { + "algorithm": "roundrobin" + }, + "forwardfor": { + "enabled": "enabled" + }, + "httpchk_params": { + "method": "GET", + "uri": "/check", + "version": "HTTP/1.1" + }, + "mode": "http", + "name": "test_backend" + } + }, + "backend_switching_rule": { + "description": "HAProxy backend switching rule configuration (corresponds to use_backend directive)", + "type": "object", + "title": "Backend Switching Rule", + "required": [ + "name" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Backend Name", + "x-dynamic-enum": { + "operation": "getBackends", + "property": "name" + }, + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "cond": "if", + "cond_test": "{ req_ssl_sni -i www.example.com }", + "index": 0, + "name": "test_backend" + } + }, + "backend_switching_rules": { + "description": "HAProxy backend switching rules array (corresponds to use_backend directives)", + "type": "array", + "title": "Backend Switching Rules Array", + "items": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + "backends": { + "description": "HAProxy backends array", + "type": "array", + "title": "Backends", + "items": { + "$ref": "#/definitions/backend" + } + }, + "balance": { + "type": "object", + "required": [ + "algorithm" + ], + "properties": { + "algorithm": { + "type": "string", + "enum": [ + "first", + "hash", + "hdr", + "leastconn", + "random", + "rdp-cookie", + "roundrobin", + "source", + "static-rr", + "uri", + "url_param" + ] + }, + "hash_expression": { + "type": "string", + "x-dependency": { + "algorithm": { + "value": "hash" + } + }, + "x-display-name": "Hash Expression" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "algorithm": { + "required": true, + "value": "hdr" + } + }, + "x-display-name": "Header Name" + }, + "hdr_use_domain_only": { + "type": "boolean", + "x-dependency": { + "algorithm": { + "value": "hdr" + } + }, + "x-display-name": "Header Use Domain Only" + }, + "random_draws": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "random" + } + }, + "x-display-name": "Random Draws", + "x-nullable": false + }, + "rdp_cookie_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "algorithm": { + "value": "rdp-cookie" + } + }, + "x-display-name": "Rdp Cookie Name" + }, + "uri_depth": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "uri" + } + }, + "x-display-name": "Uri Depth" + }, + "uri_len": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "uri" + } + }, + "x-display-name": "Uri Len" + }, + "uri_path_only": { + "type": "boolean", + "x-dependency": { + "algorithm": { + "value": "uri" + } + }, + "x-display-name": "Uri Path Only" + }, + "uri_whole": { + "type": "boolean", + "x-dependency": { + "algorithm": { + "value": "uri" + } + }, + "x-display-name": "Uri Whole" + }, + "url_param": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "algorithm": { + "required": true, + "value": "url_param" + } + }, + "x-display-name": "Url Param" + }, + "url_param_check_post": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "url_param" + } + }, + "x-display-name": "Url Param Check Post" + }, + "url_param_max_wait": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "url_param" + } + }, + "x-display-name": "Url Param Max Weight" + } + } + }, + "bind": { + "description": "HAProxy frontend bind configuration", + "title": "Bind", + "allOf": [ + { + "$ref": "#/definitions/bind_params" + }, + { + "type": "object", + "required": [ + "name" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "example": "127.0.0.1" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "example": 80 + }, + "port-range-end": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "example": 81 + } + }, + "additionalProperties": false + } + ] + }, + "bind_params": { + "type": "object", + "properties": { + "accept_netscaler_cip": { + "type": "integer" + }, + "accept_proxy": { + "type": "boolean" + }, + "allow_0rtt": { + "type": "boolean" + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "ALPN Protocols" + }, + "backlog": { + "type": "string" + }, + "ca_ignore_err": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "ca_sign_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "ca_sign_pass": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-display-name": "Passphrase" + }, + "ca_verify_file": { + "type": "string", + "x-dependency": { + "ca_file": { + "value": true + } + } + }, + "cc": { + "type": "string", + "x-display-name": "TCP Congestion Control Algorithm" + }, + "ciphers": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "ciphersuites": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "client_sigalgs": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "crl_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "crt_ignore_err": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "crt_list": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "curves": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "default_crt_list": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "x-omitempty": true + }, + "defer_accept": { + "type": "boolean" + }, + "ecdhe": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "expose_fd_listeners": { + "type": "boolean" + }, + "force_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_strict_sni": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "force_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_tlsv13": { + "description": "This field is deprecated in favor of tlsv13, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "generate_certificates": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "gid": { + "type": "integer", + "x-display-name": "Group ID" + }, + "group": { + "type": "string", + "x-display-name": "Group name" + }, + "guid_prefix": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "id": { + "type": "string", + "x-display-name": "Socket ID" + }, + "idle_ping": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "interface": { + "type": "string" + }, + "ktls": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-display-name": "Enables or disables ktls for those sockets. If enabled, kTLS will be used if the kernel supports it and the cipher is compatible.\nThis is only available on Linux kernel 4.17 and above.\nEXPERIMENTAL OPTION." + }, + "label": { + "type": "string" + }, + "level": { + "type": "string", + "enum": [ + "user", + "operator", + "admin" + ], + "example": "user" + }, + "maxconn": { + "type": "integer", + "example": 1234 + }, + "mode": { + "type": "string" + }, + "mss": { + "type": "string" + }, + "namespace": { + "type": "string", + "example": "app" + }, + "nbconn": { + "type": "integer", + "x-display-name": "Number of connection" + }, + "nice": { + "type": "integer", + "example": 1 + }, + "no_alpn": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "no_ca_names": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "no_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "no_strict_sni": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "no_tls_tickets": { + "description": "This field is deprecated in favor of tls_tickets, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "no_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "no_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "no_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "no_tlsv13": { + "description": "This field is deprecated in favor of tlsv13, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "npn": { + "type": "string" + }, + "prefer_client_ciphers": { + "type": "boolean" + }, + "proto": { + "type": "string", + "x-display-name": "Protocol name" + }, + "quic-cc-algo": { + "type": "string", + "enum": [ + "cubic", + "newreno", + "bbr", + "nocc" + ] + }, + "quic-force-retry": { + "type": "boolean" + }, + "quic-socket": { + "type": "string", + "enum": [ + "connection", + "listener" + ] + }, + "quic_cc_algo_burst_size": { + "type": "integer", + "maximum": 1024, + "x-dependency": { + "quic-cc-algo": null + }, + "x-nullable": true + }, + "quic_cc_algo_max_window": { + "type": "integer", + "maximum": 4194304, + "minimum": 10, + "x-default-unit": "k", + "x-dependency": { + "quic-cc-algo": null + }, + "x-nullable": true, + "x-size": true + }, + "severity_output": { + "type": "string", + "enum": [ + "none", + "number", + "string" + ], + "x-display-name": "Format", + "example": "none" + }, + "sigalgs": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "ssl": { + "type": "boolean" + }, + "ssl_cafile": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-display-name": "SSL CA File" + }, + "ssl_certificate": { + "description": "All of the certificates delimited by ':' as mentioned as a crt on the bind line.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "ssl_max_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_min_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "strict_sni": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + }, + "x-deprecated": true + }, + "tcp_md5sig": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "tcp_user_timeout": { + "type": "integer", + "x-nullable": true + }, + "tfo": { + "type": "boolean" + }, + "thread": { + "type": "string" + }, + "tls_ticket_keys": { + "type": "string" + }, + "tls_tickets": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "transparent": { + "type": "boolean" + }, + "uid": { + "type": "string" + }, + "user": { + "type": "string" + }, + "v4v6": { + "type": "boolean" + }, + "v6only": { + "type": "boolean" + }, + "verify": { + "type": "string", + "enum": [ + "none", + "optional", + "required" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + }, + "example": "none" + } + }, + "additionalProperties": false + }, + "binds": { + "description": "HAProxy frontend binds array (corresponds to bind directives)", + "type": "array", + "title": "Binds", + "items": { + "$ref": "#/definitions/bind" + } + }, + "cache": { + "description": "HAPRoxy Cache section", + "type": "object", + "title": "Cache", + "required": [ + "name" + ], + "properties": { + "max_age": { + "type": "integer", + "x-default-unit": "s", + "x-duration": false + }, + "max_object_size": { + "type": "integer", + "x-size": false + }, + "max_secondary_entries": { + "type": "integer" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "process_vary": { + "type": "boolean", + "x-nullable": true + }, + "total_max_size": { + "type": "integer", + "maximum": 4095, + "minimum": 1 + } + } + }, + "caches": { + "description": "HAProxy caches array", + "type": "array", + "title": "Cache Sections", + "items": { + "$ref": "#/definitions/cache" + } + }, + "capture": { + "type": "object", + "title": "Declare Capture", + "required": [ + "type", + "length" + ], + "properties": { + "length": { + "type": "integer", + "x-nullable": false + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "type": { + "type": "string", + "enum": [ + "request", + "response" + ], + "x-nullable": false + } + } + }, + "captures": { + "type": "array", + "title": "Declare capture array", + "items": { + "$ref": "#/definitions/capture" + } + }, + "cluster_settings": { + "description": "Settings related to a cluster.", + "type": "object", + "title": "Cluster Settings", + "properties": { + "bootstrap_key": { + "type": "string" + }, + "cluster": { + "type": "object", + "title": "Cluster controller information", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "readOnly": true + }, + "api_base_path": { + "type": "string", + "readOnly": true + }, + "cluster_id": { + "type": "string" + }, + "description": { + "type": "string", + "readOnly": true + }, + "log_targets": { + "type": "array", + "items": { + "type": "object", + "required": [ + "address", + "port", + "protocol" + ], + "properties": { + "address": { + "type": "string" + }, + "log_format": { + "type": "string" + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "protocol": { + "type": "string", + "enum": [ + "tcp", + "udp" + ] + } + }, + "x-go-name": "ClusterLogTarget" + }, + "x-go-name": "ClusterLogTargets", + "x-omitempty": true + }, + "name": { + "type": "string", + "readOnly": true + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "readOnly": true + } + } + }, + "mode": { + "type": "string", + "enum": [ + "single", + "cluster" + ] + }, + "status": { + "type": "string", + "enum": [ + "active", + "unreachable", + "waiting_approval" + ], + "readOnly": true + } + } + }, + "compression": { + "type": "object", + "properties": { + "algo-req": { + "type": "string", + "enum": [ + "identity", + "gzip", + "deflate", + "raw-deflate" + ], + "x-omitempty": true + }, + "algorithms": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "identity", + "gzip", + "deflate", + "raw-deflate" + ] + }, + "x-omitempty": true + }, + "algos-res": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "identity", + "gzip", + "deflate", + "raw-deflate" + ] + }, + "x-omitempty": true + }, + "direction": { + "type": "string", + "enum": [ + "request", + "response", + "both" + ], + "x-omitempty": true + }, + "minsize_req": { + "type": "integer", + "x-display-name": "Minimum Size for Requests", + "x-size": true + }, + "minsize_res": { + "type": "integer", + "x-display-name": "Minimum Size for Responses", + "x-size": true + }, + "offload": { + "type": "boolean" + }, + "types": { + "type": "array", + "items": { + "type": "string" + }, + "x-omitempty": true + }, + "types-req": { + "type": "array", + "items": { + "type": "string" + }, + "x-omitempty": true + }, + "types-res": { + "type": "array", + "items": { + "type": "string" + }, + "x-omitempty": true + } + } + }, + "config_stick_table": { + "type": "object", + "properties": { + "expire": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "keylen": { + "type": "integer", + "x-display-name": "Key Length", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "nopurge": { + "type": "boolean", + "x-display-name": "No Purge" + }, + "peers": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "recv_only": { + "type": "boolean", + "x-display-name": "Receive Only" + }, + "size": { + "type": "integer", + "x-nullable": true, + "x-size": true + }, + "srvkey": { + "type": "string", + "enum": [ + "addr", + "name" + ], + "x-nullable": true + }, + "store": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "type": { + "type": "string", + "enum": [ + "ip", + "ipv6", + "integer", + "string", + "binary" + ] + }, + "write_to": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true + } + } + }, + "consul": { + "description": "Consul server configuration", + "type": "object", + "title": "Consul server", + "required": [ + "address", + "port", + "enabled", + "retry_timeout" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "defaults": { + "description": "Name of the defaults section to be used in backends created by this service", + "type": "string" + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "health_check_policy": { + "description": "Defines the health check conditions required for each node to be considered valid for the service.\n none: all nodes are considered valid\n any: a node is considered valid if any one health check is 'passing'\n all: a node is considered valid if all health checks are 'passing'\n min: a node is considered valid if the number of 'passing' checks is greater or equal to the 'health_check_policy_min' value.\n If the node has less health checks configured then 'health_check_policy_min' it is considered invalid.", + "type": "string", + "default": "none", + "enum": [ + "none", + "any", + "all", + "min" + ] + }, + "health_check_policy_min": { + "type": "integer", + "x-dependency": { + "health_check_policy": { + "value": "min" + } + } + }, + "id": { + "description": "Auto generated ID.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true + }, + "mode": { + "type": "string", + "default": "http", + "enum": [ + "http", + "https" + ] + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "retry_timeout": { + "description": "Duration in seconds in-between data pulling requests to the consul server", + "type": "integer", + "minimum": 1 + }, + "server_slots_base": { + "type": "integer", + "default": 10 + }, + "server_slots_growth_increment": { + "type": "integer" + }, + "server_slots_growth_type": { + "type": "string", + "default": "exponential", + "enum": [ + "linear", + "exponential" + ] + }, + "service_allowlist": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "x-omitempty": true + }, + "service_denylist": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "x-omitempty": true + }, + "service_name_regexp": { + "description": "Regular expression used to filter services by name.", + "type": "string" + }, + "token": { + "type": "string", + "pattern": "^[^\\s]+$" + } + }, + "additionalProperties": false, + "example": { + "address": "127.0.0.1", + "enabled": true, + "id": "0", + "port": 90, + "retry_timeout": 10 + } + }, + "consuls": { + "description": "Consuls array", + "type": "array", + "title": "Consuls", + "items": { + "$ref": "#/definitions/consul" + } + }, + "cookie": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "attr": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string", + "pattern": "^[^\\s]+$" + } + }, + "x-go-name": "Attr" + }, + "x-go-name": "Attrs", + "x-omitempty": true + }, + "domain": { + "type": "array", + "items": { + "type": "object", + "properties": { + "value": { + "type": "string", + "pattern": "^[^\\s]+$" + } + }, + "x-go-name": "Domain" + }, + "x-go-name": "Domains", + "x-omitempty": true + }, + "dynamic": { + "type": "boolean" + }, + "httponly": { + "type": "boolean" + }, + "indirect": { + "type": "boolean" + }, + "maxidle": { + "type": "integer" + }, + "maxlife": { + "type": "integer" + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "nocache": { + "type": "boolean" + }, "postonly": { "type": "boolean" }, - "preserve": { - "type": "boolean" + "preserve": { + "type": "boolean" + }, + "secure": { + "type": "boolean" + }, + "type": { + "type": "string", + "enum": [ + "rewrite", + "insert", + "prefix" + ] + } + } + }, + "crt_load": { + "description": "Loads a certificate from a store with options", + "type": "object", + "title": "Certificate load action", + "required": [ + "certificate" + ], + "properties": { + "acme": { + "description": "ACME section name to use", + "type": "string" + }, + "alias": { + "description": "Certificate alias", + "type": "string" + }, + "certificate": { + "description": "Certificate filename", + "type": "string", + "x-nullable": false + }, + "domains": { + "description": "List of domains used to generate the certificate with ACME", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Domains", + "x-omitempty": true + }, + "issuer": { + "description": "OCSP issuer filename", + "type": "string" + }, + "key": { + "description": "Private key filename", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "ocsp": { + "description": "OCSP response filename", + "type": "string" + }, + "ocsp_update": { + "description": "Automatic OCSP response update", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "sctl": { + "description": "Signed Certificate Timestamp List filename", + "type": "string" + } + } + }, + "crt_loads": { + "description": "List of certificates to load from a Certificate Store", + "type": "array", + "items": { + "$ref": "#/definitions/crt_load" + }, + "x-omitempty": true + }, + "crt_store": { + "description": "Storage mechanism to load and store certificates used in the configuration", + "type": "object", + "title": "Certificate Store", + "required": [ + "name" + ], + "properties": { + "crt_base": { + "description": "Default directory to fetch SSL certificates from", + "type": "string" + }, + "key_base": { + "description": "Default directory to fetch SSL private keys from", + "type": "string" + }, + "loads": { + "$ref": "#/definitions/crt_loads" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false + } + }, + "additionalProperties": false + }, + "crt_stores": { + "description": "List of Certificate Stores", + "type": "array", + "items": { + "$ref": "#/definitions/crt_store" + } + }, + "debug_options": { + "type": "object", + "properties": { + "anonkey": { + "type": "integer", + "maximum": 4294967295, + "x-nullable": true + }, + "quiet": { + "type": "boolean" + }, + "stress_level": { + "type": "integer", + "maximum": 9, + "x-nullable": true + }, + "zero_warning": { + "type": "boolean" + } + } + }, + "default_bind": { + "description": "HAProxy default bind configuration", + "title": "Default Bind", + "allOf": [ + { + "$ref": "#/definitions/bind_params" + }, + { + "type": "object", + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + } + } + } + ] + }, + "default_server": { + "title": "Default Server", + "allOf": [ + { + "$ref": "#/definitions/server_params" + } + ] + }, + "defaults": { + "description": "Defaults with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/defaults_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" + }, + "http_after_response_rule_list": { + "x-go-name": "HTTPAfterResponseRuleList", + "$ref": "#/definitions/http_after_response_rules" + }, + "http_check_list": { + "x-go-name": "HTTPCheckList", + "$ref": "#/definitions/http_checks" + }, + "http_error_rule_list": { + "x-go-name": "HTTPErrorRuleList", + "$ref": "#/definitions/http_error_rules" + }, + "http_request_rule_list": { + "x-go-name": "HTTPRequestRuleList", + "$ref": "#/definitions/http_request_rules" + }, + "http_response_rule_list": { + "x-go-name": "HTTPResponseRuleList", + "$ref": "#/definitions/http_response_rules" + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + }, + "quic_initial_rule_list": { + "x-go-name": "QUICInitialRuleList", + "$ref": "#/definitions/quic_initial_rules" + }, + "tcp_check_rule_list": { + "x-go-name": "TCPCheckRuleList", + "$ref": "#/definitions/tcp_checks" + }, + "tcp_request_rule_list": { + "x-go-name": "TCPRequestRuleList", + "$ref": "#/definitions/tcp_request_rules" + }, + "tcp_response_rule_list": { + "x-go-name": "TCPResponseRuleList", + "$ref": "#/definitions/tcp_response_rules" + } + } + } + ], + "x-go-name": "Defaults" + }, + "defaults_base": { + "description": "HAProxy defaults configuration", + "type": "object", + "title": "Defaults Base", + "required": [ + "name" + ], + "properties": { + "abortonclose": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "accept_invalid_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Request" + }, + "accept_invalid_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Response" + }, + "accept_unsafe_violations_in_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Request" + }, + "accept_unsafe_violations_in_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Response" + }, + "adv_check": { + "type": "string", + "enum": [ + "httpchk", + "ldap-check", + "mysql-check", + "pgsql-check", + "redis-check", + "smtpchk", + "ssl-hello-chk", + "tcp-check" + ], + "x-display-name": "Advanced Check" + }, + "allbackups": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "All Backups" + }, + "backlog": { + "type": "integer", + "x-display-name": "Backlog", + "x-nullable": true + }, + "balance": { + "$ref": "#/definitions/balance" + }, + "check_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "checkcache": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Checkcache" + }, + "clflog": { + "type": "boolean", + "x-display-name": "CLF Log" + }, + "client_fin_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "client_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "clitcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Client TCP Keep Alive" + }, + "clitcpka_cnt": { + "type": "integer", + "x-display-name": "Clitcpka Cnt", + "x-nullable": true + }, + "clitcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "clitcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "compression": { + "$ref": "#/definitions/compression" + }, + "connect_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "contstats": { + "type": "string", + "enum": [ + "enabled" + ], + "x-display-name": "Continuous Statistics" + }, + "cookie": { + "$ref": "#/definitions/cookie" + }, + "default_backend": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-dynamic-enum": { + "operation": "getBackends", + "property": "name" + } + }, + "default_server": { + "$ref": "#/definitions/default_server" + }, + "disable_h2_upgrade": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Disable HTTP/2 Upgrade" + }, + "disabled": { + "type": "boolean" + }, + "dontlog_normal": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Dontlog Normal" + }, + "dontlognull": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Don't Log Null" + }, + "dynamic_cookie_key": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "email_alert": { + "$ref": "#/definitions/email_alert" + }, + "enabled": { + "type": "boolean" + }, + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" + }, + "x-go-name": "ErrorFiles", + "x-omitempty": true + }, + "error_log_format": { + "type": "string" + }, + "errorfiles_from_http_errors": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfiles" + }, + "x-go-name": "ErrorFilesFromHTTPErrors", + "x-omitempty": true + }, + "errorloc302": { + "$ref": "#/definitions/errorloc" + }, + "errorloc303": { + "$ref": "#/definitions/errorloc" + }, + "external_check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "External Check" + }, + "external_check_command": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Command" + }, + "external_check_path": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Path" + }, + "forwardfor": { + "$ref": "#/definitions/forwardfor" + }, + "from": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "fullconn": { + "type": "integer", + "x-nullable": true + }, + "h1_case_adjust_bogus_client": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "H1 Adjust Bogus Client" + }, + "h1_case_adjust_bogus_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "H1 Adjust Bogus Server" + }, + "hash_balance_factor": { + "type": "integer", + "x-nullable": true + }, + "hash_preserve_affinity": { + "type": "string", + "enum": [ + "always", + "maxconn", + "maxqueue" + ] + }, + "hash_type": { + "$ref": "#/definitions/hash_type" + }, + "http-buffer-request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP bufferrequest" + }, + "http-drop-request-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Request Trailers" + }, + "http-drop-response-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Response Trailers" + }, + "http-use-htx": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Use HTX" + }, + "http_connection_mode": { + "type": "string", + "enum": [ + "httpclose", + "http-server-close", + "http-keep-alive" + ] + }, + "http_ignore_probes": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Ignore Probes" + }, + "http_keep_alive_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "http_no_delay": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP No Delay" + }, + "http_pretend_keepalive": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "http_request_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "http_restrict_req_hdr_names": { + "type": "string", + "enum": [ + "preserve", + "delete", + "reject" + ], + "x-display-name": "Restrict HTTP Request Header Names" + }, + "http_reuse": { + "type": "string", + "enum": [ + "aggressive", + "always", + "never", + "safe" + ] + }, + "http_send_name_header": { + "type": "string", + "x-display-name": "Add the server name to a request", + "x-nullable": true + }, + "http_use_proxy_header": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Use Proxy Header" + }, + "httpchk_params": { + "x-dependency": { + "adv_check": { + "value": "httpchk" + } + }, + "$ref": "#/definitions/httpchk_params" + }, + "httplog": { + "type": "boolean", + "x-display-name": "HTTP Log" + }, + "httpslog": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Httpslog" + }, + "idle_close_on_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Idle Close On Response" + }, + "independent_streams": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Independent Streams" + }, + "load_server_state_from_file": { + "type": "string", + "enum": [ + "global", + "local", + "none" + ] + }, + "log_format": { + "type": "string" + }, + "log_format_sd": { + "type": "string", + "x-display-name": "Log Format SD" + }, + "log_health_checks": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log Health Checks" + }, + "log_separate_errors": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "log_steps": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "accept", + "request", + "connect", + "response", + "close", + "error", + "any" + ] + }, + "x-go-name": "LogSteps", + "x-omitempty": true + }, + "log_tag": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "logasap": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log ASAP" + }, + "max_keep_alive_queue": { + "type": "integer", + "x-display-name": "Maximum server queue size for maintaining keep-alive connections", + "x-nullable": true + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "mode": { + "type": "string", + "enum": [ + "tcp", + "http", + "log" + ] + }, + "monitor_uri": { + "$ref": "#/definitions/monitor_uri" + }, + "mysql_check_params": { + "x-dependency": { + "adv_check": { + "value": "mysql-check" + } + }, + "$ref": "#/definitions/mysql_check_params" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "nolinger": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Nolinger" + }, + "originalto": { + "$ref": "#/definitions/originalto" + }, + "persist": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Persist" + }, + "persist_rule": { + "$ref": "#/definitions/persist_rule" + }, + "pgsql_check_params": { + "x-dependency": { + "adv_check": { + "value": "pgsql-check" + } + }, + "$ref": "#/definitions/pgsql_check_params" + }, + "prefer_last_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Prefer Last Server" + }, + "queue_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "redispatch": { + "$ref": "#/definitions/redispatch" + }, + "retries": { + "type": "integer", + "x-nullable": true + }, + "retry_on": { + "type": "string", + "x-display-name": "Specify when to attempt to automatically retry a failed request" + }, + "server_fin_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "server_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "smtpchk_params": { + "x-dependency": { + "adv_check": { + "value": "smtpchk" + } + }, + "$ref": "#/definitions/smtpchk_params" + }, + "socket_stats": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Socket Stats" + }, + "source": { + "$ref": "#/definitions/source" + }, + "splice_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Auto" + }, + "splice_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Request" + }, + "splice_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Response" + }, + "srvtcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Server TCP Keep Alive" + }, + "srvtcpka_cnt": { + "type": "integer", + "x-display-name": "Srvtcpka Cnt", + "x-nullable": true + }, + "srvtcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "srvtcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "stats_options": { + "$ref": "#/definitions/stats_options" + }, + "tarpit_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "tcp_smart_accept": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Accept" + }, + "tcp_smart_connect": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Connect" + }, + "tcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "TCP Keep Alive" + }, + "tcplog": { + "type": "boolean", + "x-display-name": "TCP Log" + }, + "transparent": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Transparent" + }, + "tunnel_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "unique_id_format": { + "type": "string", + "x-display-name": "Unique ID format" + }, + "unique_id_header": { + "type": "string", + "x-display-name": "Unique ID header" + } + }, + "additionalProperties": false + }, + "defaults_sections": { + "description": "HAProxy defaults sections array", + "type": "array", + "title": "Defaults Sections", + "items": { + "$ref": "#/definitions/defaults" + } + }, + "device_atlas_options": { + "type": "object", + "properties": { + "json_file": { + "type": "string", + "x-display-name": "JSON file" + }, + "log_level": { + "type": "string", + "x-display-name": "Log Level" + }, + "properties_cookie": { + "type": "string", + "x-display-name": "Properties Cookie" + }, + "separator": { + "type": "string", + "x-display-name": "Separator" + } + } + }, + "dgram_bind": { + "description": "HAProxy log forward dgram bind configuration", + "type": "object", + "title": "Dgram Bind", + "required": [ + "name" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "interface": { + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "namespace": { + "type": "string" + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "port-range-end": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "transparent": { + "type": "boolean" + } + } + }, + "dgram_binds": { + "description": "HAProxy dgram bind array", + "type": "array", + "title": "Dgram Bind", + "items": { + "$ref": "#/definitions/dgram_bind" + } + }, + "email_alert": { + "description": "Send emails for important log messages.", + "type": "object", + "title": "Email Alert", + "required": [ + "from", + "mailers", + "to" + ], + "properties": { + "from": { + "type": "string", + "pattern": "^\\S+@\\S+$" + }, + "level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug" + ] + }, + "mailers": { + "type": "string", + "x-dynamic-enum": { + "operation": "getMailersSections", + "property": "name" + } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "myhostname": { + "type": "string" + }, + "to": { + "type": "string", + "pattern": "^\\S+@\\S+$" + } + } + }, + "email_alerts": { + "description": "Email Alerts array (corresponds to email-alert directives)", + "type": "array", + "title": "Email Alerts Array", + "items": { + "$ref": "#/definitions/email_alert" + } + }, + "endpoint": { + "description": "Endpoint definition", + "type": "object", + "title": "Endpoint", + "properties": { + "description": { + "description": "Endpoint description", + "type": "string" + }, + "title": { + "description": "Endpoint title", + "type": "string" + }, + "url": { + "description": "Path to the endpoint", + "type": "string" + } + } + }, + "endpoints": { + "description": "Collection of endpoints", + "type": "array", + "title": "Endpoints Array", + "items": { + "$ref": "#/definitions/endpoint" + } + }, + "environment_options": { + "type": "object", + "properties": { + "presetenv": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string", + "x-display-name": "Name" + }, + "value": { + "type": "string", + "x-display-name": "Value" + } + }, + "x-go-name": "PresetEnv" + }, + "x-display-name": "Preset environment variables", + "x-go-name": "PresetEnvs", + "x-omitempty": true + }, + "resetenv": { + "type": "string", + "x-display-name": "Remove all environment variables except the ones specified" + }, + "setenv": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string", + "x-display-name": "Name" + }, + "value": { + "type": "string", + "x-display-name": "Value" + } + }, + "x-go-name": "SetEnv" + }, + "x-display-name": "Set environment variables", + "x-go-name": "SetEnvs", + "x-omitempty": true + }, + "unsetenv": { + "type": "string", + "x-display-name": "Removes environment variables specified in arguments" + } + } + }, + "error": { + "description": "API Error", + "type": "object", + "title": "Error", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "x-nullable": true + }, + "message": { + "type": "string", + "x-nullable": true + } + }, + "additionalProperties": { + "type": "string" + } + }, + "errorfile": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "enum": [ + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ] + }, + "file": { + "type": "string" + } + }, + "x-display-name": "Error File" + }, + "errorfiles": { + "type": "object", + "properties": { + "codes": { + "type": "array", + "items": { + "type": "integer", + "enum": [ + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ] + }, + "x-omitempty": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string" + } + } + }, + "errorloc": { + "type": "object", + "required": [ + "url", + "code" + ], + "properties": { + "code": { + "type": "integer", + "enum": [ + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ] + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "url": { + "type": "string" + } + } + }, + "fcgi_app": { + "description": "App with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/fcgi_app_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" + } + } + } + ], + "x-go-name": "FCGIApp" + }, + "fcgi_app_base": { + "description": "HAProxy FastCGI application configuration", + "type": "object", + "title": "FCGI application base", + "required": [ + "name", + "docroot" + ], + "properties": { + "docroot": { + "description": "Defines the document root on the remote host. The parameter serves to build the default value of FastCGI parameters SCRIPT_FILENAME and PATH_TRANSLATED. It is a mandatory setting.", + "type": "string" + }, + "get_values": { + "description": "Enables or disables the retrieval of variables related to connection management.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "index": { + "description": "Defines the script name to append after a URI that ends with a slash (\"/\") to set the default value for the FastCGI parameter SCRIPT_NAME. It is an optional setting.", + "type": "string" + }, + "keep_conn": { + "description": "Tells the FastCGI application whether or not to keep the connection open after it sends a response. If disabled, the FastCGI application closes the connection after responding to this request.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "log_stderrs": { + "type": "array", + "items": { + "x-go-name": "FCGIAppLogStderr", + "$ref": "#/definitions/fcgi_log_stderr" + }, + "x-omitempty": true + }, + "max_reqs": { + "description": "Defines the maximum number of concurrent requests this application can accept. If the FastCGI application retrieves the variable FCGI_MAX_REQS during connection establishment, it can override this option. Furthermore, if the application does not do multiplexing, it will ignore this option.", + "type": "integer", + "default": 1, + "minimum": 1 + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "mpxs_conns": { + "description": "Enables or disables the support of connection multiplexing. If the FastCGI application retrieves the variable FCGI_MPXS_CONNS during connection establishment, it can override this option.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "name": { + "description": "Declares a FastCGI application", + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "pass_headers": { + "type": "array", + "items": { + "x-go-name": "FCGIAppLogPassHeader", + "$ref": "#/definitions/fcgi_pass_header" + }, + "x-omitempty": true + }, + "path_info": { + "description": "Defines a regular expression to extract the script-name and the path-info from the URI.\nThus, \u003cregex\u003e must have two captures: the first to capture the script name, and the second to capture the path- info.\nIf not defined, it does not perform matching on the URI, and does not fill the FastCGI parameters PATH_INFO and PATH_TRANSLATED.", + "type": "string" + }, + "set_params": { + "type": "array", + "items": { + "$ref": "#/definitions/fcgi_set_param" + }, + "x-omitempty": true + } + } + }, + "fcgi_apps": { + "type": "array", + "items": { + "$ref": "#/definitions/fcgi_app" + } + }, + "fcgi_log_stderr": { + "description": "Enables logging of STDERR messages that the FastCGI application reports.\nIt is an optional setting. By default, HAProxy Enterprise ignores STDERR messages.", + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "facility": { + "type": "string", + "title": "Facility" + }, + "format": { + "type": "string", + "title": "Format" + }, + "global": { + "type": "boolean", + "title": "Global" + }, + "len": { + "type": "integer", + "title": "Length" + }, + "level": { + "type": "string", + "title": "Level", + "x-dependency": { + "facility": { + "required": true + } + } + }, + "minlevel": { + "type": "string", + "title": "Minimum level", + "x-dependency": { + "facility": { + "required": true + } + } + }, + "sample": { + "type": "object", + "title": "Sample", + "required": [ + "ranges", + "size" + ], + "properties": { + "ranges": { + "type": "string", + "title": "Range" + }, + "size": { + "type": "integer", + "title": "Size" + } + } + } + } + }, + "fcgi_pass_header": { + "description": "Specifies the name of a request header to pass to the FastCGI application.\nOptionally, you can follow it with an ACL-based condition, in which case the FastCGI application evaluates it only if the condition is true.\nMost request headers are already available to the FastCGI application with the prefix \"HTTP\".\nThus, you only need this directive to pass headers that are purposefully omitted.\nCurrently, the headers \"Authorization\", \"Proxy-Authorization\", and hop-by-hop headers are omitted.\nNote that the headers \"Content-type\" and \"Content-length\" never pass to the FastCGI application because they are already converted into parameters.", + "type": "object", + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + }, + "name": { + "type": "string" + } + } + }, + "fcgi_set_param": { + "description": "Sets a FastCGI parameter to pass to this application.\nIts value, defined by \u003cformat\u003e can take a formatted string, the same as the log directive.\nOptionally, you can follow it with an ACL-based condition, in which case the FastCGI application evaluates it only if the condition is true.", + "type": "object", + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + }, + "format": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "fifty_one_degrees_options": { + "type": "object", + "properties": { + "cache_size": { + "type": "integer", + "x-display-name": "Cache Size" + }, + "data_file": { + "type": "string", + "x-display-name": "Data File" + }, + "property_name_list": { + "type": "string", + "x-display-name": "Name List" + }, + "property_separator": { + "type": "string", + "x-display-name": "Property Separator" + } + } + }, + "filter": { + "description": "HAProxy filters", + "type": "object", + "title": "Filter", + "required": [ + "type" + ], + "properties": { + "app_name": { + "description": "Name of the fcgi-app section this filter will use.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "fcgi-app" + } + } + }, + "bandwidth_limit_name": { + "description": "Filter name that will be used by 'set-bandwidth-limit' actions to reference a specific bandwidth limitation filter", + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + } + }, + "cache_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "cache" + } + } + }, + "default_limit": { + "description": "The max number of bytes that can be forwarded over the period.\nThe value must be specified for per-stream and shared bandwidth limitation filters.\nIt follows the HAProxy size format and is expressed in bytes.", + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + }, + "x-size": true + }, + "default_period": { + "description": "The default time period used to evaluate the bandwidth limitation rate.\nIt can be specified for per-stream bandwidth limitation filters only.\nIt follows the HAProxy time format and is expressed in milliseconds.", + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "default_limit": { + "required": true + }, + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + }, + "x-duration": true + }, + "key": { + "description": "A sample expression rule.\nIt describes what elements will be analyzed, extracted, combined, and used to select which table entry to update the counters.\nIt must be specified for shared bandwidth limitation filters only.", + "type": "string", + "x-dependency": { + "limit": { + "required": true + }, + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + } + }, + "limit": { + "description": "The max number of bytes that can be forwarded over the period.\nThe value must be specified for per-stream and shared bandwidth limitation filters.\nIt follows the HAProxy size format and is expressed in bytes.", + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + }, + "x-size": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "min_size": { + "description": "The optional minimum number of bytes forwarded at a time by a stream excluding the last packet that may be smaller.\nThis value can be specified for per-stream and shared bandwidth limitation filters.\nIt follows the HAProxy size format and is expressed in bytes.", + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + }, + "x-size": true + }, + "spoe_config": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "spoe" + } + } + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "spoe" + } + } + }, + "table": { + "description": "An optional table to be used instead of the default one, which is the stick-table declared in the current proxy.\nIt can be specified for shared bandwidth limitation filters only.", + "type": "string", + "x-dependency": { + "limit": { + "required": true + }, + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + } + }, + "trace_hexdump": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "trace" + } + } + }, + "trace_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "trace" + } + } + }, + "trace_rnd_forwarding": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "trace" + } + }, + "x-display-name": "Trace Random Forwarding" + }, + "trace_rnd_parsing": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "trace" + } + }, + "x-display-name": "Trace Random Parsing" + }, + "type": { + "type": "string", + "enum": [ + "bwlim-in", + "bwlim-out", + "cache", + "compression", + "fcgi-app", + "spoe", + "trace" + ], + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "trace_name": "name", + "trace_rnd_parsing": true, + "type": "trace" + } + }, + "filters": { + "description": "HAProxy filters array (corresponds to filter directive)", + "type": "array", + "title": "Filters Array", + "items": { + "$ref": "#/definitions/filter" + } + }, + "forwardfor": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled" + ] + }, + "except": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "header": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "ifnone": { + "type": "boolean" + } + }, + "x-display-name": "ForwardFor" + }, + "frontend": { + "description": "Frontend with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/frontend_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" + }, + "backend_switching_rule_list": { + "x-go-name": "BackendSwitchingRuleList", + "$ref": "#/definitions/backend_switching_rules" + }, + "binds": { + "additionalProperties": { + "$ref": "#/definitions/bind" + } + }, + "capture_list": { + "x-go-name": "CaptureList", + "$ref": "#/definitions/captures" + }, + "filter_list": { + "x-go-name": "FilterList", + "$ref": "#/definitions/filters" + }, + "http_after_response_rule_list": { + "x-go-name": "HTTPAfterResponseRuleList", + "$ref": "#/definitions/http_after_response_rules" + }, + "http_error_rule_list": { + "x-go-name": "HTTPErrorRuleList", + "$ref": "#/definitions/http_error_rules" + }, + "http_request_rule_list": { + "x-go-name": "HTTPRequestRuleList", + "$ref": "#/definitions/http_request_rules" + }, + "http_response_rule_list": { + "x-go-name": "HTTPResponseRuleList", + "$ref": "#/definitions/http_response_rules" + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + }, + "quic_initial_rule_list": { + "x-go-name": "QUICInitialRuleList", + "$ref": "#/definitions/quic_initial_rules" + }, + "ssl_front_use_list": { + "x-go-name": "SSLFrontUses", + "$ref": "#/definitions/ssl_front_uses" + }, + "tcp_request_rule_list": { + "x-go-name": "TCPRequestRuleList", + "$ref": "#/definitions/tcp_request_rules" + } + } + } + ], + "x-go-name": "Frontend" + }, + "frontend_base": { + "description": "HAProxy frontend configuration", + "type": "object", + "title": "Frontend Base", + "required": [ + "name" + ], + "properties": { + "abortonclose": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "accept_invalid_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Request" + }, + "accept_unsafe_violations_in_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Request" + }, + "backlog": { + "type": "integer", + "x-display-name": "Backlog", + "x-nullable": true + }, + "clflog": { + "type": "boolean", + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "CLF Log" + }, + "client_fin_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "client_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "clitcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" + } + }, + "x-display-name": "Client TCP Keep Alive" + }, + "clitcpka_cnt": { + "type": "integer", + "x-display-name": "Clitcpka Cnt", + "x-nullable": true + }, + "clitcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "clitcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "compression": { + "$ref": "#/definitions/compression" + }, + "contstats": { + "type": "string", + "enum": [ + "enabled" + ], + "x-display-name": "Continuous Statistics" + }, + "default_backend": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-dynamic-enum": { + "operation": "getBackends", + "property": "name" + } + }, + "description": { + "type": "string", + "x-display-name": "Description" + }, + "disable_h2_upgrade": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Disable HTTP/2 Upgrade" + }, + "disabled": { + "type": "boolean" + }, + "dontlog_normal": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "dontlognull": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Don't Log Null" + }, + "email_alert": { + "$ref": "#/definitions/email_alert" + }, + "enabled": { + "type": "boolean" + }, + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" + }, + "x-go-name": "ErrorFiles", + "x-omitempty": true + }, + "error_log_format": { + "type": "string" + }, + "errorfiles_from_http_errors": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfiles" + }, + "x-go-name": "ErrorFilesFromHTTPErrors", + "x-omitempty": true + }, + "errorloc302": { + "$ref": "#/definitions/errorloc" + }, + "errorloc303": { + "$ref": "#/definitions/errorloc" + }, + "forwardfor": { + "x-dependency": { + "mode": { + "value": "http" + } + }, + "$ref": "#/definitions/forwardfor" + }, + "from": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "guid": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "h1_case_adjust_bogus_client": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "H1 Adjust Bogus Client" + }, + "http-buffer-request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP bufferrequest" + }, + "http-drop-response-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Response Trailers" + }, + "http-use-htx": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "HTTP Use HTX" + }, + "http_connection_mode": { + "type": "string", + "enum": [ + "httpclose", + "http-server-close", + "http-keep-alive" + ], + "x-dependency": { + "mode": { + "value": "http" + } + } + }, + "http_ignore_probes": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Ignore Probes" + }, + "http_keep_alive_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-duration": true, + "x-nullable": true + }, + "http_no_delay": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP No Delay" + }, + "http_request_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-duration": true, + "x-nullable": true + }, + "http_restrict_req_hdr_names": { + "type": "string", + "enum": [ + "preserve", + "delete", + "reject" + ], + "x-display-name": "Restrict HTTP Request Header Names" + }, + "http_use_proxy_header": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Use Proxy Header" + }, + "httplog": { + "type": "boolean", + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "HTTP Log" + }, + "httpslog": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Httpslog" + }, + "id": { + "type": "integer", + "x-nullable": true + }, + "idle_close_on_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Idle Close On Response" + }, + "independent_streams": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Independent Streams" + }, + "log_format": { + "type": "string" + }, + "log_format_sd": { + "type": "string", + "x-display-name": "Log Format SD" + }, + "log_separate_errors": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "log_steps": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "accept", + "request", + "connect", + "response", + "close", + "error", + "any" + ] + }, + "x-go-name": "LogSteps", + "x-omitempty": true + }, + "log_tag": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "logasap": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log ASAP" + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp" + ] + }, + "monitor_fail": { + "$ref": "#/definitions/monitor_fail" + }, + "monitor_uri": { + "$ref": "#/definitions/monitor_uri" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "nolinger": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Nolinger" + }, + "originalto": { + "$ref": "#/definitions/originalto" + }, + "socket_stats": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Socket Stats" + }, + "splice_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Auto" + }, + "splice_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Request" + }, + "splice_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Response" + }, + "stats_options": { + "$ref": "#/definitions/stats_options" + }, + "stick_table": { + "$ref": "#/definitions/config_stick_table" + }, + "tarpit_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "tcp_smart_accept": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Accept" + }, + "tcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" + } + }, + "x-display-name": "TCP Keep Alive" + }, + "tcplog": { + "type": "boolean", + "x-dependency": { + "mode": { + "value": "tcp" + } + }, + "x-display-name": "TCP Log" + }, + "unique_id_format": { + "type": "string", + "x-display-name": "Unique ID format" + }, + "unique_id_header": { + "type": "string", + "x-display-name": "Unique ID header" + } + }, + "additionalProperties": false, + "example": { + "default_backend": "test_backend", + "http_connection_mode": "http-keep-alive", + "maxconn": 2000, + "mode": "http", + "name": "test_frontend" + } + }, + "frontends": { + "description": "HAProxy frontends array", + "type": "array", + "title": "Frontends", + "items": { + "$ref": "#/definitions/frontend" + } + }, + "general_file": { + "description": "General use file", + "type": "object", + "title": "General use file", + "properties": { + "description": { + "type": "string" + }, + "file": { + "type": "string" + }, + "id": { + "type": "string" + }, + "size": { + "description": "File size in bytes.", + "type": "integer", + "x-nullable": true + }, + "storage_name": { + "type": "string" + } + } + }, + "general_files": { + "description": "Array of general use files", + "type": "array", + "title": "General Files Array", + "items": { + "$ref": "#/definitions/general_file" + } + }, + "global": { + "description": "Frontend with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/global_base" + }, + { + "type": "object", + "properties": { + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + } + } + } + ], + "x-go-name": "Global" + }, + "global_base": { + "description": "HAProxy global configuration", + "type": "object", + "title": "Global Base", + "properties": { + "chroot": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Chroot" + }, + "close_spread_time": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "cluster_secret": { + "type": "string", + "x-display-name": "Cluster Secret" + }, + "cpu_maps": { + "type": "array", + "items": { + "type": "object", + "required": [ + "process", + "cpu_set" + ], + "properties": { + "cpu_set": { + "type": "string", + "x-display-name": "CPU Set" + }, + "process": { + "type": "string", + "x-display-name": "Process/Thread Set" + } + }, + "x-go-name": "CPUMap" + }, + "x-display-name": "CPU Maps", + "x-go-name": "CPUMaps", + "x-omitempty": true + }, + "cpu_policy": { + "type": "string", + "enum": [ + "none", + "efficiency", + "first-usable-node", + "group-by-2-ccx", + "group-by-2-clusters", + "group-by-3-ccx", + "group-by-3-clusters", + "group-by-4-ccx", + "group-by-4-cluster", + "group-by-ccx", + "group-by-cluster", + "performance", + "resource" + ], + "x-display-name": "CPU Policy" + }, + "cpu_set": { + "type": "array", + "items": { + "type": "object", + "required": [ + "directive" + ], + "properties": { + "directive": { + "type": "string", + "enum": [ + "reset", + "drop-cpu", + "only-cpu", + "drop-node", + "only-node", + "drop-cluster", + "only-cluster", + "drop-core", + "only-core", + "drop-thread", + "only-thread" + ] + }, + "set": { + "type": "string" + } + }, + "x-go-name": "CPUSet" + }, + "x-display-name": "CPU Set", + "x-go-name": "CPUSets", + "x-omitempty": true + }, + "daemon": { + "type": "boolean" + }, + "debug_options": { + "$ref": "#/definitions/debug_options" + }, + "default_path": { + "type": "object", + "required": [ + "type" + ], + "properties": { + "path": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "origin" + } + } + }, + "type": { + "type": "string", + "enum": [ + "current", + "config", + "parent", + "origin" + ], + "x-nullable": false + } + }, + "x-go-name": "GlobalDefaultPath" + }, + "description": { + "type": "string", + "x-display-name": "Text that describes the instance" + }, + "device_atlas_options": { + "$ref": "#/definitions/device_atlas_options" + }, + "dns_accept_family": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "DNS accept family" + }, + "environment_options": { + "$ref": "#/definitions/environment_options" + }, + "expose_deprecated_directives": { + "type": "boolean" + }, + "expose_experimental_directives": { + "type": "boolean" + }, + "external_check": { + "type": "boolean", + "x-display-name": "External Check" + }, + "fifty_one_degrees_options": { + "$ref": "#/definitions/fifty_one_degrees_options" + }, + "force_cfg_parser_pause": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Pause the configuration parser to simulate long reloads", + "x-duration": true, + "x-nullable": true + }, + "gid": { + "type": "integer", + "x-display-name": "GID" + }, + "grace": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Defines a delay between SIGUSR1 and real soft-stop", + "x-duration": true, + "x-nullable": true + }, + "group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Group" + }, + "h1_accept_payload_with_any_method": { + "type": "boolean" + }, + "h1_case_adjust": { + "type": "array", + "items": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" + }, + "to": { + "type": "string" + } + }, + "x-go-name": "H1CaseAdjust" + }, + "x-go-name": "H1CaseAdjusts", + "x-omitempty": true + }, + "h1_case_adjust_file": { + "type": "string" + }, + "h1_do_not_close_on_insecure_transfer_encoding": { + "type": "boolean" + }, + "h2_workaround_bogus_websocket_clients": { + "type": "boolean" + }, + "hard_stop_after": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Hard Stop After", + "x-duration": true, + "x-nullable": true + }, + "harden": { + "type": "object", + "properties": { + "reject_privileged_ports": { + "type": "object", + "properties": { + "quic": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tcp": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + } + }, + "x-go-name": "GlobalHardenRejectPrivilegedPorts" + } + }, + "x-go-name": "GlobalHarden" + }, + "http_client_options": { + "$ref": "#/definitions/http_client_options" + }, + "http_err_codes": { + "type": "array", + "items": { + "$ref": "#/definitions/http_codes" + }, + "x-display-name": "Replace, reduce or extend the list of status codes that define an error", + "x-omitempty": true + }, + "http_fail_codes": { + "type": "array", + "items": { + "$ref": "#/definitions/http_codes" + }, + "x-display-name": "Replace, reduce or extend the list of status codes that define a failure", + "x-omitempty": true + }, + "insecure_fork_wanted": { + "type": "boolean" + }, + "insecure_setuid_wanted": { + "type": "boolean" + }, + "limited_quic": { + "type": "boolean" + }, + "localpeer": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Local instance's peer name." + }, + "log_send_hostname": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "param": { + "type": "string", + "pattern": "^[^\\s]+$" + } + }, + "x-display-name": "Log Send Hostname", + "x-go-name": "GlobalLogSendHostname" + }, + "lua_options": { + "$ref": "#/definitions/lua_options" + }, + "master-worker": { + "type": "boolean", + "x-display-name": "Master Worker Mode" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "mworker_max_reloads": { + "type": "integer", + "x-display-name": "The number of times a worker can survive a reload", + "x-nullable": true + }, + "nbthread": { + "type": "integer", + "x-display-name": "Number of Threads" + }, + "no_quic": { + "type": "boolean", + "x-display-name": "Disable the use of the QUIC protocol" + }, + "node": { + "type": "string" + }, + "numa_cpu_mapping": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ocsp_update_options": { + "$ref": "#/definitions/ocsp_update_options" + }, + "performance_options": { + "$ref": "#/definitions/performance_options" + }, + "pidfile": { + "type": "string", + "x-display-name": "PID File" + }, + "pp2_never_send_local": { + "type": "boolean" + }, + "prealloc_fd": { + "type": "boolean", + "x-display-name": "Prealloc FD" + }, + "runtime_apis": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/bind_params" + }, + { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + } + } + } + ], + "x-go-name": "RuntimeAPI" + }, + "x-display-name": "Runtime APIs", + "x-go-name": "RuntimeAPIs", + "x-omitempty": true + }, + "set_dumpable": { + "type": "boolean" + }, + "set_var": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "expr" + ], + "properties": { + "expr": { + "type": "string", + "x-display-name": "Expression" + }, + "name": { + "type": "string", + "x-display-name": "Name" + } + }, + "x-go-name": "SetVar" + }, + "x-display-name": "Set variables", + "x-go-name": "SetVars", + "x-omitempty": true + }, + "set_var_fmt": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "format" + ], + "properties": { + "format": { + "type": "string", + "x-display-name": "Format" + }, + "name": { + "type": "string", + "x-display-name": "Name" + } + }, + "x-go-name": "SetVarFmt" + }, + "x-display-name": "Set variable formats", + "x-go-name": "SetVarFmts", + "x-omitempty": true + }, + "setcap": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "OS Capabilities", + "x-omitempty": true + }, + "shm_stats_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Shared Memory Statistics File (EXPERIMENTAL)" + }, + "shm_stats_file_max_objects": { + "type": "integer", + "x-display-name": "Maximum number of objects the shared memory used for shared counters will be able to store per thread group. (EXPERIMENTAL)", + "x-nullable": true + }, + "ssl_options": { + "$ref": "#/definitions/ssl_options" + }, + "stats_file": { + "type": "string" + }, + "stats_maxconn": { + "type": "integer", + "x-display-name": "Stats maxconn", + "x-nullable": true + }, + "stats_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "strict_limits": { + "type": "boolean" + }, + "thread_group_lines": { + "type": "array", + "items": { + "type": "object", + "required": [ + "group", + "num_or_range" + ], + "properties": { + "group": { + "type": "string", + "x-display-name": "Group" + }, + "num_or_range": { + "type": "string", + "x-display-name": "Number or Range" + } + }, + "x-go-name": "ThreadGroup" + }, + "x-display-name": "Thread Groups", + "x-go-name": "ThreadGroupLines", + "x-omitempty": true + }, + "thread_groups": { + "type": "integer", + "x-display-name": "Number of Thread Groups" + }, + "tune_buffer_options": { + "$ref": "#/definitions/tune_buffer_options" + }, + "tune_lua_options": { + "$ref": "#/definitions/tune_lua_options" + }, + "tune_options": { + "$ref": "#/definitions/tune_options" + }, + "tune_quic_options": { + "$ref": "#/definitions/tune_quic_options" + }, + "tune_ssl_options": { + "$ref": "#/definitions/tune_ssl_options" + }, + "tune_vars_options": { + "$ref": "#/definitions/tune_vars_options" + }, + "tune_zlib_options": { + "$ref": "#/definitions/tune_zlib_options" + }, + "uid": { + "type": "integer", + "x-display-name": "UID" + }, + "ulimit_n": { + "type": "integer" + }, + "user": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "User" + }, + "warn_blocked_traffic_after": { + "type": "integer", + "minimum": 1, + "x-default-unit": "ms", + "x-display-name": "Delay after which a stuck task triggers a warning", + "x-duration": true, + "x-nullable": true + }, + "wurfl_options": { + "$ref": "#/definitions/wurfl_options" + } + }, + "additionalProperties": false + }, + "group": { + "description": "HAProxy userlist group", + "type": "object", + "title": "Group", + "required": [ + "name" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "users": { + "type": "string", + "x-nullable": false + } + } + }, + "groups": { + "description": "HAProxy userlist groups array", + "type": "array", + "title": "Groups", + "items": { + "$ref": "#/definitions/group" + } + }, + "hash_type": { + "type": "object", + "properties": { + "function": { + "type": "string", + "enum": [ + "sdbm", + "djb2", + "wt6", + "crc32", + "none" + ] + }, + "method": { + "type": "string", + "enum": [ + "map-based", + "consistent" + ] + }, + "modifier": { + "type": "string", + "enum": [ + "avalanche" + ] + } + } + }, + "health": { + "type": "object", + "properties": { + "haproxy": { + "type": "string", + "enum": [ + "up", + "down", + "unknown" + ] + } + } + }, + "http_after_response_rule": { + "description": "HAProxy HTTP after response rule configuration (corresponds to http-after-response directives)", + "type": "object", + "title": "HTTP after Response Rule", + "required": [ + "type" + ], + "properties": { + "acl_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "del-acl" + ] + } + } + }, + "acl_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "del-acl" + ] + } + }, + "x-display-name": "ACK Key Format" + }, + "capture_id": { + "type": "integer", + "x-dependency": { + "type": { + "value": "capture" + } + }, + "x-display-name": "Capture SlotID", + "x-nullable": true + }, + "capture_len": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": "capture" + } + }, + "x-display-name": "Capture Len" + }, + "capture_sample": { + "type": "string", + "pattern": "^(?:[A-Za-z]+\\(\"([A-Za-z\\s]+)\"\\)|[A-Za-z]+)", + "x-dependency": { + "type": { + "value": "capture" + } + }, + "x-display-name": "Capture Sample" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "hdr_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value", + "set-header", + "add-header" + ] + } + }, + "x-display-name": "Header Format" + }, + "hdr_match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value" + ] + } + }, + "x-display-name": "Header Match" + }, + "hdr_method": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "del-header" + ] + } + }, + "x-display-name": "Header Match Method" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-header", + "replace-header", + "del-header", + "set-header", + "replace-value" + ] + } + }, + "x-display-name": "Header Name" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-log-level" + } + } + }, + "map_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + } + }, + "map_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + }, + "x-display-name": "Map Key Format" + }, + "map_valuefmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-map" + } + }, + "x-display-name": "Map Value Format" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] + } + } + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-set-gpt" + ] + } + } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "status": { + "type": "integer", + "maximum": 999, + "minimum": 100, + "x-dependency": { + "type": { + "required": true, + "value": "set-status" + } + }, + "x-nullable": false + }, + "status_reason": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-status" + } + } + }, + "strict_mode": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-dependency": { + "type": { + "required": true, + "value": "strict-mode" + } + } + }, + "type": { + "type": "string", + "enum": [ + "add-header", + "allow", + "capture", + "del-acl", + "del-header", + "del-map", + "replace-header", + "replace-value", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "set-header", + "set-log-level", + "set-map", + "set-status", + "set-var", + "set-var-fmt", + "strict-mode", + "unset-var", + "do-log" + ], + "x-nullable": false + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var" + } + }, + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var-fmt" + } + }, + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + } + }, + "additionalProperties": false, + "example": { + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "max-age=31536000", + "hdr_name": "Strict-Transport-Security", + "type": "set-header" + } + }, + "http_after_response_rules": { + "description": "HAProxy HTTP after response rules array (corresponds to http-after-response directives)", + "type": "array", + "title": "HTTP After Response Rules Array", + "items": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "http_check": { + "type": "object", + "title": "HTTP Check", + "required": [ + "type" + ], + "properties": { + "addr": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "connect" + } + }, + "x-nullable": false + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "connect" + } + }, + "x-display-name": "ALPN Protocols" + }, + "body": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "body_log_format": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "check_comment": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "comment", + "connect", + "expect", + "send" + ] + } + }, + "x-nullable": false + }, + "default": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" + } + } + }, + "error_status": { + "type": "string", + "enum": [ + "L7OKC", + "L7RSP", + "L7STS", + "L6RSP", + "L4CON" + ], + "x-dependency": { + "type": { + "value": "expect" + } + } + }, + "exclamation_mark": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "expect" + } + }, + "x-display-name": "Expect Exclamation Mark" + }, + "headers": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" + }, + "x-dependency": { + "type": { + "value": "send" + } + }, + "x-go-name": "CheckHeaders", + "x-omitempty": true + }, + "linger": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" + } + } + }, + "match": { + "type": "string", + "pattern": "^[^\\s]+$", + "enum": [ + "status", + "rstatus", + "hdr", + "fhdr", + "string", + "rstring" + ], + "x-dependency": { + "type": { + "required": true, + "value": "expect" + } + }, + "x-display-name": "Expect Match" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "method": { + "type": "string", + "enum": [ + "HEAD", + "PUT", + "POST", + "GET", + "TRACE", + "PATCH", + "DELETE", + "CONNECT", + "OPTIONS" + ], + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "min_recv": { + "type": "integer", + "x-dependency": { + "type": { + "value": "expect" + } + }, + "x-nullable": true + }, + "ok_status": { + "type": "string", + "enum": [ + "L7OK", + "L7OKC", + "L6OK", + "L4OK" + ], + "x-dependency": { + "type": { + "value": "expect" + } + } + }, + "on_error": { + "type": "string", + "x-dependency": { + "type": { + "value": "expect" + } + } + }, + "on_success": { + "type": "string", + "x-dependency": { + "type": { + "value": "expect" + } + } + }, + "pattern": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "expect" + } + } + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-dependency": { + "type": { + "value": "connect" + } + }, + "x-nullable": true + }, + "port_string": { + "type": "string", + "x-dependency": { + "type": { + "value": "connect" + } + } + }, + "proto": { + "type": "string", + "x-dependency": { + "type": { + "value": "connect" + } + }, + "x-nullable": false + }, + "send_proxy": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" + } + } + }, + "sni": { + "type": "string", + "x-dependency": { + "type": { + "value": "connect" + } + } + }, + "ssl": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" + } + } + }, + "status-code": { + "type": "string", + "x-dependency": { + "type": { + "value": "expect" + } + } + }, + "tout_status": { + "type": "string", + "enum": [ + "L7TOUT", + "L6TOUT", + "L4TOUT" + ], + "x-dependency": { + "type": { + "value": "expect" + } + } + }, + "type": { + "type": "string", + "enum": [ + "comment", + "connect", + "disable-on-404", + "expect", + "send", + "send-state", + "set-var", + "set-var-fmt", + "unset-var" + ], + "x-nullable": false + }, + "uri": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "uri_log_format": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var" + ] + } + }, + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var-fmt" + ] + } + }, + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "version": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "via_socks4": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" + } + } + } + } + }, + "http_checks": { + "type": "array", + "title": "HTTP Checks Array", + "items": { + "$ref": "#/definitions/http_check" + } + }, + "http_client_options": { + "type": "object", + "properties": { + "resolvers_disabled": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Client Resolvers Disabled" + }, + "resolvers_id": { + "type": "string", + "x-display-name": "HTTP Client Resolvers ID" + }, + "resolvers_prefer": { + "type": "string", + "enum": [ + "ipv4", + "ipv6" + ], + "x-display-name": "HTTP Client Resolvers Prefer" + }, + "retries": { + "type": "integer", + "x-display-name": "HTTP Client Retries" + }, + "ssl_ca_file": { + "type": "string", + "x-display-name": "HTTP Client SSL CA File" + }, + "ssl_verify": { + "type": "string", + "enum": [ + "", + "none", + "required" + ], + "x-display-name": "HTTP Client SSL Verify", + "x-nullable": true + }, + "timeout_connect": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "HTTP Client Connect Timeout", + "x-duration": true, + "x-nullable": true + } + } + }, + "http_codes": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string", + "pattern": "^[a-zA-Z0-9 +\\-,]+$", + "x-display-name": "Value" + } + }, + "x-go-name": "HTTPCodes" + }, + "http_error_rule": { + "description": "HAProxy HTTP error rule configuration (corresponds to http-error directives)", + "type": "object", + "title": "HTTP Error Rule", + "required": [ + "type", + "status" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "return_content": { + "type": "string", + "x-dependency": { + "return_content_format": { + "required": true, + "value": [ + "errofile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ] + } + } + }, + "return_content_format": { + "type": "string", + "enum": [ + "default-errorfiles", + "errorfile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ], + "x-dependency": { + "type": { + "value": "status" + } + } + }, + "return_content_type": { + "type": "string", + "x-dependency": { + "type": { + "value": "status" + } + }, + "x-display-name": "Return content type", + "x-nullable": true + }, + "return_hdrs": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" + }, + "x-dependency": { + "return_content_format": { + "value": [ + "file", + "lf-file", + "string", + "lf-string" + ] + } + }, + "x-go-name": "ReturnHeaders", + "x-omitempty": true + }, + "status": { + "type": "integer", + "enum": [ + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ], + "x-dependency": { + "type": { + "required": true, + "value": "status" + } + }, + "x-nullable": false + }, + "type": { + "type": "string", + "enum": [ + "status" + ], + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "index": 0, + "status": 425, + "type": "status" + } + }, + "http_error_rules": { + "description": "HAProxy HTTP error rules array (corresponds to http-error directives)", + "type": "array", + "title": "HTTP Error Rules Array", + "items": { + "$ref": "#/definitions/http_error_rule" + } + }, + "http_errors_section": { + "description": "A globally declared group of HTTP errors", + "type": "object", + "title": "http-errors section", + "required": [ + "name", + "error_files" + ], + "properties": { + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" + }, + "x-go-name": "ErrorFiles" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "error_files": [ + { + "code": 400, + "name": "/etc/haproxy/errorfiles/site1/400.http" + }, + { + "code": 404, + "name": "/etc/haproxy/errorfiles/site1/404.http" + } + ], + "name": "website-1" + } + }, + "http_errors_sections": { + "description": "An array of HAProxy http-error sections", + "type": "array", + "title": "http-errors sections", + "items": { + "$ref": "#/definitions/http_errors_section" + } + }, + "http_request_rule": { + "description": "HAProxy HTTP request rule configuration (corresponds to http-request directives)", + "type": "object", + "title": "HTTP Request Rule", + "required": [ + "type" + ], + "properties": { + "acl_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] + } + }, + "x-display-name": "ACL File" + }, + "acl_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] + } + }, + "x-display-name": "ACL Key Format" + }, + "auth_realm": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "auth" + } + }, + "x-display-name": "Authentication Realm" + }, + "bandwidth_limit_limit": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "bandwidth_limit_name": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" + } + }, + "x-display-name": "Bandwidth limit name" + }, + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "cache_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "cache-use" + } + }, + "x-display-name": "Cache Name" + }, + "capture_id": { + "type": "integer", + "x-dependency": { + "type": { + "value": "capture" + } + }, + "x-display-name": "Capture SlotID", + "x-nullable": true + }, + "capture_len": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": "capture" + } + }, + "x-display-name": "Capture Len" + }, + "capture_sample": { + "type": "string", + "pattern": "^(?:[A-Za-z]+\\(\"([A-Za-z\\s]+)\"\\)|[A-Za-z]+)", + "x-dependency": { + "type": { + "value": "capture" + } + }, + "x-display-name": "Capture Sample" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "deny_status": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": [ + "deny", + "tarpit" + ] + } + }, + "x-nullable": true + }, + "expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "do-resolve", + "pause", + "set-bc-mark", + "set-bc-tos", + "set-dst", + "set-dst-port", + "set-fc-mark", + "set-fc-tos", + "set-priority-class", + "set-priority-offset", + "set-src", + "set-src-port", + "set-retries" + ] + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "hdr_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value", + "set-header", + "add-header" + ] + } + }, + "x-display-name": "Header Format" + }, + "hdr_match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value" + ] + } + }, + "x-display-name": "Header Match" + }, + "hdr_method": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "del-header" + ] + } + }, + "x-display-name": "Header Match Method" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-header", + "replace-header", + "del-header", + "set-header", + "replace-value" + ] + } + }, + "x-display-name": "Header Name" + }, + "hint_format": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "early-hint" + } + }, + "x-display-name": "Hint Format" + }, + "hint_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "early-hint" + } + }, + "x-display-name": "Hint Name" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-log-level" + } + } + }, + "lua_action": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "lua" + } + } + }, + "lua_params": { + "type": "string", + "x-dependency": { + "type": { + "value": "lua" + } + } + }, + "map_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + } + }, + "map_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + }, + "x-display-name": "Map Key Format" + }, + "map_valuefmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-map" + } + }, + "x-display-name": "Map Value Format" + }, + "mark_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-mark" + } + }, + "x-display-name": "Mark Value" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "method_fmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-method" + } + } + }, + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "type": { + "required": true, + "value": "set-nice" + } + }, + "x-display-name": "Nice Value", + "x-nullable": false + }, + "normalizer": { + "type": "string", + "enum": [ + "fragment-encode", + "fragment-strip", + "path-merge-slashes", + "path-strip-dot", + "path-strip-dotdot", + "percent-decode-unreserved", + "percent-to-uppercase", + "query-sort-by-name" + ], + "x-dependency": { + "type": { + "required": true, + "value": "normalize-uri" + } + } + }, + "normalizer_full": { + "type": "boolean", + "x-dependency": { + "normalizer": { + "value": "path-strip-dotdot" + }, + "type": { + "value": "normalize-uri" + } + } + }, + "normalizer_strict": { + "type": "boolean", + "x-dependency": { + "normalizer": { + "value": [ + "percent-decode-unreserved", + "percent-to-uppercase" + ] + }, + "type": { + "value": "normalize-uri" + } + } + }, + "path_fmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-path", + "set-pathq", + "replace-path", + "replace-pathq" + ] + } + } + }, + "path_match": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-path", + "set-pathq", + "replace-path", + "replace-pathq" + ] + } + } + }, + "protocol": { + "type": "string", + "enum": [ + "ipv4", + "ipv6" + ], + "x-dependency": { + "type": { + "required": false, + "value": "do-resolve" + } + }, + "x-display-name": "Protocol" + }, + "query-fmt": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-query" + } + } + }, + "redir_code": { + "type": "integer", + "enum": [ + 301, + 302, + 303, + 307, + 308 + ], + "x-dependency": { + "type": { + "value": "redirect" + } + }, + "x-display-name": "Redirect Code", + "x-nullable": true + }, + "redir_option": { + "type": "string", + "x-dependency": { + "type": { + "value": "redirect" + } + }, + "x-display-name": "Redirect Option" + }, + "redir_type": { + "type": "string", + "enum": [ + "location", + "prefix", + "scheme" + ], + "x-dependency": { + "type": { + "required": true, + "value": "redirect" + } + }, + "x-display-name": "Redirect Type" + }, + "redir_value": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "redirect" + } + }, + "x-display-name": "Redirect Value" + }, + "resolvers": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "do-resolve" + } + }, + "x-display-name": "Resolvers" + }, + "return_content": { + "type": "string", + "x-dependency": { + "return_content_format": { + "required": true, + "value": [ + "errofile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ] + } + } + }, + "return_content_format": { + "type": "string", + "enum": [ + "default-errorfiles", + "errorfile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ], + "x-dependency": { + "type": { + "value": [ + "deny", + "tarpit", + "return" + ] + } + } + }, + "return_content_type": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "deny", + "tarpit", + "return" + ] + } + }, + "x-display-name": "Return content type", + "x-nullable": true + }, + "return_hdrs": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" + }, + "x-dependency": { + "return_content_format": { + "value": [ + "file", + "lf-file", + "string", + "lf-string" + ] + } + }, + "x-go-name": "ReturnHeaders", + "x-omitempty": true + }, + "return_status_code": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": "return" + } + }, + "x-display-name": "Return Error Code", + "x-nullable": true + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] + } + }, + "x-display-name": "RST TTL" + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] + } + } + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-set-gpt" + ] + } + } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "service_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "use-service" + } + } + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" + } + }, + "x-display-name": "SPOE Engine" + }, + "spoe_group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" + } + }, + "x-display-name": "SPOE Group" + }, + "strict_mode": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-dependency": { + "type": { + "required": true, + "value": "strict-mode" + } + } + }, + "timeout": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" + } + } + }, + "timeout_type": { + "type": "string", + "enum": [ + "server", + "tunnel", + "client" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" + } + } + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-tos" + } + }, + "x-display-name": "Tos Value" + }, + "track_sc_key": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "track-sc" + } + }, + "x-display-name": "track-sc Key" + }, + "track_sc_stick_counter": { + "type": "integer", + "x-dependency": { + "type": { + "value": "track-sc" + } + }, + "x-display-name": "track-sc StickCounter", + "x-nullable": true + }, + "track_sc_table": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "track-sc" + } + }, + "x-display-name": "track-sc Table" + }, + "type": { + "type": "string", + "enum": [ + "add-acl", + "add-header", + "allow", + "auth", + "cache-use", + "capture", + "del-acl", + "del-header", + "del-map", + "deny", + "disable-l7-retry", + "do-resolve", + "early-hint", + "lua", + "normalize-uri", + "pause", + "redirect", + "reject", + "replace-header", + "replace-path", + "replace-pathq", + "replace-uri", + "replace-value", + "return", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-bc-mark", + "set-bc-tos", + "set-dst", + "set-dst-port", + "set-fc-mark", + "set-fc-tos", + "set-header", + "set-log-level", + "set-map", + "set-mark", + "set-method", + "set-nice", + "set-path", + "set-pathq", + "set-priority-class", + "set-priority-offset", + "set-query", + "set-src", + "set-src-port", + "set-timeout", + "set-tos", + "set-uri", + "set-var", + "set-var-fmt", + "silent-drop", + "strict-mode", + "tarpit", + "track-sc", + "unset-var", + "use-service", + "wait-for-body", + "wait-for-handshake", + "set-bandwidth-limit", + "set-retries", + "do-log" + ], + "x-nullable": false + }, + "uri-fmt": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-uri", + "replace-uri" + ] + } + } + }, + "uri-match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "replace-uri" + } + } + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var" + } + }, + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var-fmt" + } + }, + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "do-resolve", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "wait_at_least": { + "type": "integer", + "x-dependency": { + "type": { + "value": "wait-for-body" + } + }, + "x-nullable": true, + "x-size": true + }, + "wait_time": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "wait-for-body" + } + }, + "x-duration": true, + "x-nullable": true + } + }, + "additionalProperties": false, + "example": { + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "index": 0, + "type": "add-header" + } + }, + "http_request_rules": { + "description": "HAProxy HTTP request rules array (corresponds to http-request directives)", + "type": "array", + "title": "HTTP Request Rules Array", + "items": { + "$ref": "#/definitions/http_request_rule" + } + }, + "http_response_rule": { + "description": "HAProxy HTTP response rule configuration (corresponds to http-response directives)", + "type": "object", + "title": "HTTP Response Rule", + "required": [ + "type" + ], + "properties": { + "acl_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] + } + } + }, + "acl_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] + } + }, + "x-display-name": "ACK Key Format" + }, + "bandwidth_limit_limit": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "bandwidth_limit_name": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" + } + }, + "x-display-name": "Bandwidth limit name" + }, + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "cache_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "cache-store" + } + }, + "x-display-name": "Cache Name" + }, + "capture_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": "capture" + } + }, + "x-display-name": "Capture SlotID", + "x-nullable": true + }, + "capture_sample": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "capture" + } + }, + "x-display-name": "Capture Sample" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "deny_status": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": "deny" + } + }, + "x-nullable": true + }, + "expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "pause", + "set-fc-mark", + "set-fc-tos" + ] + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "hdr_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value", + "set-header", + "add-header" + ] + } + }, + "x-display-name": "Header Format" + }, + "hdr_match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value" + ] + } + }, + "x-display-name": "Header Match" + }, + "hdr_method": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "del-header" + ] + } + }, + "x-display-name": "Header Match Method" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-header", + "replace-header", + "del-header", + "set-header", + "replace-value" + ] + } + }, + "x-display-name": "Header Name" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-log-level" + } + } + }, + "lua_action": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "lua" + } + } + }, + "lua_params": { + "type": "string", + "x-dependency": { + "type": { + "value": "lua" + } + } + }, + "map_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + } + }, + "map_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + }, + "x-display-name": "Map Key Format" + }, + "map_valuefmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-map" + } + }, + "x-display-name": "Map Value Format" + }, + "mark_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-mark" + } + }, + "x-display-name": "Mark Value" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "type": { + "required": true, + "value": "set-nice" + } + }, + "x-display-name": "Nice Value", + "x-nullable": false + }, + "redir_code": { + "type": "integer", + "enum": [ + 301, + 302, + 303, + 307, + 308 + ], + "x-dependency": { + "type": { + "value": "redirect" + } + }, + "x-display-name": "Redirect Code", + "x-nullable": true + }, + "redir_option": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "redirect" + } + }, + "x-display-name": "Redirect Option" + }, + "redir_type": { + "type": "string", + "enum": [ + "location", + "prefix", + "scheme" + ], + "x-dependency": { + "type": { + "required": true, + "value": "redirect" + } + }, + "x-display-name": "Redirect Type" + }, + "redir_value": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "redirect" + } + }, + "x-display-name": "Redirect Value" + }, + "return_content": { + "type": "string", + "x-dependency": { + "return_content_format": { + "required": true, + "value": [ + "errofile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ] + } + } + }, + "return_content_format": { + "type": "string", + "enum": [ + "default-errorfiles", + "errorfile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ], + "x-dependency": { + "type": { + "value": [ + "deny", + "return" + ] + } + } + }, + "return_content_type": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "deny", + "return" + ] + } + }, + "x-display-name": "Return content type", + "x-nullable": true + }, + "return_hdrs": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" + }, + "x-dependency": { + "return_content_format": { + "value": [ + "file", + "lf-file", + "string", + "lf-string" + ] + } + }, + "x-go-name": "ReturnHeaders", + "x-omitempty": true + }, + "return_status_code": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": "return" + } + }, + "x-display-name": "Return Error Code", + "x-nullable": true + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] + } + }, + "x-display-name": "RST TTL" + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] + } + } + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-set-gpt" + ] + } + } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" + } + } + }, + "spoe_group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" + } + } + }, + "status": { + "type": "integer", + "maximum": 999, + "minimum": 100, + "x-dependency": { + "type": { + "required": true, + "value": "set-status" + } + }, + "x-nullable": false + }, + "status_reason": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-status" + } + } + }, + "strict_mode": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-dependency": { + "type": { + "required": true, + "value": "strict-mode" + } + } + }, + "timeout": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" + } + } + }, + "timeout_type": { + "type": "string", + "enum": [ + "server", + "tunnel", + "client" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" + } + } + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-tos" + } + }, + "x-display-name": "Tos Value" + }, + "track_sc_key": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "track-sc" + } + }, + "x-display-name": "track-sc Key" + }, + "track_sc_stick_counter": { + "type": "integer", + "x-dependency": { + "type": { + "value": "track-sc" + } + }, + "x-display-name": "track-sc StickCounter", + "x-nullable": true + }, + "track_sc_table": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "track-sc" + } + }, + "x-display-name": "track-sc Table" + }, + "type": { + "type": "string", + "enum": [ + "add-acl", + "add-header", + "allow", + "cache-store", + "capture", + "del-acl", + "del-header", + "del-map", + "deny", + "lua", + "pause", + "redirect", + "replace-header", + "replace-value", + "return", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-fc-mark", + "set-fc-tos", + "set-header", + "set-log-level", + "set-map", + "set-mark", + "set-nice", + "set-status", + "set-timeout", + "set-tos", + "set-var", + "set-var-fmt", + "silent-drop", + "strict-mode", + "track-sc", + "unset-var", + "wait-for-body", + "set-bandwidth-limit", + "do-log" + ], + "x-nullable": false + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var" + } + }, + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var-fmt" + } + }, + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "wait_at_least": { + "type": "integer", + "x-dependency": { + "type": { + "value": "wait-for-body" + } + }, + "x-nullable": true, + "x-size": true + }, + "wait_time": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "wait-for-body" + } + }, + "x-duration": true, + "x-nullable": true + } + }, + "additionalProperties": false, + "example": { + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "index": 0, + "type": "add-header" + } + }, + "http_response_rules": { + "description": "HAProxy HTTP response rules array (corresponds to http-response directives)", + "type": "array", + "title": "HTTP Response Rules Array", + "items": { + "$ref": "#/definitions/http_response_rule" + } + }, + "httpchk_params": { + "type": "object", + "properties": { + "host": { + "type": "string" + }, + "method": { + "type": "string", + "enum": [ + "HEAD", + "PUT", + "POST", + "GET", + "TRACE", + "PATCH", + "DELETE", + "CONNECT", + "OPTIONS" + ] + }, + "uri": { + "type": "string", + "pattern": "^[^ ]*$" + }, + "version": { + "type": "string" + } + }, + "x-display-name": "HTTP Check" + }, + "info": { + "description": "General API, OS and hardware information", + "type": "object", + "title": "Information", + "properties": { + "api": { + "type": "object", + "properties": { + "build_date": { + "description": "HAProxy Dataplane API build date", + "type": "string", + "format": "date-time" + }, + "version": { + "description": "HAProxy Dataplane API version string", + "type": "string" + } + } + }, + "system": { + "type": "object", + "properties": { + "cpu_info": { + "type": "object", + "properties": { + "model": { + "type": "string" + }, + "num_cpus": { + "description": "Number of logical CPUs", + "type": "integer" + } + } + }, + "hostname": { + "description": "Hostname where the HAProxy is running", + "type": "string" + }, + "mem_info": { + "type": "object", + "properties": { + "dataplaneapi_memory": { + "type": "integer" + }, + "free_memory": { + "type": "integer" + }, + "total_memory": { + "type": "integer" + } + } + }, + "os_string": { + "description": "OS string", + "type": "string" + }, + "time": { + "description": "Current time in milliseconds since Epoch.", + "type": "integer" + }, + "uptime": { + "description": "System uptime", + "type": "integer", + "x-nullable": true + } + } + } + }, + "example": { + "api": { + "build_date": "2019-08-21T17:31:56.000Z", + "version": "v1.2.1 45a3288.dev" + }, + "system": { + "cpu_info": { + "model": "Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz", + "num_cpus": 4 + }, + "hostname": "test", + "mem_info": { + "dataplaneapi_memory": 44755536, + "free_memory": 5790642176, + "total_memory": 16681517056 + }, + "os_string": "Linux 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019", + "time": 1566401525, + "uptime": 87340 + } + } + }, + "log_forward": { + "description": "LogForward with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/log_forward_base" + }, + { + "type": "object", + "properties": { + "binds": { + "additionalProperties": { + "$ref": "#/definitions/bind" + } + }, + "dgram_binds": { + "additionalProperties": { + "$ref": "#/definitions/dgram_bind" + } + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + } + } + } + ], + "x-go-name": "LogForward" + }, + "log_forward_base": { + "description": "HAProxy log forward configuration", + "type": "object", + "title": "Log Forward", + "required": [ + "name" + ], + "properties": { + "assume-rfc6587-ntf": { + "type": "boolean", + "x-display-name": "Assume RFC-6587 Non-Transparent Framing" + }, + "backlog": { + "type": "integer", + "x-nullable": true + }, + "dont-parse-log": { + "type": "boolean", + "x-display-name": "Don't Parse Log" + }, + "maxconn": { + "type": "integer", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "timeout_client": { + "type": "integer", + "maximum": 2147483647, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + } + }, + "additionalProperties": false + }, + "log_forwards": { + "description": "HAProxy log forwards array", + "type": "array", + "title": "Log Forwards", + "items": { + "$ref": "#/definitions/log_forward" + } + }, + "log_profile": { + "description": "Defines a logging profile for one or more steps.", + "type": "object", + "title": "Log Profile", + "required": [ + "name" + ], + "properties": { + "log_tag": { + "description": "Override syslog log tag set by other \"log-tag\" directives.", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "description": "Name of the logging profile.", + "type": "string", + "minLength": 1, + "x-nullable": false + }, + "steps": { + "$ref": "#/definitions/log_profile_steps" + } + } + }, + "log_profile_step": { + "description": "Defines what to log for a given step.", + "type": "object", + "title": "Log Profile Step", + "required": [ + "step" + ], + "properties": { + "drop": { + "description": "If enabled, no log shall be emitted for the given step.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "format": { + "description": "Override \"log-format\" or \"error-log-format\" strings depending on the step.", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "sd": { + "description": "Override the \"log-format-sd\" string.", + "type": "string" + }, + "step": { + "description": "Logging step name.", + "type": "string", + "enum": [ + "accept", + "any", + "close", + "connect", + "error", + "request", + "response", + "http-req", + "http-res", + "http-after-res", + "quic-init", + "tcp-req-conn", + "tcp-req-cont", + "tcp-req-sess" + ], + "x-nullable": false + } + } + }, + "log_profile_steps": { + "description": "List of steps where to override the logging.", + "type": "array", + "items": { + "$ref": "#/definitions/log_profile_step" + }, + "x-omitempty": true + }, + "log_profiles": { + "description": "List of Logging Profiles", + "type": "array", + "items": { + "$ref": "#/definitions/log_profile" + } + }, + "log_target": { + "description": "Per-instance logging of events and traffic.", + "type": "object", + "title": "Log Target", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "global": { + "required": true, + "value": false + }, + "nolog": { + "required": true, + "value": false + } + } + }, + "facility": { + "type": "string", + "enum": [ + "kern", + "user", + "mail", + "daemon", + "auth", + "syslog", + "lpr", + "news", + "uucp", + "cron", + "auth2", + "ftp", + "ntp", + "audit", + "alert", + "cron2", + "local0", + "local1", + "local2", + "local3", + "local4", + "local5", + "local6", + "local7" + ], + "x-dependency": { + "global": { + "required": true, + "value": false + }, + "nolog": { + "required": true, + "value": false + } + } + }, + "format": { + "type": "string", + "enum": [ + "local", + "rfc3164", + "rfc5424", + "priority", + "short", + "timed", + "iso", + "raw" + ], + "x-dependency": { + "global": { + "value": false + }, + "nolog": { + "value": false + } + } + }, + "global": { + "type": "boolean" + }, + "length": { + "type": "integer", + "x-dependency": { + "global": { + "value": false + }, + "nolog": { + "value": false + } + } + }, + "level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug" + ], + "x-dependency": { + "global": { + "value": false + }, + "nolog": { + "value": false + } + } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "minlevel": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug" + ], + "x-dependency": { + "global": { + "value": false + }, + "level": { + "required": false + }, + "nolog": { + "value": false + } + } + }, + "nolog": { + "type": "boolean" + }, + "profile": { + "type": "string" + }, + "sample_range": { + "type": "string", + "x-dependency": { + "global": { + "value": false + }, + "nolog": { + "value": false + } + } + }, + "sample_size": { + "type": "integer", + "x-dependency": { + "global": { + "value": false + }, + "nolog": { + "value": false + }, + "sample_range": { + "required": true + } + } + } + }, + "additionalProperties": false + }, + "log_targets": { + "description": "HAProxy log target array (corresponds to log directives)", + "type": "array", + "title": "Log Target Array", + "items": { + "$ref": "#/definitions/log_target" + } + }, + "lua_options": { + "type": "object", + "properties": { + "load_per_thread": { + "type": "string" + }, + "loads": { + "type": "array", + "items": { + "type": "object", + "required": [ + "file" + ], + "properties": { + "file": { + "type": "string", + "pattern": "^[^\\s]+$" + } + }, + "x-go-name": "LuaLoad" + }, + "x-omitempty": true + }, + "prepend_path": { + "type": "array", + "items": { + "type": "object", + "required": [ + "path" + ], + "properties": { + "path": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "type": { + "type": "string", + "enum": [ + "path", + "cpath" + ] + } + }, + "x-go-name": "LuaPrependPath" + }, + "x-omitempty": true + } + } + }, + "mailer_entries": { + "description": "HAProxy mailer entries", + "type": "array", + "title": "Mailer Entries", + "items": { + "$ref": "#/definitions/mailer_entry" + } + }, + "mailer_entry": { + "description": "Mailer entry of a Mailers section", + "type": "object", + "title": "Mailer Entry", + "required": [ + "name", + "address", + "port" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^\\S+$", + "x-nullable": false + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": false + } + } + }, + "mailers_section": { + "description": "MailersSection with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/mailers_section_base" + }, + { + "type": "object", + "properties": { + "mailer_entries": { + "additionalProperties": { + "$ref": "#/definitions/mailer_entry" + } + } + } + } + ], + "x-go-name": "MailersSection" + }, + "mailers_section_base": { + "description": "A list of SMTP servers used by HAProxy to send emails.", + "type": "object", + "title": "Mailers Section Base", + "required": [ + "name" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false + }, + "timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Timeout to send an email in milliseconds", + "x-duration": true, + "x-nullable": true + } + }, + "additionalProperties": false + }, + "mailers_sections": { + "description": "HAProxy mailers_section array", + "type": "array", + "title": "Mailers Sections", + "items": { + "$ref": "#/definitions/mailers_section" + } + }, + "map": { + "description": "Map File", + "type": "object", + "title": "Map File", + "properties": { + "description": { + "type": "string" + }, + "file": { + "type": "string" + }, + "id": { + "type": "string" + }, + "size": { + "description": "File size in bytes.", + "type": "integer", + "x-nullable": true + }, + "storage_name": { + "type": "string" + } + } + }, + "map_entries": { + "description": "Entries of one runtime map", + "type": "array", + "title": "Maps Entries", + "items": { + "$ref": "#/definitions/map_entry" + } + }, + "map_entry": { + "description": "One Map Entry", + "type": "object", + "title": "One Map Entry", + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "maps": { + "description": "Array of runtime map files", + "type": "array", + "title": "Map Files Array", + "items": { + "$ref": "#/definitions/map" + } + }, + "monitor_fail": { + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + } + } + }, + "monitor_uri": { + "type": "string" + }, + "mysql_check_params": { + "type": "object", + "properties": { + "client_version": { + "type": "string", + "enum": [ + "pre-41", + "post-41" + ] + }, + "username": { + "type": "string" + } + } + }, + "nameserver": { + "description": "Nameserver used in Runtime DNS configuration", + "type": "object", + "title": "Nameserver", + "required": [ + "name", + "address" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + } + }, + "example": { + "address": "10.0.0.1", + "name": "ns1", + "port": 53 + } + }, + "nameservers": { + "description": "Nameservers array", + "type": "array", + "title": "Nameservers", + "items": { + "$ref": "#/definitions/nameserver" + } + }, + "native_stat": { + "description": "Current stats for one object.", + "type": "object", + "title": "Stats", + "properties": { + "backend_name": { + "type": "string", + "x-dependency": { + "type": "server" + } + }, + "name": { + "type": "string" + }, + "stats": { + "$ref": "#/definitions/native_stat_stats" + }, + "type": { + "type": "string", + "enum": [ + "backend", + "server", + "frontend" + ] + } + } + }, + "native_stat_stats": { + "type": "object", + "properties": { + "act": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "addr": { + "type": "string", + "x-dependency": { + "type": "server" + } + }, + "agent_code": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "agent_desc": { + "type": "string", + "x-dependency": { + "type": "server" + } + }, + "agent_duration": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "agent_fall": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "agent_health": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "agent_rise": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "agent_status": { + "type": "string", + "enum": [ + "UNK", + "INI", + "SOCKERR", + "L4OK", + "L4TOUT", + "L4CON", + "L7OK", + "L7STS" + ], + "x-dependency": { + "type": "server" + } + }, + "algo": { + "type": "string", + "x-dependency": { + "type": "backend" + } + }, + "bck": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "bin": { + "type": "integer", + "x-nullable": true + }, + "bout": { + "type": "integer", + "x-nullable": true + }, + "check_code": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "check_desc": { + "type": "string", + "x-dependency": { + "type": "server" + } + }, + "check_duration": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "check_fall": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "check_health": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "check_rise": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "check_status": { + "type": "string", + "enum": [ + "UNK", + "INI", + "SOCKERR", + "L4OK", + "L4TOUT", + "L4CON", + "L6OK", + "L6TOUT", + "L6RSP", + "L7OK", + "L7OKC", + "L7TOUT", + "L7RSP", + "L7STS" + ], + "x-dependency": { + "type": "server" + } + }, + "chkdown": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "chkfail": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "cli_abrt": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "comp_byp": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] + }, + "x-nullable": true + }, + "comp_in": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] + }, + "x-nullable": true + }, + "comp_out": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] + }, + "x-nullable": true + }, + "comp_rsp": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] + }, + "x-nullable": true + }, + "conn_rate": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "conn_rate_max": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "conn_tot": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "cookie": { + "type": "string", + "x-dependency": { + "type": [ + "server", + "backend" + ] + } + }, + "ctime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "dcon": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "downtime": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "dreq": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] + }, + "x-nullable": true + }, + "dresp": { + "type": "integer", + "x-nullable": true + }, + "dses": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "econ": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "ereq": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "eresp": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "hanafail": { + "type": "string", + "x-dependency": { + "type": "server" + } + }, + "hrsp_1xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_2xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_3xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_4xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_5xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_other": { + "type": "integer", + "x-nullable": true + }, + "iid": { + "type": "integer", + "x-nullable": true + }, + "intercepted": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] + }, + "x-nullable": true + }, + "last_agt": { + "type": "string", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "last_chk": { + "type": "string", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "lastchg": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "lastsess": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "lbtot": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "mode": { + "type": "string", + "enum": [ + "tcp", + "http", + "health", + "unknown" + ] + }, + "pid": { + "type": "integer", + "x-nullable": true + }, + "qcur": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "qlimit": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "qmax": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "qtime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "rate": { + "type": "integer", + "x-nullable": true + }, + "rate_lim": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "rate_max": { + "type": "integer", + "x-nullable": true + }, + "req_rate": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "req_rate_max": { + "type": "integer", + "x-dependency": { + "type": "frontend" + }, + "x-nullable": true + }, + "req_tot": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] + }, + "x-nullable": true + }, + "rtime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "scur": { + "type": "integer", + "x-nullable": true + }, + "sid": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "slim": { + "type": "integer", + "x-nullable": true + }, + "smax": { + "type": "integer", + "x-nullable": true + }, + "srv_abrt": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "status": { + "type": "string", + "enum": [ + "UP", + "DOWN", + "NOLB", + "MAINT", + "no check" + ] + }, + "stot": { + "type": "integer", + "x-nullable": true + }, + "throttle": { + "type": "integer", + "x-dependency": { + "type": "server" + }, + "x-nullable": true + }, + "tracked": { + "type": "string", + "x-dependency": { + "type": "server" + } + }, + "ttime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "weight": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "wredis": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "wretr": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + } + }, + "example": { + "bin": 4326578, + "bout": 889901290, + "comp_byp": 0, + "comp_in": 0, + "comp_out": 0, + "comp_rsp": 0, + "conn_rate": 12, + "conn_rate_max": 456, + "conn_tot": 45682, + "dcon": 0, + "dreq": 4, + "dresp": 1, + "dses": 0, + "ereq": 54, + "hrsp_1xx": 0, + "hrsp_2xx": 165, + "hrsp_3xx": 12, + "hrsp_4xx": 50, + "hrsp_5xx": 4, + "hrsp_other": 0, + "iid": 0, + "intercepted": 346, + "last_chk": "L4OK in 0ms", + "mode": "http", + "pid": 3204, + "rate": 64, + "rate_lim": 20000, + "rate_max": 4000, + "req_rate": 49, + "req_rate_max": 3965, + "req_total": 1254786, + "scur": 129, + "slim": 2000, + "smax": 2000, + "status": "UP", + "stot": 12902 + } + }, + "native_stats": { + "description": "HAProxy stats array", + "type": "object", + "title": "Stats Array", + "properties": { + "error": { + "type": "string" + }, + "runtimeAPI": { + "type": "string" + }, + "stats": { + "type": "array", + "items": { + "$ref": "#/definitions/native_stat" + }, + "x-omitempty": true + } + }, + "x-omitempty": true + }, + "ocsp_update_options": { + "type": "object", + "properties": { + "disable": { + "type": "boolean", + "default": false, + "x-display-name": "Disable OCSP Update", + "x-nullable": true + }, + "httpproxy": { + "type": "object", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "example": "127.0.0.1" + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "example": 80 + } + }, + "x-display-name": "OCSP Update HTTP Proxy", + "x-omitempty": true + }, + "maxdelay": { + "description": "Sets the maximum interval between two automatic updates of the same OCSP response.This time is expressed in seconds", + "type": "integer", + "x-default-unit": "s", + "x-display-name": "OCSP Update Maximum Delay", + "x-duration": false, + "x-nullable": true + }, + "mindelay": { + "description": "Sets the minimum interval between two automatic updates of the same OCSP response. This time is expressed in seconds", + "type": "integer", + "x-default-unit": "s", + "x-display-name": "OCSP Update Minimum Delay", + "x-duration": false, + "x-nullable": true + }, + "mode": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "OCSP Update Mode" + } + } + }, + "originalto": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled" + ] + }, + "except": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "header": { + "type": "string", + "pattern": "^[^\\s]+$" + } + }, + "x-display-name": "OriginalTo" + }, + "peer_entries": { + "description": "HAProxy peer entries array", + "type": "array", + "title": "Peer entries", + "items": { + "$ref": "#/definitions/peer_entry" + } + }, + "peer_entry": { + "description": "Peer Entry from peers table", + "type": "object", + "title": "Peer Entry", + "required": [ + "name", + "address", + "port" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "shard": { + "type": "integer" + } + } + }, + "peer_section": { + "description": "Peer Section with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/peer_section_base" + }, + { + "type": "object", + "properties": { + "binds": { + "additionalProperties": { + "$ref": "#/definitions/bind" + } + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + }, + "peer_entries": { + "additionalProperties": { + "$ref": "#/definitions/peer_entry" + } + }, + "servers": { + "additionalProperties": { + "$ref": "#/definitions/server" + } + }, + "tables": { + "additionalProperties": { + "$ref": "#/definitions/table" + } + } + } + } + ], + "x-go-name": "PeerSection" + }, + "peer_section_base": { + "description": "HAProxy peer_section configuration", + "type": "object", + "title": "Peer Section Base", + "required": [ + "name" + ], + "properties": { + "default_bind": { + "$ref": "#/definitions/default_bind" + }, + "default_server": { + "$ref": "#/definitions/default_server" + }, + "disabled": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "shards": { + "description": "In some configurations, one would like to distribute the stick-table contents\nto some peers in place of sending all the stick-table contents to each peer\ndeclared in the \"peers\" section. In such cases, \"shards\" specifies the\nnumber of peer involved in this stick-table contents distribution.", + "type": "integer" + } + }, + "additionalProperties": false + }, + "peer_sections": { + "description": "HAProxy peer_section array", + "type": "array", + "title": "Peer_Section", + "items": { + "$ref": "#/definitions/peer_section" + } + }, + "performance_options": { + "type": "object", + "properties": { + "busy_polling": { + "type": "boolean" + }, + "max_spread_checks": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "maxcompcpuusage": { + "type": "integer", + "x-display-name": "Maximum HAProxy CPU usage" + }, + "maxcomprate": { + "type": "integer", + "x-display-name": "Maximum per-process input compression rate" + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections" + }, + "maxconnrate": { + "type": "integer", + "x-display-name": "Maximum per-process number of concurrent connections" + }, + "maxpipes": { + "type": "integer", + "x-display-name": "Maximum per-process number of pipes" + }, + "maxsessrate": { + "type": "integer", + "x-display-name": "Maximum per-process number of sessions per second" + }, + "maxzlibmem": { + "type": "integer", + "x-display-name": "Maximum amount of RAM in megabytes per process usable by the zlib" + }, + "noepoll": { + "type": "boolean", + "x-display-name": "Disable the use of the \"epoll\" event polling system on Linux" + }, + "noevports": { + "type": "boolean", + "x-display-name": "Disable the use of the event ports event polling system on SunOS system derived from Solaris 10 and later" + }, + "nogetaddrinfo": { + "type": "boolean", + "x-display-name": "Disable the use of getaddrinfo for name resolving" + }, + "nokqueue": { + "type": "boolean", + "x-display-name": "Disable the use of the \"kqueue\" event polling system on BSD" + }, + "noktls": { + "type": "boolean", + "x-display-name": "Disables the use of ktls. It is equivalent to the command line argument \"-dT\"" + }, + "nopoll": { + "type": "boolean", + "x-display-name": "Disable the use of the \"poll\" event polling system" + }, + "noreuseport": { + "type": "boolean", + "x-display-name": "Disable the use of SO_REUSEPORT" + }, + "nosplice": { + "type": "boolean", + "x-display-name": "Disable the use of kernel tcp splicing between sockets on Linux" + }, + "profiling_memory": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Enable or disables per-function memory profiling" + }, + "profiling_tasks": { + "type": "string", + "enum": [ + "auto", + "enabled", + "disabled" + ], + "x-display-name": "Enable or disables per-task CPU profiling" + }, + "server_state_base": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Server State Base" + }, + "server_state_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Server State File" + }, + "spread_checks": { + "type": "integer", + "x-display-name": "Add some randomness in the check interval" + }, + "thread_hard_limit": { + "type": "integer", + "x-nullable": true + } + } + }, + "persist_rule": { + "type": "object", + "required": [ + "type" + ], + "properties": { + "rdp_cookie_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "rdp-cookie" + } + }, + "x-display-name": "Rdp Cookie Name" + }, + "type": { + "type": "string", + "enum": [ + "rdp-cookie" + ] + } + } + }, + "pgsql_check_params": { + "type": "object", + "properties": { + "username": { + "type": "string" + } + } + }, + "process_info": { + "description": "General HAProxy process information", + "type": "object", + "title": "HAProxy Information", + "properties": { + "error": { + "type": "string" + }, + "info": { + "$ref": "#/definitions/process_info_item" + }, + "runtimeAPI": { + "type": "string" + } + }, + "x-omitempty": true + }, + "process_info_item": { + "type": "object", + "properties": { + "active_peers": { + "type": "integer", + "x-nullable": true + }, + "busy_polling": { + "type": "integer", + "x-nullable": true + }, + "bytes_out_rate": { + "type": "integer", + "x-nullable": true + }, + "compress_bps_in": { + "type": "integer", + "x-nullable": true + }, + "compress_bps_out": { + "type": "integer", + "x-nullable": true + }, + "compress_bps_rate_lim": { + "type": "integer", + "x-nullable": true + }, + "conn_rate": { + "type": "integer", + "x-nullable": true + }, + "conn_rate_limit": { + "type": "integer", + "x-nullable": true + }, + "connected_peers": { + "type": "integer", + "x-nullable": true + }, + "cum_conns": { + "type": "integer", + "x-nullable": true + }, + "cum_req": { + "type": "integer", + "x-nullable": true + }, + "cum_ssl_conns": { + "type": "integer", + "x-nullable": true + }, + "curr_conns": { + "type": "integer", + "x-nullable": true + }, + "curr_ssl_conns": { + "type": "integer", + "x-nullable": true + }, + "dropped_logs": { + "type": "integer", + "x-nullable": true + }, + "failed_resolutions": { + "type": "integer", + "x-nullable": true + }, + "hard_max_conn": { + "type": "integer", + "x-nullable": true + }, + "idle_pct": { + "type": "integer", + "x-nullable": true + }, + "jobs": { + "type": "integer", + "x-nullable": true + }, + "listeners": { + "type": "integer", + "x-nullable": true + }, + "max_conn": { + "type": "integer", + "x-nullable": true + }, + "max_conn_rate": { + "type": "integer", + "x-nullable": true + }, + "max_pipes": { + "type": "integer", + "x-nullable": true + }, + "max_sess_rate": { + "type": "integer", + "x-nullable": true + }, + "max_sock": { + "type": "integer", + "x-nullable": true + }, + "max_ssl_conns": { + "type": "integer", + "x-nullable": true + }, + "max_ssl_rate": { + "type": "integer", + "x-nullable": true + }, + "max_zlib_mem_usage": { + "type": "integer", + "x-nullable": true + }, + "mem_max_mb": { + "type": "integer", + "x-nullable": true + }, + "nbthread": { + "description": "Number of threads", + "type": "integer", + "x-display-name": "Number of Threads", + "x-nullable": true + }, + "node": { + "type": "string" + }, + "pid": { + "description": "Process id of the replying worker process", + "type": "integer", + "x-display-name": "PID", + "x-nullable": true + }, + "pipes_free": { + "type": "integer", + "x-nullable": true + }, + "pipes_used": { + "type": "integer", + "x-nullable": true + }, + "pool_alloc_mb": { + "type": "integer", + "x-nullable": true + }, + "pool_failed": { + "type": "integer", + "x-nullable": true + }, + "pool_used_mb": { + "type": "integer", + "x-nullable": true + }, + "process_num": { + "description": "Process number", + "type": "integer", + "x-display-name": "Process Number", + "x-nullable": true + }, + "processes": { + "description": "Number of spawned processes", + "type": "integer", + "x-display-name": "Number of processes", + "x-nullable": true + }, + "release_date": { + "description": "HAProxy version release date", + "type": "string", + "format": "date" + }, + "run_queue": { + "type": "integer", + "x-nullable": true + }, + "sess_rate": { + "type": "integer", + "x-nullable": true + }, + "sess_rate_limit": { + "type": "integer", + "x-nullable": true + }, + "ssl_backend_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_backend_max_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_cache_lookups": { + "type": "integer", + "x-nullable": true + }, + "ssl_cache_misses": { + "type": "integer", + "x-nullable": true + }, + "ssl_frontend_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_frontend_max_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_frontend_session_reuse": { + "type": "integer", + "x-nullable": true + }, + "ssl_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_rate_limit": { + "type": "integer", + "x-nullable": true + }, + "stopping": { + "type": "integer", + "x-nullable": true + }, + "tasks": { + "type": "integer", + "x-nullable": true + }, + "total_bytes_out": { + "type": "integer", + "x-nullable": true + }, + "ulimit_n": { + "type": "integer", + "x-nullable": true + }, + "unstoppable": { + "type": "integer", + "x-nullable": true + }, + "uptime": { + "description": "HAProxy uptime in s", + "type": "integer", + "x-nullable": true + }, + "version": { + "description": "HAProxy version string", + "type": "string" + }, + "zlib_mem_usage": { + "type": "integer", + "x-nullable": true + } + } + }, + "program": { + "description": "HAProxy program configuration", + "type": "object", + "title": "Program", + "required": [ + "name", + "command" + ], + "properties": { + "command": { + "description": "The command to be run, with flags and options.", + "type": "string" + }, + "group": { + "description": "The group to run the command as, if different than the HAProxy group.", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "start-on-reload": { + "description": "HAProxy stops and recreates child programs at reload.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "user": { + "description": "The user to run the command as, if different than the HAProxy user.", + "type": "string" + } + }, + "example": { + "command": "spoa-mirror --runtime 0 --mirror-url http://test.local", + "group": "mygroupname", + "name": "mirror", + "start-on-reload": "enabled", + "user": "myusername" + } + }, + "programs": { + "type": "array", + "items": { + "$ref": "#/definitions/program" + } + }, + "quic_initial_rule": { + "description": "QUIC Initial configuration", + "type": "object", + "title": "QUIC Initial", + "required": [ + "type" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "type": { + "type": "string", + "enum": [ + "reject", + "accept", + "send-retry", + "dgram-drop" + ], + "x-nullable": false + } + }, + "additionalProperties": false, + "x-go-name": "QUICInitialRule", + "example": { + "type": "reject" + } + }, + "quic_initial_rules": { + "type": "array", + "title": "QUIC Initials Array", + "items": { + "$ref": "#/definitions/quic_initial_rule" + }, + "x-go-name": "QUICInitialRules" + }, + "redispatch": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "interval": { + "type": "integer", + "x-nullable": true + } + } + }, + "reload": { + "description": "HAProxy reload", + "type": "object", + "title": "HAProxy reload", + "properties": { + "id": { + "type": "string", + "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$" + }, + "reload_timestamp": { + "type": "integer" + }, + "response": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "failed", + "in_progress", + "succeeded" + ] + } + }, + "example": { + "id": "2019-01-03-44", + "status": "in_progress" + } + }, + "reloads": { + "description": "HAProxy reloads array", + "type": "array", + "title": "HAProxy Reloads Array", + "items": { + "$ref": "#/definitions/reload" + } + }, + "resolver": { + "description": "Resolver with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/resolver_base" + }, + { + "type": "object", + "properties": { + "nameservers": { + "additionalProperties": { + "$ref": "#/definitions/nameserver" + } + } + } + } + ], + "x-go-name": "Resolver" + }, + "resolver_base": { + "description": "Runtime DNS configuration", + "type": "object", + "title": "Resolver Base", + "required": [ + "name" + ], + "properties": { + "accepted_payload_size": { + "type": "integer", + "maximum": 8192, + "minimum": 512 + }, + "hold_nx": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_obsolete": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_other": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_refused": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_valid": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "parse-resolv-conf": { + "type": "boolean" + }, + "resolve_retries": { + "type": "integer", + "minimum": 1 + }, + "timeout_resolve": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": false + }, + "timeout_retry": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": false + } + } + }, + "resolvers": { + "description": "HAProxy resolvers array", + "type": "array", + "title": "Resolvers", + "items": { + "$ref": "#/definitions/resolver" + } + }, + "return_header": { + "type": "object", + "required": [ + "name", + "fmt" + ], + "properties": { + "fmt": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "x-go-name": "ReturnHeader" + }, + "ring": { + "description": "Ring with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/ring_base" + }, + { + "type": "object", + "properties": { + "servers": { + "additionalProperties": { + "$ref": "#/definitions/server" + } + } + } + } + ], + "x-go-name": "Ring" + }, + "ring_base": { + "description": "HAProxy ring configuration", + "type": "object", + "title": "Ring Base", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "x-display-name": "The description is an optional description string of the ring" + }, + "format": { + "type": "string", + "enum": [ + "iso", + "local", + "raw", + "rfc3164", + "rfc5424", + "short", + "priority", + "timed" + ], + "x-display-name": "Format used to store events into the ring buffer" + }, + "maxlen": { + "type": "integer", + "x-display-name": "The maximum length of an event message stored into the ring", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "size": { + "type": "integer", + "x-display-name": "Optional size in bytes for the ring-buffer", + "x-nullable": true, + "x-size": true + }, + "timeout_connect": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "timeout_server": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + } + }, + "additionalProperties": false + }, + "rings": { + "description": "HAProxy rings array", + "type": "array", + "title": "Rings", + "items": { + "$ref": "#/definitions/ring" + } + }, + "runtime_add_server": { + "description": "Settable properties when adding a new server using HAProxy's runtime.", + "type": "object", + "title": "Runtime Add Server", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false, + "readOnly": true + }, + "agent-addr": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "agent-check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "agent-port": { + "required": true + } + } + }, + "agent-inter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "agent-port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "agent-send": { + "type": "string" + }, + "allow_0rtt": { + "type": "boolean" + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "ALPN Protocols" + }, + "backup": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "check-ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check_alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Protocols" + }, + "check_proto": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Name" + }, + "check_via_socks4": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ciphers": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "ciphersuites": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "crl_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "downinter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "error_limit": { + "type": "integer", + "x-display-name": "Healthcheck error limit", + "x-nullable": true + }, + "fall": { + "type": "integer", + "x-display-name": "Nr. of consecutive failed checks", + "x-nullable": true + }, + "fastinter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "force_sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "health_check_address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "health_check_port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "id": { + "type": "string", + "readOnly": true + }, + "inter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "maintenance": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Concurrent Connections", + "x-nullable": true + }, + "maxqueue": { + "type": "integer", + "x-display-name": "Max Number of Connections", + "x-nullable": true + }, + "minconn": { + "type": "integer", + "x-nullable": true + }, + "name": { + "type": "string", + "readOnly": true + }, + "no_sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "npn": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "observe": { + "type": "string", + "enum": [ + "layer4", + "layer7" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "on-error": { + "type": "string", + "enum": [ + "fastinter", + "fail-check", + "sudden-death", + "mark-down" + ] + }, + "on-marked-down": { + "type": "string", + "enum": [ + "shutdown-sessions" + ] + }, + "on-marked-up": { + "type": "string", + "enum": [ + "shutdown-backup-sessions" + ] + }, + "pool_low_conn": { + "type": "integer", + "x-nullable": true + }, + "pool_max_conn": { + "type": "integer", + "x-nullable": true + }, + "pool_purge_delay": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "readOnly": true + }, + "proto": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "proxy-v2-options": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "authority", + "cert-cn", + "cert-key", + "cert-sig", + "crc32c", + "ssl", + "ssl-cipher", + "unique-id" + ] + }, + "x-omitempty": true + }, + "rise": { + "type": "integer", + "x-nullable": true + }, + "send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send-proxy-v2": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl_cn": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "slowstart": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "source": { + "type": "string" + }, + "ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ssl_cafile": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": "enabled" + } + }, + "x-display-name": "SSL CA File" + }, + "ssl_certificate": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "ssl_max_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_min_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_reuse": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tfo": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tls_tickets": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "track": { + "type": "string" + }, + "verify": { + "type": "string", + "enum": [ + "none", + "required" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "verifyhost": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + }, + "verify": { + "value": "required" + } + } + }, + "weight": { + "type": "integer", + "x-nullable": true + }, + "ws": { + "type": "string", + "enum": [ + "auto", + "h1", + "h2" + ], + "x-display-name": "Relaying websocket stream protocol" + } + } + }, + "runtime_server": { + "description": "Runtime transient server properties", + "type": "object", + "title": "Runtime Server", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false, + "readOnly": true + }, + "admin_state": { + "type": "string", + "enum": [ + "ready", + "maint", + "drain" + ] + }, + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string", + "readOnly": true + }, + "operational_state": { + "type": "string", + "enum": [ + "up", + "down", + "stopping" + ] + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "readOnly": true + } + }, + "example": { + "address": "127.0.0.5", + "admin_state": "ready", + "operational_state": "up", + "port": 80, + "server_id": 1, + "server_name": "web_server" + } + }, + "runtime_servers": { + "description": "HAProxy runtime servers array", + "type": "array", + "title": "HAProxy Runtime Servers Array", + "items": { + "$ref": "#/definitions/runtime_server" + } + }, + "server": { + "description": "HAProxy backend server configuration", + "title": "Server", + "allOf": [ + { + "$ref": "#/definitions/server_params" + }, + { + "type": "object", + "required": [ + "name", + "address" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "id": { + "type": "integer", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + } + } + } + ], + "additionalProperties": false, + "example": { + "address": "10.1.1.1", + "name": "www", + "port": 8080 + } + }, + "server_params": { + "type": "object", + "properties": { + "agent-addr": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "agent-check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "agent-port": { + "required": true + } + } + }, + "agent-inter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "agent-port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "agent-send": { + "type": "string" + }, + "allow_0rtt": { + "type": "boolean" + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "ALPN Protocols" + }, + "backup": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "cc": { + "type": "string", + "x-display-name": "TCP Congestion Control Algorithm" + }, + "check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-pool-conn-name": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "check-reuse-pool": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "check-ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check_alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Protocols" + }, + "check_proto": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Name" + }, + "check_sni_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check_via_socks4": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ciphers": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "ciphersuites": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "client_sigalgs": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "cookie": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "crl_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "curves": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "downinter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "error_limit": { + "type": "integer", + "x-display-name": "Error count" + }, + "fall": { + "type": "integer", + "x-display-name": "Nr. of consecutive failed checks", + "x-nullable": true + }, + "fastinter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "force_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv13": { + "description": "This field is deprecated in favor of tlsv13, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "guid": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "hash_key": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "health_check_address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "health_check_port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "idle_ping": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "init-addr": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true + }, + "init-state": { + "type": "string", + "enum": [ + "fully-up", + "up", + "down", + "fully-down" + ] + }, + "inter": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "ktls": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-display-name": "Enables or disables ktls for those sockets. If enabled, kTLS will be used if the kernel supports it and the cipher is compatible.\nThis is only available on Linux kernel 4.17 and above.\nEXPERIMENTAL OPTION." + }, + "log-bufsize": { + "type": "integer", + "x-nullable": true + }, + "log_proto": { + "type": "string", + "enum": [ + "legacy", + "octet-count" + ] + }, + "maintenance": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "max_reuse": { + "type": "integer", + "x-nullable": true + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Concurrent Connections", + "x-nullable": true + }, + "maxqueue": { + "type": "integer", + "x-display-name": "Max Number of Connections", + "x-nullable": true + }, + "minconn": { + "type": "integer", + "x-nullable": true + }, + "namespace": { + "type": "string" + }, + "no_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_tlsv13": { + "description": "This field is deprecated in favor of force_tlsv13, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_verifyhost": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "npn": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "observe": { + "type": "string", + "enum": [ + "layer4", + "layer7" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "on-error": { + "type": "string", + "enum": [ + "fastinter", + "fail-check", + "sudden-death", + "mark-down" + ] + }, + "on-marked-down": { + "type": "string", + "enum": [ + "shutdown-sessions" + ] + }, + "on-marked-up": { + "type": "string", + "enum": [ + "shutdown-backup-sessions" + ] + }, + "pool_conn_name": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "pool_low_conn": { + "type": "integer", + "x-nullable": true + }, + "pool_max_conn": { + "type": "integer", + "x-nullable": true + }, + "pool_purge_delay": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "proto": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "proxy-v2-options": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "authority", + "cert-cn", + "cert-key", + "cert-sig", + "crc32c", + "ssl", + "ssl-cipher", + "unique-id" + ] + }, + "x-omitempty": true + }, + "redir": { + "type": "string", + "x-display-name": "Prefix" + }, + "renegotiate": { + "description": "Toggles the secure renegotiation mechanism for an SSL backend.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "resolve-net": { + "type": "string", + "pattern": "^([A-Za-z0-9.:/]+)(,[A-Za-z0-9.:/]+)*$" + }, + "resolve-prefer": { + "type": "string", + "enum": [ + "ipv4", + "ipv6" + ] + }, + "resolve_opts": { + "type": "string", + "pattern": "^(allow-dup-ip|ignore-weight|prevent-dup-ip)(,(allow-dup-ip|ignore-weight|prevent-dup-ip))*$" + }, + "resolvers": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dynamic-enum": { + "operation": "getResolvers", + "property": "name" + } + }, + "rise": { + "type": "integer", + "x-nullable": true + }, + "send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send-proxy-v2": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl_cn": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "set-proxy-v2-tlv-fmt": { + "type": "object", + "required": [ + "id", + "value" + ], + "properties": { + "id": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "shard": { + "type": "integer" + }, + "sigalgs": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "slowstart": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "sni_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "socks4": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "check-via-socks4": { + "required": true + } + } + }, + "source": { + "type": "string" + }, + "ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ssl_cafile": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": "enabled" + } + }, + "x-display-name": "SSL CA File" + }, + "ssl_certificate": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "ssl_max_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_min_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_reuse": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "stick": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "strict-maxconn": { + "type": "boolean" + }, + "tcp_md5sig": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "tcp_ut": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "tfo": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tls_tickets": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "track": { + "type": "string" + }, + "verify": { + "type": "string", + "enum": [ + "none", + "required" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "verifyhost": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + }, + "verify": { + "value": "required" + } + } + }, + "weight": { + "type": "integer", + "x-nullable": true + }, + "ws": { + "type": "string", + "enum": [ + "auto", + "h1", + "h2" + ], + "x-display-name": "Relaying websocket stream protocol" + } + } + }, + "server_switching_rule": { + "description": "HAProxy server switching rule configuration (corresponds to use-server directive)", + "type": "object", + "title": "Server Switching Rule", + "required": [ + "target_server" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "target_server": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dynamic-enum": { + "operation": "getServers", + "property": "name" + }, + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "cond": "if", + "cond_test": "{ req_ssl_sni -i www.example.com }", + "target_server": "www" + } + }, + "server_switching_rules": { + "description": "HAProxy backend server switching rules array (corresponds to use-server directives)", + "type": "array", + "title": "Server Switching Rules Array", + "items": { + "$ref": "#/definitions/server_switching_rule" + } + }, + "server_template": { + "description": "Set a template to initialize servers with shared parameters.", + "title": "Server template", + "allOf": [ + { + "$ref": "#/definitions/server_params" + }, + { + "type": "object", + "required": [ + "prefix", + "num_or_range", + "fqdn" + ], + "properties": { + "fqdn": { + "type": "string", + "x-nullable": false + }, + "id": { + "type": "integer", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "num_or_range": { + "type": "string", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "prefix": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + } + } + } + ], + "additionalProperties": false, + "example": { + "fqdn": "google.com", + "num_or_range": "1-3", + "port": 80, + "prefix": "srv" + } + }, + "server_templates": { + "description": "HAProxy backend server templates array", + "type": "array", + "title": "Server templates", + "items": { + "$ref": "#/definitions/server_template" + } + }, + "servers": { + "description": "HAProxy backend servers array", + "type": "array", + "title": "Servers", + "items": { + "$ref": "#/definitions/server" + } + }, + "site": { + "description": "Site configuration. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration\nendpoints.\n", + "type": "object", + "title": "Site", + "required": [ + "name" + ], + "properties": { + "farms": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "use_as" + ], + "properties": { + "balance": { + "$ref": "#/definitions/balance" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-dependency": { + "use_as": { + "required": true, + "value": "conditional" + } + }, + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "use_as": { + "required": true, + "value": "conditional" + } + }, + "x-display-name": "Condition Test" + }, + "forwardfor": { + "$ref": "#/definitions/forwardfor" + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp" + ] + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "servers": { + "type": "array", + "items": { + "$ref": "#/definitions/server" + }, + "x-omitempty": true + }, + "use_as": { + "type": "string", + "enum": [ + "default", + "conditional" + ], + "x-nullable": false + } + }, + "x-go-name": "SiteFarm" + }, + "x-omitempty": true + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "service": { + "type": "object", + "properties": { + "http_connection_mode": { + "type": "string", + "enum": [ + "http-tunnel", + "httpclose", + "forced-close", + "http-server-close", + "http-keep-alive" + ], + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "HTTP Connection Mode" + }, + "listeners": { + "type": "array", + "items": { + "$ref": "#/definitions/bind" + }, + "x-omitempty": true + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections", + "x-nullable": true + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp" + ] + } + } + } + }, + "additionalProperties": false, + "example": { + "farms": [ + { + "balance": { + "algorithm": "roundrobin" + }, + "mode": "http", + "name": "www_backend", + "servers": [ + { + "address": "127.0.1.1", + "name": "www_server", + "port": 4567 + }, + { + "address": "127.0.1.2", + "name": "www_server_new", + "port": 4567 + } + ], + "use_as": "default" + } + ], + "name": "test_site", + "service": { + "http_connection_mode": "httpclose", + "maxconn": 2000, + "mode": "http" + } + } + }, + "sites": { + "description": "Sites array. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration\nendpoints.\n", + "type": "array", + "title": "Sites", + "items": { + "$ref": "#/definitions/site" + } + }, + "smtpchk_params": { + "type": "object", + "properties": { + "domain": { + "type": "string" + }, + "hello": { + "type": "string" + } + } + }, + "source": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string" + }, + "address_second": { + "type": "string" + }, + "hdr": { + "type": "string", + "x-dependency": { + "usesrc": { + "value": "hdr_ip" + } + } + }, + "interface": { + "type": "string" + }, + "occ": { + "type": "string", + "x-dependency": { + "usesrc": { + "value": "hdr_ip" + } + } + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "port_second": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "usesrc": { + "type": "string", + "enum": [ + "address", + "client", + "clientip", + "hdr_ip" + ] + } + } + }, + "spoe_agent": { + "description": "SPOE agent configuration", + "type": "object", + "title": "SPOE agent", + "required": [ + "name" + ], + "properties": { + "async": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "continue-on-error": { + "type": "string", + "enum": [ + "enabled" + ] + }, + "dontlog-normal": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "engine-name": { + "type": "string" + }, + "force-set-var": { + "type": "string", + "enum": [ + "enabled" + ] + }, + "groups": { + "type": "string" + }, + "hello_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true + }, + "idle_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true + }, + "log": { + "$ref": "#/definitions/log_targets" + }, + "max-frame-size": { + "type": "integer" + }, + "max-waiting-frames": { + "type": "integer" + }, + "maxconnrate": { + "type": "integer" + }, + "maxerrrate": { + "type": "integer" + }, + "messages": { + "type": "string" + }, + "name": { + "type": "string" + }, + "option_set-on-error": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.]+$" + }, + "option_set-process-time": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.]+$" + }, + "option_set-total-time": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.]+$" + }, + "option_var-prefix": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.]+$" + }, + "pipelining": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "processing_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true + }, + "register-var-names": { + "type": "string" + }, + "send-frag-payload": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "use-backend": { + "type": "string" + } + } + }, + "spoe_agents": { + "description": "SPOE Agents of one scope in SPOE file", + "type": "array", + "title": "SPOE Agents", + "items": { + "$ref": "#/definitions/spoe_agent" + } + }, + "spoe_files": { + "description": "SPOE files", + "type": "array", + "title": "SPOE files", + "items": { + "type": "string" + }, + "x-omitempty": true + }, + "spoe_group": { + "description": "SPOE group section configuration", + "type": "object", + "title": "SPOE group", + "required": [ + "name" + ], + "properties": { + "messages": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "spoe_groups": { + "description": "SPOE Groups of one scope in SPOE file", + "type": "array", + "title": "SPOE Groups", + "items": { + "$ref": "#/definitions/spoe_group" + } + }, + "spoe_message": { + "description": "SPOE message section configuration", + "type": "object", + "title": "SPOE message", + "required": [ + "name" + ], + "properties": { + "acl": { + "$ref": "#/definitions/acls" + }, + "args": { + "type": "string" + }, + "event": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + }, + "name": { + "type": "string", + "enum": [ + "on-backend-http-request", + "on-backend-tcp-request", + "on-client-session", + "on-frontend-http-request", + "on-frontend-tcp-request", + "on-http-response", + "on-server-session", + "on-tcp-response" + ] + } + } + }, + "name": { + "type": "string" + } + } + }, + "spoe_messages": { + "description": "SPOE Messages of one scope in SPOE file", + "type": "array", + "title": "SPOE Messages", + "items": { + "$ref": "#/definitions/spoe_message" + } + }, + "spoe_scope": { + "description": "SPOE scope name", + "type": "string", + "title": "SPOE scope" + }, + "spoe_scopes": { + "description": "All SPOE Scopes", + "type": "array", + "title": "SPOE Scopes", + "items": { + "$ref": "#/definitions/spoe_scope" + } + }, + "spoe_transaction": { + "description": "SPOE configuration transaction", + "type": "object", + "title": "SPOE configuration transaction", + "properties": { + "_version": { + "type": "integer" + }, + "id": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "status": { + "type": "string", + "enum": [ + "failed", + "in_progress", + "success" + ] + } + }, + "example": { + "_version": 2, + "id": "273e3385-2d0c-4fb1-aa27-93cbb31ff203", + "status": "in_progress" + } + }, + "spoe_transactions": { + "description": "SPOE Configuration transactions array", + "type": "array", + "title": "SPOE Transactions array", + "items": { + "$ref": "#/definitions/spoe_transaction" + } + }, + "ssl_ca_file": { + "description": "A file containing one or more SSL/TLS certificates and keys", + "type": "object", + "title": "SSL File", + "properties": { + "count": { + "type": "string" + }, + "file": { + "type": "string" + }, + "storage_name": { + "type": "string" + } + } + }, + "ssl_ca_files": { + "description": "Array of SSL CA files", + "type": "array", + "title": "SSL CA Files Array", + "items": { + "$ref": "#/definitions/ssl_ca_file" + } + }, + "ssl_certificate": { + "description": "A file containing one or more SSL/TLS certificates and keys", + "type": "object", + "title": "SSL File", + "properties": { + "algorithm": { + "type": "string" + }, + "authority_key_id": { + "type": "string" + }, + "chain_issuer": { + "type": "string", + "x-omitempty": true + }, + "chain_subject": { + "type": "string", + "x-omitempty": true + }, + "description": { + "type": "string" + }, + "domains": { + "type": "string", + "x-omitempty": true, + "readOnly": true + }, + "file": { + "type": "string" + }, + "ip_addresses": { + "type": "string", + "x-omitempty": true, + "readOnly": true + }, + "issuers": { + "type": "string", + "x-omitempty": true, + "readOnly": true + }, + "not_after": { + "type": "string", + "format": "date-time", + "x-go-custom-tag": "gorm:\"type:timestamp with time zone\"", + "x-nullable": true, + "readOnly": true + }, + "not_before": { + "type": "string", + "format": "date-time", + "x-go-custom-tag": "gorm:\"type:timestamp with time zone\"", + "x-nullable": true, + "readOnly": true + }, + "serial": { + "type": "string" + }, + "sha1_finger_print": { + "type": "string" + }, + "sha256_finger_print": { + "type": "string" + }, + "size": { + "description": "File size in bytes.", + "type": "integer", + "x-nullable": true, + "readOnly": true + }, + "status": { + "description": "Only set when using the runtime API.", + "type": "string", + "x-omitempty": true, + "readOnly": true + }, + "storage_name": { + "type": "string" + }, + "subject": { + "type": "string" + }, + "subject_alternative_names": { + "type": "string" + }, + "subject_key_id": { + "type": "string" + } + } + }, + "ssl_certificate_id": { + "description": "SSL Certificate ID", + "type": "object", + "title": "SSL Certificate ID", + "properties": { + "certificate_id": { + "type": "object", + "properties": { + "hash_algorithm": { + "type": "string" + }, + "issuer_key_hash": { + "type": "string" + }, + "issuer_name_hash": { + "type": "string" + }, + "serial_number": { + "type": "string" + } + }, + "x-go-name": "CertificateId" + }, + "certificate_id_key": { + "type": "string" + }, + "certificate_path": { + "type": "string" + } + } + }, + "ssl_certificates": { + "description": "Array of ssl certificate files", + "type": "array", + "title": "SSL Certificate Files Array", + "items": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "ssl_crl": { + "description": "A file containing one or more SSL/TLS CRLs", + "type": "object", + "title": "SSL CRL File", + "properties": { + "description": { + "type": "string" + }, + "file": { + "type": "string" + }, + "storage_name": { + "type": "string" + } + } + }, + "ssl_crl_entries": { + "type": "array", + "items": { + "$ref": "#/definitions/ssl_crl_entry" + } + }, + "ssl_crl_entry": { + "description": "A certificate revocation list entry.", + "type": "object", + "title": "One CRL Entry", + "properties": { + "issuer": { + "type": "string" + }, + "last_update": { + "type": "string", + "format": "date" + }, + "next_update": { + "type": "string", + "format": "date" + }, + "revoked_certificates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "revocation_date": { + "type": "string", + "format": "date" + }, + "serial_number": { + "type": "string" + } + }, + "x-go-name": "RevokedCertificates" + }, + "x-omitempty": true + }, + "signature_algorithm": { + "type": "string" + }, + "status": { + "type": "string" + }, + "storage_name": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "ssl_crls": { + "description": "Array of ssl crl files", + "type": "array", + "title": "SSL CRL Files Array", + "items": { + "$ref": "#/definitions/ssl_crl" + } + }, + "ssl_crt_list": { + "description": "SSL Crt List file", + "type": "object", + "title": "SSL Crt List", + "properties": { + "file": { + "type": "string" + } + } + }, + "ssl_crt_list_entries": { + "description": "Array of SSL Crt List Entry", + "type": "array", + "title": "SSL Crt List Entry Array", + "items": { + "$ref": "#/definitions/ssl_crt_list_entry" + } + }, + "ssl_crt_list_entry": { + "description": "SSL Crt List Entry", + "type": "object", + "title": "SSL Crt List Entry", + "properties": { + "file": { + "type": "string" + }, + "line_number": { + "type": "integer", + "x-nullable": false + }, + "sni_filter": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "SNIFilter", + "x-omitempty": true + }, + "ssl_bind_config": { + "type": "string", + "x-go-name": "SSLBindConfig" + } + } + }, + "ssl_crt_list_file": { + "description": "A file referencing one or more certificates with their configuration.", + "type": "object", + "title": "SSL CRT List File", + "properties": { + "description": { + "type": "string" + }, + "file": { + "type": "string" + }, + "size": { + "description": "File size in bytes.", + "type": "integer", + "x-nullable": true + }, + "storage_name": { + "type": "string" + } + } + }, + "ssl_crt_list_files": { + "description": "List of SSL certificate list files (crt-list)", + "type": "array", + "title": "List of SSL certificate list files", + "items": { + "$ref": "#/definitions/ssl_crt_list_file" + } + }, + "ssl_crt_lists": { + "description": "Array of SSL Crt List", + "type": "array", + "title": "SSL Crt List Array", + "items": { + "$ref": "#/definitions/ssl_crt_list" + } + }, + "ssl_front_use": { + "description": "Assign a certificate to the current frontend", + "type": "object", + "title": "SSL Frontend Use certificate", + "required": [ + "certificate" + ], + "properties": { + "allow_0rtt": { + "type": "boolean" + }, + "alpn": { + "type": "string", + "x-display-name": "ALPN Protocols" + }, + "ca_file": { + "type": "string" + }, + "certificate": { + "description": "Certificate filename", + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "ciphers": { + "type": "string" + }, + "ciphersuites": { + "type": "string" + }, + "client_sigalgs": { + "type": "string" + }, + "crl_file": { + "type": "string" + }, + "curves": { + "type": "string" + }, + "ecdhe": { + "type": "string" + }, + "issuer": { + "description": "OCSP issuer filename", + "type": "string" + }, + "key": { + "description": "Private key filename", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "no_alpn": { + "type": "boolean" + }, + "no_ca_names": { + "type": "boolean" + }, + "npn": { + "type": "string" + }, + "ocsp": { + "description": "OCSP response filename", + "type": "string" + }, + "ocsp_update": { + "description": "Automatic OCSP response update", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "sctl": { + "description": "Signed Certificate Timestamp List filename", + "type": "string" + }, + "sigalgs": { + "type": "string" + }, + "ssl_max_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_min_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "verify": { + "type": "string", + "enum": [ + "none", + "optional", + "required" + ] + } + }, + "x-go-name": "SSLFrontUse" + }, + "ssl_front_uses": { + "type": "array", + "items": { + "$ref": "#/definitions/ssl_front_use" + }, + "x-go-name": "SSLFrontUses", + "x-omitempty": true + }, + "ssl_ocsp_response": { + "description": "SSL OCSP Response", + "type": "object", + "title": "SSL OCSP Response", + "properties": { + "base64_response": { + "type": "string" + }, + "ocsp_response_status": { + "type": "string" + }, + "produced_at": { + "type": "string", + "format": "date" + }, + "responder_id": { + "type": "array", + "items": { + "type": "string" + }, + "x-omitempty": true + }, + "response_type": { + "type": "string" + }, + "responses": { + "type": "object", + "properties": { + "cert_status": { + "type": "string" + }, + "certificate_id": { + "$ref": "#/definitions/ssl_certificate_id/properties/certificate_id" + }, + "next_update": { + "type": "string", + "format": "date" + }, + "revocation_reason": { + "type": "string", + "x-omitempty": true + }, + "this_update": { + "type": "string", + "format": "date" + } + }, + "x-go-name": "OCSPResponses" + }, + "version": { + "type": "string" + } + } + }, + "ssl_ocsp_update": { + "description": "SSL OCSP Update", + "type": "object", + "title": "SSL OCSP Update", + "properties": { + "cert_id": { + "type": "string" + }, + "failures": { + "type": "integer" + }, + "last_update": { + "type": "string" + }, + "last_update_status": { + "type": "integer" + }, + "last_update_status_str": { + "type": "string" + }, + "next_update": { + "type": "string" + }, + "path": { + "type": "string" + }, + "successes": { + "type": "integer" + } + } + }, + "ssl_options": { + "type": "object", + "properties": { + "acme_scheduler": { + "type": "string", + "enum": [ + "auto", + "off" + ], + "x-display-name": "ACME Scheduler" + }, + "ca_base": { + "type": "string", + "x-display-name": "SSL CA Certificates Base Directory" + }, + "crt_base": { + "type": "string", + "x-display-name": "SSL Certificates Base Directory" + }, + "default_bind_ciphers": { + "type": "string", + "x-display-name": "SSL Default Bind Ciphers" + }, + "default_bind_ciphersuites": { + "type": "string", + "x-display-name": "SSL Default Bind Ciphersuites" + }, + "default_bind_client_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Bind Client Sigalgs" + }, + "default_bind_curves": { + "type": "string", + "x-display-name": "SSL Default Bind Curves" + }, + "default_bind_options": { + "type": "string", + "x-display-name": "SSL Default Bind Options" + }, + "default_bind_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Bind Sigalgs" + }, + "default_server_ciphers": { + "type": "string", + "x-display-name": "SSL Default Server Ciphers" + }, + "default_server_ciphersuites": { + "type": "string", + "x-display-name": "SSL Default Server Ciphersuites" + }, + "default_server_client_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Server Client Sigalgs" + }, + "default_server_curves": { + "type": "string", + "x-display-name": "SSL Default Server Curves" + }, + "default_server_options": { + "type": "string", + "x-display-name": "SSL Default Server Options" + }, + "default_server_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Server Sigalgs" + }, + "dh_param_file": { + "type": "string" + }, + "engines": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "algorithms": { + "type": "string", + "x-display-name": "Algorithms", + "x-nullable": true + }, + "name": { + "type": "string", + "x-display-name": "Name" + } + }, + "x-go-name": "SslEngine" + }, + "x-display-name": "SSL Engines", + "x-go-name": "SslEngines", + "x-omitempty": true + }, + "issuers_chain_path": { + "type": "string" + }, + "load_extra_files": { + "type": "string", + "x-display-name": "SSL Load Extra Files" + }, + "maxsslconn": { + "type": "integer", + "x-display-name": "Maximum per-process number of concurrent SSL connections" + }, + "maxsslrate": { + "type": "integer", + "x-display-name": "Maximum per-process number of SSL sessions per second" + }, + "mode_async": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Asynchronous TLS I/O operations" + }, + "passphrase_cmd": { + "type": "string" + }, + "propquery": { + "type": "string", + "x-display-name": "SSL Query String Property" + }, + "provider": { + "type": "string", + "x-display-name": "SSL Provider" + }, + "provider_path": { + "type": "string", + "x-display-name": "SSL Provider Path" + }, + "security_level": { + "type": "integer", + "maximum": 5, + "x-nullable": true + }, + "server_verify": { + "type": "string", + "enum": [ + "none", + "required" + ], + "x-display-name": "Verify server certificates" + }, + "skip_self_issued_ca": { + "type": "boolean", + "x-display-name": "Self issued CA, aka x509 root CA" + } + } + }, + "ssl_providers": { + "description": "SSL Providers", + "type": "object", + "title": "SSL Providers", + "properties": { + "providers": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "stats_auth": { + "type": "object", + "required": [ + "user", + "passwd" + ], + "properties": { + "passwd": { + "type": "string" + }, + "user": { + "type": "string" + } + } + }, + "stats_http_request": { + "type": "object", + "required": [ + "type" + ], + "properties": { + "cond": { + "type": "string" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + } + }, + "realm": { + "type": "string", + "x-dependency": { + "type": { + "value": "auth" + } + } + }, + "type": { + "type": "string", + "enum": [ + "allow", + "deny", + "auth" + ] + } + } + }, + "stats_options": { + "type": "object", + "properties": { + "stats_admin": { + "type": "boolean", + "x-display-name": "Stats Admin" + }, + "stats_admin_cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-dependency": { + "stats_admin": { + "required": true, + "value": true + } + }, + "x-display-name": "Stats Admin Condition" + }, + "stats_admin_cond_test": { + "type": "string", + "x-dependency": { + "stats_admin_cond": { + "required": true + } + }, + "x-display-name": "Stats Admin Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "stats_auths": { + "type": "array", + "items": { + "$ref": "#/definitions/stats_auth" + }, + "x-display-name": "Stats Auths", + "x-omitempty": true + }, + "stats_enable": { + "type": "boolean", + "x-display-name": "Stats Enable" + }, + "stats_hide_version": { + "type": "boolean", + "x-display-name": "Stats Hide Version" + }, + "stats_http_requests": { + "type": "array", + "items": { + "$ref": "#/definitions/stats_http_request" + }, + "x-display-name": "Stats HTTP Requests", + "x-omitempty": true + }, + "stats_maxconn": { + "type": "integer", + "minimum": 1 + }, + "stats_realm": { + "type": "boolean", + "x-display-name": "Stats Realm" + }, + "stats_realm_realm": { + "type": "string", + "x-dependency": { + "stats_realm": { + "required": true, + "value": true + } + }, + "x-nullable": true + }, + "stats_refresh_delay": { + "type": "integer", + "x-default-unit": "s", + "x-duration": true, + "x-nullable": true + }, + "stats_show_desc": { + "type": "string", + "x-nullable": true + }, + "stats_show_legends": { + "type": "boolean", + "x-display-name": "Stats Show Legends" + }, + "stats_show_modules": { + "type": "boolean", + "x-display-name": "Stats Show Modules" + }, + "stats_show_node_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true, + "x-omitempty": false + }, + "stats_uri_prefix": { + "type": "string", + "pattern": "^[^\\s]+$" + } + } + }, + "stick_rule": { + "description": "Define a pattern used to create an entry in a stickiness table or matching condition or associate a user to a server.", + "type": "object", + "title": "Stick Rule", + "required": [ + "type", + "pattern" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "pattern": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "table": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "type": { + "type": "string", + "enum": [ + "match", + "on", + "store-request", + "store-response" + ], + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "pattern": "src", + "type": "match" + } + }, + "stick_rules": { + "description": "HAProxy backend stick rules array (corresponds to stick store-request, stick match, stick on, stick store-response)", + "type": "array", + "title": "Stick Rules Array", + "items": { + "$ref": "#/definitions/stick_rule" + } + }, + "stick_table": { + "description": "Stick Table Information", + "type": "object", + "title": "Stick Table", + "properties": { + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { + "type": "string", + "enum": [ + "bytes_in_cnt", + "bytes_in_rate", + "bytes_out_cnt", + "bytes_out_rate", + "conn_cnt", + "conn_cur", + "conn_rate", + "glitch_cnt", + "glitch_rate", + "gpc", + "gpc_rate", + "gpc0", + "gpc0_rate", + "gpc1", + "gpc1_rate", + "gpt0", + "gpt", + "http_req_cnt", + "http_req_rate", + "http_err_cnt", + "http_err_rate", + "http_fail_cnt", + "http_fail_rate", + "server_id", + "sess_cnt", + "sess_rate" + ] + }, + "idx": { + "type": "integer", + "x-dependency": { + "field": { + "value": [ + "gpc", + "gpc_rate", + "gpt" + ] + } + } + }, + "period": { + "type": "integer", + "x-dependency": { + "type": { + "value": "rate" + } + } + }, + "type": { + "type": "string", + "enum": [ + "rate", + "counter" + ] + } + }, + "x-go-name": "StickTableField" + }, + "x-omitempty": true + }, + "name": { + "type": "string" + }, + "size": { + "type": "integer", + "x-nullable": true + }, + "type": { + "type": "string", + "enum": [ + "ip", + "ipv6", + "integer", + "string", + "binary" + ] + }, + "used": { + "type": "integer", + "x-nullable": true + } + } + }, + "stick_table_entries": { + "description": "Entries of one runtime stick table", + "type": "array", + "title": "Stick Tables Entries", + "items": { + "$ref": "#/definitions/stick_table_entry" + } + }, + "stick_table_entry": { + "description": "One entry in stick table", + "type": "object", + "title": "Stick Table Entry", + "properties": { + "bytes_in_cnt": { + "type": "integer", + "x-nullable": true + }, + "bytes_in_rate": { + "type": "integer", + "x-nullable": true + }, + "bytes_out_cnt": { + "type": "integer", + "x-nullable": true + }, + "bytes_out_rate": { + "type": "integer", + "x-nullable": true + }, + "conn_cnt": { + "type": "integer", + "x-nullable": true + }, + "conn_cur": { + "type": "integer", + "x-nullable": true + }, + "conn_rate": { + "type": "integer", + "x-nullable": true + }, + "exp": { + "type": "integer", + "x-nullable": true + }, + "glitch_cnt": { + "type": "integer", + "x-nullable": true + }, + "glitch_rate": { + "type": "integer", + "x-nullable": true + }, + "gpc": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { + "type": "integer", + "x-nullable": true + } + } + }, + "gpc0": { + "type": "integer", + "x-nullable": true + }, + "gpc0_rate": { + "type": "integer", + "x-nullable": true + }, + "gpc1": { + "type": "integer", + "x-nullable": true + }, + "gpc1_rate": { + "type": "integer", + "x-nullable": true + }, + "gpc_rate": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { + "type": "integer", + "x-nullable": true + } + } + }, + "gpt": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { + "type": "integer", + "x-nullable": true + } + } + }, + "gpt0": { + "type": "integer", + "x-nullable": true + }, + "http_err_cnt": { + "type": "integer", + "x-nullable": true + }, + "http_err_rate": { + "type": "integer", + "x-nullable": true + }, + "http_fail_cnt": { + "type": "integer", + "x-nullable": true + }, + "http_fail_rate": { + "type": "integer", + "x-nullable": true + }, + "http_req_cnt": { + "type": "integer", + "x-nullable": true + }, + "http_req_rate": { + "type": "integer", + "x-nullable": true + }, + "id": { + "type": "string" + }, + "key": { + "type": "string" + }, + "server_id": { + "type": "integer", + "x-nullable": true + }, + "sess_cnt": { + "type": "integer", + "x-nullable": true + }, + "sess_rate": { + "type": "integer", + "x-nullable": true + }, + "use": { + "type": "boolean" + } + } + }, + "stick_tables": { + "description": "Array of runtime stick tables", + "type": "array", + "title": "Stick Tables Array", + "items": { + "$ref": "#/definitions/stick_table" + } + }, + "table": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "expire": { + "type": "string", + "pattern": "^\\d+(ms|s|m|h|d)?$", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "x-nullable": false + }, + "no_purge": { + "type": "boolean", + "x-display-name": "No Purge" + }, + "recv_only": { + "type": "boolean", + "x-display-name": "Receive Only" + }, + "size": { + "type": "string", + "pattern": "^\\d+(k|K|m|M|g|G)?$", + "x-size": true + }, + "store": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "ip", + "integer", + "string", + "binary" + ] + }, + "type_len": { + "type": "integer", + "x-display-name": "Type", + "x-nullable": true + }, + "write_to": { + "type": "string", + "x-nullable": true + } + } + }, + "tables": { + "description": "HAProxy table array", + "type": "array", + "title": "Tables", + "items": { + "$ref": "#/definitions/table" + } + }, + "tcp_check": { + "type": "object", + "title": "TCP Check", + "required": [ + "action" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "comment", + "connect", + "expect", + "send", + "send-lf", + "send-binary", + "send-binary-lf", + "set-var", + "set-var-fmt", + "unset-var" + ], + "x-nullable": false + }, + "addr": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "value": "connect" + } + }, + "x-nullable": false + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "value": "connect" + } + }, + "x-display-name": "ALPN Protocols", + "x-nullable": false + }, + "check_comment": { + "type": "string", + "x-dependency": { + "action": { + "value": [ + "connect", + "expect", + "send", + "send-lf", + "send-binary", + "send-binary-lf" + ] + } + }, + "x-nullable": false + }, + "data": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send" + } + } + }, + "default": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } + }, + "error_status": { + "type": "string", + "enum": [ + "L7OKC", + "L7RSP", + "L7STS", + "L6RSP", + "L4CON" + ], + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "exclamation_mark": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "expect" + } + }, + "x-display-name": "Expect Exclamation Mark" + }, + "fmt": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send-lf" + } + } + }, + "hex_fmt": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send-binary-lf" + } + } + }, + "hex_string": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send-binary" + } + } + }, + "linger": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } + }, + "match": { + "type": "string", + "pattern": "^[^\\s]+$", + "enum": [ + "string", + "rstring", + "string-lf", + "binary", + "rbinary", + "binary-lf" + ], + "x-dependency": { + "action": { + "required": true, + "value": "expect" + } + }, + "x-display-name": "Expect Match" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "min_recv": { + "type": "integer", + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "ok_status": { + "type": "string", + "enum": [ + "L7OK", + "L7OKC", + "L6OK", + "L4OK" + ], + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "on_error": { + "type": "string", + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "on_success": { + "type": "string", + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "pattern": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "expect" + } + } + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-dependency": { + "action": { + "value": "connect" + } + }, + "x-nullable": true + }, + "port_string": { + "type": "string", + "x-dependency": { + "action": { + "value": "connect" + } + } + }, + "proto": { + "type": "string", + "x-dependency": { + "action": { + "value": "connect" + } + }, + "x-nullable": false + }, + "send_proxy": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } + }, + "sni": { + "type": "string", + "x-dependency": { + "action": { + "value": "connect" + } + }, + "x-nullable": false + }, + "ssl": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } + }, + "status-code": { + "type": "string", + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "tout_status": { + "type": "string", + "enum": [ + "L7TOUT", + "L6TOUT", + "L4TOUT" + ], + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "var_expr": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var" + ] + } + }, + "x-display-name": "Var Expression" + }, + "var_fmt": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var-fmt" + ] + } + }, + "x-display-name": "Var Log format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "via_socks4": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } + } + } + }, + "tcp_checks": { + "type": "array", + "title": "TCP Checks Array", + "items": { + "$ref": "#/definitions/tcp_check" + } + }, + "tcp_request_rule": { + "description": "HAProxy TCP Request Rule configuration (corresponds to tcp-request)", + "type": "object", + "title": "TCP Request Rule", + "required": [ + "type" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "accept", + "attach-srv", + "capture", + "do-resolve", + "expect-netscaler-cip", + "expect-proxy", + "lua", + "reject", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-bandwidth-limit", + "set-bc-mark", + "set-bc-tos", + "set-dst-port", + "set-dst", + "set-fc-mark", + "set-fc-tos", + "set-log-level", + "set-mark", + "set-nice", + "set-priority-class", + "set-priority-offset", + "set-src", + "set-src-port", + "set-tos", + "set-var", + "set-var-fmt", + "silent-drop", + "switch-mode", + "track-sc", + "unset-var", + "use-service", + "set-retries", + "do-log" + ], + "x-dependency": { + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-nullable": false + }, + "bandwidth_limit_limit": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "bandwidth_limit_name": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Bandwidth limit name" + }, + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "capture_len": { + "type": "integer", + "x-dependency": { + "action": { + "required": true, + "value": "capture" + }, + "type": { + "required": true, + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Capture Length" + }, + "capture_sample": { + "type": "string", + "pattern": "^(?:[A-Za-z]+\\(\"([A-Za-z\\s]+)\"\\)|[A-Za-z]+)", + "x-dependency": { + "action": { + "required": true, + "value": "capture" + }, + "type": { + "required": true, + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Capture Sample" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-dependency": { + "type": { + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + }, + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "expr": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "do-resolve", + "set-bc-mark", + "set-bc-tos", + "set-dst", + "set-dst-port", + "set-fc-mark", + "set-fc-tos", + "set-priority-class", + "set-priority-offset", + "set-src", + "set-src-port", + "set-var", + "set-retries" + ] + }, + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "gpt_value": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "sc-set-gpt0" + }, + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Sticky counter value" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "action": { + "required": true, + "value": "set-log-level" + }, + "type": { + "value": "content" + } + } + }, + "lua_action": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": "lua" + }, + "type": { + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Lua action name" + }, + "lua_params": { + "type": "string", + "x-dependency": { + "action": { + "value": "lua" + }, + "type": { + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Lua action params" + }, + "mark_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "action": { + "required": true, + "value": "set-mark" + }, + "type": { + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Mark Value" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "action": { + "required": true, + "value": "set-nice" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Nice Value", + "x-nullable": false + }, + "resolve_protocol": { + "type": "string", + "enum": [ + "ipv4", + "ipv6" + ], + "x-dependency": { + "action": { + "required": false, + "value": "do-resolve" + }, + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Protocol" + }, + "resolve_resolvers": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "do-resolve" + }, + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Resolvers" + }, + "resolve_var": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "do-resolve" + }, + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Variable name" + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] + } + }, + "x-display-name": "RST TTL" + }, + "sc_idx": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-set-gpt" + ] + }, + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Sticky counter Index" + }, + "sc_inc_id": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] + }, + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Sticky counter ID" + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "server_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "attach-srv" + }, + "type": { + "value": "session" + } + }, + "x-display-name": "Server name" + }, + "service_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "use-service" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Service name" + }, + "spoe_engine_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" + }, + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Engine name" + }, + "spoe_group_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" + }, + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Group name" + }, + "switch_mode_proto": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "switch-mode" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Switch Mode Proto" + }, + "timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "inspect-delay" + } + }, + "x-duration": true, + "x-nullable": true + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "action": { + "required": true, + "value": "set-tos" + }, + "type": { + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Tos Value" + }, + "track_key": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "track-sc" + ] + }, + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Sample expression rule" + }, + "track_stick_counter": { + "type": "integer", + "x-dependency": { + "action": { + "required": false, + "value": [ + "track-sc" + ] + }, + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Track Stick Counter", + "x-nullable": true + }, + "track_table": { + "type": "string", + "x-dependency": { + "action": { + "required": false, + "value": [ + "track-sc" + ] + }, + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Optional table name" + }, + "type": { + "type": "string", + "enum": [ + "connection", + "content", + "inspect-delay", + "session" + ], + "x-nullable": false + }, + "var_format": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "set-var-fmt" + }, + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var", + "unset-var", + "set-var-fmt" + ] + }, + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Variable name" + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var", + "unset-var", + "set-var-fmt" + ] + }, + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Variable scope" + } + }, + "additionalProperties": false, + "example": { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "index": 0, + "type": "connection" + } + }, + "tcp_request_rules": { + "description": "HAProxy TCP request rules array (corresponds to tcp-request directive)", + "type": "array", + "title": "TCP Request Rules Array", + "items": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "tcp_response_rule": { + "description": "HAProxy TCP Response Rule configuration (corresponds to tcp-response)", + "type": "object", + "title": "TCP Response Rule", + "required": [ + "type" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "accept", + "close", + "lua", + "reject", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-bandwidth-limit", + "set-fc-mark", + "set-fc-tos", + "set-log-level", + "set-mark", + "set-nice", + "set-tos", + "set-var", + "set-var-fmt", + "silent-drop", + "unset-var", + "do-log" + ], + "x-dependency": { + "type": { + "required": true, + "value": "content" + } + }, + "x-nullable": false + }, + "bandwidth_limit_limit": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "bandwidth_limit_name": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Bandwidth limit name" + }, + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-dependency": { + "type": { + "value": "content" + } + }, + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "expr": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-src-port", + "sc-set-gpt0", + "set-fc-mark", + "set-fc-tos" + ] + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "action": { + "required": true, + "value": "set-log-level" + }, + "type": { + "value": "content" + } + } + }, + "lua_action": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": "lua" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Lua action name" + }, + "lua_params": { + "type": "string", + "x-dependency": { + "action": { + "value": "lua" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Lua action params" + }, + "mark_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "action": { + "required": true, + "value": "set-mark" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Mark Value" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "action": { + "required": true, + "value": "set-nice" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Nice Value", + "x-nullable": false + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] + } + }, + "x-display-name": "RST TTL" + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc" + ] + }, + "type": { + "value": "content" + } + }, + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] + }, + "type": { + "value": "content" + } + } + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt", + "sc-inc-gpc" + ] + }, + "type": { + "value": "content" + } + } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc" + ] + }, + "type": { + "value": "content" + } + }, + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "SPOE Engine" + }, + "spoe_group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "SPOE Group" + }, + "timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "inspect-delay" + } + }, + "x-duration": true, + "x-nullable": true + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "action": { + "required": true, + "value": "set-tos" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Tos Value" + }, + "type": { + "type": "string", + "enum": [ + "content", + "inspect-delay" + ], + "x-nullable": false + }, + "var_format": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "set-var-fmt" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "unset-var" + ] + }, + "type": { + "value": "content" + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "value": "unset-var" + }, + "type": { + "value": "content" + } + } + } + }, + "additionalProperties": false, + "example": { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "index": 0, + "type": "content" + } + }, + "tcp_response_rules": { + "description": "HAProxy TCP response rules array (corresponds to tcp-response directive)", + "type": "array", + "title": "TCP Response Rules Array", + "items": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "trace_entries": { + "description": "list of entries in a traces section", + "type": "array", + "items": { + "$ref": "#/definitions/trace_entry" + } + }, + "trace_entry": { + "description": "Configure a trace event", + "type": "object", + "title": "Trace event", + "required": [ + "trace" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "trace": { + "description": "Trace parameters", + "type": "string", + "minLength": 1, + "x-nullable": false + } + } + }, + "traces": { + "description": "Trace events configuration", + "type": "object", + "properties": { + "entries": { + "$ref": "#/definitions/trace_entries" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + } + }, + "additionalProperties": false, + "x-go-name": "Traces" + }, + "transaction": { + "description": "HAProxy configuration transaction", + "type": "object", + "title": "Configuration transaction", + "properties": { + "_version": { + "type": "integer" + }, + "id": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "status": { + "type": "string", + "enum": [ + "failed", + "outdated", + "in_progress", + "success" + ] + } + }, + "example": { + "_version": 2, + "id": "273e3385-2d0c-4fb1-aa27-93cbb31ff203", + "status": "in_progress" + } + }, + "transactions": { + "description": "Configuration transactions array", + "type": "array", + "title": "Transactions array", + "items": { + "$ref": "#/definitions/transaction" + } + }, + "tune_buffer_options": { + "type": "object", + "properties": { + "buffers_limit": { + "type": "integer", + "x-display-name": "Buffers Limit", + "x-nullable": true + }, + "buffers_reserve": { + "type": "integer", + "minimum": 2, + "x-display-name": "Buffers Reserve" + }, + "bufsize": { + "type": "integer", + "x-display-name": "Buffer Size", + "x-size": true + }, + "bufsize_small": { + "type": "integer", + "minimum": 1, + "x-display-name": "Size of small buffers (for memory-restrained situations)", + "x-nullable": true, + "x-size": true + }, + "pipesize": { + "type": "integer", + "x-display-name": "Pipe Buffer Size", + "x-size": true + }, + "rcvbuf_backend": { + "type": "integer", + "x-display-name": "Backend Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "rcvbuf_client": { + "type": "integer", + "x-display-name": "Client Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "rcvbuf_frontend": { + "type": "integer", + "x-display-name": "Frontend Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "rcvbuf_server": { + "type": "integer", + "x-display-name": "Server Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "recv_enough": { + "type": "integer", + "x-display-name": "Receive Enough Socket Buffer Size", + "x-size": true + }, + "sndbuf_backend": { + "type": "integer", + "x-display-name": "Backend Send Buffer Size", + "x-nullable": true, + "x-size": true + }, + "sndbuf_client": { + "type": "integer", + "x-display-name": "Client Send Buffer Size", + "x-nullable": true, + "x-size": true + }, + "sndbuf_frontend": { + "type": "integer", + "x-display-name": "Frontend Send Buffer Size", + "x-nullable": true, + "x-size": true + }, + "sndbuf_server": { + "type": "integer", + "x-display-name": "Server Send Buffer Size", + "x-nullable": true, + "x-size": true + } + } + }, + "tune_lua_options": { + "type": "object", + "properties": { + "bool_sample_conversion": { + "type": "string", + "enum": [ + "normal", + "pre-3.1-bug" + ] + }, + "burst_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Burst execution timeout", + "x-duration": true, + "x-nullable": true + }, + "forced_yield": { + "type": "integer", + "x-display-name": "Lua Forced Yield" + }, + "log_loggers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Send Lua Logs to the Loggers" + }, + "log_stderr": { + "type": "string", + "enum": [ + "auto", + "enabled", + "disabled" + ], + "x-display-name": "Send Lua Logs to stderr" + }, + "maxmem": { + "type": "integer", + "x-display-name": "Lua Maximum Memory Usage", + "x-nullable": true + }, + "service_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Lua Service timeout", + "x-duration": true, + "x-nullable": true + }, + "session_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Lua Session Timeout", + "x-duration": true, + "x-nullable": true + }, + "task_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "Lua Task Timeout", + "x-duration": true, + "x-nullable": true + } + } + }, + "tune_options": { + "type": "object", + "properties": { + "applet_zero_copy_forwarding": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Enables of disabled the zero-copy forwarding of data for the applets" + }, + "comp_maxlevel": { + "type": "integer", + "x-display-name": "Maximum Compression Level" + }, + "disable_fast_forward": { + "type": "boolean", + "x-display-name": "Disable fast-forwarding" + }, + "disable_zero_copy_forwarding": { + "type": "boolean", + "x-display-name": "Disable zero-copy forwarding" + }, + "epoll_mask_events": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "err", + "hup", + "rdhup" + ] + }, + "x-omitempty": true + }, + "events_max_events_at_once": { + "type": "integer", + "maximum": 10000, + "minimum": 1 + }, + "fail_alloc": { + "type": "boolean", + "x-display-name": "Failed Allocation Chance" + }, + "fd_edge_triggered": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Edge-triggered polling mode" + }, + "glitches_kill_cpu_usage": { + "type": "integer", + "maximum": 100, + "x-display-name": "CPU Usage Kill glitched Connections", + "x-nullable": true + }, + "h1_zero_copy_fwd_recv": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "enable or disable the zero-copy receives of data for the HTTP/1 multiplexer" + }, + "h1_zero_copy_fwd_send": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "enable or disable the zero-copy sends of data for the HTTP/1 multiplexer" + }, + "h2_be_glitches_threshold": { + "type": "integer", + "x-display-name": "Automatically kill a backend connection past a number of glitches", + "x-nullable": true + }, + "h2_be_initial_window_size": { + "type": "integer", + "x-display-name": "Initial window size for outgoing connections" + }, + "h2_be_max_concurrent_streams": { + "type": "integer", + "x-display-name": "Maximum number of concurrent streams per outgoing connection" + }, + "h2_be_rxbuf": { + "type": "integer", + "x-display-name": "HTTP/2 receive buffer size for outgoing connections", + "x-nullable": true, + "x-size": true + }, + "h2_fe_glitches_threshold": { + "type": "integer", + "x-display-name": "Automatically kill a frontend connection past a number of glitches", + "x-nullable": true + }, + "h2_fe_initial_window_size": { + "type": "integer", + "x-display-name": "Initial window size for incoming connections" + }, + "h2_fe_max_concurrent_streams": { + "type": "integer", + "x-display-name": "Maximum number of concurrent streams per incoming connection" + }, + "h2_fe_max_total_streams": { + "type": "integer", + "x-display-name": "Maximum number of total streams processed per incoming HTTP/2 connection", + "x-nullable": true + }, + "h2_fe_rxbuf": { + "type": "integer", + "x-display-name": "HTTP/2 receive buffer size for incoming connections", + "x-nullable": true, + "x-size": true + }, + "h2_header_table_size": { + "type": "integer", + "maximum": 65535, + "x-display-name": "HTTP/2 Dynamic Header Table Size" + }, + "h2_initial_window_size": { + "type": "integer", + "x-display-name": "HTTP/2 Initial Window Size", + "x-nullable": true + }, + "h2_max_concurrent_streams": { + "type": "integer", + "x-display-name": "HTTP/2 Maximum Number of Concurrent Streams" + }, + "h2_max_frame_size": { + "type": "integer", + "x-display-name": "HTTP/2 Maximum Frame Size" + }, + "h2_zero_copy_fwd_send": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "enable or disable the zero-copy sends of data for the HTTP/2 multiplexer" + }, + "http_cookielen": { + "type": "integer", + "x-display-name": "Maximum Cookie Length" + }, + "http_logurilen": { + "type": "integer", + "x-display-name": "Maximum URI Length" + }, + "http_maxhdr": { + "type": "integer", + "maximum": 32767, + "minimum": 1, + "x-display-name": "Maximum Number of Headers" + }, + "idle_pool_shared": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Share Idle Connections" + }, + "idletimer": { + "type": "integer", + "maximum": 65535, + "x-default-unit": "ms", + "x-display-name": "Idle Stream Duration", + "x-duration": true, + "x-nullable": true + }, + "listener_default_shards": { + "type": "string", + "enum": [ + "by-process", + "by-thread", + "by-group" + ], + "x-display-name": "Listener Default Shards" + }, + "listener_multi_queue": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Listener Multi Queue Accept" + }, + "max_checks_per_thread": { + "type": "integer", + "x-display-name": "Maximum checks per thread", + "x-nullable": true + }, + "max_rules_at_once": { + "type": "integer", + "x-display-name": "Maximum rules at once", + "x-nullable": true + }, + "maxaccept": { + "type": "integer", + "x-display-name": "Maximum Accept Events" + }, + "maxpollevents": { + "type": "integer", + "x-display-name": "Maximum Polled Events" + }, + "maxrewrite": { + "type": "integer", + "x-display-name": "Maximum Rewrite Space" + }, + "memory_hot_size": { + "type": "integer", + "x-display-name": "Per-thread Amount of Memory", + "x-nullable": true + }, + "notsent_lowat_client": { + "type": "integer", + "x-display-name": "Client Not Sent Low Watermark", + "x-nullable": true, + "x-size": true + }, + "notsent_lowat_server": { + "type": "integer", + "x-display-name": "Server Not Sent Low Watermark", + "x-nullable": true, + "x-size": true + }, + "pattern_cache_size": { + "type": "integer", + "x-display-name": "Pattern Lookup Cache Size", + "x-nullable": true + }, + "peers_max_updates_at_once": { + "type": "integer", + "x-display-name": "Maximum number of stick-table updates at once" + }, + "pool_high_fd_ratio": { + "type": "integer", + "x-display-name": "Max Used High FD Ratio" + }, + "pool_low_fd_ratio": { + "type": "integer", + "x-display-name": "Max Used Low FD Ratio" + }, + "pt_zero_copy_forwarding": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "enable or disable the zero-copy forwarding of data for the pass-through multiplexer" + }, + "renice_runtime": { + "type": "integer", + "maximum": 19, + "minimum": -20, + "x-display-name": "Scheduling priority applied after the configuration parsing", + "x-nullable": true + }, + "renice_startup": { + "type": "integer", + "maximum": 19, + "minimum": -20, + "x-display-name": "Scheduling priority applied before the rest of the configuration", + "x-nullable": true + }, + "ring_queues": { + "type": "integer", + "x-display-name": "Number of write queues in front of ring buffers", + "x-nullable": true + }, + "runqueue_depth": { + "type": "integer", + "x-display-name": "Max Tasks in Run Queue" + }, + "sched_low_latency": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Low Latency Task Scheduler" + }, + "stick_counters": { + "type": "integer", + "x-display-name": "Number of stick-counters", + "x-nullable": true + }, + "takeover_other_tg_connections": { + "type": "string", + "enum": [ + "none", + "restricted", + "full" + ], + "x-display-name": "Takeover Other Thread Groups Connections" + } + } + }, + "tune_quic_options": { + "type": "object", + "properties": { + "frontend_conn_tx_buffers_limit": { + "type": "integer", + "x-display-name": "QUIC Frontend Connection TX Buffer Limit", + "x-nullable": true + }, + "frontend_max_idle_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-display-name": "QUIC Frontend Max Idle Timeout", + "x-duration": true, + "x-nullable": true + }, + "frontend_max_streams_bidi": { + "type": "integer", + "x-display-name": "QUIC Max Number of Bidirectional Streams", + "x-nullable": true + }, + "frontend_max_tx_memory": { + "type": "integer", + "x-display-name": "QUIC Frontend Max Tx Memory", + "x-nullable": true, + "x-size": true + }, + "max_frame_loss": { + "type": "integer", + "x-display-name": "QUIC Max Limit for Frame Loss", + "x-nullable": true + }, + "reorder_ratio": { + "type": "integer", + "maximum": 100, + "x-display-name": "Ratio applied to the packet reordering threshold", + "x-nullable": true + }, + "retry_threshold": { + "type": "integer", + "x-display-name": "QUIC Retry Threshold", + "x-nullable": true + }, + "socket_owner": { + "type": "string", + "enum": [ + "listener", + "connection" + ], + "x-display-name": "QUIC Socket Owner" + }, + "zero_copy_fwd_send": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Enables or disables the zero-copy sends for the QUIC multiplexer" + } + } + }, + "tune_ssl_options": { + "type": "object", + "properties": { + "cachesize": { + "type": "integer", + "x-display-name": "SSL Cache Size", + "x-nullable": true + }, + "capture_buffer_size": { + "type": "integer", + "x-display-name": "SSL Maximum Size of Cipherlist Buffer", + "x-nullable": true + }, + "ctx_cache_size": { + "type": "integer", + "x-display-name": "SSL Number of Certificates in Cache" + }, + "default_dh_param": { + "type": "integer", + "x-display-name": "SSL Default DH Parameter Size" + }, + "force_private_cache": { + "type": "boolean", + "x-display-name": "SSL Force Private Cache" + }, + "keylog": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "SSL Log TLS Keys" + }, + "lifetime": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "SSL Session Lifetime", + "x-duration": true, + "x-nullable": true + }, + "maxrecord": { + "type": "integer", + "x-display-name": "SSL Maximum Size", + "x-nullable": true, + "x-size": false + }, + "ocsp_update_max_delay": { + "type": "integer", + "x-display-name": "SSL Maximum Interval Between Two Automatic Updates of the same OCSP Response", + "x-nullable": true + }, + "ocsp_update_min_delay": { + "type": "integer", + "x-display-name": "SSL Minimum Interval Between Two Automatic Updates of the same OCSP Response", + "x-nullable": true + } + } + }, + "tune_vars_options": { + "type": "object", + "properties": { + "global_max_size": { + "type": "integer", + "x-display-name": "Variables Global Max Size", + "x-nullable": true, + "x-size": false + }, + "proc_max_size": { + "type": "integer", + "x-display-name": "Variables Process Max Size", + "x-nullable": true, + "x-size": false + }, + "reqres_max_size": { + "type": "integer", + "x-display-name": "Variables Request/Response Max Size", + "x-nullable": true, + "x-size": false + }, + "sess_max_size": { + "type": "integer", + "x-display-name": "Variables Session Max Size", + "x-nullable": true, + "x-size": false + }, + "txn_max_size": { + "type": "integer", + "x-display-name": "Variables Transaction Max Size", + "x-nullable": true, + "x-size": false + } + } + }, + "tune_zlib_options": { + "type": "object", + "properties": { + "memlevel": { + "type": "integer", + "maximum": 9, + "minimum": 1, + "x-display-name": "Zlib Memory Level" + }, + "windowsize": { + "type": "integer", + "maximum": 15, + "minimum": 8, + "x-display-name": "Zlib Window Size" + } + } + }, + "user": { + "description": "HAProxy userlist user", + "type": "object", + "title": "User", + "required": [ + "username", + "secure_password", + "password" + ], + "properties": { + "groups": { + "type": "string", + "x-nullable": false + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "password": { + "type": "string", + "x-nullable": false }, - "secure": { + "secure_password": { "type": "boolean" }, - "type": { + "username": { "type": "string", - "enum": [ - "rewrite", - "insert", - "prefix" - ] + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + } + } + }, + "userlist": { + "description": "Userlist with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/userlist_base" + }, + { + "type": "object", + "properties": { + "groups": { + "additionalProperties": { + "$ref": "#/definitions/group" + } + }, + "users": { + "additionalProperties": { + "$ref": "#/definitions/user" + } + } + } + } + ], + "x-go-name": "Userlist" + }, + "userlist_base": { + "description": "HAProxy configuration of access control", + "type": "object", + "title": "Userlist Base", + "required": [ + "name" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + } + } + }, + "userlists": { + "description": "HAProxy userlists array", + "type": "array", + "title": "Userlists", + "items": { + "$ref": "#/definitions/userlist" + } + }, + "users": { + "description": "HAProxy userlist users array", + "type": "array", + "title": "Users", + "items": { + "$ref": "#/definitions/user" + } + }, + "wurfl_options": { + "type": "object", + "properties": { + "cache_size": { + "type": "integer", + "x-display-name": "Sets the WURFL Useragent cache size" + }, + "data_file": { + "type": "string", + "x-display-name": "The path of the WURFL data file" + }, + "information_list": { + "type": "string", + "x-display-name": "A space-delimited list of WURFL capabilities" + }, + "information_list_separator": { + "type": "string", + "x-display-name": "A char that will be used to separate values in a response header containing WURFL results" + }, + "patch_file": { + "type": "string", + "x-display-name": "A list of WURFL patch file paths" + } + } + } + }, + "parameters": { + "force_reload": { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + "full_section": { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + }, + "parent_name": { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + "skip_reload": { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + "transaction_id": { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + "version": { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + }, + "responses": { + "AlreadyExists": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "BadRequest": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "DefaultError": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "NotAcceptable": { + "description": "The specified resource cannot be handled", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "NotFound": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + }, + "securityDefinitions": { + "basic_auth": { + "type": "basic" + } + }, + "security": [ + { + "basic_auth": [] + } + ], + "tags": [ + { + "name": "ACL" + }, + { + "name": "Acme" + }, + { + "description": "Managing backend configurations (advanced mode)", + "name": "Backend" + }, + { + "name": "BackendSwitchingRule" + }, + { + "description": "Managing frontend bind configurations (advanced mode)", + "name": "Bind" + }, + { + "name": "Cache" + }, + { + "name": "Cluster" + }, + { + "description": "Raw HAProxy configuration management (advanced mode)", + "name": "Configuration" + }, + { + "name": "CrtLoad" + }, + { + "name": "CrtStore" + }, + { + "name": "DeclareCapture" + }, + { + "description": "Managing defaults configuration (advanced mode)", + "name": "Defaults" + }, + { + "name": "DgramBind" + }, + { + "description": "API autodiscover endpoints", + "name": "Discovery" + }, + { + "name": "FCGIApp" + }, + { + "name": "Filter" + }, + { + "description": "Managing frontend configuration (advanced mode)", + "name": "Frontend" + }, + { + "description": "Managing global configuration (advanced mode)", + "name": "Global" + }, + { + "name": "HTTPCheck" + }, + { + "name": "HTTPErrorRule" + }, + { + "name": "HTTPErrors" + }, + { + "name": "HTTPRequestRule" + }, + { + "name": "HTTPResponseRule" + }, + { + "name": "Information" + }, + { + "name": "LogForward" + }, + { + "name": "LogProfile" + }, + { + "name": "LogTarget" + }, + { + "name": "MailerEntry" + }, + { + "name": "Mailers" + }, + { + "name": "Maps" + }, + { + "name": "Nameserver" + }, + { + "name": "Peer" + }, + { + "name": "PeerEntry" + }, + { + "name": "ProcessManager" + }, + { + "description": "Checking reload success. To avoid constant reloading we reload in intervals that are configurable when\nwith reload-delay option. When a change to configuration is made and force_reload url query string\nparameter is false we issue a request for reload, and return the reload ID in response header. You can\nthen use reloads endpoints to check the status of that reload ID. If force_reload is true, we override all\nof this and reload immediately.\n", + "name": "Reloads" + }, + { + "name": "Resolver" + }, + { + "name": "Ring" + }, + { + "description": "Managing backend server configurations (advanced mode)", + "name": "Server" + }, + { + "name": "ServerSwitchingRule" + }, + { + "name": "ServerTemplate" + }, + { + "name": "ServiceDiscovery" + }, + { + "description": "Managing sites (simple configuration mode). Sites are considered as one frontend with multiple backends\nconnected to it via default_backend or use-backend directives.\n", + "name": "Sites" + }, + { + "name": "Specification" + }, + { + "name": "SpecificationOpenapiv3" + }, + { + "name": "Spoe" + }, + { + "name": "SpoeTransactions" + }, + { + "description": "Stats container", + "name": "Stats" + }, + { + "name": "StickRule" + }, + { + "name": "StickTable" + }, + { + "name": "Storage" + }, + { + "name": "TCPCheck" + }, + { + "name": "TCPRequestRule" + }, + { + "name": "TCPResponseRule" + }, + { + "name": "Table" + }, + { + "name": "Traces" + }, + { + "description": "Managing transactions. Configuration changes can be grouped in the transaction. You start the\ntransaction with trasactions POST, and call the configuration changes you need with parameter\ntransaction_id. When you want to commit the transaction, you call the transactions PUT and all changes\nin that transaction is committed. If you call a configuration change without the transaction_id,\ntransaction mechanism is implicitly called with one operation in transaction.\n", + "name": "Transactions" + }, + { + "name": "Userlist" + } + ], + "externalDocs": { + "description": "HAProxy Documentation", + "url": "https://docs.haproxy.org/" + } +}`)) + FlatSwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "API for editing and managing haproxy instances. Provides process information, configuration management,\nhaproxy stats and logs.\n", + "title": "HAProxy Data Plane API", + "contact": { + "name": "HAProxy Support", + "url": "https://my.haproxy.com/portal/cust/login", + "email": "support@haproxy.com" + }, + "version": "3.3" + }, + "basePath": "/v3", + "paths": { + "/": { + "get": { + "description": "Returns a list of root endpoints.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of root endpoints", + "operationId": "getAPIEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/cluster": { + "get": { + "description": "Returns cluster data", + "produces": [ + "application/json" + ], + "tags": [ + "Cluster" + ], + "summary": "Return cluster data", + "operationId": "getCluster", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Edit cluster settings", + "tags": [ + "Cluster" + ], + "summary": "Edit cluster settings", + "operationId": "editCluster", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Cluster settings changed", + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Post cluster settings", + "tags": [ + "Cluster" + ], + "summary": "Post cluster settings", + "operationId": "postCluster", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + { + "enum": [ + "keep" + ], + "type": "string", + "description": "In case of moving to single mode do we keep or clean configuration", + "name": "configuration", + "in": "query" + }, + { + "type": "string", + "description": "Force the advertised address when joining a cluster", + "name": "advertised_address", + "in": "query" + }, + { + "maximum": 65535, + "minimum": 1, + "type": "integer", + "description": "Force the advertised port when joining a cluster", + "name": "advertised_port", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Cluster settings changed", + "schema": { + "$ref": "#/definitions/cluster_settings" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Delete cluster settings and move the node back to single mode", + "tags": [ + "Cluster" + ], + "summary": "Delete cluster settings", + "operationId": "deleteCluster", + "parameters": [ + { + "enum": [ + "keep" + ], + "type": "string", + "description": "In case of moving to single mode do we keep or clean configuration", + "name": "configuration", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Cluster settings deleted and node moved to single mode" + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/cluster/certificate": { + "post": { + "description": "Initiates a certificate refresh", + "tags": [ + "Cluster" + ], + "summary": "Initiates a certificate refresh", + "operationId": "initiateCertificateRefresh", + "responses": { + "200": { + "description": "refresh activated" + }, + "403": { + "description": "refresh not possible" + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/health": { + "get": { + "description": "Return managed services health", + "produces": [ + "application/json" + ], + "tags": [ + "Health" + ], + "summary": "Return managed services health", + "operationId": "getHealth", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/health" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/info": { + "get": { + "description": "Return API, hardware and OS information", + "produces": [ + "application/json" + ], + "tags": [ + "Information" + ], + "summary": "Return API, hardware and OS information", + "operationId": "getInfo", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/info" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/service_discovery/aws": { + "get": { + "description": "Return all configured AWS regions.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Return an array of all configured AWS regions", + "operationId": "getAWSRegions", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/awsRegions" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Add a new AWS region.\nCredentials are not required in case Dataplane API is running in an EC2 instance with proper IAM role attached.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Add a new AWS region", + "operationId": "createAWSRegion", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/awsRegion" + } + } + ], + "responses": { + "201": { + "description": "Resource created", + "schema": { + "$ref": "#/definitions/awsRegion" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/service_discovery/aws/{id}": { + "get": { + "description": "Return one AWS Region configuration by it's id.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Return an AWS region", + "operationId": "getAWSRegion", + "parameters": [ + { + "type": "string", + "description": "AWS region id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/awsRegion" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replace an AWS region configuration by its id.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Replace an AWS region", + "operationId": "replaceAWSRegion", + "parameters": [ + { + "type": "string", + "description": "AWS Region ID", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/awsRegion" + } + } + ], + "responses": { + "200": { + "description": "Resource updated", + "schema": { + "$ref": "#/definitions/awsRegion" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Delete an AWS region configuration by it's id.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Delete an AWS region", + "operationId": "deleteAWSRegion", + "parameters": [ + { + "type": "string", + "description": "AWS region ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Resource deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/service_discovery/consul": { + "get": { + "description": "Returns all configured Consul servers.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Return an array of all configured Consul servers", + "operationId": "getConsuls", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/consuls" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Consul server.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Add a new Consul server", + "operationId": "createConsul", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/consul" + } + } + ], + "responses": { + "201": { + "description": "Consul created", + "schema": { + "$ref": "#/definitions/consul" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/service_discovery/consul/{id}": { + "get": { + "description": "Returns one Consul server configuration by it's id.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Return one Consul server", + "operationId": "getConsul", + "parameters": [ + { + "type": "string", + "description": "Consul server id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/consul" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Consul server configuration by it's id.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Replace a Consul server", + "operationId": "replaceConsul", + "parameters": [ + { + "type": "string", + "description": "Consul Index", + "name": "id", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/consul" + } + } + ], + "responses": { + "200": { + "description": "Consul server replaced", + "schema": { + "$ref": "#/definitions/consul" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Consul server configuration by it's id.", + "tags": [ + "ServiceDiscovery" + ], + "summary": "Delete a Consul server", + "operationId": "deleteConsul", + "parameters": [ + { + "type": "string", + "description": "Consul server Index", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Consul server deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services": { + "get": { + "description": "Returns a list of API managed services endpoints.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of service endpoints", + "operationId": "getServicesEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy": { + "get": { + "description": "Returns a list of HAProxy related endpoints.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy related endpoints", + "operationId": "getHaproxyEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration": { + "get": { + "description": "Returns a list of endpoints to be used for advanced configuration of HAProxy objects.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy advanced configuration endpoints", + "operationId": "getConfigurationEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/acme": { + "get": { + "description": "Returns an array of all the configured ACME providers", + "tags": [ + "Acme" + ], + "summary": "Return all the ACME providers", + "operationId": "getAcmeProviders", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acme_providers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates a new acme section", + "tags": [ + "Acme" + ], + "summary": "Add a new Acme provider", + "operationId": "createAcmeProvider", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acme_provider" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Profile created", + "schema": { + "$ref": "#/definitions/acme_provider" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acme_provider" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/acme/{name}": { + "get": { + "description": "Find an acme section by its name", + "tags": [ + "Acme" + ], + "summary": "Find an ACME provider", + "operationId": "getAcmeProvider", + "parameters": [ + { + "type": "string", + "description": "acme section name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acme_provider" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Modifies a acme_provider's configuration by its name", + "tags": [ + "Acme" + ], + "summary": "Modify an ACME provider", + "operationId": "editAcmeProvider", + "parameters": [ + { + "type": "string", + "description": "acme section name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acme_provider" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "acme_provider configuration updated", + "schema": { + "$ref": "#/definitions/acme_provider" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acme_provider" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes an acme section from the configuration", + "tags": [ + "Acme" + ], + "summary": "Delete an ACME provider", + "operationId": "deleteAcmeProvider", + "parameters": [ + { + "type": "string", + "description": "acme section name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "acme provider deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends": { + "get": { + "description": "Returns an array of all configured backends.", + "tags": [ + "Backend" + ], + "summary": "Return an array of backends", + "operationId": "getBackends", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/backends" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new backend to the configuration file.", + "tags": [ + "Backend" + ], + "summary": "Add a backend", + "operationId": "createBackend", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Backend created", + "schema": { + "$ref": "#/definitions/backend" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{name}": { + "get": { + "description": "Returns one backend configuration by it's name.", + "tags": [ + "Backend" + ], + "summary": "Return a backend", + "operationId": "getBackend", + "parameters": [ + { + "type": "string", + "description": "Backend name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/backend" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a backend configuration by it's name.", + "tags": [ + "Backend" + ], + "summary": "Replace a backend", + "operationId": "replaceBackend", + "parameters": [ + { + "type": "string", + "description": "Backend name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Backend replaced", + "schema": { + "$ref": "#/definitions/backend" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a backend from the configuration by it's name.", + "tags": [ + "Backend" + ], + "summary": "Delete a backend", + "operationId": "deleteBackend", + "parameters": [ + { + "type": "string", + "description": "Backend name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Backend deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/acls": { + "get": { + "description": "Returns all ACL lines that are configured in specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of ACLs with the list given in parameter", + "tags": [ + "ACL" + ], + "summary": "Replace an ACL list", + "operationId": "replaceAllAclBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acls" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All ACL lines replaced", + "schema": { + "$ref": "#/definitions/acls" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/acls/{index}": { + "get": { + "description": "Returns one ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return one ACL line", + "operationId": "getAclBackend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Replace a ACL line", + "operationId": "replaceAclBackend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "ACL line replaced", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Add a new ACL line", + "operationId": "createAclBackend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "ACL line created", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a ACL line configuration by it's index from the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Delete a ACL line", + "operationId": "deleteAclBackend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "ACL line deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/filters": { + "get": { + "description": "Returns all Filters that are configured in specified parent.", + "tags": [ + "Filter" + ], + "summary": "Return an array of all Filters", + "operationId": "getAllFilterBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/filters" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Filters with the list given in parameter", + "tags": [ + "Filter" + ], + "summary": "Replace a Filter list", + "operationId": "replaceAllFilterBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filters" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Filter lines replaced", + "schema": { + "$ref": "#/definitions/filters" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filters" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/filters/{index}": { + "get": { + "description": "Returns one Filter configuration by it's index in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Return one Filter", + "operationId": "getFilterBackend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Filter configuration by it's index in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Replace a Filter", + "operationId": "replaceFilterBackend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filter" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Filter replaced", + "schema": { + "$ref": "#/definitions/filter" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Filter of the specified type in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Add a new Filter", + "operationId": "createFilterBackend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filter" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Filter created", + "schema": { + "$ref": "#/definitions/filter" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Filter configuration by it's index from the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Delete a Filter", + "operationId": "deleteFilterBackend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Filter deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules": { + "get": { + "description": "Returns all HTTP After Response Rules that are configured in specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return an array of all HTTP After Response Rules", + "operationId": "getAllHTTPAfterResponseRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP After Response Rules with the list given in parameter", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace an HTTP After Response Rules list", + "operationId": "replaceAllHTTPAfterResponseRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}": { + "get": { + "description": "Returns one HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return one HTTP After Response Rule", + "operationId": "getHTTPAfterResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace a HTTP After Response Rule", + "operationId": "replaceHTTPAfterResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP After Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP After Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Add a new HTTP After Response Rule", + "operationId": "createHTTPAfterResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP After Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Delete a HTTP After Response Rule", + "operationId": "deleteHTTPAfterResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP After Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_checks": { + "get": { + "description": "Returns all HTTP checks that are configured in specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Return an array of HTTP checks", + "operationId": "getAllHTTPCheckBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_checks" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP checks with the list given in parameter", + "tags": [ + "HTTPCheck" + ], + "summary": "Replace an HTTP checks list", + "operationId": "replaceAllHTTPCheckBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_checks" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP checks lines replaced", + "schema": { + "$ref": "#/definitions/http_checks" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_checks" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}": { + "get": { + "description": "Returns one HTTP check configuration by it's index in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Return one HTTP check", + "operationId": "getHTTPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Check configuration by it's index in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Replace a HTTP check", + "operationId": "replaceHTTPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP check replaced", + "schema": { + "$ref": "#/definitions/http_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP check of the specified type in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Add a new HTTP check", + "operationId": "createHTTPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP check created", + "schema": { + "$ref": "#/definitions/http_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP check configuration by it's index from the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Delete a HTTP check", + "operationId": "deleteHTTPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP check deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_error_rules": { + "get": { + "description": "Returns all HTTP Error Rules that are configured in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return an array of all HTTP Error Rules", + "operationId": "getAllHTTPErrorRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Error Rules with the list given in parameter", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace an HTTP Error Rules list", + "operationId": "replaceAllHTTPErrorRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Error Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}": { + "get": { + "description": "Returns one HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return one HTTP Error Rule", + "operationId": "getHTTPErrorRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace a HTTP Error Rule", + "operationId": "replaceHTTPErrorRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Error Rule replaced", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Error Rule of the specified type in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Add a new HTTP Error Rule", + "operationId": "createHTTPErrorRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Error Rule created", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Error Rule configuration by its index from the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Delete a HTTP Error Rule", + "operationId": "deleteHTTPErrorRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Error Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_request_rules": { + "get": { + "description": "Returns all HTTP Request Rules that are configured in specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return an array of all HTTP Request Rules", + "operationId": "getAllHTTPRequestRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Request Rules with the list given in parameter", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace an HTTP Request Rule list", + "operationId": "replaceAllHTTPRequestRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}": { + "get": { + "description": "Returns one HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return one HTTP Request Rule", + "operationId": "getHTTPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace a HTTP Request Rule", + "operationId": "replaceHTTPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Request Rule replaced", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Add a new HTTP Request Rule", + "operationId": "createHTTPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Request Rule created", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Delete a HTTP Request Rule", + "operationId": "deleteHTTPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Request Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_response_rules": { + "get": { + "description": "Returns all HTTP Response Rules that are configured in specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return an array of all HTTP Response Rules", + "operationId": "getAllHTTPResponseRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Response Rules with the list given in parameter", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace an HTTP Response Rule list", + "operationId": "replaceAllHTTPResponseRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}": { + "get": { + "description": "Returns one HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return one HTTP Response Rule", + "operationId": "getHTTPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace a HTTP Response Rule", + "operationId": "replaceHTTPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Add a new HTTP Response Rule", + "operationId": "createHTTPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Delete a HTTP Response Rule", + "operationId": "deleteHTTPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetBackend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetBackend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetBackend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetBackend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules": { + "get": { + "description": "Returns all Backend Switching Rules that are configured in specified backend.", + "tags": [ + "ServerSwitchingRule" + ], + "summary": "Return an array of all Server Switching Rules", + "operationId": "getServerSwitchingRules", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server_switching_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Server Switching Rules with the list given in parameter", + "tags": [ + "ServerSwitchingRule" + ], + "summary": "Replace an Server Switching Rule list", + "operationId": "replaceServerSwitchingRules", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server_switching_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Server Switching Rule lines replaced", + "schema": { + "$ref": "#/definitions/server_switching_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server_switching_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}": { + "get": { + "description": "Returns one Server Switching Rule configuration by it's index in the specified backend.", + "tags": [ + "ServerSwitchingRule" + ], + "summary": "Return one Server Switching Rule", + "operationId": "getServerSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server_switching_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Server Switching Rule configuration by it's index in the specified backend.", + "tags": [ + "ServerSwitchingRule" + ], + "summary": "Replace a Server Switching Rule", + "operationId": "replaceServerSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server_switching_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Server Switching Rule replaced", + "schema": { + "$ref": "#/definitions/server_switching_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server_switching_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Server Switching Rule of the specified type in the specified backend.", + "tags": [ + "ServerSwitchingRule" + ], + "summary": "Add a new Server Switching Rule", + "operationId": "createServerSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server_switching_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Server Switching Rule created", + "schema": { + "$ref": "#/definitions/server_switching_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server_switching_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Server Switching Rule configuration by it's index from the specified backend.", + "tags": [ + "ServerSwitchingRule" + ], + "summary": "Delete a Server Switching Rule", + "operationId": "deleteServerSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Server Switching Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/server_templates": { + "get": { + "description": "Returns an array of all server templates that are configured in specified backend.", + "tags": [ + "ServerTemplate" + ], + "summary": "Return an array of server templates", + "operationId": "getServerTemplates", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server_templates" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new server template in the specified backend in the configuration file.", + "tags": [ + "ServerTemplate" + ], + "summary": "Add a new server template", + "operationId": "createServerTemplate", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server_template" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Server template created", + "schema": { + "$ref": "#/definitions/server_template" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server_template" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}": { + "get": { + "description": "Returns one server template configuration by it's prefix in the specified backend.", + "tags": [ + "ServerTemplate" + ], + "summary": "Return one server template", + "operationId": "getServerTemplate", + "parameters": [ + { + "type": "string", + "description": "Server template prefix", + "name": "prefix", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server_template" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a server template configuration by it's prefix in the specified backend.", + "tags": [ + "ServerTemplate" + ], + "summary": "Replace a server template", + "operationId": "replaceServerTemplate", + "parameters": [ + { + "type": "string", + "description": "Server template prefix", + "name": "prefix", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server_template" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Server template replaced", + "schema": { + "$ref": "#/definitions/server_template" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server_template" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a server template configuration by it's prefix in the specified backend.", + "tags": [ + "ServerTemplate" + ], + "summary": "Delete a server template", + "operationId": "deleteServerTemplate", + "parameters": [ + { + "type": "string", + "description": "Server template prefix", + "name": "prefix", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Server template deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/servers": { + "get": { + "description": "Returns an array of all servers that are configured in specified backend.", + "tags": [ + "Server" + ], + "summary": "Return an array of servers", + "operationId": "getAllServerBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/servers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new server in the specified backend in the configuration file.", + "tags": [ + "Server" + ], + "summary": "Add a new server", + "operationId": "createServerBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Server created", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/servers/{name}": { + "get": { + "description": "Returns one server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Return one server", + "operationId": "getServerBackend", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Replace a server", + "operationId": "replaceServerBackend", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Server replaced", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Delete a server", + "operationId": "deleteServerBackend", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Server deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/stick_rules": { + "get": { + "description": "Returns all Stick Rules that are configured in specified backend.", + "tags": [ + "StickRule" + ], + "summary": "Return an array of all Stick Rules", + "operationId": "getStickRules", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Stick Rules with the list given in parameter", + "tags": [ + "StickRule" + ], + "summary": "Replace a Stick Rule list", + "operationId": "replaceStickRules", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/stick_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Stick Rule lines replaced", + "schema": { + "$ref": "#/definitions/stick_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/stick_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}": { + "get": { + "description": "Returns one Stick Rule configuration by it's index in the specified backend.", + "tags": [ + "StickRule" + ], + "summary": "Return one Stick Rule", + "operationId": "getStickRule", + "parameters": [ + { + "type": "integer", + "description": "Stick Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Stick Rule configuration by it's index in the specified backend.", + "tags": [ + "StickRule" + ], + "summary": "Replace a Stick Rule", + "operationId": "replaceStickRule", + "parameters": [ + { + "type": "integer", + "description": "Stick Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/stick_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Stick Rule replaced", + "schema": { + "$ref": "#/definitions/stick_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/stick_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Stick Rule of the specified type in the specified backend.", + "tags": [ + "StickRule" + ], + "summary": "Add a new Stick Rule", + "operationId": "createStickRule", + "parameters": [ + { + "type": "integer", + "description": "Stick Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/stick_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Stick Rule created", + "schema": { + "$ref": "#/definitions/stick_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/stick_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Stick Rule configuration by it's index from the specified backend.", + "tags": [ + "StickRule" + ], + "summary": "Delete a Stick Rule", + "operationId": "deleteStickRule", + "parameters": [ + { + "type": "integer", + "description": "Stick Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Stick Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_checks": { + "get": { + "description": "Returns all TCP checks that are configured in specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Return an array of TCP checks", + "operationId": "getAllTCPCheckBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Checks with the list given in parameter", + "tags": [ + "TCPCheck" + ], + "summary": "Replace an TCP Check list", + "operationId": "replaceAllTCPCheckBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TCP Check lines replaced", + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}": { + "get": { + "description": "Returns one TCP check configuration by it's index in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Return one TCP check", + "operationId": "getTCPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a TCP Check configuration by it's index in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Replace a TCP check", + "operationId": "replaceTCPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "TCP check replaced", + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new TCP check of the specified type in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Add a new TCP check", + "operationId": "createTCPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "TCP check created", + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a TCP check configuration by it's index from the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Delete a TCP check", + "operationId": "deleteTCPCheckBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP check deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules": { + "get": { + "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return an array of all TCP Request Rules", + "operationId": "getAllTCPRequestRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Request Rules with the list given in parameter", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace an TCP Request Rule list", + "operationId": "replaceAllTCPRequestRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TCP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}": { + "get": { + "description": "Returns one TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return one TCP Request Rule", + "operationId": "getTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace a TCP Request Rule", + "operationId": "replaceTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "TCP Request Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Add a new TCP Request Rule", + "operationId": "createTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "TCP Request Rule created", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a TCP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Delete a TCP Request Rule", + "operationId": "deleteTCPRequestRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Request Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules": { + "get": { + "description": "Returns all TCP Response Rules that are configured in specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return an array of all TCP Response Rules", + "operationId": "getAllTCPResponseRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Response Rules with the list given in parameter", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule list", + "operationId": "replaceAllTCPResponseRuleBackend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TCP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}": { + "get": { + "description": "Returns one TCP Response Rule configuration by it's index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return one TCP Response Rule", + "operationId": "getTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a TCP Response Rule configuration by it's Index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule", + "operationId": "replaceTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "TCP Response Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new TCP Response Rule of the specified type in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Add a new TCP Response Rule", + "operationId": "createTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "TCP Response Rule created", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a TCP Response Rule configuration by it's index from the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Delete a TCP Response Rule", + "operationId": "deleteTCPResponseRuleBackend", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/caches": { + "get": { + "description": "Returns an array of all configured caches.", + "tags": [ + "Cache" + ], + "summary": "Return an array of caches", + "operationId": "getCaches", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/caches" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new cache section to the configuration file.", + "tags": [ + "Cache" + ], + "summary": "Add a cache", + "operationId": "createCache", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cache" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Cache created", + "schema": { + "$ref": "#/definitions/cache" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/cache" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/caches/{name}": { + "get": { + "description": "Returns one cache section configuration by it's name.", + "tags": [ + "Cache" + ], + "summary": "Return a cache", + "operationId": "getCache", + "parameters": [ + { + "type": "string", + "description": "Cache name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/cache" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a cache configuration by it's name.", + "tags": [ + "Cache" + ], + "summary": "Replace a cache", + "operationId": "replaceCache", + "parameters": [ + { + "type": "string", + "description": "Cache name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/cache" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Cache replaced", + "schema": { + "$ref": "#/definitions/cache" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/cache" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a cache from the configuration by it's name.", + "tags": [ + "Cache" + ], + "summary": "Delete a cache", + "operationId": "deleteCache", + "parameters": [ + { + "type": "string", + "description": "Cache name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Cache deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/crt_loads": { + "get": { + "description": "Returns the list of loaded certificates from the specified crt_store", + "tags": [ + "CrtLoad" + ], + "summary": "Return an array of loaded certificates", + "operationId": "getCrtLoads", + "parameters": [ + { + "type": "string", + "description": "Parent crt_store name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_loads" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new load entry to the specified crt_store section in the configuration", + "tags": [ + "CrtLoad" + ], + "summary": "Add a new certificate to load", + "operationId": "createCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Parent crt_store section name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Certificate load entry created", + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_load" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/crt_loads/{certificate}": { + "get": { + "description": "Returns one load entry by its certificate name in the specified crt_store", + "tags": [ + "CrtLoad" + ], + "summary": "Return one certificate load entry", + "operationId": "getCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Certificate filename", + "name": "certificate", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent crt_store name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_load" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a load entry by its certificate name in the specified crt_store section", + "tags": [ + "CrtLoad" + ], + "summary": "Replace a certificate load entry", + "operationId": "replaceCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Certificate filename", + "name": "certificate", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent crt_store section name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Certificate load entry replaced", + "schema": { + "$ref": "#/definitions/crt_load" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_load" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a load entry by its certificate name in the specified crt_store section", + "tags": [ + "CrtLoad" + ], + "summary": "Delete a certificate load entry", + "operationId": "deleteCrtLoad", + "parameters": [ + { + "type": "string", + "description": "Certificate filename", + "name": "certificate", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent crt_store section name", + "name": "crt_store", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Certificate load entry deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/crt_stores": { + "get": { + "description": "Returns an array of all the configured crt_store sections in HAProxy", + "tags": [ + "CrtStore" + ], + "summary": "Return all the Certificate Stores", + "operationId": "getCrtStores", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_stores" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates a new crt_store section", + "tags": [ + "CrtStore" + ], + "summary": "Add a new Certificate Store", + "operationId": "createCrtStore", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Certificate Store created", + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_store" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/crt_stores/{name}": { + "get": { + "description": "Returns crt_store section by its name", + "tags": [ + "CrtStore" + ], + "summary": "Return a Certificate Store", + "operationId": "getCrtStore", + "parameters": [ + { + "type": "string", + "description": "crt_store name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/crt_store" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Modifies a crt_store's configuration by its name", + "tags": [ + "CrtStore" + ], + "summary": "Modify a Certificate Store", + "operationId": "editCrtStore", + "parameters": [ + { + "type": "string", + "description": "crt_store name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "crt_store configuration updated", + "schema": { + "$ref": "#/definitions/crt_store" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/crt_store" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a crt_store section from the configuration", + "tags": [ + "CrtStore" + ], + "summary": "Delete a Certificate Store", + "operationId": "deleteCrtStore", + "parameters": [ + { + "type": "string", + "description": "crt_store name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "crt_store deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults": { + "get": { + "description": "Returns an array of all configured defaults.", + "tags": [ + "Defaults" + ], + "summary": "Return an array of defaults", + "operationId": "getDefaultsSections", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/defaults_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Adds a new defaults section to the configuration file.", + "tags": [ + "Defaults" + ], + "summary": "Add a defaults section", + "operationId": "createDefaultsSection", + "deprecated": true, + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/defaults" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Defaults created", + "schema": { + "$ref": "#/definitions/defaults" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new defaults section to the configuration file.", + "tags": [ + "Defaults" + ], + "summary": "Add a defaults section", + "operationId": "addDefaultsSection", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/defaults" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Defaults created", + "schema": { + "$ref": "#/definitions/defaults" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{name}": { + "get": { + "description": "Returns one defaults section configuration by it's name.", + "tags": [ + "Defaults" + ], + "summary": "Return a defaults section", + "operationId": "getDefaultsSection", + "parameters": [ + { + "type": "string", + "description": "Defaults name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a defatults section configuration by it's name.", + "tags": [ + "Defaults" + ], + "summary": "Replace a defatults section", + "operationId": "replaceDefaultsSection", + "parameters": [ + { + "type": "string", + "description": "Defaults name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/defaults" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Defaults section replaced", + "schema": { + "$ref": "#/definitions/defaults" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/defaults" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a defaults section from the configuration by it's name.", + "tags": [ + "Defaults" + ], + "summary": "Delete a defaults section", + "operationId": "deleteDefaultsSection", + "parameters": [ + { + "type": "string", + "description": "Defaults name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Defaults section deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/acls": { + "get": { + "description": "Returns all ACL lines that are configured in specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of ACLs with the list given in parameter", + "tags": [ + "ACL" + ], + "summary": "Replace an ACL list", + "operationId": "replaceAllAclDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acls" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All ACL lines replaced", + "schema": { + "$ref": "#/definitions/acls" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/acls/{index}": { + "get": { + "description": "Returns one ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return one ACL line", + "operationId": "getAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Replace a ACL line", + "operationId": "replaceAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "ACL line replaced", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Add a new ACL line", + "operationId": "createAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "ACL line created", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a ACL line configuration by it's index from the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Delete a ACL line", + "operationId": "deleteAclDefaults", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "ACL line deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules": { + "get": { + "description": "Returns all HTTP After Response Rules that are configured in specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return an array of all HTTP After Response Rules", + "operationId": "getAllHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP After Response Rules with the list given in parameter", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace an HTTP After Response Rules list", + "operationId": "replaceAllHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}": { + "get": { + "description": "Returns one HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return one HTTP After Response Rule", + "operationId": "getHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace a HTTP After Response Rule", + "operationId": "replaceHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP After Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP After Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Add a new HTTP After Response Rule", + "operationId": "createHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP After Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Delete a HTTP After Response Rule", + "operationId": "deleteHTTPAfterResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP After Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_checks": { + "get": { + "description": "Returns all HTTP checks that are configured in specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Return an array of HTTP checks", + "operationId": "getAllHTTPCheckDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_checks" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP checks with the list given in parameter", + "tags": [ + "HTTPCheck" + ], + "summary": "Replace an HTTP checks list", + "operationId": "replaceAllHTTPCheckDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_checks" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP checks lines replaced", + "schema": { + "$ref": "#/definitions/http_checks" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_checks" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}": { + "get": { + "description": "Returns one HTTP check configuration by it's index in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Return one HTTP check", + "operationId": "getHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Check configuration by it's index in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Replace a HTTP check", + "operationId": "replaceHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP check replaced", + "schema": { + "$ref": "#/definitions/http_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP check of the specified type in the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Add a new HTTP check", + "operationId": "createHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP check created", + "schema": { + "$ref": "#/definitions/http_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP check configuration by it's index from the specified parent.", + "tags": [ + "HTTPCheck" + ], + "summary": "Delete a HTTP check", + "operationId": "deleteHTTPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP check deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules": { + "get": { + "description": "Returns all HTTP Error Rules that are configured in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return an array of all HTTP Error Rules", + "operationId": "getAllHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Error Rules with the list given in parameter", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace an HTTP Error Rules list", + "operationId": "replaceAllHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Error Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}": { + "get": { + "description": "Returns one HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return one HTTP Error Rule", + "operationId": "getHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace a HTTP Error Rule", + "operationId": "replaceHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Error Rule replaced", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Error Rule of the specified type in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Add a new HTTP Error Rule", + "operationId": "createHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Error Rule created", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Error Rule configuration by its index from the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Delete a HTTP Error Rule", + "operationId": "deleteHTTPErrorRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Error Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules": { + "get": { + "description": "Returns all HTTP Request Rules that are configured in specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return an array of all HTTP Request Rules", + "operationId": "getAllHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Request Rules with the list given in parameter", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace an HTTP Request Rule list", + "operationId": "replaceAllHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}": { + "get": { + "description": "Returns one HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return one HTTP Request Rule", + "operationId": "getHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace a HTTP Request Rule", + "operationId": "replaceHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Request Rule replaced", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Add a new HTTP Request Rule", + "operationId": "createHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Request Rule created", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Delete a HTTP Request Rule", + "operationId": "deleteHTTPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Request Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules": { + "get": { + "description": "Returns all HTTP Response Rules that are configured in specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return an array of all HTTP Response Rules", + "operationId": "getAllHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Response Rules with the list given in parameter", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace an HTTP Response Rule list", + "operationId": "replaceAllHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}": { + "get": { + "description": "Returns one HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return one HTTP Response Rule", + "operationId": "getHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace a HTTP Response Rule", + "operationId": "replaceHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Add a new HTTP Response Rule", + "operationId": "createHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Delete a HTTP Response Rule", + "operationId": "deleteHTTPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetDefaults", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules": { + "get": { + "description": "Returns all QUIC Initial rules that are configured in specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return an array of all QUIC Initial rules", + "operationId": "getAllQUICInitialRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of QUIC Initial rules with the list given in parameter", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace an QUIC Initial rules list", + "operationId": "replaceAllQUICInitialRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}": { + "get": { + "description": "Returns one QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return one QUIC Initial Rule", + "operationId": "getQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace a QUIC Initial Rule", + "operationId": "replaceQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "QUIC Initial Rule replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new QUIC Initial Rule of the specified type in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Add a new QUIC Initial Rule", + "operationId": "createQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a QUIC Initial Rule configuration by it's index from the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Delete a QUIC Initial Rule", + "operationId": "deleteQUICInitialRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "QUIC Initial Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks": { + "get": { + "description": "Returns all TCP checks that are configured in specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Return an array of TCP checks", + "operationId": "getAllTCPCheckDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Checks with the list given in parameter", + "tags": [ + "TCPCheck" + ], + "summary": "Replace an TCP Check list", + "operationId": "replaceAllTCPCheckDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TCP Check lines replaced", + "schema": { + "$ref": "#/definitions/tcp_checks" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_checks" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}": { + "get": { + "description": "Returns one TCP check configuration by it's index in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Return one TCP check", + "operationId": "getTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a TCP Check configuration by it's index in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Replace a TCP check", + "operationId": "replaceTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "TCP check replaced", + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new TCP check of the specified type in the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Add a new TCP check", + "operationId": "createTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "TCP check created", + "schema": { + "$ref": "#/definitions/tcp_check" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_check" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a TCP check configuration by it's index from the specified parent.", + "tags": [ + "TCPCheck" + ], + "summary": "Delete a TCP check", + "operationId": "deleteTCPCheckDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP check Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP check deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules": { + "get": { + "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return an array of all TCP Request Rules", + "operationId": "getAllTCPRequestRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Request Rules with the list given in parameter", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace an TCP Request Rule list", + "operationId": "replaceAllTCPRequestRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TCP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}": { + "get": { + "description": "Returns one TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return one TCP Request Rule", + "operationId": "getTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace a TCP Request Rule", + "operationId": "replaceTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "TCP Request Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Add a new TCP Request Rule", + "operationId": "createTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "TCP Request Rule created", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a TCP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Delete a TCP Request Rule", + "operationId": "deleteTCPRequestRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Request Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules": { + "get": { + "description": "Returns all TCP Response Rules that are configured in specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return an array of all TCP Response Rules", + "operationId": "getAllTCPResponseRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Response Rules with the list given in parameter", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule list", + "operationId": "replaceAllTCPResponseRuleDefaults", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TCP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}": { + "get": { + "description": "Returns one TCP Response Rule configuration by it's index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Return one TCP Response Rule", + "operationId": "getTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a TCP Response Rule configuration by it's Index in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Replace a TCP Response Rule", + "operationId": "replaceTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "TCP Response Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new TCP Response Rule of the specified type in the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Add a new TCP Response Rule", + "operationId": "createTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "TCP Response Rule created", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a TCP Response Rule configuration by it's index from the specified backend.", + "tags": [ + "TCPResponseRule" + ], + "summary": "Delete a TCP Response Rule", + "operationId": "deleteTCPResponseRuleDefaults", + "parameters": [ + { + "type": "integer", + "description": "TCP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps": { + "get": { + "description": "Returns an array of all configured FCGI applications.", + "tags": [ + "FCGIApp" + ], + "summary": "Return an array of FCGI apps", + "operationId": "getFCGIApps", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/fcgi_apps" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new FCGI application to the configuration file.", + "tags": [ + "FCGIApp" + ], + "summary": "Add an FCGI app", + "operationId": "createFCGIApp", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Application created", + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/fcgi_app" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps/{name}": { + "get": { + "description": "Returns one FCGI application configuration by its name.", + "tags": [ + "FCGIApp" + ], + "summary": "Return a FCGI app", + "operationId": "getFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Application name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/fcgi_app" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a FCGI application configuration by its name.", + "tags": [ + "FCGIApp" + ], + "summary": "Replace a FCGI app", + "operationId": "replaceFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Application name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Application replaced", + "schema": { + "$ref": "#/definitions/fcgi_app" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/fcgi_app" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes an FCGI application from the configuration by its name.", + "tags": [ + "FCGIApp" + ], + "summary": "Delete an FCGI app", + "operationId": "deleteFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Application name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Application deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls": { + "get": { + "description": "Returns all ACL lines that are configured in specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of ACLs with the list given in parameter", + "tags": [ + "ACL" + ], + "summary": "Replace an ACL list", + "operationId": "replaceAllAclFCGIApp", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acls" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All ACL lines replaced", + "schema": { + "$ref": "#/definitions/acls" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}": { + "get": { + "description": "Returns one ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return one ACL line", + "operationId": "getAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Replace a ACL line", + "operationId": "replaceAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "ACL line replaced", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Add a new ACL line", + "operationId": "createAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "ACL line created", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a ACL line configuration by it's index from the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Delete a ACL line", + "operationId": "deleteAclFCGIApp", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "ACL line deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends": { + "get": { + "description": "Returns an array of all configured frontends.", + "tags": [ + "Frontend" + ], + "summary": "Return an array of frontends", + "operationId": "getFrontends", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/frontends" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new frontend to the configuration file.", + "tags": [ + "Frontend" + ], + "summary": "Add a frontend", + "operationId": "createFrontend", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/frontend" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Frontend created", + "schema": { + "$ref": "#/definitions/frontend" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/frontend" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{name}": { + "get": { + "description": "Returns one frontend configuration by it's name.", + "tags": [ + "Frontend" + ], + "summary": "Return a frontend", + "operationId": "getFrontend", + "parameters": [ + { + "type": "string", + "description": "Frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/frontend" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a frontend configuration by it's name.", + "tags": [ + "Frontend" + ], + "summary": "Replace a frontend", + "operationId": "replaceFrontend", + "parameters": [ + { + "type": "string", + "description": "Frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/frontend" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Frontend replaced", + "schema": { + "$ref": "#/definitions/frontend" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/frontend" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a frontend from the configuration by it's name.", + "tags": [ + "Frontend" + ], + "summary": "Delete a frontend", + "operationId": "deleteFrontend", + "parameters": [ + { + "type": "string", + "description": "Frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Frontend deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/acls": { + "get": { + "description": "Returns all ACL lines that are configured in specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return an array of all ACL lines", + "operationId": "getAllAclFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "ACL name", + "name": "acl_name", + "in": "query" + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of ACLs with the list given in parameter", + "tags": [ + "ACL" + ], + "summary": "Replace an ACL list", + "operationId": "replaceAllAclFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acls" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All ACL lines replaced", + "schema": { + "$ref": "#/definitions/acls" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acls" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/acls/{index}": { + "get": { + "description": "Returns one ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Return one ACL line", + "operationId": "getAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a ACL line configuration by it's index in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Replace a ACL line", + "operationId": "replaceAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "ACL line replaced", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new ACL line of the specified type in the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Add a new ACL line", + "operationId": "createAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "ACL line created", + "schema": { + "$ref": "#/definitions/acl" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/acl" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a ACL line configuration by it's index from the specified parent.", + "tags": [ + "ACL" + ], + "summary": "Delete a ACL line", + "operationId": "deleteAclFrontend", + "parameters": [ + { + "type": "integer", + "description": "ACL line Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "ACL line deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules": { + "get": { + "description": "Returns all Backend Switching Rules that are configured in specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Return an array of all Backend Switching Rules", + "operationId": "getBackendSwitchingRules", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/backend_switching_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Backend Switching Rules with the list given in parameter", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Replace an Backend Switching Rule list", + "operationId": "replaceBackendSwitchingRules", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend_switching_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Backend Switching Rule lines replaced", + "schema": { + "$ref": "#/definitions/backend_switching_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend_switching_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}": { + "get": { + "description": "Returns one Backend Switching Rule configuration by it's index in the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Return one Backend Switching Rule", + "operationId": "getBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Backend Switching Rule configuration by it's index in the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Replace a Backend Switching Rule", + "operationId": "replaceBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Backend Switching Rule replaced", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Backend Switching Rule of the specified type in the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Add a new Backend Switching Rule", + "operationId": "createBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Backend Switching Rule created", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/backend_switching_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Backend Switching Rule configuration by it's index from the specified frontend.", + "tags": [ + "BackendSwitchingRule" + ], + "summary": "Delete a Backend Switching Rule", + "operationId": "deleteBackendSwitchingRule", + "parameters": [ + { + "type": "integer", + "description": "Switching Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Backend Switching Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/binds": { + "get": { + "description": "Returns an array of all binds that are configured in specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return an array of binds", + "operationId": "getAllBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new bind in the specified frontend in the configuration file.", + "tags": [ + "Bind" + ], + "summary": "Add a new bind", + "operationId": "createBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/binds/{name}": { + "get": { + "description": "Returns one bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return one bind", + "operationId": "getBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Replace a bind", + "operationId": "replaceBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Delete a bind", + "operationId": "deleteBindFrontend", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/captures": { + "get": { + "description": "Returns an array of all declare capture records that are configured in specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Return an array of declare captures", + "operationId": "getDeclareCaptures", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/captures" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of declare capture with the list given in parameter", + "tags": [ + "DeclareCapture" + ], + "summary": "Replace a declare capture list", + "operationId": "replaceDeclareCaptures", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/captures" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Declare capture lines replaced", + "schema": { + "$ref": "#/definitions/captures" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/captures" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/captures/{index}": { + "get": { + "description": "Returns one declare capture configuration by it's index in the specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Return one declare capture", + "operationId": "getDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/capture" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a declare capture configuration by it's index in the specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Replace a declare capture", + "operationId": "replaceDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/capture" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Declare Capture replaced", + "schema": { + "$ref": "#/definitions/capture" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/capture" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new declare capture in the specified frontend in the configuration file.", + "tags": [ + "DeclareCapture" + ], + "summary": "Add a new declare capture", + "operationId": "createDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/capture" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Declare capture created", + "schema": { + "$ref": "#/definitions/capture" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/capture" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a declare capture configuration by it's index in the specified frontend.", + "tags": [ + "DeclareCapture" + ], + "summary": "Delete a declare capture", + "operationId": "deleteDeclareCapture", + "parameters": [ + { + "type": "integer", + "description": "Declare Capture Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Declare Capture deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/filters": { + "get": { + "description": "Returns all Filters that are configured in specified parent.", + "tags": [ + "Filter" + ], + "summary": "Return an array of all Filters", + "operationId": "getAllFilterFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/filters" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Filters with the list given in parameter", + "tags": [ + "Filter" + ], + "summary": "Replace a Filter list", + "operationId": "replaceAllFilterFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filters" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Filter lines replaced", + "schema": { + "$ref": "#/definitions/filters" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filters" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/filters/{index}": { + "get": { + "description": "Returns one Filter configuration by it's index in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Return one Filter", + "operationId": "getFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Filter configuration by it's index in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Replace a Filter", + "operationId": "replaceFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filter" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Filter replaced", + "schema": { + "$ref": "#/definitions/filter" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Filter of the specified type in the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Add a new Filter", + "operationId": "createFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/filter" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Filter created", + "schema": { + "$ref": "#/definitions/filter" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/filter" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Filter configuration by it's index from the specified parent.", + "tags": [ + "Filter" + ], + "summary": "Delete a Filter", + "operationId": "deleteFilterFrontend", + "parameters": [ + { + "type": "integer", + "description": "Filter Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Filter deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules": { + "get": { + "description": "Returns all HTTP After Response Rules that are configured in specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return an array of all HTTP After Response Rules", + "operationId": "getAllHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP After Response Rules with the list given in parameter", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace an HTTP After Response Rules list", + "operationId": "replaceAllHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}": { + "get": { + "description": "Returns one HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Return one HTTP After Response Rule", + "operationId": "getHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP After Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Replace a HTTP After Response Rule", + "operationId": "replaceHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP After Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP After Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Add a new HTTP After Response Rule", + "operationId": "createHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_after_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP After Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPAfterResponseRule" + ], + "summary": "Delete a HTTP After Response Rule", + "operationId": "deleteHTTPAfterResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP After Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP After Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules": { + "get": { + "description": "Returns all HTTP Error Rules that are configured in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return an array of all HTTP Error Rules", + "operationId": "getAllHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Error Rules with the list given in parameter", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace an HTTP Error Rules list", + "operationId": "replaceAllHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Error Rules lines replaced", + "schema": { + "$ref": "#/definitions/http_error_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}": { + "get": { + "description": "Returns one HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Return one HTTP Error Rule", + "operationId": "getHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Error Rule configuration by its index in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Replace a HTTP Error Rule", + "operationId": "replaceHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Error Rule replaced", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Error Rule of the specified type in the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Add a new HTTP Error Rule", + "operationId": "createHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Error Rule created", + "schema": { + "$ref": "#/definitions/http_error_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_error_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Error Rule configuration by its index from the specified parent.", + "tags": [ + "HTTPErrorRule" + ], + "summary": "Delete a HTTP Error Rule", + "operationId": "deleteHTTPErrorRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Error Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Error Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules": { + "get": { + "description": "Returns all HTTP Request Rules that are configured in specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return an array of all HTTP Request Rules", + "operationId": "getAllHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Request Rules with the list given in parameter", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace an HTTP Request Rule list", + "operationId": "replaceAllHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}": { + "get": { + "description": "Returns one HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Return one HTTP Request Rule", + "operationId": "getHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Replace a HTTP Request Rule", + "operationId": "replaceHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Request Rule replaced", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Add a new HTTP Request Rule", + "operationId": "createHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Request Rule created", + "schema": { + "$ref": "#/definitions/http_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPRequestRule" + ], + "summary": "Delete a HTTP Request Rule", + "operationId": "deleteHTTPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Request Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules": { + "get": { + "description": "Returns all HTTP Response Rules that are configured in specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return an array of all HTTP Response Rules", + "operationId": "getAllHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of HTTP Response Rules with the list given in parameter", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace an HTTP Response Rule list", + "operationId": "replaceAllHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All HTTP Response Rule lines replaced", + "schema": { + "$ref": "#/definitions/http_response_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}": { + "get": { + "description": "Returns one HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Return one HTTP Response Rule", + "operationId": "getHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a HTTP Response Rule configuration by it's index in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Replace a HTTP Response Rule", + "operationId": "replaceHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "HTTP Response Rule replaced", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Add a new HTTP Response Rule", + "operationId": "createHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/http_response_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_response_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a HTTP Response Rule configuration by it's index from the specified parent.", + "tags": [ + "HTTPResponseRule" + ], + "summary": "Delete a HTTP Response Rule", + "operationId": "deleteHTTPResponseRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "HTTP Response Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "HTTP Response Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetFrontend", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules": { + "get": { + "description": "Returns all QUIC Initial rules that are configured in specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return an array of all QUIC Initial rules", + "operationId": "getAllQUICInitialRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of QUIC Initial rules with the list given in parameter", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace an QUIC Initial rules list", + "operationId": "replaceAllQUICInitialRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TTP After Response Rules lines replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}": { + "get": { + "description": "Returns one QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Return one QUIC Initial Rule", + "operationId": "getQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a QUIC Initial Rule configuration by it's index in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Replace a QUIC Initial Rule", + "operationId": "replaceQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "QUIC Initial Rule replaced", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new QUIC Initial Rule of the specified type in the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Add a new QUIC Initial Rule", + "operationId": "createQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "HTTP Response Rule created", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/quic_initial_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a QUIC Initial Rule configuration by it's index from the specified parent.", + "tags": [ + "QUICInitialRule" + ], + "summary": "Delete a QUIC Initial Rule", + "operationId": "deleteQUICInitialRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "QUIC Initial Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "QUIC Initial Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses": { + "get": { + "description": "Returns an array of all SSLFrontUses that are configured in specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Return an array of SSLFrontUses", + "operationId": "getAllSSLFrontUses", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_front_uses" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new SSLFrontUse in the specified frontend in the configuration file.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Add a new SSLFrontUse", + "operationId": "createSSLFrontUse", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "SSLFrontUse created", + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ssl_front_use" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}": { + "get": { + "description": "Returns one SSLFrontUse configuration by its index in the specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Return one SSLFrontUse", + "operationId": "getSSLFrontUse", + "parameters": [ + { + "type": "integer", + "description": "SSLFrontUse index (zero-based)", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_front_use" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces an SSLFrontUse configuration by its index in the specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Replace an SSLFrontUse", + "operationId": "replaceSSLFrontUse", + "parameters": [ + { + "type": "integer", + "description": "SSLFrontUse index (zero-based)", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "SSLFrontUse replaced", + "schema": { + "$ref": "#/definitions/ssl_front_use" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ssl_front_use" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes an SSLFrontUse configuration by its index in the specified frontend.", + "tags": [ + "SSLFrontUse" + ], + "summary": "Delete an SSLFrontUse", + "operationId": "deleteSSLFrontUse", + "parameters": [ + { + "type": "integer", + "description": "SSLFrontUse index (zero-based)", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "SSLFrontUse deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules": { + "get": { + "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return an array of all TCP Request Rules", + "operationId": "getAllTCPRequestRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of TCP Request Rules with the list given in parameter", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace an TCP Request Rule list", + "operationId": "replaceAllTCPRequestRuleFrontend", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All TCP Request Rule lines replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rules" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}": { + "get": { + "description": "Returns one TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Return one TCP Request Rule", + "operationId": "getTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a TCP Request Rule configuration by it's index in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Replace a TCP Request Rule", + "operationId": "replaceTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "TCP Request Rule replaced", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Add a new TCP Request Rule", + "operationId": "createTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "TCP Request Rule created", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/tcp_request_rule" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a TCP Request Rule configuration by it's index from the specified parent.", + "tags": [ + "TCPRequestRule" + ], + "summary": "Delete a TCP Request Rule", + "operationId": "deleteTCPRequestRuleFrontend", + "parameters": [ + { + "type": "integer", + "description": "TCP Request Rule Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "TCP Request Rule deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/global": { + "get": { + "description": "Returns global part of configuration.", + "tags": [ + "Global" + ], + "summary": "Return a global part of configuration", + "operationId": "getGlobal", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/global" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replace global part of config", + "tags": [ + "Global" + ], + "summary": "Replace global", + "operationId": "replaceGlobal", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/global" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Global replaced", + "schema": { + "$ref": "#/definitions/global" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/global" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/global/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetGlobal", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetGlobal", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/global/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetGlobal", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/groups": { + "get": { + "tags": [ + "Group" + ], + "summary": "Return an array of userlist groups", + "operationId": "getGroups", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/groups" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "tags": [ + "Group" + ], + "summary": "Add a new userlist group", + "operationId": "createGroup", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Group created", + "schema": { + "$ref": "#/definitions/group" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/group" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/groups/{name}": { + "get": { + "tags": [ + "Group" + ], + "summary": "Return one userlist group", + "operationId": "getGroup", + "parameters": [ + { + "type": "string", + "description": "Group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/group" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "tags": [ + "Group" + ], + "summary": "Replace a group", + "operationId": "replaceGroup", + "parameters": [ + { + "type": "string", + "description": "group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/group" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Group replaced", + "schema": { + "$ref": "#/definitions/group" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/group" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "tags": [ + "Group" + ], + "summary": "Delete a group", + "operationId": "deleteGroup", + "parameters": [ + { + "type": "string", + "description": "group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Group deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/http_errors_sections": { + "get": { + "description": "Returns an array of all configured http-error sections.", + "tags": [ + "HTTPErrors" + ], + "summary": "Return an array of http-error sections", + "operationId": "getHTTPErrorsSections", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_errors_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new http-error section to the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Add a new http-error section", + "operationId": "createHTTPErrorsSection", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "http-error section created", + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_errors_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/http_errors_sections/{name}": { + "get": { + "description": "Returns one http-error section with a given name from the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Return a http-error section", + "operationId": "getHTTPErrorsSection", + "parameters": [ + { + "type": "string", + "description": "http-error section name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/http_errors_section" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a http-error section with a given name in the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Replace a http-error section", + "operationId": "replaceHTTPErrorsSection", + "parameters": [ + { + "type": "string", + "description": "http-error section name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "http-error section updated", + "schema": { + "$ref": "#/definitions/http_errors_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/http_errors_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a http-error section with a given name from the configuration.", + "tags": [ + "HTTPErrors" + ], + "summary": "Delete a http-error section", + "operationId": "deleteHTTPErrorsSection", + "parameters": [ + { + "type": "string", + "description": "http-error section name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "http-error section deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards": { + "get": { + "description": "Returns an array of all configured log forwards.", + "tags": [ + "LogForward" + ], + "summary": "Return an array of log forwards", + "operationId": "getLogForwards", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_forwards" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new log_forward to the configuration file.", + "tags": [ + "LogForward" + ], + "summary": "Add a log forward", + "operationId": "createLogForward", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Forward created", + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_forward" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{name}": { + "get": { + "description": "Returns one log forward configuration by it's name.", + "tags": [ + "LogForward" + ], + "summary": "Return a log forward", + "operationId": "getLogForward", + "parameters": [ + { + "type": "string", + "description": "Log Forward name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_forward" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a log forward configuration by it's name.", + "tags": [ + "LogForward" + ], + "summary": "Replace a log forward", + "operationId": "replaceLogForward", + "parameters": [ + { + "type": "string", + "description": "Log Forward name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Log Forward replaced", + "schema": { + "$ref": "#/definitions/log_forward" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_forward" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a log forward from the configuration by it's name.", + "tags": [ + "LogForward" + ], + "summary": "Delete a log forward", + "operationId": "deleteLogForward", + "parameters": [ + { + "type": "string", + "description": "Log Forward name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Forward deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/binds": { + "get": { + "description": "Returns an array of all binds that are configured in specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return an array of binds", + "operationId": "getAllBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new bind in the specified frontend in the configuration file.", + "tags": [ + "Bind" + ], + "summary": "Add a new bind", + "operationId": "createBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}": { + "get": { + "description": "Returns one bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return one bind", + "operationId": "getBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Replace a bind", + "operationId": "replaceBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Delete a bind", + "operationId": "deleteBindLogForward", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds": { + "get": { + "description": "Returns an array of all dgram binds that are configured in specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Return an array of dgram binds", + "operationId": "getDgramBinds", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/dgram_binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new dgram bind in the specified log forward in the configuration file.", + "tags": [ + "DgramBind" + ], + "summary": "Add a new dgram bind", + "operationId": "createDgramBind", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/dgram_bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}": { + "get": { + "description": "Returns one dgram bind configuration by it's name in the specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Return one dgram bind", + "operationId": "getDgramBind", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/dgram_bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a dgram bind configuration by it's name in the specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Replace a dgram bind", + "operationId": "replaceDgramBind", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/dgram_bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/dgram_bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a dgram bind configuration by it's name in the specified log forward.", + "tags": [ + "DgramBind" + ], + "summary": "Delete a dgram bind", + "operationId": "deleteDgramBind", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetLogForward", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetLogForward", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetLogForward", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_profiles": { + "get": { + "description": "Returns an array of all the configured log_profile sections in HAProxy", + "tags": [ + "LogProfile" + ], + "summary": "Return all the Log Profiles", + "operationId": "getLogProfiles", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_profiles" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates a new log_profile section", + "tags": [ + "LogProfile" + ], + "summary": "Add a new Log Profile", + "operationId": "createLogProfile", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Profile created", + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_profile" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/log_profiles/{name}": { + "get": { + "description": "Find a log_profile section by its name", + "tags": [ + "LogProfile" + ], + "summary": "Return a Log Profile", + "operationId": "getLogProfile", + "parameters": [ + { + "type": "string", + "description": "log_profile name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_profile" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Modifies a log_profile's configuration by its name", + "tags": [ + "LogProfile" + ], + "summary": "Modify a Log Profile", + "operationId": "editLogProfile", + "parameters": [ + { + "type": "string", + "description": "log_profile name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "log_profile configuration updated", + "schema": { + "$ref": "#/definitions/log_profile" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_profile" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a log_profile section from the configuration", + "tags": [ + "LogProfile" + ], + "summary": "Delete a Log Profile", + "operationId": "deleteLogProfile", + "parameters": [ + { + "type": "string", + "description": "log_profile name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "log_profile deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/mailer_entries": { + "get": { + "description": "Returns an array of all the mailer_entries configured in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Return an array of mailer_entries", + "operationId": "getMailerEntries", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailer_entries" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new mailer entry to the specified mailers section in the configuration file.", + "tags": [ + "MailerEntry" + ], + "summary": "Add a new mailer_entry", + "operationId": "createMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "MailerEntry created", + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/mailer_entries/{name}": { + "get": { + "description": "Returns one mailer_entry configuration by it's name in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Return one mailer_entry", + "operationId": "getMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "MailerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent mailers name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailer_entry" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a mailer entry configuration by it's name in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Replace a mailer_entry", + "operationId": "replaceMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "MailerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "MailerEntry replaced", + "schema": { + "$ref": "#/definitions/mailer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a mailer entry configuration by it's name in the specified mailers section.", + "tags": [ + "MailerEntry" + ], + "summary": "Delete a mailer_entry", + "operationId": "deleteMailerEntry", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "MailerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent mailers section name", + "name": "mailers_section", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "MailerEntry deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/mailers_section": { + "get": { + "description": "Returns an array of all the configured mailers in HAProxy", + "tags": [ + "Mailers" + ], + "summary": "Return an array of mailers sections", + "operationId": "getMailersSections", + "deprecated": true, + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailers_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates a new empty Mailers section", + "tags": [ + "Mailers" + ], + "summary": "Add a new Mailers section", + "operationId": "createMailersSection", + "deprecated": true, + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Mailers created", + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailers_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/mailers_section/{name}": { + "get": { + "description": "Returns one mailers configuration by it's name.", + "tags": [ + "Mailers" + ], + "summary": "Return a Mailers section", + "operationId": "getMailersSection", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Mailers name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/mailers_section" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Modifies a mailers configuration by it's name.", + "tags": [ + "Mailers" + ], + "summary": "Modify a Mailers section", + "operationId": "editMailersSection", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Mailers name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Mailers configuration updated", + "schema": { + "$ref": "#/definitions/mailers_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/mailers_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a mailers from the configuration by it's name.", + "tags": [ + "Mailers" + ], + "summary": "Delete a Mailers section", + "operationId": "deleteMailersSection", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Mailers name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Mailers deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/nameservers": { + "get": { + "description": "Returns an array of all configured nameservers.", + "tags": [ + "Nameserver" + ], + "summary": "Return an array of nameservers", + "operationId": "getNameservers", + "parameters": [ + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/nameservers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new nameserver to the resolvers section.", + "tags": [ + "Nameserver" + ], + "summary": "Add a nameserver", + "operationId": "createNameserver", + "parameters": [ + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Nameserver created", + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/nameserver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/nameservers/{name}": { + "get": { + "description": "Returns one nameserver configuration by it's name.", + "tags": [ + "Nameserver" + ], + "summary": "Return a nameserver", + "operationId": "getNameserver", + "parameters": [ + { + "type": "string", + "description": "Nameserver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/nameserver" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a nameserver configuration by it's name.", + "tags": [ + "Nameserver" + ], + "summary": "Replace a nameserver", + "operationId": "replaceNameserver", + "parameters": [ + { + "type": "string", + "description": "Nameserver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Nameserver replaced", + "schema": { + "$ref": "#/definitions/nameserver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/nameserver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a nameserver from the resolvers section by it's name.", + "tags": [ + "Nameserver" + ], + "summary": "Delete a nameserver", + "operationId": "deleteNameserver", + "parameters": [ + { + "type": "string", + "description": "Nameserver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent resolver name", + "name": "resolver", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Nameserver deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peer_entries": { + "get": { + "description": "Returns an array of all peer_entries that are configured in specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Return an array of peer_entries", + "operationId": "getPeerEntries", + "parameters": [ + { + "type": "string", + "description": "Parent peer section name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_entries" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new peer entry in the specified peer section in the configuration file.", + "tags": [ + "PeerEntry" + ], + "summary": "Add a new peer_entry", + "operationId": "createPeerEntry", + "parameters": [ + { + "type": "string", + "description": "Parent peer section name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "PeerEntry created", + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/peer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peer_entries/{name}": { + "get": { + "description": "Returns one peer_entry configuration by it's name in the specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Return one peer_entry", + "operationId": "getPeerEntry", + "parameters": [ + { + "type": "string", + "description": "PeerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent peers name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_entry" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a peer entry configuration by it's name in the specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Replace a peer_entry", + "operationId": "replacePeerEntry", + "parameters": [ + { + "type": "string", + "description": "PeerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent peers name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "PeerEntry replaced", + "schema": { + "$ref": "#/definitions/peer_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/peer_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a peer entry configuration by it's name in the specified peer section.", + "tags": [ + "PeerEntry" + ], + "summary": "Delete a peer_entry", + "operationId": "deletePeerEntry", + "parameters": [ + { + "type": "string", + "description": "PeerEntry name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent peers name", + "name": "peer_section", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "PeerEntry deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peer_section": { + "get": { + "description": "Returns an array of all configured peer_section.", + "tags": [ + "Peer" + ], + "summary": "Return an array of peer_section", + "operationId": "getPeerSections", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_sections" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new peer to the configuration file.", + "tags": [ + "Peer" + ], + "summary": "Add a peer", + "operationId": "createPeer", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/peer_section" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Peer created", + "schema": { + "$ref": "#/definitions/peer_section" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/peer_section" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peer_section/{name}": { + "get": { + "description": "Returns one peer configuration by it's name.", + "tags": [ + "Peer" + ], + "summary": "Return a peer", + "operationId": "getPeerSection", + "parameters": [ + { + "type": "string", + "description": "Peer name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/peer_section" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a peer from the configuration by it's name.", + "tags": [ + "Peer" + ], + "summary": "Delete a peer", + "operationId": "deletePeer", + "parameters": [ + { + "type": "string", + "description": "Peer name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Peer deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/binds": { + "get": { + "description": "Returns an array of all binds that are configured in specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return an array of binds", + "operationId": "getAllBindPeer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/binds" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new bind in the specified frontend in the configuration file.", + "tags": [ + "Bind" + ], + "summary": "Add a new bind", + "operationId": "createBindPeer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Bind created", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/binds/{name}": { + "get": { + "description": "Returns one bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Return one bind", + "operationId": "getBindPeer", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Replace a bind", + "operationId": "replaceBindPeer", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bind" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Bind replaced", + "schema": { + "$ref": "#/definitions/bind" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/bind" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a bind configuration by it's name in the specified frontend.", + "tags": [ + "Bind" + ], + "summary": "Delete a bind", + "operationId": "deleteBindPeer", + "parameters": [ + { + "type": "string", + "description": "Bind name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Bind deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/log_targets": { + "get": { + "description": "Returns all Log Targets that are configured in specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return an array of all Log Targets", + "operationId": "getAllLogTargetPeer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a whole list of Log Targets with the list given in parameter", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target list", + "operationId": "replaceAllLogTargetPeer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "All Log Target lines replaced", + "schema": { + "$ref": "#/definitions/log_targets" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_targets" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}": { + "get": { + "description": "Returns one Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Return one Log Target", + "operationId": "getLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a Log Target configuration by it's index in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Replace a Log Target", + "operationId": "replaceLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Log Target replaced", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new Log Target of the specified type in the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Add a new Log Target", + "operationId": "createLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/log_target" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Log Target created", + "schema": { + "$ref": "#/definitions/log_target" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/log_target" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a Log Target configuration by it's index from the specified parent.", + "tags": [ + "LogTarget" + ], + "summary": "Delete a Log Target", + "operationId": "deleteLogTargetPeer", + "parameters": [ + { + "type": "integer", + "description": "Log Target Index", + "name": "index", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Log Target deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/servers": { + "get": { + "description": "Returns an array of all servers that are configured in specified backend.", + "tags": [ + "Server" + ], + "summary": "Return an array of servers", + "operationId": "getAllServerPeer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/servers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new server in the specified backend in the configuration file.", + "tags": [ + "Server" + ], + "summary": "Add a new server", + "operationId": "createServerPeer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Server created", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/servers/{name}": { + "get": { + "description": "Returns one server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Return one server", + "operationId": "getServerPeer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Replace a server", + "operationId": "replaceServerPeer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Server replaced", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Delete a server", + "operationId": "deleteServerPeer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Server deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/tables": { + "get": { + "description": "Returns an array of all tables that are configured in specified peer section.", + "tags": [ + "Table" + ], + "summary": "Return an array of tables", + "operationId": "getTables", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/tables" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new table in the specified peer section in the configuration file.", + "tags": [ + "Table" + ], + "summary": "Add a new table", + "operationId": "createTable", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/table" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Table created", + "schema": { + "$ref": "#/definitions/table" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/table" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/peers/{parent_name}/tables/{name}": { + "get": { + "description": "Returns one table configuration by it's name in the specified peer section.", + "tags": [ + "Table" + ], + "summary": "Return one table", + "operationId": "getTable", + "parameters": [ + { + "type": "string", + "description": "Table name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/table" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a table configuration by it's name in the specified peer section.", + "tags": [ + "Table" + ], + "summary": "Replace a table", + "operationId": "replaceTable", + "parameters": [ + { + "type": "string", + "description": "Table name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/table" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Table replaced", + "schema": { + "$ref": "#/definitions/table" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/table" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a table configuration by it's name in the specified peer section.", + "tags": [ + "Table" + ], + "summary": "Delete a table", + "operationId": "deleteTable", + "parameters": [ + { + "type": "string", + "description": "Table name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Table deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/programs": { + "get": { + "description": "Returns an array of all configured programs in the process-manager configuration file.", + "tags": [ + "ProcessManager" + ], + "summary": "Return an array of programs", + "operationId": "getPrograms", + "deprecated": true, + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/programs" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new program to the process-manager configuration file.", + "tags": [ + "ProcessManager" + ], + "summary": "Add a program", + "operationId": "createProgram", + "deprecated": true, + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/program" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Program created", + "schema": { + "$ref": "#/definitions/program" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/program" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/programs/{name}": { + "get": { + "description": "Returns one program by its name from the process-manager configuration file.", + "tags": [ + "ProcessManager" + ], + "summary": "Return a program", + "operationId": "getProgram", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Program name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/program" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a program from the process-manager configuration by its name.", + "tags": [ + "ProcessManager" + ], + "summary": "Replace a program", + "operationId": "replaceProgram", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Program name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/program" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Program replaced", + "schema": { + "$ref": "#/definitions/program" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/program" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a program from the process-manager configuration file by its name.", + "tags": [ + "ProcessManager" + ], + "summary": "Delete a program", + "operationId": "deleteProgram", + "deprecated": true, + "parameters": [ + { + "type": "string", + "description": "Program name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Program deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/raw": { + "get": { + "description": "Returns HAProxy configuration file in plain text", + "produces": [ + "text/plain" + ], + "tags": [ + "Configuration" + ], + "summary": "Return HAProxy configuration", + "operationId": "getHAProxyConfiguration", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Operation successful", + "schema": { + "type": "string" + }, + "headers": { + "Cluster-Version": { + "type": "string", + "description": "Cluster configuration version" + }, + "Configuration-Checksum": { + "type": "string", + "description": "Configuration file md5 checksum" + }, + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "type": "string" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Push a new haproxy configuration file in plain text", + "consumes": [ + "text/plain" + ], + "produces": [ + "text/plain" + ], + "tags": [ + "Configuration" + ], + "summary": "Push new haproxy configuration", + "operationId": "postHAProxyConfiguration", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "type": "boolean", + "default": false, + "description": "If set, no version check will be done and the pushed config will be enforced", + "name": "skip_version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated and runtime actions from X-Runtime-Actions will be applied", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, only validates configuration, without applying it", + "name": "only_validate", + "in": "query" + }, + { + "type": "string", + "description": "List of Runtime API commands with parameters separated by ';'", + "name": "X-Runtime-Actions", + "in": "header" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "New HAProxy configuration pushed", + "schema": { + "type": "string" + }, + "headers": { + "Cluster-Version": { + "type": "string", + "description": "Cluster configuration version" + }, + "Configuration-Checksum": { + "type": "string", + "description": "Configuration file md5 checksum" + }, + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "type": "string" + }, + "headers": { + "Cluster-Version": { + "type": "string", + "description": "Cluster configuration version" + }, + "Configuration-Checksum": { + "type": "string", + "description": "Configuration file md5 checksum" + }, + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + }, + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "type": "string" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "type": "string" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/resolvers": { + "get": { + "description": "Returns an array of all configured resolvers.", + "tags": [ + "Resolver" + ], + "summary": "Return an array of resolvers", + "operationId": "getResolvers", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/resolvers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new resolver section to the configuration file.", + "tags": [ + "Resolver" + ], + "summary": "Add a resolver", + "operationId": "createResolver", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/resolver" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Resolver created", + "schema": { + "$ref": "#/definitions/resolver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/resolver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/resolvers/{name}": { + "get": { + "description": "Returns one resolver section configuration by it's name.", + "tags": [ + "Resolver" + ], + "summary": "Return a resolver", + "operationId": "getResolver", + "parameters": [ + { + "type": "string", + "description": "Resolver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/resolver" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a resolver configuration by it's name.", + "tags": [ + "Resolver" + ], + "summary": "Replace a resolver", + "operationId": "replaceResolver", + "parameters": [ + { + "type": "string", + "description": "Resolver name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/resolver" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Resolver replaced", + "schema": { + "$ref": "#/definitions/resolver" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/resolver" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a resolver from the configuration by it's name.", + "tags": [ + "Resolver" + ], + "summary": "Delete a resolver", + "operationId": "deleteResolver", + "parameters": [ + { + "type": "string", + "description": "Resolver name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Resolver deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/rings": { + "get": { + "description": "Returns an array of all configured rings.", + "tags": [ + "Ring" + ], + "summary": "Return an array of rings", + "operationId": "getRings", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/rings" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new ring to the configuration file.", + "tags": [ + "Ring" + ], + "summary": "Add a ring", + "operationId": "createRing", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ring" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Ring created", + "schema": { + "$ref": "#/definitions/ring" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ring" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/rings/{name}": { + "get": { + "description": "Returns one ring configuration by it's name.", + "tags": [ + "Ring" + ], + "summary": "Return a ring", + "operationId": "getRing", + "parameters": [ + { + "type": "string", + "description": "Ring name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ring" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a ring configuration by it's name.", + "tags": [ + "Ring" + ], + "summary": "Replace a ring", + "operationId": "replaceRing", + "parameters": [ + { + "type": "string", + "description": "Ring name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ring" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Ring replaced", + "schema": { + "$ref": "#/definitions/ring" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/ring" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a ring from the configuration by it's name.", + "tags": [ + "Ring" + ], + "summary": "Delete a ring", + "operationId": "deleteRing", + "parameters": [ + { + "type": "string", + "description": "Ring name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Ring deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/rings/{parent_name}/servers": { + "get": { + "description": "Returns an array of all servers that are configured in specified backend.", + "tags": [ + "Server" + ], + "summary": "Return an array of servers", + "operationId": "getAllServerRing", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/servers" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new server in the specified backend in the configuration file.", + "tags": [ + "Server" + ], + "summary": "Add a new server", + "operationId": "createServerRing", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Server created", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/rings/{parent_name}/servers/{name}": { + "get": { + "description": "Returns one server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Return one server", + "operationId": "getServerRing", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Replace a server", + "operationId": "replaceServerRing", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/server" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Server replaced", + "schema": { + "$ref": "#/definitions/server" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/server" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a server configuration by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Delete a server", + "operationId": "deleteServerRing", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Server deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/traces": { + "get": { + "description": "Return the traces section contents.", + "tags": [ + "Traces" + ], + "summary": "Return the traces section contents", + "operationId": "getTraces", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/traces" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replace the traces section contents", + "tags": [ + "Traces" + ], + "summary": "Replace traces", + "operationId": "replaceTraces", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/traces" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Traces replaced", + "schema": { + "$ref": "#/definitions/traces" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/traces" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Create the traces section.", + "tags": [ + "Traces" + ], + "summary": "Create the traces section", + "operationId": "createTraces", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/traces" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Traces section created", + "schema": { + "$ref": "#/definitions/traces" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/traces" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Delete the whole traces section.", + "tags": [ + "Traces" + ], + "summary": "Delete the traces section", + "operationId": "deleteTraces", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Traces section deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/traces/entries": { + "post": { + "description": "Adds a new trace entry into the traces section. The traces section will be created if needed.", + "tags": [ + "Traces" + ], + "summary": "Add a new trace entry", + "operationId": "createTraceEntry", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/trace_entry" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Trace entry added", + "schema": { + "$ref": "#/definitions/trace_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/trace_entry" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a trace entry from the traces section.", + "tags": [ + "Traces" + ], + "summary": "Delete a trace entry", + "operationId": "deleteTraceEntry", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/trace_entry" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Trace entry deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/userlists": { + "get": { + "description": "Returns an array of all configured userlists.", + "tags": [ + "Userlist" + ], + "summary": "Return an array of userlists", + "operationId": "getUserlists", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/userlists" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new userlist to the configuration file.", + "tags": [ + "Userlist" + ], + "summary": "Add a new userlist", + "operationId": "createUserlist", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/userlist" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Userlist created", + "schema": { + "$ref": "#/definitions/userlist" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/userlist" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/userlists/{name}": { + "get": { + "description": "Returns one userlist configuration by it's name.", + "tags": [ + "Userlist" + ], + "summary": "Return one userlist", + "operationId": "getUserlist", + "parameters": [ + { + "type": "string", + "description": "Userlist name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/userlist" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a userlist configuration by it's name.", + "tags": [ + "Userlist" + ], + "summary": "Delete a userlist", + "operationId": "deleteUserlist", + "parameters": [ + { + "type": "string", + "description": "Userlist name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Userlist deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/users": { + "get": { + "tags": [ + "User" + ], + "summary": "Return an array of userlist users", + "operationId": "getUsers", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/users" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "tags": [ + "User" + ], + "summary": "Add a new userlist user", + "operationId": "createUser", + "parameters": [ + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "User created", + "schema": { + "$ref": "#/definitions/user" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/user" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/users/{username}": { + "get": { + "tags": [ + "User" + ], + "summary": "Return one userlist user", + "operationId": "getUser", + "parameters": [ + { + "type": "string", + "description": "User username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/user" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "tags": [ + "User" + ], + "summary": "Replace a user", + "operationId": "replaceUser", + "parameters": [ + { + "type": "string", + "description": "User username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/user" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "User replaced", + "schema": { + "$ref": "#/definitions/user" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/user" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "tags": [ + "User" + ], + "summary": "Delete a user", + "operationId": "deleteUser", + "parameters": [ + { + "type": "string", + "description": "User username", + "name": "username", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent userlist name", + "name": "userlist", + "in": "query", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "User deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/configuration/version": { + "get": { + "description": "Returns configuration version.", + "tags": [ + "Configuration" + ], + "summary": "Return a configuration version", + "operationId": "getConfigurationVersion", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Configuration version", + "schema": { + "type": "integer" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/reloads": { + "get": { + "description": "Returns a list of HAProxy reloads.", + "produces": [ + "application/json" + ], + "tags": [ + "Reloads" + ], + "summary": "Return list of HAProxy Reloads.", + "operationId": "getReloads", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/reloads" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/reloads/{id}": { + "get": { + "description": "Returns one HAProxy reload status.", + "tags": [ + "Reloads" + ], + "summary": "Return one HAProxy reload status", + "operationId": "getReload", + "parameters": [ + { + "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$", + "type": "string", + "description": "Reload id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/reload" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime": { + "get": { + "description": "Returns a list of endpoints to be used for advanced runtime settings of HAProxy objects.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy advanced runtime endpoints", + "operationId": "getRuntimeEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/acls": { + "get": { + "description": "Returns all ACL files using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an array of all ACL files", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_files" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/acls/{id}": { + "get": { + "description": "Returns an ACL file by id using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an ACL file", + "parameters": [ + { + "type": "string", + "description": "ACL file entry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_file" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/acls/{parent_name}/entries": { + "get": { + "description": "Returns an ACL runtime setting using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an ACL entries", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_files_entries" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Adds a new ACL payload.", + "tags": [ + "ACL Runtime" + ], + "summary": "Add a new ACL payload", + "operationId": "addPayloadRuntimeACL", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl_files_entries" + } + } + ], + "responses": { + "201": { + "description": "ACL payload added", + "schema": { + "$ref": "#/definitions/acl_files_entries" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds an entry into the ACL file using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Add entry to an ACL file", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/acl_file_entry" + } + } + ], + "responses": { + "201": { + "description": "ACL entry created", + "schema": { + "$ref": "#/definitions/acl_file_entry" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/acls/{parent_name}/entries/{id}": { + "get": { + "description": "Returns the ACL entry by its ID using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Return an ACL entry", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "File entry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acl_file_entry" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes the entry from the ACL by its value using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "ACL Runtime" + ], + "summary": "Delete an ACL entry", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "File entry ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Successful operation" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/acme": { + "get": { + "description": "Returns the status of each managed ACME certificate.", + "tags": [ + "AcmeRuntime" + ], + "summary": "ACME Status", + "operationId": "getAcmeStatus", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/acme_status" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Force renewal of an ACME certificate.", + "tags": [ + "AcmeRuntime" + ], + "summary": "Renew ACME certificate", + "operationId": "renewAcmeCertificate", + "parameters": [ + { + "type": "string", + "description": "Certificate file name", + "name": "certificate", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Operation started" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/backends/{parent_name}/servers": { + "get": { + "description": "Returns an array of all servers' runtime settings.", + "tags": [ + "Server" + ], + "summary": "Return an array of runtime servers' settings", + "operationId": "getAllRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/runtime_servers" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new server to the specified backend", + "tags": [ + "Server" + ], + "summary": "Adds a new server to a backend", + "operationId": "addRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/runtime_add_server" + } + } + ], + "responses": { + "201": { + "description": "Server added", + "schema": { + "$ref": "#/definitions/runtime_add_server" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/backends/{parent_name}/servers/{name}": { + "get": { + "description": "Returns one server runtime settings by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Return one server runtime settings", + "operationId": "getRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/runtime_server" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a server transient settings by it's name in the specified backend.", + "tags": [ + "Server" + ], + "summary": "Replace server transient settings", + "operationId": "replaceRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/runtime_server" + } + } + ], + "responses": { + "200": { + "description": "Server transient settings replaced", + "schema": { + "$ref": "#/definitions/runtime_server" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a server from the specified backend", + "tags": [ + "Server" + ], + "summary": "Deletes a server from a backend", + "operationId": "deleteRuntimeServer", + "parameters": [ + { + "type": "string", + "description": "Server name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Server deleted" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/info": { + "get": { + "description": "Return HAProxy process information", + "produces": [ + "application/json" + ], + "tags": [ + "Information" + ], + "summary": "Return HAProxy process information", + "operationId": "getHaproxyProcessInfo", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/process_info" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/maps": { + "get": { + "description": "Returns runtime map files.", + "tags": [ + "Maps" + ], + "summary": "Return runtime map files", + "operationId": "getAllRuntimeMapFiles", + "parameters": [ + { + "type": "boolean", + "default": false, + "description": "If true, also show unmanaged map files loaded in haproxy", + "name": "include_unmanaged", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/maps" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/maps/{name}": { + "get": { + "description": "Returns one runtime map file.", + "tags": [ + "Maps" + ], + "summary": "Return one runtime map file", + "operationId": "getOneRuntimeMap", + "parameters": [ + { + "type": "string", + "description": "Map file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/map" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Adds a new map payload.", + "tags": [ + "Maps" + ], + "summary": "Add a new map payload", + "operationId": "addPayloadRuntimeMap", + "parameters": [ + { + "type": "string", + "description": "Map file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/map_entries" + } + } + ], + "responses": { + "201": { + "description": "Map payload added", + "schema": { + "$ref": "#/definitions/map_entries" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Remove all map entries from the map file.", + "tags": [ + "Maps" + ], + "summary": "Remove all map entries from the map file", + "operationId": "clearRuntimeMap", + "parameters": [ + { + "type": "string", + "description": "Map file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "If true, deletes file from disk", + "name": "forceDelete", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + } + ], + "responses": { + "204": { + "description": "All map entries deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/maps/{parent_name}/entries": { + "get": { + "description": "Returns an array of all entries in a given runtime map file.", + "tags": [ + "Maps" + ], + "summary": "Return one map runtime entries", + "operationId": "showRuntimeMap", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/map_entries" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds an entry into the map file.", + "tags": [ + "Maps" + ], + "summary": "Adds an entry into the map file", + "operationId": "addMapEntry", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/map_entry" + } + } + ], + "responses": { + "201": { + "description": "Map entry created", + "schema": { + "$ref": "#/definitions/map_entry" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/maps/{parent_name}/entries/{id}": { + "get": { + "description": "Returns one map runtime setting by it's id.", + "tags": [ + "Maps" + ], + "summary": "Return one map runtime setting", + "operationId": "getRuntimeMapEntry", + "parameters": [ + { + "type": "string", + "description": "Map id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/map_entry" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces the value corresponding to each id in a map.", + "tags": [ + "Maps" + ], + "summary": "Replace the value corresponding to each id in a map", + "operationId": "replaceRuntimeMapEntry", + "parameters": [ + { + "type": "string", + "description": "Map id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "description": "Map value", + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "Map value replaced", + "schema": { + "$ref": "#/definitions/map_entry" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Delete all the map entries from the map by its id.", + "tags": [ + "Maps" + ], + "summary": "Deletes all the map entries from the map by its id", + "operationId": "deleteRuntimeMapEntry", + "parameters": [ + { + "type": "string", + "description": "Map id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If true, immediately syncs changes to disk", + "name": "force_sync", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Map key/value deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files": { + "get": { + "description": "Returns all SSL CA files using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an array of all SSL CA files", + "operationId": "getAllCaFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_ca_files" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates a new SSL CA file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Creates a new SSL CA file", + "operationId": "createCaFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "CA certificate file", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "SSL CA file created" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files/{name}": { + "get": { + "description": "Returns an SSL CA file by name using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an SSL CA file", + "operationId": "getCaFile", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_ca_file" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replace the contents of a CA file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Update the contents of a CA file", + "operationId": "setCaFile", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "SSL CA payload added" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a CA file", + "tags": [ + "SSLRuntime" + ], + "summary": "Deletes a CA file", + "operationId": "deleteCaFile", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "SSL CA deleted" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files/{name}/entries": { + "post": { + "description": "Adds an entry to an existing CA file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Add a certificate to a CA file", + "operationId": "addCaEntry", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "description": "Payload of the cert entry", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_ca_files/{name}/entries/{index}": { + "get": { + "description": "Returns an SSL CA file cert entry.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an SSL CA file cert entry", + "operationId": "getCaEntry", + "parameters": [ + { + "type": "string", + "description": "SSL CA file name", + "name": "name", + "in": "path", + "required": true + }, + { + "minimum": 0, + "type": "integer", + "description": "SSL CA file index", + "name": "index", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_certs": { + "get": { + "description": "Returns certificate files descriptions from runtime.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return a list of SSL certificate files", + "operationId": "getAllCerts", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificates" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates a new SSL certificate file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Create a new SSL certificate file", + "operationId": "createCert", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "Certificate file", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "Certificate created" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_certs/{name}": { + "get": { + "description": "Returns one structured certificate using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return one structured certificate", + "operationId": "getCert", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Sets a certificate payload using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Replace the contents of a certificate", + "operationId": "replaceCert", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "File updated" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a certificate using the runtime socket.", + "tags": [ + "SSLRuntime" + ], + "summary": "Delete a certificate", + "operationId": "deleteCert", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "File deleted" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_crl_files": { + "get": { + "description": "Returns all the certificate revocation list files using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Return an array of all the CRL files", + "operationId": "getAllCrl", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crls" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates a new CRL file with its contents using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Create a new CRL file", + "operationId": "createCrl", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "CRL file", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "201": { + "description": "CRL file created" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_crl_files/{name}": { + "get": { + "description": "Returns one or all entries in a CRL file using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Get the contents of a CRL file", + "operationId": "getCrl", + "parameters": [ + { + "type": "string", + "description": "CRL file name", + "name": "name", + "in": "path", + "required": true + }, + { + "minimum": 1, + "type": "integer", + "x-nullable": true, + "description": "Entry index to return. Starts at 1. If not provided, all entries are returned.", + "name": "index", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crl_entries" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces the contents of a CRL file using the runtime socket.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Replace the contents of a CRL file", + "operationId": "replaceCrl", + "parameters": [ + { + "type": "string", + "description": "CRL file name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "text/plain", + "description": "CRL file contents", + "name": "file_upload", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "File modified" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a CRL file using the runtime socket.", + "tags": [ + "SSLRuntime" + ], + "summary": "Delete a CRL file", + "operationId": "deleteCrl", + "parameters": [ + { + "type": "string", + "description": "CRL file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "File deleted" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_crt_lists": { + "get": { + "description": "Returns an array of crt-list file descriptions from runtime.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Get the list of all crt-list files", + "operationId": "getAllCrtLists", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_lists" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/ssl_crt_lists/entries": { + "get": { + "description": "Returns an array of entries present inside the given crt-list file. Their index can be used to delete them.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Get all the entries inside a crt-list", + "operationId": "getAllCrtListEntries", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list filename", + "name": "name", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_list_entries" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Appends an entry to the given crt-list using the runtime socket.", + "produces": [ + "application/json" + ], + "tags": [ + "SSLRuntime" + ], + "summary": "Add an entry into a crt-list", + "operationId": "addCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list filename", + "name": "name", + "in": "query", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_crt_list_entry" + } + } + ], + "responses": { + "201": { + "description": "Successful operation" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a single entry from the given crt-list using the runtime socket.", + "tags": [ + "SSLRuntime" + ], + "summary": "Delete an entry from a crt-list", + "operationId": "deleteCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt list name", + "name": "name", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "SSL cert entry name", + "name": "cert_file", + "in": "query", + "required": true + }, + { + "minimum": 1, + "type": "integer", + "x-nullable": true, + "description": "The line number where the entry is located, in case several entries share the same certificate.", + "name": "line_number", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Successful operation" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/stick_tables": { + "get": { + "description": "Returns an array of all stick tables.", + "tags": [ + "StickTable" + ], + "summary": "Return Stick Tables", + "operationId": "getStickTables", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_tables" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/stick_tables/{name}": { + "get": { + "description": "Returns one stick table from runtime.", + "tags": [ + "StickTable" + ], + "summary": "Return Stick Table", + "operationId": "getStickTable", + "parameters": [ + { + "type": "string", + "description": "Stick table name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_table" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/runtime/stick_tables/{parent_name}/entries": { + "get": { + "description": "Returns an array of all entries in a given stick tables.", + "tags": [ + "StickTable" + ], + "summary": "Return Stick Table Entries", + "operationId": "getStickTableEntries", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "A list of filters in format data.\u003ctype\u003e \u003coperator\u003e \u003cvalue\u003e separated by comma", + "name": "filter", + "in": "query" + }, + { + "type": "string", + "description": "Key which we want the entries for", + "name": "key", + "in": "query" + }, + { + "type": "integer", + "description": "Max number of entries to be returned for pagination", + "name": "count", + "in": "query" + }, + { + "type": "integer", + "description": "Offset which indicates how many items we skip in pagination", + "name": "offset", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/stick_table_entries" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Create or update a stick-table entry in the table.", + "tags": [ + "StickTable" + ], + "summary": "Set Entry to Stick Table", + "operationId": "setStickTableEntries", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "description": "Stick table entry", + "name": "stick_table_entry", + "in": "body", + "schema": { + "type": "object", + "required": [ + "key", + "data_type" + ], + "properties": { + "data_type": { + "$ref": "#/definitions/stick_table_entry" + }, + "key": { + "type": "string" + } + } + } + } + ], + "responses": { + "204": { + "description": "Successful operation" + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/sites": { + "get": { + "description": "Returns an array of all configured sites.", + "tags": [ + "Sites" + ], + "summary": "Return an array of sites", + "operationId": "getSites", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/sites" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new site to the configuration file.", + "tags": [ + "Sites" + ], + "summary": "Add a site", + "operationId": "createSite", + "parameters": [ + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/site" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Site created", + "schema": { + "$ref": "#/definitions/site" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/site" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/sites/{name}": { + "get": { + "description": "Returns one site configuration by it's name.", + "tags": [ + "Sites" + ], + "summary": "Return a site", + "operationId": "getSite", + "parameters": [ + { + "type": "string", + "description": "Site frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/site" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a site configuration by it's name.", + "tags": [ + "Sites" + ], + "summary": "Replace a site", + "operationId": "replaceSite", + "parameters": [ + { + "type": "string", + "description": "Site frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/site" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Site replaced", + "schema": { + "$ref": "#/definitions/site" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/site" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a site from the configuration by it's name.", + "tags": [ + "Sites" + ], + "summary": "Delete a site", + "operationId": "deleteSite", + "parameters": [ + { + "type": "string", + "description": "Site frontend name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "Site deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe": { + "get": { + "description": "Returns a list of endpoints to be used for SPOE settings of HAProxy.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy SPOE endpoints", + "operationId": "getSpoeEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files": { + "get": { + "description": "Returns all available SPOE files.", + "tags": [ + "Spoe" + ], + "summary": "Return all available SPOE files", + "operationId": "getAllSpoeFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_files" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates SPOE file with its entries.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Spoe" + ], + "summary": "Creates SPOE file with its entries", + "operationId": "createSpoe", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The spoe file to upload", + "name": "file_upload", + "in": "formData" + } + ], + "responses": { + "201": { + "description": "SPOE file created with its entries", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{name}": { + "get": { + "description": "Returns one SPOE file.", + "tags": [ + "Spoe" + ], + "summary": "Return one SPOE file", + "operationId": "getOneSpoeFile", + "parameters": [ + { + "type": "string", + "description": "SPOE file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "object", + "properties": { + "data": { + "type": "string" + } + } + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes SPOE file.", + "tags": [ + "Spoe" + ], + "summary": "Delete SPOE file", + "operationId": "deleteSpoeFile", + "parameters": [ + { + "type": "string", + "description": "SPOE file name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "SPOE file deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes": { + "get": { + "description": "Returns an array of all configured spoe scopes.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of spoe scopes", + "operationId": "getAllSpoeScope", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_scopes" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new spoe scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new spoe scope", + "operationId": "createSpoeScope", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_scope" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Spoe scope created", + "schema": { + "$ref": "#/definitions/spoe_scope" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name}": { + "get": { + "description": "Returns one SPOE scope in one SPOE file.", + "tags": [ + "Spoe" + ], + "summary": "Return one SPOE scope", + "operationId": "getSpoeScope", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_scope" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a SPOE scope from the configuration file.", + "tags": [ + "Spoe" + ], + "summary": "Delete a SPOE scope", + "operationId": "deleteSpoeScope", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Spoe scope deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents": { + "get": { + "description": "Returns an array of all configured spoe agents in one scope.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of spoe agents in one scope", + "operationId": "getAllSpoeAgent", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_agents" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new spoe agent to the spoe scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new spoe agent to scope", + "operationId": "createSpoeAgent", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Spoe agent created", + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}": { + "get": { + "description": "Returns one spoe agent configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return a spoe agent", + "operationId": "getSpoeAgent", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe agent name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_agent" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a SPOE agent configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Replace a SPOE agent", + "operationId": "replaceSpoeAgent", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe agent name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Spoe agent replaced", + "schema": { + "$ref": "#/definitions/spoe_agent" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a SPOE agent from the configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Delete a SPOE agent", + "operationId": "deleteSpoeAgent", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe agent name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Spoe agent deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups": { + "get": { + "description": "Returns an array of all configured SPOE groups in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of SPOE groups", + "operationId": "getAllSpoeGroup", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_groups" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new SPOE groups to the SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new SPOE groups", + "operationId": "createSpoeGroup", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Spoe groups created", + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}": { + "get": { + "description": "Returns one SPOE groups configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return a SPOE groups", + "operationId": "getSpoeGroup", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_group" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a SPOE groups configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Replace a SPOE groups", + "operationId": "replaceSpoeGroup", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe group name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Spoe groups replaced", + "schema": { + "$ref": "#/definitions/spoe_group" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a SPOE groups from the one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Delete a SPOE groups", + "operationId": "deleteSpoeGroup", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe group name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Spoe group deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages": { + "get": { + "description": "Returns an array of all configured spoe messages in one scope.", + "tags": [ + "Spoe" + ], + "summary": "Return an array of spoe messages in one scope", + "operationId": "getAllSpoeMessage", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_messages" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Adds a new spoe message to the spoe scope.", + "tags": [ + "Spoe" + ], + "summary": "Add a new spoe message to scope", + "operationId": "createSpoeMessage", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Spoe message created", + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + } + }, + "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}": { + "get": { + "description": "Returns one spoe message configuration in SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Return a spoe message", + "operationId": "getSpoeMessage", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe message name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_message" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Spoe configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Replaces a spoe message configuration in one SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Replace a spoe message", + "operationId": "replaceSpoeMessage", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe message name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Spoe message replaced", + "schema": { + "$ref": "#/definitions/spoe_message" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a spoe message from the SPOE scope.", + "tags": [ + "Spoe" + ], + "summary": "Delete a spoe message", + "operationId": "deleteSpoeMessage", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe scope name", + "name": "scope_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Spoe message name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "integer", + "x-nullable": false, + "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", + "name": "version", + "in": "query" + } + ], + "responses": { + "204": { + "description": "Spoe message deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } } }, - "default_server": { - "type": "object", - "properties": { - "fall": { - "type": "integer", - "x-nullable": true - }, - "inter": { - "type": "integer", - "x-nullable": true - }, - "port": { - "type": "integer", - "maximum": 65535, - "minimum": 1, - "x-nullable": true - }, - "rise": { - "type": "integer", - "x-nullable": true + "/services/haproxy/spoe/spoe_files/{parent_name}/transactions": { + "get": { + "description": "Returns a list of SPOE configuration transactions. Transactions can be filtered by their status.", + "produces": [ + "application/json" + ], + "tags": [ + "SpoeTransactions" + ], + "summary": "Return list of SPOE configuration transactions.", + "operationId": "getAllSpoeTransaction", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "enum": [ + "failed", + "in_progress" + ], + "type": "string", + "description": "Filter by transaction status", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/spoe_transactions" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Starts a new transaction and returns it's id", + "produces": [ + "application/json" + ], + "tags": [ + "SpoeTransactions" + ], + "summary": "Start a new transaction", + "operationId": "startSpoeTransaction", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Configuration version on which to work on", + "name": "version", + "in": "query", + "required": true + } + ], + "responses": { + "201": { + "description": "Transaction started", + "schema": { + "$ref": "#/definitions/spoe_transaction" + } + }, + "429": { + "description": "Too many open transactions", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "message": { + "type": "string" + } + }, + "example": { + "code": 429, + "message": "cannot start a new transaction, reached the maximum amount of 20 active transactions available" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } } }, - "defaults": { - "description": "HAProxy defaults configuration", - "type": "object", - "title": "Defaults", - "properties": { - "adv_check": { - "type": "string", - "enum": [ - "ssl-hello-chk", - "smtpchk", - "ldap-check", - "mysql-check", - "pgsql-check", - "tcp-check", - "redis-check" - ], - "x-display-name": "Advanced Check" - }, - "balance": { - "$ref": "#/definitions/balance" - }, - "check_timeout": { - "type": "integer", - "x-nullable": true - }, - "clflog": { - "type": "boolean", - "x-display-name": "CLF Log" - }, - "client_timeout": { - "type": "integer", - "x-nullable": true - }, - "clitcpka": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "Client TCP Keep Alive" - }, - "connect_timeout": { - "type": "integer", - "x-nullable": true - }, - "contstats": { - "type": "string", - "enum": [ - "enabled" - ], - "x-display-name": "Continuous Statistics" - }, - "cookie": { - "$ref": "#/definitions/cookie" - }, - "default_backend": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-dynamic-enum": { - "operation": "getBackends", - "property": "name" + "/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}": { + "get": { + "description": "Returns one SPOE configuration transactions.", + "tags": [ + "SpoeTransactions" + ], + "summary": "Return one SPOE configuration transactions", + "operationId": "getSpoeTransaction", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true } - }, - "default_server": { - "$ref": "#/definitions/default_server" - }, - "dontlognull": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "Don't Log Null" - }, - "error_files": { - "type": "array", - "items": { - "$ref": "#/definitions/errorfile" + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/spoe_transaction" + } }, - "x-go-name": "ErrorFiles" - }, - "external_check": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "External Check" - }, - "external_check_command": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Command" - }, - "external_check_path": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Path" - }, - "forwardfor": { - "$ref": "#/definitions/forwardfor" - }, - "http-use-htx": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "HTTP Use HTX" - }, - "http_connection_mode": { - "type": "string", - "enum": [ - "httpclose", - "http-server-close", - "http-keep-alive" - ] - }, - "http_keep_alive_timeout": { - "type": "integer", - "x-nullable": true - }, - "http_pretend_keepalive": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ] - }, - "http_request_timeout": { - "type": "integer", - "x-nullable": true - }, - "httpchk": { - "$ref": "#/definitions/httpchk" - }, - "httplog": { - "type": "boolean", - "x-display-name": "HTTP Log" - }, - "log_format": { - "type": "string" - }, - "log_format_sd": { - "type": "string", - "x-display-name": "Log Format SD" - }, - "log_separate_errors": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ] - }, - "log_tag": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true - }, - "mode": { - "type": "string", - "enum": [ - "tcp", - "http" - ] - }, - "queue_timeout": { - "type": "integer", - "x-nullable": true - }, - "redispatch": { - "$ref": "#/definitions/redispatch" - }, - "retries": { - "type": "integer", - "x-nullable": true - }, - "server_timeout": { - "type": "integer", - "x-nullable": true - }, - "tcplog": { - "type": "boolean", - "x-display-name": "TCP Log" + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "put": { + "description": "Commit transaction, execute all operations in transaction and return msg", + "tags": [ + "SpoeTransactions" + ], + "summary": "Commit transaction", + "operationId": "commitSpoeTransaction", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Transaction successfully committed", + "schema": { + "$ref": "#/definitions/spoe_transaction" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/spoe_transaction" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a transaction.", + "tags": [ + "SpoeTransactions" + ], + "summary": "Delete a transaction", + "operationId": "deleteSpoeTransaction", + "parameters": [ + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Transaction deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } - }, - "additionalProperties": false + } }, - "endpoint": { - "description": "Endpoint definition", - "type": "object", - "title": "Endpoint", - "properties": { - "description": { - "description": "Endpoint description", - "type": "string" - }, - "title": { - "description": "Endpoint title", - "type": "string" - }, - "url": { - "description": "Path to the endpoint", - "type": "string" + "/services/haproxy/spoe/{parent_name}/version": { + "get": { + "description": "Returns SPOE configuration version.", + "tags": [ + "Spoe" + ], + "summary": "Return a SPOE configuration version", + "operationId": "getSpoeConfigurationVersion", + "parameters": [ + { + "type": "string", + "x-nullable": false, + "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", + "name": "transaction_id", + "in": "query" + }, + { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "SPOE configuration version", + "schema": { + "type": "integer" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } } }, - "endpoints": { - "description": "Collection of endpoints", - "type": "array", - "title": "Endpoints Array", - "items": { - "$ref": "#/definitions/endpoint" + "/services/haproxy/stats": { + "get": { + "description": "Returns a list of HAProxy stats endpoints.", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy stats endpoints", + "operationId": "getStatsEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } } }, - "error": { - "description": "API Error", - "type": "object", - "title": "Error", - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "type": "integer", - "x-nullable": true - }, - "message": { - "type": "string", - "x-nullable": true + "/services/haproxy/stats/native": { + "get": { + "description": "Getting stats from the HAProxy.", + "produces": [ + "application/json" + ], + "tags": [ + "Stats" + ], + "summary": "Gets stats", + "operationId": "getStats", + "parameters": [ + { + "enum": [ + "frontend", + "backend", + "server" + ], + "type": "string", + "description": "Object type to get stats for (one of frontend, backend, server)", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "Object name to get stats for", + "name": "name", + "in": "query" + }, + { + "type": "string", + "x-dependency": { + "query.type": "server" + }, + "description": "Object parent name to get stats for, in case the object is a server", + "name": "parent", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/native_stats" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/native_stats" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } - }, - "additionalProperties": { - "type": "string" } }, - "errorfile": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "enum": [ - 200, - 400, - 403, - 405, - 408, - 425, - 429, - 500, - 502, - 503, - 504 - ] - }, - "file": { - "type": "string" + "/services/haproxy/storage": { + "get": { + "description": "Returns a list of endpoints that use HAProxy storage for persistency, e.g. maps, ssl certificates...", + "produces": [ + "application/json" + ], + "tags": [ + "Discovery" + ], + "summary": "Return list of HAProxy storage endpoints", + "operationId": "getStorageEndpoints", + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/endpoints" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } - }, - "x-display-name": "Error File" + } }, - "filter": { - "description": "HAProxy filters", - "type": "object", - "title": "Filter", - "required": [ - "id", - "type" - ], - "properties": { - "cache_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "cache" + "/services/haproxy/storage/general": { + "get": { + "description": "Returns a list of all managed general use files", + "tags": [ + "Storage" + ], + "summary": "Return a list of all managed general use files", + "operationId": "getAllStorageGeneralFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/general_files" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "spoe_config": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "spoe" + } + }, + "post": { + "description": "Creates a managed storage general use file with contents.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Creates a managed storage general use file with contents", + "operationId": "createStorageGeneralFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "application/octet-stream", + "description": "General use file content", + "name": "file_upload", + "in": "formData" + } + ], + "responses": { + "201": { + "description": "General use file created with its contents", + "schema": { + "$ref": "#/definitions/general_file" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "spoe_engine": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "value": "spoe" + } + } + }, + "/services/haproxy/storage/general/{name}": { + "get": { + "description": "Returns the contents of one managed general use file from disk", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Storage" + ], + "summary": "Return the contents of one managed general use file from disk", + "operationId": "getOneStorageGeneralFile", + "parameters": [ + { + "type": "string", + "description": "General use file storage_name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "file" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "trace_hexdump": { - "type": "boolean", - "x-dependency": { - "type": { - "value": "trace" + } + }, + "put": { + "description": "Replaces the contents of a managed general use file on disk", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace contents of a managed general use file on disk", + "operationId": "replaceStorageGeneralFile", + "parameters": [ + { + "type": "string", + "description": "General use file storage_name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "file", + "x-mimetype": "application/octet-stream", + "description": "General use file content", + "name": "file_upload", + "in": "formData" + }, + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "General use file replaced" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "trace_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "value": "trace" - } + } + }, + "delete": { + "description": "Deletes a managed general use file from disk.", + "tags": [ + "Storage" + ], + "summary": "Deletes a managed general use file from disk", + "operationId": "deleteStorageGeneralFile", + "parameters": [ + { + "type": "string", + "description": "General use file storage_name", + "name": "name", + "in": "path", + "required": true } - }, - "trace_rnd_forwarding": { - "type": "boolean", - "x-dependency": { - "type": { - "value": "trace" - } + ], + "responses": { + "204": { + "description": "General use file deleted" }, - "x-display-name": "Trace Random Forwarding" - }, - "trace_rnd_parsing": { - "type": "boolean", - "x-dependency": { - "type": { - "value": "trace" + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Trace Random Parsing" - }, - "type": { - "type": "string", - "enum": [ - "trace", - "compression", - "spoe", - "cache" - ], - "x-nullable": false + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } - }, - "additionalProperties": false, - "example": { - "id": 0, - "trace_name": "name", - "trace_rnd_parsing": true, - "type": "trace" - } - }, - "filters": { - "description": "HAProxy filters array (corresponds to filter directive)", - "type": "array", - "title": "Filters Array", - "items": { - "$ref": "#/definitions/filter" } }, - "forwardfor": { - "type": "object", - "required": [ - "enabled" - ], - "properties": { - "enabled": { - "type": "string", - "enum": [ - "enabled" - ] - }, - "except": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "header": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "ifnone": { - "type": "boolean" + "/services/haproxy/storage/maps": { + "get": { + "description": "Returns a list of all managed map files", + "tags": [ + "Storage" + ], + "summary": "Return a list of all managed map files", + "operationId": "getAllStorageMapFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/maps" + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } }, - "x-display-name": "ForwardFor" - }, - "frontend": { - "description": "HAProxy frontend configuration", - "type": "object", - "title": "Frontend", - "required": [ - "name" - ], - "properties": { - "clflog": { - "type": "boolean", - "x-dependency": { - "mode": { - "value": "http" + "post": { + "description": "Creates a managed storage map file with its entries.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Creates a managed storage map file with its entries", + "operationId": "createStorageMapFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The map file contents", + "name": "file_upload", + "in": "formData" + } + ], + "responses": { + "201": { + "description": "Map file created with its entries", + "schema": { + "$ref": "#/definitions/map" } }, - "x-display-name": "CLF Log" - }, - "client_timeout": { - "type": "integer", - "x-nullable": true - }, - "clitcpka": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "mode": { - "value": "tcp" + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Client TCP Keep Alive" - }, - "contstats": { - "type": "string", - "enum": [ - "enabled" - ], - "x-display-name": "Continous Statistics" - }, - "default_backend": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-dynamic-enum": { - "operation": "getBackends", - "property": "name" + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } } - }, - "dontlognull": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "Don't Log Null" - }, - "forwardfor": { - "x-dependency": { - "mode": { - "value": "http" + } + } + }, + "/services/haproxy/storage/maps/{name}": { + "get": { + "description": "Returns the contents of one managed map file from disk", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Storage" + ], + "summary": "Return the contents of one managed map file from disk", + "operationId": "getOneStorageMap", + "parameters": [ + { + "type": "string", + "description": "Map file storage_name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "file" } }, - "$ref": "#/definitions/forwardfor" - }, - "http-use-htx": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "mode": { - "value": "http" + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "HTTP Use HTX" - }, - "http_connection_mode": { - "type": "string", - "enum": [ - "httpclose", - "http-server-close", - "http-keep-alive" - ], - "x-dependency": { - "mode": { - "value": "http" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "http_keep_alive_timeout": { - "type": "integer", - "x-dependency": { - "mode": { - "value": "http" + } + }, + "put": { + "description": "Replaces the contents of a managed map file on disk", + "consumes": [ + "text/plain" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace contents of a managed map file on disk", + "operationId": "replaceStorageMapFile", + "parameters": [ + { + "type": "string", + "description": "Map file storage_name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" } }, - "x-nullable": true - }, - "http_request_timeout": { - "type": "integer", - "x-dependency": { - "mode": { - "value": "http" + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, - "x-nullable": true - }, - "httplog": { - "type": "boolean", - "x-dependency": { - "mode": { - "value": "http" + "204": { + "description": "Map file replaced" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "HTTP Log" - }, - "log_format": { - "type": "string" - }, - "log_format_sd": { - "type": "string", - "x-display-name": "Log Format SD" - }, - "log_separate_errors": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ] - }, - "log_tag": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$" - }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true - }, - "mode": { - "type": "string", - "enum": [ - "http", - "tcp" - ] - }, - "name": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false - }, - "tcplog": { - "type": "boolean", - "x-dependency": { - "mode": { - "value": "tcp" + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "TCP Log" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } }, - "additionalProperties": false, - "example": { - "default_backend": "test_backend", - "http_connection_mode": "http-keep-alive", - "maxconn": 2000, - "mode": "http", - "name": "test_frontend" - } - }, - "frontends": { - "description": "HAProxy frontends array", - "type": "array", - "title": "Frontends", - "items": { - "$ref": "#/definitions/frontend" - } - }, - "global": { - "description": "HAProxy global configuration", - "type": "object", - "title": "Global", - "properties": { - "cpu_maps": { - "type": "array", - "items": { - "type": "object", - "required": [ - "process", - "cpu_set" - ], - "properties": { - "cpu_set": { + "delete": { + "description": "Deletes a managed map file from disk.", + "tags": [ + "Storage" + ], + "summary": "Deletes a managed map file from disk", + "operationId": "deleteStorageMap", + "parameters": [ + { + "type": "string", + "description": "Map file storage_name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Map file deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { "type": "string", - "x-display-name": "CPU Set" - }, - "process": { + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { "type": "string", - "x-display-name": "Process/Thread Set" + "description": "Configuration file version" } - }, - "x-go-name": "CPUMap" + } + } + } + } + }, + "/services/haproxy/storage/ssl_certificates": { + "get": { + "description": "Returns all available SSL certificates on disk.", + "tags": [ + "Storage" + ], + "summary": "Return all available SSL certificates on disk", + "operationId": "getAllStorageSSLCertificates", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificates" + } }, - "x-display-name": "CPU Maps", - "x-go-name": "CPUMaps" - }, - "daemon": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ] - }, - "external_check": { - "type": "boolean", - "x-display-name": "External Check" - }, - "master-worker": { - "type": "boolean", - "x-display-name": "Master Worker Mode" - }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections" - }, - "nbproc": { - "type": "integer", - "x-display-name": "Number of Processes" - }, - "nbthread": { - "type": "integer", - "x-display-name": "Number of Threads" - }, - "pidfile": { - "type": "string", - "x-display-name": "PID File" - }, - "runtime_apis": { - "type": "array", - "items": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { "type": "string", - "pattern": "^[^\\s]+$" - }, - "exposeFdListeners": { - "type": "boolean", - "x-display-name": "Expose FD Listeners" - }, - "level": { + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { "type": "string", - "enum": [ - "user", - "operator", - "admin" - ] - }, - "mode": { + "description": "Configuration file version" + } + } + } + } + }, + "post": { + "description": "Creates SSL certificate.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Create SSL certificate", + "operationId": "createStorageSSLCertificate", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The SSL certificate to upload", + "name": "file_upload", + "in": "formData" + }, + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "SSL certificate created", + "schema": { + "$ref": "#/definitions/ssl_certificate" + } + }, + "202": { + "description": "SSL certificate created requested", + "schema": { + "$ref": "#/definitions/ssl_certificate" + }, + "headers": { + "Reload-ID": { "type": "string", - "pattern": "^[^\\s]+$" - }, - "process": { + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { "type": "string", - "pattern": "^[^\\s]+$" + "description": "Configuration file version" } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" }, - "x-go-name": "RuntimeAPI" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } }, - "x-display-name": "Runtime APIs", - "x-go-name": "RuntimeAPIs" - }, - "ssl_default_bind_ciphers": { - "type": "string", - "x-display-name": "SSL Default Bind Ciphers" - }, - "ssl_default_bind_options": { - "type": "string", - "x-display-name": "SSL Default Bind Options" - }, - "stats_timeout": { - "type": "integer", - "x-nullable": true - }, - "tune_ssl_default_dh_param": { - "type": "integer", - "x-display-name": "SSL Default DH Parameter Size" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } - }, - "additionalProperties": false + } }, - "http_request_rule": { - "description": "HAProxy HTTP request rule configuration (corresponds to http-request directives)", - "type": "object", - "title": "HTTP Request Rule", - "required": [ - "id", - "type" - ], - "properties": { - "acl_file": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "add-acl", - "del-acl" - ] + "/services/haproxy/storage/ssl_certificates/{name}": { + "get": { + "description": "Returns one SSL certificate from disk.", + "tags": [ + "Storage" + ], + "summary": "Return one SSL certificate from disk", + "operationId": "getOneStorageSSLCertificate", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_certificate" } }, - "x-display-name": "ACL File" - }, - "acl_keyfmt": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "add-acl", - "del-acl" - ] + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "ACL Key Format" - }, - "auth_realm": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "value": "auth" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } + } + } + }, + "put": { + "description": "Replaces SSL certificate on disk.", + "consumes": [ + "text/plain" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace SSL certificates on disk", + "operationId": "replaceStorageSSLCertificate", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true }, - "x-display-name": "Authentication Realm" - }, - "cond": { - "type": "string", - "enum": [ - "if", - "unless" - ], - "x-display-name": "Condition" - }, - "cond_test": { - "type": "string", - "x-dependency": { - "cond": { - "required": true + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" } }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" } - }, - "deny_status": { - "type": "integer", - "x-dependency": { - "type": { - "value": [ - "deny", - "tarpit" - ] + ], + "responses": { + "200": { + "description": "SSL certificate replaced", + "schema": { + "$ref": "#/definitions/ssl_certificate" } }, - "x-nullable": false - }, - "hdr_format": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "replace-header", - "replace-value", - "set-header", - "add-header" - ] + "202": { + "description": "SSL certificate replaced and reload requested", + "schema": { + "$ref": "#/definitions/ssl_certificate" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, - "x-display-name": "Header Format" - }, - "hdr_match": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "replace-header", - "replace-value" - ] + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Header Match" - }, - "hdr_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "add-header", - "replace-header", - "del-header", - "set-header", - "replace-value" - ] + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Header Name" - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "log_level": { - "type": "string", - "enum": [ - "emerg", - "alert", - "crit", - "err", - "warning", - "notice", - "info", - "debug", - "silent" - ], - "x-dependency": { - "type": { - "required": true, - "value": "set-log-level" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "path_fmt": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-path" - } + } + }, + "delete": { + "description": "Deletes SSL certificate from disk.", + "tags": [ + "Storage" + ], + "summary": "Delete SSL certificate from disk", + "operationId": "deleteStorageSSLCertificate", + "parameters": [ + { + "type": "string", + "description": "SSL certificate name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" } - }, - "query-fmt": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-query" + ], + "responses": { + "202": { + "description": "SSL certificate deleted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "204": { + "description": "SSL certificate deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "redir_code": { - "type": "integer", - "enum": [ - 301, - 302, - 303 - ], - "x-dependency": { - "type": { - "value": "redirect" + } + } + }, + "/services/haproxy/storage/ssl_crt_lists": { + "get": { + "description": "Returns all available certificate lists on disk.", + "tags": [ + "Storage" + ], + "summary": "Return all available certificate lists on disk", + "operationId": "getAllStorageSSLCrtListFiles", + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_list_files" } }, - "x-display-name": "Redirect Code" - }, - "redir_option": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "redirect" + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Redirect Option" - }, - "redir_type": { - "type": "string", - "enum": [ - "location", - "prefix", - "scheme" - ], - "x-dependency": { - "type": { - "required": true, - "value": "redirect" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } + } + } + }, + "post": { + "description": "Creates a certificate list.", + "consumes": [ + "multipart/form-data" + ], + "tags": [ + "Storage" + ], + "summary": "Create a certificate list", + "operationId": "createStorageSSLCrtListFile", + "parameters": [ + { + "type": "file", + "x-mimetype": "text/plain", + "description": "The certificate list to upload", + "name": "file_upload", + "in": "formData" }, - "x-display-name": "Redirect Type" - }, - "redir_value": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "redirect" + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "201": { + "description": "Certificate list created", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" } }, - "x-display-name": "Redirect Value" - }, - "spoe_engine": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" + "202": { + "description": "Certificate list created requested", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, - "x-display-name": "SPOE Engine" - }, - "spoe_group": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "SPOE Group" - }, - "type": { - "type": "string", - "enum": [ - "allow", - "deny", - "auth", - "redirect", - "tarpit", - "add-header", - "replace-header", - "replace-value", - "del-header", - "set-header", - "set-log-level", - "set-path", - "set-query", - "set-uri", - "set-var", - "send-spoe-group", - "add-acl", - "del-acl" - ], - "x-nullable": false - }, - "uri-fmt": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-uri" - } - } - }, - "var_expr": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Var Expression" - }, - "var_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" - } - } - }, - "var_scope": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } } - }, - "additionalProperties": false, - "example": { - "cond": "unless", - "cond_test": "{ src 192.168.0.0/16 }", - "hdr_format": "%T", - "hdr_name": "X-Haproxy-Current-Date", - "id": 0, - "type": "add-header" } }, - "http_request_rules": { - "description": "HAProxy HTTP request rules array (corresponds to http-request directives)", - "type": "array", - "title": "HTTP Request Rules Array", - "items": { - "$ref": "#/definitions/http_request_rule" - } - }, - "http_response_rule": { - "description": "HAProxy HTTP response rule configuration (corresponds to http-response directives)", - "type": "object", - "title": "HTTP Response Rule", - "required": [ - "id", - "type" - ], - "properties": { - "acl_file": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "add-acl", - "del-acl" - ] - } + "/services/haproxy/storage/ssl_crt_lists/{name}": { + "get": { + "description": "Returns one certificate list from disk.", + "produces": [ + "application/octet-stream" + ], + "tags": [ + "Storage" + ], + "summary": "Return one certificate list from disk", + "operationId": "getOneStorageSSLCrtListFile", + "parameters": [ + { + "type": "string", + "description": "Certificate list name", + "name": "name", + "in": "path", + "required": true } - }, - "acl_keyfmt": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "add-acl", - "del-acl" - ] + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "type": "file" } }, - "x-display-name": "ACK Key Format" - }, - "cond": { - "type": "string", - "enum": [ - "if", - "unless" - ], - "x-display-name": "Condition" - }, - "cond_test": { - "type": "string", - "x-dependency": { - "cond": { - "required": true + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } } - }, - "hdr_format": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "replace-header", - "replace-value", - "set-header", - "add-header" - ] + } + }, + "put": { + "description": "Replaces a certificate list on disk.", + "consumes": [ + "text/plain" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Replace a certificate lists on disk", + "operationId": "replaceStorageSSLCrtListFile", + "parameters": [ + { + "type": "string", + "description": "Certificate list name", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "data", + "in": "body", + "required": true, + "schema": { + "type": "string" } }, - "x-display-name": "Header Format" - }, - "hdr_match": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "replace-header", - "replace-value" - ] + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Certificate list replaced", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" } }, - "x-display-name": "Header Match" - }, - "hdr_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "add-header", - "replace-header", - "del-header", - "set-header", - "replace-value" - ] + "202": { + "description": "Certificate list replaced and reload requested", + "schema": { + "$ref": "#/definitions/ssl_crt_list_file" + }, + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, - "x-display-name": "Header Name" - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "log_level": { - "type": "string", - "enum": [ - "emerg", - "alert", - "crit", - "err", - "warning", - "notice", - "info", - "debug", - "silent" - ], - "x-dependency": { - "type": { - "required": true, - "value": "set-log-level" + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } - } - }, - "redir_code": { - "type": "integer", - "enum": [ - 301, - 302, - 303 - ], - "x-dependency": { - "type": { - "value": "redirect" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Redirect Code" - }, - "redir_option": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "redirect" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } + } + } + }, + "delete": { + "description": "Deletes a certificate list from disk.", + "tags": [ + "Storage" + ], + "summary": "Delete a certificate list from disk", + "operationId": "deleteStorageSSLCrtListFile", + "parameters": [ + { + "type": "string", + "description": "Certificate list name", + "name": "name", + "in": "path", + "required": true }, - "x-display-name": "Redirect Option" - }, - "redir_type": { - "type": "string", - "enum": [ - "location", - "prefix", - "scheme" - ], - "x-dependency": { - "type": { - "required": true, - "value": "redirect" + { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "202": { + "description": "Certificate list deleted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } }, - "x-display-name": "Redirect Type" - }, - "redir_value": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "redirect" + "204": { + "description": "Certificate list deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Redirect Value" - }, - "spoe_engine": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "spoe_group": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" - } + } + } + }, + "/services/haproxy/storage/ssl_crt_lists/{name}/entries": { + "get": { + "description": "Returns all the entries in a certificate list.", + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Returns all the entries in a CrtList", + "operationId": "GetStorageSSLCrtListEntries", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list file", + "name": "name", + "in": "path", + "required": true } - }, - "status": { - "type": "integer", - "maximum": 999, - "minimum": 100, - "x-dependency": { - "type": { - "required": true, - "value": "set-status" + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/ssl_crt_list_entries" } }, - "x-nullable": false - }, - "status_reason": { - "type": "string", - "x-dependency": { - "type": { - "value": "set-status" - } - } - }, - "type": { - "type": "string", - "enum": [ - "allow", - "deny", - "redirect", - "add-header", - "set-header", - "del-header", - "set-log-level", - "set-var", - "set-status", - "send-spoe-group", - "replace-header", - "replace-value", - "add-acl", - "del-acl" - ], - "x-nullable": false - }, - "var_expr": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-display-name": "Var Expression" - }, - "var_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" - } - } - }, - "var_scope": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } } }, - "additionalProperties": false, - "example": { - "cond": "unless", - "cond_test": "{ src 192.168.0.0/16 }", - "hdr_format": "%T", - "hdr_name": "X-Haproxy-Current-Date", - "id": 0, - "type": "add-header" - } - }, - "http_response_rules": { - "description": "HAProxy HTTP response rules array (corresponds to http-response directives)", - "type": "array", - "title": "HTTP Response Rules Array", - "items": { - "$ref": "#/definitions/http_response_rule" - } - }, - "httpchk": { - "type": "object", - "properties": { - "method": { - "type": "string", - "enum": [ - "HEAD", - "PUT", - "POST", - "GET", - "TRACE", - "PATCH" - ] - }, - "uri": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "version": { - "type": "string", - "pattern": "^[^\\s]+$" - } - }, - "x-display-name": "HTTP Check" - }, - "info": { - "description": "General API, OS and hardware information", - "type": "object", - "title": "Information", - "properties": { - "api": { - "type": "object", - "properties": { - "build_date": { - "description": "HAProxy Dataplane API build date", - "type": "string", - "format": "date-time" - }, - "version": { - "description": "HAProxy Dataplane API version string", - "type": "string" + "post": { + "description": "Creates a new entry in a certificate list.", + "produces": [ + "application/json" + ], + "tags": [ + "Storage" + ], + "summary": "Creates a new entry in a CrtList", + "operationId": "CreateStorageSSLCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt-list file", + "name": "name", + "in": "path", + "required": true + }, + { + "description": "SSL crt-list entry", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ssl_crt_list_entry" } + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" } - }, - "system": { - "type": "object", - "properties": { - "cpu_info": { - "type": "object", - "properties": { - "model": { - "type": "string" - }, - "num_cpus": { - "description": "Number of logical CPUs", - "type": "integer" - } + ], + "responses": { + "201": { + "description": "New entry added", + "schema": { + "$ref": "#/definitions/ssl_crt_list_entry" + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" }, - "hostname": { - "description": "Hostname where the HAProxy is running", - "type": "string" - }, - "mem_info": { - "type": "object", - "properties": { - "dataplaneapi_memory": { - "type": "integer" - }, - "free_memory": { - "type": "integer" - }, - "total_memory": { - "type": "integer" - } + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" } + } + }, + "409": { + "description": "The specified resource already exists", + "schema": { + "$ref": "#/definitions/error" }, - "os_string": { - "description": "OS string", - "type": "string" - }, - "time": { - "description": "Current time in milliseconds since Epoch.", - "type": "integer" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" }, - "uptime": { - "description": "System uptime", - "type": "integer", - "x-nullable": true + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } } }, - "example": { - "api": { - "build_date": "2019-08-21T17:31:56.000Z", - "version": "v1.2.1 45a3288.dev" - }, - "system": { - "cpu_info": { - "model": "Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz", - "num_cpus": 4 + "delete": { + "description": "Deletes an entry from a certificate list.", + "tags": [ + "Storage" + ], + "summary": "Deletes an entry from CrtList file", + "operationId": "DeleteStorageSSLCrtListEntry", + "parameters": [ + { + "type": "string", + "description": "SSL crt list name", + "name": "name", + "in": "path", + "required": true }, - "hostname": "test", - "mem_info": { - "dataplaneapi_memory": 44755536, - "free_memory": 5790642176, - "total_memory": 16681517056 + { + "type": "string", + "description": "SSL certificate filename", + "name": "certificate", + "in": "query", + "required": true }, - "os_string": "Linux 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019", - "time": 1566401525, - "uptime": 87340 - } - } - }, - "log_target": { - "description": "Per-instance logging of events and traffic.", - "type": "object", - "title": "Log Target", - "required": [ - "id" - ], - "properties": { - "address": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "global": { - "required": true, - "value": false - }, - "nolog": { - "required": true, - "value": false - } - } - }, - "facility": { - "type": "string", - "enum": [ - "kern", - "user", - "mail", - "daemon", - "auth", - "syslog", - "lpr", - "news", - "uucp", - "cron", - "auth2", - "ftp", - "ntp", - "audit", - "alert", - "cron2", - "local0", - "local1", - "local2", - "local3", - "local4", - "local5", - "local6", - "local7" - ], - "x-dependency": { - "global": { - "required": true, - "value": false - }, - "nolog": { - "required": true, - "value": false - } + { + "minimum": 0, + "type": "integer", + "description": "The line number in the crt-list", + "name": "line_number", + "in": "query", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" } - }, - "format": { - "type": "string", - "enum": [ - "rfc3164", - "rfc5424", - "short", - "raw" - ], - "x-dependency": { - "global": { - "value": false - }, - "nolog": { - "value": false + ], + "responses": { + "202": { + "description": "Configuration change accepted and reload requested", + "headers": { + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } } - } - }, - "global": { - "type": "boolean" - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "length": { - "type": "integer", - "x-dependency": { - "global": { - "value": false + }, + "204": { + "description": "Successful operation" + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" }, - "nolog": { - "value": false + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } - } - }, - "level": { - "type": "string", - "enum": [ - "emerg", - "alert", - "crit", - "err", - "warning", - "notice", - "info", - "debug" - ], - "x-dependency": { - "global": { - "value": false + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" }, - "nolog": { - "value": false + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } - } - }, - "minlevel": { - "type": "string", - "enum": [ - "emerg", - "alert", - "crit", - "err", - "warning", - "notice", - "info", - "debug" - ], - "x-dependency": { - "global": { - "value": false - }, - "level": { - "required": false + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" }, - "nolog": { - "value": false + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "nolog": { - "type": "boolean" } - }, - "additionalProperties": false - }, - "log_targets": { - "description": "HAProxy log target array (corresponds to log directives)", - "type": "array", - "title": "Log Target Array", - "items": { - "$ref": "#/definitions/log_target" } }, - "native_stat": { - "description": "Current stats for one object.", - "type": "object", - "title": "Stats", - "properties": { - "backend_name": { - "type": "string", - "x-dependency": { - "type": "server" + "/services/haproxy/transactions": { + "get": { + "description": "Returns a list of HAProxy configuration transactions. Transactions can be filtered by their status.", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Return list of HAProxy configuration transactions.", + "operationId": "getTransactions", + "parameters": [ + { + "enum": [ + "failed", + "in_progress" + ], + "type": "string", + "description": "Filter by transaction status", + "name": "status", + "in": "query" } - }, - "name": { - "type": "string" - }, - "stats": { - "type": "object", - "properties": { - "act": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/transactions" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" }, - "addr": { - "type": "string", - "x-dependency": { - "type": "server" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" } + } + } + } + }, + "post": { + "description": "Starts a new transaction and returns it's id", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Start a new transaction", + "operationId": "startTransaction", + "parameters": [ + { + "type": "integer", + "description": "Configuration version on which to work on", + "name": "version", + "in": "query", + "required": true + } + ], + "responses": { + "201": { + "description": "Transaction started", + "schema": { + "$ref": "#/definitions/transaction" }, - "agent_code": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_desc": { - "type": "string", - "x-dependency": { - "type": "server" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" } - }, - "agent_duration": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_fall": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_health": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_rise": { - "type": "integer", - "x-dependency": { - "type": "server" + } + }, + "429": { + "description": "Too many open transactions", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "message": { + "type": "string" + } }, - "x-nullable": true - }, - "agent_status": { - "type": "string", - "enum": [ - "UNK", - "INI", - "SOCKERR", - "L40K", - "L4TOUT", - "L4CON", - "L7OK", - "L7STS" - ], - "x-dependency": { - "type": "server" - } - }, - "algo": { - "type": "string", - "x-dependency": { - "type": "backend" + "example": { + "code": 429, + "message": "cannot start a new transaction, reached the maximum amount of 20 active transactions available" } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" }, - "bck": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "bin": { - "type": "integer", - "x-nullable": true - }, - "bout": { - "type": "integer", - "x-nullable": true - }, - "check_code": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_desc": { - "type": "string", - "x-dependency": { - "type": "server" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" } + } + } + } + } + }, + "/services/haproxy/transactions/{id}": { + "get": { + "description": "Returns one HAProxy configuration transactions.", + "tags": [ + "Transactions" + ], + "summary": "Return one HAProxy configuration transactions", + "operationId": "getTransaction", + "parameters": [ + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Successful operation", + "schema": { + "$ref": "#/definitions/transaction" }, - "check_duration": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_fall": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_health": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_rise": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_status": { - "type": "string", - "enum": [ - "UNK", - "INI", - "SOCKERR", - "L40K", - "L4TOUT", - "L4CON", - "L6OK", - "L6TOUT", - "L6RSP", - "L7OK", - "L7OKC", - "L7TOUT", - "L7RSP", - "L7STS" - ], - "x-dependency": { - "type": "server" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" }, - "chkdown": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "chkfail": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "cli_abrt": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "comp_byp": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "comp_in": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "comp_out": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "comp_rsp": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "conn_rate": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "conn_rate_max": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "conn_tot": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "cookie": { - "type": "string", - "x-dependency": { - "type": [ - "server", - "backend" - ] + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" }, - "ctime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "dcon": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "downtime": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "dreq": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "dresp": { - "type": "integer", - "x-nullable": true - }, - "dses": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "econ": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "ereq": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "eresp": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "hanafail": { - "type": "string", - "x-dependency": { - "type": "server" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" } + } + } + } + }, + "put": { + "description": "Commit transaction, execute all operations in transaction and return msg", + "tags": [ + "Transactions" + ], + "summary": "Commit transaction", + "operationId": "commitTransaction", + "parameters": [ + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "boolean", + "default": false, + "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", + "name": "force_reload", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Transaction successfully committed", + "schema": { + "$ref": "#/definitions/transaction" }, - "hrsp_1xx": { - "type": "integer", - "x-nullable": true - }, - "hrsp_2xx": { - "type": "integer", - "x-nullable": true - }, - "hrsp_3xx": { - "type": "integer", - "x-nullable": true - }, - "hrsp_4xx": { - "type": "integer", - "x-nullable": true - }, - "hrsp_5xx": { - "type": "integer", - "x-nullable": true - }, - "hrsp_other": { - "type": "integer", - "x-nullable": true - }, - "iid": { - "type": "integer", - "x-nullable": true - }, - "intercepted": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "lastchg": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "lastsess": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "lbtot": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "mode": { - "type": "string", - "enum": [ - "tcp", - "http", - "health", - "unknown" - ] - }, - "pid": { - "type": "integer", - "x-nullable": true - }, - "qcur": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "qlimit": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "qmax": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "qtime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "rate": { - "type": "integer", - "x-nullable": true - }, - "rate_lim": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "rate_max": { - "type": "integer", - "x-nullable": true - }, - "req_rate": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "req_rate_max": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "req_tot": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "rtime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "scur": { - "type": "integer", - "x-nullable": true - }, - "sid": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "slim": { - "type": "integer", - "x-nullable": true - }, - "smax": { - "type": "integer", - "x-nullable": true - }, - "srv_abrt": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "status": { - "type": "string", - "enum": [ - "UP", - "DOWN", - "NOLB", - "MAINT", - "no check" - ] - }, - "stot": { - "type": "integer", - "x-nullable": true + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "202": { + "description": "Configuration change accepted and reload requested", + "schema": { + "$ref": "#/definitions/transaction" }, - "throttle": { - "type": "integer", - "x-dependency": { - "type": "server" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" }, - "x-nullable": true + "Reload-ID": { + "type": "string", + "description": "ID of the requested reload" + } + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/error" }, - "tracked": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" }, - "ttime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "406": { + "description": "The specified resource cannot be handled", + "schema": { + "$ref": "#/definitions/error" }, - "weight": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" }, - "wredis": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } + } + }, + "delete": { + "description": "Deletes a transaction.", + "tags": [ + "Transactions" + ], + "summary": "Delete a transaction", + "operationId": "deleteTransaction", + "parameters": [ + { + "type": "string", + "description": "Transaction id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "Transaction deleted" + }, + "404": { + "description": "The specified resource was not found", + "schema": { + "$ref": "#/definitions/error" }, - "wretr": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } }, - "x-go-name": "NativeStatStats" - }, - "type": { - "type": "string", - "enum": [ - "backend", - "server", - "frontend" - ] + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } + } + } } - }, - "x-go-name": "NativeStat", - "example": { - "name": "frontend_test", - "stats": { - "bin": 4326578, - "bout": 889901290, - "comp_byp": 0, - "comp_in": 0, - "comp_out": 0, - "comp_rsp": 0, - "conn_rate": 12, - "conn_rate_max": 456, - "conn_tot": 45682, - "dcon": 0, - "dreq": 4, - "dresp": 1, - "dses": 0, - "ereq": 54, - "hrsp_1xx": 0, - "hrsp_2xx": 165, - "hrsp_3xx": 12, - "hrsp_4xx": 50, - "hrsp_5xx": 4, - "hrsp_other": 0, - "iid": 0, - "intercepted": 346, - "mode": "http", - "pid": 3204, - "rate": 64, - "rate_lim": 20000, - "rate_max": 4000, - "req_rate": 49, - "req_rate_max": 3965, - "req_total": 1254786, - "scur": 129, - "slim": 2000, - "smax": 2000, - "status": "UP", - "stot": 12902 - }, - "type": "frontend" } }, - "native_stats": { - "description": "HAProxy stats array", - "type": "array", - "title": "Stats Array", - "items": { - "description": "Stats from one runtime API", - "type": "object", - "title": "Stats collection", - "properties": { - "error": { - "type": "string" - }, - "runtimeAPI": { - "type": "string" + "/specification": { + "get": { + "description": "Return Data Plane API OpenAPI specification", + "produces": [ + "application/json" + ], + "tags": [ + "Specification" + ], + "summary": "Data Plane API Specification", + "operationId": "getSpecification", + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object" + } }, - "stats": { - "type": "array", - "items": { - "$ref": "#/definitions/native_stat" + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } - }, - "x-go-name": "NativeStatsCollection" - }, - "x-go-name": "NativeStats" + } + } }, - "process_info": { - "description": "General HAProxy process information", - "type": "object", - "title": "HAProxy Information", - "properties": { - "haproxy": { - "type": "object", - "properties": { - "pid": { - "description": "Process id of the replying worker process", - "type": "integer", - "x-nullable": true - }, - "processes": { - "description": "Number of spawned processes", - "type": "integer", - "x-nullable": true - }, - "release_date": { - "description": "HAProxy version release date", - "type": "string", - "format": "date" - }, - "uptime": { - "description": "HAProxy uptime in s", - "type": "integer", - "x-nullable": true + "/specification_openapiv3": { + "get": { + "description": "Return Data Plane API OpenAPI v3 specification", + "produces": [ + "application/json" + ], + "tags": [ + "SpecificationOpenapiv3" + ], + "summary": "Data Plane API v3 Specification", + "operationId": "getOpenapiv3Specification", + "responses": { + "200": { + "description": "Success", + "schema": { + "type": "object" + } + }, + "default": { + "description": "General Error", + "schema": { + "$ref": "#/definitions/error" }, - "version": { - "description": "HAProxy version string", - "type": "string" + "headers": { + "Configuration-Version": { + "type": "string", + "description": "Configuration file version" + } } } } - }, - "example": { - "haproxy": { - "address": "127.0.0.1", - "pid": 1234, - "processes": 4, - "release_date": "2016-03-11", - "time": "2018-07-02T12:00:00.124Z", - "uptime": 8, - "version": "1.7-dev1-868ab3-148" - } } - }, - "redispatch": { + } + }, + "definitions": { + "BackendBaseForcePersist": { + "description": "This field is deprecated in favor of force_persist_list, and will be removed in a future release", "type": "object", "required": [ - "enabled" + "cond", + "cond_test" ], "properties": { - "enabled": { + "cond": { "type": "string", "enum": [ - "enabled", - "disabled" - ] + "if", + "unless" + ], + "x-display-name": "Condition" }, - "interval": { - "type": "integer", - "x-nullable": false + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" } - } + }, + "x-deprecated": true, + "x-go-name": "BackendForcePersist" }, - "reload": { - "description": "HAProxy reload", + "BackendBaseForcePersistListItems0": { "type": "object", - "title": "HAProxy reload", + "required": [ + "cond", + "cond_test" + ], "properties": { - "id": { + "cond": { "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$" - }, - "reload_timestamp": { - "type": "integer" - }, - "response": { - "type": "string" + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" }, - "status": { + "cond_test": { "type": "string", - "enum": [ - "failed", - "in_progress", - "succeeded" - ] + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" } }, - "example": { - "id": "2019-01-03-44", - "status": "in_progress" - } - }, - "reloads": { - "description": "HAProxy reloads array", - "type": "array", - "title": "HAProxy Reloads Array", - "items": { - "$ref": "#/definitions/reload" - } + "x-go-name": "ForcePersist" }, - "server": { - "description": "HAProxy backend server configuration", + "BackendBaseIgnorePersist": { + "description": "This field is deprecated in favor of ignore_persist_list, and will be removed in a future release", "type": "object", - "title": "Server", "required": [ - "name" + "cond", + "cond_test" ], "properties": { - "address": { + "cond": { "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" }, - "agent-addr": { + "cond_test": { "type": "string", - "pattern": "^[^\\s]+$" - }, - "agent-check": { + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + } + }, + "x-deprecated": true, + "x-go-name": "BackendIgnorePersist" + }, + "BackendBaseIgnorePersistListItems0": { + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { "type": "string", "enum": [ - "enabled", - "disabled" + "if", + "unless" ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", "x-dependency": { - "agent-port": { + "cond": { "required": true } - } + }, + "x-display-name": "Condition Test" + } + }, + "x-go-name": "IgnorePersist" + }, + "ClusterSettingsCluster": { + "type": "object", + "title": "Cluster controller information", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "readOnly": true }, - "agent-inter": { - "type": "integer", - "x-nullable": true + "api_base_path": { + "type": "string", + "readOnly": true }, - "agent-port": { + "cluster_id": { + "type": "string" + }, + "description": { + "type": "string", + "readOnly": true + }, + "log_targets": { + "type": "array", + "items": { + "$ref": "#/definitions/ClusterSettingsClusterLogTargetsItems0" + }, + "x-go-name": "ClusterLogTargets", + "x-omitempty": true + }, + "name": { + "type": "string", + "readOnly": true + }, + "port": { "type": "integer", "maximum": 65535, "minimum": 1, - "x-nullable": true + "x-nullable": true, + "readOnly": true + } + } + }, + "ClusterSettingsClusterLogTargetsItems0": { + "type": "object", + "required": [ + "address", + "port", + "protocol" + ], + "properties": { + "address": { + "type": "string" }, - "agent-send": { + "log_format": { "type": "string" }, - "allow_0rtt": { - "type": "boolean" + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1 }, - "backup": { + "protocol": { "type": "string", "enum": [ - "enabled", - "disabled" + "tcp", + "udp" ] - }, - "check": { + } + }, + "x-go-name": "ClusterLogTarget" + }, + "CookieAttrItems0": { + "type": "object", + "properties": { + "value": { "type": "string", - "enum": [ - "enabled", - "disabled" - ] - }, - "cookie": { + "pattern": "^[^\\s]+$" + } + }, + "x-go-name": "Attr" + }, + "CookieDomainItems0": { + "type": "object", + "properties": { + "value": { "type": "string", "pattern": "^[^\\s]+$" + } + }, + "x-go-name": "Domain" + }, + "EnvironmentOptionsPresetenvItems0": { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string", + "x-display-name": "Name" }, - "inter": { - "type": "integer", - "x-nullable": true + "value": { + "type": "string", + "x-display-name": "Value" + } + }, + "x-go-name": "PresetEnv" + }, + "EnvironmentOptionsSetenvItems0": { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string", + "x-display-name": "Name" }, - "maintenance": { + "value": { "type": "string", - "enum": [ - "enabled", - "disabled" - ] + "x-display-name": "Value" + } + }, + "x-go-name": "SetEnv" + }, + "FCGILogStderrSample": { + "type": "object", + "title": "Sample", + "required": [ + "ranges", + "size" + ], + "properties": { + "ranges": { + "type": "string", + "title": "Range" }, - "maxconn": { + "size": { "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true - }, - "name": { + "title": "Size" + } + } + }, + "GlobalBaseCPUMapsItems0": { + "type": "object", + "required": [ + "process", + "cpu_set" + ], + "properties": { + "cpu_set": { "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false + "x-display-name": "CPU Set" }, - "on-error": { + "process": { + "type": "string", + "x-display-name": "Process/Thread Set" + } + }, + "x-go-name": "CPUMap" + }, + "GlobalBaseCPUSetItems0": { + "type": "object", + "required": [ + "directive" + ], + "properties": { + "directive": { "type": "string", "enum": [ - "fastinter", - "fail-check", - "sudden-death", - "mark-down" + "reset", + "drop-cpu", + "only-cpu", + "drop-node", + "only-node", + "drop-cluster", + "only-cluster", + "drop-core", + "only-core", + "drop-thread", + "only-thread" ] }, - "on-marked-down": { + "set": { + "type": "string" + } + }, + "x-go-name": "CPUSet" + }, + "GlobalBaseDefaultPath": { + "type": "object", + "required": [ + "type" + ], + "properties": { + "path": { "type": "string", - "enum": [ - "shutdown-sessions" - ] + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "origin" + } + } }, - "on-marked-up": { + "type": { "type": "string", "enum": [ - "shutdown-backup-sessions" - ] - }, - "port": { - "type": "integer", - "maximum": 65535, - "minimum": 1, - "x-nullable": true + "current", + "config", + "parent", + "origin" + ], + "x-nullable": false + } + }, + "x-go-name": "GlobalDefaultPath" + }, + "GlobalBaseH1CaseAdjustItems0": { + "type": "object", + "required": [ + "from", + "to" + ], + "properties": { + "from": { + "type": "string" }, - "send-proxy": { + "to": { + "type": "string" + } + }, + "x-go-name": "H1CaseAdjust" + }, + "GlobalBaseHarden": { + "type": "object", + "properties": { + "reject_privileged_ports": { + "type": "object", + "properties": { + "quic": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tcp": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + } + }, + "x-go-name": "GlobalHardenRejectPrivilegedPorts" + } + }, + "x-go-name": "GlobalHarden" + }, + "GlobalBaseHardenRejectPrivilegedPorts": { + "type": "object", + "properties": { + "quic": { "type": "string", "enum": [ "enabled", "disabled" ] }, - "send-proxy-v2": { + "tcp": { "type": "string", "enum": [ "enabled", "disabled" ] - }, - "ssl": { + } + }, + "x-go-name": "GlobalHardenRejectPrivilegedPorts" + }, + "GlobalBaseLogSendHostname": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { "type": "string", "enum": [ "enabled", "disabled" ] }, - "ssl_cafile": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": "enabled" - } - }, - "x-display-name": "SSL CA File" - }, - "ssl_certificate": { + "param": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": "enabled" - } - } + "pattern": "^[^\\s]+$" + } + }, + "x-display-name": "Log Send Hostname", + "x-go-name": "GlobalLogSendHostname" + }, + "GlobalBaseRuntimeApisItems0": { + "allOf": [ + { + "$ref": "#/definitions/bind_params" }, - "tls_tickets": { - "type": "string", - "enum": [ - "enabled", - "disabled" + { + "type": "object", + "required": [ + "address" ], - "x-dependency": { - "ssl": { - "value": "enabled" + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false } } - }, - "verify": { + } + ], + "x-go-name": "RuntimeAPI" + }, + "GlobalBaseSetVarFmtItems0": { + "type": "object", + "required": [ + "name", + "format" + ], + "properties": { + "format": { "type": "string", - "enum": [ - "none", - "required" - ], - "x-dependency": { - "ssl": { - "value": "enabled" - } - } + "x-display-name": "Format" }, - "weight": { - "type": "integer", - "x-nullable": true + "name": { + "type": "string", + "x-display-name": "Name" } }, - "additionalProperties": false, - "example": { - "address": "10.1.1.1", - "check": "enabled", - "max-connections": 500, - "name": "www", - "port": 8080, - "weight": 80 - } + "x-go-name": "SetVarFmt" }, - "server_switching_rule": { - "description": "HAProxy server switching rule configuration (corresponds to use-server directive)", + "GlobalBaseSetVarItems0": { "type": "object", - "title": "Server Switching Rule", "required": [ - "id", - "target_server" + "name", + "expr" ], "properties": { - "cond": { + "expr": { "type": "string", - "enum": [ - "if", - "unless" - ], - "x-display-name": "Condition" + "x-display-name": "Expression" }, - "cond_test": { + "name": { "type": "string", - "x-dependency": { - "cond": { - "required": true - } - }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } - }, - "id": { - "type": "integer", - "x-nullable": true + "x-display-name": "Name" + } + }, + "x-go-name": "SetVar" + }, + "GlobalBaseThreadGroupLinesItems0": { + "type": "object", + "required": [ + "group", + "num_or_range" + ], + "properties": { + "group": { + "type": "string", + "x-display-name": "Group" }, - "target_server": { + "num_or_range": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dynamic-enum": { - "operation": "getServers", - "property": "name" - }, - "x-nullable": false + "x-display-name": "Number or Range" } }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ req_ssl_sni -i www.example.com }", - "id": 0, - "target_server": "www" - } - }, - "server_switching_rules": { - "description": "HAProxy backend server switching rules array (corresponds to use-server directives)", - "type": "array", - "title": "Server Switching Rules Array", - "items": { - "$ref": "#/definitions/server_switching_rule" - } + "x-go-name": "ThreadGroup" }, - "servers": { - "description": "HAProxy backend servers array", - "type": "array", - "title": "Servers", - "items": { - "$ref": "#/definitions/server" + "InfoAPI": { + "type": "object", + "properties": { + "build_date": { + "description": "HAProxy Dataplane API build date", + "type": "string", + "format": "date-time" + }, + "version": { + "description": "HAProxy Dataplane API version string", + "type": "string" + } } }, - "site": { - "description": "Site configuration. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration \nendpoints.\n", + "InfoSystem": { "type": "object", - "title": "Site", - "required": [ - "name" - ], "properties": { - "farms": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name", - "use_as" - ], - "properties": { - "balance": { - "$ref": "#/definitions/balance" - }, - "cond": { - "type": "string", - "enum": [ - "if", - "unless" - ], - "x-dependency": { - "use_as": { - "required": true, - "value": "conditional" - } - }, - "x-display-name": "Condition" - }, - "cond_test": { - "type": "string", - "x-dependency": { - "use_as": { - "required": true, - "value": "conditional" - } - }, - "x-display-name": "Condition Test" - }, - "forwardfor": { - "$ref": "#/definitions/forwardfor" - }, - "mode": { - "type": "string", - "enum": [ - "http", - "tcp" - ] - }, - "name": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false - }, - "servers": { - "type": "array", - "items": { - "$ref": "#/definitions/server" - } - }, - "use_as": { - "type": "string", - "enum": [ - "default", - "conditional" - ], - "x-nullable": false - } + "cpu_info": { + "type": "object", + "properties": { + "model": { + "type": "string" }, - "x-go-name": "SiteFarm" + "num_cpus": { + "description": "Number of logical CPUs", + "type": "integer" + } } }, - "name": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false + "hostname": { + "description": "Hostname where the HAProxy is running", + "type": "string" }, - "service": { + "mem_info": { "type": "object", "properties": { - "http_connection_mode": { - "type": "string", - "enum": [ - "http-tunnel", - "httpclose", - "forced-close", - "http-server-close", - "http-keep-alive" - ], - "x-dependency": { - "mode": { - "value": "http" - } - }, - "x-display-name": "HTTP Connection Mode" - }, - "listeners": { - "type": "array", - "items": { - "$ref": "#/definitions/bind" - } + "dataplaneapi_memory": { + "type": "integer" }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true + "free_memory": { + "type": "integer" }, - "mode": { - "type": "string", - "enum": [ - "http", - "tcp" - ] + "total_memory": { + "type": "integer" } } + }, + "os_string": { + "description": "OS string", + "type": "string" + }, + "time": { + "description": "Current time in milliseconds since Epoch.", + "type": "integer" + }, + "uptime": { + "description": "System uptime", + "type": "integer", + "x-nullable": true } - }, - "additionalProperties": false, - "example": { - "farms": [ - { - "balance": { - "algorithm": "roundrobin" - }, - "mode": "http", - "name": "www_backend", - "servers": [ - { - "address": "127.0.1.1", - "name": "www_server", - "port": 4567, - "weight": 30 - }, - { - "address": "127.0.1.2", - "name": "www_server_new", - "port": 4567, - "weight": 70 - } - ], - "use_as": "default" - } - ], - "name": "test_site", - "service": { - "http_connection_mode": "httpclose", - "listeners": [ - { - "address": "127.0.0.1", - "name": "test_listener", - "port": 80 - }, - { - "address": "127.0.0.1", - "name": "test_listener_2", - "port": 8080 - } - ], - "maxconn": 2000, - "mode": "http" + } + }, + "InfoSystemCPUInfo": { + "type": "object", + "properties": { + "model": { + "type": "string" + }, + "num_cpus": { + "description": "Number of logical CPUs", + "type": "integer" } } }, - "sites": { - "description": "Sites array. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration \nendpoints.\n", - "type": "array", - "title": "Sites", - "items": { - "$ref": "#/definitions/site" + "InfoSystemMemInfo": { + "type": "object", + "properties": { + "dataplaneapi_memory": { + "type": "integer" + }, + "free_memory": { + "type": "integer" + }, + "total_memory": { + "type": "integer" + } } }, - "stick_rule": { - "description": "Define a pattern used to create an entry in a stickiness table or matching condition or associate a user to a server.", + "LuaOptionsLoadsItems0": { "type": "object", - "title": "Stick Rule", "required": [ - "id", - "type", - "pattern" + "file" ], "properties": { - "cond": { - "type": "string", - "enum": [ - "if", - "unless" - ], - "x-display-name": "Condition" - }, - "cond_test": { - "type": "string", - "x-dependency": { - "cond": { - "required": true - } - }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "pattern": { + "file": { "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false - }, - "table": { + "pattern": "^[^\\s]+$" + } + }, + "x-go-name": "LuaLoad" + }, + "LuaOptionsPrependPathItems0": { + "type": "object", + "required": [ + "path" + ], + "properties": { + "path": { "type": "string", "pattern": "^[^\\s]+$" }, "type": { "type": "string", "enum": [ - "match", - "on", - "store-request", - "store-response" - ], - "x-nullable": false + "path", + "cpath" + ] } }, - "additionalProperties": false, - "example": { - "id": 0, - "pattern": "src", - "type": "storeonly" - } + "x-go-name": "LuaPrependPath" }, - "stick_rules": { - "description": "HAProxy backend stick rules array (corresponds to stick store-request, stick match, stick on, stick store-response)", - "type": "array", - "title": "Stick Rules Array", - "items": { - "$ref": "#/definitions/stick_rule" - } + "OcspUpdateOptionsHttpproxy": { + "type": "object", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "example": "127.0.0.1" + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "example": 80 + } + }, + "x-display-name": "OCSP Update HTTP Proxy", + "x-omitempty": true }, - "tcp_request_rule": { - "description": "HAProxy TCP Request Rule configuration (corresponds to tcp-request)", + "ServerParamsSetProxyV2TlvFmt": { "type": "object", - "title": "TCP Request Rule", "required": [ "id", - "type" + "value" ], "properties": { - "action": { - "type": "string", - "enum": [ - "accept", - "reject" - ], - "x-dependency": { - "type": { - "required": true, - "value": [ - "connection", - "content", - "session" - ] - } - }, - "x-nullable": false + "id": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "SiteFarmsItems0": { + "type": "object", + "required": [ + "name", + "use_as" + ], + "properties": { + "balance": { + "$ref": "#/definitions/balance" }, "cond": { "type": "string", @@ -9110,12 +85885,9 @@ func init() { "unless" ], "x-dependency": { - "type": { - "value": [ - "connection", - "content", - "session" - ] + "use_as": { + "required": true, + "value": "conditional" } }, "x-display-name": "Condition" @@ -9123,100 +85895,98 @@ func init() { "cond_test": { "type": "string", "x-dependency": { - "cond": { - "required": true - }, - "type": { + "use_as": { "required": true, - "value": [ - "connection", - "content", - "session" - ] + "value": "conditional" } }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } + "x-display-name": "Condition Test" }, - "id": { - "type": "integer", - "x-nullable": true + "forwardfor": { + "$ref": "#/definitions/forwardfor" + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp" + ] }, - "timeout": { - "type": "integer", - "x-dependency": { - "type": { - "required": true, - "value": "inspect-delay" - } + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "servers": { + "type": "array", + "items": { + "$ref": "#/definitions/server" }, - "x-nullable": true + "x-omitempty": true }, - "type": { + "use_as": { "type": "string", "enum": [ - "connection", - "content", - "inspect-delay", - "session" + "default", + "conditional" ], "x-nullable": false } }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ src 192.168.0.0/16 }", - "id": 0, - "type": "accept" - } - }, - "tcp_request_rules": { - "description": "HAProxy TCP request rules array (corresponds to tcp-request directive)", - "type": "array", - "title": "TCP Request Rules Array", - "items": { - "$ref": "#/definitions/tcp_request_rule" - } + "x-go-name": "SiteFarm" }, - "tcp_response_rule": { - "description": "HAProxy TCP Response Rule configuration (corresponds to tcp-response)", + "SiteService": { "type": "object", - "title": "TCP Response Rule", - "required": [ - "id", - "type" - ], "properties": { - "action": { + "http_connection_mode": { "type": "string", "enum": [ - "accept", - "reject" + "http-tunnel", + "httpclose", + "forced-close", + "http-server-close", + "http-keep-alive" ], "x-dependency": { - "type": { - "required": true, - "value": "content" + "mode": { + "value": "http" } }, - "x-nullable": false + "x-display-name": "HTTP Connection Mode" + }, + "listeners": { + "type": "array", + "items": { + "$ref": "#/definitions/bind" + }, + "x-omitempty": true + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections", + "x-nullable": true }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp" + ] + } + } + }, + "SpoeMessageEvent": { + "type": "object", + "required": [ + "name" + ], + "properties": { "cond": { "type": "string", "enum": [ "if", "unless" ], - "x-dependency": { - "type": { - "value": "content" - } - }, "x-display-name": "Condition" }, "cond_test": { @@ -9224,8633 +85994,12135 @@ func init() { "x-dependency": { "cond": { "required": true - }, - "type": { - "value": "content" - } - }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } - }, - "id": { - "type": "integer", - "x-nullable": true - }, - "timeout": { - "type": "integer", - "x-dependency": { - "type": { - "required": true, - "value": "inspect-delay" } }, - "x-nullable": true + "x-display-name": "Condition Test" }, - "type": { + "name": { "type": "string", "enum": [ - "content", - "inspect-delay" - ], - "x-nullable": false + "on-backend-http-request", + "on-backend-tcp-request", + "on-client-session", + "on-frontend-http-request", + "on-frontend-tcp-request", + "on-http-response", + "on-server-session", + "on-tcp-response" + ] } - }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ src 192.168.0.0/16 }", - "id": 0, - "type": "accept" } }, - "tcp_response_rules": { - "description": "HAProxy TCP response rules array (corresponds to tcp-response directive)", - "type": "array", - "title": "TCP Response Rules Array", - "items": { - "$ref": "#/definitions/tcp_response_rule" - } + "SslCrlEntryRevokedCertificatesItems0": { + "type": "object", + "properties": { + "revocation_date": { + "type": "string", + "format": "date" + }, + "serial_number": { + "type": "string" + } + }, + "x-go-name": "RevokedCertificates" }, - "transaction": { - "description": "HAProxy configuration transaction", + "SslOcspResponseResponses": { "type": "object", - "title": "Configuration transaction", "properties": { - "_version": { - "type": "integer" + "cert_status": { + "type": "string" }, - "id": { + "certificate_id": { + "$ref": "#/definitions/sslCertificateIdCertificateId" + }, + "next_update": { "type": "string", - "pattern": "^[^\\s]+$" + "format": "date" }, - "status": { + "revocation_reason": { "type": "string", - "enum": [ - "failed", - "in_progress", - "success" - ] + "x-omitempty": true + }, + "this_update": { + "type": "string", + "format": "date" } }, - "example": { - "_version": 2, - "id": "273e3385-2d0c-4fb1-aa27-93cbb31ff203", - "status": "in_progress" - } - }, - "transactions": { - "description": "Configuration transactions array", - "type": "array", - "title": "Transactions array", - "items": { - "$ref": "#/definitions/transaction" - } - } - }, - "parameters": { - "force_reload": { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - }, - "transaction_id": { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-go-name": "OCSPResponses" }, - "version": { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - } - }, - "responses": { - "AlreadyExists": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" + "SslOptionsEnginesItems0": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "algorithms": { + "type": "string", + "x-display-name": "Algorithms", + "x-nullable": true + }, + "name": { + "type": "string", + "x-display-name": "Name" + } }, - "headers": { - "Configuration-Version": { + "x-go-name": "SslEngine" + }, + "StickTableEntryGpc": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { "type": "integer", - "description": "Configuration file version" + "x-nullable": true } } }, - "BadRequest": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { + "StickTableEntryGpcRate": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { "type": "integer", - "description": "Configuration file version" + "x-nullable": true } } }, - "DefaultError": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { + "StickTableEntryGpt": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { "type": "integer", - "description": "Configuration file version" + "x-nullable": true } } }, - "NotFound": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { + "StickTableFieldsItems0": { + "type": "object", + "properties": { + "field": { + "type": "string", + "enum": [ + "bytes_in_cnt", + "bytes_in_rate", + "bytes_out_cnt", + "bytes_out_rate", + "conn_cnt", + "conn_cur", + "conn_rate", + "glitch_cnt", + "glitch_rate", + "gpc", + "gpc_rate", + "gpc0", + "gpc0_rate", + "gpc1", + "gpc1_rate", + "gpt0", + "gpt", + "http_req_cnt", + "http_req_rate", + "http_err_cnt", + "http_err_rate", + "http_fail_cnt", + "http_fail_rate", + "server_id", + "sess_cnt", + "sess_rate" + ] + }, + "idx": { "type": "integer", - "description": "Configuration file version" + "x-dependency": { + "field": { + "value": [ + "gpc", + "gpc_rate", + "gpt" + ] + } + } + }, + "period": { + "type": "integer", + "x-dependency": { + "type": { + "value": "rate" + } + } + }, + "type": { + "type": "string", + "enum": [ + "rate", + "counter" + ] } - } - } - }, - "securityDefinitions": { - "basic_auth": { - "type": "basic" - } - }, - "security": [ - { - "basic_auth": null - } - ], - "tags": [ - { - "description": "API autodiscover endpoints", - "name": "Discovery" - }, - { - "name": "Information" - }, - { - "name": "Specification" - }, - { - "description": "Managing transactions. Configuration changes can be grouped in the transaction. You start the \ntransaction with trasactions POST, and call the configuration changes you need with parameter \ntransaction_id. When you want to commit the transaction, you call the transactions PUT and all changes\nin that transaction is commited. If you call a configuration change without the transaction_id, \ntransaction mechanism is implicitly called with one operation in transaction.\n", - "name": "Transactions" - }, - { - "description": "Checking reload success. To avoid constant reloading we reload in intervals that are configurable when\nwith reload-delay option. When a change to configuration is made and force_reload url query string \nparameter is false we issue a request for reload, and return the reload ID in response header. You can\nthen use reloads endpoints to check the status of that reload ID. If force_reload is true, we override all\nof this and reload immediately.\n", - "name": "Reloads" - }, - { - "description": "Managing sites (simple configuration mode). Sites are considered as one frontend with multiple backends \nconnected to it via default_backend or use-backend directives.\n", - "name": "Sites" - }, - { - "description": "Stats container", - "name": "Stats" - }, - { - "description": "Managing global configuration (advanced mode)", - "name": "Global" - }, - { - "description": "Managing defaults configuration (advanced mode)", - "name": "Defaults" - }, - { - "description": "Managing frontend configuration (advanced mode)", - "name": "Frontend" - }, - { - "description": "Managing backend configurations (advanced mode)", - "name": "Backend" - }, - { - "description": "Managing frontend bind configurations (advanced mode)", - "name": "Bind" - }, - { - "description": "Managing backend server configurations (advanced mode)", - "name": "Server" - }, - { - "description": "Various frontend options (advanced mode)", - "name": "Frontend options" - }, - { - "description": "Various backend options (advanced mode)", - "name": "Backend options" - }, - { - "description": "Raw HAProxy configuration management (advanced mode)", - "name": "Configuration" - }, - { - "description": "Managing advanced haproxy configuration (advanced mode)", - "name": "HAProxy configuration management" - }, - { - "name": "TCPRequestRule" - }, - { - "name": "HTTPRequestRule" - }, - { - "name": "HTTPResponseRule" - }, - { - "name": "BackendSwitchingRule" - }, - { - "name": "ServerSwitchingRule" + }, + "x-go-name": "StickTableField" }, - { - "name": "TCPResponseRule" + "acl": { + "description": "The use of Access Control Lists (ACL) provides a flexible solution to perform\ncontent switching and generally to take decisions based on content extracted\nfrom the request, the response or any environmental status.\n", + "type": "object", + "title": "ACL Lines", + "required": [ + "acl_name", + "criterion" + ], + "properties": { + "acl_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "criterion": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "value": { + "type": "string", + "x-nullable": false + } + }, + "additionalProperties": false }, - { - "name": "Filter" + "acl_file": { + "description": "ACL File", + "type": "object", + "title": "ACL File", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "storage_name": { + "type": "string" + } + } }, - { - "name": "StickRule" + "acl_file_entry": { + "description": "One ACL File Entry", + "type": "object", + "title": "One ACL File Entry", + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "value": { + "type": "string" + } + } }, - { - "name": "LogTarget" + "acl_files": { + "description": "Array of runtime acl files", + "type": "array", + "title": "ACL Files Array", + "items": { + "$ref": "#/definitions/acl_file" + } }, - { - "name": "ACL" - } - ], - "externalDocs": { - "description": "HAProxy Documentation", - "url": "https://cbonte.github.io/haproxy-dconv/" - } -}`)) - FlatSwaggerJSON = json.RawMessage([]byte(`{ - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "schemes": [ - "http" - ], - "swagger": "2.0", - "info": { - "description": "API for editing and managing haproxy instances. Provides process information, configuration management,\nhaproxy stats and logs.\n", - "title": "HAProxy Data Plane API", - "contact": { - "name": "HAProxy Support", - "url": "https://my.haproxy.com/portal/cust/login", - "email": "support@haproxy.com" + "acl_files_entries": { + "description": "Array of entries of one runtime acl file", + "type": "array", + "title": "ACL Files Entries", + "items": { + "$ref": "#/definitions/acl_file_entry" + } }, - "version": "2.0" - }, - "basePath": "/v2", - "paths": { - "/": { - "get": { - "description": "Returns a list of root endpoints.", - "produces": [ - "application/json" - ], - "tags": [ - "Discovery" - ], - "summary": "Return list of root endpoints", - "operationId": "getAPIEndpoints", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/endpoints" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } + "acls": { + "description": "HAProxy ACL lines array (corresponds to acl directives)", + "type": "array", + "title": "ACL Lines Array", + "items": { + "$ref": "#/definitions/acl" } }, - "/info": { - "get": { - "description": "Return API, hardware and OS information", - "produces": [ - "application/json" - ], - "tags": [ - "Information" - ], - "summary": "Return API, hardware and OS information", - "operationId": "getInfo", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/info" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "acme_certificate_status": { + "description": "Status of a single ACME certificate from runtime.", + "type": "object", + "title": "ACME certificate status", + "properties": { + "acme_section": { + "description": "ACME section which generated the certificate.", + "type": "string" + }, + "certificate": { + "description": "Certificate name", + "type": "string" + }, + "expiries_in": { + "description": "Duration until certificate expiry.", + "type": "string" + }, + "expiry_date": { + "description": "Certificate expiration date.", + "type": "string", + "format": "date-time" + }, + "renewal_in": { + "description": "Duration until the next planned renewal.", + "type": "string" + }, + "scheduled_renewal": { + "description": "Planned date for certificate renewal.", + "type": "string", + "format": "date-time" + }, + "state": { + "description": "State of the ACME task, either \"Running\" or \"Scheduled\".", + "type": "string" } } }, - "/services": { - "get": { - "description": "Returns a list of API managed services endpoints.", - "produces": [ - "application/json" - ], - "tags": [ - "Discovery" - ], - "summary": "Return list of service endpoints", - "operationId": "getServicesEndpoints", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/endpoints" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "acme_provider": { + "description": "Define an ACME provider to generate certificates automatically", + "type": "object", + "title": "ACME Provider", + "required": [ + "name", + "directory" + ], + "properties": { + "account_key": { + "description": "Path where the the ACME account key is stored", + "type": "string" + }, + "acme_provider": { + "description": "DNS provider for the dns-01 challenge", + "type": "string" + }, + "acme_vars": { + "description": "List of variables passed to the dns-01 provider (typically API keys)", + "additionalProperties": { + "type": "string" + } + }, + "bits": { + "description": "Number of bits to generate an RSA certificate", + "type": "integer", + "minimum": 1024, + "x-nullable": true, + "x-omitempty": true + }, + "challenge": { + "description": "ACME challenge type. Only http-01 and dns-01 are supported.", + "type": "string", + "enum": [ + "http-01", + "dns-01" + ] + }, + "contact": { + "description": "Contact email for the ACME account", + "type": "string" + }, + "curves": { + "description": "Curves used with the ECDSA key type", + "type": "string" + }, + "directory": { + "description": "URL to the ACME provider's directory. For example:\nhttps://acme-staging-v02.api.letsencrypt.org/directory\n", + "type": "string", + "pattern": "^https://[^\\s]+$", + "x-nullable": false + }, + "keytype": { + "description": "Type of key to generate", + "type": "string", + "enum": [ + "RSA", + "ECDSA" + ] + }, + "map": { + "description": "The map which will be used to store the ACME token (key) and thumbprint", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "description": "ACME provider's name", + "type": "string", + "x-nullable": false + }, + "reuse_key": { + "description": "Try to reuse the private key instead of generating a new one.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] } + }, + "additionalProperties": false + }, + "acme_providers": { + "description": "List of ACME sections.", + "type": "array", + "items": { + "x-omitempty": true, + "$ref": "#/definitions/acme_provider" } }, - "/services/haproxy": { - "get": { - "description": "Returns a list of HAProxy related endpoints.", - "produces": [ - "application/json" - ], - "tags": [ - "Discovery" - ], - "summary": "Return list of HAProxy related endpoints", - "operationId": "getHaproxyEndpoints", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/endpoints" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } + "acme_status": { + "description": "Status of all the ACME certificates from runtime.", + "type": "array", + "title": "ACME status", + "items": { + "$ref": "#/definitions/acme_certificate_status" } }, - "/services/haproxy/configuration": { - "get": { - "description": "Returns a list of endpoints to be used for advanced configuration of HAProxy objects.", - "produces": [ - "application/json" - ], - "tags": [ - "Discovery" - ], - "summary": "Return list of HAProxy advanced configuration endpoints", - "operationId": "getConfigurationEndpoints", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/endpoints" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "awsFilters": { + "type": "object", + "required": [ + "key", + "value" + ], + "properties": { + "key": { + "description": "Key to use as filter, using the format specified at https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options", + "type": "string" + }, + "value": { + "description": "Value of the filter to use", + "type": "string" } } }, - "/services/haproxy/configuration/acls": { - "get": { - "description": "Returns all ACL lines that are configured in specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" - ], - "summary": "Return an array of all ACL lines", - "operationId": "getAcls", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "awsRegion": { + "description": "AWS region configuration", + "type": "object", + "title": "AWS region", + "required": [ + "name", + "region", + "enabled", + "retry_timeout", + "ipv4_address" + ], + "properties": { + "access_key_id": { + "description": "AWS Access Key ID.", + "type": "string" + }, + "allowlist": { + "description": "Specify the AWS filters used to filter the EC2 instances to add", + "type": "array", + "items": { + "$ref": "#/definitions/awsFilters" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/acls" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-omitempty": true + }, + "denylist": { + "description": "Specify the AWS filters used to filter the EC2 instances to ignore", + "type": "array", + "items": { + "$ref": "#/definitions/awsFilters" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "x-omitempty": true + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "id": { + "description": "Auto generated ID.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true, + "readOnly": true + }, + "ipv4_address": { + "description": "Select which IPv4 address the Service Discovery has to use for the backend server entry", + "type": "string", + "enum": [ + "private", + "public" + ] + }, + "name": { + "type": "string" + }, + "region": { + "type": "string" + }, + "retry_timeout": { + "description": "Duration in seconds in-between data pulling requests to the AWS region", + "type": "integer", + "minimum": 1 + }, + "secret_access_key": { + "description": "AWS Secret Access Key.", + "type": "string" + }, + "server_slots_base": { + "type": "integer", + "default": 10 + }, + "server_slots_growth_increment": { + "type": "integer" + }, + "server_slots_growth_type": { + "type": "string", + "default": "exponential", + "enum": [ + "linear", + "exponential" + ] } }, - "post": { - "description": "Adds a new ACL line of the specified type in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" - ], - "summary": "Add a new ACL line", - "operationId": "createAcl", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/acl" - } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, + "example": { + "access_key_id": "****************L7GT", + "allowlist": [ { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, + "key": "tag-key", + "value": "Instance:Having:This:Tag" + } + ], + "denylist": [ { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "key": "tag:Environment", + "value": "development" } ], - "responses": { - "201": { - "description": "ACL line created", - "schema": { - "$ref": "#/definitions/acl" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/acl" + "enabled": true, + "id": "0", + "ipv4_address": "private", + "name": "frontend-service", + "region": "us-east-1", + "retry_timeout": 1, + "secret_access_key": "****************soLl" + } + }, + "awsRegions": { + "description": "AWS regions array", + "type": "array", + "title": "AWS", + "items": { + "$ref": "#/definitions/awsRegion" + } + }, + "backend": { + "description": "Backend with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/backend_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" + "filter_list": { + "x-go-name": "FilterList", + "$ref": "#/definitions/filters" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" + "http_after_response_rule_list": { + "x-go-name": "HTTPAfterResponseRuleList", + "$ref": "#/definitions/http_after_response_rules" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "http_check_list": { + "x-go-name": "HTTPCheckList", + "$ref": "#/definitions/http_checks" + }, + "http_error_rule_list": { + "x-go-name": "HTTPErrorRuleList", + "$ref": "#/definitions/http_error_rules" + }, + "http_request_rule_list": { + "x-go-name": "HTTPRequestRuleList", + "$ref": "#/definitions/http_request_rules" + }, + "http_response_rule_list": { + "x-go-name": "HTTPResponseRuleList", + "$ref": "#/definitions/http_response_rules" + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + }, + "server_switching_rule_list": { + "x-go-name": "ServerSwitchingRuleList", + "$ref": "#/definitions/server_switching_rules" + }, + "server_templates": { + "additionalProperties": { + "$ref": "#/definitions/server_template" } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "servers": { + "additionalProperties": { + "$ref": "#/definitions/server" } + }, + "stick_rule_list": { + "x-go-name": "StickRuleList", + "$ref": "#/definitions/stick_rules" + }, + "tcp_check_rule_list": { + "x-go-name": "TCPCheckRuleList", + "$ref": "#/definitions/tcp_checks" + }, + "tcp_request_rule_list": { + "x-go-name": "TCPRequestRuleList", + "$ref": "#/definitions/tcp_request_rules" + }, + "tcp_response_rule_list": { + "x-go-name": "TCPResponseRuleList", + "$ref": "#/definitions/tcp_response_rules" } } } - } + ], + "x-go-name": "Backend" }, - "/services/haproxy/configuration/acls/{id}": { - "get": { - "description": "Returns one ACL line configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" - ], - "summary": "Return one ACL line", - "operationId": "getAcl", - "parameters": [ - { - "type": "integer", - "description": "ACL line ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "backend_base": { + "description": "HAProxy backend configuration", + "type": "object", + "title": "Backend Base", + "required": [ + "name" + ], + "properties": { + "abortonclose": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "accept_invalid_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Response" + }, + "accept_unsafe_violations_in_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Response" + }, + "adv_check": { + "type": "string", + "enum": [ + "httpchk", + "ldap-check", + "mysql-check", + "pgsql-check", + "redis-check", + "smtpchk", + "ssl-hello-chk", + "tcp-check" + ], + "x-display-name": "Advanced Check" + }, + "allbackups": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "All Backups" + }, + "balance": { + "$ref": "#/definitions/balance" + }, + "check_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "checkcache": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Checkcache" + }, + "compression": { + "$ref": "#/definitions/compression" + }, + "connect_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "cookie": { + "x-dependency": { + "mode": { + "value": "http" + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/acl" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/cookie" + }, + "default_server": { + "$ref": "#/definitions/default_server" + }, + "description": { + "type": "string", + "x-display-name": "Description" + }, + "disabled": { + "type": "boolean" + }, + "dynamic_cookie_key": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "cookie.dynamic": { + "value": true } + } + }, + "email_alert": { + "$ref": "#/definitions/email_alert" + }, + "enabled": { + "type": "boolean" + }, + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-go-name": "ErrorFiles", + "x-omitempty": true + }, + "errorfiles_from_http_errors": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfiles" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "x-go-name": "ErrorFilesFromHTTPErrors", + "x-omitempty": true + }, + "errorloc302": { + "$ref": "#/definitions/errorloc" + }, + "errorloc303": { + "$ref": "#/definitions/errorloc" + }, + "external_check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "External Check" + }, + "external_check_command": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Command" + }, + "external_check_path": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Path" + }, + "force_persist": { + "description": "This field is deprecated in favor of force_persist_list, and will be removed in a future release", + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" } - } - } - }, - "put": { - "description": "Replaces a ACL line configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" - ], - "summary": "Replace a ACL line", - "operationId": "replaceAcl", - "parameters": [ - { - "type": "integer", - "description": "ACL line ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-deprecated": true, + "x-go-name": "BackendForcePersist" + }, + "force_persist_list": { + "type": "array", + "items": { + "$ref": "#/definitions/BackendBaseForcePersistListItems0" }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/acl" + "x-go-name": "ForcePersistList", + "x-omitempty": true + }, + "forwardfor": { + "x-dependency": { + "mode": { + "value": "http" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "ACL line replaced", - "schema": { - "$ref": "#/definitions/acl" + "$ref": "#/definitions/forwardfor" + }, + "from": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "fullconn": { + "type": "integer", + "x-nullable": true + }, + "guid": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "h1_case_adjust_bogus_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/acl" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "H1 Adjust Bogus Server" + }, + "hash_balance_factor": { + "type": "integer", + "x-nullable": true + }, + "hash_preserve_affinity": { + "type": "string", + "enum": [ + "always", + "maxconn", + "maxqueue" + ] + }, + "hash_type": { + "$ref": "#/definitions/hash_type" + }, + "http-buffer-request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "HTTP bufferrequest" + }, + "http-drop-request-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Request Trailers" + }, + "http-no-delay": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "HTTP low interactive delays" + }, + "http-use-htx": { + "type": "string", + "pattern": "^[^\\s]+$", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "http_connection_mode": { + "type": "string", + "enum": [ + "httpclose", + "http-server-close", + "http-keep-alive" + ], + "x-dependency": { + "mode": { + "value": "http" } } - } - }, - "delete": { - "description": "Deletes a ACL line configuration by it's ID from the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "ACL" - ], - "summary": "Delete a ACL line", - "operationId": "deleteAcl", - "parameters": [ - { - "type": "integer", - "description": "ACL line ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + }, + "http_keep_alive_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-duration": true, + "x-nullable": true + }, + "http_pretend_keepalive": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" + } } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "http_proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" } }, - "204": { - "description": "ACL line deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "HTTP proxy mode" + }, + "http_request_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-duration": true, + "x-nullable": true + }, + "http_restrict_req_hdr_names": { + "type": "string", + "enum": [ + "preserve", + "delete", + "reject" + ], + "x-display-name": "Restrict HTTP Request Header Names" + }, + "http_reuse": { + "type": "string", + "enum": [ + "aggressive", + "always", + "never", + "safe" + ], + "x-dependency": { + "mode": { + "value": "http" } } - } - } - }, - "/services/haproxy/configuration/backend_switching_rules": { - "get": { - "description": "Returns all Backend Switching Rules that are configured in specified frontend.", - "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" - ], - "summary": "Return an array of all Backend Switching Rules", - "operationId": "getBackendSwitchingRules", - "parameters": [ - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backend_switching_rules" - } - } + }, + "http_send_name_header": { + "type": "string", + "x-display-name": "The header string to use to send the server name", + "x-nullable": true + }, + "httpchk_params": { + "x-dependency": { + "adv_check": { + "value": "httpchk" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "mode": { + "value": "http" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "$ref": "#/definitions/httpchk_params" + }, + "id": { + "type": "integer", + "x-nullable": true + }, + "ignore_persist": { + "description": "This field is deprecated in favor of ignore_persist_list, and will be removed in a future release", + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } - }, - "post": { - "description": "Adds a new Backend Switching Rule of the specified type in the specified frontend.", - "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" - ], - "summary": "Add a new Backend Switching Rule", - "operationId": "createBackendSwitchingRule", - "parameters": [ - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/backend_switching_rule" + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-deprecated": true, + "x-go-name": "BackendIgnorePersist" + }, + "ignore_persist_list": { + "type": "array", + "items": { + "$ref": "#/definitions/BackendBaseIgnorePersistListItems0" }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-go-name": "IgnorePersistList", + "x-omitempty": true + }, + "independent_streams": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Independent Streams" + }, + "load_server_state_from_file": { + "type": "string", + "enum": [ + "global", + "local", + "none" + ] + }, + "log_health_checks": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log Health Checks" + }, + "log_tag": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "max_keep_alive_queue": { + "type": "integer", + "x-display-name": "Maximum keep alive queue", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "201": { - "description": "Backend Switching Rule created", - "schema": { - "$ref": "#/definitions/backend_switching_rule" + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp", + "log" + ] + }, + "mysql_check_params": { + "x-dependency": { + "adv_check": { + "value": "mysql-check" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/backend_switching_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "$ref": "#/definitions/mysql_check_params" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "nolinger": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Nolinger" + }, + "originalto": { + "$ref": "#/definitions/originalto" + }, + "persist": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Persist" + }, + "persist_rule": { + "$ref": "#/definitions/persist_rule" + }, + "pgsql_check_params": { + "x-dependency": { + "adv_check": { + "value": "pgsql-check" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/pgsql_check_params" + }, + "prefer_last_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Prefer Last Server" + }, + "queue_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "redispatch": { + "$ref": "#/definitions/redispatch" + }, + "retries": { + "type": "integer", + "x-nullable": true + }, + "retry_on": { + "type": "string", + "x-display-name": "Retry on" + }, + "server_fin_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "server_state_file_name": { + "type": "string", + "x-display-name": "Server state file" + }, + "server_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "smtpchk_params": { + "x-dependency": { + "adv_check": { + "value": "smtpchk" } }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/smtpchk_params" + }, + "source": { + "$ref": "#/definitions/source" + }, + "splice_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Auto" + }, + "splice_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Request" + }, + "splice_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Response" + }, + "spop_check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Spop Check" + }, + "srvtcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Server TCP Keep Alive" + }, + "srvtcpka_cnt": { + "type": "integer", + "x-display-name": "Srvtcpka Cnt", + "x-nullable": true + }, + "srvtcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "srvtcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "stats_options": { + "$ref": "#/definitions/stats_options" + }, + "stick_table": { + "$ref": "#/definitions/config_stick_table" + }, + "tarpit_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "tcp_smart_connect": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Connect" + }, + "tcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" } - } + }, + "x-display-name": "TCP Keep Alive" + }, + "transparent": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Transparent" + }, + "tunnel_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "use_fcgi_app": { + "type": "string", + "x-display-name": "FastCGI application" } + }, + "additionalProperties": false, + "example": { + "adv_check": "httpchk", + "balance": { + "algorithm": "roundrobin" + }, + "forwardfor": { + "enabled": "enabled" + }, + "httpchk_params": { + "method": "GET", + "uri": "/check", + "version": "HTTP/1.1" + }, + "mode": "http", + "name": "test_backend" } }, - "/services/haproxy/configuration/backend_switching_rules/{id}": { - "get": { - "description": "Returns one Backend Switching Rule configuration by it's ID in the specified frontend.", - "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" - ], - "summary": "Return one Backend Switching Rule", - "operationId": "getBackendSwitchingRule", - "parameters": [ - { - "type": "integer", - "description": "Switching Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backend_switching_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "backend_switching_rule": { + "description": "HAProxy backend switching rule configuration (corresponds to use_backend directive)", + "type": "object", + "title": "Backend Switching Rule", + "required": [ + "name" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Backend Name", + "x-dynamic-enum": { + "operation": "getBackends", + "property": "name" + }, + "x-nullable": false } }, - "put": { - "description": "Replaces a Backend Switching Rule configuration by it's ID in the specified frontend.", - "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" - ], - "summary": "Replace a Backend Switching Rule", - "operationId": "replaceBackendSwitchingRule", - "parameters": [ - { - "type": "integer", - "description": "Switching Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/backend_switching_rule" + "additionalProperties": false, + "example": { + "cond": "if", + "cond_test": "{ req_ssl_sni -i www.example.com }", + "index": 0, + "name": "test_backend" + } + }, + "backend_switching_rules": { + "description": "HAProxy backend switching rules array (corresponds to use_backend directives)", + "type": "array", + "title": "Backend Switching Rules Array", + "items": { + "$ref": "#/definitions/backend_switching_rule" + } + }, + "backends": { + "description": "HAProxy backends array", + "type": "array", + "title": "Backends", + "items": { + "$ref": "#/definitions/backend" + } + }, + "balance": { + "type": "object", + "required": [ + "algorithm" + ], + "properties": { + "algorithm": { + "type": "string", + "enum": [ + "first", + "hash", + "hdr", + "leastconn", + "random", + "rdp-cookie", + "roundrobin", + "source", + "static-rr", + "uri", + "url_param" + ] + }, + "hash_expression": { + "type": "string", + "x-dependency": { + "algorithm": { + "value": "hash" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Backend Switching Rule replaced", - "schema": { - "$ref": "#/definitions/backend_switching_rule" + "x-display-name": "Hash Expression" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "algorithm": { + "required": true, + "value": "hdr" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/backend_switching_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Header Name" + }, + "hdr_use_domain_only": { + "type": "boolean", + "x-dependency": { + "algorithm": { + "value": "hdr" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Header Use Domain Only" + }, + "random_draws": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "random" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Random Draws", + "x-nullable": false + }, + "rdp_cookie_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "algorithm": { + "value": "rdp-cookie" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Rdp Cookie Name" + }, + "uri_depth": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "uri" } - } - } - }, - "delete": { - "description": "Deletes a Backend Switching Rule configuration by it's ID from the specified frontend.", - "tags": [ - "HAProxy configuration management", - "Frontend options", - "BackendSwitchingRule" - ], - "summary": "Delete a Backend Switching Rule", - "operationId": "deleteBackendSwitchingRule", - "parameters": [ - { - "type": "integer", - "description": "Switching Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "Uri Depth" + }, + "uri_len": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "uri" + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Uri Len" + }, + "uri_path_only": { + "type": "boolean", + "x-dependency": { + "algorithm": { + "value": "uri" } }, - "204": { - "description": "Backend Switching Rule deleted" + "x-display-name": "Uri Path Only" + }, + "uri_whole": { + "type": "boolean", + "x-dependency": { + "algorithm": { + "value": "uri" + } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Uri Whole" + }, + "url_param": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "algorithm": { + "required": true, + "value": "url_param" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Url Param" + }, + "url_param_check_post": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "url_param" } - } + }, + "x-display-name": "Url Param Check Post" + }, + "url_param_max_wait": { + "type": "integer", + "x-dependency": { + "algorithm": { + "value": "url_param" + } + }, + "x-display-name": "Url Param Max Weight" } } }, - "/services/haproxy/configuration/backends": { - "get": { - "description": "Returns an array of all configured backends.", - "tags": [ - "Backend", - "HAProxy configuration management" - ], - "summary": "Return an array of backends", - "operationId": "getBackends", - "parameters": [ - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backends" - } - } + "bind": { + "description": "HAProxy frontend bind configuration", + "title": "Bind", + "allOf": [ + { + "$ref": "#/definitions/bind_params" + }, + { + "type": "object", + "required": [ + "name" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "example": "127.0.0.1" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "example": 80 + }, + "port-range-end": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "example": 81 } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "additionalProperties": false + } + ] + }, + "bind_params": { + "type": "object", + "properties": { + "accept_netscaler_cip": { + "type": "integer" + }, + "accept_proxy": { + "type": "boolean" + }, + "allow_0rtt": { + "type": "boolean" + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "ALPN Protocols" + }, + "backlog": { + "type": "string" + }, + "ca_ignore_err": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } } - } - }, - "post": { - "description": "Adds a new backend to the configuration file.", - "tags": [ - "Backend", - "HAProxy configuration management" - ], - "summary": "Add a backend", - "operationId": "createBackend", - "parameters": [ - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/backend" + }, + "ca_sign_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" } - ], - "responses": { - "201": { - "description": "Backend created", - "schema": { - "$ref": "#/definitions/backend" + }, + "ca_sign_pass": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/backend" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Passphrase" + }, + "ca_verify_file": { + "type": "string", + "x-dependency": { + "ca_file": { + "value": true } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "cc": { + "type": "string", + "x-display-name": "TCP Congestion Control Algorithm" + }, + "ciphers": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } - }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "ciphersuites": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "client_sigalgs": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } } - } - } - }, - "/services/haproxy/configuration/backends/{name}": { - "get": { - "description": "Returns one backend configuration by it's name.", - "tags": [ - "Backend", - "HAProxy configuration management" - ], - "summary": "Return a backend", - "operationId": "getBackend", - "parameters": [ - { - "type": "string", - "description": "Backend name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + }, + "crl_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/backend" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "crt_ignore_err": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "crt_list": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "curves": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } } - } - }, - "put": { - "description": "Replaces a backend configuration by it's name.", - "tags": [ - "Backend", - "HAProxy configuration management" - ], - "summary": "Replace a backend", - "operationId": "replaceBackend", - "parameters": [ - { + }, + "default_crt_list": { + "type": "array", + "items": { "type": "string", - "description": "Backend name", - "name": "name", - "in": "path", - "required": true + "pattern": "^[^\\s]+$" }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/backend" + "x-omitempty": true + }, + "defer_accept": { + "type": "boolean" + }, + "ecdhe": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "expose_fd_listeners": { + "type": "boolean" + }, + "force_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_strict_sni": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "force_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "force_tlsv13": { + "description": "This field is deprecated in favor of tlsv13, and will be removed in a future release", + "type": "boolean", + "x-deprecated": true + }, + "generate_certificates": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "gid": { + "type": "integer", + "x-display-name": "Group ID" + }, + "group": { + "type": "string", + "x-display-name": "Group name" + }, + "guid_prefix": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "id": { + "type": "string", + "x-display-name": "Socket ID" + }, + "idle_ping": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "interface": { + "type": "string" + }, + "ktls": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-display-name": "Enables or disables ktls for those sockets. If enabled, kTLS will be used if the kernel supports it and the cipher is compatible.\nThis is only available on Linux kernel 4.17 and above.\nEXPERIMENTAL OPTION." + }, + "label": { + "type": "string" + }, + "level": { + "type": "string", + "enum": [ + "user", + "operator", + "admin" + ], + "example": "user" + }, + "maxconn": { + "type": "integer", + "example": 1234 + }, + "mode": { + "type": "string" + }, + "mss": { + "type": "string" + }, + "namespace": { + "type": "string", + "example": "app" + }, + "nbconn": { + "type": "integer", + "x-display-name": "Number of connection" + }, + "nice": { + "type": "integer", + "example": 1 + }, + "no_alpn": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "no_ca_names": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "no_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-deprecated": true + }, + "no_strict_sni": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Backend replaced", - "schema": { - "$ref": "#/definitions/backend" + "x-deprecated": true + }, + "no_tls_tickets": { + "description": "This field is deprecated in favor of tls_tickets, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/backend" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-deprecated": true + }, + "no_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-deprecated": true + }, + "no_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-deprecated": true + }, + "no_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-deprecated": true + }, + "no_tlsv13": { + "description": "This field is deprecated in favor of tlsv13, and will be removed in a future release", + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true } - } - } - }, - "delete": { - "description": "Deletes a frontend from the configuration by it's name.", - "tags": [ - "Backend", - "HAProxy configuration management" - ], - "summary": "Delete a backend", - "operationId": "deleteBackend", - "parameters": [ - { - "type": "string", - "description": "Backend name", - "name": "name", - "in": "path", - "required": true }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-deprecated": true + }, + "npn": { + "type": "string" + }, + "prefer_client_ciphers": { + "type": "boolean" + }, + "proto": { + "type": "string", + "x-display-name": "Protocol name" + }, + "quic-cc-algo": { + "type": "string", + "enum": [ + "cubic", + "newreno", + "bbr", + "nocc" + ] + }, + "quic-force-retry": { + "type": "boolean" + }, + "quic-socket": { + "type": "string", + "enum": [ + "connection", + "listener" + ] + }, + "quic_cc_algo_burst_size": { + "type": "integer", + "maximum": 1024, + "minimum": 0, + "x-dependency": { + "quic-cc-algo": null }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-nullable": true + }, + "quic_cc_algo_max_window": { + "type": "integer", + "maximum": 4194304, + "minimum": 10, + "x-default-unit": "k", + "x-dependency": { + "quic-cc-algo": null }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-nullable": true, + "x-size": true + }, + "severity_output": { + "type": "string", + "enum": [ + "none", + "number", + "string" + ], + "x-display-name": "Format", + "example": "none" + }, + "sigalgs": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true } - }, - "204": { - "description": "Backend deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "ssl": { + "type": "boolean" + }, + "ssl_cafile": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": true } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "SSL CA File" + }, + "ssl_certificate": { + "description": "All of the certificates delimited by ':' as mentioned as a crt on the bind line.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": true } } - } - } - }, - "/services/haproxy/configuration/binds": { - "get": { - "description": "Returns an array of all binds that are configured in specified frontend.", - "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" - ], - "summary": "Return an array of binds", - "operationId": "getBinds", - "parameters": [ - { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + }, + "ssl_max_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_min_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/binds" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "strict_sni": { + "type": "boolean", + "x-dependency": { + "ssl": { + "value": true } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-deprecated": true + }, + "tcp_md5sig": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "tcp_user_timeout": { + "type": "integer", + "x-nullable": true + }, + "tfo": { + "type": "boolean" + }, + "thread": { + "type": "string" + }, + "tls_ticket_keys": { + "type": "string" + }, + "tls_tickets": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true } } - } - }, - "post": { - "description": "Adds a new bind in the specified frontend in the configuration file.", - "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" - ], - "summary": "Add a new bind", - "operationId": "createBind", - "parameters": [ - { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/bind" + }, + "tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" } - ], - "responses": { - "201": { - "description": "Bind created", - "schema": { - "$ref": "#/definitions/bind" + }, + "tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/bind" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + } + }, + "tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": true } - }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "transparent": { + "type": "boolean" + }, + "uid": { + "type": "string" + }, + "user": { + "type": "string" + }, + "v4v6": { + "type": "boolean" + }, + "v6only": { + "type": "boolean" + }, + "verify": { + "type": "string", + "enum": [ + "none", + "optional", + "required" + ], + "x-dependency": { + "ssl": { + "value": "enabled" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "example": "none" + } + }, + "additionalProperties": false + }, + "binds": { + "description": "HAProxy frontend binds array (corresponds to bind directives)", + "type": "array", + "title": "Binds", + "items": { + "$ref": "#/definitions/bind" + } + }, + "cache": { + "description": "HAPRoxy Cache section", + "type": "object", + "title": "Cache", + "required": [ + "name" + ], + "properties": { + "max_age": { + "type": "integer", + "x-default-unit": "s", + "x-duration": false + }, + "max_object_size": { + "type": "integer", + "x-size": false + }, + "max_secondary_entries": { + "type": "integer" + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "process_vary": { + "type": "boolean", + "x-nullable": true + }, + "total_max_size": { + "type": "integer", + "maximum": 4095, + "minimum": 1 } } }, - "/services/haproxy/configuration/binds/{name}": { - "get": { - "description": "Returns one bind configuration by it's name in the specified frontend.", - "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" - ], - "summary": "Return one bind", - "operationId": "getBind", - "parameters": [ - { - "type": "string", - "description": "Bind name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "caches": { + "description": "HAProxy caches array", + "type": "array", + "title": "Cache Sections", + "items": { + "$ref": "#/definitions/cache" + } + }, + "capture": { + "type": "object", + "title": "Declare Capture", + "required": [ + "type", + "length" + ], + "properties": { + "length": { + "type": "integer", + "x-nullable": false + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/bind" - } - } + }, + "type": { + "type": "string", + "enum": [ + "request", + "response" + ], + "x-nullable": false + } + } + }, + "captures": { + "type": "array", + "title": "Declare capture array", + "items": { + "$ref": "#/definitions/capture" + } + }, + "cluster_settings": { + "description": "Settings related to a cluster.", + "type": "object", + "title": "Cluster Settings", + "properties": { + "bootstrap_key": { + "type": "string" + }, + "cluster": { + "type": "object", + "title": "Cluster controller information", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "readOnly": true }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "404": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" + "api_base_path": { + "type": "string", + "readOnly": true }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "cluster_id": { + "type": "string" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "description": { + "type": "string", + "readOnly": true + }, + "log_targets": { + "type": "array", + "items": { + "$ref": "#/definitions/ClusterSettingsClusterLogTargetsItems0" + }, + "x-go-name": "ClusterLogTargets", + "x-omitempty": true + }, + "name": { + "type": "string", + "readOnly": true + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "readOnly": true } } + }, + "mode": { + "type": "string", + "enum": [ + "single", + "cluster" + ] + }, + "status": { + "type": "string", + "enum": [ + "active", + "unreachable", + "waiting_approval" + ], + "readOnly": true } - }, - "put": { - "description": "Replaces a bind configuration by it's name in the specified frontend.", - "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" - ], - "summary": "Replace a bind", - "operationId": "replaceBind", - "parameters": [ - { + } + }, + "compression": { + "type": "object", + "properties": { + "algo-req": { + "type": "string", + "enum": [ + "identity", + "gzip", + "deflate", + "raw-deflate" + ], + "x-omitempty": true + }, + "algorithms": { + "type": "array", + "items": { "type": "string", - "description": "Bind name", - "name": "name", - "in": "path", - "required": true + "enum": [ + "identity", + "gzip", + "deflate", + "raw-deflate" + ] }, - { + "x-omitempty": true + }, + "algos-res": { + "type": "array", + "items": { "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true + "enum": [ + "identity", + "gzip", + "deflate", + "raw-deflate" + ] }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/bind" - } + "x-omitempty": true + }, + "direction": { + "type": "string", + "enum": [ + "request", + "response", + "both" + ], + "x-omitempty": true + }, + "minsize_req": { + "type": "integer", + "x-display-name": "Minimum Size for Requests", + "x-size": true + }, + "minsize_res": { + "type": "integer", + "x-display-name": "Minimum Size for Responses", + "x-size": true + }, + "offload": { + "type": "boolean" + }, + "types": { + "type": "array", + "items": { + "type": "string" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-omitempty": true + }, + "types-req": { + "type": "array", + "items": { + "type": "string" }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-omitempty": true + }, + "types-res": { + "type": "array", + "items": { + "type": "string" }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-omitempty": true + } + } + }, + "config_stick_table": { + "type": "object", + "properties": { + "expire": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "keylen": { + "type": "integer", + "x-display-name": "Key Length", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "200": { - "description": "Bind replaced", - "schema": { - "$ref": "#/definitions/bind" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/bind" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "nopurge": { + "type": "boolean", + "x-display-name": "No Purge" + }, + "peers": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "recv_only": { + "type": "boolean", + "x-display-name": "Receive Only" + }, + "size": { + "type": "integer", + "minimum": 0, + "x-nullable": true, + "x-size": true + }, + "srvkey": { + "type": "string", + "enum": [ + "addr", + "name" + ], + "x-nullable": true + }, + "store": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "type": { + "type": "string", + "enum": [ + "ip", + "ipv6", + "integer", + "string", + "binary" + ] + }, + "write_to": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true + } + } + }, + "consul": { + "description": "Consul server configuration", + "type": "object", + "title": "Consul server", + "required": [ + "address", + "port", + "enabled", + "retry_timeout" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "defaults": { + "description": "Name of the defaults section to be used in backends created by this service", + "type": "string" + }, + "description": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "health_check_policy": { + "description": "Defines the health check conditions required for each node to be considered valid for the service.\n none: all nodes are considered valid\n any: a node is considered valid if any one health check is 'passing'\n all: a node is considered valid if all health checks are 'passing'\n min: a node is considered valid if the number of 'passing' checks is greater or equal to the 'health_check_policy_min' value.\n If the node has less health checks configured then 'health_check_policy_min' it is considered invalid.", + "type": "string", + "default": "none", + "enum": [ + "none", + "any", + "all", + "min" + ] + }, + "health_check_policy_min": { + "type": "integer", + "x-dependency": { + "health_check_policy": { + "value": "min" } } - } - }, - "delete": { - "description": "Deletes a bind configuration by it's name in the specified frontend.", - "tags": [ - "Bind", - "HAProxy configuration management", - "Frontend options" - ], - "summary": "Delete a bind", - "operationId": "deleteBind", - "parameters": [ - { - "type": "string", - "description": "Bind name", - "name": "name", - "in": "path", - "required": true - }, - { + }, + "id": { + "description": "Auto generated ID.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true + }, + "mode": { + "type": "string", + "default": "http", + "enum": [ + "http", + "https" + ] + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "retry_timeout": { + "description": "Duration in seconds in-between data pulling requests to the consul server", + "type": "integer", + "minimum": 1 + }, + "server_slots_base": { + "type": "integer", + "default": 10 + }, + "server_slots_growth_increment": { + "type": "integer" + }, + "server_slots_growth_type": { + "type": "string", + "default": "exponential", + "enum": [ + "linear", + "exponential" + ] + }, + "service_allowlist": { + "type": "array", + "items": { "type": "string", - "description": "Parent frontend name", - "name": "frontend", - "in": "query", - "required": true + "pattern": "^[^\\s]+$" }, - { + "x-omitempty": true + }, + "service_denylist": { + "type": "array", + "items": { "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "pattern": "^[^\\s]+$" }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-omitempty": true + }, + "service_name_regexp": { + "description": "Regular expression used to filter services by name.", + "type": "string" + }, + "token": { + "type": "string", + "pattern": "^[^\\s]+$" + } + }, + "additionalProperties": false, + "example": { + "address": "127.0.0.1", + "enabled": true, + "id": "0", + "port": 90, + "retry_timeout": 10 + } + }, + "consuls": { + "description": "Consuls array", + "type": "array", + "title": "Consuls", + "items": { + "$ref": "#/definitions/consul" + } + }, + "cookie": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "attr": { + "type": "array", + "items": { + "$ref": "#/definitions/CookieAttrItems0" }, - "204": { - "description": "Bind deleted" + "x-go-name": "Attrs", + "x-omitempty": true + }, + "domain": { + "type": "array", + "items": { + "$ref": "#/definitions/CookieDomainItems0" }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-go-name": "Domains", + "x-omitempty": true + }, + "dynamic": { + "type": "boolean" + }, + "httponly": { + "type": "boolean" + }, + "indirect": { + "type": "boolean" + }, + "maxidle": { + "type": "integer" + }, + "maxlife": { + "type": "integer" + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "nocache": { + "type": "boolean" + }, + "postonly": { + "type": "boolean" + }, + "preserve": { + "type": "boolean" + }, + "secure": { + "type": "boolean" + }, + "type": { + "type": "string", + "enum": [ + "rewrite", + "insert", + "prefix" + ] + } + } + }, + "crt_load": { + "description": "Loads a certificate from a store with options", + "type": "object", + "title": "Certificate load action", + "required": [ + "certificate" + ], + "properties": { + "acme": { + "description": "ACME section name to use", + "type": "string" + }, + "alias": { + "description": "Certificate alias", + "type": "string" + }, + "certificate": { + "description": "Certificate filename", + "type": "string", + "x-nullable": false + }, + "domains": { + "description": "List of domains used to generate the certificate with ACME", + "type": "array", + "items": { + "type": "string" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-go-name": "Domains", + "x-omitempty": true + }, + "issuer": { + "description": "OCSP issuer filename", + "type": "string" + }, + "key": { + "description": "Private key filename", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "ocsp": { + "description": "OCSP response filename", + "type": "string" + }, + "ocsp_update": { + "description": "Automatic OCSP response update", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "sctl": { + "description": "Signed Certificate Timestamp List filename", + "type": "string" } } }, - "/services/haproxy/configuration/defaults": { - "get": { - "description": "Returns defaults part of configuration.", - "tags": [ - "Defaults", - "HAProxy configuration management" - ], - "summary": "Return defaults part of configuration", - "operationId": "getDefaults", - "parameters": [ - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/defaults" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "crt_loads": { + "description": "List of certificates to load from a Certificate Store", + "type": "array", + "items": { + "$ref": "#/definitions/crt_load" + }, + "x-omitempty": true + }, + "crt_store": { + "description": "Storage mechanism to load and store certificates used in the configuration", + "type": "object", + "title": "Certificate Store", + "required": [ + "name" + ], + "properties": { + "crt_base": { + "description": "Default directory to fetch SSL certificates from", + "type": "string" + }, + "key_base": { + "description": "Default directory to fetch SSL private keys from", + "type": "string" + }, + "loads": { + "$ref": "#/definitions/crt_loads" + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false } }, - "put": { - "description": "Replace defaults part of config", - "tags": [ - "Defaults", - "HAProxy configuration management" - ], - "summary": "Replace defaults", - "operationId": "replaceDefaults", - "parameters": [ - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/defaults" - } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Defaults replaced", - "schema": { - "$ref": "#/definitions/defaults" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/defaults" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "additionalProperties": false + }, + "crt_stores": { + "description": "List of Certificate Stores", + "type": "array", + "items": { + "$ref": "#/definitions/crt_store" + } + }, + "debug_options": { + "type": "object", + "properties": { + "anonkey": { + "type": "integer", + "maximum": 4294967295, + "minimum": 0, + "x-nullable": true + }, + "quiet": { + "type": "boolean" + }, + "stress_level": { + "type": "integer", + "maximum": 9, + "minimum": 0, + "x-nullable": true + }, + "zero_warning": { + "type": "boolean" + } + } + }, + "default_bind": { + "description": "HAProxy default bind configuration", + "title": "Default Bind", + "allOf": [ + { + "$ref": "#/definitions/bind_params" + }, + { + "type": "object", + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false } } } - } + ] }, - "/services/haproxy/configuration/filters": { - "get": { - "description": "Returns all Filters that are configured in specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" - ], - "summary": "Return an array of all Filters", - "operationId": "getFilters", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/filters" - } - } + "default_server": { + "title": "Default Server", + "allOf": [ + { + "$ref": "#/definitions/server_params" + } + ] + }, + "defaults": { + "description": "Defaults with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/defaults_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "http_after_response_rule_list": { + "x-go-name": "HTTPAfterResponseRuleList", + "$ref": "#/definitions/http_after_response_rules" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "http_check_list": { + "x-go-name": "HTTPCheckList", + "$ref": "#/definitions/http_checks" + }, + "http_error_rule_list": { + "x-go-name": "HTTPErrorRuleList", + "$ref": "#/definitions/http_error_rules" + }, + "http_request_rule_list": { + "x-go-name": "HTTPRequestRuleList", + "$ref": "#/definitions/http_request_rules" + }, + "http_response_rule_list": { + "x-go-name": "HTTPResponseRuleList", + "$ref": "#/definitions/http_response_rules" + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + }, + "quic_initial_rule_list": { + "x-go-name": "QUICInitialRuleList", + "$ref": "#/definitions/quic_initial_rules" + }, + "tcp_check_rule_list": { + "x-go-name": "TCPCheckRuleList", + "$ref": "#/definitions/tcp_checks" + }, + "tcp_request_rule_list": { + "x-go-name": "TCPRequestRuleList", + "$ref": "#/definitions/tcp_request_rules" + }, + "tcp_response_rule_list": { + "x-go-name": "TCPResponseRuleList", + "$ref": "#/definitions/tcp_response_rules" } } } - }, - "post": { - "description": "Adds a new Filter of the specified type in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" - ], - "summary": "Add a new Filter", - "operationId": "createFilter", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + ], + "x-go-name": "Defaults" + }, + "defaults_base": { + "description": "HAProxy defaults configuration", + "type": "object", + "title": "Defaults Base", + "required": [ + "name" + ], + "properties": { + "abortonclose": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "accept_invalid_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Request" + }, + "accept_invalid_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Response" + }, + "accept_unsafe_violations_in_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Request" + }, + "accept_unsafe_violations_in_http_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Response" + }, + "adv_check": { + "type": "string", + "enum": [ + "httpchk", + "ldap-check", + "mysql-check", + "pgsql-check", + "redis-check", + "smtpchk", + "ssl-hello-chk", + "tcp-check" + ], + "x-display-name": "Advanced Check" + }, + "allbackups": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "All Backups" + }, + "backlog": { + "type": "integer", + "x-display-name": "Backlog", + "x-nullable": true + }, + "balance": { + "$ref": "#/definitions/balance" + }, + "check_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "checkcache": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Checkcache" + }, + "clflog": { + "type": "boolean", + "x-display-name": "CLF Log" + }, + "client_fin_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "client_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "clitcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Client TCP Keep Alive" + }, + "clitcpka_cnt": { + "type": "integer", + "x-display-name": "Clitcpka Cnt", + "x-nullable": true + }, + "clitcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "clitcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "compression": { + "$ref": "#/definitions/compression" + }, + "connect_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "contstats": { + "type": "string", + "enum": [ + "enabled" + ], + "x-display-name": "Continuous Statistics" + }, + "cookie": { + "$ref": "#/definitions/cookie" + }, + "default_backend": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-dynamic-enum": { + "operation": "getBackends", + "property": "name" + } + }, + "default_server": { + "$ref": "#/definitions/default_server" + }, + "disable_h2_upgrade": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Disable HTTP/2 Upgrade" + }, + "disabled": { + "type": "boolean" + }, + "dontlog_normal": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Dontlog Normal" + }, + "dontlognull": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Don't Log Null" + }, + "dynamic_cookie_key": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "email_alert": { + "$ref": "#/definitions/email_alert" + }, + "enabled": { + "type": "boolean" + }, + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-go-name": "ErrorFiles", + "x-omitempty": true + }, + "error_log_format": { + "type": "string" + }, + "errorfiles_from_http_errors": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfiles" }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/filter" + "x-go-name": "ErrorFilesFromHTTPErrors", + "x-omitempty": true + }, + "errorloc302": { + "$ref": "#/definitions/errorloc" + }, + "errorloc303": { + "$ref": "#/definitions/errorloc" + }, + "external_check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "External Check" + }, + "external_check_command": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Command" + }, + "external_check_path": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "External Check Path" + }, + "forwardfor": { + "$ref": "#/definitions/forwardfor" + }, + "from": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "fullconn": { + "type": "integer", + "x-nullable": true + }, + "h1_case_adjust_bogus_client": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "H1 Adjust Bogus Client" + }, + "h1_case_adjust_bogus_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "H1 Adjust Bogus Server" + }, + "hash_balance_factor": { + "type": "integer", + "x-nullable": true + }, + "hash_preserve_affinity": { + "type": "string", + "enum": [ + "always", + "maxconn", + "maxqueue" + ] + }, + "hash_type": { + "$ref": "#/definitions/hash_type" + }, + "http-buffer-request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP bufferrequest" + }, + "http-drop-request-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Request Trailers" + }, + "http-drop-response-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Response Trailers" + }, + "http-use-htx": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Use HTX" + }, + "http_connection_mode": { + "type": "string", + "enum": [ + "httpclose", + "http-server-close", + "http-keep-alive" + ] + }, + "http_ignore_probes": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Ignore Probes" + }, + "http_keep_alive_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "http_no_delay": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP No Delay" + }, + "http_pretend_keepalive": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "http_request_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "http_restrict_req_hdr_names": { + "type": "string", + "enum": [ + "preserve", + "delete", + "reject" + ], + "x-display-name": "Restrict HTTP Request Header Names" + }, + "http_reuse": { + "type": "string", + "enum": [ + "aggressive", + "always", + "never", + "safe" + ] + }, + "http_send_name_header": { + "type": "string", + "x-display-name": "Add the server name to a request", + "x-nullable": true + }, + "http_use_proxy_header": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Use Proxy Header" + }, + "httpchk_params": { + "x-dependency": { + "adv_check": { + "value": "httpchk" } }, - { + "$ref": "#/definitions/httpchk_params" + }, + "httplog": { + "type": "boolean", + "x-display-name": "HTTP Log" + }, + "httpslog": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Httpslog" + }, + "idle_close_on_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Idle Close On Response" + }, + "independent_streams": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Independent Streams" + }, + "load_server_state_from_file": { + "type": "string", + "enum": [ + "global", + "local", + "none" + ] + }, + "log_format": { + "type": "string" + }, + "log_format_sd": { + "type": "string", + "x-display-name": "Log Format SD" + }, + "log_health_checks": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log Health Checks" + }, + "log_separate_errors": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "log_steps": { + "type": "array", + "items": { "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "enum": [ + "accept", + "request", + "connect", + "response", + "close", + "error", + "any" + ] + }, + "x-go-name": "LogSteps", + "x-omitempty": true + }, + "log_tag": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "logasap": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log ASAP" + }, + "max_keep_alive_queue": { + "type": "integer", + "x-display-name": "Maximum server queue size for maintaining keep-alive connections", + "x-nullable": true + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "201": { - "description": "Filter created", - "schema": { - "$ref": "#/definitions/filter" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/filter" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "mode": { + "type": "string", + "enum": [ + "tcp", + "http", + "log" + ] + }, + "monitor_uri": { + "$ref": "#/definitions/monitor_uri" + }, + "mysql_check_params": { + "x-dependency": { + "adv_check": { + "value": "mysql-check" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/mysql_check_params" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "nolinger": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Nolinger" + }, + "originalto": { + "$ref": "#/definitions/originalto" + }, + "persist": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Persist" + }, + "persist_rule": { + "$ref": "#/definitions/persist_rule" + }, + "pgsql_check_params": { + "x-dependency": { + "adv_check": { + "value": "pgsql-check" } }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "$ref": "#/definitions/pgsql_check_params" + }, + "prefer_last_server": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Prefer Last Server" + }, + "queue_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "redispatch": { + "$ref": "#/definitions/redispatch" + }, + "retries": { + "type": "integer", + "x-nullable": true + }, + "retry_on": { + "type": "string", + "x-display-name": "Specify when to attempt to automatically retry a failed request" + }, + "server_fin_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "server_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "smtpchk_params": { + "x-dependency": { + "adv_check": { + "value": "smtpchk" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "$ref": "#/definitions/smtpchk_params" + }, + "socket_stats": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Socket Stats" + }, + "source": { + "$ref": "#/definitions/source" + }, + "splice_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Auto" + }, + "splice_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Request" + }, + "splice_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Response" + }, + "srvtcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Server TCP Keep Alive" + }, + "srvtcpka_cnt": { + "type": "integer", + "x-display-name": "Srvtcpka Cnt", + "x-nullable": true + }, + "srvtcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "srvtcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Srvtcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "stats_options": { + "$ref": "#/definitions/stats_options" + }, + "tarpit_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "tcp_smart_accept": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Accept" + }, + "tcp_smart_connect": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Connect" + }, + "tcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "TCP Keep Alive" + }, + "tcplog": { + "type": "boolean", + "x-display-name": "TCP Log" + }, + "transparent": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Transparent" + }, + "tunnel_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "unique_id_format": { + "type": "string", + "x-display-name": "Unique ID format" + }, + "unique_id_header": { + "type": "string", + "x-display-name": "Unique ID header" + } + }, + "additionalProperties": false + }, + "defaults_sections": { + "description": "HAProxy defaults sections array", + "type": "array", + "title": "Defaults Sections", + "items": { + "$ref": "#/definitions/defaults" + } + }, + "device_atlas_options": { + "type": "object", + "properties": { + "json_file": { + "type": "string", + "x-display-name": "JSON file" + }, + "log_level": { + "type": "string", + "x-display-name": "Log Level" + }, + "properties_cookie": { + "type": "string", + "x-display-name": "Properties Cookie" + }, + "separator": { + "type": "string", + "x-display-name": "Separator" + } + } + }, + "dgram_bind": { + "description": "HAProxy log forward dgram bind configuration", + "type": "object", + "title": "Dgram Bind", + "required": [ + "name" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "interface": { + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "namespace": { + "type": "string" + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "port-range-end": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "transparent": { + "type": "boolean" } } }, - "/services/haproxy/configuration/filters/{id}": { - "get": { - "description": "Returns one Filter configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" - ], - "summary": "Return one Filter", - "operationId": "getFilter", - "parameters": [ - { - "type": "integer", - "description": "Filter ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "dgram_binds": { + "description": "HAProxy dgram bind array", + "type": "array", + "title": "Dgram Bind", + "items": { + "$ref": "#/definitions/dgram_bind" + } + }, + "email_alert": { + "description": "Send emails for important log messages.", + "type": "object", + "title": "Email Alert", + "required": [ + "from", + "mailers", + "to" + ], + "properties": { + "from": { + "type": "string", + "pattern": "^\\S+@\\S+$" + }, + "level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug" + ] + }, + "mailers": { + "type": "string", + "x-dynamic-enum": { + "operation": "getMailersSections", + "property": "name" } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/filter" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "myhostname": { + "type": "string" + }, + "to": { + "type": "string", + "pattern": "^\\S+@\\S+$" + } + } + }, + "email_alerts": { + "description": "Email Alerts array (corresponds to email-alert directives)", + "type": "array", + "title": "Email Alerts Array", + "items": { + "$ref": "#/definitions/email_alert" + } + }, + "endpoint": { + "description": "Endpoint definition", + "type": "object", + "title": "Endpoint", + "properties": { + "description": { + "description": "Endpoint description", + "type": "string" + }, + "title": { + "description": "Endpoint title", + "type": "string" + }, + "url": { + "description": "Path to the endpoint", + "type": "string" + } + } + }, + "endpoints": { + "description": "Collection of endpoints", + "type": "array", + "title": "Endpoints Array", + "items": { + "$ref": "#/definitions/endpoint" + } + }, + "environment_options": { + "type": "object", + "properties": { + "presetenv": { + "type": "array", + "items": { + "$ref": "#/definitions/EnvironmentOptionsPresetenvItems0" }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-display-name": "Preset environment variables", + "x-go-name": "PresetEnvs", + "x-omitempty": true + }, + "resetenv": { + "type": "string", + "x-display-name": "Remove all environment variables except the ones specified" + }, + "setenv": { + "type": "array", + "items": { + "$ref": "#/definitions/EnvironmentOptionsSetenvItems0" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "x-display-name": "Set environment variables", + "x-go-name": "SetEnvs", + "x-omitempty": true + }, + "unsetenv": { + "type": "string", + "x-display-name": "Removes environment variables specified in arguments" + } + } + }, + "error": { + "description": "API Error", + "type": "object", + "title": "Error", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "x-nullable": true + }, + "message": { + "type": "string", + "x-nullable": true + } + }, + "additionalProperties": { + "type": "string" + } + }, + "errorfile": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "enum": [ + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ] + }, + "file": { + "type": "string" } }, - "put": { - "description": "Replaces a Filter configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" - ], - "summary": "Replace a Filter", - "operationId": "replaceFilter", - "parameters": [ - { + "x-display-name": "Error File" + }, + "errorfiles": { + "type": "object", + "properties": { + "codes": { + "type": "array", + "items": { "type": "integer", - "description": "Filter ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/filter" + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ] + }, + "x-omitempty": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string" + } + } + }, + "errorloc": { + "type": "object", + "required": [ + "url", + "code" + ], + "properties": { + "code": { + "type": "integer", + "enum": [ + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ] + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "url": { + "type": "string" + } + } + }, + "fcgi_app": { + "description": "App with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/fcgi_app_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" } + } + } + ], + "x-go-name": "FCGIApp" + }, + "fcgi_app_base": { + "description": "HAProxy FastCGI application configuration", + "type": "object", + "title": "FCGI application base", + "required": [ + "name", + "docroot" + ], + "properties": { + "docroot": { + "description": "Defines the document root on the remote host. The parameter serves to build the default value of FastCGI parameters SCRIPT_FILENAME and PATH_TRANSLATED. It is a mandatory setting.", + "type": "string" + }, + "get_values": { + "description": "Enables or disables the retrieval of variables related to connection management.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "index": { + "description": "Defines the script name to append after a URI that ends with a slash (\"/\") to set the default value for the FastCGI parameter SCRIPT_NAME. It is an optional setting.", + "type": "string" + }, + "keep_conn": { + "description": "Tells the FastCGI application whether or not to keep the connection open after it sends a response. If disabled, the FastCGI application closes the connection after responding to this request.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "log_stderrs": { + "type": "array", + "items": { + "x-go-name": "FCGIAppLogStderr", + "$ref": "#/definitions/fcgi_log_stderr" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-omitempty": true + }, + "max_reqs": { + "description": "Defines the maximum number of concurrent requests this application can accept. If the FastCGI application retrieves the variable FCGI_MAX_REQS during connection establishment, it can override this option. Furthermore, if the application does not do multiplexing, it will ignore this option.", + "type": "integer", + "default": 1, + "minimum": 1 + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "200": { - "description": "Filter replaced", - "schema": { - "$ref": "#/definitions/filter" - } + }, + "mpxs_conns": { + "description": "Enables or disables the support of connection multiplexing. If the FastCGI application retrieves the variable FCGI_MPXS_CONNS during connection establishment, it can override this option.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "name": { + "description": "Declares a FastCGI application", + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "pass_headers": { + "type": "array", + "items": { + "x-go-name": "FCGIAppLogPassHeader", + "$ref": "#/definitions/fcgi_pass_header" }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/filter" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-omitempty": true + }, + "path_info": { + "description": "Defines a regular expression to extract the script-name and the path-info from the URI.\nThus, \u003cregex\u003e must have two captures: the first to capture the script name, and the second to capture the path- info.\nIf not defined, it does not perform matching on the URI, and does not fill the FastCGI parameters PATH_INFO and PATH_TRANSLATED.", + "type": "string" + }, + "set_params": { + "type": "array", + "items": { + "$ref": "#/definitions/fcgi_set_param" }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-omitempty": true + } + } + }, + "fcgi_apps": { + "type": "array", + "items": { + "$ref": "#/definitions/fcgi_app" + } + }, + "fcgi_log_stderr": { + "description": "Enables logging of STDERR messages that the FastCGI application reports.\nIt is an optional setting. By default, HAProxy Enterprise ignores STDERR messages.", + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "facility": { + "type": "string", + "title": "Facility" + }, + "format": { + "type": "string", + "title": "Format" + }, + "global": { + "type": "boolean", + "title": "Global" + }, + "len": { + "type": "integer", + "title": "Length" + }, + "level": { + "type": "string", + "title": "Level", + "x-dependency": { + "facility": { + "required": true } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "minlevel": { + "type": "string", + "title": "Minimum level", + "x-dependency": { + "facility": { + "required": true } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + } + }, + "sample": { + "type": "object", + "title": "Sample", + "required": [ + "ranges", + "size" + ], + "properties": { + "ranges": { + "type": "string", + "title": "Range" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "size": { + "type": "integer", + "title": "Size" } } } - }, - "delete": { - "description": "Deletes a Filter configuration by it's ID from the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "Filter" - ], - "summary": "Delete a Filter", - "operationId": "deleteFilter", - "parameters": [ - { - "type": "integer", - "description": "Filter ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + } + }, + "fcgi_pass_header": { + "description": "Specifies the name of a request header to pass to the FastCGI application.\nOptionally, you can follow it with an ACL-based condition, in which case the FastCGI application evaluates it only if the condition is true.\nMost request headers are already available to the FastCGI application with the prefix \"HTTP\".\nThus, you only need this directive to pass headers that are purposefully omitted.\nCurrently, the headers \"Authorization\", \"Proxy-Authorization\", and hop-by-hop headers are omitted.\nNote that the headers \"Content-type\" and \"Content-length\" never pass to the FastCGI application because they are already converted into parameters.", + "type": "object", + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true } }, - "204": { - "description": "Filter deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Condition Test" + }, + "name": { + "type": "string" + } + } + }, + "fcgi_set_param": { + "description": "Sets a FastCGI parameter to pass to this application.\nIts value, defined by \u003cformat\u003e can take a formatted string, the same as the log directive.\nOptionally, you can follow it with an ACL-based condition, in which case the FastCGI application evaluates it only if the condition is true.", + "type": "object", + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "x-display-name": "Condition Test" + }, + "format": { + "type": "string" + }, + "name": { + "type": "string" } } }, - "/services/haproxy/configuration/frontends": { - "get": { - "description": "Returns an array of all configured frontends.", - "tags": [ - "Frontend", - "HAProxy configuration management" - ], - "summary": "Return an array of frontends", - "operationId": "getFrontends", - "parameters": [ - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/frontends" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "fifty_one_degrees_options": { + "type": "object", + "properties": { + "cache_size": { + "type": "integer", + "x-display-name": "Cache Size" + }, + "data_file": { + "type": "string", + "x-display-name": "Data File" + }, + "property_name_list": { + "type": "string", + "x-display-name": "Name List" + }, + "property_separator": { + "type": "string", + "x-display-name": "Property Separator" + } + } + }, + "filter": { + "description": "HAProxy filters", + "type": "object", + "title": "Filter", + "required": [ + "type" + ], + "properties": { + "app_name": { + "description": "Name of the fcgi-app section this filter will use.", + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "fcgi-app" } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "bandwidth_limit_name": { + "description": "Filter name that will be used by 'set-bandwidth-limit' actions to reference a specific bandwidth limitation filter", + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] } } - } - }, - "post": { - "description": "Adds a new frontend to the configuration file.", - "tags": [ - "Frontend", - "HAProxy configuration management" - ], - "summary": "Add a frontend", - "operationId": "createFrontend", - "parameters": [ - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/frontend" + }, + "cache_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "cache" } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" } - ], - "responses": { - "201": { - "description": "Frontend created", - "schema": { - "$ref": "#/definitions/frontend" + }, + "default_limit": { + "description": "The max number of bytes that can be forwarded over the period.\nThe value must be specified for per-stream and shared bandwidth limitation filters.\nIt follows the HAProxy size format and is expressed in bytes.", + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/frontend" + "x-size": true + }, + "default_period": { + "description": "The default time period used to evaluate the bandwidth limitation rate.\nIt can be specified for per-stream bandwidth limitation filters only.\nIt follows the HAProxy time format and is expressed in milliseconds.", + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "default_limit": { + "required": true }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" + "x-duration": true + }, + "key": { + "description": "A sample expression rule.\nIt describes what elements will be analyzed, extracted, combined, and used to select which table entry to update the counters.\nIt must be specified for shared bandwidth limitation filters only.", + "type": "string", + "x-dependency": { + "limit": { + "required": true }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + } + }, + "limit": { + "description": "The max number of bytes that can be forwarded over the period.\nThe value must be specified for per-stream and shared bandwidth limitation filters.\nIt follows the HAProxy size format and is expressed in bytes.", + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] } }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-size": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "min_size": { + "description": "The optional minimum number of bytes forwarded at a time by a stream excluding the last packet that may be smaller.\nThis value can be specified for per-stream and shared bandwidth limitation filters.\nIt follows the HAProxy size format and is expressed in bytes.", + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-size": true + }, + "spoe_config": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "spoe" } } - } - } - }, - "/services/haproxy/configuration/frontends/{name}": { - "get": { - "description": "Returns one frontend configuration by it's name.", - "tags": [ - "Frontend", - "HAProxy configuration management" - ], - "summary": "Return a frontend", - "operationId": "getFrontend", - "parameters": [ - { - "type": "string", - "description": "Frontend name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "spoe" + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/frontend" - } - } + }, + "table": { + "description": "An optional table to be used instead of the default one, which is the stick-table declared in the current proxy.\nIt can be specified for shared bandwidth limitation filters only.", + "type": "string", + "x-dependency": { + "limit": { + "required": true }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "type": { + "required": true, + "value": [ + "bwlim-in", + "bwlim-out" + ] + } + } + }, + "trace_hexdump": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "trace" + } + } + }, + "trace_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "trace" + } + } + }, + "trace_rnd_forwarding": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "trace" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Trace Random Forwarding" + }, + "trace_rnd_parsing": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "trace" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "x-display-name": "Trace Random Parsing" + }, + "type": { + "type": "string", + "enum": [ + "bwlim-in", + "bwlim-out", + "cache", + "compression", + "fcgi-app", + "spoe", + "trace" + ], + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "trace_name": "name", + "trace_rnd_parsing": true, + "type": "trace" + } + }, + "filters": { + "description": "HAProxy filters array (corresponds to filter directive)", + "type": "array", + "title": "Filters Array", + "items": { + "$ref": "#/definitions/filter" + } + }, + "forwardfor": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled" + ] + }, + "except": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "header": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "ifnone": { + "type": "boolean" + } + }, + "x-display-name": "ForwardFor" + }, + "frontend": { + "description": "Frontend with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/frontend_base" + }, + { + "type": "object", + "properties": { + "acl_list": { + "x-go-name": "AclList", + "$ref": "#/definitions/acls" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "backend_switching_rule_list": { + "x-go-name": "BackendSwitchingRuleList", + "$ref": "#/definitions/backend_switching_rules" + }, + "binds": { + "additionalProperties": { + "$ref": "#/definitions/bind" } + }, + "capture_list": { + "x-go-name": "CaptureList", + "$ref": "#/definitions/captures" + }, + "filter_list": { + "x-go-name": "FilterList", + "$ref": "#/definitions/filters" + }, + "http_after_response_rule_list": { + "x-go-name": "HTTPAfterResponseRuleList", + "$ref": "#/definitions/http_after_response_rules" + }, + "http_error_rule_list": { + "x-go-name": "HTTPErrorRuleList", + "$ref": "#/definitions/http_error_rules" + }, + "http_request_rule_list": { + "x-go-name": "HTTPRequestRuleList", + "$ref": "#/definitions/http_request_rules" + }, + "http_response_rule_list": { + "x-go-name": "HTTPResponseRuleList", + "$ref": "#/definitions/http_response_rules" + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" + }, + "quic_initial_rule_list": { + "x-go-name": "QUICInitialRuleList", + "$ref": "#/definitions/quic_initial_rules" + }, + "ssl_front_use_list": { + "x-go-name": "SSLFrontUses", + "$ref": "#/definitions/ssl_front_uses" + }, + "tcp_request_rule_list": { + "x-go-name": "TCPRequestRuleList", + "$ref": "#/definitions/tcp_request_rules" } } } - }, - "put": { - "description": "Replaces a frontend configuration by it's name.", - "tags": [ - "Frontend", - "HAProxy configuration management" - ], - "summary": "Replace a frontend", - "operationId": "replaceFrontend", - "parameters": [ - { - "type": "string", - "description": "Frontend name", - "name": "name", - "in": "path", - "required": true + ], + "x-go-name": "Frontend" + }, + "frontend_base": { + "description": "HAProxy frontend configuration", + "type": "object", + "title": "Frontend Base", + "required": [ + "name" + ], + "properties": { + "abortonclose": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "accept_invalid_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Invalid HTTP Request" + }, + "accept_unsafe_violations_in_http_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Accept Unsafe Violations in HTTP Request" + }, + "backlog": { + "type": "integer", + "x-display-name": "Backlog", + "x-nullable": true + }, + "clflog": { + "type": "boolean", + "x-dependency": { + "mode": { + "value": "http" + } }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/frontend" + "x-display-name": "CLF Log" + }, + "client_fin_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "client_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "clitcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "Client TCP Keep Alive" + }, + "clitcpka_cnt": { + "type": "integer", + "x-display-name": "Clitcpka Cnt", + "x-nullable": true + }, + "clitcpka_idle": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Idle", + "x-duration": true, + "x-nullable": true + }, + "clitcpka_intvl": { + "type": "integer", + "x-default-unit": "s", + "x-display-name": "Clitcpka Intvl", + "x-duration": true, + "x-nullable": true + }, + "compression": { + "$ref": "#/definitions/compression" + }, + "contstats": { + "type": "string", + "enum": [ + "enabled" + ], + "x-display-name": "Continuous Statistics" + }, + "default_backend": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-dynamic-enum": { + "operation": "getBackends", + "property": "name" + } + }, + "description": { + "type": "string", + "x-display-name": "Description" + }, + "disable_h2_upgrade": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Disable HTTP/2 Upgrade" + }, + "disabled": { + "type": "boolean" + }, + "dontlog_normal": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "dontlognull": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Don't Log Null" + }, + "email_alert": { + "$ref": "#/definitions/email_alert" + }, + "enabled": { + "type": "boolean" + }, + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-go-name": "ErrorFiles", + "x-omitempty": true + }, + "error_log_format": { + "type": "string" + }, + "errorfiles_from_http_errors": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfiles" }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Frontend replaced", - "schema": { - "$ref": "#/definitions/frontend" + "x-go-name": "ErrorFilesFromHTTPErrors", + "x-omitempty": true + }, + "errorloc302": { + "$ref": "#/definitions/errorloc" + }, + "errorloc303": { + "$ref": "#/definitions/errorloc" + }, + "forwardfor": { + "x-dependency": { + "mode": { + "value": "http" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/frontend" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "$ref": "#/definitions/forwardfor" + }, + "from": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "guid": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "h1_case_adjust_bogus_client": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "H1 Adjust Bogus Client" + }, + "http-buffer-request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP bufferrequest" + }, + "http-drop-response-trailers": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Drop HTTP Response Trailers" + }, + "http-use-htx": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "http" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "HTTP Use HTX" + }, + "http_connection_mode": { + "type": "string", + "enum": [ + "httpclose", + "http-server-close", + "http-keep-alive" + ], + "x-dependency": { + "mode": { + "value": "http" + } + } + }, + "http_ignore_probes": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Ignore Probes" + }, + "http_keep_alive_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-duration": true, + "x-nullable": true + }, + "http_no_delay": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP No Delay" + }, + "http_request_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-dependency": { + "mode": { + "value": "http" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-duration": true, + "x-nullable": true + }, + "http_restrict_req_hdr_names": { + "type": "string", + "enum": [ + "preserve", + "delete", + "reject" + ], + "x-display-name": "Restrict HTTP Request Header Names" + }, + "http_use_proxy_header": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Use Proxy Header" + }, + "httplog": { + "type": "boolean", + "x-dependency": { + "mode": { + "value": "http" } - } - } - }, - "delete": { - "description": "Deletes a frontend from the configuration by it's name.", - "tags": [ - "Frontend", - "HAProxy configuration management" - ], - "summary": "Delete a frontend", - "operationId": "deleteFrontend", - "parameters": [ - { - "type": "string", - "description": "Frontend name", - "name": "name", - "in": "path", - "required": true }, - { + "x-display-name": "HTTP Log" + }, + "httpslog": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Httpslog" + }, + "id": { + "type": "integer", + "x-nullable": true + }, + "idle_close_on_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Idle Close On Response" + }, + "independent_streams": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Independent Streams" + }, + "log_format": { + "type": "string" + }, + "log_format_sd": { + "type": "string", + "x-display-name": "Log Format SD" + }, + "log_separate_errors": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "log_steps": { + "type": "array", + "items": { "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "enum": [ + "accept", + "request", + "connect", + "response", + "close", + "error", + "any" + ] + }, + "x-go-name": "LogSteps", + "x-omitempty": true + }, + "log_tag": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "logasap": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Log ASAP" + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp" + ] + }, + "monitor_fail": { + "$ref": "#/definitions/monitor_fail" + }, + "monitor_uri": { + "$ref": "#/definitions/monitor_uri" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "nolinger": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Nolinger" + }, + "originalto": { + "$ref": "#/definitions/originalto" + }, + "socket_stats": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Socket Stats" + }, + "splice_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Auto" + }, + "splice_request": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Request" + }, + "splice_response": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Splice Response" + }, + "stats_options": { + "$ref": "#/definitions/stats_options" + }, + "stick_table": { + "$ref": "#/definitions/config_stick_table" + }, + "tarpit_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "tcp_smart_accept": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Tcp Smart Accept" + }, + "tcpka": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "mode": { + "value": "tcp" } }, - "204": { - "description": "Frontend deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "TCP Keep Alive" + }, + "tcplog": { + "type": "boolean", + "x-dependency": { + "mode": { + "value": "tcp" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "x-display-name": "TCP Log" + }, + "unique_id_format": { + "type": "string", + "x-display-name": "Unique ID format" + }, + "unique_id_header": { + "type": "string", + "x-display-name": "Unique ID header" + } + }, + "additionalProperties": false, + "example": { + "default_backend": "test_backend", + "http_connection_mode": "http-keep-alive", + "maxconn": 2000, + "mode": "http", + "name": "test_frontend" + } + }, + "frontends": { + "description": "HAProxy frontends array", + "type": "array", + "title": "Frontends", + "items": { + "$ref": "#/definitions/frontend" + } + }, + "general_file": { + "description": "General use file", + "type": "object", + "title": "General use file", + "properties": { + "description": { + "type": "string" + }, + "file": { + "type": "string" + }, + "id": { + "type": "string" + }, + "size": { + "description": "File size in bytes.", + "type": "integer", + "x-nullable": true + }, + "storage_name": { + "type": "string" } } }, - "/services/haproxy/configuration/global": { - "get": { - "description": "Returns global part of configuration.", - "tags": [ - "Global", - "HAProxy configuration management" - ], - "summary": "Return a global part of configuration", - "operationId": "getGlobal", - "parameters": [ - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/global" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "general_files": { + "description": "Array of general use files", + "type": "array", + "title": "General Files Array", + "items": { + "$ref": "#/definitions/general_file" + } + }, + "global": { + "description": "Frontend with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/global_base" + }, + { + "type": "object", + "properties": { + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" } } } - }, - "put": { - "description": "Replace global part of config", - "tags": [ - "Global", - "HAProxy configuration management" - ], - "summary": "Replace global", - "operationId": "replaceGlobal", - "parameters": [ - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/global" - } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Global replaced", - "schema": { - "$ref": "#/definitions/global" - } + ], + "x-go-name": "Global" + }, + "global_base": { + "description": "HAProxy global configuration", + "type": "object", + "title": "Global Base", + "properties": { + "chroot": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Chroot" + }, + "close_spread_time": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "cluster_secret": { + "type": "string", + "x-display-name": "Cluster Secret" + }, + "cpu_maps": { + "type": "array", + "items": { + "$ref": "#/definitions/GlobalBaseCPUMapsItems0" }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/global" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-display-name": "CPU Maps", + "x-go-name": "CPUMaps", + "x-omitempty": true + }, + "cpu_policy": { + "type": "string", + "enum": [ + "none", + "efficiency", + "first-usable-node", + "group-by-2-ccx", + "group-by-2-clusters", + "group-by-3-ccx", + "group-by-3-clusters", + "group-by-4-ccx", + "group-by-4-cluster", + "group-by-ccx", + "group-by-cluster", + "performance", + "resource" + ], + "x-display-name": "CPU Policy" + }, + "cpu_set": { + "type": "array", + "items": { + "$ref": "#/definitions/GlobalBaseCPUSetItems0" }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "x-display-name": "CPU Set", + "x-go-name": "CPUSets", + "x-omitempty": true + }, + "daemon": { + "type": "boolean" + }, + "debug_options": { + "$ref": "#/definitions/debug_options" + }, + "default_path": { + "type": "object", + "required": [ + "type" + ], + "properties": { + "path": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "origin" + } } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "type": { + "type": "string", + "enum": [ + "current", + "config", + "parent", + "origin" + ], + "x-nullable": false } - } - } - } - }, - "/services/haproxy/configuration/http_request_rules": { - "get": { - "description": "Returns all HTTP Request Rules that are configured in specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" - ], - "summary": "Return an array of all HTTP Request Rules", - "operationId": "getHTTPRequestRules", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-go-name": "GlobalDefaultPath" + }, + "description": { + "type": "string", + "x-display-name": "Text that describes the instance" + }, + "device_atlas_options": { + "$ref": "#/definitions/device_atlas_options" + }, + "dns_accept_family": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "DNS accept family" + }, + "environment_options": { + "$ref": "#/definitions/environment_options" + }, + "expose_deprecated_directives": { + "type": "boolean" + }, + "expose_experimental_directives": { + "type": "boolean" + }, + "external_check": { + "type": "boolean", + "x-display-name": "External Check" + }, + "fifty_one_degrees_options": { + "$ref": "#/definitions/fifty_one_degrees_options" + }, + "force_cfg_parser_pause": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Pause the configuration parser to simulate long reloads", + "x-duration": true, + "x-nullable": true + }, + "gid": { + "type": "integer", + "x-display-name": "GID" + }, + "grace": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Defines a delay between SIGUSR1 and real soft-stop", + "x-duration": true, + "x-nullable": true + }, + "group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Group" + }, + "h1_accept_payload_with_any_method": { + "type": "boolean" + }, + "h1_case_adjust": { + "type": "array", + "items": { + "$ref": "#/definitions/GlobalBaseH1CaseAdjustItems0" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { + "x-go-name": "H1CaseAdjusts", + "x-omitempty": true + }, + "h1_case_adjust_file": { + "type": "string" + }, + "h1_do_not_close_on_insecure_transfer_encoding": { + "type": "boolean" + }, + "h2_workaround_bogus_websocket_clients": { + "type": "boolean" + }, + "hard_stop_after": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Hard Stop After", + "x-duration": true, + "x-nullable": true + }, + "harden": { + "type": "object", + "properties": { + "reject_privileged_ports": { "type": "object", - "required": [ - "data" - ], "properties": { - "_version": { - "type": "integer" + "quic": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] }, - "data": { - "$ref": "#/definitions/http_request_rules" + "tcp": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "x-go-name": "GlobalHardenRejectPrivilegedPorts" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } - }, - "post": { - "description": "Adds a new HTTP Request Rule of the specified type in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" - ], - "summary": "Add a new HTTP Request Rule", - "operationId": "createHTTPRequestRule", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "x-go-name": "GlobalHarden" + }, + "http_client_options": { + "$ref": "#/definitions/http_client_options" + }, + "http_err_codes": { + "type": "array", + "items": { + "$ref": "#/definitions/http_codes" }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-display-name": "Replace, reduce or extend the list of status codes that define an error", + "x-omitempty": true + }, + "http_fail_codes": { + "type": "array", + "items": { + "$ref": "#/definitions/http_codes" }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/http_request_rule" + "x-display-name": "Replace, reduce or extend the list of status codes that define a failure", + "x-omitempty": true + }, + "insecure_fork_wanted": { + "type": "boolean" + }, + "insecure_setuid_wanted": { + "type": "boolean" + }, + "limited_quic": { + "type": "boolean" + }, + "localpeer": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Local instance's peer name." + }, + "log_send_hostname": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "param": { + "type": "string", + "pattern": "^[^\\s]+$" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-display-name": "Log Send Hostname", + "x-go-name": "GlobalLogSendHostname" + }, + "lua_options": { + "$ref": "#/definitions/lua_options" + }, + "master-worker": { + "type": "boolean", + "x-display-name": "Master Worker Mode" + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "201": { - "description": "HTTP Request Rule created", - "schema": { - "$ref": "#/definitions/http_request_rule" - } + }, + "mworker_max_reloads": { + "type": "integer", + "minimum": 0, + "x-display-name": "The number of times a worker can survive a reload", + "x-nullable": true + }, + "nbthread": { + "type": "integer", + "x-display-name": "Number of Threads" + }, + "no_quic": { + "type": "boolean", + "x-display-name": "Disable the use of the QUIC protocol" + }, + "node": { + "type": "string" + }, + "numa_cpu_mapping": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ocsp_update_options": { + "$ref": "#/definitions/ocsp_update_options" + }, + "performance_options": { + "$ref": "#/definitions/performance_options" + }, + "pidfile": { + "type": "string", + "x-display-name": "PID File" + }, + "pp2_never_send_local": { + "type": "boolean" + }, + "prealloc_fd": { + "type": "boolean", + "x-display-name": "Prealloc FD" + }, + "runtime_apis": { + "type": "array", + "items": { + "$ref": "#/definitions/GlobalBaseRuntimeApisItems0" }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/http_request_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-display-name": "Runtime APIs", + "x-go-name": "RuntimeAPIs", + "x-omitempty": true + }, + "set_dumpable": { + "type": "boolean" + }, + "set_var": { + "type": "array", + "items": { + "$ref": "#/definitions/GlobalBaseSetVarItems0" }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-display-name": "Set variables", + "x-go-name": "SetVars", + "x-omitempty": true + }, + "set_var_fmt": { + "type": "array", + "items": { + "$ref": "#/definitions/GlobalBaseSetVarFmtItems0" }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-display-name": "Set variable formats", + "x-go-name": "SetVarFmts", + "x-omitempty": true + }, + "setcap": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "OS Capabilities", + "x-omitempty": true + }, + "shm_stats_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Shared Memory Statistics File (EXPERIMENTAL)" + }, + "shm_stats_file_max_objects": { + "type": "integer", + "minimum": 0, + "x-display-name": "Maximum number of objects the shared memory used for shared counters will be able to store per thread group. (EXPERIMENTAL)", + "x-nullable": true + }, + "ssl_options": { + "$ref": "#/definitions/ssl_options" + }, + "stats_file": { + "type": "string" + }, + "stats_maxconn": { + "type": "integer", + "x-display-name": "Stats maxconn", + "x-nullable": true + }, + "stats_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "strict_limits": { + "type": "boolean" + }, + "thread_group_lines": { + "type": "array", + "items": { + "$ref": "#/definitions/GlobalBaseThreadGroupLinesItems0" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-display-name": "Thread Groups", + "x-go-name": "ThreadGroupLines", + "x-omitempty": true + }, + "thread_groups": { + "type": "integer", + "x-display-name": "Number of Thread Groups" + }, + "tune_buffer_options": { + "$ref": "#/definitions/tune_buffer_options" + }, + "tune_lua_options": { + "$ref": "#/definitions/tune_lua_options" + }, + "tune_options": { + "$ref": "#/definitions/tune_options" + }, + "tune_quic_options": { + "$ref": "#/definitions/tune_quic_options" + }, + "tune_ssl_options": { + "$ref": "#/definitions/tune_ssl_options" + }, + "tune_vars_options": { + "$ref": "#/definitions/tune_vars_options" + }, + "tune_zlib_options": { + "$ref": "#/definitions/tune_zlib_options" + }, + "uid": { + "type": "integer", + "x-display-name": "UID" + }, + "ulimit_n": { + "type": "integer" + }, + "user": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "User" + }, + "warn_blocked_traffic_after": { + "type": "integer", + "minimum": 1, + "x-default-unit": "ms", + "x-display-name": "Delay after which a stuck task triggers a warning", + "x-duration": true, + "x-nullable": true + }, + "wurfl_options": { + "$ref": "#/definitions/wurfl_options" + } + }, + "additionalProperties": false + }, + "group": { + "description": "HAProxy userlist group", + "type": "object", + "title": "Group", + "required": [ + "name" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "users": { + "type": "string", + "x-nullable": false } } }, - "/services/haproxy/configuration/http_request_rules/{id}": { - "get": { - "description": "Returns one HTTP Request Rule configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" - ], - "summary": "Return one HTTP Request Rule", - "operationId": "getHTTPRequestRule", - "parameters": [ - { - "type": "integer", - "description": "HTTP Request Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "groups": { + "description": "HAProxy userlist groups array", + "type": "array", + "title": "Groups", + "items": { + "$ref": "#/definitions/group" + } + }, + "hash_type": { + "type": "object", + "properties": { + "function": { + "type": "string", + "enum": [ + "sdbm", + "djb2", + "wt6", + "crc32", + "none" + ] + }, + "method": { + "type": "string", + "enum": [ + "map-based", + "consistent" + ] + }, + "modifier": { + "type": "string", + "enum": [ + "avalanche" + ] + } + } + }, + "health": { + "type": "object", + "properties": { + "haproxy": { + "type": "string", + "enum": [ + "up", + "down", + "unknown" + ] + } + } + }, + "http_after_response_rule": { + "description": "HAProxy HTTP after response rule configuration (corresponds to http-after-response directives)", + "type": "object", + "title": "HTTP after Response Rule", + "required": [ + "type" + ], + "properties": { + "acl_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "del-acl" + ] + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/http_request_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "acl_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "del-acl" + ] } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "ACK Key Format" + }, + "capture_id": { + "type": "integer", + "x-dependency": { + "type": { + "value": "capture" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Capture SlotID", + "x-nullable": true + }, + "capture_len": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": "capture" } - } - } - }, - "put": { - "description": "Replaces a HTTP Request Rule configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" - ], - "summary": "Replace a HTTP Request Rule", - "operationId": "replaceHTTPRequestRule", - "parameters": [ - { - "type": "integer", - "description": "HTTP Request Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/http_request_rule" + "x-display-name": "Capture Len" + }, + "capture_sample": { + "type": "string", + "pattern": "^(?:[A-Za-z]+\\(\"([A-Za-z\\s]+)\"\\)|[A-Za-z]+)", + "x-dependency": { + "type": { + "value": "capture" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "Capture Sample" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" } - ], - "responses": { - "200": { - "description": "HTTP Request Rule replaced", - "schema": { - "$ref": "#/definitions/http_request_rule" + }, + "hdr_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value", + "set-header", + "add-header" + ] } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/http_request_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Header Format" + }, + "hdr_match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value" + ] } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Header Match" + }, + "hdr_method": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "del-header" + ] } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Header Match Method" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-header", + "replace-header", + "del-header", + "set-header", + "replace-value" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Header Name" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-log-level" } } - } - }, - "delete": { - "description": "Deletes a HTTP Request Rule configuration by it's ID from the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPRequestRule" - ], - "summary": "Delete a HTTP Request Rule", - "operationId": "deleteHTTPRequestRule", - "parameters": [ - { - "type": "integer", - "description": "HTTP Request Rule ID", - "name": "id", - "in": "path", - "required": true + }, + "map_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + } + }, + "map_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "x-display-name": "Map Key Format" + }, + "map_valuefmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-map" + } }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-display-name": "Map Value Format" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] + } + } + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-set-gpt" + ] + } + } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "status": { + "type": "integer", + "maximum": 999, + "minimum": 100, + "x-dependency": { + "type": { + "required": true, + "value": "set-status" + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-nullable": false + }, + "status_reason": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-status" + } } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "strict_mode": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-dependency": { + "type": { + "required": true, + "value": "strict-mode" + } + } + }, + "type": { + "type": "string", + "enum": [ + "add-header", + "allow", + "capture", + "del-acl", + "del-header", + "del-map", + "replace-header", + "replace-value", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "set-header", + "set-log-level", + "set-map", + "set-status", + "set-var", + "set-var-fmt", + "strict-mode", + "unset-var", + "do-log" + ], + "x-nullable": false + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var" } }, - "204": { - "description": "HTTP Request Rule deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var-fmt" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] } } } + }, + "additionalProperties": false, + "example": { + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "max-age=31536000", + "hdr_name": "Strict-Transport-Security", + "type": "set-header" } }, - "/services/haproxy/configuration/http_response_rules": { - "get": { - "description": "Returns all HTTP Response Rules that are configured in specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" - ], - "summary": "Return an array of all HTTP Response Rules", - "operationId": "getHTTPResponseRules", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "http_after_response_rules": { + "description": "HAProxy HTTP after response rules array (corresponds to http-after-response directives)", + "type": "array", + "title": "HTTP After Response Rules Array", + "items": { + "$ref": "#/definitions/http_after_response_rule" + } + }, + "http_check": { + "type": "object", + "title": "HTTP Check", + "required": [ + "type" + ], + "properties": { + "addr": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "connect" + } }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-nullable": false + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "connect" + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "ALPN Protocols" + }, + "body": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/http_response_rules" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "body_log_format": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "check_comment": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "comment", + "connect", + "expect", + "send" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-nullable": false + }, + "default": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" } } - } - }, - "post": { - "description": "Adds a new HTTP Response Rule of the specified type in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" - ], - "summary": "Add a new HTTP Response Rule", - "operationId": "createHTTPResponseRule", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + }, + "error_status": { + "type": "string", + "enum": [ + "L7OKC", + "L7RSP", + "L7STS", + "L6RSP", + "L4CON" + ], + "x-dependency": { + "type": { + "value": "expect" + } + } + }, + "exclamation_mark": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "expect" + } }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-display-name": "Expect Exclamation Mark" + }, + "headers": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/http_response_rule" + "x-dependency": { + "type": { + "value": "send" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-go-name": "CheckHeaders", + "x-omitempty": true + }, + "linger": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" + } + } + }, + "match": { + "type": "string", + "pattern": "^[^\\s]+$", + "enum": [ + "status", + "rstatus", + "hdr", + "fhdr", + "string", + "rstring" + ], + "x-dependency": { + "type": { + "required": true, + "value": "expect" + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-display-name": "Expect Match" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "method": { + "type": "string", + "enum": [ + "HEAD", + "PUT", + "POST", + "GET", + "TRACE", + "PATCH", + "DELETE", + "CONNECT", + "OPTIONS" + ], + "x-dependency": { + "type": { + "value": "send" + } } - ], - "responses": { - "201": { - "description": "HTTP Response Rule created", - "schema": { - "$ref": "#/definitions/http_response_rule" + }, + "min_recv": { + "type": "integer", + "x-dependency": { + "type": { + "value": "expect" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/http_response_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-nullable": true + }, + "ok_status": { + "type": "string", + "enum": [ + "L7OK", + "L7OKC", + "L6OK", + "L4OK" + ], + "x-dependency": { + "type": { + "value": "expect" } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "on_error": { + "type": "string", + "x-dependency": { + "type": { + "value": "expect" } - }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "on_success": { + "type": "string", + "x-dependency": { + "type": { + "value": "expect" } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "pattern": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "expect" } } - } - } - }, - "/services/haproxy/configuration/http_response_rules/{id}": { - "get": { - "description": "Returns one HTTP Response Rule configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" - ], - "summary": "Return one HTTP Response Rule", - "operationId": "getHTTPResponseRule", - "parameters": [ - { - "type": "integer", - "description": "HTTP Response Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-dependency": { + "type": { + "value": "connect" + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-nullable": true + }, + "port_string": { + "type": "string", + "x-dependency": { + "type": { + "value": "connect" + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/http_response_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "proto": { + "type": "string", + "x-dependency": { + "type": { + "value": "connect" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-nullable": false + }, + "send_proxy": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "sni": { + "type": "string", + "x-dependency": { + "type": { + "value": "connect" } } - } - }, - "put": { - "description": "Replaces a HTTP Response Rule configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" - ], - "summary": "Replace a HTTP Response Rule", - "operationId": "replaceHTTPResponseRule", - "parameters": [ - { - "type": "integer", - "description": "HTTP Response Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/http_response_rule" + }, + "ssl": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" } - ], - "responses": { - "200": { - "description": "HTTP Response Rule replaced", - "schema": { - "$ref": "#/definitions/http_response_rule" + }, + "status-code": { + "type": "string", + "x-dependency": { + "type": { + "value": "expect" } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/http_response_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + } + }, + "tout_status": { + "type": "string", + "enum": [ + "L7TOUT", + "L6TOUT", + "L4TOUT" + ], + "x-dependency": { + "type": { + "value": "expect" } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "type": { + "type": "string", + "enum": [ + "comment", + "connect", + "disable-on-404", + "expect", + "send", + "send-state", + "set-var", + "set-var-fmt", + "unset-var" + ], + "x-nullable": false + }, + "uri": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "uri_log_format": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var" + ] } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var-fmt" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "version": { + "type": "string", + "x-dependency": { + "type": { + "value": "send" + } + } + }, + "via_socks4": { + "type": "boolean", + "x-dependency": { + "type": { + "value": "connect" } } } + } + }, + "http_checks": { + "type": "array", + "title": "HTTP Checks Array", + "items": { + "$ref": "#/definitions/http_check" + } + }, + "http_client_options": { + "type": "object", + "properties": { + "resolvers_disabled": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "HTTP Client Resolvers Disabled" + }, + "resolvers_id": { + "type": "string", + "x-display-name": "HTTP Client Resolvers ID" + }, + "resolvers_prefer": { + "type": "string", + "enum": [ + "ipv4", + "ipv6" + ], + "x-display-name": "HTTP Client Resolvers Prefer" + }, + "retries": { + "type": "integer", + "x-display-name": "HTTP Client Retries" + }, + "ssl_ca_file": { + "type": "string", + "x-display-name": "HTTP Client SSL CA File" + }, + "ssl_verify": { + "type": "string", + "enum": [ + "", + "none", + "required" + ], + "x-display-name": "HTTP Client SSL Verify", + "x-nullable": true + }, + "timeout_connect": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "HTTP Client Connect Timeout", + "x-duration": true, + "x-nullable": true + } + } + }, + "http_codes": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string", + "pattern": "^[a-zA-Z0-9 +\\-,]+$", + "x-display-name": "Value" + } }, - "delete": { - "description": "Deletes a HTTP Response Rule configuration by it's ID from the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "HTTPResponseRule" - ], - "summary": "Delete a HTTP Response Rule", - "operationId": "deleteHTTPResponseRule", - "parameters": [ - { - "type": "integer", - "description": "HTTP Response Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-go-name": "HTTPCodes" + }, + "http_error_rule": { + "description": "HAProxy HTTP error rule configuration (corresponds to http-error directives)", + "type": "object", + "title": "HTTP Error Rule", + "required": [ + "type", + "status" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "return_content": { + "type": "string", + "x-dependency": { + "return_content_format": { + "required": true, + "value": [ + "errofile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ] + } + } + }, + "return_content_format": { + "type": "string", + "enum": [ + "default-errorfiles", + "errorfile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ], + "x-dependency": { + "type": { + "value": "status" + } + } + }, + "return_content_type": { + "type": "string", + "x-dependency": { + "type": { + "value": "status" } }, - "204": { - "description": "HTTP Response Rule deleted" + "x-display-name": "Return content type", + "x-nullable": true + }, + "return_hdrs": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-dependency": { + "return_content_format": { + "value": [ + "file", + "lf-file", + "string", + "lf-string" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-go-name": "ReturnHeaders", + "x-omitempty": true + }, + "status": { + "type": "integer", + "enum": [ + 200, + 400, + 401, + 403, + 404, + 405, + 407, + 408, + 410, + 413, + 425, + 429, + 500, + 501, + 502, + 503, + 504 + ], + "x-dependency": { + "type": { + "required": true, + "value": "status" } - } + }, + "x-nullable": false + }, + "type": { + "type": "string", + "enum": [ + "status" + ], + "x-nullable": false } + }, + "additionalProperties": false, + "example": { + "index": 0, + "status": 425, + "type": "status" } }, - "/services/haproxy/configuration/log_targets": { - "get": { - "description": "Returns all Log Targets that are configured in specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" - ], - "summary": "Return an array of all Log Targets", - "operationId": "getLogTargets", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "http_error_rules": { + "description": "HAProxy HTTP error rules array (corresponds to http-error directives)", + "type": "array", + "title": "HTTP Error Rules Array", + "items": { + "$ref": "#/definitions/http_error_rule" + } + }, + "http_errors_section": { + "description": "A globally declared group of HTTP errors", + "type": "object", + "title": "http-errors section", + "required": [ + "name", + "error_files" + ], + "properties": { + "error_files": { + "type": "array", + "items": { + "$ref": "#/definitions/errorfile" }, + "x-go-name": "ErrorFiles" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "error_files": [ { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "code": 400, + "name": "/etc/haproxy/errorfiles/site1/400.http" }, { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "code": 404, + "name": "/etc/haproxy/errorfiles/site1/404.http" } ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/log_targets" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "name": "website-1" + } + }, + "http_errors_sections": { + "description": "An array of HAProxy http-error sections", + "type": "array", + "title": "http-errors sections", + "items": { + "$ref": "#/definitions/http_errors_section" + } + }, + "http_request_rule": { + "description": "HAProxy HTTP request rule configuration (corresponds to http-request directives)", + "type": "object", + "title": "HTTP Request Rule", + "required": [ + "type" + ], + "properties": { + "acl_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "ACL File" + }, + "acl_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] } - } - } - }, - "post": { - "description": "Adds a new Log Target of the specified type in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" - ], - "summary": "Add a new Log Target", - "operationId": "createLogTarget", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/log_target" + "x-display-name": "ACL Key Format" + }, + "auth_realm": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "auth" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "Authentication Realm" + }, + "bandwidth_limit_limit": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "201": { - "description": "Log Target created", - "schema": { - "$ref": "#/definitions/log_target" + "x-display-name": "Standard HAProxy expression" + }, + "bandwidth_limit_name": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/log_target" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Bandwidth limit name" + }, + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Standard HAProxy expression" + }, + "cache_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "cache-use" } }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Cache Name" + }, + "capture_id": { + "type": "integer", + "x-dependency": { + "type": { + "value": "capture" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Capture SlotID", + "x-nullable": true + }, + "capture_len": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": "capture" } - } - } - } - }, - "/services/haproxy/configuration/log_targets/{id}": { - "get": { - "description": "Returns one Log Target configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" - ], - "summary": "Return one Log Target", - "operationId": "getLogTarget", - "parameters": [ - { - "type": "integer", - "description": "Log Target ID", - "name": "id", - "in": "path", - "required": true }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "x-display-name": "Capture Len" + }, + "capture_sample": { + "type": "string", + "pattern": "^(?:[A-Za-z]+\\(\"([A-Za-z\\s]+)\"\\)|[A-Za-z]+)", + "x-dependency": { + "type": { + "value": "capture" + } }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-display-name": "Capture Sample" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/log_target" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "deny_status": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": [ + "deny", + "tarpit" + ] } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-nullable": true + }, + "expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "do-resolve", + "pause", + "set-bc-mark", + "set-bc-tos", + "set-dst", + "set-dst-port", + "set-fc-mark", + "set-fc-tos", + "set-priority-class", + "set-priority-offset", + "set-src", + "set-src-port", + "set-retries" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Standard HAProxy expression" + }, + "hdr_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value", + "set-header", + "add-header" + ] } - } - } - }, - "put": { - "description": "Replaces a Log Target configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" - ], - "summary": "Replace a Log Target", - "operationId": "replaceLogTarget", - "parameters": [ - { - "type": "integer", - "description": "Log Target ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/log_target" + "x-display-name": "Header Format" + }, + "hdr_match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value" + ] } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Log Target replaced", - "schema": { - "$ref": "#/definitions/log_target" + "x-display-name": "Header Match" + }, + "hdr_method": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "del-header" + ] } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/log_target" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Header Match Method" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-header", + "replace-header", + "del-header", + "set-header", + "replace-value" + ] } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Header Name" + }, + "hint_format": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "early-hint" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Hint Format" + }, + "hint_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "early-hint" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Hint Name" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-log-level" } } - } - }, - "delete": { - "description": "Deletes a Log Target configuration by it's ID from the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "LogTarget" - ], - "summary": "Delete a Log Target", - "operationId": "deleteLogTarget", - "parameters": [ - { - "type": "integer", - "description": "Log Target ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + }, + "lua_action": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "lua" + } } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "lua_params": { + "type": "string", + "x-dependency": { + "type": { + "value": "lua" + } + } + }, + "map_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + } + }, + "map_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] } }, - "204": { - "description": "Log Target deleted" + "x-display-name": "Map Key Format" + }, + "map_valuefmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-map" + } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Map Value Format" + }, + "mark_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-mark" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Mark Value" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "method_fmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-method" } } - } - } - }, - "/services/haproxy/configuration/raw": { - "get": { - "description": "Returns HAProxy configuration file in plain text", - "produces": [ - "text/plain" - ], - "tags": [ - "Configuration", - "HAProxy configuration management" - ], - "summary": "Return HAProxy configuration", - "operationId": "getHAProxyConfiguration", - "parameters": [ - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + }, + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "type": { + "required": true, + "value": "set-nice" + } }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "Nice Value", + "x-nullable": false + }, + "normalizer": { + "type": "string", + "enum": [ + "fragment-encode", + "fragment-strip", + "path-merge-slashes", + "path-strip-dot", + "path-strip-dotdot", + "percent-decode-unreserved", + "percent-to-uppercase", + "query-sort-by-name" + ], + "x-dependency": { + "type": { + "required": true, + "value": "normalize-uri" + } } - ], - "responses": { - "200": { - "description": "Operation successful", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "type": "string" - } - } + }, + "normalizer_full": { + "type": "boolean", + "x-dependency": { + "normalizer": { + "value": "path-strip-dotdot" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "type": { + "value": "normalize-uri" } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + } + }, + "normalizer_strict": { + "type": "boolean", + "x-dependency": { + "normalizer": { + "value": [ + "percent-decode-unreserved", + "percent-to-uppercase" + ] }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "type": { + "value": "normalize-uri" } } - } - }, - "post": { - "description": "Push a new haproxy configuration file in plain text", - "consumes": [ - "text/plain" - ], - "produces": [ - "text/plain" - ], - "tags": [ - "Configuration", - "HAProxy configuration management" - ], - "summary": "Push new haproxy configuration", - "operationId": "postHAProxyConfiguration", - "parameters": [ - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "type": "string" + }, + "path_fmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-path", + "set-pathq", + "replace-path", + "replace-pathq" + ] } - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" } - ], - "responses": { - "201": { - "description": "New HAProxy configuration pushed", - "schema": { - "type": "string" + }, + "path_match": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-path", + "set-pathq", + "replace-path", + "replace-pathq" + ] } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "type": "string" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + } + }, + "protocol": { + "type": "string", + "enum": [ + "ipv4", + "ipv6" + ], + "x-dependency": { + "type": { + "required": false, + "value": "do-resolve" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Protocol" + }, + "query-fmt": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-query" + } + } + }, + "redir_code": { + "type": "integer", + "enum": [ + 301, + 302, + 303, + 307, + 308 + ], + "x-dependency": { + "type": { + "value": "redirect" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Redirect Code", + "x-nullable": true + }, + "redir_option": { + "type": "string", + "x-dependency": { + "type": { + "value": "redirect" } - } - } - } - }, - "/services/haproxy/configuration/server_switching_rules": { - "get": { - "description": "Returns all Backend Switching Rules that are configured in specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" - ], - "summary": "Return an array of all Server Switching Rules", - "operationId": "getServerSwitchingRules", - "parameters": [ - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/server_switching_rules" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Redirect Option" + }, + "redir_type": { + "type": "string", + "enum": [ + "location", + "prefix", + "scheme" + ], + "x-dependency": { + "type": { + "required": true, + "value": "redirect" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Redirect Type" + }, + "redir_value": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "redirect" } - } - } - }, - "post": { - "description": "Adds a new Server Switching Rule of the specified type in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" - ], - "summary": "Add a new Server Switching Rule", - "operationId": "createServerSwitchingRule", - "parameters": [ - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/server_switching_rule" + "x-display-name": "Redirect Value" + }, + "resolvers": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "do-resolve" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "Resolvers" + }, + "return_content": { + "type": "string", + "x-dependency": { + "return_content_format": { + "required": true, + "value": [ + "errofile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ] + } + } + }, + "return_content_format": { + "type": "string", + "enum": [ + "default-errorfiles", + "errorfile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ], + "x-dependency": { + "type": { + "value": [ + "deny", + "tarpit", + "return" + ] + } + } + }, + "return_content_type": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "deny", + "tarpit", + "return" + ] + } }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "Return content type", + "x-nullable": true + }, + "return_hdrs": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "201": { - "description": "Server Switching Rule created", - "schema": { - "$ref": "#/definitions/server_switching_rule" + "x-dependency": { + "return_content_format": { + "value": [ + "file", + "lf-file", + "string", + "lf-string" + ] } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/server_switching_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-go-name": "ReturnHeaders", + "x-omitempty": true + }, + "return_status_code": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": "return" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Return Error Code", + "x-nullable": true + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] } }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "RST TTL" + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] } } - } - } - }, - "/services/haproxy/configuration/server_switching_rules/{id}": { - "get": { - "description": "Returns one Server Switching Rule configuration by it's ID in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" - ], - "summary": "Return one Server Switching Rule", - "operationId": "getServerSwitchingRule", - "parameters": [ - { - "type": "integer", - "description": "Switching Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-set-gpt" + ] + } + } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "service_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "use-service" + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/server_switching_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "SPOE Engine" + }, + "spoe_group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "SPOE Group" + }, + "strict_mode": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-dependency": { + "type": { + "required": true, + "value": "strict-mode" } } - } - }, - "put": { - "description": "Replaces a Server Switching Rule configuration by it's ID in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" - ], - "summary": "Replace a Server Switching Rule", - "operationId": "replaceServerSwitchingRule", - "parameters": [ - { - "type": "integer", - "description": "Switching Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/server_switching_rule" + }, + "timeout": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" } - ], - "responses": { - "200": { - "description": "Server Switching Rule replaced", - "schema": { - "$ref": "#/definitions/server_switching_rule" + }, + "timeout_type": { + "type": "string", + "enum": [ + "server", + "tunnel", + "client" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" + } + } + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-tos" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/server_switching_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Tos Value" + }, + "track_sc_key": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "track-sc" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "track-sc Key" + }, + "track_sc_stick_counter": { + "type": "integer", + "x-dependency": { + "type": { + "value": "track-sc" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "track-sc StickCounter", + "x-nullable": true + }, + "track_sc_table": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "track-sc" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "track-sc Table" + }, + "type": { + "type": "string", + "enum": [ + "add-acl", + "add-header", + "allow", + "auth", + "cache-use", + "capture", + "del-acl", + "del-header", + "del-map", + "deny", + "disable-l7-retry", + "do-resolve", + "early-hint", + "lua", + "normalize-uri", + "pause", + "redirect", + "reject", + "replace-header", + "replace-path", + "replace-pathq", + "replace-uri", + "replace-value", + "return", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-bc-mark", + "set-bc-tos", + "set-dst", + "set-dst-port", + "set-fc-mark", + "set-fc-tos", + "set-header", + "set-log-level", + "set-map", + "set-mark", + "set-method", + "set-nice", + "set-path", + "set-pathq", + "set-priority-class", + "set-priority-offset", + "set-query", + "set-src", + "set-src-port", + "set-timeout", + "set-tos", + "set-uri", + "set-var", + "set-var-fmt", + "silent-drop", + "strict-mode", + "tarpit", + "track-sc", + "unset-var", + "use-service", + "wait-for-body", + "wait-for-handshake", + "set-bandwidth-limit", + "set-retries", + "do-log" + ], + "x-nullable": false + }, + "uri-fmt": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-uri", + "replace-uri" + ] } } - } - }, - "delete": { - "description": "Deletes a Server Switching Rule configuration by it's ID from the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "ServerSwitchingRule" - ], - "summary": "Delete a Server Switching Rule", - "operationId": "deleteServerSwitchingRule", - "parameters": [ - { - "type": "integer", - "description": "Switching Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + }, + "uri-match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "replace-uri" + } } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var" } }, - "204": { - "description": "Server Switching Rule deleted" + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var-fmt" + } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "do-resolve", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "wait_at_least": { + "type": "integer", + "x-dependency": { + "type": { + "value": "wait-for-body" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-nullable": true, + "x-size": true + }, + "wait_time": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "wait-for-body" } - } + }, + "x-duration": true, + "x-nullable": true } + }, + "additionalProperties": false, + "example": { + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "index": 0, + "type": "add-header" } }, - "/services/haproxy/configuration/servers": { - "get": { - "description": "Returns an array of all servers that are configured in specified backend.", - "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" - ], - "summary": "Return an array of servers", - "operationId": "getServers", - "parameters": [ - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "http_request_rules": { + "description": "HAProxy HTTP request rules array (corresponds to http-request directives)", + "type": "array", + "title": "HTTP Request Rules Array", + "items": { + "$ref": "#/definitions/http_request_rule" + } + }, + "http_response_rule": { + "description": "HAProxy HTTP response rule configuration (corresponds to http-response directives)", + "type": "object", + "title": "HTTP Response Rule", + "required": [ + "type" + ], + "properties": { + "acl_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/servers" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "acl_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-acl", + "del-acl" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "ACK Key Format" + }, + "bandwidth_limit_limit": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" } - } - } - }, - "post": { - "description": "Adds a new server in the specified backend in the configuration file.", - "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" - ], - "summary": "Add a new server", - "operationId": "createServer", - "parameters": [ - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/server" + "x-display-name": "Standard HAProxy expression" + }, + "bandwidth_limit_name": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "201": { - "description": "Server created", - "schema": { - "$ref": "#/definitions/server" + "x-display-name": "Bandwidth limit name" + }, + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-bandwidth-limit" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/server" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Standard HAProxy expression" + }, + "cache_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "cache-store" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Cache Name" + }, + "capture_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": "capture" } }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Capture SlotID", + "x-nullable": true + }, + "capture_sample": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "capture" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Capture Sample" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" } - } - } - }, - "/services/haproxy/configuration/servers/{name}": { - "get": { - "description": "Returns one server configuration by it's name in the specified backend.", - "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" - ], - "summary": "Return one server", - "operationId": "getServer", - "parameters": [ - { - "type": "string", - "description": "Server name", - "name": "name", - "in": "path", - "required": true + }, + "deny_status": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": "deny" + } }, - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "x-nullable": true + }, + "expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "pause", + "set-fc-mark", + "set-fc-tos" + ] + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/server" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Standard HAProxy expression" + }, + "hdr_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value", + "set-header", + "add-header" + ] } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Header Format" + }, + "hdr_match": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "replace-header", + "replace-value" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Header Match" + }, + "hdr_method": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "del-header" + ] } - } - } - }, - "put": { - "description": "Replaces a server configuration by it's name in the specified backend.", - "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" - ], - "summary": "Replace a server", - "operationId": "replaceServer", - "parameters": [ - { - "type": "string", - "description": "Server name", - "name": "name", - "in": "path", - "required": true }, - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "x-display-name": "Header Match Method" + }, + "hdr_name": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "add-header", + "replace-header", + "del-header", + "set-header", + "replace-value" + ] + } }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/server" + "x-display-name": "Header Name" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-log-level" + } + } + }, + "lua_action": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "lua" + } + } + }, + "lua_params": { + "type": "string", + "x-dependency": { + "type": { + "value": "lua" + } + } + }, + "map_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] + } + } + }, + "map_keyfmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-map", + "del-map" + ] } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "Map Key Format" + }, + "map_valuefmt": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "set-map" + } }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "Map Value Format" + }, + "mark_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-mark" + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-display-name": "Mark Value" + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "200": { - "description": "Server replaced", - "schema": { - "$ref": "#/definitions/server" + }, + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "type": { + "required": true, + "value": "set-nice" + } + }, + "x-display-name": "Nice Value", + "x-nullable": false + }, + "redir_code": { + "type": "integer", + "enum": [ + 301, + 302, + 303, + 307, + 308 + ], + "x-dependency": { + "type": { + "value": "redirect" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/server" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "Redirect Code", + "x-nullable": true + }, + "redir_option": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "redirect" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Redirect Option" + }, + "redir_type": { + "type": "string", + "enum": [ + "location", + "prefix", + "scheme" + ], + "x-dependency": { + "type": { + "required": true, + "value": "redirect" } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Redirect Type" + }, + "redir_value": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "redirect" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Redirect Value" + }, + "return_content": { + "type": "string", + "x-dependency": { + "return_content_format": { + "required": true, + "value": [ + "errofile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ] } } - } - }, - "delete": { - "description": "Deletes a server configuration by it's name in the specified backend.", - "tags": [ - "Server", - "HAProxy configuration management", - "Backend options" - ], - "summary": "Delete a server", - "operationId": "deleteServer", - "parameters": [ - { - "type": "string", - "description": "Server name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + }, + "return_content_format": { + "type": "string", + "enum": [ + "default-errorfiles", + "errorfile", + "errorfiles", + "file", + "lf-file", + "string", + "lf-string" + ], + "x-dependency": { + "type": { + "value": [ + "deny", + "return" + ] + } + } + }, + "return_content_type": { + "type": "string", + "x-dependency": { + "type": { + "value": [ + "deny", + "return" + ] + } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "Return content type", + "x-nullable": true + }, + "return_hdrs": { + "type": "array", + "items": { + "$ref": "#/definitions/return_header" }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-dependency": { + "return_content_format": { + "value": [ + "file", + "lf-file", + "string", + "lf-string" + ] + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-go-name": "ReturnHeaders", + "x-omitempty": true + }, + "return_status_code": { + "type": "integer", + "maximum": 599, + "minimum": 200, + "x-dependency": { + "type": { + "value": "return" } }, - "204": { - "description": "Server deleted" + "x-display-name": "Return Error Code", + "x-nullable": true + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] + } }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "RST TTL" + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] } } - } - } - }, - "/services/haproxy/configuration/stick_rules": { - "get": { - "description": "Returns all Stick Rules that are configured in specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" - ], - "summary": "Return an array of all Stick Rules", - "operationId": "getStickRules", - "parameters": [ - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-set-gpt" + ] + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/stick_rules" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" } } - } - }, - "post": { - "description": "Adds a new Stick Rule of the specified type in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" - ], - "summary": "Add a new Stick Rule", - "operationId": "createStickRule", - "parameters": [ - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + }, + "spoe_group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "send-spoe-group" + } + } + }, + "status": { + "type": "integer", + "maximum": 999, + "minimum": 100, + "x-dependency": { + "type": { + "required": true, + "value": "set-status" + } }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/stick_rule" + "x-nullable": false + }, + "status_reason": { + "type": "string", + "x-dependency": { + "type": { + "value": "set-status" + } + } + }, + "strict_mode": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-dependency": { + "type": { + "required": true, + "value": "strict-mode" + } + } + }, + "timeout": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" + } + } + }, + "timeout_type": { + "type": "string", + "enum": [ + "server", + "tunnel", + "client" + ], + "x-dependency": { + "type": { + "required": true, + "value": "set-timeout" + } + } + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "type": { + "required": true, + "value": "set-tos" } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-display-name": "Tos Value" + }, + "track_sc_key": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": "track-sc" + } }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-display-name": "track-sc Key" + }, + "track_sc_stick_counter": { + "type": "integer", + "x-dependency": { + "type": { + "value": "track-sc" + } }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "201": { - "description": "Stick Rule created", - "schema": { - "$ref": "#/definitions/stick_rule" + "x-display-name": "track-sc StickCounter", + "x-nullable": true + }, + "track_sc_table": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "track-sc" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/stick_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "track-sc Table" + }, + "type": { + "type": "string", + "enum": [ + "add-acl", + "add-header", + "allow", + "cache-store", + "capture", + "del-acl", + "del-header", + "del-map", + "deny", + "lua", + "pause", + "redirect", + "replace-header", + "replace-value", + "return", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-fc-mark", + "set-fc-tos", + "set-header", + "set-log-level", + "set-map", + "set-mark", + "set-nice", + "set-status", + "set-timeout", + "set-tos", + "set-var", + "set-var-fmt", + "silent-drop", + "strict-mode", + "track-sc", + "unset-var", + "wait-for-body", + "set-bandwidth-limit", + "do-log" + ], + "x-nullable": false + }, + "var_expr": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var" } }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Var Expression" + }, + "var_format": { + "type": "string", + "x-dependency": { + "type": { + "required": true, + "value": "set-var-fmt" } }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "required": true, + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "wait_at_least": { + "type": "integer", + "x-dependency": { + "type": { + "value": "wait-for-body" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "x-nullable": true, + "x-size": true + }, + "wait_time": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "wait-for-body" } - } + }, + "x-duration": true, + "x-nullable": true } + }, + "additionalProperties": false, + "example": { + "cond": "unless", + "cond_test": "{ src 192.168.0.0/16 }", + "hdr_format": "%T", + "hdr_name": "X-Haproxy-Current-Date", + "index": 0, + "type": "add-header" } }, - "/services/haproxy/configuration/stick_rules/{id}": { - "get": { - "description": "Returns one Stick Rule configuration by it's ID in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" - ], - "summary": "Return one Stick Rule", - "operationId": "getStickRule", - "parameters": [ - { - "type": "integer", - "description": "Stick Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "http_response_rules": { + "description": "HAProxy HTTP response rules array (corresponds to http-response directives)", + "type": "array", + "title": "HTTP Response Rules Array", + "items": { + "$ref": "#/definitions/http_response_rule" + } + }, + "httpchk_params": { + "type": "object", + "properties": { + "host": { + "type": "string" + }, + "method": { + "type": "string", + "enum": [ + "HEAD", + "PUT", + "POST", + "GET", + "TRACE", + "PATCH", + "DELETE", + "CONNECT", + "OPTIONS" + ] + }, + "uri": { + "type": "string", + "pattern": "^[^ ]*$" + }, + "version": { + "type": "string" + } + }, + "x-display-name": "HTTP Check" + }, + "info": { + "description": "General API, OS and hardware information", + "type": "object", + "title": "Information", + "properties": { + "api": { + "type": "object", + "properties": { + "build_date": { + "description": "HAProxy Dataplane API build date", + "type": "string", + "format": "date-time" + }, + "version": { + "description": "HAProxy Dataplane API version string", + "type": "string" + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { + }, + "system": { + "type": "object", + "properties": { + "cpu_info": { "type": "object", "properties": { - "_version": { - "type": "integer" + "model": { + "type": "string" }, - "data": { - "$ref": "#/definitions/stick_rule" + "num_cpus": { + "description": "Number of logical CPUs", + "type": "integer" } } }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" + "hostname": { + "description": "Hostname where the HAProxy is running", + "type": "string" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "mem_info": { + "type": "object", + "properties": { + "dataplaneapi_memory": { + "type": "integer" + }, + "free_memory": { + "type": "integer" + }, + "total_memory": { + "type": "integer" + } } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "os_string": { + "description": "OS string", + "type": "string" + }, + "time": { + "description": "Current time in milliseconds since Epoch.", + "type": "integer" + }, + "uptime": { + "description": "System uptime", + "type": "integer", + "x-nullable": true } } } }, - "put": { - "description": "Replaces a Stick Rule configuration by it's ID in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" - ], - "summary": "Replace a Stick Rule", - "operationId": "replaceStickRule", - "parameters": [ - { - "type": "integer", - "description": "Stick Rule ID", - "name": "id", - "in": "path", - "required": true + "example": { + "api": { + "build_date": "2019-08-21T17:31:56.000Z", + "version": "v1.2.1 45a3288.dev" + }, + "system": { + "cpu_info": { + "model": "Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz", + "num_cpus": 4 }, - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true + "hostname": "test", + "mem_info": { + "dataplaneapi_memory": 44755536, + "free_memory": 5790642176, + "total_memory": 16681517056 }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/stick_rule" + "os_string": "Linux 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019", + "time": 1566401525, + "uptime": 87340 + } + } + }, + "log_forward": { + "description": "LogForward with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/log_forward_base" + }, + { + "type": "object", + "properties": { + "binds": { + "additionalProperties": { + "$ref": "#/definitions/bind" + } + }, + "dgram_binds": { + "additionalProperties": { + "$ref": "#/definitions/dgram_bind" + } + }, + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" } - ], - "responses": { - "200": { - "description": "Stick Rule replaced", - "schema": { - "$ref": "#/definitions/stick_rule" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/stick_rule" + } + ], + "x-go-name": "LogForward" + }, + "log_forward_base": { + "description": "HAProxy log forward configuration", + "type": "object", + "title": "Log Forward", + "required": [ + "name" + ], + "properties": { + "assume-rfc6587-ntf": { + "type": "boolean", + "x-display-name": "Assume RFC-6587 Non-Transparent Framing" + }, + "backlog": { + "type": "integer", + "x-nullable": true + }, + "dont-parse-log": { + "type": "boolean", + "x-display-name": "Don't Parse Log" + }, + "maxconn": { + "type": "integer", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "timeout_client": { + "type": "integer", + "maximum": 2147483647, + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + } + }, + "additionalProperties": false + }, + "log_forwards": { + "description": "HAProxy log forwards array", + "type": "array", + "title": "Log Forwards", + "items": { + "$ref": "#/definitions/log_forward" + } + }, + "log_profile": { + "description": "Defines a logging profile for one or more steps.", + "type": "object", + "title": "Log Profile", + "required": [ + "name" + ], + "properties": { + "log_tag": { + "description": "Override syslog log tag set by other \"log-tag\" directives.", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "description": "Name of the logging profile.", + "type": "string", + "minLength": 1, + "x-nullable": false + }, + "steps": { + "$ref": "#/definitions/log_profile_steps" + } + } + }, + "log_profile_step": { + "description": "Defines what to log for a given step.", + "type": "object", + "title": "Log Profile Step", + "required": [ + "step" + ], + "properties": { + "drop": { + "description": "If enabled, no log shall be emitted for the given step.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "format": { + "description": "Override \"log-format\" or \"error-log-format\" strings depending on the step.", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "sd": { + "description": "Override the \"log-format-sd\" string.", + "type": "string" + }, + "step": { + "description": "Logging step name.", + "type": "string", + "enum": [ + "accept", + "any", + "close", + "connect", + "error", + "request", + "response", + "http-req", + "http-res", + "http-after-res", + "quic-init", + "tcp-req-conn", + "tcp-req-cont", + "tcp-req-sess" + ], + "x-nullable": false + } + } + }, + "log_profile_steps": { + "description": "List of steps where to override the logging.", + "type": "array", + "items": { + "$ref": "#/definitions/log_profile_step" + }, + "x-omitempty": true + }, + "log_profiles": { + "description": "List of Logging Profiles", + "type": "array", + "items": { + "$ref": "#/definitions/log_profile" + } + }, + "log_target": { + "description": "Per-instance logging of events and traffic.", + "type": "object", + "title": "Log Target", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "global": { + "required": true, + "value": false }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "nolog": { + "required": true, + "value": false } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" + } + }, + "facility": { + "type": "string", + "enum": [ + "kern", + "user", + "mail", + "daemon", + "auth", + "syslog", + "lpr", + "news", + "uucp", + "cron", + "auth2", + "ftp", + "ntp", + "audit", + "alert", + "cron2", + "local0", + "local1", + "local2", + "local3", + "local4", + "local5", + "local6", + "local7" + ], + "x-dependency": { + "global": { + "required": true, + "value": false }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "nolog": { + "required": true, + "value": false } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" + } + }, + "format": { + "type": "string", + "enum": [ + "local", + "rfc3164", + "rfc5424", + "priority", + "short", + "timed", + "iso", + "raw" + ], + "x-dependency": { + "global": { + "value": false }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "nolog": { + "value": false } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + } + }, + "global": { + "type": "boolean" + }, + "length": { + "type": "integer", + "x-dependency": { + "global": { + "value": false }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "nolog": { + "value": false } } - } - }, - "delete": { - "description": "Deletes a Stick Rule configuration by it's ID from the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "StickRule" - ], - "summary": "Delete a Stick Rule", - "operationId": "deleteStickRule", - "parameters": [ - { - "type": "integer", - "description": "Stick Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + }, + "level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug" + ], + "x-dependency": { + "global": { + "value": false + }, + "nolog": { + "value": false + } } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "minlevel": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug" + ], + "x-dependency": { + "global": { + "value": false + }, + "level": { + "required": false + }, + "nolog": { + "value": false } - }, - "204": { - "description": "Stick Rule deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" + } + }, + "nolog": { + "type": "boolean" + }, + "profile": { + "type": "string" + }, + "sample_range": { + "type": "string", + "x-dependency": { + "global": { + "value": false }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "nolog": { + "value": false } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + } + }, + "sample_size": { + "type": "integer", + "x-dependency": { + "global": { + "value": false }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "nolog": { + "value": false + }, + "sample_range": { + "required": true } } } + }, + "additionalProperties": false + }, + "log_targets": { + "description": "HAProxy log target array (corresponds to log directives)", + "type": "array", + "title": "Log Target Array", + "items": { + "$ref": "#/definitions/log_target" } }, - "/services/haproxy/configuration/tcp_request_rules": { - "get": { - "description": "Returns all TCP Request Rules that are configured in specified parent and parent type.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" - ], - "summary": "Return an array of all TCP Request Rules", - "operationId": "getTCPRequestRules", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "lua_options": { + "type": "object", + "properties": { + "load_per_thread": { + "type": "string" + }, + "loads": { + "type": "array", + "items": { + "$ref": "#/definitions/LuaOptionsLoadsItems0" }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-omitempty": true + }, + "prepend_path": { + "type": "array", + "items": { + "$ref": "#/definitions/LuaOptionsPrependPathItems0" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-omitempty": true + } + } + }, + "mailer_entries": { + "description": "HAProxy mailer entries", + "type": "array", + "title": "Mailer Entries", + "items": { + "$ref": "#/definitions/mailer_entry" + } + }, + "mailer_entry": { + "description": "Mailer entry of a Mailers section", + "type": "object", + "title": "Mailer Entry", + "required": [ + "name", + "address", + "port" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^\\S+$", + "x-nullable": false + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_request_rules" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": false + } + } + }, + "mailers_section": { + "description": "MailersSection with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/mailers_section_base" + }, + { + "type": "object", + "properties": { + "mailer_entries": { + "additionalProperties": { + "$ref": "#/definitions/mailer_entry" } } } } + ], + "x-go-name": "MailersSection" + }, + "mailers_section_base": { + "description": "A list of SMTP servers used by HAProxy to send emails.", + "type": "object", + "title": "Mailers Section Base", + "required": [ + "name" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_]+$", + "x-nullable": false + }, + "timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Timeout to send an email in milliseconds", + "x-duration": true, + "x-nullable": true + } }, - "post": { - "description": "Adds a new TCP Request Rule of the specified type in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" - ], - "summary": "Add a new TCP Request Rule", - "operationId": "createTCPRequestRule", - "parameters": [ - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/tcp_request_rule" + "additionalProperties": false + }, + "mailers_sections": { + "description": "HAProxy mailers_section array", + "type": "array", + "title": "Mailers Sections", + "items": { + "$ref": "#/definitions/mailers_section" + } + }, + "map": { + "description": "Map File", + "type": "object", + "title": "Map File", + "properties": { + "description": { + "type": "string" + }, + "file": { + "type": "string" + }, + "id": { + "type": "string" + }, + "size": { + "description": "File size in bytes.", + "type": "integer", + "x-nullable": true + }, + "storage_name": { + "type": "string" + } + } + }, + "map_entries": { + "description": "Entries of one runtime map", + "type": "array", + "title": "Maps Entries", + "items": { + "$ref": "#/definitions/map_entry" + } + }, + "map_entry": { + "description": "One Map Entry", + "type": "object", + "title": "One Map Entry", + "properties": { + "id": { + "type": "string", + "readOnly": true + }, + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "maps": { + "description": "Array of runtime map files", + "type": "array", + "title": "Map Files Array", + "items": { + "$ref": "#/definitions/map" + } + }, + "monitor_fail": { + "type": "object", + "required": [ + "cond", + "cond_test" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-display-name": "Condition Test" + } + } + }, + "monitor_uri": { + "type": "string" + }, + "mysql_check_params": { + "type": "object", + "properties": { + "client_version": { + "type": "string", + "enum": [ + "pre-41", + "post-41" + ] + }, + "username": { + "type": "string" + } + } + }, + "nameserver": { + "description": "Nameserver used in Runtime DNS configuration", + "type": "object", + "title": "Nameserver", + "required": [ + "name", + "address" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "201": { - "description": "TCP Request Rule created", - "schema": { - "$ref": "#/definitions/tcp_request_rule" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/tcp_request_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + } + }, + "example": { + "address": "10.0.0.1", + "name": "ns1", + "port": 53 + } + }, + "nameservers": { + "description": "Nameservers array", + "type": "array", + "title": "Nameservers", + "items": { + "$ref": "#/definitions/nameserver" + } + }, + "native_stat": { + "description": "Current stats for one object.", + "type": "object", + "title": "Stats", + "properties": { + "backend_name": { + "type": "string", + "x-dependency": { + "type": "server" } + }, + "name": { + "type": "string" + }, + "stats": { + "$ref": "#/definitions/native_stat_stats" + }, + "type": { + "type": "string", + "enum": [ + "backend", + "server", + "frontend" + ] } } }, - "/services/haproxy/configuration/tcp_request_rules/{id}": { - "get": { - "description": "Returns one TCP Request Rule configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" - ], - "summary": "Return one TCP Request Rule", - "operationId": "getTCPRequestRule", - "parameters": [ - { - "type": "integer", - "description": "TCP Request Rule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true - }, - { - "enum": [ - "frontend", + "native_stat_stats": { + "type": "object", + "properties": { + "act": { + "type": "integer", + "x-dependency": { + "type": [ + "server", "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + ] }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-nullable": true + }, + "addr": { + "type": "string", + "x-dependency": { + "type": "server" } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_request_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + }, + "agent_code": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "agent_desc": { + "type": "string", + "x-dependency": { + "type": "server" } - } - }, - "put": { - "description": "Replaces a TCP Request Rule configuration by it's ID in the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" - ], - "summary": "Replace a TCP Request Rule", - "operationId": "replaceTCPRequestRule", - "parameters": [ - { - "type": "integer", - "description": "TCP Request Rule ID", - "name": "id", - "in": "path", - "required": true + }, + "agent_duration": { + "type": "integer", + "x-dependency": { + "type": "server" }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "x-nullable": true + }, + "agent_fall": { + "type": "integer", + "x-dependency": { + "type": "server" }, - { - "enum": [ - "frontend", - "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + "x-nullable": true + }, + "agent_health": { + "type": "integer", + "x-dependency": { + "type": "server" }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/tcp_request_rule" - } + "x-nullable": true + }, + "agent_rise": { + "type": "integer", + "x-dependency": { + "type": "server" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-nullable": true + }, + "agent_status": { + "type": "string", + "enum": [ + "UNK", + "INI", + "SOCKERR", + "L4OK", + "L4TOUT", + "L4CON", + "L7OK", + "L7STS" + ], + "x-dependency": { + "type": "server" + } + }, + "algo": { + "type": "string", + "x-dependency": { + "type": "backend" + } + }, + "bck": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-nullable": true + }, + "bin": { + "type": "integer", + "x-nullable": true + }, + "bout": { + "type": "integer", + "x-nullable": true + }, + "check_code": { + "type": "integer", + "x-dependency": { + "type": "server" }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-nullable": true + }, + "check_desc": { + "type": "string", + "x-dependency": { + "type": "server" } - ], - "responses": { - "200": { - "description": "TCP Request Rule replaced", - "schema": { - "$ref": "#/definitions/tcp_request_rule" - } + }, + "check_duration": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/tcp_request_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-nullable": true + }, + "check_fall": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "check_health": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "check_rise": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "check_status": { + "type": "string", + "enum": [ + "UNK", + "INI", + "SOCKERR", + "L4OK", + "L4TOUT", + "L4CON", + "L6OK", + "L6TOUT", + "L6RSP", + "L7OK", + "L7OKC", + "L7TOUT", + "L7RSP", + "L7STS" + ], + "x-dependency": { + "type": "server" } - } - }, - "delete": { - "description": "Deletes a TCP Request Rule configuration by it's ID from the specified parent.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPRequestRule" - ], - "summary": "Delete a TCP Request Rule", - "operationId": "deleteTCPRequestRule", - "parameters": [ - { - "type": "integer", - "description": "TCP Request Rule ID", - "name": "id", - "in": "path", - "required": true + }, + "chkdown": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "string", - "description": "Parent name", - "name": "parent_name", - "in": "query", - "required": true + "x-nullable": true + }, + "chkfail": { + "type": "integer", + "x-dependency": { + "type": "server" }, - { - "enum": [ - "frontend", + "x-nullable": true + }, + "cli_abrt": { + "type": "integer", + "x-dependency": { + "type": [ + "server", "backend" - ], - "type": "string", - "description": "Parent type", - "name": "parent_type", - "in": "query", - "required": true + ] }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-nullable": true + }, + "comp_byp": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-nullable": true + }, + "comp_in": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-nullable": true + }, + "comp_out": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] }, - "204": { - "description": "TCP Request Rule deleted" + "x-nullable": true + }, + "comp_rsp": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "conn_rate": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } - } - }, - "/services/haproxy/configuration/tcp_response_rules": { - "get": { - "description": "Returns all TCP Response Rules that are configured in specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" - ], - "summary": "Return an array of all TCP Response Rules", - "operationId": "getTCPResponseRules", - "parameters": [ - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "x-nullable": true + }, + "conn_rate_max": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_response_rules" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "conn_tot": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "cookie": { + "type": "string", + "x-dependency": { + "type": [ + "server", + "backend" + ] } - } - }, - "post": { - "description": "Adds a new TCP Response Rule of the specified type in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" - ], - "summary": "Add a new TCP Response Rule", - "operationId": "createTCPResponseRule", - "parameters": [ - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/tcp_response_rule" - } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + }, + "ctime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-nullable": true + }, + "dcon": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "201": { - "description": "TCP Response Rule created", - "schema": { - "$ref": "#/definitions/tcp_response_rule" - } + "x-nullable": true + }, + "downtime": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/tcp_response_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-nullable": true + }, + "dreq": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "dresp": { + "type": "integer", + "x-nullable": true + }, + "dses": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "econ": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } - } - }, - "/services/haproxy/configuration/tcp_response_rules/{id}": { - "get": { - "description": "Returns one TCP Response Rule configuration by it's ID in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" - ], - "summary": "Return one TCP Response Rule", - "operationId": "getTCPResponseRule", - "parameters": [ - { - "type": "integer", - "description": "TCP Response Rule ID", - "name": "id", - "in": "path", - "required": true + "x-nullable": true + }, + "ereq": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "x-nullable": true + }, + "eresp": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-nullable": true + }, + "hanafail": { + "type": "string", + "x-dependency": { + "type": "server" } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/tcp_response_rule" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + }, + "hrsp_1xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_2xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_3xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_4xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_5xx": { + "type": "integer", + "x-nullable": true + }, + "hrsp_other": { + "type": "integer", + "x-nullable": true + }, + "iid": { + "type": "integer", + "x-nullable": true + }, + "intercepted": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "last_agt": { + "type": "string", + "x-dependency": { + "type": "server" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } - }, - "put": { - "description": "Replaces a TCP Response Rule configuration by it's ID in the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" - ], - "summary": "Replace a TCP Response Rule", - "operationId": "replaceTCPResponseRule", - "parameters": [ - { - "type": "integer", - "description": "TCP Response Rule ID", - "name": "id", - "in": "path", - "required": true + "x-nullable": true + }, + "last_chk": { + "type": "string", + "x-dependency": { + "type": "server" }, - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "x-nullable": true + }, + "lastchg": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/tcp_response_rule" - } + "x-nullable": true + }, + "lastsess": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-nullable": true + }, + "lbtot": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-nullable": true + }, + "mode": { + "type": "string", + "enum": [ + "tcp", + "http", + "health", + "unknown" + ] + }, + "pid": { + "type": "integer", + "x-nullable": true + }, + "qcur": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "TCP Response Rule replaced", - "schema": { - "$ref": "#/definitions/tcp_response_rule" - } + "x-nullable": true + }, + "qlimit": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/tcp_response_rule" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-nullable": true + }, + "qmax": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "qtime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "rate": { + "type": "integer", + "x-nullable": true + }, + "rate_lim": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } - } - }, - "delete": { - "description": "Deletes a TCP Response Rule configuration by it's ID from the specified backend.", - "tags": [ - "HAProxy configuration management", - "Backend options", - "Frontend options", - "TCPResponseRule" - ], - "summary": "Delete a TCP Response Rule", - "operationId": "deleteTCPResponseRule", - "parameters": [ - { - "type": "integer", - "description": "TCP Response Rule ID", - "name": "id", - "in": "path", - "required": true + "x-nullable": true + }, + "rate_max": { + "type": "integer", + "x-nullable": true + }, + "req_rate": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - { - "type": "string", - "description": "Parent backend name", - "name": "backend", - "in": "query", - "required": true + "x-nullable": true + }, + "req_rate_max": { + "type": "integer", + "x-dependency": { + "type": "frontend" }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" + "x-nullable": true + }, + "req_tot": { + "type": "integer", + "x-dependency": { + "type": [ + "frontend", + "backend" + ] }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" + "x-nullable": true + }, + "rtime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } + "x-nullable": true + }, + "scur": { + "type": "integer", + "x-nullable": true + }, + "sid": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "204": { - "description": "TCP Response Rule deleted" + "x-nullable": true + }, + "slim": { + "type": "integer", + "x-nullable": true + }, + "smax": { + "type": "integer", + "x-nullable": true + }, + "srv_abrt": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "status": { + "type": "string", + "enum": [ + "UP", + "DOWN", + "NOLB", + "MAINT", + "no check" + ] + }, + "stot": { + "type": "integer", + "x-nullable": true + }, + "throttle": { + "type": "integer", + "x-dependency": { + "type": "server" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "x-nullable": true + }, + "tracked": { + "type": "string", + "x-dependency": { + "type": "server" } + }, + "ttime": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "weight": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "wredis": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true + }, + "wretr": { + "type": "integer", + "x-dependency": { + "type": [ + "server", + "backend" + ] + }, + "x-nullable": true } + }, + "example": { + "bin": 4326578, + "bout": 889901290, + "comp_byp": 0, + "comp_in": 0, + "comp_out": 0, + "comp_rsp": 0, + "conn_rate": 12, + "conn_rate_max": 456, + "conn_tot": 45682, + "dcon": 0, + "dreq": 4, + "dresp": 1, + "dses": 0, + "ereq": 54, + "hrsp_1xx": 0, + "hrsp_2xx": 165, + "hrsp_3xx": 12, + "hrsp_4xx": 50, + "hrsp_5xx": 4, + "hrsp_other": 0, + "iid": 0, + "intercepted": 346, + "last_chk": "L4OK in 0ms", + "mode": "http", + "pid": 3204, + "rate": 64, + "rate_lim": 20000, + "rate_max": 4000, + "req_rate": 49, + "req_rate_max": 3965, + "req_total": 1254786, + "scur": 129, + "slim": 2000, + "smax": 2000, + "status": "UP", + "stot": 12902 } }, - "/services/haproxy/info": { - "get": { - "description": "Return HAProxy process information", - "produces": [ - "application/json" - ], - "tags": [ - "Information" - ], - "summary": "Return HAProxy process information", - "operationId": "getHaproxyProcessInfo", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/process_info" - } + "native_stats": { + "description": "HAProxy stats array", + "type": "object", + "title": "Stats Array", + "properties": { + "error": { + "type": "string" + }, + "runtimeAPI": { + "type": "string" + }, + "stats": { + "type": "array", + "items": { + "$ref": "#/definitions/native_stat" }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "x-omitempty": true + } + }, + "x-omitempty": true + }, + "ocsp_update_options": { + "type": "object", + "properties": { + "disable": { + "type": "boolean", + "default": false, + "x-display-name": "Disable OCSP Update", + "x-nullable": true + }, + "httpproxy": { + "type": "object", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "example": "127.0.0.1" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "example": 80 } - } + }, + "x-display-name": "OCSP Update HTTP Proxy", + "x-omitempty": true + }, + "maxdelay": { + "description": "Sets the maximum interval between two automatic updates of the same OCSP response.This time is expressed in seconds", + "type": "integer", + "x-default-unit": "s", + "x-display-name": "OCSP Update Maximum Delay", + "x-duration": false, + "x-nullable": true + }, + "mindelay": { + "description": "Sets the minimum interval between two automatic updates of the same OCSP response. This time is expressed in seconds", + "type": "integer", + "x-default-unit": "s", + "x-display-name": "OCSP Update Minimum Delay", + "x-duration": false, + "x-nullable": true + }, + "mode": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "OCSP Update Mode" } } }, - "/services/haproxy/reloads": { - "get": { - "description": "Returns a list of HAProxy reloads.", - "produces": [ - "application/json" - ], - "tags": [ - "Reloads" - ], - "summary": "Return list of HAProxy Reloads.", - "operationId": "getReloads", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/reloads" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "originalto": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled" + ] + }, + "except": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "header": { + "type": "string", + "pattern": "^[^\\s]+$" } + }, + "x-display-name": "OriginalTo" + }, + "peer_entries": { + "description": "HAProxy peer entries array", + "type": "array", + "title": "Peer entries", + "items": { + "$ref": "#/definitions/peer_entry" } }, - "/services/haproxy/reloads/{id}": { - "get": { - "description": "Returns one HAProxy reload status.", - "tags": [ - "Reloads" - ], - "summary": "Return one HAProxy reload status", - "operationId": "getReload", - "parameters": [ - { - "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$", - "type": "string", - "description": "Reload id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "$ref": "#/definitions/reload" - } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "peer_entry": { + "description": "Peer Entry from peers table", + "type": "object", + "title": "Peer Entry", + "required": [ + "name", + "address", + "port" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "shard": { + "type": "integer" } } }, - "/services/haproxy/sites": { - "get": { - "description": "Returns an array of all configured sites.", - "tags": [ - "Sites" - ], - "summary": "Return an array of sites", - "operationId": "getSites", - "parameters": [ - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/sites" - } + "peer_section": { + "description": "Peer Section with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/peer_section_base" + }, + { + "type": "object", + "properties": { + "binds": { + "additionalProperties": { + "$ref": "#/definitions/bind" } }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "log_target_list": { + "x-go-name": "LogTargetList", + "$ref": "#/definitions/log_targets" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "peer_entries": { + "additionalProperties": { + "$ref": "#/definitions/peer_entry" } - } - } - } - }, - "post": { - "description": "Adds a new site to the configuration file.", - "tags": [ - "Sites" - ], - "summary": "Add a site", - "operationId": "createSite", - "parameters": [ - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/site" - } - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "201": { - "description": "Site created", - "schema": { - "$ref": "#/definitions/site" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/site" }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" + "servers": { + "additionalProperties": { + "$ref": "#/definitions/server" } - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "tables": { + "additionalProperties": { + "$ref": "#/definitions/table" } } - }, - "409": { - "description": "The specified resource already exists", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + } + ], + "x-go-name": "PeerSection" + }, + "peer_section_base": { + "description": "HAProxy peer_section configuration", + "type": "object", + "title": "Peer Section Base", + "required": [ + "name" + ], + "properties": { + "default_bind": { + "$ref": "#/definitions/default_bind" + }, + "default_server": { + "$ref": "#/definitions/default_server" + }, + "disabled": { + "type": "boolean" + }, + "enabled": { + "type": "boolean" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "shards": { + "description": "In some configurations, one would like to distribute the stick-table contents\nto some peers in place of sending all the stick-table contents to each peer\ndeclared in the \"peers\" section. In such cases, \"shards\" specifies the\nnumber of peer involved in this stick-table contents distribution.", + "type": "integer" + } + }, + "additionalProperties": false + }, + "peer_sections": { + "description": "HAProxy peer_section array", + "type": "array", + "title": "Peer_Section", + "items": { + "$ref": "#/definitions/peer_section" + } + }, + "performance_options": { + "type": "object", + "properties": { + "busy_polling": { + "type": "boolean" + }, + "max_spread_checks": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "maxcompcpuusage": { + "type": "integer", + "x-display-name": "Maximum HAProxy CPU usage" + }, + "maxcomprate": { + "type": "integer", + "x-display-name": "Maximum per-process input compression rate" + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections" + }, + "maxconnrate": { + "type": "integer", + "x-display-name": "Maximum per-process number of concurrent connections" + }, + "maxpipes": { + "type": "integer", + "x-display-name": "Maximum per-process number of pipes" + }, + "maxsessrate": { + "type": "integer", + "x-display-name": "Maximum per-process number of sessions per second" + }, + "maxzlibmem": { + "type": "integer", + "x-display-name": "Maximum amount of RAM in megabytes per process usable by the zlib" + }, + "noepoll": { + "type": "boolean", + "x-display-name": "Disable the use of the \"epoll\" event polling system on Linux" + }, + "noevports": { + "type": "boolean", + "x-display-name": "Disable the use of the event ports event polling system on SunOS system derived from Solaris 10 and later" + }, + "nogetaddrinfo": { + "type": "boolean", + "x-display-name": "Disable the use of getaddrinfo for name resolving" + }, + "nokqueue": { + "type": "boolean", + "x-display-name": "Disable the use of the \"kqueue\" event polling system on BSD" + }, + "noktls": { + "type": "boolean", + "x-display-name": "Disables the use of ktls. It is equivalent to the command line argument \"-dT\"" + }, + "nopoll": { + "type": "boolean", + "x-display-name": "Disable the use of the \"poll\" event polling system" + }, + "noreuseport": { + "type": "boolean", + "x-display-name": "Disable the use of SO_REUSEPORT" + }, + "nosplice": { + "type": "boolean", + "x-display-name": "Disable the use of kernel tcp splicing between sockets on Linux" + }, + "profiling_memory": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Enable or disables per-function memory profiling" + }, + "profiling_tasks": { + "type": "string", + "enum": [ + "auto", + "enabled", + "disabled" + ], + "x-display-name": "Enable or disables per-task CPU profiling" + }, + "server_state_base": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Server State Base" + }, + "server_state_file": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Server State File" + }, + "spread_checks": { + "type": "integer", + "x-display-name": "Add some randomness in the check interval" + }, + "thread_hard_limit": { + "type": "integer", + "x-nullable": true + } + } + }, + "persist_rule": { + "type": "object", + "required": [ + "type" + ], + "properties": { + "rdp_cookie_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "type": { + "value": "rdp-cookie" } }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "x-display-name": "Rdp Cookie Name" + }, + "type": { + "type": "string", + "enum": [ + "rdp-cookie" + ] + } + } + }, + "pgsql_check_params": { + "type": "object", + "properties": { + "username": { + "type": "string" + } + } + }, + "process_info": { + "description": "General HAProxy process information", + "type": "object", + "title": "HAProxy Information", + "properties": { + "error": { + "type": "string" + }, + "info": { + "$ref": "#/definitions/process_info_item" + }, + "runtimeAPI": { + "type": "string" + } + }, + "x-omitempty": true + }, + "process_info_item": { + "type": "object", + "properties": { + "active_peers": { + "type": "integer", + "x-nullable": true + }, + "busy_polling": { + "type": "integer", + "x-nullable": true + }, + "bytes_out_rate": { + "type": "integer", + "x-nullable": true + }, + "compress_bps_in": { + "type": "integer", + "x-nullable": true + }, + "compress_bps_out": { + "type": "integer", + "x-nullable": true + }, + "compress_bps_rate_lim": { + "type": "integer", + "x-nullable": true + }, + "conn_rate": { + "type": "integer", + "x-nullable": true + }, + "conn_rate_limit": { + "type": "integer", + "x-nullable": true + }, + "connected_peers": { + "type": "integer", + "x-nullable": true + }, + "cum_conns": { + "type": "integer", + "x-nullable": true + }, + "cum_req": { + "type": "integer", + "x-nullable": true + }, + "cum_ssl_conns": { + "type": "integer", + "x-nullable": true + }, + "curr_conns": { + "type": "integer", + "x-nullable": true + }, + "curr_ssl_conns": { + "type": "integer", + "x-nullable": true + }, + "dropped_logs": { + "type": "integer", + "x-nullable": true + }, + "failed_resolutions": { + "type": "integer", + "x-nullable": true + }, + "hard_max_conn": { + "type": "integer", + "x-nullable": true + }, + "idle_pct": { + "type": "integer", + "x-nullable": true + }, + "jobs": { + "type": "integer", + "x-nullable": true + }, + "listeners": { + "type": "integer", + "x-nullable": true + }, + "max_conn": { + "type": "integer", + "x-nullable": true + }, + "max_conn_rate": { + "type": "integer", + "x-nullable": true + }, + "max_pipes": { + "type": "integer", + "x-nullable": true + }, + "max_sess_rate": { + "type": "integer", + "x-nullable": true + }, + "max_sock": { + "type": "integer", + "x-nullable": true + }, + "max_ssl_conns": { + "type": "integer", + "x-nullable": true + }, + "max_ssl_rate": { + "type": "integer", + "x-nullable": true + }, + "max_zlib_mem_usage": { + "type": "integer", + "x-nullable": true + }, + "mem_max_mb": { + "type": "integer", + "x-nullable": true + }, + "nbthread": { + "description": "Number of threads", + "type": "integer", + "x-display-name": "Number of Threads", + "x-nullable": true + }, + "node": { + "type": "string" + }, + "pid": { + "description": "Process id of the replying worker process", + "type": "integer", + "x-display-name": "PID", + "x-nullable": true + }, + "pipes_free": { + "type": "integer", + "x-nullable": true + }, + "pipes_used": { + "type": "integer", + "x-nullable": true + }, + "pool_alloc_mb": { + "type": "integer", + "x-nullable": true + }, + "pool_failed": { + "type": "integer", + "x-nullable": true + }, + "pool_used_mb": { + "type": "integer", + "x-nullable": true + }, + "process_num": { + "description": "Process number", + "type": "integer", + "x-display-name": "Process Number", + "x-nullable": true + }, + "processes": { + "description": "Number of spawned processes", + "type": "integer", + "x-display-name": "Number of processes", + "x-nullable": true + }, + "release_date": { + "description": "HAProxy version release date", + "type": "string", + "format": "date" + }, + "run_queue": { + "type": "integer", + "x-nullable": true + }, + "sess_rate": { + "type": "integer", + "x-nullable": true + }, + "sess_rate_limit": { + "type": "integer", + "x-nullable": true + }, + "ssl_backend_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_backend_max_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_cache_lookups": { + "type": "integer", + "x-nullable": true + }, + "ssl_cache_misses": { + "type": "integer", + "x-nullable": true + }, + "ssl_frontend_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_frontend_max_key_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_frontend_session_reuse": { + "type": "integer", + "x-nullable": true + }, + "ssl_rate": { + "type": "integer", + "x-nullable": true + }, + "ssl_rate_limit": { + "type": "integer", + "x-nullable": true + }, + "stopping": { + "type": "integer", + "x-nullable": true + }, + "tasks": { + "type": "integer", + "x-nullable": true + }, + "total_bytes_out": { + "type": "integer", + "x-nullable": true + }, + "ulimit_n": { + "type": "integer", + "x-nullable": true + }, + "unstoppable": { + "type": "integer", + "x-nullable": true + }, + "uptime": { + "description": "HAProxy uptime in s", + "type": "integer", + "x-nullable": true + }, + "version": { + "description": "HAProxy version string", + "type": "string" + }, + "zlib_mem_usage": { + "type": "integer", + "x-nullable": true } } }, - "/services/haproxy/sites/{name}": { - "get": { - "description": "Returns one site configuration by it's name.", - "tags": [ - "Sites" - ], - "summary": "Return a site", - "operationId": "getSite", - "parameters": [ - { - "type": "string", - "description": "Site frontend name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "type": "object", - "properties": { - "_version": { - "type": "integer" - }, - "data": { - "$ref": "#/definitions/site" - } - } - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "program": { + "description": "HAProxy program configuration", + "type": "object", + "title": "Program", + "required": [ + "name", + "command" + ], + "properties": { + "command": { + "description": "The command to be run, with flags and options.", + "type": "string" + }, + "group": { + "description": "The group to run the command as, if different than the HAProxy group.", + "type": "string" + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "start-on-reload": { + "description": "HAProxy stops and recreates child programs at reload.", + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "user": { + "description": "The user to run the command as, if different than the HAProxy user.", + "type": "string" } }, - "put": { - "description": "Replaces a site configuration by it's name.", - "tags": [ - "Sites" - ], - "summary": "Replace a site", - "operationId": "replaceSite", - "parameters": [ - { - "type": "string", - "description": "Site frontend name", - "name": "name", - "in": "path", - "required": true - }, - { - "name": "data", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/site" + "example": { + "command": "spoa-mirror --runtime 0 --mirror-url http://test.local", + "group": "mygroupname", + "name": "mirror", + "start-on-reload": "enabled", + "user": "myusername" + } + }, + "programs": { + "type": "array", + "items": { + "$ref": "#/definitions/program" + } + }, + "quic_initial_rule": { + "description": "QUIC Initial configuration", + "type": "object", + "title": "QUIC Initial", + "required": [ + "type" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true } }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" } - ], - "responses": { - "200": { - "description": "Site replaced", - "schema": { - "$ref": "#/definitions/site" - } - }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/site" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "type": { + "type": "string", + "enum": [ + "reject", + "accept", + "send-retry", + "dgram-drop" + ], + "x-nullable": false } }, - "delete": { - "description": "Deletes a site from the configuration by it's name.", - "tags": [ - "Sites" - ], - "summary": "Delete a site", - "operationId": "deleteSite", - "parameters": [ - { - "type": "string", - "description": "Site frontend name", - "name": "name", - "in": "path", - "required": true - }, - { - "type": "string", - "x-nullable": false, - "description": "ID of the transaction where we want to add the operation. Cannot be used when version is specified.", - "name": "transaction_id", - "in": "query" - }, - { - "type": "integer", - "x-nullable": false, - "description": "Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version.", - "name": "version", - "in": "query" - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "202": { - "description": "Configuration change accepted and reload requested", - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } - } - }, - "204": { - "description": "Site deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - } + "additionalProperties": false, + "x-go-name": "QUICInitialRule", + "example": { + "type": "reject" + } + }, + "quic_initial_rules": { + "type": "array", + "title": "QUIC Initials Array", + "items": { + "$ref": "#/definitions/quic_initial_rule" + }, + "x-go-name": "QUICInitialRules" + }, + "redispatch": { + "type": "object", + "required": [ + "enabled" + ], + "properties": { + "enabled": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "interval": { + "type": "integer", + "x-nullable": true } } }, - "/services/haproxy/stats": { - "get": { - "description": "Returns a list of HAProxy stats endpoints.", - "produces": [ - "application/json" - ], - "tags": [ - "Discovery" - ], - "summary": "Return list of HAProxy stats endpoints", - "operationId": "getStatsEndpoints", - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/endpoints" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "reload": { + "description": "HAProxy reload", + "type": "object", + "title": "HAProxy reload", + "properties": { + "id": { + "type": "string", + "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$" + }, + "reload_timestamp": { + "type": "integer" + }, + "response": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "failed", + "in_progress", + "succeeded" + ] + } + }, + "example": { + "id": "2019-01-03-44", + "status": "in_progress" + } + }, + "reloads": { + "description": "HAProxy reloads array", + "type": "array", + "title": "HAProxy Reloads Array", + "items": { + "$ref": "#/definitions/reload" + } + }, + "resolver": { + "description": "Resolver with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/resolver_base" + }, + { + "type": "object", + "properties": { + "nameservers": { + "additionalProperties": { + "$ref": "#/definitions/nameserver" } } } } - } + ], + "x-go-name": "Resolver" }, - "/services/haproxy/stats/native": { - "get": { - "description": "Getting stats from the HAProxy.", - "produces": [ - "application/json" - ], - "tags": [ - "Stats" - ], - "summary": "Gets stats", - "operationId": "getStats", - "parameters": [ - { - "enum": [ - "frontend", - "backend", - "server" - ], - "type": "string", - "description": "Object type to get stats for (one of frontend, backend, server)", - "name": "type", - "in": "query" - }, - { - "type": "string", - "description": "Object name to get stats for", - "name": "name", - "in": "query" - }, - { - "type": "string", - "x-dependency": { - "query.type": "server" - }, - "description": "Object parent name to get stats for, in case the object is a server", - "name": "parent", - "in": "query" + "resolver_base": { + "description": "Runtime DNS configuration", + "type": "object", + "title": "Resolver Base", + "required": [ + "name" + ], + "properties": { + "accepted_payload_size": { + "type": "integer", + "maximum": 8192, + "minimum": 512 + }, + "hold_nx": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_obsolete": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_other": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_refused": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "hold_valid": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/native_stats" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/native_stats" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "parse-resolv-conf": { + "type": "boolean" + }, + "resolve_retries": { + "type": "integer", + "minimum": 1 + }, + "timeout_resolve": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": false + }, + "timeout_retry": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": false + } + } + }, + "resolvers": { + "description": "HAProxy resolvers array", + "type": "array", + "title": "Resolvers", + "items": { + "$ref": "#/definitions/resolver" + } + }, + "return_header": { + "type": "object", + "required": [ + "name", + "fmt" + ], + "properties": { + "fmt": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "x-go-name": "ReturnHeader" + }, + "ring": { + "description": "Ring with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/ring_base" + }, + { + "type": "object", + "properties": { + "servers": { + "additionalProperties": { + "$ref": "#/definitions/server" } } } } - } + ], + "x-go-name": "Ring" }, - "/services/haproxy/transactions": { - "get": { - "description": "Returns a list of HAProxy configuration transactions. Transactions can be filtered by their status.", - "produces": [ - "application/json" - ], - "tags": [ - "Transactions" - ], - "summary": "Return list of HAProxy configuration transactions.", - "operationId": "getTransactions", - "parameters": [ - { - "enum": [ - "failed", - "in_progress" - ], - "type": "string", - "description": "Filter by transaction status", - "name": "status", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Success", - "schema": { - "$ref": "#/definitions/transactions" - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } + "ring_base": { + "description": "HAProxy ring configuration", + "type": "object", + "title": "Ring Base", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string", + "x-display-name": "The description is an optional description string of the ring" + }, + "format": { + "type": "string", + "enum": [ + "iso", + "local", + "raw", + "rfc3164", + "rfc5424", + "short", + "priority", + "timed" + ], + "x-display-name": "Format used to store events into the ring buffer" + }, + "maxlen": { + "type": "integer", + "x-display-name": "The maximum length of an event message stored into the ring", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "size": { + "type": "integer", + "minimum": 0, + "x-display-name": "Optional size in bytes for the ring-buffer", + "x-nullable": true, + "x-size": true + }, + "timeout_connect": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "timeout_server": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true } }, - "post": { - "description": "Starts a new transaction and returns it's id", - "produces": [ - "application/json" - ], - "tags": [ - "Transactions" - ], - "summary": "Start a new transaction", - "operationId": "startTransaction", - "parameters": [ - { - "type": "integer", - "description": "Configuration version on which to work on", - "name": "version", - "in": "query", - "required": true - } - ], - "responses": { - "201": { - "description": "Transaction started", - "schema": { - "$ref": "#/definitions/transaction" + "additionalProperties": false + }, + "rings": { + "description": "HAProxy rings array", + "type": "array", + "title": "Rings", + "items": { + "$ref": "#/definitions/ring" + } + }, + "runtime_add_server": { + "description": "Settable properties when adding a new server using HAProxy's runtime.", + "type": "object", + "title": "Runtime Add Server", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false, + "readOnly": true + }, + "agent-addr": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "agent-check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "agent-port": { + "required": true } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "agent-inter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "agent-port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "agent-send": { + "type": "string" + }, + "allow_0rtt": { + "type": "boolean" + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "ALPN Protocols" + }, + "backup": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "check-ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check_alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Protocols" + }, + "check_proto": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Name" + }, + "check_via_socks4": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ciphers": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" } } - } - } - }, - "/services/haproxy/transactions/{id}": { - "get": { - "description": "Returns one HAProxy configuration transactions.", - "tags": [ - "Transactions" - ], - "summary": "Return one HAProxy configuration transactions", - "operationId": "getTransaction", - "parameters": [ - { - "type": "string", - "description": "Transaction id", - "name": "id", - "in": "path", - "required": true + }, + "ciphersuites": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } } - ], - "responses": { - "200": { - "description": "Successful operation", - "schema": { - "$ref": "#/definitions/transaction" + }, + "crl_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "downinter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "error_limit": { + "type": "integer", + "x-display-name": "Healthcheck error limit", + "x-nullable": true + }, + "fall": { + "type": "integer", + "x-display-name": "Nr. of consecutive failed checks", + "x-nullable": true + }, + "fastinter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "force_sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "force_tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "health_check_address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "health_check_port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "id": { + "type": "string", + "readOnly": true + }, + "inter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "maintenance": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Concurrent Connections", + "x-nullable": true + }, + "maxqueue": { + "type": "integer", + "x-display-name": "Max Number of Connections", + "x-nullable": true + }, + "minconn": { + "type": "integer", + "x-nullable": true + }, + "name": { + "type": "string", + "readOnly": true + }, + "no_sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "no_tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "npn": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "observe": { + "type": "string", + "enum": [ + "layer4", + "layer7" + ], + "x-dependency": { + "ssl": { + "value": "enabled" } } - } - }, - "put": { - "description": "Commit transaction, execute all operations in transaction and return msg", - "tags": [ - "Transactions" - ], - "summary": "Commit transaction", - "operationId": "commitTransaction", - "parameters": [ - { + }, + "on-error": { + "type": "string", + "enum": [ + "fastinter", + "fail-check", + "sudden-death", + "mark-down" + ] + }, + "on-marked-down": { + "type": "string", + "enum": [ + "shutdown-sessions" + ] + }, + "on-marked-up": { + "type": "string", + "enum": [ + "shutdown-backup-sessions" + ] + }, + "pool_low_conn": { + "type": "integer", + "x-nullable": true + }, + "pool_max_conn": { + "type": "integer", + "x-nullable": true + }, + "pool_purge_delay": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "readOnly": true + }, + "proto": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "proxy-v2-options": { + "type": "array", + "items": { "type": "string", - "description": "Transaction id", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "boolean", - "default": false, - "description": "If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration.", - "name": "force_reload", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Transaction succesfully commited", - "schema": { - "$ref": "#/definitions/transaction" + "enum": [ + "authority", + "cert-cn", + "cert-key", + "cert-sig", + "crc32c", + "ssl", + "ssl-cipher", + "unique-id" + ] + }, + "x-omitempty": true + }, + "rise": { + "type": "integer", + "x-nullable": true + }, + "send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send-proxy-v2": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl_cn": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "slowstart": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "source": { + "type": "string" + }, + "ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ssl_cafile": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": "enabled" } }, - "202": { - "description": "Configuration change accepted and reload requested", - "schema": { - "$ref": "#/definitions/transaction" - }, - "headers": { - "Reload-ID": { - "type": "string", - "description": "ID of the requested reload" - } + "x-display-name": "SSL CA File" + }, + "ssl_certificate": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "ssl": { + "value": "enabled" } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "ssl_max_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_min_ver": { + "type": "string", + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] + }, + "ssl_reuse": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tfo": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tls_tickets": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": "enabled" } - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "track": { + "type": "string" + }, + "verify": { + "type": "string", + "enum": [ + "none", + "required" + ], + "x-dependency": { + "ssl": { + "value": "enabled" } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + } + }, + "verifyhost": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + "verify": { + "value": "required" } } + }, + "weight": { + "type": "integer", + "x-nullable": true + }, + "ws": { + "type": "string", + "enum": [ + "auto", + "h1", + "h2" + ], + "x-display-name": "Relaying websocket stream protocol" + } + } + }, + "runtime_server": { + "description": "Runtime transient server properties", + "type": "object", + "title": "Runtime Server", + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false, + "readOnly": true + }, + "admin_state": { + "type": "string", + "enum": [ + "ready", + "maint", + "drain" + ] + }, + "id": { + "type": "string", + "readOnly": true + }, + "name": { + "type": "string", + "readOnly": true + }, + "operational_state": { + "type": "string", + "enum": [ + "up", + "down", + "stopping" + ] + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true, + "readOnly": true } }, - "delete": { - "description": "Deletes a transaction.", - "tags": [ - "Transactions" - ], - "summary": "Delete a transaction", - "operationId": "deleteTransaction", - "parameters": [ - { - "type": "string", - "description": "Transaction id", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "204": { - "description": "Transaction deleted" - }, - "404": { - "description": "The specified resource was not found", - "schema": { - "$ref": "#/definitions/error" + "example": { + "address": "127.0.0.5", + "admin_state": "ready", + "operational_state": "up", + "port": 80, + "server_id": 1, + "server_name": "web_server" + } + }, + "runtime_servers": { + "description": "HAProxy runtime servers array", + "type": "array", + "title": "HAProxy Runtime Servers Array", + "items": { + "$ref": "#/definitions/runtime_server" + } + }, + "server": { + "description": "HAProxy backend server configuration", + "title": "Server", + "allOf": [ + { + "$ref": "#/definitions/server_params" + }, + { + "type": "object", + "required": [ + "name", + "address" + ], + "properties": { + "address": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } - } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" + "id": { + "type": "integer", + "x-nullable": true }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" + "metadata": { + "additionalProperties": { + "type": "object" } + }, + "name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true } } } + ], + "additionalProperties": false, + "example": { + "address": "10.1.1.1", + "name": "www", + "port": 8080 } }, - "/specification": { - "get": { - "description": "Return Data Plane API OpenAPI specification", - "produces": [ - "application/json" - ], - "tags": [ - "Specification" - ], - "summary": "Data Plane API Specification", - "operationId": "getSpecification", - "responses": { - "200": { - "description": "Success", - "schema": { - "type": "object" + "server_params": { + "type": "object", + "properties": { + "agent-addr": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "agent-check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "agent-port": { + "required": true } - }, - "default": { - "description": "General Error", - "schema": { - "$ref": "#/definitions/error" - }, - "headers": { - "Configuration-Version": { - "type": "integer", - "description": "Configuration file version" - } + } + }, + "agent-inter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "agent-port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "agent-send": { + "type": "string" + }, + "allow_0rtt": { + "type": "boolean" + }, + "alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "ALPN Protocols" + }, + "backup": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "cc": { + "type": "string", + "x-display-name": "TCP Congestion Control Algorithm" + }, + "check": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-pool-conn-name": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "check-reuse-pool": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check-sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "check-ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check_alpn": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Protocols" + }, + "check_proto": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-display-name": "Name" + }, + "check_sni_auto": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "check_via_socks4": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ciphers": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" } } - } - } - } - }, - "definitions": { - "acl": { - "description": "The use of Access Control Lists (ACL) provides a flexible solution to perform\ncontent switching and generally to take decisions based on content extracted\nfrom the request, the response or any environmental status.\n", - "type": "object", - "title": "ACL Lines", - "required": [ - "id", - "acl_name", - "criterion", - "value" - ], - "properties": { - "acl_name": { + }, + "ciphersuites": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "client_sigalgs": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "cookie": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "crl_file": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "curves": { + "type": "string", + "x-dependency": { + "ssl": { + "value": true + } + } + }, + "downinter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "error_limit": { + "type": "integer", + "x-display-name": "Error count" + }, + "fall": { + "type": "integer", + "x-display-name": "Nr. of consecutive failed checks", + "x-nullable": true + }, + "fastinter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "force_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "force_tlsv13": { + "description": "This field is deprecated in favor of tlsv13, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "guid": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$" + }, + "hash_key": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "health_check_address": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "health_check_port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "idle_ping": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "init-addr": { "type": "string", "pattern": "^[^\\s]+$", - "x-nullable": false + "x-nullable": true + }, + "init-state": { + "type": "string", + "enum": [ + "fully-up", + "up", + "down", + "fully-down" + ] + }, + "inter": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true + }, + "ktls": { + "type": "string", + "enum": [ + "on", + "off" + ], + "x-display-name": "Enables or disables ktls for those sockets. If enabled, kTLS will be used if the kernel supports it and the cipher is compatible.\nThis is only available on Linux kernel 4.17 and above.\nEXPERIMENTAL OPTION." + }, + "log-bufsize": { + "type": "integer", + "x-nullable": true + }, + "log_proto": { + "type": "string", + "enum": [ + "legacy", + "octet-count" + ] + }, + "maintenance": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "max_reuse": { + "type": "integer", + "x-nullable": true + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Concurrent Connections", + "x-nullable": true + }, + "maxqueue": { + "type": "integer", + "x-display-name": "Max Number of Connections", + "x-nullable": true + }, + "minconn": { + "type": "integer", + "x-nullable": true + }, + "namespace": { + "type": "string" + }, + "no_sslv3": { + "description": "This field is deprecated in favor of sslv3, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_tlsv10": { + "description": "This field is deprecated in favor of tlsv10, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_tlsv11": { + "description": "This field is deprecated in favor of tlsv11, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true + }, + "no_tlsv12": { + "description": "This field is deprecated in favor of tlsv12, and will be removed in a future release", + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true }, - "criterion": { + "no_tlsv13": { + "description": "This field is deprecated in favor of force_tlsv13, and will be removed in a future release", "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false + "enum": [ + "enabled", + "disabled" + ], + "x-deprecated": true }, - "id": { - "type": "integer", - "x-nullable": true + "no_verifyhost": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] }, - "value": { + "npn": { "type": "string", - "x-nullable": false - } - }, - "additionalProperties": false - }, - "acls": { - "description": "HAProxy ACL lines array (corresponds to acl directives)", - "type": "array", - "title": "ACL Lines Array", - "items": { - "$ref": "#/definitions/acl" - } - }, - "backend": { - "description": "HAProxy backend configuration", - "type": "object", - "title": "Backend", - "required": [ - "name" - ], - "properties": { - "adv_check": { + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "observe": { "type": "string", "enum": [ - "ssl-hello-chk", - "smtpchk", - "ldap-check", - "mysql-check", - "pgsql-check", - "tcp-check", - "redis-check" + "layer4", + "layer7" ], - "x-display-name": "Advanced Check" + "x-dependency": { + "ssl": { + "value": "enabled" + } + } }, - "balance": { - "$ref": "#/definitions/balance" + "on-error": { + "type": "string", + "enum": [ + "fastinter", + "fail-check", + "sudden-death", + "mark-down" + ] }, - "check_timeout": { + "on-marked-down": { + "type": "string", + "enum": [ + "shutdown-sessions" + ] + }, + "on-marked-up": { + "type": "string", + "enum": [ + "shutdown-backup-sessions" + ] + }, + "pool_conn_name": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "pool_low_conn": { "type": "integer", "x-nullable": true }, - "connect_timeout": { + "pool_max_conn": { "type": "integer", "x-nullable": true }, - "cookie": { - "x-dependency": { - "mode": { - "value": "http" - } - }, - "$ref": "#/definitions/cookie" + "pool_purge_delay": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true }, - "default_server": { - "$ref": "#/definitions/default_server" + "proto": { + "type": "string", + "pattern": "^[^\\s]+$" }, - "external_check": { + "proxy-v2-options": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "authority", + "cert-cn", + "cert-key", + "cert-sig", + "crc32c", + "ssl", + "ssl-cipher", + "unique-id" + ] + }, + "x-omitempty": true + }, + "redir": { + "type": "string", + "x-display-name": "Prefix" + }, + "renegotiate": { + "description": "Toggles the secure renegotiation mechanism for an SSL backend.", "type": "string", "enum": [ "enabled", "disabled" - ], - "x-display-name": "External Check" + ] }, - "external_check_command": { + "resolve-net": { "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Command" + "pattern": "^([A-Za-z0-9.:/]+)(,[A-Za-z0-9.:/]+)*$" }, - "external_check_path": { + "resolve-prefer": { "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Path" + "enum": [ + "ipv4", + "ipv6" + ] }, - "forwardfor": { - "x-dependency": { - "mode": { - "value": "http" - } - }, - "$ref": "#/definitions/forwardfor" + "resolve_opts": { + "type": "string", + "pattern": "^(allow-dup-ip|ignore-weight|prevent-dup-ip)(,(allow-dup-ip|ignore-weight|prevent-dup-ip))*$" }, - "hash_type": { - "type": "object", - "properties": { - "function": { - "type": "string", - "enum": [ - "sdbm", - "djb2", - "wt6", - "crc32" - ] - }, - "method": { - "type": "string", - "enum": [ - "map-based", - "consistent" - ] - }, - "modifier": { - "type": "string", - "enum": [ - "avalanche" - ] - } + "resolvers": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dynamic-enum": { + "operation": "getResolvers", + "property": "name" } }, - "http-use-htx": { + "rise": { + "type": "integer", + "x-nullable": true + }, + "send-proxy": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send-proxy-v2": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "send_proxy_v2_ssl_cn": { "type": "string", "enum": [ "enabled", "disabled" + ] + }, + "set-proxy-v2-tlv-fmt": { + "type": "object", + "required": [ + "id", + "value" ], - "x-dependency": { - "mode": { - "value": "http" + "properties": { + "id": { + "type": "string" + }, + "value": { + "type": "string" } } }, - "http_connection_mode": { + "shard": { + "type": "integer" + }, + "sigalgs": { "type": "string", - "enum": [ - "httpclose", - "http-server-close", - "http-keep-alive" - ], "x-dependency": { - "mode": { - "value": "http" + "ssl": { + "value": true } } }, - "http_keep_alive_timeout": { + "slowstart": { "type": "integer", - "x-dependency": { - "mode": { - "value": "http" - } - }, + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, "x-nullable": true }, - "http_pretend_keepalive": { + "sni": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "sni_auto": { "type": "string", "enum": [ "enabled", "disabled" - ], + ] + }, + "socks4": { + "type": "string", + "pattern": "^[^\\s]+$", "x-dependency": { - "mode": { - "value": "http" + "check-via-socks4": { + "required": true } } }, - "http_request_timeout": { - "type": "integer", + "source": { + "type": "string" + }, + "ssl": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "ssl_cafile": { + "type": "string", + "pattern": "^[^\\s]+$", "x-dependency": { - "mode": { - "value": "http" + "ssl": { + "value": "enabled" } }, - "x-nullable": true + "x-display-name": "SSL CA File" }, - "httpchk": { + "ssl_certificate": { + "type": "string", + "pattern": "^[^\\s]+$", "x-dependency": { - "mode": { - "value": "http" + "ssl": { + "value": "enabled" } - }, - "$ref": "#/definitions/httpchk" + } }, - "log_tag": { + "ssl_max_ver": { "type": "string", - "pattern": "^[^\\s]+$" + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] }, - "mode": { + "ssl_min_ver": { "type": "string", "enum": [ - "http", - "tcp" + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" ] }, - "name": { + "ssl_reuse": { "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false + "enum": [ + "enabled", + "disabled" + ] }, - "queue_timeout": { - "type": "integer", - "x-nullable": true + "sslv3": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] }, - "redispatch": { - "$ref": "#/definitions/redispatch" + "stick": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] }, - "retries": { - "type": "integer", - "x-nullable": true + "strict-maxconn": { + "type": "boolean" }, - "server_timeout": { + "tcp_md5sig": { + "type": "string", + "pattern": "^[^\\s]+$" + }, + "tcp_ut": { "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-duration": true, "x-nullable": true }, - "stick_table": { - "type": "object", - "properties": { - "expire": { - "type": "integer", - "x-nullable": true - }, - "keylen": { - "type": "integer", - "x-display-name": "Key Length", - "x-nullable": true - }, - "nopurge": { - "type": "boolean", - "x-display-name": "No Purge" - }, - "peers": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "size": { - "type": "integer", - "x-nullable": true - }, - "store": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "type": { - "type": "string", - "enum": [ - "ip", - "ipv6", - "integer", - "string", - "binary" - ] + "tfo": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tls_tickets": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ], + "x-dependency": { + "ssl": { + "value": "enabled" } } - } - }, - "additionalProperties": false, - "example": { - "balance": { - "algorithm": "roundrobin" }, - "forwardfor": { - "enabled": true + "tlsv10": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] }, - "httpchk": { - "method": "OPTIONS", - "uri": "/check", - "version": "HTTP/1.1" + "tlsv11": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] }, - "mode": "http", - "name": "test_backend" + "tlsv12": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "tlsv13": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] + }, + "track": { + "type": "string" + }, + "verify": { + "type": "string", + "enum": [ + "none", + "required" + ], + "x-dependency": { + "ssl": { + "value": "enabled" + } + } + }, + "verifyhost": { + "type": "string", + "x-dependency": { + "ssl": { + "value": "enabled" + }, + "verify": { + "value": "required" + } + } + }, + "weight": { + "type": "integer", + "x-nullable": true + }, + "ws": { + "type": "string", + "enum": [ + "auto", + "h1", + "h2" + ], + "x-display-name": "Relaying websocket stream protocol" + } } }, - "backend_switching_rule": { - "description": "HAProxy backend switching rule configuration (corresponds to use_backend directive)", + "server_switching_rule": { + "description": "HAProxy server switching rule configuration (corresponds to use-server directive)", "type": "object", - "title": "Backend Switching Rule", + "title": "Server Switching Rule", "required": [ - "id", - "name" + "target_server" ], "properties": { "cond": { @@ -17875,995 +98147,1367 @@ func init() { "property": "acl_name" } }, - "id": { - "type": "integer", - "x-nullable": true + "metadata": { + "additionalProperties": { + "type": "object" + } }, - "name": { + "target_server": { "type": "string", "pattern": "^[^\\s]+$", - "x-display-name": "Backend Name", "x-dynamic-enum": { - "operation": "getBackends", + "operation": "getServers", "property": "name" }, "x-nullable": false } - }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ req_ssl_sni -i www.example.com }", - "id": 0, - "name": "test_backend" + }, + "additionalProperties": false, + "example": { + "cond": "if", + "cond_test": "{ req_ssl_sni -i www.example.com }", + "target_server": "www" + } + }, + "server_switching_rules": { + "description": "HAProxy backend server switching rules array (corresponds to use-server directives)", + "type": "array", + "title": "Server Switching Rules Array", + "items": { + "$ref": "#/definitions/server_switching_rule" + } + }, + "server_template": { + "description": "Set a template to initialize servers with shared parameters.", + "title": "Server template", + "allOf": [ + { + "$ref": "#/definitions/server_params" + }, + { + "type": "object", + "required": [ + "prefix", + "num_or_range", + "fqdn" + ], + "properties": { + "fqdn": { + "type": "string", + "x-nullable": false + }, + "id": { + "type": "integer", + "x-nullable": true + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "num_or_range": { + "type": "string", + "x-nullable": false + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-nullable": true + }, + "prefix": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": false + } + } + } + ], + "additionalProperties": false, + "example": { + "fqdn": "google.com", + "num_or_range": "1-3", + "port": 80, + "prefix": "srv" + } + }, + "server_templates": { + "description": "HAProxy backend server templates array", + "type": "array", + "title": "Server templates", + "items": { + "$ref": "#/definitions/server_template" + } + }, + "servers": { + "description": "HAProxy backend servers array", + "type": "array", + "title": "Servers", + "items": { + "$ref": "#/definitions/server" + } + }, + "site": { + "description": "Site configuration. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration\nendpoints.\n", + "type": "object", + "title": "Site", + "required": [ + "name" + ], + "properties": { + "farms": { + "type": "array", + "items": { + "$ref": "#/definitions/SiteFarmsItems0" + }, + "x-omitempty": true + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + }, + "service": { + "type": "object", + "properties": { + "http_connection_mode": { + "type": "string", + "enum": [ + "http-tunnel", + "httpclose", + "forced-close", + "http-server-close", + "http-keep-alive" + ], + "x-dependency": { + "mode": { + "value": "http" + } + }, + "x-display-name": "HTTP Connection Mode" + }, + "listeners": { + "type": "array", + "items": { + "$ref": "#/definitions/bind" + }, + "x-omitempty": true + }, + "maxconn": { + "type": "integer", + "x-display-name": "Max Connections", + "x-nullable": true + }, + "mode": { + "type": "string", + "enum": [ + "http", + "tcp" + ] + } + } + } + }, + "additionalProperties": false, + "example": { + "farms": [ + { + "balance": { + "algorithm": "roundrobin" + }, + "mode": "http", + "name": "www_backend", + "servers": [ + { + "address": "127.0.1.1", + "name": "www_server", + "port": 4567 + }, + { + "address": "127.0.1.2", + "name": "www_server_new", + "port": 4567 + } + ], + "use_as": "default" + } + ], + "name": "test_site", + "service": { + "http_connection_mode": "httpclose", + "maxconn": 2000, + "mode": "http" + } } }, - "backend_switching_rules": { - "description": "HAProxy backend switching rules array (corresponds to use_backend directives)", + "sites": { + "description": "Sites array. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration\nendpoints.\n", "type": "array", - "title": "Backend Switching Rules Array", + "title": "Sites", "items": { - "$ref": "#/definitions/backend_switching_rule" + "$ref": "#/definitions/site" } }, - "backends": { - "description": "HAProxy backends array", - "type": "array", - "title": "Backends", - "items": { - "$ref": "#/definitions/backend" + "smtpchk_params": { + "type": "object", + "properties": { + "domain": { + "type": "string" + }, + "hello": { + "type": "string" + } } }, - "balance": { + "source": { "type": "object", + "required": [ + "address" + ], "properties": { - "algorithm": { + "address": { + "type": "string" + }, + "address_second": { + "type": "string" + }, + "hdr": { "type": "string", - "enum": [ - "roundrobin", - "static-rr", - "leastconn", - "first", - "source", - "uri", - "url_param", - "random" - ] + "x-dependency": { + "usesrc": { + "value": "hdr_ip" + } + } }, - "arguments": { - "type": "array", - "items": { - "type": "string", - "pattern": "^[^\\s]+$" - }, + "interface": { + "type": "string" + }, + "occ": { + "type": "string", "x-dependency": { - "algorithm": { - "value": [ - "uri", - "url_param" - ] + "usesrc": { + "value": "hdr_ip" } } + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "port_second": { + "type": "integer", + "maximum": 65535, + "minimum": 1 + }, + "usesrc": { + "type": "string", + "enum": [ + "address", + "client", + "clientip", + "hdr_ip" + ] } } }, - "bind": { - "description": "HAProxy frontend bind configuration", + "spoe_agent": { + "description": "SPOE agent configuration", "type": "object", - "title": "Bind", + "title": "SPOE agent", "required": [ "name" ], "properties": { - "accept_proxy": { - "type": "boolean" - }, - "address": { + "async": { "type": "string", - "pattern": "^[^\\s]+$" + "enum": [ + "enabled", + "disabled" + ] }, - "allow_0rtt": { - "type": "boolean" + "continue-on-error": { + "type": "string", + "enum": [ + "enabled" + ] }, - "alpn": { + "dontlog-normal": { "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "ALPN Protocols" + "enum": [ + "enabled", + "disabled" + ] }, - "name": { + "engine-name": { + "type": "string" + }, + "force-set-var": { "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false + "enum": [ + "enabled" + ] }, - "port": { + "groups": { + "type": "string" + }, + "hello_timeout": { "type": "integer", - "maximum": 65535, - "minimum": 1, - "x-nullable": true + "x-default-unit": "ms", + "x-duration": true }, - "process": { + "idle_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true + }, + "log": { + "$ref": "#/definitions/log_targets" + }, + "max-frame-size": { + "type": "integer" + }, + "max-waiting-frames": { + "type": "integer" + }, + "maxconnrate": { + "type": "integer" + }, + "maxerrrate": { + "type": "integer" + }, + "messages": { + "type": "string" + }, + "name": { + "type": "string" + }, + "option_set-on-error": { "type": "string", - "pattern": "^[^\\s]+$" + "pattern": "^[A-Za-z0-9-_.]+$" }, - "ssl": { - "type": "boolean" + "option_set-process-time": { + "type": "string", + "pattern": "^[A-Za-z0-9-_.]+$" }, - "ssl_cafile": { + "option_set-total-time": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": true - } - }, - "x-display-name": "SSL CA File" + "pattern": "^[A-Za-z0-9-_.]+$" }, - "ssl_certificate": { + "option_var-prefix": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": true - } - } + "pattern": "^[A-Za-z0-9-_.]+$" }, - "tcp_user_timeout": { - "type": "integer", - "x-nullable": true + "pipelining": { + "type": "string", + "enum": [ + "enabled", + "disabled" + ] }, - "transparent": { - "type": "boolean" + "processing_timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-duration": true }, - "v4v6": { - "type": "boolean" + "register-var-names": { + "type": "string" }, - "verify": { + "send-frag-payload": { "type": "string", "enum": [ - "none", - "optional", - "required" - ], - "x-dependency": { - "ssl": { - "value": "enabled" - } - } + "enabled", + "disabled" + ] + }, + "use-backend": { + "type": "string" } - }, - "additionalProperties": false, - "example": { - "address": "127.0.0.1", - "name": "http", - "port": 80 } }, - "binds": { - "description": "HAProxy frontend binds array (corresponds to bind directives)", + "spoe_agents": { + "description": "SPOE Agents of one scope in SPOE file", "type": "array", - "title": "Binds", + "title": "SPOE Agents", "items": { - "$ref": "#/definitions/bind" + "$ref": "#/definitions/spoe_agent" } }, - "cookie": { + "spoe_files": { + "description": "SPOE files", + "type": "array", + "title": "SPOE files", + "items": { + "type": "string" + }, + "x-omitempty": true + }, + "spoe_group": { + "description": "SPOE group section configuration", "type": "object", + "title": "SPOE group", "required": [ "name" ], "properties": { - "domain": { - "type": "array", - "items": { - "type": "string", - "pattern": "^[^\\s]+$" - } - }, - "dynamic": { - "type": "boolean" - }, - "httponly": { - "type": "boolean" + "messages": { + "type": "string" }, - "indirect": { - "type": "boolean" + "name": { + "type": "string" + } + } + }, + "spoe_groups": { + "description": "SPOE Groups of one scope in SPOE file", + "type": "array", + "title": "SPOE Groups", + "items": { + "$ref": "#/definitions/spoe_group" + } + }, + "spoe_message": { + "description": "SPOE message section configuration", + "type": "object", + "title": "SPOE message", + "required": [ + "name" + ], + "properties": { + "acl": { + "$ref": "#/definitions/acls" }, - "maxidle": { - "type": "integer", - "pattern": "^[^\\d+$]" + "args": { + "type": "string" }, - "maxlife": { - "type": "integer", - "pattern": "^[^\\d+$]" + "event": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + }, + "x-display-name": "Condition Test" + }, + "name": { + "type": "string", + "enum": [ + "on-backend-http-request", + "on-backend-tcp-request", + "on-client-session", + "on-frontend-http-request", + "on-frontend-tcp-request", + "on-http-response", + "on-server-session", + "on-tcp-response" + ] + } + } }, "name": { + "type": "string" + } + } + }, + "spoe_messages": { + "description": "SPOE Messages of one scope in SPOE file", + "type": "array", + "title": "SPOE Messages", + "items": { + "$ref": "#/definitions/spoe_message" + } + }, + "spoe_scope": { + "description": "SPOE scope name", + "type": "string", + "title": "SPOE scope" + }, + "spoe_scopes": { + "description": "All SPOE Scopes", + "type": "array", + "title": "SPOE Scopes", + "items": { + "$ref": "#/definitions/spoe_scope" + } + }, + "spoe_transaction": { + "description": "SPOE configuration transaction", + "type": "object", + "title": "SPOE configuration transaction", + "properties": { + "_version": { + "type": "integer" + }, + "id": { "type": "string", "pattern": "^[^\\s]+$" }, - "nocache": { - "type": "boolean" - }, - "postonly": { - "type": "boolean" - }, - "preserve": { - "type": "boolean" - }, - "secure": { - "type": "boolean" - }, - "type": { + "status": { "type": "string", "enum": [ - "rewrite", - "insert", - "prefix" + "failed", + "in_progress", + "success" ] } + }, + "example": { + "_version": 2, + "id": "273e3385-2d0c-4fb1-aa27-93cbb31ff203", + "status": "in_progress" } }, - "default_server": { + "spoe_transactions": { + "description": "SPOE Configuration transactions array", + "type": "array", + "title": "SPOE Transactions array", + "items": { + "$ref": "#/definitions/spoe_transaction" + } + }, + "sslCertificateIdCertificateId": { "type": "object", "properties": { - "fall": { - "type": "integer", - "x-nullable": true + "hash_algorithm": { + "type": "string" }, - "inter": { - "type": "integer", - "x-nullable": true + "issuer_key_hash": { + "type": "string" }, - "port": { - "type": "integer", - "maximum": 65535, - "minimum": 1, - "x-nullable": true + "issuer_name_hash": { + "type": "string" }, - "rise": { - "type": "integer", - "x-nullable": true + "serial_number": { + "type": "string" } - } + }, + "x-go-gen-location": "models", + "x-go-name": "CertificateId" }, - "defaults": { - "description": "HAProxy defaults configuration", + "ssl_ca_file": { + "description": "A file containing one or more SSL/TLS certificates and keys", "type": "object", - "title": "Defaults", + "title": "SSL File", "properties": { - "adv_check": { - "type": "string", - "enum": [ - "ssl-hello-chk", - "smtpchk", - "ldap-check", - "mysql-check", - "pgsql-check", - "tcp-check", - "redis-check" - ], - "x-display-name": "Advanced Check" - }, - "balance": { - "$ref": "#/definitions/balance" + "count": { + "type": "string" }, - "check_timeout": { - "type": "integer", - "x-nullable": true + "file": { + "type": "string" }, - "clflog": { - "type": "boolean", - "x-display-name": "CLF Log" + "storage_name": { + "type": "string" + } + } + }, + "ssl_ca_files": { + "description": "Array of SSL CA files", + "type": "array", + "title": "SSL CA Files Array", + "items": { + "$ref": "#/definitions/ssl_ca_file" + } + }, + "ssl_certificate": { + "description": "A file containing one or more SSL/TLS certificates and keys", + "type": "object", + "title": "SSL File", + "properties": { + "algorithm": { + "type": "string" }, - "client_timeout": { - "type": "integer", - "x-nullable": true + "authority_key_id": { + "type": "string" }, - "clitcpka": { + "chain_issuer": { "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "Client TCP Keep Alive" - }, - "connect_timeout": { - "type": "integer", - "x-nullable": true + "x-omitempty": true }, - "contstats": { + "chain_subject": { "type": "string", - "enum": [ - "enabled" - ], - "x-display-name": "Continuous Statistics" + "x-omitempty": true }, - "cookie": { - "$ref": "#/definitions/cookie" + "description": { + "type": "string" }, - "default_backend": { + "domains": { "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-dynamic-enum": { - "operation": "getBackends", - "property": "name" - } + "x-omitempty": true, + "readOnly": true }, - "default_server": { - "$ref": "#/definitions/default_server" + "file": { + "type": "string" }, - "dontlognull": { + "ip_addresses": { "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "Don't Log Null" - }, - "error_files": { - "type": "array", - "items": { - "$ref": "#/definitions/errorfile" - }, - "x-go-name": "ErrorFiles" + "x-omitempty": true, + "readOnly": true }, - "external_check": { + "issuers": { "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "External Check" + "x-omitempty": true, + "readOnly": true }, - "external_check_command": { + "not_after": { "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Command" + "format": "date-time", + "x-go-custom-tag": "gorm:\"type:timestamp with time zone\"", + "x-nullable": true, + "readOnly": true }, - "external_check_path": { + "not_before": { "type": "string", - "pattern": "^[^\\s]+$", - "x-display-name": "External Check Path" + "format": "date-time", + "x-go-custom-tag": "gorm:\"type:timestamp with time zone\"", + "x-nullable": true, + "readOnly": true }, - "forwardfor": { - "$ref": "#/definitions/forwardfor" + "serial": { + "type": "string" }, - "http-use-htx": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "HTTP Use HTX" + "sha1_finger_print": { + "type": "string" }, - "http_connection_mode": { - "type": "string", - "enum": [ - "httpclose", - "http-server-close", - "http-keep-alive" - ] + "sha256_finger_print": { + "type": "string" }, - "http_keep_alive_timeout": { + "size": { + "description": "File size in bytes.", "type": "integer", - "x-nullable": true + "x-nullable": true, + "readOnly": true }, - "http_pretend_keepalive": { + "status": { + "description": "Only set when using the runtime API.", "type": "string", - "enum": [ - "enabled", - "disabled" - ] + "x-omitempty": true, + "readOnly": true }, - "http_request_timeout": { - "type": "integer", - "x-nullable": true - }, - "httpchk": { - "$ref": "#/definitions/httpchk" - }, - "httplog": { - "type": "boolean", - "x-display-name": "HTTP Log" - }, - "log_format": { + "storage_name": { "type": "string" }, - "log_format_sd": { - "type": "string", - "x-display-name": "Log Format SD" - }, - "log_separate_errors": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ] - }, - "log_tag": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true - }, - "mode": { - "type": "string", - "enum": [ - "tcp", - "http" - ] - }, - "queue_timeout": { - "type": "integer", - "x-nullable": true + "subject": { + "type": "string" }, - "redispatch": { - "$ref": "#/definitions/redispatch" + "subject_alternative_names": { + "type": "string" }, - "retries": { - "type": "integer", - "x-nullable": true + "subject_key_id": { + "type": "string" + } + } + }, + "ssl_certificate_id": { + "description": "SSL Certificate ID", + "type": "object", + "title": "SSL Certificate ID", + "properties": { + "certificate_id": { + "$ref": "#/definitions/sslCertificateIdCertificateId" }, - "server_timeout": { - "type": "integer", - "x-nullable": true + "certificate_id_key": { + "type": "string" }, - "tcplog": { - "type": "boolean", - "x-display-name": "TCP Log" + "certificate_path": { + "type": "string" } - }, - "additionalProperties": false + } + }, + "ssl_certificates": { + "description": "Array of ssl certificate files", + "type": "array", + "title": "SSL Certificate Files Array", + "items": { + "$ref": "#/definitions/ssl_certificate" + } }, - "endpoint": { - "description": "Endpoint definition", + "ssl_crl": { + "description": "A file containing one or more SSL/TLS CRLs", "type": "object", - "title": "Endpoint", + "title": "SSL CRL File", "properties": { "description": { - "description": "Endpoint description", "type": "string" }, - "title": { - "description": "Endpoint title", + "file": { "type": "string" }, - "url": { - "description": "Path to the endpoint", + "storage_name": { "type": "string" } } }, - "endpoints": { - "description": "Collection of endpoints", + "ssl_crl_entries": { "type": "array", - "title": "Endpoints Array", "items": { - "$ref": "#/definitions/endpoint" + "$ref": "#/definitions/ssl_crl_entry" } }, - "error": { - "description": "API Error", + "ssl_crl_entry": { + "description": "A certificate revocation list entry.", "type": "object", - "title": "Error", - "required": [ - "code", - "message" - ], + "title": "One CRL Entry", "properties": { - "code": { - "type": "integer", - "x-nullable": true + "issuer": { + "type": "string" }, - "message": { + "last_update": { "type": "string", - "x-nullable": true + "format": "date" + }, + "next_update": { + "type": "string", + "format": "date" + }, + "revoked_certificates": { + "type": "array", + "items": { + "$ref": "#/definitions/SslCrlEntryRevokedCertificatesItems0" + }, + "x-omitempty": true + }, + "signature_algorithm": { + "type": "string" + }, + "status": { + "type": "string" + }, + "storage_name": { + "type": "string" + }, + "version": { + "type": "string" } - }, - "additionalProperties": { - "type": "string" } }, - "errorfile": { + "ssl_crls": { + "description": "Array of ssl crl files", + "type": "array", + "title": "SSL CRL Files Array", + "items": { + "$ref": "#/definitions/ssl_crl" + } + }, + "ssl_crt_list": { + "description": "SSL Crt List file", "type": "object", + "title": "SSL Crt List", "properties": { - "code": { - "type": "integer", - "enum": [ - 200, - 400, - 403, - 405, - 408, - 425, - 429, - 500, - 502, - 503, - 504 - ] - }, "file": { "type": "string" } - }, - "x-display-name": "Error File" + } }, - "filter": { - "description": "HAProxy filters", + "ssl_crt_list_entries": { + "description": "Array of SSL Crt List Entry", + "type": "array", + "title": "SSL Crt List Entry Array", + "items": { + "$ref": "#/definitions/ssl_crt_list_entry" + } + }, + "ssl_crt_list_entry": { + "description": "SSL Crt List Entry", "type": "object", - "title": "Filter", - "required": [ - "id", - "type" - ], + "title": "SSL Crt List Entry", "properties": { - "cache_name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "cache" - } - } + "file": { + "type": "string" }, - "id": { + "line_number": { "type": "integer", - "x-nullable": true - }, - "spoe_config": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "spoe" - } - } - }, - "spoe_engine": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "value": "spoe" - } - } + "minimum": 0, + "x-nullable": false }, - "trace_hexdump": { - "type": "boolean", - "x-dependency": { - "type": { - "value": "trace" - } - } + "sni_filter": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "SNIFilter", + "x-omitempty": true }, - "trace_name": { + "ssl_bind_config": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "value": "trace" - } - } + "x-go-name": "SSLBindConfig" + } + } + }, + "ssl_crt_list_file": { + "description": "A file referencing one or more certificates with their configuration.", + "type": "object", + "title": "SSL CRT List File", + "properties": { + "description": { + "type": "string" }, - "trace_rnd_forwarding": { - "type": "boolean", - "x-dependency": { - "type": { - "value": "trace" - } - }, - "x-display-name": "Trace Random Forwarding" + "file": { + "type": "string" }, - "trace_rnd_parsing": { - "type": "boolean", - "x-dependency": { - "type": { - "value": "trace" - } - }, - "x-display-name": "Trace Random Parsing" + "size": { + "description": "File size in bytes.", + "type": "integer", + "x-nullable": true }, - "type": { - "type": "string", - "enum": [ - "trace", - "compression", - "spoe", - "cache" - ], - "x-nullable": false + "storage_name": { + "type": "string" } - }, - "additionalProperties": false, - "example": { - "id": 0, - "trace_name": "name", - "trace_rnd_parsing": true, - "type": "trace" } }, - "filters": { - "description": "HAProxy filters array (corresponds to filter directive)", + "ssl_crt_list_files": { + "description": "List of SSL certificate list files (crt-list)", "type": "array", - "title": "Filters Array", + "title": "List of SSL certificate list files", "items": { - "$ref": "#/definitions/filter" + "$ref": "#/definitions/ssl_crt_list_file" } }, - "forwardfor": { + "ssl_crt_lists": { + "description": "Array of SSL Crt List", + "type": "array", + "title": "SSL Crt List Array", + "items": { + "$ref": "#/definitions/ssl_crt_list" + } + }, + "ssl_front_use": { + "description": "Assign a certificate to the current frontend", "type": "object", + "title": "SSL Frontend Use certificate", "required": [ - "enabled" + "certificate" ], "properties": { - "enabled": { - "type": "string", - "enum": [ - "enabled" - ] + "allow_0rtt": { + "type": "boolean" }, - "except": { + "alpn": { "type": "string", - "pattern": "^[^\\s]+$" + "x-display-name": "ALPN Protocols" }, - "header": { + "ca_file": { + "type": "string" + }, + "certificate": { + "description": "Certificate filename", "type": "string", - "pattern": "^[^\\s]+$" + "pattern": "^[^\\s]+$", + "x-nullable": false }, - "ifnone": { - "type": "boolean" - } - }, - "x-display-name": "ForwardFor" - }, - "frontend": { - "description": "HAProxy frontend configuration", - "type": "object", - "title": "Frontend", - "required": [ - "name" - ], - "properties": { - "clflog": { - "type": "boolean", - "x-dependency": { - "mode": { - "value": "http" - } - }, - "x-display-name": "CLF Log" + "ciphers": { + "type": "string" }, - "client_timeout": { - "type": "integer", - "x-nullable": true + "ciphersuites": { + "type": "string" }, - "clitcpka": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "mode": { - "value": "tcp" - } - }, - "x-display-name": "Client TCP Keep Alive" + "client_sigalgs": { + "type": "string" }, - "contstats": { - "type": "string", - "enum": [ - "enabled" - ], - "x-display-name": "Continous Statistics" + "crl_file": { + "type": "string" }, - "default_backend": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-dynamic-enum": { - "operation": "getBackends", - "property": "name" - } + "curves": { + "type": "string" }, - "dontlognull": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-display-name": "Don't Log Null" + "ecdhe": { + "type": "string" }, - "forwardfor": { - "x-dependency": { - "mode": { - "value": "http" - } - }, - "$ref": "#/definitions/forwardfor" + "issuer": { + "description": "OCSP issuer filename", + "type": "string" }, - "http-use-htx": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "mode": { - "value": "http" - } - }, - "x-display-name": "HTTP Use HTX" + "key": { + "description": "Private key filename", + "type": "string" }, - "http_connection_mode": { - "type": "string", - "enum": [ - "httpclose", - "http-server-close", - "http-keep-alive" - ], - "x-dependency": { - "mode": { - "value": "http" - } + "metadata": { + "additionalProperties": { + "type": "object" } }, - "http_keep_alive_timeout": { - "type": "integer", - "x-dependency": { - "mode": { - "value": "http" - } - }, - "x-nullable": true - }, - "http_request_timeout": { - "type": "integer", - "x-dependency": { - "mode": { - "value": "http" - } - }, - "x-nullable": true + "no_alpn": { + "type": "boolean" }, - "httplog": { - "type": "boolean", - "x-dependency": { - "mode": { - "value": "http" - } - }, - "x-display-name": "HTTP Log" + "no_ca_names": { + "type": "boolean" }, - "log_format": { + "npn": { "type": "string" }, - "log_format_sd": { - "type": "string", - "x-display-name": "Log Format SD" + "ocsp": { + "description": "OCSP response filename", + "type": "string" }, - "log_separate_errors": { + "ocsp_update": { + "description": "Automatic OCSP response update", "type": "string", "enum": [ "enabled", "disabled" ] }, - "log_tag": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$" + "sctl": { + "description": "Signed Certificate Timestamp List filename", + "type": "string" }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true + "sigalgs": { + "type": "string" }, - "mode": { + "ssl_max_ver": { "type": "string", "enum": [ - "http", - "tcp" + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" ] }, - "name": { + "ssl_min_ver": { "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false + "enum": [ + "SSLv3", + "TLSv1.0", + "TLSv1.1", + "TLSv1.2", + "TLSv1.3" + ] }, - "tcplog": { - "type": "boolean", - "x-dependency": { - "mode": { - "value": "tcp" - } - }, - "x-display-name": "TCP Log" + "verify": { + "type": "string", + "enum": [ + "none", + "optional", + "required" + ] } }, - "additionalProperties": false, - "example": { - "default_backend": "test_backend", - "http_connection_mode": "http-keep-alive", - "maxconn": 2000, - "mode": "http", - "name": "test_frontend" - } + "x-go-name": "SSLFrontUse" }, - "frontends": { - "description": "HAProxy frontends array", + "ssl_front_uses": { "type": "array", - "title": "Frontends", "items": { - "$ref": "#/definitions/frontend" - } + "$ref": "#/definitions/ssl_front_use" + }, + "x-go-name": "SSLFrontUses", + "x-omitempty": true }, - "global": { - "description": "HAProxy global configuration", + "ssl_ocsp_response": { + "description": "SSL OCSP Response", "type": "object", - "title": "Global", + "title": "SSL OCSP Response", "properties": { - "cpu_maps": { + "base64_response": { + "type": "string" + }, + "ocsp_response_status": { + "type": "string" + }, + "produced_at": { + "type": "string", + "format": "date" + }, + "responder_id": { "type": "array", "items": { - "type": "object", - "required": [ - "process", - "cpu_set" - ], - "properties": { - "cpu_set": { - "type": "string", - "x-display-name": "CPU Set" - }, - "process": { - "type": "string", - "x-display-name": "Process/Thread Set" - } + "type": "string" + }, + "x-omitempty": true + }, + "response_type": { + "type": "string" + }, + "responses": { + "type": "object", + "properties": { + "cert_status": { + "type": "string" }, - "x-go-name": "CPUMap" + "certificate_id": { + "$ref": "#/definitions/sslCertificateIdCertificateId" + }, + "next_update": { + "type": "string", + "format": "date" + }, + "revocation_reason": { + "type": "string", + "x-omitempty": true + }, + "this_update": { + "type": "string", + "format": "date" + } }, - "x-display-name": "CPU Maps", - "x-go-name": "CPUMaps" + "x-go-name": "OCSPResponses" }, - "daemon": { + "version": { + "type": "string" + } + } + }, + "ssl_ocsp_update": { + "description": "SSL OCSP Update", + "type": "object", + "title": "SSL OCSP Update", + "properties": { + "cert_id": { + "type": "string" + }, + "failures": { + "type": "integer" + }, + "last_update": { + "type": "string" + }, + "last_update_status": { + "type": "integer" + }, + "last_update_status_str": { + "type": "string" + }, + "next_update": { + "type": "string" + }, + "path": { + "type": "string" + }, + "successes": { + "type": "integer" + } + } + }, + "ssl_options": { + "type": "object", + "properties": { + "acme_scheduler": { "type": "string", "enum": [ - "enabled", - "disabled" - ] + "auto", + "off" + ], + "x-display-name": "ACME Scheduler" }, - "external_check": { - "type": "boolean", - "x-display-name": "External Check" + "ca_base": { + "type": "string", + "x-display-name": "SSL CA Certificates Base Directory" }, - "master-worker": { - "type": "boolean", - "x-display-name": "Master Worker Mode" + "crt_base": { + "type": "string", + "x-display-name": "SSL Certificates Base Directory" }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections" + "default_bind_ciphers": { + "type": "string", + "x-display-name": "SSL Default Bind Ciphers" }, - "nbproc": { - "type": "integer", - "x-display-name": "Number of Processes" + "default_bind_ciphersuites": { + "type": "string", + "x-display-name": "SSL Default Bind Ciphersuites" }, - "nbthread": { - "type": "integer", - "x-display-name": "Number of Threads" + "default_bind_client_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Bind Client Sigalgs" }, - "pidfile": { + "default_bind_curves": { "type": "string", - "x-display-name": "PID File" + "x-display-name": "SSL Default Bind Curves" }, - "runtime_apis": { + "default_bind_options": { + "type": "string", + "x-display-name": "SSL Default Bind Options" + }, + "default_bind_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Bind Sigalgs" + }, + "default_server_ciphers": { + "type": "string", + "x-display-name": "SSL Default Server Ciphers" + }, + "default_server_ciphersuites": { + "type": "string", + "x-display-name": "SSL Default Server Ciphersuites" + }, + "default_server_client_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Server Client Sigalgs" + }, + "default_server_curves": { + "type": "string", + "x-display-name": "SSL Default Server Curves" + }, + "default_server_options": { + "type": "string", + "x-display-name": "SSL Default Server Options" + }, + "default_server_sigalgs": { + "type": "string", + "x-display-name": "SSL Default Server Sigalgs" + }, + "dh_param_file": { + "type": "string" + }, + "engines": { "type": "array", "items": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "exposeFdListeners": { - "type": "boolean", - "x-display-name": "Expose FD Listeners" - }, - "level": { - "type": "string", - "enum": [ - "user", - "operator", - "admin" - ] - }, - "mode": { - "type": "string", - "pattern": "^[^\\s]+$" - }, - "process": { - "type": "string", - "pattern": "^[^\\s]+$" - } - }, - "x-go-name": "RuntimeAPI" + "$ref": "#/definitions/SslOptionsEnginesItems0" }, - "x-display-name": "Runtime APIs", - "x-go-name": "RuntimeAPIs" + "x-display-name": "SSL Engines", + "x-go-name": "SslEngines", + "x-omitempty": true + }, + "issuers_chain_path": { + "type": "string" }, - "ssl_default_bind_ciphers": { + "load_extra_files": { "type": "string", - "x-display-name": "SSL Default Bind Ciphers" + "x-display-name": "SSL Load Extra Files" + }, + "maxsslconn": { + "type": "integer", + "x-display-name": "Maximum per-process number of concurrent SSL connections" + }, + "maxsslrate": { + "type": "integer", + "x-display-name": "Maximum per-process number of SSL sessions per second" }, - "ssl_default_bind_options": { + "mode_async": { "type": "string", - "x-display-name": "SSL Default Bind Options" + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Asynchronous TLS I/O operations" }, - "stats_timeout": { + "passphrase_cmd": { + "type": "string" + }, + "propquery": { + "type": "string", + "x-display-name": "SSL Query String Property" + }, + "provider": { + "type": "string", + "x-display-name": "SSL Provider" + }, + "provider_path": { + "type": "string", + "x-display-name": "SSL Provider Path" + }, + "security_level": { "type": "integer", + "maximum": 5, + "minimum": 0, "x-nullable": true }, - "tune_ssl_default_dh_param": { - "type": "integer", - "x-display-name": "SSL Default DH Parameter Size" + "server_verify": { + "type": "string", + "enum": [ + "none", + "required" + ], + "x-display-name": "Verify server certificates" + }, + "skip_self_issued_ca": { + "type": "boolean", + "x-display-name": "Self issued CA, aka x509 root CA" } - }, - "additionalProperties": false + } }, - "http_request_rule": { - "description": "HAProxy HTTP request rule configuration (corresponds to http-request directives)", + "ssl_providers": { + "description": "SSL Providers", + "type": "object", + "title": "SSL Providers", + "properties": { + "providers": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "stats_auth": { + "type": "object", + "required": [ + "user", + "passwd" + ], + "properties": { + "passwd": { + "type": "string" + }, + "user": { + "type": "string" + } + } + }, + "stats_http_request": { "type": "object", - "title": "HTTP Request Rule", "required": [ - "id", "type" ], "properties": { - "acl_file": { + "cond": { + "type": "string" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + } + } + }, + "realm": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { "type": { + "value": "auth" + } + } + }, + "type": { + "type": "string", + "enum": [ + "allow", + "deny", + "auth" + ] + } + } + }, + "stats_options": { + "type": "object", + "properties": { + "stats_admin": { + "type": "boolean", + "x-display-name": "Stats Admin" + }, + "stats_admin_cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-dependency": { + "stats_admin": { "required": true, - "value": [ - "add-acl", - "del-acl" - ] + "value": true } }, - "x-display-name": "ACL File" + "x-display-name": "Stats Admin Condition" }, - "acl_keyfmt": { + "stats_admin_cond_test": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { - "required": true, - "value": [ - "add-acl", - "del-acl" - ] + "stats_admin_cond": { + "required": true } }, - "x-display-name": "ACL Key Format" + "x-display-name": "Stats Admin Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } }, - "auth_realm": { + "stats_auths": { + "type": "array", + "items": { + "$ref": "#/definitions/stats_auth" + }, + "x-display-name": "Stats Auths", + "x-omitempty": true + }, + "stats_enable": { + "type": "boolean", + "x-display-name": "Stats Enable" + }, + "stats_hide_version": { + "type": "boolean", + "x-display-name": "Stats Hide Version" + }, + "stats_http_requests": { + "type": "array", + "items": { + "$ref": "#/definitions/stats_http_request" + }, + "x-display-name": "Stats HTTP Requests", + "x-omitempty": true + }, + "stats_maxconn": { + "type": "integer", + "minimum": 1 + }, + "stats_realm": { + "type": "boolean", + "x-display-name": "Stats Realm" + }, + "stats_realm_realm": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { - "value": "auth" + "stats_realm": { + "required": true, + "value": true } }, - "x-display-name": "Authentication Realm" + "x-nullable": true + }, + "stats_refresh_delay": { + "type": "integer", + "minimum": 0, + "x-default-unit": "s", + "x-duration": true, + "x-nullable": true + }, + "stats_show_desc": { + "type": "string", + "x-nullable": true }, + "stats_show_legends": { + "type": "boolean", + "x-display-name": "Stats Show Legends" + }, + "stats_show_modules": { + "type": "boolean", + "x-display-name": "Stats Show Modules" + }, + "stats_show_node_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-nullable": true, + "x-omitempty": false + }, + "stats_uri_prefix": { + "type": "string", + "pattern": "^[^\\s]+$" + } + } + }, + "stick_rule": { + "description": "Define a pattern used to create an entry in a stickiness table or matching condition or associate a user to a server.", + "type": "object", + "title": "Stick Rule", + "required": [ + "type", + "pattern" + ], + "properties": { "cond": { "type": "string", "enum": [ @@ -18886,517 +99530,626 @@ func init() { "property": "acl_name" } }, - "deny_status": { - "type": "integer", - "x-dependency": { - "type": { - "value": [ - "deny", - "tarpit" - ] - } - }, - "x-nullable": false + "metadata": { + "additionalProperties": { + "type": "object" + } }, - "hdr_format": { + "pattern": { "type": "string", "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "replace-header", - "replace-value", - "set-header", - "add-header" - ] - } - }, - "x-display-name": "Header Format" + "x-nullable": false }, - "hdr_match": { + "table": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "replace-header", - "replace-value" - ] - } - }, - "x-display-name": "Header Match" + "pattern": "^[^\\s]+$" }, - "hdr_name": { + "type": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": [ - "add-header", - "replace-header", - "del-header", - "set-header", - "replace-value" - ] - } + "enum": [ + "match", + "on", + "store-request", + "store-response" + ], + "x-nullable": false + } + }, + "additionalProperties": false, + "example": { + "pattern": "src", + "type": "match" + } + }, + "stick_rules": { + "description": "HAProxy backend stick rules array (corresponds to stick store-request, stick match, stick on, stick store-response)", + "type": "array", + "title": "Stick Rules Array", + "items": { + "$ref": "#/definitions/stick_rule" + } + }, + "stick_table": { + "description": "Stick Table Information", + "type": "object", + "title": "Stick Table", + "properties": { + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/StickTableFieldsItems0" }, - "x-display-name": "Header Name" + "x-omitempty": true }, - "id": { + "name": { + "type": "string" + }, + "size": { "type": "integer", "x-nullable": true }, - "log_level": { + "type": { "type": "string", "enum": [ - "emerg", - "alert", - "crit", - "err", - "warning", - "notice", - "info", - "debug", - "silent" - ], - "x-dependency": { - "type": { - "required": true, - "value": "set-log-level" + "ip", + "ipv6", + "integer", + "string", + "binary" + ] + }, + "used": { + "type": "integer", + "x-nullable": true + } + } + }, + "stick_table_entries": { + "description": "Entries of one runtime stick table", + "type": "array", + "title": "Stick Tables Entries", + "items": { + "$ref": "#/definitions/stick_table_entry" + } + }, + "stick_table_entry": { + "description": "One entry in stick table", + "type": "object", + "title": "Stick Table Entry", + "properties": { + "bytes_in_cnt": { + "type": "integer", + "x-nullable": true + }, + "bytes_in_rate": { + "type": "integer", + "x-nullable": true + }, + "bytes_out_cnt": { + "type": "integer", + "x-nullable": true + }, + "bytes_out_rate": { + "type": "integer", + "x-nullable": true + }, + "conn_cnt": { + "type": "integer", + "x-nullable": true + }, + "conn_cur": { + "type": "integer", + "x-nullable": true + }, + "conn_rate": { + "type": "integer", + "x-nullable": true + }, + "exp": { + "type": "integer", + "x-nullable": true + }, + "glitch_cnt": { + "type": "integer", + "x-nullable": true + }, + "glitch_rate": { + "type": "integer", + "x-nullable": true + }, + "gpc": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { + "type": "integer", + "x-nullable": true } } }, - "path_fmt": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-path" + "gpc0": { + "type": "integer", + "x-nullable": true + }, + "gpc0_rate": { + "type": "integer", + "x-nullable": true + }, + "gpc1": { + "type": "integer", + "x-nullable": true + }, + "gpc1_rate": { + "type": "integer", + "x-nullable": true + }, + "gpc_rate": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { + "type": "integer", + "x-nullable": true } } }, - "query-fmt": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-query" + "gpt": { + "type": "object", + "properties": { + "idx": { + "type": "integer" + }, + "value": { + "type": "integer", + "x-nullable": true } } }, - "redir_code": { + "gpt0": { "type": "integer", - "enum": [ - 301, - 302, - 303 - ], - "x-dependency": { - "type": { - "value": "redirect" - } - }, - "x-display-name": "Redirect Code" + "x-nullable": true }, - "redir_option": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "redirect" - } - }, - "x-display-name": "Redirect Option" + "http_err_cnt": { + "type": "integer", + "x-nullable": true }, - "redir_type": { - "type": "string", - "enum": [ - "location", - "prefix", - "scheme" - ], - "x-dependency": { - "type": { - "required": true, - "value": "redirect" - } - }, - "x-display-name": "Redirect Type" + "http_err_rate": { + "type": "integer", + "x-nullable": true }, - "redir_value": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "redirect" - } - }, - "x-display-name": "Redirect Value" + "http_fail_cnt": { + "type": "integer", + "x-nullable": true }, - "spoe_engine": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" - } - }, - "x-display-name": "SPOE Engine" + "http_fail_rate": { + "type": "integer", + "x-nullable": true }, - "spoe_group": { + "http_req_cnt": { + "type": "integer", + "x-nullable": true + }, + "http_req_rate": { + "type": "integer", + "x-nullable": true + }, + "id": { + "type": "string" + }, + "key": { + "type": "string" + }, + "server_id": { + "type": "integer", + "x-nullable": true + }, + "sess_cnt": { + "type": "integer", + "x-nullable": true + }, + "sess_rate": { + "type": "integer", + "x-nullable": true + }, + "use": { + "type": "boolean" + } + } + }, + "stick_tables": { + "description": "Array of runtime stick tables", + "type": "array", + "title": "Stick Tables Array", + "items": { + "$ref": "#/definitions/stick_table" + } + }, + "table": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "expire": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" - } - }, - "x-display-name": "SPOE Group" + "pattern": "^\\d+(ms|s|m|h|d)?$", + "x-default-unit": "ms", + "x-duration": true, + "x-nullable": true }, - "type": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "name": { "type": "string", - "enum": [ - "allow", - "deny", - "auth", - "redirect", - "tarpit", - "add-header", - "replace-header", - "replace-value", - "del-header", - "set-header", - "set-log-level", - "set-path", - "set-query", - "set-uri", - "set-var", - "send-spoe-group", - "add-acl", - "del-acl" - ], "x-nullable": false }, - "uri-fmt": { - "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-uri" - } - } + "no_purge": { + "type": "boolean", + "x-display-name": "No Purge" }, - "var_expr": { + "recv_only": { + "type": "boolean", + "x-display-name": "Receive Only" + }, + "size": { "type": "string", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" - } - }, - "x-display-name": "Var Expression" + "pattern": "^\\d+(k|K|m|M|g|G)?$", + "x-size": true }, - "var_name": { + "store": { + "type": "string" + }, + "type": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" - } - } + "enum": [ + "ip", + "integer", + "string", + "binary" + ] + }, + "type_len": { + "type": "integer", + "x-display-name": "Type", + "x-nullable": true }, - "var_scope": { + "write_to": { "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "type": { - "required": true, - "value": "set-var" - } - } + "x-nullable": true } - }, - "additionalProperties": false, - "example": { - "cond": "unless", - "cond_test": "{ src 192.168.0.0/16 }", - "hdr_format": "%T", - "hdr_name": "X-Haproxy-Current-Date", - "id": 0, - "type": "add-header" } }, - "http_request_rules": { - "description": "HAProxy HTTP request rules array (corresponds to http-request directives)", + "tables": { + "description": "HAProxy table array", "type": "array", - "title": "HTTP Request Rules Array", + "title": "Tables", "items": { - "$ref": "#/definitions/http_request_rule" + "$ref": "#/definitions/table" } }, - "http_response_rule": { - "description": "HAProxy HTTP response rule configuration (corresponds to http-response directives)", + "tcp_check": { "type": "object", - "title": "HTTP Response Rule", + "title": "TCP Check", "required": [ - "id", - "type" + "action" ], "properties": { - "acl_file": { + "action": { + "type": "string", + "enum": [ + "comment", + "connect", + "expect", + "send", + "send-lf", + "send-binary", + "send-binary-lf", + "set-var", + "set-var-fmt", + "unset-var" + ], + "x-nullable": false + }, + "addr": { "type": "string", "pattern": "^[^\\s]+$", "x-dependency": { - "type": { - "required": true, - "value": [ - "add-acl", - "del-acl" - ] + "action": { + "value": "connect" } - } + }, + "x-nullable": false }, - "acl_keyfmt": { + "alpn": { "type": "string", "pattern": "^[^\\s]+$", "x-dependency": { - "type": { - "required": true, + "action": { + "value": "connect" + } + }, + "x-display-name": "ALPN Protocols", + "x-nullable": false + }, + "check_comment": { + "type": "string", + "x-dependency": { + "action": { "value": [ - "add-acl", - "del-acl" + "connect", + "expect", + "send", + "send-lf", + "send-binary", + "send-binary-lf" ] } }, - "x-display-name": "ACK Key Format" + "x-nullable": false }, - "cond": { + "data": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send" + } + } + }, + "default": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } + }, + "error_status": { "type": "string", "enum": [ - "if", - "unless" + "L7OKC", + "L7RSP", + "L7STS", + "L6RSP", + "L4CON" ], - "x-display-name": "Condition" + "x-dependency": { + "action": { + "value": "expect" + } + } }, - "cond_test": { - "type": "string", + "exclamation_mark": { + "type": "boolean", "x-dependency": { - "cond": { - "required": true + "action": { + "value": "expect" } }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } + "x-display-name": "Expect Exclamation Mark" }, - "hdr_format": { + "fmt": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { + "action": { "required": true, - "value": [ - "replace-header", - "replace-value", - "set-header", - "add-header" - ] + "value": "send-lf" } - }, - "x-display-name": "Header Format" + } }, - "hdr_match": { + "hex_fmt": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { + "action": { "required": true, - "value": [ - "replace-header", - "replace-value" - ] + "value": "send-binary-lf" } - }, - "x-display-name": "Header Match" + } }, - "hdr_name": { + "hex_string": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { + "action": { "required": true, - "value": [ - "add-header", - "replace-header", - "del-header", - "set-header", - "replace-value" - ] + "value": "send-binary" } - }, - "x-display-name": "Header Name" + } }, - "id": { - "type": "integer", - "x-nullable": true + "linger": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } }, - "log_level": { + "match": { "type": "string", + "pattern": "^[^\\s]+$", "enum": [ - "emerg", - "alert", - "crit", - "err", - "warning", - "notice", - "info", - "debug", - "silent" + "string", + "rstring", + "string-lf", + "binary", + "rbinary", + "binary-lf" ], "x-dependency": { - "type": { + "action": { "required": true, - "value": "set-log-level" + "value": "expect" } + }, + "x-display-name": "Expect Match" + }, + "metadata": { + "additionalProperties": { + "type": "object" } }, - "redir_code": { + "min_recv": { "type": "integer", + "x-dependency": { + "action": { + "value": "expect" + } + } + }, + "ok_status": { + "type": "string", "enum": [ - 301, - 302, - 303 + "L7OK", + "L7OKC", + "L6OK", + "L4OK" ], "x-dependency": { - "type": { - "value": "redirect" + "action": { + "value": "expect" } - }, - "x-display-name": "Redirect Code" + } }, - "redir_option": { + "on_error": { "type": "string", "x-dependency": { - "type": { - "required": true, - "value": "redirect" + "action": { + "value": "expect" } - }, - "x-display-name": "Redirect Option" + } }, - "redir_type": { + "on_success": { "type": "string", - "enum": [ - "location", - "prefix", - "scheme" - ], "x-dependency": { - "type": { - "required": true, - "value": "redirect" + "action": { + "value": "expect" } - }, - "x-display-name": "Redirect Type" + } }, - "redir_value": { + "pattern": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { + "action": { "required": true, - "value": "redirect" + "value": "expect" + } + } + }, + "port": { + "type": "integer", + "maximum": 65535, + "minimum": 1, + "x-dependency": { + "action": { + "value": "connect" } }, - "x-display-name": "Redirect Value" + "x-nullable": true }, - "spoe_engine": { + "port_string": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" + "action": { + "value": "connect" } } }, - "spoe_group": { + "proto": { "type": "string", - "pattern": "^[^\\s]+$", "x-dependency": { - "type": { - "required": true, - "value": "send-spoe-group" + "action": { + "value": "connect" + } + }, + "x-nullable": false + }, + "send_proxy": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" } } }, - "status": { - "type": "integer", - "maximum": 999, - "minimum": 100, + "sni": { + "type": "string", "x-dependency": { - "type": { - "required": true, - "value": "set-status" + "action": { + "value": "connect" } }, "x-nullable": false }, - "status_reason": { + "ssl": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" + } + } + }, + "status-code": { "type": "string", "x-dependency": { - "type": { - "value": "set-status" + "action": { + "value": "expect" } } }, - "type": { + "tout_status": { "type": "string", "enum": [ - "allow", - "deny", - "redirect", - "add-header", - "set-header", - "del-header", - "set-log-level", - "set-var", - "set-status", - "send-spoe-group", - "replace-header", - "replace-value", - "add-acl", - "del-acl" + "L7TOUT", + "L6TOUT", + "L4TOUT" ], - "x-nullable": false + "x-dependency": { + "action": { + "value": "expect" + } + } }, "var_expr": { "type": "string", "x-dependency": { - "type": { + "action": { "required": true, - "value": "set-var" + "value": [ + "set-var" + ] } }, "x-display-name": "Var Expression" }, + "var_fmt": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var-fmt" + ] + } + }, + "x-display-name": "Var Log format" + }, "var_name": { "type": "string", "pattern": "^[^\\s]+$", "x-dependency": { - "type": { + "action": { "required": true, - "value": "set-var" + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] } } }, @@ -19404,243 +100157,256 @@ func init() { "type": "string", "pattern": "^[^\\s]+$", "x-dependency": { - "type": { + "action": { "required": true, - "value": "set-var" + "value": [ + "set-var", + "set-var-fmt", + "unset-var" + ] + } + } + }, + "via_socks4": { + "type": "boolean", + "x-dependency": { + "action": { + "value": "connect" } } } - }, - "additionalProperties": false, - "example": { - "cond": "unless", - "cond_test": "{ src 192.168.0.0/16 }", - "hdr_format": "%T", - "hdr_name": "X-Haproxy-Current-Date", - "id": 0, - "type": "add-header" } }, - "http_response_rules": { - "description": "HAProxy HTTP response rules array (corresponds to http-response directives)", + "tcp_checks": { "type": "array", - "title": "HTTP Response Rules Array", + "title": "TCP Checks Array", "items": { - "$ref": "#/definitions/http_response_rule" + "$ref": "#/definitions/tcp_check" } }, - "httpchk": { + "tcp_request_rule": { + "description": "HAProxy TCP Request Rule configuration (corresponds to tcp-request)", "type": "object", + "title": "TCP Request Rule", + "required": [ + "type" + ], "properties": { - "method": { + "action": { "type": "string", "enum": [ - "HEAD", - "PUT", - "POST", - "GET", - "TRACE", - "PATCH" - ] + "accept", + "attach-srv", + "capture", + "do-resolve", + "expect-netscaler-cip", + "expect-proxy", + "lua", + "reject", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-bandwidth-limit", + "set-bc-mark", + "set-bc-tos", + "set-dst-port", + "set-dst", + "set-fc-mark", + "set-fc-tos", + "set-log-level", + "set-mark", + "set-nice", + "set-priority-class", + "set-priority-offset", + "set-src", + "set-src-port", + "set-tos", + "set-var", + "set-var-fmt", + "silent-drop", + "switch-mode", + "track-sc", + "unset-var", + "use-service", + "set-retries", + "do-log" + ], + "x-dependency": { + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-nullable": false }, - "uri": { + "bandwidth_limit_limit": { "type": "string", - "pattern": "^[^\\s]+$" + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" + }, + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" }, - "version": { + "bandwidth_limit_name": { "type": "string", - "pattern": "^[^\\s]+$" - } - }, - "x-display-name": "HTTP Check" - }, - "info": { - "description": "General API, OS and hardware information", - "type": "object", - "title": "Information", - "properties": { - "api": { - "type": "object", - "properties": { - "build_date": { - "description": "HAProxy Dataplane API build date", - "type": "string", - "format": "date-time" + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" }, - "version": { - "description": "HAProxy Dataplane API version string", - "type": "string" + "type": { + "value": "content" } - } + }, + "x-display-name": "Bandwidth limit name" }, - "system": { - "type": "object", - "properties": { - "cpu_info": { - "type": "object", - "properties": { - "model": { - "type": "string" - }, - "num_cpus": { - "description": "Number of logical CPUs", - "type": "integer" - } - } - }, - "hostname": { - "description": "Hostname where the HAProxy is running", - "type": "string" - }, - "mem_info": { - "type": "object", - "properties": { - "dataplaneapi_memory": { - "type": "integer" - }, - "free_memory": { - "type": "integer" - }, - "total_memory": { - "type": "integer" - } - } - }, - "os_string": { - "description": "OS string", - "type": "string" - }, - "time": { - "description": "Current time in milliseconds since Epoch.", - "type": "integer" + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" }, - "uptime": { - "description": "System uptime", - "type": "integer", - "x-nullable": true + "type": { + "value": "content" } - } - } - }, - "example": { - "api": { - "build_date": "2019-08-21T17:31:56.000Z", - "version": "v1.2.1 45a3288.dev" - }, - "system": { - "cpu_info": { - "model": "Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz", - "num_cpus": 4 - }, - "hostname": "test", - "mem_info": { - "dataplaneapi_memory": 44755536, - "free_memory": 5790642176, - "total_memory": 16681517056 }, - "os_string": "Linux 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019", - "time": 1566401525, - "uptime": 87340 - } - } - }, - "log_target": { - "description": "Per-instance logging of events and traffic.", - "type": "object", - "title": "Log Target", - "required": [ - "id" - ], - "properties": { - "address": { - "type": "string", - "pattern": "^[^\\s]+$", + "x-display-name": "Standard HAProxy expression" + }, + "capture_len": { + "type": "integer", "x-dependency": { - "global": { + "action": { "required": true, - "value": false + "value": "capture" }, - "nolog": { + "type": { "required": true, - "value": false + "value": [ + "connection", + "content" + ] } - } + }, + "x-display-name": "Capture Length" }, - "facility": { + "capture_sample": { "type": "string", - "enum": [ - "kern", - "user", - "mail", - "daemon", - "auth", - "syslog", - "lpr", - "news", - "uucp", - "cron", - "auth2", - "ftp", - "ntp", - "audit", - "alert", - "cron2", - "local0", - "local1", - "local2", - "local3", - "local4", - "local5", - "local6", - "local7" - ], + "pattern": "^(?:[A-Za-z]+\\(\"([A-Za-z\\s]+)\"\\)|[A-Za-z]+)", "x-dependency": { - "global": { + "action": { "required": true, - "value": false + "value": "capture" }, - "nolog": { + "type": { "required": true, - "value": false + "value": [ + "connection", + "content" + ] } - } + }, + "x-display-name": "Capture Sample" }, - "format": { + "cond": { "type": "string", "enum": [ - "rfc3164", - "rfc5424", - "short", - "raw" + "if", + "unless" ], "x-dependency": { - "global": { - "value": false + "type": { + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true + }, + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "expr": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "do-resolve", + "set-bc-mark", + "set-bc-tos", + "set-dst", + "set-dst-port", + "set-fc-mark", + "set-fc-tos", + "set-priority-class", + "set-priority-offset", + "set-src", + "set-src-port", + "set-var", + "set-retries" + ] }, - "nolog": { - "value": false + "type": { + "value": [ + "session", + "connection", + "content" + ] } - } - }, - "global": { - "type": "boolean" - }, - "id": { - "type": "integer", - "x-nullable": true + }, + "x-display-name": "Standard HAProxy expression" }, - "length": { - "type": "integer", + "gpt_value": { + "type": "string", "x-dependency": { - "global": { - "value": false + "action": { + "required": true, + "value": "sc-set-gpt0" }, - "nolog": { - "value": false + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] } - } + }, + "x-display-name": "Sticky counter value" }, - "level": { + "log_level": { "type": "string", "enum": [ "emerg", @@ -19650,1596 +100416,1697 @@ func init() { "warning", "notice", "info", - "debug" + "debug", + "silent" ], "x-dependency": { - "global": { - "value": false + "action": { + "required": true, + "value": "set-log-level" }, - "nolog": { - "value": false + "type": { + "value": "content" } } }, - "minlevel": { + "lua_action": { "type": "string", - "enum": [ - "emerg", - "alert", - "crit", - "err", - "warning", - "notice", - "info", - "debug" - ], + "pattern": "^[^\\s]+$", "x-dependency": { - "global": { - "value": false + "action": { + "required": true, + "value": "lua" }, - "level": { - "required": false + "type": { + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Lua action name" + }, + "lua_params": { + "type": "string", + "x-dependency": { + "action": { + "value": "lua" }, - "nolog": { - "value": false + "type": { + "value": [ + "connection", + "content" + ] } - } + }, + "x-display-name": "Lua action params" }, - "nolog": { - "type": "boolean" - } - }, - "additionalProperties": false - }, - "log_targets": { - "description": "HAProxy log target array (corresponds to log directives)", - "type": "array", - "title": "Log Target Array", - "items": { - "$ref": "#/definitions/log_target" - } - }, - "native_stat": { - "description": "Current stats for one object.", - "type": "object", - "title": "Stats", - "properties": { - "backend_name": { + "mark_value": { "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", "x-dependency": { - "type": "server" - } + "action": { + "required": true, + "value": "set-mark" + }, + "type": { + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Mark Value" }, - "name": { - "type": "string" + "metadata": { + "additionalProperties": { + "type": "object" + } }, - "stats": { - "type": "object", - "properties": { - "act": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "addr": { - "type": "string", - "x-dependency": { - "type": "server" - } - }, - "agent_code": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_desc": { - "type": "string", - "x-dependency": { - "type": "server" - } - }, - "agent_duration": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_fall": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_health": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_rise": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "agent_status": { - "type": "string", - "enum": [ - "UNK", - "INI", - "SOCKERR", - "L40K", - "L4TOUT", - "L4CON", - "L7OK", - "L7STS" - ], - "x-dependency": { - "type": "server" - } - }, - "algo": { - "type": "string", - "x-dependency": { - "type": "backend" - } - }, - "bck": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "bin": { - "type": "integer", - "x-nullable": true - }, - "bout": { - "type": "integer", - "x-nullable": true - }, - "check_code": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_desc": { - "type": "string", - "x-dependency": { - "type": "server" - } - }, - "check_duration": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_fall": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_health": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_rise": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "check_status": { - "type": "string", - "enum": [ - "UNK", - "INI", - "SOCKERR", - "L40K", - "L4TOUT", - "L4CON", - "L6OK", - "L6TOUT", - "L6RSP", - "L7OK", - "L7OKC", - "L7TOUT", - "L7RSP", - "L7STS" - ], - "x-dependency": { - "type": "server" - } - }, - "chkdown": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "chkfail": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "cli_abrt": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "comp_byp": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "comp_in": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "comp_out": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "comp_rsp": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "conn_rate": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "conn_rate_max": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "conn_tot": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "cookie": { - "type": "string", - "x-dependency": { - "type": [ - "server", - "backend" - ] - } - }, - "ctime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "dcon": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "downtime": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true - }, - "dreq": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true - }, - "dresp": { - "type": "integer", - "x-nullable": true - }, - "dses": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "econ": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "ereq": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true - }, - "eresp": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true - }, - "hanafail": { - "type": "string", - "x-dependency": { - "type": "server" - } - }, - "hrsp_1xx": { - "type": "integer", - "x-nullable": true - }, - "hrsp_2xx": { - "type": "integer", - "x-nullable": true + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "action": { + "required": true, + "value": "set-nice" }, - "hrsp_3xx": { - "type": "integer", - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Nice Value", + "x-nullable": false + }, + "resolve_protocol": { + "type": "string", + "enum": [ + "ipv4", + "ipv6" + ], + "x-dependency": { + "action": { + "required": false, + "value": "do-resolve" }, - "hrsp_4xx": { - "type": "integer", - "x-nullable": true + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Protocol" + }, + "resolve_resolvers": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "do-resolve" }, - "hrsp_5xx": { - "type": "integer", - "x-nullable": true + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Resolvers" + }, + "resolve_var": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "do-resolve" }, - "hrsp_other": { - "type": "integer", - "x-nullable": true + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Variable name" + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] + } + }, + "x-display-name": "RST TTL" + }, + "sc_idx": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-set-gpt" + ] }, - "iid": { - "type": "integer", - "x-nullable": true + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Sticky counter Index" + }, + "sc_inc_id": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] }, - "intercepted": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true + "type": { + "required": true, + "value": [ + "connection", + "content", + "session" + ] + } + }, + "x-display-name": "Sticky counter ID" + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt0" + ] + } + }, + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "server_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "attach-srv" }, - "lastchg": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "session" + } + }, + "x-display-name": "Server name" + }, + "service_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "use-service" }, - "lastsess": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Service name" + }, + "spoe_engine_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" }, - "lbtot": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "required": true, + "value": [ + "content" + ] + } + }, + "x-display-name": "Engine name" + }, + "spoe_group_name": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" }, - "mode": { - "type": "string", - "enum": [ - "tcp", - "http", - "health", - "unknown" + "type": { + "required": true, + "value": [ + "content" ] + } + }, + "x-display-name": "Group name" + }, + "switch_mode_proto": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "switch-mode" }, - "pid": { - "type": "integer", - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Switch Mode Proto" + }, + "timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "inspect-delay" + } + }, + "x-duration": true, + "x-nullable": true + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "action": { + "required": true, + "value": "set-tos" }, - "qcur": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": [ + "connection", + "content" + ] + } + }, + "x-display-name": "Tos Value" + }, + "track_key": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "track-sc" + ] }, - "qlimit": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Sample expression rule" + }, + "track_stick_counter": { + "type": "integer", + "x-dependency": { + "action": { + "required": false, + "value": [ + "track-sc" + ] }, - "qmax": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Track Stick Counter", + "x-nullable": true + }, + "track_table": { + "type": "string", + "x-dependency": { + "action": { + "required": false, + "value": [ + "track-sc" + ] }, - "qtime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Optional table name" + }, + "type": { + "type": "string", + "enum": [ + "connection", + "content", + "inspect-delay", + "session" + ], + "x-nullable": false + }, + "var_format": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "set-var-fmt" }, - "rate": { - "type": "integer", - "x-nullable": true + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var", + "unset-var", + "set-var-fmt" + ] }, - "rate_lim": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Variable name" + }, + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-var", + "unset-var", + "set-var-fmt" + ] }, - "rate_max": { - "type": "integer", - "x-nullable": true + "type": { + "value": [ + "session", + "connection", + "content" + ] + } + }, + "x-display-name": "Variable scope" + } + }, + "additionalProperties": false, + "example": { + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "index": 0, + "type": "connection" + } + }, + "tcp_request_rules": { + "description": "HAProxy TCP request rules array (corresponds to tcp-request directive)", + "type": "array", + "title": "TCP Request Rules Array", + "items": { + "$ref": "#/definitions/tcp_request_rule" + } + }, + "tcp_response_rule": { + "description": "HAProxy TCP Response Rule configuration (corresponds to tcp-response)", + "type": "object", + "title": "TCP Response Rule", + "required": [ + "type" + ], + "properties": { + "action": { + "type": "string", + "enum": [ + "accept", + "close", + "lua", + "reject", + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0", + "send-spoe-group", + "set-bandwidth-limit", + "set-fc-mark", + "set-fc-tos", + "set-log-level", + "set-mark", + "set-nice", + "set-tos", + "set-var", + "set-var-fmt", + "silent-drop", + "unset-var", + "do-log" + ], + "x-dependency": { + "type": { + "required": true, + "value": "content" + } + }, + "x-nullable": false + }, + "bandwidth_limit_limit": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" }, - "req_rate": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "bandwidth_limit_name": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" }, - "req_rate_max": { - "type": "integer", - "x-dependency": { - "type": "frontend" - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Bandwidth limit name" + }, + "bandwidth_limit_period": { + "type": "string", + "x-dependency": { + "action": { + "value": "set-bandwidth-limit" }, - "req_tot": { - "type": "integer", - "x-dependency": { - "type": [ - "frontend", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "cond": { + "type": "string", + "enum": [ + "if", + "unless" + ], + "x-dependency": { + "type": { + "value": "content" + } + }, + "x-display-name": "Condition" + }, + "cond_test": { + "type": "string", + "x-dependency": { + "cond": { + "required": true }, - "rtime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Condition Test", + "x-dynamic-enum": { + "freeFormat": true, + "operation": "getACLs", + "property": "acl_name" + } + }, + "expr": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "set-src-port", + "sc-set-gpt0", + "set-fc-mark", + "set-fc-tos" + ] }, - "scur": { - "type": "integer", - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Standard HAProxy expression" + }, + "log_level": { + "type": "string", + "enum": [ + "emerg", + "alert", + "crit", + "err", + "warning", + "notice", + "info", + "debug", + "silent" + ], + "x-dependency": { + "action": { + "required": true, + "value": "set-log-level" }, - "sid": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true + "type": { + "value": "content" + } + } + }, + "lua_action": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": "lua" }, - "slim": { - "type": "integer", - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Lua action name" + }, + "lua_params": { + "type": "string", + "x-dependency": { + "action": { + "value": "lua" }, - "smax": { - "type": "integer", - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Lua action params" + }, + "mark_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "action": { + "required": true, + "value": "set-mark" }, - "srv_abrt": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "Mark Value" + }, + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "nice_value": { + "type": "integer", + "maximum": 1024, + "minimum": -1024, + "x-dependency": { + "action": { + "required": true, + "value": "set-nice" }, - "status": { - "type": "string", - "enum": [ - "UP", - "DOWN", - "NOLB", - "MAINT", - "no check" + "type": { + "value": "content" + } + }, + "x-display-name": "Nice Value", + "x-nullable": false + }, + "rst_ttl": { + "type": "integer", + "x-dependency": { + "type": { + "required": true, + "value": [ + "silent-drop" + ] + } + }, + "x-display-name": "RST TTL" + }, + "sc_expr": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc" ] }, - "stot": { - "type": "integer", - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "ScSet Expression Value" + }, + "sc_id": { + "type": "integer", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc", + "sc-inc-gpc0", + "sc-inc-gpc1", + "sc-set-gpt", + "sc-set-gpt0" + ] }, - "throttle": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true + "type": { + "value": "content" + } + } + }, + "sc_idx": { + "type": "integer", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-set-gpt", + "sc-inc-gpc" + ] }, - "tracked": { - "type": "integer", - "x-dependency": { - "type": "server" - }, - "x-nullable": true + "type": { + "value": "content" + } + } + }, + "sc_int": { + "type": "integer", + "x-dependency": { + "action": { + "required": true, + "value": [ + "sc-add-gpc", + "sc-inc-gpc" + ] }, - "ttime": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "ScSet Integer Value", + "x-nullable": true + }, + "spoe_engine": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" }, - "weight": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "SPOE Engine" + }, + "spoe_group": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": "send-spoe-group" }, - "wredis": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" + } + }, + "x-display-name": "SPOE Group" + }, + "timeout": { + "type": "integer", + "x-default-unit": "ms", + "x-dependency": { + "type": { + "required": true, + "value": "inspect-delay" + } + }, + "x-duration": true, + "x-nullable": true + }, + "tos_value": { + "type": "string", + "pattern": "^(0x[0-9A-Fa-f]+|[0-9]+)$", + "x-dependency": { + "action": { + "required": true, + "value": "set-tos" }, - "wretr": { - "type": "integer", - "x-dependency": { - "type": [ - "server", - "backend" - ] - }, - "x-nullable": true + "type": { + "value": "content" } }, - "x-go-name": "NativeStatStats" + "x-display-name": "Tos Value" }, "type": { "type": "string", "enum": [ - "backend", - "server", - "frontend" - ] - } - }, - "x-go-name": "NativeStat", - "example": { - "name": "frontend_test", - "stats": { - "bin": 4326578, - "bout": 889901290, - "comp_byp": 0, - "comp_in": 0, - "comp_out": 0, - "comp_rsp": 0, - "conn_rate": 12, - "conn_rate_max": 456, - "conn_tot": 45682, - "dcon": 0, - "dreq": 4, - "dresp": 1, - "dses": 0, - "ereq": 54, - "hrsp_1xx": 0, - "hrsp_2xx": 165, - "hrsp_3xx": 12, - "hrsp_4xx": 50, - "hrsp_5xx": 4, - "hrsp_other": 0, - "iid": 0, - "intercepted": 346, - "mode": "http", - "pid": 3204, - "rate": 64, - "rate_lim": 20000, - "rate_max": 4000, - "req_rate": 49, - "req_rate_max": 3965, - "req_total": 1254786, - "scur": 129, - "slim": 2000, - "smax": 2000, - "status": "UP", - "stot": 12902 - }, - "type": "frontend" - } - }, - "native_stats": { - "description": "HAProxy stats array", - "type": "array", - "title": "Stats Array", - "items": { - "description": "Stats from one runtime API", - "type": "object", - "title": "Stats collection", - "properties": { - "error": { - "type": "string" - }, - "runtimeAPI": { - "type": "string" + "content", + "inspect-delay" + ], + "x-nullable": false + }, + "var_format": { + "type": "string", + "x-dependency": { + "action": { + "required": true, + "value": "set-var-fmt" + }, + "type": { + "value": "content" + } }, - "stats": { - "type": "array", - "items": { - "$ref": "#/definitions/native_stat" + "x-display-name": "Var Format" + }, + "var_name": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "required": true, + "value": [ + "unset-var" + ] + }, + "type": { + "value": "content" } } }, - "x-go-name": "NativeStatsCollection" - }, - "x-go-name": "NativeStats" - }, - "process_info": { - "description": "General HAProxy process information", - "type": "object", - "title": "HAProxy Information", - "properties": { - "haproxy": { - "type": "object", - "properties": { - "pid": { - "description": "Process id of the replying worker process", - "type": "integer", - "x-nullable": true - }, - "processes": { - "description": "Number of spawned processes", - "type": "integer", - "x-nullable": true - }, - "release_date": { - "description": "HAProxy version release date", - "type": "string", - "format": "date" - }, - "uptime": { - "description": "HAProxy uptime in s", - "type": "integer", - "x-nullable": true + "var_scope": { + "type": "string", + "pattern": "^[^\\s]+$", + "x-dependency": { + "action": { + "value": "unset-var" }, - "version": { - "description": "HAProxy version string", - "type": "string" + "type": { + "value": "content" } } } }, + "additionalProperties": false, "example": { - "haproxy": { - "address": "127.0.0.1", - "pid": 1234, - "processes": 4, - "release_date": "2016-03-11", - "time": "2018-07-02T12:00:00.124Z", - "uptime": 8, - "version": "1.7-dev1-868ab3-148" - } + "cond": "if", + "cond_test": "{ src 192.168.0.0/16 }", + "index": 0, + "type": "content" + } + }, + "tcp_response_rules": { + "description": "HAProxy TCP response rules array (corresponds to tcp-response directive)", + "type": "array", + "title": "TCP Response Rules Array", + "items": { + "$ref": "#/definitions/tcp_response_rule" } }, - "redispatch": { + "trace_entries": { + "description": "list of entries in a traces section", + "type": "array", + "items": { + "$ref": "#/definitions/trace_entry" + } + }, + "trace_entry": { + "description": "Configure a trace event", "type": "object", + "title": "Trace event", "required": [ - "enabled" + "trace" ], "properties": { - "enabled": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ] + "metadata": { + "additionalProperties": { + "type": "object" + } }, - "interval": { - "type": "integer", + "trace": { + "description": "Trace parameters", + "type": "string", + "minLength": 1, "x-nullable": false } } }, - "reload": { - "description": "HAProxy reload", + "traces": { + "description": "Trace events configuration", "type": "object", - "title": "HAProxy reload", "properties": { - "id": { - "type": "string", - "pattern": "^\\d{4}-\\d{2}-\\d{2}-\\d+$" + "entries": { + "$ref": "#/definitions/trace_entries" }, - "reload_timestamp": { + "metadata": { + "additionalProperties": { + "type": "object" + } + } + }, + "additionalProperties": false, + "x-go-name": "Traces" + }, + "transaction": { + "description": "HAProxy configuration transaction", + "type": "object", + "title": "Configuration transaction", + "properties": { + "_version": { "type": "integer" }, - "response": { - "type": "string" + "id": { + "type": "string", + "pattern": "^[^\\s]+$" }, "status": { "type": "string", "enum": [ "failed", + "outdated", "in_progress", - "succeeded" + "success" ] } }, "example": { - "id": "2019-01-03-44", + "_version": 2, + "id": "273e3385-2d0c-4fb1-aa27-93cbb31ff203", "status": "in_progress" } }, - "reloads": { - "description": "HAProxy reloads array", + "transactions": { + "description": "Configuration transactions array", "type": "array", - "title": "HAProxy Reloads Array", + "title": "Transactions array", "items": { - "$ref": "#/definitions/reload" + "$ref": "#/definitions/transaction" } }, - "server": { - "description": "HAProxy backend server configuration", + "tune_buffer_options": { "type": "object", - "title": "Server", - "required": [ - "name" - ], "properties": { - "address": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false + "buffers_limit": { + "type": "integer", + "x-display-name": "Buffers Limit", + "x-nullable": true }, - "agent-addr": { - "type": "string", - "pattern": "^[^\\s]+$" + "buffers_reserve": { + "type": "integer", + "minimum": 2, + "x-display-name": "Buffers Reserve" }, - "agent-check": { + "bufsize": { + "type": "integer", + "x-display-name": "Buffer Size", + "x-size": true + }, + "bufsize_small": { + "type": "integer", + "minimum": 1, + "x-display-name": "Size of small buffers (for memory-restrained situations)", + "x-nullable": true, + "x-size": true + }, + "pipesize": { + "type": "integer", + "x-display-name": "Pipe Buffer Size", + "x-size": true + }, + "rcvbuf_backend": { + "type": "integer", + "x-display-name": "Backend Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "rcvbuf_client": { + "type": "integer", + "x-display-name": "Client Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "rcvbuf_frontend": { + "type": "integer", + "x-display-name": "Frontend Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "rcvbuf_server": { + "type": "integer", + "x-display-name": "Server Receive Buffer Size", + "x-nullable": true, + "x-size": true + }, + "recv_enough": { + "type": "integer", + "x-display-name": "Receive Enough Socket Buffer Size", + "x-size": true + }, + "sndbuf_backend": { + "type": "integer", + "x-display-name": "Backend Send Buffer Size", + "x-nullable": true, + "x-size": true + }, + "sndbuf_client": { + "type": "integer", + "x-display-name": "Client Send Buffer Size", + "x-nullable": true, + "x-size": true + }, + "sndbuf_frontend": { + "type": "integer", + "x-display-name": "Frontend Send Buffer Size", + "x-nullable": true, + "x-size": true + }, + "sndbuf_server": { + "type": "integer", + "x-display-name": "Server Send Buffer Size", + "x-nullable": true, + "x-size": true + } + } + }, + "tune_lua_options": { + "type": "object", + "properties": { + "bool_sample_conversion": { "type": "string", "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "agent-port": { - "required": true - } - } + "normal", + "pre-3.1-bug" + ] }, - "agent-inter": { + "burst_timeout": { "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Burst execution timeout", + "x-duration": true, "x-nullable": true }, - "agent-port": { + "forced_yield": { "type": "integer", - "maximum": 65535, - "minimum": 1, - "x-nullable": true - }, - "agent-send": { - "type": "string" - }, - "allow_0rtt": { - "type": "boolean" + "x-display-name": "Lua Forced Yield" }, - "backup": { + "log_loggers": { "type": "string", "enum": [ "enabled", "disabled" - ] + ], + "x-display-name": "Send Lua Logs to the Loggers" }, - "check": { + "log_stderr": { "type": "string", "enum": [ + "auto", "enabled", "disabled" - ] + ], + "x-display-name": "Send Lua Logs to stderr" }, - "cookie": { - "type": "string", - "pattern": "^[^\\s]+$" + "maxmem": { + "type": "integer", + "x-display-name": "Lua Maximum Memory Usage", + "x-nullable": true }, - "inter": { + "service_timeout": { "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Lua Service timeout", + "x-duration": true, "x-nullable": true }, - "maintenance": { + "session_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Lua Session Timeout", + "x-duration": true, + "x-nullable": true + }, + "task_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Lua Task Timeout", + "x-duration": true, + "x-nullable": true + } + } + }, + "tune_options": { + "type": "object", + "properties": { + "applet_zero_copy_forwarding": { "type": "string", "enum": [ "enabled", "disabled" - ] + ], + "x-display-name": "Enables of disabled the zero-copy forwarding of data for the applets" }, - "maxconn": { + "comp_maxlevel": { "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true - }, - "name": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false + "x-display-name": "Maximum Compression Level" }, - "on-error": { - "type": "string", - "enum": [ - "fastinter", - "fail-check", - "sudden-death", - "mark-down" - ] + "disable_fast_forward": { + "type": "boolean", + "x-display-name": "Disable fast-forwarding" }, - "on-marked-down": { - "type": "string", - "enum": [ - "shutdown-sessions" - ] + "disable_zero_copy_forwarding": { + "type": "boolean", + "x-display-name": "Disable zero-copy forwarding" }, - "on-marked-up": { - "type": "string", - "enum": [ - "shutdown-backup-sessions" - ] + "epoll_mask_events": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "err", + "hup", + "rdhup" + ] + }, + "x-omitempty": true }, - "port": { + "events_max_events_at_once": { "type": "integer", - "maximum": 65535, - "minimum": 1, - "x-nullable": true + "maximum": 10000, + "minimum": 1 }, - "send-proxy": { + "fail_alloc": { + "type": "boolean", + "x-display-name": "Failed Allocation Chance" + }, + "fd_edge_triggered": { "type": "string", "enum": [ "enabled", "disabled" - ] + ], + "x-display-name": "Edge-triggered polling mode" }, - "send-proxy-v2": { + "glitches_kill_cpu_usage": { + "type": "integer", + "maximum": 100, + "minimum": 0, + "x-display-name": "CPU Usage Kill glitched Connections", + "x-nullable": true + }, + "h1_zero_copy_fwd_recv": { "type": "string", "enum": [ "enabled", "disabled" - ] + ], + "x-display-name": "enable or disable the zero-copy receives of data for the HTTP/1 multiplexer" }, - "ssl": { + "h1_zero_copy_fwd_send": { "type": "string", "enum": [ "enabled", "disabled" - ] + ], + "x-display-name": "enable or disable the zero-copy sends of data for the HTTP/1 multiplexer" }, - "ssl_cafile": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": "enabled" - } - }, - "x-display-name": "SSL CA File" + "h2_be_glitches_threshold": { + "type": "integer", + "x-display-name": "Automatically kill a backend connection past a number of glitches", + "x-nullable": true }, - "ssl_certificate": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dependency": { - "ssl": { - "value": "enabled" - } - } + "h2_be_initial_window_size": { + "type": "integer", + "x-display-name": "Initial window size for outgoing connections" }, - "tls_tickets": { - "type": "string", - "enum": [ - "enabled", - "disabled" - ], - "x-dependency": { - "ssl": { - "value": "enabled" - } - } + "h2_be_max_concurrent_streams": { + "type": "integer", + "x-display-name": "Maximum number of concurrent streams per outgoing connection" }, - "verify": { - "type": "string", - "enum": [ - "none", - "required" - ], - "x-dependency": { - "ssl": { - "value": "enabled" - } - } + "h2_be_rxbuf": { + "type": "integer", + "x-display-name": "HTTP/2 receive buffer size for outgoing connections", + "x-nullable": true, + "x-size": true }, - "weight": { + "h2_fe_glitches_threshold": { "type": "integer", + "x-display-name": "Automatically kill a frontend connection past a number of glitches", "x-nullable": true - } - }, - "additionalProperties": false, - "example": { - "address": "10.1.1.1", - "check": "enabled", - "max-connections": 500, - "name": "www", - "port": 8080, - "weight": 80 - } - }, - "server_switching_rule": { - "description": "HAProxy server switching rule configuration (corresponds to use-server directive)", - "type": "object", - "title": "Server Switching Rule", - "required": [ - "id", - "target_server" - ], - "properties": { - "cond": { + }, + "h2_fe_initial_window_size": { + "type": "integer", + "x-display-name": "Initial window size for incoming connections" + }, + "h2_fe_max_concurrent_streams": { + "type": "integer", + "x-display-name": "Maximum number of concurrent streams per incoming connection" + }, + "h2_fe_max_total_streams": { + "type": "integer", + "x-display-name": "Maximum number of total streams processed per incoming HTTP/2 connection", + "x-nullable": true + }, + "h2_fe_rxbuf": { + "type": "integer", + "x-display-name": "HTTP/2 receive buffer size for incoming connections", + "x-nullable": true, + "x-size": true + }, + "h2_header_table_size": { + "type": "integer", + "maximum": 65535, + "x-display-name": "HTTP/2 Dynamic Header Table Size" + }, + "h2_initial_window_size": { + "type": "integer", + "x-display-name": "HTTP/2 Initial Window Size", + "x-nullable": true + }, + "h2_max_concurrent_streams": { + "type": "integer", + "x-display-name": "HTTP/2 Maximum Number of Concurrent Streams" + }, + "h2_max_frame_size": { + "type": "integer", + "x-display-name": "HTTP/2 Maximum Frame Size" + }, + "h2_zero_copy_fwd_send": { "type": "string", "enum": [ - "if", - "unless" + "enabled", + "disabled" ], - "x-display-name": "Condition" + "x-display-name": "enable or disable the zero-copy sends of data for the HTTP/2 multiplexer" }, - "cond_test": { - "type": "string", - "x-dependency": { - "cond": { - "required": true - } - }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } + "http_cookielen": { + "type": "integer", + "x-display-name": "Maximum Cookie Length" }, - "id": { + "http_logurilen": { "type": "integer", - "x-nullable": true + "x-display-name": "Maximum URI Length" }, - "target_server": { - "type": "string", - "pattern": "^[^\\s]+$", - "x-dynamic-enum": { - "operation": "getServers", - "property": "name" - }, - "x-nullable": false - } - }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ req_ssl_sni -i www.example.com }", - "id": 0, - "target_server": "www" - } - }, - "server_switching_rules": { - "description": "HAProxy backend server switching rules array (corresponds to use-server directives)", - "type": "array", - "title": "Server Switching Rules Array", - "items": { - "$ref": "#/definitions/server_switching_rule" - } - }, - "servers": { - "description": "HAProxy backend servers array", - "type": "array", - "title": "Servers", - "items": { - "$ref": "#/definitions/server" - } - }, - "site": { - "description": "Site configuration. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration \nendpoints.\n", - "type": "object", - "title": "Site", - "required": [ - "name" - ], - "properties": { - "farms": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name", - "use_as" - ], - "properties": { - "balance": { - "$ref": "#/definitions/balance" - }, - "cond": { - "type": "string", - "enum": [ - "if", - "unless" - ], - "x-dependency": { - "use_as": { - "required": true, - "value": "conditional" - } - }, - "x-display-name": "Condition" - }, - "cond_test": { - "type": "string", - "x-dependency": { - "use_as": { - "required": true, - "value": "conditional" - } - }, - "x-display-name": "Condition Test" - }, - "forwardfor": { - "$ref": "#/definitions/forwardfor" - }, - "mode": { - "type": "string", - "enum": [ - "http", - "tcp" - ] - }, - "name": { - "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false - }, - "servers": { - "type": "array", - "items": { - "$ref": "#/definitions/server" - } - }, - "use_as": { - "type": "string", - "enum": [ - "default", - "conditional" - ], - "x-nullable": false - } - }, - "x-go-name": "SiteFarm" - } + "http_maxhdr": { + "type": "integer", + "maximum": 32767, + "minimum": 1, + "x-display-name": "Maximum Number of Headers" }, - "name": { + "idle_pool_shared": { "type": "string", - "pattern": "^[A-Za-z0-9-_.:]+$", - "x-nullable": false - }, - "service": { - "type": "object", - "properties": { - "http_connection_mode": { - "type": "string", - "enum": [ - "http-tunnel", - "httpclose", - "forced-close", - "http-server-close", - "http-keep-alive" - ], - "x-dependency": { - "mode": { - "value": "http" - } - }, - "x-display-name": "HTTP Connection Mode" - }, - "listeners": { - "type": "array", - "items": { - "$ref": "#/definitions/bind" - } - }, - "maxconn": { - "type": "integer", - "x-display-name": "Max Connections", - "x-nullable": true - }, - "mode": { - "type": "string", - "enum": [ - "http", - "tcp" - ] - } - } - } - }, - "additionalProperties": false, - "example": { - "farms": [ - { - "balance": { - "algorithm": "roundrobin" - }, - "mode": "http", - "name": "www_backend", - "servers": [ - { - "address": "127.0.1.1", - "name": "www_server", - "port": 4567, - "weight": 30 - }, - { - "address": "127.0.1.2", - "name": "www_server_new", - "port": 4567, - "weight": 70 - } - ], - "use_as": "default" - } - ], - "name": "test_site", - "service": { - "http_connection_mode": "httpclose", - "listeners": [ - { - "address": "127.0.0.1", - "name": "test_listener", - "port": 80 - }, - { - "address": "127.0.0.1", - "name": "test_listener_2", - "port": 8080 - } + "enum": [ + "enabled", + "disabled" ], - "maxconn": 2000, - "mode": "http" - } - } - }, - "sites": { - "description": "Sites array. Sites are considered as one service and all farms connected to that service.\nFarms are connected to service using use-backend and default_backend directives. Sites let you\nconfigure simple HAProxy configurations, for more advanced options use /haproxy/configuration \nendpoints.\n", - "type": "array", - "title": "Sites", - "items": { - "$ref": "#/definitions/site" - } - }, - "stick_rule": { - "description": "Define a pattern used to create an entry in a stickiness table or matching condition or associate a user to a server.", - "type": "object", - "title": "Stick Rule", - "required": [ - "id", - "type", - "pattern" - ], - "properties": { - "cond": { + "x-display-name": "Share Idle Connections" + }, + "idletimer": { + "type": "integer", + "maximum": 65535, + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "Idle Stream Duration", + "x-duration": true, + "x-nullable": true + }, + "listener_default_shards": { "type": "string", "enum": [ - "if", - "unless" + "by-process", + "by-thread", + "by-group" ], - "x-display-name": "Condition" + "x-display-name": "Listener Default Shards" }, - "cond_test": { + "listener_multi_queue": { "type": "string", - "x-dependency": { - "cond": { - "required": true - } - }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Listener Multi Queue Accept" }, - "id": { + "max_checks_per_thread": { "type": "integer", + "x-display-name": "Maximum checks per thread", "x-nullable": true }, - "pattern": { + "max_rules_at_once": { + "type": "integer", + "minimum": 0, + "x-display-name": "Maximum rules at once", + "x-nullable": true + }, + "maxaccept": { + "type": "integer", + "x-display-name": "Maximum Accept Events" + }, + "maxpollevents": { + "type": "integer", + "x-display-name": "Maximum Polled Events" + }, + "maxrewrite": { + "type": "integer", + "x-display-name": "Maximum Rewrite Space" + }, + "memory_hot_size": { + "type": "integer", + "x-display-name": "Per-thread Amount of Memory", + "x-nullable": true + }, + "notsent_lowat_client": { + "type": "integer", + "x-display-name": "Client Not Sent Low Watermark", + "x-nullable": true, + "x-size": true + }, + "notsent_lowat_server": { + "type": "integer", + "x-display-name": "Server Not Sent Low Watermark", + "x-nullable": true, + "x-size": true + }, + "pattern_cache_size": { + "type": "integer", + "x-display-name": "Pattern Lookup Cache Size", + "x-nullable": true + }, + "peers_max_updates_at_once": { + "type": "integer", + "x-display-name": "Maximum number of stick-table updates at once" + }, + "pool_high_fd_ratio": { + "type": "integer", + "x-display-name": "Max Used High FD Ratio" + }, + "pool_low_fd_ratio": { + "type": "integer", + "x-display-name": "Max Used Low FD Ratio" + }, + "pt_zero_copy_forwarding": { "type": "string", - "pattern": "^[^\\s]+$", - "x-nullable": false + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "enable or disable the zero-copy forwarding of data for the pass-through multiplexer" }, - "table": { + "renice_runtime": { + "type": "integer", + "maximum": 19, + "minimum": -20, + "x-display-name": "Scheduling priority applied after the configuration parsing", + "x-nullable": true + }, + "renice_startup": { + "type": "integer", + "maximum": 19, + "minimum": -20, + "x-display-name": "Scheduling priority applied before the rest of the configuration", + "x-nullable": true + }, + "ring_queues": { + "type": "integer", + "x-display-name": "Number of write queues in front of ring buffers", + "x-nullable": true + }, + "runqueue_depth": { + "type": "integer", + "x-display-name": "Max Tasks in Run Queue" + }, + "sched_low_latency": { "type": "string", - "pattern": "^[^\\s]+$" + "enum": [ + "enabled", + "disabled" + ], + "x-display-name": "Low Latency Task Scheduler" }, - "type": { + "stick_counters": { + "type": "integer", + "x-display-name": "Number of stick-counters", + "x-nullable": true + }, + "takeover_other_tg_connections": { "type": "string", "enum": [ - "match", - "on", - "store-request", - "store-response" + "none", + "restricted", + "full" ], - "x-nullable": false + "x-display-name": "Takeover Other Thread Groups Connections" } - }, - "additionalProperties": false, - "example": { - "id": 0, - "pattern": "src", - "type": "storeonly" - } - }, - "stick_rules": { - "description": "HAProxy backend stick rules array (corresponds to stick store-request, stick match, stick on, stick store-response)", - "type": "array", - "title": "Stick Rules Array", - "items": { - "$ref": "#/definitions/stick_rule" } }, - "tcp_request_rule": { - "description": "HAProxy TCP Request Rule configuration (corresponds to tcp-request)", + "tune_quic_options": { "type": "object", - "title": "TCP Request Rule", - "required": [ - "id", - "type" - ], "properties": { - "action": { + "frontend_conn_tx_buffers_limit": { + "type": "integer", + "x-display-name": "QUIC Frontend Connection TX Buffer Limit", + "x-nullable": true + }, + "frontend_max_idle_timeout": { + "type": "integer", + "minimum": 0, + "x-default-unit": "ms", + "x-display-name": "QUIC Frontend Max Idle Timeout", + "x-duration": true, + "x-nullable": true + }, + "frontend_max_streams_bidi": { + "type": "integer", + "x-display-name": "QUIC Max Number of Bidirectional Streams", + "x-nullable": true + }, + "frontend_max_tx_memory": { + "type": "integer", + "x-display-name": "QUIC Frontend Max Tx Memory", + "x-nullable": true, + "x-size": true + }, + "max_frame_loss": { + "type": "integer", + "x-display-name": "QUIC Max Limit for Frame Loss", + "x-nullable": true + }, + "reorder_ratio": { + "type": "integer", + "maximum": 100, + "minimum": 0, + "x-display-name": "Ratio applied to the packet reordering threshold", + "x-nullable": true + }, + "retry_threshold": { + "type": "integer", + "x-display-name": "QUIC Retry Threshold", + "x-nullable": true + }, + "socket_owner": { "type": "string", "enum": [ - "accept", - "reject" + "listener", + "connection" ], - "x-dependency": { - "type": { - "required": true, - "value": [ - "connection", - "content", - "session" - ] - } - }, - "x-nullable": false + "x-display-name": "QUIC Socket Owner" }, - "cond": { + "zero_copy_fwd_send": { "type": "string", "enum": [ - "if", - "unless" + "enabled", + "disabled" ], - "x-dependency": { - "type": { - "value": [ - "connection", - "content", - "session" - ] - } - }, - "x-display-name": "Condition" - }, - "cond_test": { - "type": "string", - "x-dependency": { - "cond": { - "required": true - }, - "type": { - "required": true, - "value": [ - "connection", - "content", - "session" - ] - } - }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" - } - }, - "id": { + "x-display-name": "Enables or disables the zero-copy sends for the QUIC multiplexer" + } + } + }, + "tune_ssl_options": { + "type": "object", + "properties": { + "cachesize": { "type": "integer", + "x-display-name": "SSL Cache Size", "x-nullable": true }, - "timeout": { + "capture_buffer_size": { "type": "integer", - "x-dependency": { - "type": { - "required": true, - "value": "inspect-delay" - } - }, + "x-display-name": "SSL Maximum Size of Cipherlist Buffer", "x-nullable": true }, - "type": { + "ctx_cache_size": { + "type": "integer", + "x-display-name": "SSL Number of Certificates in Cache" + }, + "default_dh_param": { + "type": "integer", + "x-display-name": "SSL Default DH Parameter Size" + }, + "force_private_cache": { + "type": "boolean", + "x-display-name": "SSL Force Private Cache" + }, + "keylog": { "type": "string", "enum": [ - "connection", - "content", - "inspect-delay", - "session" + "enabled", + "disabled" ], - "x-nullable": false + "x-display-name": "SSL Log TLS Keys" + }, + "lifetime": { + "type": "integer", + "minimum": 0, + "x-default-unit": "s", + "x-display-name": "SSL Session Lifetime", + "x-duration": true, + "x-nullable": true + }, + "maxrecord": { + "type": "integer", + "x-display-name": "SSL Maximum Size", + "x-nullable": true, + "x-size": false + }, + "ocsp_update_max_delay": { + "type": "integer", + "x-display-name": "SSL Maximum Interval Between Two Automatic Updates of the same OCSP Response", + "x-nullable": true + }, + "ocsp_update_min_delay": { + "type": "integer", + "x-display-name": "SSL Minimum Interval Between Two Automatic Updates of the same OCSP Response", + "x-nullable": true } - }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ src 192.168.0.0/16 }", - "id": 0, - "type": "accept" } }, - "tcp_request_rules": { - "description": "HAProxy TCP request rules array (corresponds to tcp-request directive)", - "type": "array", - "title": "TCP Request Rules Array", - "items": { - "$ref": "#/definitions/tcp_request_rule" + "tune_vars_options": { + "type": "object", + "properties": { + "global_max_size": { + "type": "integer", + "x-display-name": "Variables Global Max Size", + "x-nullable": true, + "x-size": false + }, + "proc_max_size": { + "type": "integer", + "x-display-name": "Variables Process Max Size", + "x-nullable": true, + "x-size": false + }, + "reqres_max_size": { + "type": "integer", + "x-display-name": "Variables Request/Response Max Size", + "x-nullable": true, + "x-size": false + }, + "sess_max_size": { + "type": "integer", + "x-display-name": "Variables Session Max Size", + "x-nullable": true, + "x-size": false + }, + "txn_max_size": { + "type": "integer", + "x-display-name": "Variables Transaction Max Size", + "x-nullable": true, + "x-size": false + } } }, - "tcp_response_rule": { - "description": "HAProxy TCP Response Rule configuration (corresponds to tcp-response)", + "tune_zlib_options": { "type": "object", - "title": "TCP Response Rule", + "properties": { + "memlevel": { + "type": "integer", + "maximum": 9, + "minimum": 1, + "x-display-name": "Zlib Memory Level" + }, + "windowsize": { + "type": "integer", + "maximum": 15, + "minimum": 8, + "x-display-name": "Zlib Window Size" + } + } + }, + "user": { + "description": "HAProxy userlist user", + "type": "object", + "title": "User", "required": [ - "id", - "type" + "username", + "secure_password", + "password" ], "properties": { - "action": { + "groups": { "type": "string", - "enum": [ - "accept", - "reject" - ], - "x-dependency": { - "type": { - "required": true, - "value": "content" - } - }, "x-nullable": false }, - "cond": { + "metadata": { + "additionalProperties": { + "type": "object" + } + }, + "password": { "type": "string", - "enum": [ - "if", - "unless" - ], - "x-dependency": { - "type": { - "value": "content" - } - }, - "x-display-name": "Condition" + "x-nullable": false }, - "cond_test": { + "secure_password": { + "type": "boolean" + }, + "username": { "type": "string", - "x-dependency": { - "cond": { - "required": true + "pattern": "^[A-Za-z0-9-_.:]+$", + "x-nullable": false + } + } + }, + "userlist": { + "description": "Userlist with all it's children resources", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/userlist_base" + }, + { + "type": "object", + "properties": { + "groups": { + "additionalProperties": { + "$ref": "#/definitions/group" + } }, - "type": { - "value": "content" + "users": { + "additionalProperties": { + "$ref": "#/definitions/user" + } } - }, - "x-display-name": "Condition Test", - "x-dynamic-enum": { - "freeFormat": true, - "operation": "getACLs", - "property": "acl_name" + } + } + ], + "x-go-name": "Userlist" + }, + "userlist_base": { + "description": "HAProxy configuration of access control", + "type": "object", + "title": "Userlist Base", + "required": [ + "name" + ], + "properties": { + "metadata": { + "additionalProperties": { + "type": "object" } }, - "id": { - "type": "integer", - "x-nullable": true - }, - "timeout": { - "type": "integer", - "x-dependency": { - "type": { - "required": true, - "value": "inspect-delay" - } - }, - "x-nullable": true - }, - "type": { + "name": { "type": "string", - "enum": [ - "content", - "inspect-delay" - ], + "pattern": "^[A-Za-z0-9-_.:]+$", "x-nullable": false } - }, - "additionalProperties": false, - "example": { - "cond": "if", - "cond_test": "{ src 192.168.0.0/16 }", - "id": 0, - "type": "accept" } }, - "tcp_response_rules": { - "description": "HAProxy TCP response rules array (corresponds to tcp-response directive)", + "userlists": { + "description": "HAProxy userlists array", "type": "array", - "title": "TCP Response Rules Array", + "title": "Userlists", "items": { - "$ref": "#/definitions/tcp_response_rule" + "$ref": "#/definitions/userlist" } }, - "transaction": { - "description": "HAProxy configuration transaction", + "users": { + "description": "HAProxy userlist users array", + "type": "array", + "title": "Users", + "items": { + "$ref": "#/definitions/user" + } + }, + "wurfl_options": { "type": "object", - "title": "Configuration transaction", "properties": { - "_version": { - "type": "integer" + "cache_size": { + "type": "integer", + "x-display-name": "Sets the WURFL Useragent cache size" }, - "id": { + "data_file": { "type": "string", - "pattern": "^[^\\s]+$" + "x-display-name": "The path of the WURFL data file" }, - "status": { + "information_list": { "type": "string", - "enum": [ - "failed", - "in_progress", - "success" - ] + "x-display-name": "A space-delimited list of WURFL capabilities" + }, + "information_list_separator": { + "type": "string", + "x-display-name": "A char that will be used to separate values in a response header containing WURFL results" + }, + "patch_file": { + "type": "string", + "x-display-name": "A list of WURFL patch file paths" } - }, - "example": { - "_version": 2, - "id": "273e3385-2d0c-4fb1-aa27-93cbb31ff203", - "status": "in_progress" - } - }, - "transactions": { - "description": "Configuration transactions array", - "type": "array", - "title": "Transactions array", - "items": { - "$ref": "#/definitions/transaction" } } }, @@ -21251,6 +102118,27 @@ func init() { "name": "force_reload", "in": "query" }, + "full_section": { + "type": "boolean", + "default": false, + "description": "Indicates if the action affects the specified child resources as well", + "name": "full_section", + "in": "query" + }, + "parent_name": { + "type": "string", + "description": "Parent name", + "name": "parent_name", + "in": "path", + "required": true + }, + "skip_reload": { + "type": "boolean", + "default": false, + "description": "If set, no reload will be initiated after update", + "name": "skip_reload", + "in": "query" + }, "transaction_id": { "type": "string", "x-nullable": false, @@ -21274,7 +102162,7 @@ func init() { }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -21286,7 +102174,7 @@ func init() { }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -21298,7 +102186,19 @@ func init() { }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", + "description": "Configuration file version" + } + } + }, + "NotAcceptable": { + "description": "The specified resource cannot be handled", + "schema": { + "$ref": "#/definitions/error" + }, + "headers": { + "Configuration-Version": { + "type": "string", "description": "Configuration file version" } } @@ -21310,7 +102210,7 @@ func init() { }, "headers": { "Configuration-Version": { - "type": "integer", + "type": "string", "description": "Configuration file version" } } @@ -21328,105 +102228,192 @@ func init() { ], "tags": [ { - "description": "API autodiscover endpoints", - "name": "Discovery" + "name": "ACL" }, { - "name": "Information" + "name": "Acme" }, { - "name": "Specification" + "description": "Managing backend configurations (advanced mode)", + "name": "Backend" }, { - "description": "Managing transactions. Configuration changes can be grouped in the transaction. You start the \ntransaction with trasactions POST, and call the configuration changes you need with parameter \ntransaction_id. When you want to commit the transaction, you call the transactions PUT and all changes\nin that transaction is commited. If you call a configuration change without the transaction_id, \ntransaction mechanism is implicitly called with one operation in transaction.\n", - "name": "Transactions" + "name": "BackendSwitchingRule" }, { - "description": "Checking reload success. To avoid constant reloading we reload in intervals that are configurable when\nwith reload-delay option. When a change to configuration is made and force_reload url query string \nparameter is false we issue a request for reload, and return the reload ID in response header. You can\nthen use reloads endpoints to check the status of that reload ID. If force_reload is true, we override all\nof this and reload immediately.\n", - "name": "Reloads" + "description": "Managing frontend bind configurations (advanced mode)", + "name": "Bind" }, { - "description": "Managing sites (simple configuration mode). Sites are considered as one frontend with multiple backends \nconnected to it via default_backend or use-backend directives.\n", - "name": "Sites" + "name": "Cache" }, { - "description": "Stats container", - "name": "Stats" + "name": "Cluster" }, { - "description": "Managing global configuration (advanced mode)", - "name": "Global" + "description": "Raw HAProxy configuration management (advanced mode)", + "name": "Configuration" + }, + { + "name": "CrtLoad" + }, + { + "name": "CrtStore" + }, + { + "name": "DeclareCapture" }, { "description": "Managing defaults configuration (advanced mode)", "name": "Defaults" }, + { + "name": "DgramBind" + }, + { + "description": "API autodiscover endpoints", + "name": "Discovery" + }, + { + "name": "FCGIApp" + }, + { + "name": "Filter" + }, { "description": "Managing frontend configuration (advanced mode)", "name": "Frontend" }, { - "description": "Managing backend configurations (advanced mode)", - "name": "Backend" + "description": "Managing global configuration (advanced mode)", + "name": "Global" }, { - "description": "Managing frontend bind configurations (advanced mode)", - "name": "Bind" + "name": "HTTPCheck" + }, + { + "name": "HTTPErrorRule" + }, + { + "name": "HTTPErrors" + }, + { + "name": "HTTPRequestRule" + }, + { + "name": "HTTPResponseRule" + }, + { + "name": "Information" + }, + { + "name": "LogForward" + }, + { + "name": "LogProfile" + }, + { + "name": "LogTarget" + }, + { + "name": "MailerEntry" + }, + { + "name": "Mailers" + }, + { + "name": "Maps" + }, + { + "name": "Nameserver" + }, + { + "name": "Peer" + }, + { + "name": "PeerEntry" + }, + { + "name": "ProcessManager" + }, + { + "description": "Checking reload success. To avoid constant reloading we reload in intervals that are configurable when\nwith reload-delay option. When a change to configuration is made and force_reload url query string\nparameter is false we issue a request for reload, and return the reload ID in response header. You can\nthen use reloads endpoints to check the status of that reload ID. If force_reload is true, we override all\nof this and reload immediately.\n", + "name": "Reloads" + }, + { + "name": "Resolver" + }, + { + "name": "Ring" }, { "description": "Managing backend server configurations (advanced mode)", "name": "Server" }, { - "description": "Various frontend options (advanced mode)", - "name": "Frontend options" + "name": "ServerSwitchingRule" }, { - "description": "Various backend options (advanced mode)", - "name": "Backend options" + "name": "ServerTemplate" }, { - "description": "Raw HAProxy configuration management (advanced mode)", - "name": "Configuration" + "name": "ServiceDiscovery" }, { - "description": "Managing advanced haproxy configuration (advanced mode)", - "name": "HAProxy configuration management" + "description": "Managing sites (simple configuration mode). Sites are considered as one frontend with multiple backends\nconnected to it via default_backend or use-backend directives.\n", + "name": "Sites" }, { - "name": "TCPRequestRule" + "name": "Specification" }, { - "name": "HTTPRequestRule" + "name": "SpecificationOpenapiv3" }, { - "name": "HTTPResponseRule" + "name": "Spoe" }, { - "name": "BackendSwitchingRule" + "name": "SpoeTransactions" }, { - "name": "ServerSwitchingRule" + "description": "Stats container", + "name": "Stats" + }, + { + "name": "StickRule" + }, + { + "name": "StickTable" + }, + { + "name": "Storage" + }, + { + "name": "TCPCheck" + }, + { + "name": "TCPRequestRule" }, { "name": "TCPResponseRule" }, { - "name": "Filter" + "name": "Table" }, { - "name": "StickRule" + "name": "Traces" }, { - "name": "LogTarget" + "description": "Managing transactions. Configuration changes can be grouped in the transaction. You start the\ntransaction with trasactions POST, and call the configuration changes you need with parameter\ntransaction_id. When you want to commit the transaction, you call the transactions PUT and all changes\nin that transaction is committed. If you call a configuration change without the transaction_id,\ntransaction mechanism is implicitly called with one operation in transaction.\n", + "name": "Transactions" }, { - "name": "ACL" + "name": "Userlist" } ], "externalDocs": { "description": "HAProxy Documentation", - "url": "https://cbonte.github.io/haproxy-dconv/" + "url": "https://docs.haproxy.org/" } }`)) } diff --git a/generate/configuration-example-hcl.tmpl b/generate/configuration-example-hcl.tmpl new file mode 100644 index 00000000..75b12e13 --- /dev/null +++ b/generate/configuration-example-hcl.tmpl @@ -0,0 +1,54 @@ +config_version = 2 +{{- range $i, $MainGroup := .Groups}} + {{- if ne .Name ""}} + {{- if eq .Parent ""}} +{{- if ne $i 1}} +} +{{- end}} + +{{ .Name }} { + + {{- range .Attributes}} + {{- if not .Deprecated}} + {{- if eq .Type "[]string" }} +{{ . | IsListItem }}{{ .FileName }} = [{{ . | QuotedExample }}] +{{- else }} +{{ . | IsListItem }}{{ .FileName }} = {{ . | QuotedExample }} + {{- end}} + {{- end}} + {{- end}} + + {{- $indexinsideLoopFirst := 0}} + {{- range $SubGroup := $.Groups}} + {{- if eq $MainGroup.Name .Parent }} + {{- if ne $indexinsideLoopFirst 0}} + } + {{- end}} + + {{ .Name }} {{- if not .HasACLKey }} { {{- end -}} + {{- range $index,$a := .Attributes -}} + {{- if not .Deprecated -}} + {{- if $SubGroup.HasACLKey }}{{- if eq $index 0 }} {{ . | QuotedExample }} { {{- else }} + {{ .FileName }} = {{ . | QuotedExample }} + {{- end -}}{{- end -}} + {{- if not $SubGroup.HasACLKey }} + {{ .FileName }} = {{ . | QuotedExample }} + {{- end -}} + {{- $indexinsideLoopFirst := 1 }} + {{- end}} + {{- end}} + } + + {{- end}} + {{- end}} + {{- end}} + + {{- else}} + {{- range .Attributes}} + {{- if not .Deprecated}} +{{ .SpecName }} = {{ . | QuotedExample }} + {{- end}} + {{- end}} + {{- end}} +{{- end}} +} diff --git a/generate/configuration-example-yaml.tmpl b/generate/configuration-example-yaml.tmpl new file mode 100644 index 00000000..38c15821 --- /dev/null +++ b/generate/configuration-example-yaml.tmpl @@ -0,0 +1,38 @@ +config_version: 2 +{{- range $MainGroup := .Groups}} + {{- if ne .Name ""}} + {{- if eq .Parent ""}} +{{ .Name }}: + + {{- range .Attributes}} + {{- if not .Deprecated}} + {{- if eq .Type "[]string" }} +{{ . | IsListItem }}{{ .FileName }}: # {{.Type | StripAtomic }} + - {{ . | Example }} +{{- else }} +{{ . | IsListItem }}{{ .FileName }}: {{ . | Example }} # {{.Type | StripAtomic }} + {{- end}} + {{- end}} + {{- end}} + + {{- range $SubGroup := $.Groups}} + {{- if eq $MainGroup.Name .Parent }} + {{ .Name }}: + {{- range .Attributes}} + {{- if not .Deprecated}} + {{ . | IsListItem }}{{ .FileName }}: {{ . | Example }} # {{.Type | StripAtomic }} 2 + {{- end}} + {{- end}} + + {{- end}} + {{- end}} + + {{- end}} + {{- else}} + {{- range .Attributes}} + {{- if not .Deprecated}} +{{ .SpecName }}: {{ . | Example }} # {{.Type | StripAtomic }} + {{- end}} + {{- end}} + {{- end}} +{{- end}} diff --git a/generate/configuration.tmpl b/generate/configuration.tmpl new file mode 100644 index 00000000..d8d53199 --- /dev/null +++ b/generate/configuration.tmpl @@ -0,0 +1,202 @@ +// Code generated by go generate; DO NOT EDIT. +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +import ( + "github.com/jessevdk/go-flags" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/misc" + dpapilog "github.com/haproxytech/dataplaneapi/log" +) +{{- range $MainGroup := .Groups}} + {{- if ne .Name ""}} + + type configType{{ .Name | Capitalize }} struct { + {{- range .Attributes}} + {{- if eq .Type "AtomicString"}} + {{ .Name }} *string `yaml:"{{ .FileName }},omitempty"` + {{- else if eq .Type "AtomicInt"}} + {{ .Name }} *int `yaml:"{{ .FileName }},omitempty"` + {{- else if eq .Type "AtomicBool"}} + {{ .Name }} *bool `yaml:"{{ .FileName }},omitempty"` + {{- else if eq .Type "time.Duration" }} + {{ .Name }} *string `yaml:"{{ .FileName }},omitempty"` + {{- else if eq .Type "flagext.ByteSize" }} + {{ .Name }} *string `yaml:"{{ .FileName }},omitempty"` + {{- else }} + {{ .Name }} *{{ .Type }} `yaml:"{{ .FileName }},omitempty"` + {{- end}} + {{- end}} + {{- range $.Groups}} + {{- if eq $MainGroup.Name .Parent }} + {{- if .IsList }} + {{ .Name | Capitalize }} []configType{{ .Name | Capitalize }} `yaml:"{{ .Name }},omitempty"` + {{- else}} + {{ .Name | Capitalize }} *configType{{ .Name | Capitalize }} `yaml:"{{ .Name }},omitempty"` + {{- end}} + {{- end}} + {{- end}} + } + {{- end}} +{{- end}} + +type StorageDataplaneAPIConfiguration struct { + Version *int `yaml:"config_version,omitempty"` +{{- range .Groups}} + {{- if ne .Name ""}} + {{- if eq .Parent ""}} + {{ .Name | Capitalize }} *configType{{ .Name | Capitalize }} `yaml:"{{ .Name }},omitempty"` + {{- end}} + {{- else}} + {{- range .Attributes}} + {{- if eq .Type "AtomicString"}} + {{ .Name }} *string `yaml:"{{ .SpecName }},omitempty"` + {{- else if eq .Type "AtomicInt"}} + {{ .Name }} *int `yaml:"{{ .SpecName }},omitempty"` + {{- else if eq .Type "AtomicBool"}} + {{ .Name }} *bool `yaml:"{{ .SpecName }},omitempty"` + {{- else if eq .Type "int"}} + {{ .Name }} *int `yaml:"{{ .SpecName }},omitempty"` + {{- else}} + err {{ .Type }} is not supported + {{- end}} + {{- end}} + {{- end}} +{{- end}} +} + +func copyToConfiguration(cfg *Configuration) { + cfgStorage := cfg.storage.Get() +{{- range $group := .Groups}} + {{- if $group.IsList }} + if cfgStorage.{{ $group.Parent | Capitalize }} != nil && cfgStorage.{{ $group.Parent | Capitalize }}.{{ .Name | Capitalize}} != nil { + cfg.{{ .AttName }} = []{{ .OriginalGroup }}{} + for _, item := range cfgStorage.{{ $group.Parent | Capitalize }}.{{ .Name | Capitalize}} { + item{{ $group.OriginalGroup }} := {{ .OriginalGroup }}{ + } + {{- range .Attributes}} + if item.{{ .Name }} != nil { + item{{ $group.OriginalGroup }}.{{ .Name }}= *item.{{ .Name }} + } + {{- end}} + cfg.{{ .AttName }} = append(cfg.{{ .AttName }}, item{{ $group.OriginalGroup }}) + } + } + {{- else}} + {{- range .Attributes}} + {{- if eq $group.AttName "-" }} + if cfgStorage.{{ .Name }} != nil { + cfg.{{ .Name }}.Store(*cfgStorage.{{ .Name }}) + } + {{- else if ne $group.AttName "" }} + {{- if eq $group.Parent "" }} + if cfgStorage.{{ $group.Name | Capitalize }} != nil && cfgStorage.{{ $group.Name | Capitalize }}.{{ .Name }} != nil && !misc.HasOSArg("{{ .Short }}", "{{ .Long }}", "{{ .ENV }}") { + {{- if eq .Type "AtomicString"}} + cfg.{{ .AttName }}.{{ .Name }}.Store(*cfgStorage.{{ $group.Name | Capitalize }}.{{ .Name }}) + {{- else if eq .Type "AtomicInt"}} + cfg.{{ .AttName }}.{{ .Name }}.Store(*cfgStorage.{{ $group.Name | Capitalize }}.{{ .Name }}) + {{- else if eq .Type "AtomicBool"}} + cfg.{{ .AttName }}.{{ .Name }}.Store(*cfgStorage.{{ $group.Name | Capitalize }}.{{ .Name }}) + {{- else}} + cfg.{{ .AttName }}.{{ .Name }} = *cfgStorage.{{ $group.Name | Capitalize }}.{{ .Name }} + {{- end }} + {{- else }} + if cfgStorage.{{ $group.Parent | Capitalize }} !=nil && cfgStorage.{{ $group.Parent | Capitalize }}.{{ $group.Name | Capitalize }} != nil && cfgStorage.{{ $group.Parent | Capitalize }}.{{ $group.Name | Capitalize }}.{{ .Name }} != nil && !misc.HasOSArg("{{ .Short }}", "{{ .Long }}", "{{ .ENV }}") { + cfg.{{ .AttName }}.{{ .Name }} = *cfgStorage.{{ $group.Parent | Capitalize }}.{{ $group.Name | Capitalize }}.{{ .Name }} + {{- end }} + } + {{- else if ne .StructName "Server"}} + if cfgStorage.{{ $group.Name | Capitalize }} != nil && cfgStorage.{{ $group.Name | Capitalize }}.{{ .Name }} != nil && !misc.HasOSArg("{{ .Short }}", "{{ .Long }}", "{{ .ENV }}") { + cfg.{{ .AttName }}.{{ .Name }} = *cfgStorage.{{ $group.Name | Capitalize }}.{{ .Name }} + } + {{- end}} + {{- end}} + {{- end}} +{{- end}} +} + +func copyConfigurationToStorage(cfg *Configuration) { + cfgStorage := cfg.storage.Get() + + version := 2 + cfgStorage.Version = &version + +{{ range $group := .Groups}} + {{ range .Attributes}} + {{ if eq $group.AttName "-" }} + {{- if eq .Type "AtomicString" }} + {{- if not .Deprecated }} + value{{ .Name }} := cfg.{{ .Name }}.Load() + cfgStorage.{{ .Name }}= &value{{ .Name }} + {{- else }} + cfgStorage.{{ .Name }}= nil + {{- end }} + {{- else }} + + cfgStorage.{{ .Name }} = &cfg.{{ .Name }} + {{- end}} + {{ else }} + {{- if .Save }} + {{- if eq .Type "AtomicString" }} + {{- if not .Deprecated }} + value{{$group.Name | Capitalize}}{{ .Name }} := cfg.{{ .AttName }}.{{ .Name }}.Load() + if cfgStorage.Cluster == nil { + cfgStorage.{{ .AttName }} = &configType{{ .AttName }}{} + } + cfgStorage.{{ .AttName }}.{{ .Name }}= &value{{$group.Name | Capitalize}}{{ .Name }} + {{- else }} + if cfgStorage.Cluster != nil { + cfgStorage.{{ .AttName }}.{{ .Name }}= nil + } + {{- end }} + {{- else if eq .Type "AtomicBool" }} + value{{$group.Name | Capitalize}}{{ .Name }} := cfg.{{ .AttName }}.{{ .Name }}.Load() + if cfgStorage.Cluster == nil { + cfgStorage.{{ .AttName }} = &configType{{ .AttName }}{} + } + if cfgStorage.Cluster != nil { + cfgStorage.{{ .AttName }}.{{ .Name }}= &value{{$group.Name | Capitalize}}{{ .Name }} + } + {{- else if eq .Type "AtomicInt" }} + {{- if not .Deprecated }} + value{{$group.Name | Capitalize}}{{ .Name }} := cfg.{{ .AttName }}.{{ .Name }}.Load() + if cfgStorage.Cluster == nil { + cfgStorage.{{ .AttName }} = &configType{{ .AttName }}{} + } + cfgStorage.{{ .AttName }}.{{ .Name }}= &value{{$group.Name | Capitalize}}{{ .Name }} + {{- else }} + if cfgStorage.Cluster != nil { + cfgStorage.{{ .AttName }}.{{ .Name }}= nil + } + {{- end }} + {{- else}} + {{- if $group.Parent }} + if cfgStorage.{{ $group.Parent | Capitalize }} == nil { + cfgStorage.{{ $group.Parent | Capitalize }} = &configType{{ $group.Parent | Capitalize }}{} + } + {{- end }} + if cfgStorage{{ if $group.Parent }}.{{ $group.Parent | Capitalize }}{{ end }}.{{$group.Name | Capitalize}} == nil { + cfgStorage{{ if $group.Parent }}.{{ $group.Parent | Capitalize }}{{ end }}.{{$group.Name | Capitalize }} = &configType{{$group.Name | Capitalize}}{} + } + cfgStorage{{ if $group.Parent }}.{{ $group.Parent | Capitalize }}{{ end }}.{{$group.Name | Capitalize}}.{{ .Name }} = &cfg.{{ .AttName }}.{{ .Name }} + {{- end}} + {{- end}} + {{- end}} + {{- end}} +{{- end}} +} diff --git a/generate/dataplaneapi.tmpl b/generate/dataplaneapi.tmpl new file mode 100644 index 00000000..155e2c07 --- /dev/null +++ b/generate/dataplaneapi.tmpl @@ -0,0 +1,64 @@ +// Code generated by go generate; DO NOT EDIT. +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dataplaneapi + +import ( + "time" + + "github.com/docker/go-units" + "github.com/go-openapi/runtime/flagext" + + "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/misc" +) + +func SyncWithFileSettings(server *Server, cfg *configuration.Configuration) { + configStorage := cfg.GetStorageData() +{{- range $group := .Groups}} +{{- range .Attributes}} +{{- if eq $group.AttName "" }} +{{- if eq .StructName "Server" }} + {{- if eq $group.Parent "" }} + if configStorage.{{ $group.Name | Capitalize }} != nil && configStorage.{{ $group.Name | Capitalize }}.{{ .Name }} != nil && !misc.HasOSArg("{{ .Short }}", "{{ .Long }}", "{{ .ENV }}") { + {{- if eq .Type "time.Duration" }} + if d, err := time.ParseDuration(*configStorage.{{ $group.Name | Capitalize }}.{{ .Name }}); err != nil { + server.{{ .Name }} = d + } + {{- else if eq .Type "flagext.ByteSize" }} + s, err := units.FromHumanSize(*configStorage.{{ $group.Name | Capitalize }}.{{ .Name }}) + if err == nil { + server.{{ .Name }} = flagext.ByteSize(s) + } + {{- else }} + server.{{ .Name }} = *configStorage.{{ $group.Name | Capitalize }}.{{ .Name }} + {{- end }} + {{- else }} + if configStorage.{{ $group.Parent | Capitalize }} != nil && configStorage.{{ $group.Parent | Capitalize }}.{{ $group.Name | Capitalize }} != nil && configStorage.{{ $group.Parent | Capitalize }}.{{ $group.Name | Capitalize }}.{{ .Name }} != nil && !misc.HasOSArg("{{ .Short }}", "{{ .Long }}", "{{ .ENV }}") { + {{- if eq .Type "time.Duration" }} + if d, err := time.ParseDuration(*configStorage.{{ $group.Parent | Capitalize }}.{{ $group.Name | Capitalize }}.{{ .Name }}); err != nil { + server.{{ .Name }} = d + } + {{- else }} + server.{{ .Name }} = *configStorage.{{ $group.Parent | Capitalize }}.{{ $group.Name | Capitalize }}.{{ .Name }} + {{- end }} + {{- end}} + } +{{- end}} +{{- end}} +{{- end}} +{{- end}} +} diff --git a/generate/go-generate.go b/generate/go-generate.go new file mode 100644 index 00000000..6f78aa48 --- /dev/null +++ b/generate/go-generate.go @@ -0,0 +1,479 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package main + +import ( + "errors" + "fmt" + "log" + "os" + "os/exec" + "path" + "path/filepath" + "strconv" + "strings" + "text/template" + "unicode" +) + +var serverGroups = map[string]string{ + "EnabledListeners": "dataplaneapi", + "CleanupTimeout": "dataplaneapi", + "GracefulTimeout": "dataplaneapi", + "MaxHeaderSize": "dataplaneapi", + "SocketPath": "dataplaneapi", + "DebugSocketPath": "dataplaneapi", + "Host": "dataplaneapi", + "Port": "dataplaneapi", + "ListenLimit": "dataplaneapi", + "KeepAlive": "dataplaneapi", + "ReadTimeout": "dataplaneapi", + "WriteTimeout": "dataplaneapi", + "TLSHost": "tls", + "TLSPort": "tls", + "TLSCertificate": "tls", + "TLSCertificateKey": "tls", + "TLSCACertificate": "tls", + "TLSListenLimit": "tls", + "TLSKeepAlive": "tls", + "TLSReadTimeout": "tls", + "TLSWriteTimeout": "tls", +} + +var groupParents = map[string]string{ + "advertised": "dataplaneapi", + "userlist": "dataplaneapi", + "resources": "dataplaneapi", + "transaction": "dataplaneapi", + "tls": "dataplaneapi", + "user": "dataplaneapi", + "reload": "haproxy", + "syslog": "log", + "log_targets": "log", +} + +var itemDefaults = map[string]any{ + "port": 80, + "listen_limit": 1024, + "tls_host": "null", + "tls_port": 6443, + "tls_certificate": "null", + "tls_key": "null", + "tls_ca": "null", + "tls_listen_limit": 10, + "tls_keep_alive": "1m", + "tls_read_timeout": "10s", + "tls_write_timeout": "10s", + "userlist_file": "null", + "backups_dir": "/tmp/backups", + "scheme": "http", +} + +type Attribute struct { + Default string + Group string + Type string + Long string + FileName string + Short string + AttName string + ENV string + Name string + StructName string + SpecName string + Example string + Deprecated bool + Save bool +} + +type ParseGroup struct { + OriginalGroup string + Name string + AttName string + Parent string + Elements []string + Attributes []Attribute + MaxSize int + MaxTypeSize int + HasACLKey bool + IsList bool +} + +type ParseData struct { + Groups []ParseGroup +} + +func readServerData(filePath string, pd *ParseData, structName string, attName string, groupName string, isList bool) { + typeStruct := fmt.Sprintf("type %s struct {", structName) + dat, err := os.ReadFile(filePath) + if err != nil { + log.Panic(err) + } + lines := strings.Split(string(dat), "\n") + inside := false + for _, line := range lines { + if strings.HasPrefix(line, typeStruct) { + inside = true + continue + } + if strings.HasPrefix(line, "}") { + inside = false + continue + } + if inside && strings.Contains(line, "`") { + res, err := processLine(line) + if err != nil { + continue + } + if structName == "Server" { + group, ok := serverGroups[res.Name] + if !ok { + log.Panicf("group not defined for %s in serverGroups", res.Name) + } + res.Group = group + } + res.AttName = attName + res.StructName = structName + found := false + if groupName == "" { + groupName = res.Group + } + for i, g := range pd.Groups { + if g.Name == res.Group { + found = true + g.Attributes = append(g.Attributes, res) + if g.MaxSize < len(res.Name) { + g.MaxSize = len(res.Name) + } + if g.MaxTypeSize < len(res.Type) { + g.MaxSize = len(res.Type) + } + pd.Groups[i] = g + break + } + } + if !found { + pd.Groups = append(pd.Groups, ParseGroup{ + OriginalGroup: structName, + Name: res.Group, + AttName: attName, + Parent: groupParents[res.Group], + MaxSize: len(res.Name), + MaxTypeSize: len(res.Type), + Attributes: []Attribute{res}, + IsList: isList, + }) + } + } + } +} + +func capitalize(str string) string { + if len(str) == 0 { + return "" + } + var res strings.Builder + parts := strings.FieldsFunc(str, split) + for _, part := range parts { + res.WriteString(capitalizeChunk(part)) + } + return res.String() +} + +func split(r rune) bool { + return r == '_' || r == '-' +} + +func capitalizeChunk(str string) string { + if len(str) == 0 { + return "" + } + result := []rune(str) + result[0] = unicode.ToUpper(result[0]) + return string(result) +} + +func stripAtomic(str string) string { + if len(str) == 0 { + return "" + } + if after, ok := strings.CutPrefix(str, "Atomic"); ok { + return strings.ToLower(after) + } + return str +} + +func isListItem(att Attribute) string { + return " " +} + +func getExample(att Attribute) string { + if att.Example != "" { + if att.Type == "int" { + i, _ := strconv.ParseInt(att.Example, 10, 64) + return strconv.FormatInt(i, 10) + } + return att.Example + } + if att.Default != "" { + switch att.Type { + case "int", "int64": + return att.Default + default: + return fmt.Sprintf(`"%s"`, att.Default) + } + } + if att.Type == "bool" { + return `false` + } + if strings.HasPrefix(att.Type, "[]*models.") { + return `[]` + } + if v, ok := itemDefaults[att.FileName]; ok { + switch t := v.(type) { + case int: + return strconv.Itoa(v.(int)) + default: + return t.(string) + } + } + return "null" +} + +func getQuotedExample(att Attribute) string { + if att.Type == "int" || att.Type == "int64" { + switch { + case len(att.Example) > 0: + return att.Example + case len(att.Default) > 0: + return att.Default + } + } + if att.Type == "bool" || att.Type == "AtomicBool" { + if len(att.Example) == 0 { + return `false` + } + return att.Example + } + if strings.HasPrefix(att.Type, "[]*models.") { + return `[]` + } + if att.Example != "" { + return fmt.Sprintf(`"%s"`, att.Example) + } + if att.Default != "" { + return fmt.Sprintf(`"%s"`, att.Default) + } + if v, ok := itemDefaults[att.FileName]; ok { + switch v.(type) { + case int: + return fmt.Sprintf("%d", v) + default: + return fmt.Sprintf(`"%s"`, v) + } + } + return `"null"` +} + +func main() { + dir, err := filepath.Abs(filepath.Dir(os.Args[0])) + if err != nil { + log.Fatal(err) + } + if strings.HasSuffix(dir, "generate") { + dir, err = filepath.Abs(filepath.Dir(os.Args[0]) + "/..") + if err != nil { + log.Fatal(err) + } + } + if len(os.Args) > 1 { + dir = os.Args[1] + } + + pd := &ParseData{ + Groups: []ParseGroup{}, + } + + pd.Groups = append(pd.Groups, ParseGroup{ + Name: "", + AttName: "-", + Parent: "", + MaxSize: 4, + MaxTypeSize: 12, + Attributes: []Attribute{}, + }) + // ######################################## server.go + filePath := path.Join(dir, "server.go") + readServerData(filePath, pd, "Server", "", "", false) + // ######################################## configuration.go + filePath = path.Join(dir, "configuration", "configuration.go") + readServerData(filePath, pd, "Configuration", "-", "", false) + readServerData(filePath, pd, "User", "Users", "", true) + readServerData(filePath, pd, "HAProxyConfiguration", "HAProxy", "", false) + readServerData(filePath, pd, "APIConfiguration", "APIOptions", "", false) + readServerData(filePath, pd, "ServiceDiscovery", "ServiceDiscovery", "", false) + readServerData(filePath, pd, "ClusterConfiguration", "Cluster", "cluster", false) + readServerData(filePath, pd, "SyslogOptions", "Syslog", "", false) + readServerData(filePath, pd, "LoggingOptions", "Logging", "", false) + // readServerData(filePath, pd, "User", "User", "") + // ######################################## + + // prepare template function + funcMap := template.FuncMap{ + "Capitalize": capitalize, + "StripAtomic": stripAtomic, + "Example": getExample, + "QuotedExample": getQuotedExample, + "IsListItem": isListItem, + } + // create configuration_generated + templatePath := path.Join(dir, "generate", "configuration.tmpl") + tmpl, err := template.New("configuration.tmpl").Funcs(funcMap).ParseFiles(templatePath) + if err != nil { + log.Panic(err) + } + tmpl = tmpl.Funcs(funcMap) + filePath = path.Join(dir, "configuration", "configuration_generated.go") + f, err := os.Create(filePath) + if err != nil { + log.Panic(err) + } + defer f.Close() + err = tmpl.Execute(f, pd) + if err != nil { + log.Panic(err) + } + fmtFile(filePath) + // create dataplaneapi_generated + templatePath = path.Join(dir, "generate", "dataplaneapi.tmpl") + tmpl, err = template.New("dataplaneapi.tmpl").Funcs(funcMap).ParseFiles(templatePath) + if err != nil { + log.Panic(err) + } + tmpl = tmpl.Funcs(funcMap) + filePath = path.Join(dir, "dataplaneapi_generated.go") + f, err = os.Create(filePath) + if err != nil { + log.Panic(err) + } + defer f.Close() + err = tmpl.Execute(f, pd) + if err != nil { + log.Panic(err) + } + fmtFile(filePath) + // create configuration example yaml + templatePath = path.Join(dir, "generate", "configuration-example-yaml.tmpl") + tmpl, err = template.New("configuration-example-yaml.tmpl").Funcs(funcMap).ParseFiles(templatePath) + if err != nil { + log.Panic(err) + } + tmpl = tmpl.Funcs(funcMap) + filePath = path.Join(dir, "configuration/examples/example-full.yaml") + f, err = os.Create(filePath) + if err != nil { + log.Panic(err) + } + defer f.Close() + err = tmpl.Execute(f, pd) + if err != nil { + log.Panic(err) + } +} + +func splitBy(c rune) bool { + return c == ' ' || c == '\t' +} + +func processLine(line string) (Attribute, error) { + parts := strings.FieldsFunc(line, splitBy) + var longName string + var envName string + var shortName string + var defaultName string + var group string + var specName string + var save bool + var deprecated bool + var example string + for _, part := range parts[2:] { + if strings.Contains(part, "long:") { + p := strings.Split(part, `"`) + longName = p[1] + } + if strings.Contains(part, "env:") { + p := strings.Split(part, `"`) + envName = p[1] + } + if strings.Contains(part, "short:") { + p := strings.Split(part, `"`) + shortName = p[1] + } + if strings.Contains(part, "default:") { + p := strings.Split(part, `"`) + defaultName = p[1] + } + if strings.Contains(part, "example:") { + p := strings.Split(part, `"`) + example = p[1] + } + if strings.Contains(part, "group:") { + p := strings.Split(part, `"`) + group = p[1] + } + if strings.Contains(part, `save:"true"`) { + save = true + } + if strings.Contains(part, `deprecated:"true"`) { + deprecated = true + } + if strings.Contains(part, `yaml:"-"`) { + return Attribute{}, errors.New("ignore this attribute") + } else if strings.Contains(part, `yaml:"`) { + p := strings.Split(part, `"`) + if strings.Contains(part, `,omitempty`) { + p[1] = strings.Replace(p[1], ",omitempty", "", 1) + } + specName = p[1] + } + } + fileName := longName + if longName == "" { + fileName = specName + } + + // fmt.Println(parts[0], parts[1]) + return Attribute{ + Name: parts[0], + Type: parts[1], + Long: longName, + FileName: strings.ReplaceAll(fileName, "-", "_"), + ENV: envName, + Short: shortName, + Default: defaultName, + Group: group, + SpecName: specName, + Save: save, + Deprecated: deprecated, + Example: example, + }, nil +} + +func fmtFile(filename string) { + cmd := exec.Command("gofmt", "-s", "-w", filename) + err := cmd.Run() + if err != nil { + log.Fatalf("cmd.Run() failed with %s\n", err) + } +} diff --git a/generate/parents/main.go b/generate/parents/main.go new file mode 100644 index 00000000..789b9282 --- /dev/null +++ b/generate/parents/main.go @@ -0,0 +1,105 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package main + +import ( + "bytes" + "fmt" + "os" + "strings" + "text/template" + + "github.com/go-openapi/swag/mangling" + cnparents "github.com/haproxytech/client-native/v6/configuration/parents" +) + +// To generate parent aliases parent_<childType>_generated.go in handler/ +// Usage: go run generate/parents/*.go +// To generate for a new childType, update 2 files: +// - operations.go for the list of operations to generate (Create/Get/...) + +func main() { + fmt.Println("Generating parent aliases") + children := []string{ + cnparents.ServerChildType, + cnparents.HTTPAfterResponseRuleChildType, + cnparents.HTTPCheckChildType, + cnparents.HTTPErrorRuleChildType, + cnparents.HTTPRequestRuleChildType, + cnparents.HTTPResponseRuleChildType, + cnparents.TCPCheckChildType, + cnparents.TCPRequestRuleChildType, + cnparents.TCPResponseRuleChildType, + cnparents.QUICInitialRuleType, + cnparents.ACLChildType, + cnparents.BindChildType, + cnparents.FilterChildType, + cnparents.LogTargetChildType, + } + for _, childType := range children { + res := generateAlias(childType) + + // Create or open a file + fileName := fmt.Sprintf("handlers/parent_%s_generated.go", strings.ToLower(childType)) + fmt.Printf("Generated %s\n", fileName) + file, err := os.Create(fileName) + if err != nil { + fmt.Println("Error creating file:", err) + return + } + defer file.Close() + + // Write the buffer's content to the file + _, err = res.WriteTo(file) + if err != nil { + fmt.Println("Error writing to file:", err) + return + } + } +} + +type TmplData struct { + GoChildType string + ChildType string + Operations []string + OperationPackage string +} + +func generateAlias(childType string) bytes.Buffer { + funcMap := template.FuncMap{ + "parents": cnparents.Parents, + } + parents := cnparents.Parents(childType) + fmt.Printf("Generating for child %s / parents: %v\n", childType, parents) + mangler := mangling.NewNameMangler(mangling.WithAdditionalInitialisms("QUIC")) + tmplData := TmplData{ + ChildType: childType, + GoChildType: mangler.ToGoName(childType), + Operations: operations(childType), + OperationPackage: childType, + } + templateName := "parent_generated.tmpl" + tmpl := template.Must(template.New(templateName).Funcs(funcMap).ParseFiles("generate/parents/" + templateName)) + var result bytes.Buffer + err := tmpl.ExecuteTemplate(&result, templateName, tmplData) + if err != nil { + exitError(err.Error()) + } + return result +} + +func exitError(msg string) { + fmt.Fprintf(os.Stderr, "ERROR: %v\n", msg) + os.Exit(1) +} diff --git a/generate/parents/operations.go b/generate/parents/operations.go new file mode 100644 index 00000000..8b0efe30 --- /dev/null +++ b/generate/parents/operations.go @@ -0,0 +1,148 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package main + +import ( + cnparents "github.com/haproxytech/client-native/v6/configuration/parents" +) + +func operations(childType string) []string { + switch childType { + case cnparents.ServerChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + } + case cnparents.HTTPAfterResponseRuleChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.HTTPCheckChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.HTTPErrorRuleChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.HTTPRequestRuleChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.HTTPResponseRuleChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.TCPCheckChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.TCPRequestRuleChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.TCPResponseRuleChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.QUICInitialRuleType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.ACLChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.BindChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + } + case cnparents.FilterChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + case cnparents.LogTargetChildType: + return []string{ + "Create", + "Get", + "GetAll", + "Delete", + "Replace", + "ReplaceAll", + } + } + return []string{} +} diff --git a/generate/parents/parent_generated.tmpl b/generate/parents/parent_generated.tmpl new file mode 100644 index 00000000..036b4d20 --- /dev/null +++ b/generate/parents/parent_generated.tmpl @@ -0,0 +1,49 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/{{ .OperationPackage }}" +) + +{{$out := .}} + +{{ range $i, $op := $out.Operations -}} +type ( + +{{ range parents $out.ChildType -}} + {{ $op }}{{ $out.GoChildType }}{{ .ParentType }}HandlerImpl {{ $op }}{{ $out.GoChildType }}HandlerImpl +{{ end -}} +) +{{ end -}} + + + + +{{ range $i, $op := $out.Operations -}} +{{ range parents $out.ChildType -}} +func (h *{{ $op }}{{ $out.GoChildType }}{{ .ParentType }}HandlerImpl) Handle(params {{ $out.OperationPackage }}.{{ $op }}{{ $out.GoChildType }}{{ .ParentType }}Params, principal any) middleware.Responder { + g := {{ $op }}{{ $out.GoChildType }}HandlerImpl(*h) + {{ if not .IsGenericParent -}} + pg := {{ $out.OperationPackage }}.{{ $op }}{{ $out.GoChildType }}{{ .GenericParentType }}Params(params) + return g.Handle(cnconstants.{{ .ParentType }}ParentType, pg, principal) + {{ else -}} + return g.Handle(cnconstants.{{ .ParentType }}ParentType, params, principal) + {{ end -}} +} +{{ end -}} +{{ end -}} diff --git a/generate/post_swagger.sh b/generate/post_swagger.sh new file mode 100755 index 00000000..5c60ee9b --- /dev/null +++ b/generate/post_swagger.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e +echo -n " ---> adding serverStartedCallback() to " +sed -i "s/wg.Wait()/serverStartedCallback()\nwg.Wait()/g" server.go +go fmt server.go diff --git a/generate/swagger/Dockerfile b/generate/swagger/Dockerfile new file mode 100644 index 00000000..683a4703 --- /dev/null +++ b/generate/swagger/Dockerfile @@ -0,0 +1,23 @@ +ARG SWAGGER_VERSION + +FROM golang:1.25 AS golang + +FROM quay.io/goswagger/swagger:0.32.3 +COPY --from=golang /usr/local/go /usr/local/go + +ENV PATH="$PATH:/usr/local/go/bin" + +WORKDIR /data +ARG UID +ARG GID +COPY script.sh /generate/swagger/script.sh +COPY templates /generate/swagger/templates +VOLUME ["/data"] + +RUN apk add bash jq && sed -i "s/999/99/" /etc/group && \ + addgroup -g "$GID" -S docker && adduser -u "$UID" -S user -G docker && \ + chmod +x /generate/swagger/script.sh && \ + chown -R "${UID}:${GID}" /data + +USER user +ENTRYPOINT ["/generate/swagger/script.sh"] diff --git a/generate/swagger/script.sh b/generate/swagger/script.sh new file mode 100755 index 00000000..d8c752cb --- /dev/null +++ b/generate/swagger/script.sh @@ -0,0 +1,149 @@ +#!/bin/bash + +set -e +GO_VERSION=$(go version) +echo " ---> go version: $GO_VERSION" +SPEC_DIR=$(mktemp -d) +echo " ---> source folder: $SPEC_DIR" +DST_DIR=$(mktemp -d) +echo " ---> generate folder: $DST_DIR" +# see if we have a replace directive +CN_VERSION=$(go mod edit -json | jq -c -r '.Replace | .[] | select(.Old.Path | contains("github.com/haproxytech/client-native/v6")) | .New.Version' 2>/dev/null | awk -F"-" '{print $NF}') || "" +REMOTE_VERSION=$(go mod edit -json | jq -c -r '.Replace | .[] | select(.Old.Path | contains("github.com/haproxytech/client-native/v6")) | .New.Version' 2>/dev/null | awk -F"/" '{print $1}') || "" +if [ "$REMOTE_VERSION" = "null" ]; then + # we have a local version of CN + CN_VERSION=$(go mod edit -json | jq -c -r '.Replace | .[] | select(.Old.Path | contains("github.com/haproxytech/client-native/v6")) | .New.Path' 2>/dev/null) || "" +fi +# if hash is to short take all of it (example v1.0.0-dev1) +[ "${#CN_VERSION}" -gt 0 ] && [ "${#CN_VERSION}" -lt 6 ] && CN_VERSION=$(go mod edit -json | jq -c -r '.Replace | .[] | select(.Old.Path | contains("github.com/haproxytech/client-native/v6")) | .New.Version') +# check if version is there, if not, use one from require +[ -z "$CN_VERSION" ] && CN_VERSION=$(go mod edit -json | jq -c -r '.Require | .[] | select(.Path | contains("github.com/haproxytech/client-native/v6")) | .Version' 2>/dev/null) +# check if version contains '-' and if it is a 12 char commit hash then use it, if not use the whole tag +suffix=$(echo $CN_VERSION | awk -F"-" '{print$NF}') +[ -z "${CN_VERSION##*"-"*}" ] && [ ${#suffix} -eq 12 ] && CN_VERSION=$suffix +echo " ---> version of client native used: $CN_VERSION" +# extract repository +REPO_PATH=$(go mod edit -json | jq -r '.Replace | .[] | select(.Old.Path | contains("github.com/haproxytech/client-native/v6")) | .New.Path' 2>/dev/null | awk -F"/" '{print $2 "/" $3}') || "" +[ -z "$REPO_PATH" ] && REPO_PATH=haproxytech/client-native + +# extract url, gitlab and github have different urls to raw content +URL_PATH=$(go mod edit -json | jq -r '.Replace | .[] | select(.Old.Path | contains("github.com/haproxytech/client-native/v6")) | .New.Path' 2>/dev/null | awk -F"/" '{print $1}') || "" +EXTRA_PATH="" +if [[ $URL_PATH =~ "gitlab" ]]; then + EXTRA_PATH="-/raw/" +else + URL_PATH=raw.githubusercontent.com +fi + +if [ "$REMOTE_VERSION" = "null" ]; then + SPEC_URL=$(readlink -f $CN_VERSION/specification) + echo " ---> using local version of specification: $SPEC_URL" + echo " ---> copy specification to: $SPEC_DIR/haproxy_spec.yaml" + cp $SPEC_URL/build/haproxy_spec.yaml $SPEC_DIR/haproxy_spec.yaml + echo " ---> copy copyright to : $SPEC_DIR/copyright.txt" + cp $SPEC_URL/copyright.txt $SPEC_DIR/copyright.txt +else + echo " ---> URL path: $URL_PATH" + echo " ---> repository path: $REPO_PATH" + echo " ---> client native version: $CN_VERSION" + SPEC_URL=https://$URL_PATH/$REPO_PATH/$EXTRA_PATH$CN_VERSION/specification + + echo " ---> fetching specification: $SPEC_URL/build/haproxy_spec.yaml" + wget -q -O $SPEC_DIR/haproxy_spec.yaml $SPEC_URL/build/haproxy_spec.yaml + echo " ---> fetching copyright: $SPEC_URL/copyright.txt" + wget -q -O $SPEC_DIR/copyright.txt $SPEC_URL/copyright.txt +fi + +echo "module github.com/haproxytech" > $DST_DIR/go.mod +mkdir -p $DST_DIR/dataplaneapi/operations +cp configure_data_plane.go $DST_DIR/dataplaneapi/configure_data_plane.go + +swagger generate server -f $SPEC_DIR/haproxy_spec.yaml \ + -A "Data Plane" \ + -t $DST_DIR \ + --existing-models github.com/haproxytech/client-native/v6/models \ + --exclude-main \ + --skip-models \ + -s dataplaneapi \ + --additional-initialism=FCGI \ + --additional-initialism=QUIC \ + --tags=Discovery \ + --tags=ServiceDiscovery \ + --tags=Information \ + --tags=Health \ + --tags=Specification \ + --tags=SpecificationOpenapiv3 \ + --tags=Transactions \ + --tags=Sites \ + --tags=Stats \ + --tags=Global \ + --tags=Frontend \ + --tags=Backend \ + --tags=Ring \ + --tags=DgramBind \ + --tags=LogForward \ + --tags=Bind \ + --tags=Server \ + --tags=Configuration \ + --tags=HTTPCheck \ + --tags=HTTPRequestRule \ + --tags=HTTPResponseRule \ + --tags=HTTPAfterResponseRule \ + --tags=HTTPErrorRule \ + --tags=HTTPErrors \ + --tags=BackendSwitchingRule \ + --tags=ServerSwitchingRule \ + --tags=TCPResponseRule \ + --tags=TCPRequestRule \ + --tags=TCPCheck \ + --tags=FCGIApp \ + --tags=Filter \ + --tags=StickRule \ + --tags=LogTarget \ + --tags=Reloads \ + --tags=ACL \ + --tags=Defaults \ + --tags=StickTable \ + --tags=Maps \ + --tags=Nameserver \ + --tags=Cluster \ + --tags=Peer \ + --tags=PeerEntry \ + --tags=ProcessManager \ + --tags=Resolver \ + --tags=Spoe \ + --tags=SpoeTransactions \ + --tags=Storage \ + --tags="ACL Runtime" \ + --tags=ServerTemplate \ + --tags=Cache \ + --tags=DeclareCapture \ + --tags=Userlist \ + --tags=User \ + --tags=Group \ + --tags=MailerEntry \ + --tags=Mailers \ + --tags=Table \ + --tags=CrtStore \ + --tags=CrtLoad \ + --tags=QUICInitialRule \ + --tags=Traces \ + --tags=LogProfile \ + --tags=SSLFrontUse \ + --tags=SSLRuntime \ + --tags=Acme \ + --tags=AcmeRuntime \ + -r $SPEC_DIR/copyright.txt \ + --template-dir generate/swagger/templates + +echo " ---> removing doc.go" +rm doc.go || echo "doc.go does not exists" +echo " ---> removing embedded_spec.go" +rm embedded_spec.go || echo "embedded_spec.go does not exists" +echo " ---> removing server.go" +rm server.go || echo "server.go does not exists" +echo " ---> removing operations/*" +rm -rf operations/* || echo "operations/ does not exists" + +echo " ---> copy generated files to destination" +cp -a $DST_DIR/dataplaneapi/. . diff --git a/generate/swagger/templates/server/parameter.gotmpl b/generate/swagger/templates/server/parameter.gotmpl new file mode 100644 index 00000000..678cb494 --- /dev/null +++ b/generate/swagger/templates/server/parameter.gotmpl @@ -0,0 +1,715 @@ +{{ define "bindprimitiveparam" }}{{/* an empty test definition to test template repo dependencies resolution - DO NOT CHANGE THIS */}} +{{ end }} +{{ define "bodyvalidator" }} + {{- if .HasModelBodyParams }} + // validate body object{{/* delegate validation to model object */}} + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + } + {{- else if and .HasSimpleBodyParams .HasModelBodyItems }} + + {{- if or .Schema.HasSliceValidations .Schema.Items.HasValidations }} + + // validate array of body objects + {{- end }} + + {{- if .Schema.HasSliceValidations }} + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + {{ template "sliceparamvalidator" . }} + {{- end }} + + {{- if and .Schema.Items.HasValidations (not (or .Schema.Items.IsInterface .Schema.Items.IsStream)) }} + for {{ .IndexVar }} := range body { + {{- if .Schema.Items.IsNullable }} + if body[{{ .IndexVar }}] == nil { + {{- if .Schema.Items.Required }} + res = append(res, errors.Required({{ .Child.Path }}, {{ printf "%q" .Child.Location }}, body[{{ .IndexVar }}])) + break + {{- else }} + continue + {{- end }} + } + {{- end }} + if err := body[{{ .IndexVar }}].Validate(route.Formats); err != nil { + res = append(res, err) + break + } + } + + {{- if not .Schema.HasSliceValidations }} + + if len(res) == 0 { + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + } + {{- end }} + {{- else }} + // no validation for items in this slice + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + {{- end }} + + {{- else if and .HasSimpleBodyParams .HasModelBodyMap }} + + {{- if and .Schema.HasValidations (not (or .Schema.AdditionalProperties.IsInterface .Schema.AdditionalProperties.IsStream)) }} + // validate map of body objects + for {{ .KeyVar }} := range body { + {{- if .Schema.AdditionalProperties.Required }} + if err := validate.Required({{ if .Child.Path }}{{ .Child.Path }}{{ else }}""{{ end }}, {{ printf "%q" .Child.Location }}, {{ if not .IsAnonymous }}{{ .Schema.GoType }}({{ end }}body[{{ .KeyVar }}]{{ if not .IsAnonymous }}){{ end }}); err != nil { + return err + } + {{- end }} + {{- if and .Schema.AdditionalProperties.IsNullable (not .IsMapNullOverride) }} + if body[{{ .KeyVar }}] == nil { + {{- if .Schema.AdditionalProperties.Required }} + res = append(res, errors.Required({{ .Path }}, {{ printf "%q" .Location }}, body[{{ .KeyVar }}])) + break + {{- else }} + continue + {{- end }} + } + {{- end }} + if val , ok :=body[{{ .KeyVar }}]; ok { + {{- if and .IsNullable (not .IsMapNullOverride) }} + if val != nil { + {{- end }} + if err := val.Validate(route.Formats); err != nil { + res = append(res, err) + break + } + {{- if and .IsNullable (not .IsMapNullOverride) }} + } + {{- end }} + } + } + + if len(res) == 0 { + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + } + {{- else }} + // no validation for this map + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + {{- end }} + {{- else if .HasSimpleBodyParams }} + {{- if and (not .IsArray) (not .IsMap) .Schema.HasValidations }} + // validate inline body + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + if err := {{ .ReceiverName }}.validate{{ pascalize .ID }}Body(route.Formats); err != nil { + res = append(res, err) + } + {{- else if and (or .IsArray .IsMap) .Schema.HasValidations }} + // validate inline body {{ if .IsArray }}array{{ else }}map{{ end }} + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + if err := {{ .ReceiverName }}.validate{{ pascalize .ID }}Body(route.Formats); err != nil { + res = append(res, err) + } + {{- else }} + // no validation required on inline body + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + {{- end}} + {{- else }} + {{- if .IsInterface }} + // no validation on generic interface + {{ .ReceiverName }}.{{ pascalize .Name }} = {{ if and (not .Schema.IsBaseType) .IsNullable }}&{{ end }}body + {{- end }} + {{- end }} +{{- end }} + +{{ define "sliceparamvalidator"}} + {{- if or .MinItems .MaxItems }} + + {{ camelize .Name }}Size := int64(len({{ if and (not .IsArray) (not .HasDiscriminator) (not .IsInterface) (not .IsStream) .IsNullable }}*{{ end }}{{ if and .Child (not (hasPrefix .ValueExpression "o.")) }}{{ .Child.ValueExpression }}C{{ else }}{{ .ValueExpression }}{{ end }})) + {{- end }} + {{- if .MinItems }} + +// {{ .ItemsDepth }}minItems: {{ .MinItems }} +if err := validate.MinItems({{ .Path }}, {{ printf "%q" .Location }}, {{ camelize .Name }}Size, {{ .MinItems }}); err != nil { + return err +} + {{- end }} + {{- if .MaxItems }} + +// {{ .ItemsDepth }}maxItems: {{ .MaxItems }} +if err := validate.MaxItems({{ .Path }}, {{ printf "%q" .Location }}, {{ camelize .Name }}Size, {{.MaxItems}}); err != nil { + return err +} + {{- end }} + {{- if .UniqueItems }} + +// {{ .ItemsDepth }}uniqueItems: true +if err := validate.UniqueItems({{ .Path }}, {{ printf "%q" .Location }}, {{ if and (not .IsArray) (not .HasDiscriminator) (not .IsInterface) (not .IsStream) .IsNullable }}*{{ end }}{{ if and .Child (not ( hasPrefix .ValueExpression "o." )) }}{{ .Child.ValueExpression }}C{{ else }}{{ .ValueExpression }}{{ end }}); err != nil { + return err +} + {{- end }} + {{- if .Enum }} + +// {{ .ItemsDepth }}Enum: {{ .Enum }} +if err := validate.EnumCase( + {{- .Path }}, {{ printf "%q" .Location }}, + {{- if and (not .IsArray) (not .HasDiscriminator) (not .IsInterface) (not .IsStream) .IsNullable }}*{{ end -}} + {{- if .Child -}} + {{- if not ( hasPrefix .ValueExpression "o." ) -}} + {{- .Child.ValueExpression }}C{{- if .IsCustomFormatter }}.String(){{ end -}} + {{- else -}} + {{- .ValueExpression -}}{{- if .Child.IsCustomFormatter }}.String(){{ end -}} + {{- end -}} + {{- end -}}, + {{- printf "%#v" .Enum -}}, {{ if .IsEnumCI }}false{{ else }}true{{ end }}); err != nil { + return err + } + {{- end }} +{{- end }} + +{{- define "childvalidator" }} + {{- if .Converter }} + {{- if ne .SwaggerFormat "" }} + // {{ .ItemsDepth }}Format: {{ printf "%q" .SwaggerFormat }} + {{- end }} + {{ varname .ValueExpression }}, err := {{ .Converter }}({{ varname .ValueExpression }}V) + if err != nil { + return errors.InvalidType({{ .Path }}, {{ printf "%q" .Location }}, "{{ .GoType }}", {{ varname .ValueExpression }}) + } + {{- else if and .IsCustomFormatter (not .SkipParse) }}{{/* parsing is skipped for simple body items */}} + // {{ .ItemsDepth }}Format: {{ printf "%q" .SwaggerFormat }} + value, err := formats.Parse({{ printf "%q" .SwaggerFormat }},{{ varname .ValueExpression }}V) + if err != nil { + return errors.InvalidType({{ .Path }}, {{ printf "%q" .Location }}, "{{ .GoType }}", value) + } + {{ varname .ValueExpression }} := *(value.(*{{.GoType}})) + {{- else if and .IsComplexObject .HasValidations }}{{/* dedicated to nested body params */}} + {{ varname .ValueExpression }} := {{ varname .ValueExpression }}V + if err := {{ .ValueExpression }}.Validate(formats) ; err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName({{ .Path }}) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName({{ .Path }}) + } + return err + } + {{- else }} + {{ varname .ValueExpression }} := {{ varname .ValueExpression }}V + {{- end }} + {{ template "propertyparamvalidator" . }} +{{- end }} + +{{- define "mapparamvalidator" }} + {{- if and .Child.HasValidations (not (or .Child.IsInterface .Child.IsStream)) }} + + // validations for map + {{- else }} + + // map has no validations: copying all elements + {{- end }} + {{ varname .Child.ValueExpression }}R := make({{ .GoType }},len({{ .Child.ValueExpression }}C)) + for {{ .KeyVar }}, {{ .Child.ValueExpression }}V := range {{ .Child.ValueExpression}}C { + {{- if .Child.IsArray }} + {{ .Child.Child.ValueExpression }}C := {{ varname .Child.ValueExpression }}V + {{- if .Child.HasSliceValidations }} + {{- template "sliceparamvalidator" .Child }} + {{- end }} + {{- template "sliceparambinder" .Child }} + {{- else if .Child.IsMap }} + {{ .Child.Child.ValueExpression }}C := {{ varname .Child.ValueExpression }}V + {{ template "mapparamvalidator" .Child }} + {{- else }} + {{- if and .Child.IsNullable }} + if {{ varname .Child.ValueExpression }}V == nil { + {{- if .Child.Required }} + return errors.Required({{ .Child.Path }}, {{ printf "%q" .Child.Location }}, {{ varname .Child.ValueExpression }}V) + {{- else }} + continue + {{- end }} + } + {{- end }} + {{- template "childvalidator" .Child }} + {{- end }} + {{ varname .Child.ValueExpression }}R[{{.KeyVar}}] = {{ varname .Child.ValueExpression }}{{ if or .Child.IsArray .Child.IsMap}}IR{{end}} + } +{{- end }} + +{{- define "propertyparamvalidator" }} + {{- if .IsPrimitive }} + {{ template "validationPrimitive" . }} + {{- end }} + {{- if and .IsCustomFormatter (not .IsStream) (not .IsBase64) }} + +if err := validate.FormatOf({{.Path}}, "{{.Location}}", "{{.SwaggerFormat}}", {{ .ValueExpression}}.String(), formats); err != nil { + return err +} + {{- end }} + {{- if .IsArray }}{{/* slice validations */}} + {{ template "sliceparamvalidator" . }} + {{- else if .IsMap }} + {{ .Child.ValueExpression }}C := {{ varname .Child.ValueExpression }}V + {{ template "mapparamvalidator" . }} + {{- end }} +{{- end }} + +{{ define "sliceparambinder" }} +var {{ varname .Child.ValueExpression }}R {{ .GoType }} +for {{ if .Child.NeedsIndex }}{{ .IndexVar }}{{ else }}_{{ end }}, {{ varname .Child.ValueExpression }}V := range {{ varname .Child.ValueExpression }}C { + {{- if .Child.IsArray }}{{/* recursive resolution of arrays in params */}} + {{- if not .Child.SkipParse }} + // {{ .Child.ItemsDepth }}CollectionFormat: {{ .Child.CollectionFormat }} + {{- end }} + {{ .Child.Child.ValueExpression }}C := {{ if .Child.SkipParse }}{{ varname .Child.ValueExpression }}V{{ else }}swag.SplitByFormat({{ varname .Child.ValueExpression }}V, {{ printf "%q" .Child.CollectionFormat }}){{ end }} + {{- if .Child.HasSliceValidations }} + {{- template "sliceparamvalidator" .Child }} + {{- end }} + if len({{ varname .Child.Child.ValueExpression }}C) > 0 { + {{ template "sliceparambinder" .Child }} + {{ varname .Child.ValueExpression }}R = append({{ varname .Child.ValueExpression }}R, {{ varname .Child.ValueExpression }}{{ if or .Child.IsArray .Child.IsMap }}IR{{end}}) + } + {{- else if .Child.IsMap }}{{/* simple map in items (possible with body params)*/}} + {{ .Child.Child.ValueExpression }}C := {{ varname .Child.ValueExpression }}V + {{- template "mapparamvalidator" .Child }} + {{ varname .Child.ValueExpression }}R = append({{ varname .Child.ValueExpression }}R, {{ varname .Child.ValueExpression }}{{ if or .Child.IsArray .Child.IsMap }}IR{{end}}) + {{- else }}{{/* non-array && non-map type in items */}} + {{- if and .Child.IsNullable (not .IsMapNullOverride) }} + if {{ varname .Child.ValueExpression }}V == nil { + {{- if .Child.Required }} + return errors.Required({{ .Child.Path }}, {{ printf "%q" .Child.Location }}, {{ varname .Child.ValueExpression }}V) + {{- else }} + continue + {{- end }} + } + {{- end }} + {{- template "childvalidator" .Child }} + {{ varname .Child.ValueExpression }}R = append({{ varname .Child.ValueExpression }}R, {{ varname .Child.ValueExpression }}{{ if or .Child.IsArray .Child.IsMap }}IR{{end}}) + {{- end }} +} +{{ end }} +// Code generated by go-swagger; DO NOT EDIT. + + +{{ if .Copyright -}}// {{ comment .Copyright -}}{{ end }} + + +package {{ .Package }} + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + {{ imports .DefaultImports }} + {{ imports .Imports }} +) + +{{- if .HasFormParams }} + +// {{ pascalize .Name }}MaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var {{ pascalize .Name }}MaxParseMemory int64 = 32 << 20 +{{- end }} + +// New{{ pascalize .Name }}Params creates a new {{ pascalize .Name }}Params object +{{- if .Params.HasSomeDefaults }} +// with the default values initialized. +{{- else }} +// +// There are no default values defined in the spec. +{{- end }} +func New{{ pascalize .Name }}Params() {{ pascalize .Name }}Params { +{{ if .Params.HasSomeDefaults }} + var ( + // initialize parameters with default values + {{ range .Params }} + {{ if .HasDefault -}} + {{ if not .IsFileParam }}{{ varname .ID}}Default = + {{- if and .IsPrimitive .IsCustomFormatter (not (stringContains .Zero "(\"" )) }}{{ .Zero }}{{/* strfmt type initializer requires UnmarshalText(), e.g. Date, Datetime, Duration */}} + {{- else if and .IsPrimitive .IsCustomFormatter (stringContains .Zero "(\"" ) }}{{.GoType}}({{- printf "%#v" .Default }}){{/* strfmt type initializer takes string */}} + {{- else if and .IsPrimitive (not .IsCustomFormatter) -}}{{.GoType}}({{- printf "%#v" .Default }}){{/* regular go primitive type initializer */}} + {{- else if .IsArray -}}{{- /* Do not initialize from possible defaults in nested arrays */ -}} + {{- if and .Child.IsPrimitive .Child.IsCustomFormatter }}{{ .Zero }}{{/* initialization strategy with UnmarshalText() */}} + {{- else if .Child.IsArray -}}{{ .Zero }}{{/* initialization strategy with json.Unmarshal() */}} + {{- else if and .Child.IsPrimitive (not .Child.IsCustomFormatter) -}}{{.GoType}}{{- arrayInitializer .Default }}{{/* regular go primitive type initializer: simple slice initializer */}} + {{- else }}{{ printf "%#v" .Default }}{{/* all other cases (e.g. schema) [should not occur] */}} + {{- end }} + {{- else }}{{ printf "%#v" .Default }}{{/* case .Schema */}} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + ) + +{{ range .Params }}{{ if .HasDefault -}}{{- /* carry out UnmarshalText initialization strategy */ -}} + {{ if and .IsPrimitive .IsCustomFormatter (not (stringContains .Zero "(\"")) }}{{ varname .ID}}Default.UnmarshalText([]byte({{ printf "%q" .Default }})) + {{ else if .IsArray -}} + {{ if or ( and .Child.IsPrimitive .Child.IsCustomFormatter ) .Child.IsArray -}} + if err := json.Unmarshal([]byte(`{{printf "%s" (json .Default)}}`), &{{ varname .ID }}Default); err != nil { + // panics if specification is invalid + msg := fmt.Sprintf("invalid default value for parameter {{ varname .ID }}: %v",err) + panic(msg) + } + {{ end -}} + {{- end }} + {{ end -}} +{{- end }} +{{ end }} + return {{ pascalize .Name }}Params{ {{ range .Params }}{{ if .HasDefault }} + {{ pascalize .ID}}: {{ if and (not .IsArray) (not .HasDiscriminator) (not .IsInterface) (not .IsStream) .IsNullable }}&{{ end }}{{ varname .ID }}Default, + {{ end }}{{ end }} } +} + +// {{ pascalize .Name }}Params contains all the bound params for the {{ humanize .Name }} operation +// typically these are obtained from a http.Request +// +// swagger:parameters {{ .Name }} +type {{ pascalize .Name }}Params struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + {{ range .Params }}/*{{ if .Description }}{{ blockcomment .Description }}{{ end }}{{ if .Required }} + Required: true{{ end }}{{ if .Maximum }} + Maximum: {{ if .ExclusiveMaximum }}< {{ end }}{{ .Maximum }}{{ end }}{{ if .Minimum }} + Minimum: {{ if .ExclusiveMinimum }}> {{ end }}{{ .Minimum }}{{ end }}{{ if .MultipleOf }} + Multiple Of: {{ .MultipleOf }}{{ end }}{{ if .MaxLength }} + Max Length: {{ .MaxLength }}{{ end }}{{ if .MinLength }} + Min Length: {{ .MinLength }}{{ end }}{{ if .Pattern }} + Pattern: {{ .Pattern }}{{ end }}{{ if .MaxItems }} + Max Items: {{ .MaxItems }}{{ end }}{{ if .MinItems }} + Min Items: {{ .MinItems }}{{ end }}{{ if .UniqueItems }} + Unique: true{{ end }}{{ if .Location }} + In: {{ .Location }}{{ end }}{{ if .CollectionFormat }} + Collection Format: {{ .CollectionFormat }}{{ end }}{{ if .HasDefault }} + Default: {{ printf "%#v" .Default }}{{ end }} + */ + {{ if not .Schema }}{{ pascalize .ID }} {{ if and (not .IsArray) (not .HasDiscriminator) (not .IsInterface) (not .IsStream) .IsNullable }}*{{ end }}{{.GoType}}{{ else }}{{ pascalize .Name }} {{ if and (not .Schema.IsBaseType) .IsNullable (not .Schema.IsStream) }}*{{ end }}{{.GoType}}{{ end }} + {{ end}} +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with New{{ pascalize .Name }}Params() beforehand. +func ({{ .ReceiverName }} *{{ pascalize .Name }}Params) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + {{ .ReceiverName }}.HTTPRequest = r + +{{- if .HasQueryParams }} + + qs := runtime.Values(r.URL.Query()) +{{- end }} + +{{- if .HasFormParams }} + + if err := r.ParseMultipartForm({{ pascalize .Name }}MaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400,"%v",err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400,"%v",err) + } + } + {{- if .HasFormValueParams }} + fds := runtime.Values(r.Form) + {{- end }} +{{- end }} +{{ range .Params }} + {{- if not .IsArray }} + {{- if .IsQueryParam }} + + q{{ pascalize .Name }}, qhk{{ pascalize .Name }}, _ := qs.GetOK({{ .Path }}) + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(q{{ pascalize .Name }}, qhk{{ pascalize .Name }}, route.Formats); err != nil { + res = append(res, err) + } + {{- else if .IsPathParam }} + + r{{ pascalize .Name }}, rhk{{ pascalize .Name }}, _ := route.Params.GetOK({{ .Path }}) + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(r{{ pascalize .Name }}, rhk{{ pascalize .Name }}, route.Formats); err != nil { + res = append(res, err) + } + {{- else if .IsHeaderParam }} + + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(r.Header[http.CanonicalHeaderKey({{ .Path }})], true, route.Formats); err != nil { + res = append(res, err) + } + {{- else if .IsFormParam }} + {{- if .IsFileParam }} + + {{ camelize .Name }}, {{ camelize .Name }}Header, err := r.FormFile({{ .Path }}) + if err != nil {{ if .IsNullable }}&& err != http.ErrMissingFile{{ end }}{ + res = append(res, errors.New(400, "reading file %q failed: %v", {{ printf "%q" (camelize .Name) }}, err)) + {{- if .IsNullable }} + } else if err == http.ErrMissingFile { + // no-op for missing but optional file parameter + {{- end }} + } else if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}({{ camelize .Name }}, {{ camelize .Name }}Header); err != nil { + {{- if .Required }} + // Required: true + {{- end }} + res = append(res, err) + } else { + {{ .ReceiverName }}.{{ pascalize .Name }} = &runtime.File{Data: {{ camelize .Name }}, Header: {{ camelize .Name }}Header} + } + {{- else }} + + fd{{ pascalize .Name }}, fdhk{{ pascalize .Name }}, _ := fds.GetOK({{ .Path }}) + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(fd{{ pascalize .Name }}, fdhk{{ pascalize .Name }}, route.Formats); err != nil { + res = append(res, err) + } + {{- end }} + {{- end }} + {{- else if .IsArray }} + {{- if .IsQueryParam }} + + q{{ pascalize .Name }}, qhk{{ pascalize .Name }}, _ := qs.GetOK({{ .Path }}) + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(q{{ pascalize .Name }}, qhk{{ pascalize .Name }}, route.Formats); err != nil { + res = append(res, err) + } + {{- else if .IsPathParam }} + + r{{ pascalize .Name }}, rhk{{ pascalize .Name }}, _ := route.Params.GetOK({{ .Path }}) + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(r{{ pascalize .Name }}, rhk{{ pascalize .Name }}, route.Formats); err != nil { + res = append(res, err) + } + {{- else if .IsHeaderParam }} + + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(r.Header[http.CanonicalHeaderKey({{ .Path }})], true, route.Formats); err != nil { + res = append(res, err) + } + {{- else if and .IsFormParam }} + + fd{{ pascalize .Name }}, fdhk{{ pascalize .Name }}, _ := fds.GetOK({{ .Path }}) + if err := {{ .ReceiverName }}.bind{{ pascalize .ID }}(fd{{ pascalize .Name }}, fdhk{{ pascalize .Name }}, route.Formats); err != nil { + res = append(res, err) + } + {{- end }} + {{- end }} + + {{- if and .IsBodyParam .Schema }} + + if runtime.HasBody(r) { + {{- if .Schema.IsStream }} + {{ .ReceiverName }}.{{ pascalize .Name }} = r.Body + {{- else }} + defer r.Body.Close() + {{- if and .Schema.IsBaseType .Schema.IsExported }} + body, err := {{ toPackageName .ModelsPackage }}.Unmarshal{{ dropPackage .GoType }}{{ if .IsArray }}Slice{{ end }}(r.Body, route.Consumer) + if err != nil { + {{- if .Required }} + if err == io.EOF { + err = errors.Required({{ .Path }}, {{ printf "%q" .Location }}, "") + } + {{- end }} + res = append(res, err) + {{- else }} + var body {{ .GoType }} + if err := route.Consumer.Consume(r.Body, &body); err != nil { + {{- if .Required }} + if err == io.EOF { + res = append(res, errors.Required({{ printf "%q" (camelize .Name) }}, {{ printf "%q" .Location }}, "")) + } else { + {{- end }} + res = append(res, errors.NewParseError({{ printf "%q" (camelize .Name) }}, {{ printf "%q" .Location }}, "", err)) + {{- if .Required }} + } + {{- end }} + {{- end }} + } else { + {{- template "bodyvalidator" . }} + } + {{- end }} + } + {{- if .Required }} else { + res = append(res, errors.Required({{ printf "%q" (camelize .Name) }}, {{ printf "%q" .Location }}, "")) + } + {{- end }} + {{- end }} +{{- end }} + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +{{- $className := (pascalize .Name) }} +{{ range .Params }} + {{- if .IsFileParam }} +// bind{{ pascalize .ID }} binds file parameter {{ .ID }}. +// +// The only supported validations on files are MinLength and MaxLength +func ({{ .ReceiverName }} *{{ $className }}Params) bind{{ pascalize .ID }}(file multipart.File, header *multipart.FileHeader) error { + {{- if or .MinLength .MaxLength }} + size, _ := file.Seek(0, io.SeekEnd) + file.Seek(0, io.SeekStart) + {{- end }} + {{- if .MinLength}} + if size < {{.MinLength}} { + return errors.ExceedsMinimum({{ .Path }}, {{ printf "%q" .Location }}, {{ .MinLength }}, false, size) + } + {{- end }} + {{- if .MaxLength}} + if size > {{.MaxLength}} { + return errors.ExceedsMaximum({{ .Path }}, {{ printf "%q" .Location }}, {{ .MaxLength }}, false, size) + } + {{- end }} + return nil +} + {{- else if not .IsBodyParam }} + {{- if or .IsPrimitive .IsCustomFormatter }} + +// bind{{ pascalize .ID }} binds and validates parameter {{ .ID }} from {{ .Location }}. +func ({{ .ReceiverName }} *{{ $className }}Params) bind{{ pascalize .ID }}(rawData []string, hasKey bool, formats strfmt.Registry) error { + {{- if and (not .IsPathParam) .Required }} + if !hasKey { + return errors.Required({{ .Path }}, {{ printf "%q" .Location }}, rawData) + } + {{- end }} + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: {{ .Required }} + {{- if .IsQueryParam }} + // AllowEmptyValue: {{ .AllowEmptyValue }} + {{- end }} + {{- if .IsPathParam }} + // Parameter is provided by construction from the route + {{- end }} + + {{- if and (not .IsPathParam) .Required (not .AllowEmptyValue) }} + + if err := validate.RequiredString({{ .Path }}, {{ printf "%q" .Location }}, raw); err != nil { + return err + } + {{- else if and ( not .IsPathParam ) (or (not .Required) .AllowEmptyValue) }} + + if raw == "" { // empty values pass all other validations + {{- if .HasDefault }} + // Default values have been previously initialized by New{{ $className }}Params() + {{- end }} + return nil + } + {{- end }} + + {{- if .Converter }} + + value, err := {{ .Converter }}(raw) + if err != nil { + return errors.InvalidType({{ .Path }}, {{ printf "%q" .Location }}, {{ printf "%q" .GoType }}, raw) + } + {{ .ValueExpression }} = {{ if .IsNullable }}&{{ end }}value + {{- else if .IsCustomFormatter }} + + // Format: {{ .SwaggerFormat }} + value, err := formats.Parse({{ printf "%q" .SwaggerFormat }}, raw) + if err != nil { + return errors.InvalidType({{ .Path }}, {{ printf "%q" .Location }}, {{ printf "%q" .GoType }}, raw) + } + {{ .ValueExpression }} = {{ if or .IsArray .HasDiscriminator .IsFileParam .IsStream (not .IsNullable) }}*{{ end }}(value.(*{{ .GoType }})) + {{- else}} + {{ .ValueExpression }} = {{ if .IsNullable }}&{{ end }}raw + {{- end }} + + {{- if .HasValidations }} + + if err := {{ .ReceiverName }}.validate{{ pascalize .ID }}(formats); err != nil { + return err + } + {{- end }} + + return nil +} + {{- else if .IsArray }} + +// bind{{ pascalize .ID }} binds and validates array parameter {{ .ID }} from {{ .Location }}. +// +// Arrays are parsed according to CollectionFormat: "{{ .CollectionFormat }}" (defaults to "csv" when empty). +func ({{ .ReceiverName }} *{{ $className }}Params) bind{{ pascalize .ID }}(rawData []string, hasKey bool, formats strfmt.Registry) error { + {{- if .Required }} + if !hasKey { + return errors.Required({{ .Path }}, {{ printf "%q" .Location }}, rawData) + } + {{- end }} + {{- if eq .CollectionFormat "multi" }} + // CollectionFormat: {{ .CollectionFormat }} + {{ varname .Child.ValueExpression }}C := rawData + {{- else }} + var qv{{ pascalize .Name }} string + if len(rawData) > 0 { + qv{{ pascalize .Name }} = rawData[len(rawData) - 1] + } + + // CollectionFormat: {{ .CollectionFormat }} + {{ varname .Child.ValueExpression }}C := swag.SplitByFormat(qv{{ pascalize .Name }}, {{ printf "%q" .CollectionFormat }}) + {{- end }} + {{- if and .Required (not .AllowEmptyValue) }} + if len({{ varname .Child.ValueExpression }}C) == 0 { + return errors.Required({{ .Path }}, {{ printf "%q" .Location }}, {{ varname .Child.ValueExpression }}C) + } + {{- else }} + if len({{ varname .Child.ValueExpression }}C) == 0 { + {{- if .HasDefault }} + // Default values have been previously initialized by New{{ $className }}Params() + {{- end }} + return nil + } {{- end }} + {{ template "sliceparambinder" . }} + {{ .ValueExpression }} = {{ varname .Child.ValueExpression }}R + {{- if .HasSliceValidations }} + if err := {{ .ReceiverName }}.validate{{ pascalize .ID }}(formats); err != nil { + return err + } + {{- end }} + + return nil +} + {{- end }} + + {{- if or (and (not .IsArray) .HasValidations) (and .IsArray .HasSliceValidations) }} + +// validate{{ pascalize .ID }} carries on validations for parameter {{ .ID }} +func ({{ .ReceiverName }} *{{ $className }}Params) validate{{ pascalize .ID }}(formats strfmt.Registry) error { + {{ template "propertyparamvalidator" . }} + return nil +} + {{- end }} + + {{- else if .IsBodyParam }}{{/* validation method for inline body parameters with validations */}} + {{- if and .HasSimpleBodyParams (not .HasModelBodyItems) (not .HasModelBodyMap) }} + {{- if .Schema.HasValidations }} + +// validate{{ pascalize .ID }}Body validates an inline body parameter +func ({{ .ReceiverName }} *{{ $className }}Params) validate{{ pascalize .ID }}Body(formats strfmt.Registry) error { + {{- if .IsArray }} + {{- if .HasSliceValidations }} + {{- template "sliceparamvalidator" . }} + {{- end }} + {{- if .Child.HasValidations }} + {{ varname .Child.ValueExpression }}C := {{ .ValueExpression }} + {{ template "sliceparambinder" . }} + {{ .ValueExpression }} = {{ varname .Child.ValueExpression }}R + {{- end }} + {{- else if .IsMap }} + {{ varname .Child.ValueExpression }}C := {{ .ValueExpression }} + {{ template "mapparamvalidator" . }} + {{ .ValueExpression }} = {{ varname .Child.ValueExpression }}R + {{- else }} + {{ template "propertyparamvalidator" . }} + {{- end }} + return nil +} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/go.mod b/go.mod index 9afa0842..3ced3509 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,175 @@ module github.com/haproxytech/dataplaneapi -go 1.12 +go 1.25 require ( - github.com/GehirnInc/crypt v0.0.0-20190301055215-6c0105aabd46 - github.com/docker/go-units v0.4.0 - github.com/go-openapi/errors v0.19.0 - github.com/go-openapi/loads v0.19.0 - github.com/go-openapi/runtime v0.19.0 - github.com/go-openapi/spec v0.19.0 - github.com/go-openapi/strfmt v0.19.0 - github.com/go-openapi/swag v0.19.0 - github.com/go-openapi/validate v0.19.0 - github.com/haproxytech/client-native v1.2.7-0.20191014132956-b019aa5097ae - github.com/haproxytech/config-parser v1.1.11-0.20191010080921-251bc0c7bdac - github.com/haproxytech/models v1.2.5-0.20191014095528-ac55cbc13783 - github.com/jessevdk/go-flags v1.4.0 - github.com/rs/cors v1.6.0 - github.com/shirou/gopsutil v2.18.12+incompatible - github.com/sirupsen/logrus v1.4.2 - golang.org/x/net v0.0.0-20190607181551-461777fb6f67 - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 + github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 + github.com/KimMachineGun/automemlimit v0.7.4 + github.com/Masterminds/semver v1.5.0 + github.com/aws/aws-sdk-go-v2 v1.39.2 + github.com/aws/aws-sdk-go-v2/config v1.31.12 + github.com/aws/aws-sdk-go-v2/credentials v1.18.16 + github.com/aws/aws-sdk-go-v2/service/autoscaling v1.56.0 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.254.1 + github.com/docker/go-units v0.5.0 + github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 + github.com/fsnotify/fsnotify v1.9.0 + github.com/getkin/kin-openapi v0.133.0 + github.com/go-openapi/errors v0.22.6 + github.com/go-openapi/loads v0.23.2 + github.com/go-openapi/runtime v0.29.0 + github.com/go-openapi/spec v0.22.3 + github.com/go-openapi/strfmt v0.25.0 + github.com/go-openapi/swag v0.25.4 + github.com/go-openapi/swag/cmdutils v0.25.4 + github.com/go-openapi/swag/mangling v0.25.4 + github.com/go-openapi/validate v0.25.1 + github.com/google/go-cmp v0.7.0 + github.com/google/renameio v1.0.1 + github.com/google/uuid v1.6.0 + github.com/haproxytech/client-native/v6 v6.3.0 + github.com/jessevdk/go-flags v1.6.1 + github.com/joho/godotenv v1.5.1 + github.com/json-iterator/go v1.1.12 + github.com/kr/pretty v0.3.1 + github.com/lestrrat-go/apache-logformat v0.0.0-20210106032603-24d066f940f8 + github.com/libdns/azure v0.5.0 + github.com/libdns/cloudflare v0.2.1 + github.com/libdns/cloudns v1.1.0 + github.com/libdns/desec v1.0.1 + github.com/libdns/digitalocean v0.0.0-20250606071607-dfa7af5c2e31 + github.com/libdns/gandi v1.1.0 + github.com/libdns/godaddy v1.1.0 + github.com/libdns/googleclouddns v1.2.0 + github.com/libdns/hetzner v1.0.0 + github.com/libdns/infomaniak v0.2.0 + github.com/libdns/inwx v0.3.0 + github.com/libdns/ionos v1.2.0 + github.com/libdns/libdns v1.1.1 + github.com/libdns/linode v0.5.0 + github.com/libdns/namecheap v0.1.1-0.20250828012207-e1a51bc9ed35 + github.com/libdns/netcup v1.0.0 + github.com/libdns/ovh v1.1.0 + github.com/libdns/porkbun v1.1.0 + github.com/libdns/rfc2136 v1.0.1 + github.com/libdns/route53 v1.6.0 + github.com/libdns/scaleway v0.2.3 + github.com/libdns/vultr/v2 v2.0.4 + github.com/maruel/panicparse/v2 v2.5.0 + github.com/miekg/dns v1.1.64 + github.com/nathanaelle/syslog5424/v2 v2.0.5 + github.com/rs/cors v1.11.1 + github.com/rubyist/circuitbreaker v2.2.1+incompatible + github.com/shirou/gopsutil v3.21.11+incompatible + github.com/sirupsen/logrus v1.9.3 + github.com/stretchr/testify v1.11.1 + go.uber.org/automaxprocs v1.6.0 + golang.org/x/net v0.49.0 + golang.org/x/sys v0.40.0 + gopkg.in/yaml.v2 v2.4.0 +) + +require ( + cloud.google.com/go/auth v0.16.1 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect + cloud.google.com/go/compute/metadata v0.6.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.9.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.9 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.9 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.9 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.9 // indirect + github.com/aws/aws-sdk-go-v2/service/route53 v1.58.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.29.6 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.1 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.38.6 // indirect + github.com/aws/smithy-go v1.23.0 // indirect + github.com/boombuler/barcode v1.0.1 // indirect + github.com/cenk/backoff v2.2.1+incompatible // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/digitalocean/godo v1.148.0 // indirect + github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/go-openapi/analysis v0.24.2 // indirect + github.com/go-openapi/jsonpointer v0.22.4 // indirect + github.com/go-openapi/jsonreference v0.21.4 // indirect + github.com/go-openapi/swag/conv v0.25.4 // indirect + github.com/go-openapi/swag/fileutils v0.25.4 // indirect + github.com/go-openapi/swag/jsonname v0.25.4 // indirect + github.com/go-openapi/swag/jsonutils v0.25.4 // indirect + github.com/go-openapi/swag/loading v0.25.4 // indirect + github.com/go-openapi/swag/netutils v0.25.4 // indirect + github.com/go-openapi/swag/stringutils v0.25.4 // indirect + github.com/go-openapi/swag/typeutils v0.25.4 // indirect + github.com/go-openapi/swag/yamlutils v0.25.4 // indirect + github.com/go-resty/resty/v2 v2.16.5 // indirect + github.com/go-viper/mapstructure/v2 v2.5.0 // indirect + github.com/gofrs/flock v0.13.0 // indirect + github.com/golang-jwt/jwt/v5 v5.2.2 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/s2a-go v0.1.9 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect + github.com/googleapis/gax-go/v2 v2.14.1 // indirect + github.com/haproxytech/go-logger v1.1.0 // indirect + github.com/haproxytech/go-method-gen v0.1.1 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/lestrrat-go/strftime v1.1.1 // indirect + github.com/linode/linodego v1.56.0 // indirect + github.com/mailru/easyjson v0.9.1 // 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/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect + github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect + github.com/oklog/ulid v1.3.1 // indirect + github.com/ovh/go-ovh v1.7.0 // indirect + github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect + github.com/perimeterx/marshmallow v1.1.5 // indirect + github.com/peterbourgon/g2s v0.0.0-20170223122336-d4e7ad98afea // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/pquerna/otp v1.4.0 // indirect + github.com/rogpeppe/go-internal v1.14.1 // indirect + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34 // indirect + github.com/tklauser/go-sysconf v0.3.15 // indirect + github.com/tklauser/numcpus v0.10.0 // indirect + github.com/vultr/govultr/v3 v3.20.0 // indirect + github.com/woodsbury/decimal128 v1.4.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + go.mongodb.org/mongo-driver v1.17.7 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect + go.opentelemetry.io/otel v1.38.0 // indirect + go.opentelemetry.io/otel/metric v1.38.0 // indirect + go.opentelemetry.io/otel/trace v1.38.0 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/crypto v0.47.0 // indirect + golang.org/x/mod v0.32.0 // indirect + golang.org/x/oauth2 v0.30.0 // indirect + golang.org/x/sync v0.19.0 // indirect + golang.org/x/text v0.33.0 // indirect + golang.org/x/time v0.11.0 // indirect + golang.org/x/tools v0.41.0 // indirect + google.golang.org/api v0.233.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 // indirect + google.golang.org/grpc v1.72.0 // indirect + google.golang.org/protobuf v1.36.6 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + mvdan.cc/gofumpt v0.9.2 // indirect ) diff --git a/go.sum b/go.sum index 8f61e7d1..9a6bc31f 100644 --- a/go.sum +++ b/go.sum @@ -1,155 +1,410 @@ -github.com/GehirnInc/crypt v0.0.0-20190301055215-6c0105aabd46 h1:rs0kDBt2zF4/CM9rO5/iH+U22jnTygPlqWgX55Ufcxg= -github.com/GehirnInc/crypt v0.0.0-20190301055215-6c0105aabd46/go.mod h1:kC29dT1vFpj7py2OvG1khBdQpo3kInWP+6QipLbdngo= -github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco= -github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +cloud.google.com/go v0.121.0 h1:pgfwva8nGw7vivjZiRfrmglGWiCJBP+0OmDpenG/Fwg= +cloud.google.com/go v0.121.0/go.mod h1:rS7Kytwheu/y9buoDmu5EIpMMCI4Mb8ND4aeN4Vwj7Q= +cloud.google.com/go/auth v0.16.1 h1:XrXauHMd30LhQYVRHLGvJiYeczweKQXZxsTbV9TiguU= +cloud.google.com/go/auth v0.16.1/go.mod h1:1howDHJ5IETh/LwYs3ZxvlkXF48aSqqJUM+5o02dNOI= +cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc= +cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c= +cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I= +cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.9.0 h1:OVoM452qUFBrX+URdH3VpR299ma4kfom0yB0URYky9g= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.9.0/go.mod h1:kUjrAo8bgEwLeZ/CmHqNl3Z/kPm7y6FKfxxK0izYUg4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 h1:FPKJS1T+clwv+OLGt13a8UjqeRuh0O4SJ3lUriThc+4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1/go.mod h1:j2chePtV91HrC22tGoRX3sGY42uF13WzmmV80/OdVAA= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 h1:lpOxwrQ919lCZoNCd69rVt8u1eLZuMORrGXqy8sNf3c= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0/go.mod h1:fSvRkb8d26z9dbL40Uf/OO6Vo9iExtZK3D0ulRV+8M0= +github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= +github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= +github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= +github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 h1:IEjq88XO4PuBDcvmjQJcQGg+w+UaafSy8G5Kcb5tBhI= +github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5/go.mod h1:exZ0C/1emQJAw5tHOaUDyY1ycttqBAPcxuzf7QbY6ec= +github.com/KimMachineGun/automemlimit v0.7.4 h1:UY7QYOIfrr3wjjOAqahFmC3IaQCLWvur9nmfIn6LnWk= +github.com/KimMachineGun/automemlimit v0.7.4/go.mod h1:QZxpHaGOQoYvFhv/r4u3U0JTC2ZcOwbSr11UZF46UBM= +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/aws/aws-sdk-go-v2 v1.39.2 h1:EJLg8IdbzgeD7xgvZ+I8M1e0fL0ptn/M47lianzth0I= +github.com/aws/aws-sdk-go-v2 v1.39.2/go.mod h1:sDioUELIUO9Znk23YVmIk86/9DOpkbyyVb1i/gUNFXY= +github.com/aws/aws-sdk-go-v2/config v1.31.12 h1:pYM1Qgy0dKZLHX2cXslNacbcEFMkDMl+Bcj5ROuS6p8= +github.com/aws/aws-sdk-go-v2/config v1.31.12/go.mod h1:/MM0dyD7KSDPR+39p9ZNVKaHDLb9qnfDurvVS2KAhN8= +github.com/aws/aws-sdk-go-v2/credentials v1.18.16 h1:4JHirI4zp958zC026Sm+V4pSDwW4pwLefKrc0bF2lwI= +github.com/aws/aws-sdk-go-v2/credentials v1.18.16/go.mod h1:qQMtGx9OSw7ty1yLclzLxXCRbrkjWAM7JnObZjmCB7I= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.9 h1:Mv4Bc0mWmv6oDuSWTKnk+wgeqPL5DRFu5bQL9BGPQ8Y= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.9/go.mod h1:IKlKfRppK2a1y0gy1yH6zD+yX5uplJ6UuPlgd48dJiQ= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.9 h1:se2vOWGD3dWQUtfn4wEjRQJb1HK1XsNIt825gskZ970= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.9/go.mod h1:hijCGH2VfbZQxqCDN7bwz/4dzxV+hkyhjawAtdPWKZA= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.9 h1:6RBnKZLkJM4hQ+kN6E7yWFveOTg8NLPHAkqrs4ZPlTU= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.9/go.mod h1:V9rQKRmK7AWuEsOMnHzKj8WyrIir1yUJbZxDuZLFvXI= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo= +github.com/aws/aws-sdk-go-v2/service/autoscaling v1.56.0 h1:YO7rat493hVtpBExbcDPKdGzk9eYTtaUrwaFJSWAqLo= +github.com/aws/aws-sdk-go-v2/service/autoscaling v1.56.0/go.mod h1:6vrMqNnS2fpOfZ9tZmIGDWYGTio7+SJ18fql3IwoSBg= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.254.1 h1:7p9bJCZ/b3EJXXARW7JMEs2IhsnI4YFHpfXQfgMh0eg= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.254.1/go.mod h1:M8WWWIfXmxA4RgTXcI/5cSByxRqjgne32Sh0VIbrn0A= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1 h1:oegbebPEMA/1Jny7kvwejowCaHz1FWZAQ94WXFNCyTM= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1/go.mod h1:kemo5Myr9ac0U9JfSjMo9yHLtw+pECEHsFtJ9tqCEI8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.9 h1:5r34CgVOD4WZudeEKZ9/iKpiT6cM1JyEROpXjOcdWv8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.9/go.mod h1:dB12CEbNWPbzO2uC6QSWHteqOg4JfBVJOojbAoAUb5I= +github.com/aws/aws-sdk-go-v2/service/route53 v1.58.3 h1:jQzRC+0eI/l5mFXVoPTyyolrqyZtKIYaKHSuKJoIJKs= +github.com/aws/aws-sdk-go-v2/service/route53 v1.58.3/go.mod h1:1GNaojT/gG4Ru9tT39ton6kRZ3FvptJ/QRKBoqUOVX4= +github.com/aws/aws-sdk-go-v2/service/sso v1.29.6 h1:A1oRkiSQOWstGh61y4Wc/yQ04sqrQZr1Si/oAXj20/s= +github.com/aws/aws-sdk-go-v2/service/sso v1.29.6/go.mod h1:5PfYspyCU5Vw1wNPsxi15LZovOnULudOQuVxphSflQA= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.1 h1:5fm5RTONng73/QA73LhCNR7UT9RpFH3hR6HWL6bIgVY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.1/go.mod h1:xBEjWD13h+6nq+z4AkqSfSvqRKFgDIQeaMguAJndOWo= +github.com/aws/aws-sdk-go-v2/service/sts v1.38.6 h1:p3jIvqYwUZgu/XYeI48bJxOhvm47hZb5HUQ0tn6Q9kA= +github.com/aws/aws-sdk-go-v2/service/sts v1.38.6/go.mod h1:WtKK+ppze5yKPkZ0XwqIVWD4beCwv056ZbPQNoeHqM8= +github.com/aws/smithy-go v1.23.0 h1:8n6I3gXzWJB2DxBDnfxgBaSX6oe0d/t10qGz7OKqMCE= +github.com/aws/smithy-go v1.23.0/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= +github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyXcs= +github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= +github.com/cenk/backoff v2.2.1+incompatible h1:djdFT7f4gF2ttuzRKPbMOWgZajgesItGLwG5FTQKmmE= +github.com/cenk/backoff v2.2.1+incompatible/go.mod h1:7FtoeaSnHoZnmZzz47cM35Y9nSW7tNyaidugnHTaFDE= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= -github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= -github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/analysis v0.18.0 h1:hRMEymXOgwo7KLPqqFmw6t3jLO2/zxUe/TXjAHPq9Gc= -github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.19.0 h1:guf3T2lnCBKlODmERt4T9GtMWRpJOikgKGyIvi0xcb8= -github.com/go-openapi/errors v0.19.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.18.0 h1:KVRzjXpMzgdM4GEMDmDTnGcY5yBwGWreJwmmk4k35yU= -github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.18.0 h1:oP2OUNdG1l2r5kYhrfVMXO54gWmzcfAwP/GFuHpNTkE= -github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.19.0 h1:wCOBNscACI8L93tt5tvB2zOMkJ098XCw3fP0BY2ybDA= -github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= -github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE= -github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= -github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= -github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk= -github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= -github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.19.0 h1:Kg7Wl7LkTPlmc393QZQ/5rQadPhi7pBVEMZxyTi0Ii8= -github.com/go-openapi/swag v0.19.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= -github.com/go-openapi/validate v0.19.0 h1:SF5vyj6PBFM6D1cw2NJIFrlS8Su2YKk6ADPPjAH70Bw= -github.com/go-openapi/validate v0.19.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/haproxytech/client-native v1.2.3 h1:/i2Tkn4sMABWQWXNWpQQ68Zto0rE5jmsXcGJ5jGF80o= -github.com/haproxytech/client-native v1.2.3/go.mod h1:VcZdVPpnqyeQJcgOqD0onws4PfU0702fP58V7zO8LnE= -github.com/haproxytech/client-native v1.2.4 h1:M/gzlYixGGItcjobBS1QQFdp+Hqufe/djcSqPBHHa50= -github.com/haproxytech/client-native v1.2.4/go.mod h1:pJeEyNF4+sZpBrm4rCH263PcBpJyYN+JDjOQleWcW5M= -github.com/haproxytech/client-native v1.2.5-0.20190823115908-abc6e1722a52 h1:8Bd005lWCNfUOb7607o3amQahBkqWvzpo3+sqThOwWk= -github.com/haproxytech/client-native v1.2.5-0.20190823115908-abc6e1722a52/go.mod h1:WsLizjzTjRwzqm7RlKTutJHvSbLMwyKVMCww7u3Jpzo= -github.com/haproxytech/client-native v1.2.5 h1:bTsiws1J66wIedGLKtvrzO5hAww6TCTf9zzp89NalQk= -github.com/haproxytech/client-native v1.2.5/go.mod h1:WsLizjzTjRwzqm7RlKTutJHvSbLMwyKVMCww7u3Jpzo= -github.com/haproxytech/client-native v1.2.6-0.20191004065443-7098fd623688 h1:Zih8StutXQE/KIDIIwzWHdGTkm0Kfeohk26mynRoWIQ= -github.com/haproxytech/client-native v1.2.6-0.20191004065443-7098fd623688/go.mod h1:GKKH8rBT+qaC6Br8RbIif3lvQK1bnbqmoiv0KtP6Bvs= -github.com/haproxytech/client-native v1.2.6-0.20191004134249-74efe2bd67ea h1:BYs+E6bAQoz8KgmkjDjBcpq49ifj+nGqSkYQyGn8gSM= -github.com/haproxytech/client-native v1.2.6-0.20191004134249-74efe2bd67ea/go.mod h1:GKKH8rBT+qaC6Br8RbIif3lvQK1bnbqmoiv0KtP6Bvs= -github.com/haproxytech/client-native v1.2.6-0.20191009080518-a66b8506357e h1:9b/JmkKgZjXplVc081mBsnWyoRykh8KQ0D7gZ8987pM= -github.com/haproxytech/client-native v1.2.6-0.20191009080518-a66b8506357e/go.mod h1:iZogi0TuU/0cs7//YJGKihba2je60gQghH12izKHF8Q= -github.com/haproxytech/client-native v1.2.6 h1:h6ToCiUuKign1wTW71WicI6Jzs75CLT/NVIBH2epeMs= -github.com/haproxytech/client-native v1.2.6/go.mod h1:7EUfsYlRhfoiffrF6Tg0hmvzjxp665ImajpPGsPJzVY= -github.com/haproxytech/client-native v1.2.7-0.20191014073021-13f38a2fe6e0 h1:95ANXV/Vi/EpHkDws4kmmG3A3SoS+Iq4HA7wzHtF5Oc= -github.com/haproxytech/client-native v1.2.7-0.20191014073021-13f38a2fe6e0/go.mod h1:d3YkFk9CotqL3P628STS7pEuuCyOYLL+sXrjjJxWFug= -github.com/haproxytech/client-native v1.2.7-0.20191014091556-b685939d54e9 h1:NuXyp+8vfgJ/ESp69qS0geWbCqBB3qb1Ls0Jk8GqqDE= -github.com/haproxytech/client-native v1.2.7-0.20191014091556-b685939d54e9/go.mod h1:KOOeLJgjqDoU25LVmAYaXRxQcv510Ju5nBK2xdgDMek= -github.com/haproxytech/client-native v1.2.7-0.20191014093528-779cd403980d h1:/3+IjJs+zR9vnI3bMbfEXDzD/7uCPcHuAckoLDhGWms= -github.com/haproxytech/client-native v1.2.7-0.20191014093528-779cd403980d/go.mod h1:KOOeLJgjqDoU25LVmAYaXRxQcv510Ju5nBK2xdgDMek= -github.com/haproxytech/client-native v1.2.7-0.20191014132956-b019aa5097ae h1:/d/4oc376+HV0VsGker31ulJvcitVI6YyaTY4PsuNdc= -github.com/haproxytech/client-native v1.2.7-0.20191014132956-b019aa5097ae/go.mod h1:kl0ubY5UlRzwEg16V2BxJ7X/IHs7RmfnalH9go4RXg8= -github.com/haproxytech/config-parser v1.1.3 h1:8G+XQ7QXGctmeQlgg9xME0WMY0TK7pZenf/DZM/QWfo= -github.com/haproxytech/config-parser v1.1.3/go.mod h1:se7v728KDunj+qz1kXFFFl+nDuoBdUaN5eYSi+gYjNM= -github.com/haproxytech/config-parser v1.1.4 h1:J9ziufMtKSemiHILPu3GgAopuhA8bMxxR1f0kGtgnHk= -github.com/haproxytech/config-parser v1.1.4/go.mod h1:se7v728KDunj+qz1kXFFFl+nDuoBdUaN5eYSi+gYjNM= -github.com/haproxytech/config-parser v1.1.5 h1:3sA/k2klE9MpZtv05eGBD4J3JWMUzam9CM/cJoteSFo= -github.com/haproxytech/config-parser v1.1.5/go.mod h1:se7v728KDunj+qz1kXFFFl+nDuoBdUaN5eYSi+gYjNM= -github.com/haproxytech/config-parser v1.1.9 h1:79+CVUkcVbmcWzQZ594O5BI0qYzihoOSfvzJ104OoJg= -github.com/haproxytech/config-parser v1.1.9/go.mod h1:se7v728KDunj+qz1kXFFFl+nDuoBdUaN5eYSi+gYjNM= -github.com/haproxytech/config-parser v1.1.10 h1:dcqTi/3W1VDiPHvH5ASL1uV8YWMNaNI7XEmHZNT0kCg= -github.com/haproxytech/config-parser v1.1.10/go.mod h1:se7v728KDunj+qz1kXFFFl+nDuoBdUaN5eYSi+gYjNM= -github.com/haproxytech/config-parser v1.1.11-0.20191010080921-251bc0c7bdac h1:snL1q+Qyjuqq7qp6izRLeLnMTd5el0pDPRTvhfq5F28= -github.com/haproxytech/config-parser v1.1.11-0.20191010080921-251bc0c7bdac/go.mod h1:se7v728KDunj+qz1kXFFFl+nDuoBdUaN5eYSi+gYjNM= -github.com/haproxytech/models v1.2.1/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.2 h1:/lXf0e3zCF4jCH+QZ9LfcCS2YXPRXFrQrWWTirL6gOY= -github.com/haproxytech/models v1.2.2/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.3-0.20190823114805-b3bd06b1c569 h1:uSIImvE2nSiEqMvesozR0cF90I0Gys8Rl6uEItGMZbw= -github.com/haproxytech/models v1.2.3-0.20190823114805-b3bd06b1c569/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.3 h1:g0ac/TkUKjRCzx3AQwHZSJzUKVCZlmSn7UcA/+eDzio= -github.com/haproxytech/models v1.2.3/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.4-0.20190924151828-3388735e4d3a h1:1HKlqzi0gHs+suoFZfXv6GQ14+U/0dyQbydaEN0ZzVg= -github.com/haproxytech/models v1.2.4-0.20190924151828-3388735e4d3a/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.4-0.20191004062656-5bd0f64c765b h1:HA9wpdMbDsT/A5z5L6McXLDh8yiSfwxK32PRwx/F1to= -github.com/haproxytech/models v1.2.4-0.20191004062656-5bd0f64c765b/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.4-0.20191009071622-2e6a8ecf1d8e h1:UlPkQ90yhiNgT2adfzgcGytWYAp7+pleCSexRdH48Ow= -github.com/haproxytech/models v1.2.4-0.20191009071622-2e6a8ecf1d8e/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.4 h1:KYWMzEVVRxAPI6F64xF6oISY10TGm6VWvo/T2rXp4x4= -github.com/haproxytech/models v1.2.4/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.5-0.20191014071538-306b0b122d42 h1:Yp0oKt9wE2NDNBGUKUR+dgpiQ+6i04/WkcDp+M5CIJY= -github.com/haproxytech/models v1.2.5-0.20191014071538-306b0b122d42/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.5-0.20191014074611-afc4060df863 h1:+11bo6uZr97ZLf0+yo9rBms8+bGqCGf9aTz2Vg3X68A= -github.com/haproxytech/models v1.2.5-0.20191014074611-afc4060df863/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/haproxytech/models v1.2.5-0.20191014095528-ac55cbc13783 h1:Rss3B2VIwgLjHMuNiki0osAYYmVJlafMij4jqMENGaQ= -github.com/haproxytech/models v1.2.5-0.20191014095528-ac55cbc13783/go.mod h1:UXZVErm/XN6z10sM/enmxrdeEnwo7vz1JI+a8ycEvOQ= -github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe h1:W/GaMY0y69G4cFlmsC6B9sbuo2fP8OFP1ABjt4kPz+w= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/digitalocean/godo v1.148.0 h1:th91q+6bZY+Slgs9eZxBupa2+aUUYn1qT7gPICFmtPA= +github.com/digitalocean/godo v1.148.0/go.mod h1:tYeiWY5ZXVpU48YaFv0M5irUFHXGorZpDNm7zzdWMzM= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 h1:aYo8nnk3ojoQkP5iErif5Xxv0Mo0Ga/FR5+ffl/7+Nk= +github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc= +github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw= +github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40egUymuWXxAe151lTNnCv97MddSOVsjpPPkityA= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= +github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/getkin/kin-openapi v0.133.0 h1:pJdmNohVIJ97r4AUFtEXRXwESr8b0bD721u/Tz6k8PQ= +github.com/getkin/kin-openapi v0.133.0/go.mod h1:boAciF6cXk5FhPqe/NQeBTeenbjqU4LhWBf09ILVvWE= +github.com/go-faker/faker/v4 v4.7.0 h1:VboC02cXHl/NuQh5lM2W8b87yp4iFXIu59x4w0RZi4E= +github.com/go-faker/faker/v4 v4.7.0/go.mod h1:u1dIRP5neLB6kTzgyVjdBOV5R1uP7BdxkcWk7tiKQXk= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/go-openapi/analysis v0.24.2 h1:6p7WXEuKy1llDgOH8FooVeO+Uq2za9qoAOq4ZN08B50= +github.com/go-openapi/analysis v0.24.2/go.mod h1:x27OOHKANE0lutg2ml4kzYLoHGMKgRm1Cj2ijVOjJuE= +github.com/go-openapi/errors v0.22.6 h1:eDxcf89O8odEnohIXwEjY1IB4ph5vmbUsBMsFNwXWPo= +github.com/go-openapi/errors v0.22.6/go.mod h1:z9S8ASTUqx7+CP1Q8dD8ewGH/1JWFFLX/2PmAYNQLgk= +github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4= +github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80= +github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8= +github.com/go-openapi/jsonreference v0.21.4/go.mod h1:rIENPTjDbLpzQmQWCj5kKj3ZlmEh+EFVbz3RTUh30/4= +github.com/go-openapi/loads v0.23.2 h1:rJXAcP7g1+lWyBHC7iTY+WAF0rprtM+pm8Jxv1uQJp4= +github.com/go-openapi/loads v0.23.2/go.mod h1:IEVw1GfRt/P2Pplkelxzj9BYFajiWOtY2nHZNj4UnWY= +github.com/go-openapi/runtime v0.29.0 h1:Y7iDTFarS9XaFQ+fA+lBLngMwH6nYfqig1G+pHxMRO0= +github.com/go-openapi/runtime v0.29.0/go.mod h1:52HOkEmLL/fE4Pg3Kf9nxc9fYQn0UsIWyGjGIJE9dkg= +github.com/go-openapi/spec v0.22.3 h1:qRSmj6Smz2rEBxMnLRBMeBWxbbOvuOoElvSvObIgwQc= +github.com/go-openapi/spec v0.22.3/go.mod h1:iIImLODL2loCh3Vnox8TY2YWYJZjMAKYyLH2Mu8lOZs= +github.com/go-openapi/strfmt v0.25.0 h1:7R0RX7mbKLa9EYCTHRcCuIPcaqlyQiWNPTXwClK0saQ= +github.com/go-openapi/strfmt v0.25.0/go.mod h1:nNXct7OzbwrMY9+5tLX4I21pzcmE6ccMGXl3jFdPfn8= +github.com/go-openapi/swag v0.25.4 h1:OyUPUFYDPDBMkqyxOTkqDYFnrhuhi9NR6QVUvIochMU= +github.com/go-openapi/swag v0.25.4/go.mod h1:zNfJ9WZABGHCFg2RnY0S4IOkAcVTzJ6z2Bi+Q4i6qFQ= +github.com/go-openapi/swag/cmdutils v0.25.4 h1:8rYhB5n6WawR192/BfUu2iVlxqVR9aRgGJP6WaBoW+4= +github.com/go-openapi/swag/cmdutils v0.25.4/go.mod h1:pdae/AFo6WxLl5L0rq87eRzVPm/XRHM3MoYgRMvG4A0= +github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4= +github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU= +github.com/go-openapi/swag/fileutils v0.25.4 h1:2oI0XNW5y6UWZTC7vAxC8hmsK/tOkWXHJQH4lKjqw+Y= +github.com/go-openapi/swag/fileutils v0.25.4/go.mod h1:cdOT/PKbwcysVQ9Tpr0q20lQKH7MGhOEb6EwmHOirUk= +github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI= +github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag= +github.com/go-openapi/swag/jsonutils v0.25.4 h1:VSchfbGhD4UTf4vCdR2F4TLBdLwHyUDTd1/q4i+jGZA= +github.com/go-openapi/swag/jsonutils v0.25.4/go.mod h1:7OYGXpvVFPn4PpaSdPHJBtF0iGnbEaTk8AvBkoWnaAY= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4 h1:IACsSvBhiNJwlDix7wq39SS2Fh7lUOCJRmx/4SN4sVo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4/go.mod h1:Mt0Ost9l3cUzVv4OEZG+WSeoHwjWLnarzMePNDAOBiM= +github.com/go-openapi/swag/loading v0.25.4 h1:jN4MvLj0X6yhCDduRsxDDw1aHe+ZWoLjW+9ZQWIKn2s= +github.com/go-openapi/swag/loading v0.25.4/go.mod h1:rpUM1ZiyEP9+mNLIQUdMiD7dCETXvkkC30z53i+ftTE= +github.com/go-openapi/swag/mangling v0.25.4 h1:2b9kBJk9JvPgxr36V23FxJLdwBrpijI26Bx5JH4Hp48= +github.com/go-openapi/swag/mangling v0.25.4/go.mod h1:6dxwu6QyORHpIIApsdZgb6wBk/DPU15MdyYj/ikn0Hg= +github.com/go-openapi/swag/netutils v0.25.4 h1:Gqe6K71bGRb3ZQLusdI8p/y1KLgV4M/k+/HzVSqT8H0= +github.com/go-openapi/swag/netutils v0.25.4/go.mod h1:m2W8dtdaoX7oj9rEttLyTeEFFEBvnAx9qHd5nJEBzYg= +github.com/go-openapi/swag/stringutils v0.25.4 h1:O6dU1Rd8bej4HPA3/CLPciNBBDwZj9HiEpdVsb8B5A8= +github.com/go-openapi/swag/stringutils v0.25.4/go.mod h1:GTsRvhJW5xM5gkgiFe0fV3PUlFm0dr8vki6/VSRaZK0= +github.com/go-openapi/swag/typeutils v0.25.4 h1:1/fbZOUN472NTc39zpa+YGHn3jzHWhv42wAJSN91wRw= +github.com/go-openapi/swag/typeutils v0.25.4/go.mod h1:Ou7g//Wx8tTLS9vG0UmzfCsjZjKhpjxayRKTHXf2pTE= +github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtPBZ9A56h92Sw= +github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg= +github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= +github.com/go-openapi/validate v0.25.1 h1:sSACUI6Jcnbo5IWqbYHgjibrhhmt3vR6lCzKZnmAgBw= +github.com/go-openapi/validate v0.25.1/go.mod h1:RMVyVFYte0gbSTaZ0N4KmTn6u/kClvAFp+mAVfS/DQc= +github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= +github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= +github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM= +github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= +github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= +github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0= +github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= +github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= +github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= +github.com/google/renameio v1.0.1 h1:Lh/jXZmvZxb0BBeSY5VKEfidcbcbenKjZFzM/q0fSeU= +github.com/google/renameio v1.0.1/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk= +github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0= +github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4= +github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA= +github.com/googleapis/gax-go/v2 v2.14.1 h1:hb0FFeiPaQskmvakKu5EbCbpntQn48jyHuvrkurSS/Q= +github.com/googleapis/gax-go/v2 v2.14.1/go.mod h1:Hb/NubMaVM88SrNkvl8X/o8XWwDJEPqouaLeN2IUxoA= +github.com/haproxytech/client-native/v6 v6.3.0 h1:bKiQHCW6gKusA2XixfUPy+L/XdEa4LNR6jFMuQ+C908= +github.com/haproxytech/client-native/v6 v6.3.0/go.mod h1:2ybXlzwzdrIOlFl468y/VeGLD5uVS4P7L0TxN9Os+as= +github.com/haproxytech/go-logger v1.1.0 h1:HgGtYaI1ApkvbQdsm7f9AzQQoxTB7w37criTflh7IQE= +github.com/haproxytech/go-logger v1.1.0/go.mod h1:OekUd8HCb7ubxMplzHUPBTHNxZmddOWfOjWclZsqIeM= +github.com/haproxytech/go-method-gen v0.1.1 h1:anoX6RjASOqtwxYCeX5JlsF3ETrAU9fQkxA3vi6tRmA= +github.com/haproxytech/go-method-gen v0.1.1/go.mod h1:3lORMBgT21FSJwyEjIF5rlcwJ1Yj2tFx8bMs8Rzf/d8= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= +github.com/jarcoal/httpmock v1.4.1 h1:0Ju+VCFuARfFlhVXFc2HxlcQkfB+Xq12/EotHko+x2A= +github.com/jarcoal/httpmock v1.4.1/go.mod h1:ftW1xULwo+j0R0JJkJIIi7UKigZUXCLLanykgjwBXL0= +github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4= +github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU= +github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/lestrrat-go/apache-logformat v0.0.0-20210106032603-24d066f940f8 h1:YTyb23TYmO5068vabZIrocTP6Ql1bX53Qhkf7IjYU08= +github.com/lestrrat-go/apache-logformat v0.0.0-20210106032603-24d066f940f8/go.mod h1:thy9OlWY26pQu7tUAL5Ox9HV/sZzlSwx/AW43yO4lSg= +github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8= +github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= +github.com/lestrrat-go/strftime v0.0.0-20180821113735-8b31f9c59b0f/go.mod h1:RMlXygAD3c48Psmr06d2G75L4E4xxzxkIe/+ppX9eAU= +github.com/lestrrat-go/strftime v1.1.1 h1:zgf8QCsgj27GlKBy3SU9/8MMgegZ8UCzlCyHYrUF0QU= +github.com/lestrrat-go/strftime v1.1.1/go.mod h1:YDrzHJAODYQ+xxvrn5SG01uFIQAeDTzpxNVppCz7Nmw= +github.com/libdns/azure v0.5.0 h1:zqIjuEinZsuIS9jlooJlc562Xwtlng5boruHoo7xbkc= +github.com/libdns/azure v0.5.0/go.mod h1:9aCIh+jdIR/+6sTIsONLGGUjho9vjneRS59hSqIJo7k= +github.com/libdns/cloudflare v0.2.1 h1:E8aoP5o79AU47t1XyzCgSecST3GvWv/nC3ycibg0t+o= +github.com/libdns/cloudflare v0.2.1/go.mod h1:Aq4IXdjalB6mD0ELvKqJiIGim8zSC6mlIshRPMOAb5w= +github.com/libdns/cloudns v1.1.0 h1:W+1MadtxKySn3b5RITFTsXgTIvr5VoO5x97cewjlDcs= +github.com/libdns/cloudns v1.1.0/go.mod h1:/22V6tYYDALDpM4pw/RGGJ+X2F1Luibty9kKpKvkqBM= +github.com/libdns/desec v1.0.1 h1:q8U+/dE4W7V3N9wsAC6aOceP4vOMKaa02D15N3Gg0dc= +github.com/libdns/desec v1.0.1/go.mod h1:kyNfDM37feCTHJO4ha0SCRafQQS+dQ/kBRWwZYDfrJo= +github.com/libdns/digitalocean v0.0.0-20250606071607-dfa7af5c2e31 h1:raIuvxYVJtZ60hREOOL3MS2AS3xA0W2G3grPQ4rGTeo= +github.com/libdns/digitalocean v0.0.0-20250606071607-dfa7af5c2e31/go.mod h1:hde/tjNiPFe1lLaf2TtaCAYgJ9j/SGLhaQMpgZlF6e0= +github.com/libdns/gandi v1.1.0 h1:gBBbx23xejvOpbUX7HRqCYsROYag5+OUMGhQXzAkol4= +github.com/libdns/gandi v1.1.0/go.mod h1:HAbs4cfjYUX28d25Iyn9rq4oNLoVLpJ6YSkRFLbo9IE= +github.com/libdns/godaddy v1.1.0 h1:mxB107yFulEGApacljrCfaR4faR/9d9SyrGmjD2VubU= +github.com/libdns/godaddy v1.1.0/go.mod h1:ZU6B93OoBN8jTbN97Ud5QdgbNvd6asV0EO8KVrGMWm4= +github.com/libdns/googleclouddns v1.2.0 h1:6K333FYwKkiOuq0Rpe5XVyUkgNoY3X7RgKqVMFEtaEs= +github.com/libdns/googleclouddns v1.2.0/go.mod h1:ubTPz+22nDk9aOmNBQAOgHd3/yfKUPZXB88XHrP5iCk= +github.com/libdns/hetzner v1.0.0 h1:dFcgqTIfdiKQTqoqBBtgU9CewD8JSnB7p6BKxQ5kheM= +github.com/libdns/hetzner v1.0.0/go.mod h1:OmuTyXMHTfy2nCqbt9KYkf0KwQSvo0ZeFGxEQSl3r2w= +github.com/libdns/infomaniak v0.2.0 h1:TC3jP68Tnw4sAi87r1xNY4fPF5Cs5SPGbEkTWvXCmnc= +github.com/libdns/infomaniak v0.2.0/go.mod h1:2RTkgFMLv45OPE8dwgFZKn4PKzECdVADdHdkIcbUZWE= +github.com/libdns/inwx v0.3.0 h1:TFKFqKUDfrlmKpeZc0mxAM3o9GZ4sQ7cwq+KyuybGWk= +github.com/libdns/inwx v0.3.0/go.mod h1:q+nLyMTVQGL8DRCLGB1IT6WIWr9GOu8billodJNQssY= +github.com/libdns/ionos v1.2.0 h1:FQ2xQTBfsjc7aMArRBBCs9l48Squt76GHXbxDsqOKgw= +github.com/libdns/ionos v1.2.0/go.mod h1:g/JYno/+VXdujTGPBDMDeCfeLF0PJyJynsCrFu+2EFQ= +github.com/libdns/libdns v1.1.1 h1:wPrHrXILoSHKWJKGd0EiAVmiJbFShguILTg9leS/P/U= +github.com/libdns/libdns v1.1.1/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ= +github.com/libdns/linode v0.5.0 h1:BYWhIfK+M7Qh/naDzL2FX2oTWBv6VbRRPiypIFe9yT8= +github.com/libdns/linode v0.5.0/go.mod h1:s6utuPHV0ZtERlsDPvAZbo2X86xq2AJQ+dsIQTFyxls= +github.com/libdns/namecheap v0.1.1-0.20250828012207-e1a51bc9ed35 h1:ScmNxAt/kxKZxPIlhc05AArkgSbhUBxkRe8ZwWDdFgc= +github.com/libdns/namecheap v0.1.1-0.20250828012207-e1a51bc9ed35/go.mod h1:v57RUzOgOGVnI9wY3uqPEanSrKx2I1YgR24uep/ys9Y= +github.com/libdns/netcup v1.0.0 h1:+hXRhnCWPTBhsuZX+laBrWt+ijDINoq7zVbaA2UHFuY= +github.com/libdns/netcup v1.0.0/go.mod h1:yfRQIwtgK9T3o2MZjMrPJhtJgH2uHNWJQfZ1n28J/3I= +github.com/libdns/ovh v1.1.0 h1:J909NRjU2IwRxvwwuvrHRomQ7lyetZdUISkqEhgmNYA= +github.com/libdns/ovh v1.1.0/go.mod h1:NspcMQgmvCyHr4jhu+Zli/RQ86Vvt+jNtLzMMeOP8ag= +github.com/libdns/porkbun v1.1.0 h1:X763NqXjW26VEl7GvBtF/3CGeuGt9JqoQ35mwIlx40E= +github.com/libdns/porkbun v1.1.0/go.mod h1:JL6NfXkkSlLr24AI5Fv0t3/Oa6PXOSOerVsOmr8+URs= +github.com/libdns/rfc2136 v1.0.1 h1:aiztZgzI2cd9FAtBNPILz01mQcZs1jMqJ467KKI4UQ0= +github.com/libdns/rfc2136 v1.0.1/go.mod h1:Uf4niCfXVgiMgwUrkPdIa5/sqLFdjVhkZj1ZfFAuSq4= +github.com/libdns/route53 v1.6.0 h1:1fZcoCIxagfftw9GBhIqZ2rumEiB0K58n11X7ko2DOg= +github.com/libdns/route53 v1.6.0/go.mod h1:7QGcw/2J0VxcVwHsPYpuo1I6IJLHy77bbOvi1BVK3eE= +github.com/libdns/scaleway v0.2.3 h1:krZpbQyl4cyuB6sVLHLfEQ63K1Z+PDiQcFcJBU3Kyp4= +github.com/libdns/scaleway v0.2.3/go.mod h1:N9nY2+aeFQu5y439nKT25GHLOhBlRf93WvOqgeX+ztI= +github.com/libdns/vultr/v2 v2.0.4 h1:4V1OSiUnYvFfpFBicdM27JEnAF0D694cmmQ3AyNqobA= +github.com/libdns/vultr/v2 v2.0.4/go.mod h1:u5Vgx6UG44bMLFKzqHdixc+o2TfP8aGUUmEZk4asH9o= +github.com/linode/linodego v1.56.0 h1:WO2ztR6/hdfqCIeZnC8DyYb+AXnuWOl4FB/qqK6T5HE= +github.com/linode/linodego v1.56.0/go.mod h1:W5+QH6nCppgi5gud/b16uAKOzTtfuwzjOHEFA7bKOd0= +github.com/mailru/easyjson v0.9.1 h1:LbtsOm5WAswyWbvTEOqhypdPeZzHavpZx96/n553mR8= +github.com/mailru/easyjson v0.9.1/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= +github.com/maruel/panicparse/v2 v2.5.0 h1:yCtuS0FWjfd0RTYMXGpDvWcb0kINm8xJGu18/xMUh00= +github.com/maruel/panicparse/v2 v2.5.0/go.mod h1:DA2fDiBk63bKfBf4CVZP9gb4fuvzdPbLDsSI873hweQ= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g= +github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= +github.com/miekg/dns v1.1.64 h1:wuZgD9wwCE6XMT05UU/mlSko71eRSXEAm2EbjQXLKnQ= +github.com/miekg/dns v1.1.64/go.mod h1:Dzw9769uoKVaLuODMDZz9M6ynFU6Em65csPuoi8G0ck= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +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/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/nathanaelle/syslog5424/v2 v2.0.5 h1:oLVYQmKnv3nlnmvlbBWM+iWl9AONcU+tuxIL0fjko5A= +github.com/nathanaelle/syslog5424/v2 v2.0.5/go.mod h1:f9MvsGkLOtYh2VzLT4Pjuwx3+Xv2EogxJNda+HLPDus= +github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY= +github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw= +github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c= +github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o= +github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/ovh/go-ovh v1.7.0 h1:V14nF7FwDjQrZt9g7jzcvAAQ3HN6DNShRFRMC3jLoPw= +github.com/ovh/go-ovh v1.7.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= +github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= +github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= +github.com/peterbourgon/g2s v0.0.0-20170223122336-d4e7ad98afea h1:sKwxy1H95npauwu8vtF95vG/syrL0p8fSZo/XlDg5gk= +github.com/peterbourgon/g2s v0.0.0-20170223122336-d4e7ad98afea/go.mod h1:1VcHEd3ro4QMoHfiNl/j7Jkln9+KQuorp0PItHMJYNg= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI= -github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM= -github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/pquerna/otp v1.4.0 h1:wZvl1TIVxKRThZIBiwOOHOGP/1+nZyWBil9Y2XNEDzg= +github.com/pquerna/otp v1.4.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg= +github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= +github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= +github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM= +github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= +github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rubyist/circuitbreaker v2.2.1+incompatible h1:KUKd/pV8Geg77+8LNDwdow6rVCAYOp8+kHUyFvL6Mhk= +github.com/rubyist/circuitbreaker v2.2.1+incompatible/go.mod h1:Ycs3JgJADPuzJDwffe12k6BZT8hxVi6lFK+gWYJLN4A= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34 h1:48+VFHsyVcAHIN2v1Ao9v1/RkjJS5AwctFucBrfYNIA= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.34/go.mod h1:zFWiHphneiey3s8HOtAEnGrRlWivNaxW5T6d5Xfco7g= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190607181551-461777fb6f67 h1:rJJxsykSlULwd2P2+pg/rtnwN2FrWp4IuCxOSyS0V00= -golang.org/x/net v0.0.0-20190607181551-461777fb6f67/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= +github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= +github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= +github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= +github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/vultr/govultr/v3 v3.20.0 h1:O+Om6gXpN6ehwAIIKq5DyGuekpyHaoRlwrxTb44bDzA= +github.com/vultr/govultr/v3 v3.20.0/go.mod h1:q34Wd76upKmf+vxFMgaNMH3A8BbsPBmSYZUGC8oZa5w= +github.com/woodsbury/decimal128 v1.4.0 h1:xJATj7lLu4f2oObouMt2tgGiElE5gO6mSWUjQsBgUlc= +github.com/woodsbury/decimal128 v1.4.0/go.mod h1:BP46FUrVjVhdTbKT+XuQh2xfQaGki9LMIRJSFuh6THU= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.mongodb.org/mongo-driver v1.17.7 h1:a9w+U3Vt67eYzcfq3k/OAv284/uUUkL0uP75VE5rCOU= +go.mongodb.org/mongo-driver v1.17.7/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o= +go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= +go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= +golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= +golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= +golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= +golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc= +golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.233.0 h1:iGZfjXAJiUFSSaekVB7LzXl6tRfEKhUN7FkZN++07tI= +google.golang.org/api v0.233.0/go.mod h1:TCIVLLlcwunlMpZIhIp7Ltk77W+vUSdUKAAIlbxY44c= +google.golang.org/genproto v0.0.0-20250512202823-5a2f75b736a9 h1:0DnDgelxbooHLt0nyiPeCP0zrH/RL+UG558i1oNU1xE= +google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 h1:vPV0tzlsK6EzEDHNNH5sa7Hs9bd7iXR7B1tSiPepkV0= +google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:pKLAc5OolXC3ViWGI62vvC0n10CpwAtRcTNCFwTKBEw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 h1:IqsN8hx+lWLqlN+Sc3DoMy/watjofWiU8sRFgQ8fhKM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= +google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= 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/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +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.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= +mvdan.cc/gofumpt v0.9.2 h1:zsEMWL8SVKGHNztrx6uZrXdp7AX8r421Vvp23sz7ik4= +mvdan.cc/gofumpt v0.9.2/go.mod h1:iB7Hn+ai8lPvofHd9ZFGVg2GOr8sBUw1QUWjNbmIL/s= diff --git a/handlers/acl.go b/handlers/acl.go index d510184c..e20ef218 100644 --- a/handlers/acl.go +++ b/handlers/acl.go @@ -17,43 +17,51 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/acl" - "github.com/haproxytech/models" ) -//CreateACLHandlerImpl implementation of the CreateACLHandler interface using client-native client +// CreateACLHandlerImpl implementation of the CreateACLHandler interface using client-native client type CreateACLHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteACLHandlerImpl implementation of the DeleteACLHandler interface using client-native client +// DeleteACLHandlerImpl implementation of the DeleteACLHandler interface using client-native client type DeleteACLHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetACLHandlerImpl implementation of the GetACLHandler interface using client-native client +// GetACLHandlerImpl implementation of the GetACLHandler interface using client-native client type GetACLHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetAclsHandlerImpl implementation of the GetAclsHandler interface using client-native client -type GetAclsHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllACLHandlerImpl implementation of the GetAclsHandler interface using client-native client +type GetAllACLHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceACLHandlerImpl implementation of the ReplaceACLHandler interface using client-native client +// ReplaceACLHandlerImpl implementation of the ReplaceACLHandler interface using client-native client type ReplaceACLHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllACLHandlerImpl implementation of the ReplaceAclsHandler interface using client-native client +type ReplaceAllACLHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateACLHandlerImpl) Handle(params acl.CreateACLParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateACLHandlerImpl) Handle(parentType cnconstants.CnParentType, params acl.CreateACLBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,13 +78,19 @@ func (h *CreateACLHandlerImpl) Handle(params acl.CreateACLParams, principal inte Message: &msg, Code: &c, } - return acl.NewCreateACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewCreateACLBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acl.NewCreateACLBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateACL(params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.CreateACL(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return acl.NewCreateACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewCreateACLBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -84,18 +98,18 @@ func (h *CreateACLHandlerImpl) Handle(params acl.CreateACLParams, principal inte err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return acl.NewCreateACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewCreateACLBackendDefault(int(*e.Code)).WithPayload(e) } - return acl.NewCreateACLCreated().WithPayload(params.Data) + return acl.NewCreateACLBackendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return acl.NewCreateACLAccepted().WithReloadID(rID).WithPayload(params.Data) + return acl.NewCreateACLBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return acl.NewCreateACLAccepted().WithPayload(params.Data) + return acl.NewCreateACLBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteACLHandlerImpl) Handle(params acl.DeleteACLParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteACLHandlerImpl) Handle(parentType cnconstants.CnParentType, params acl.DeleteACLBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -112,62 +126,132 @@ func (h *DeleteACLHandlerImpl) Handle(params acl.DeleteACLParams, principal inte Message: &msg, Code: &c, } - return acl.NewDeleteACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewDeleteACLBackendDefault(int(*e.Code)).WithPayload(e) + } + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acl.NewDeleteACLBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteACL(params.ID, params.ParentType, params.ParentName, t, v) + err = configuration.DeleteACL(params.Index, string(parentType), params.ParentName, t, v) if err != nil { e := misc.HandleError(err) - return acl.NewDeleteACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewDeleteACLBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return acl.NewDeleteACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewDeleteACLBackendDefault(int(*e.Code)).WithPayload(e) } - return acl.NewDeleteACLNoContent() + return acl.NewDeleteACLBackendNoContent() } rID := h.ReloadAgent.Reload() - return acl.NewDeleteACLAccepted().WithReloadID(rID) + return acl.NewDeleteACLBackendAccepted().WithReloadID(rID) } - return acl.NewDeleteACLAccepted() + return acl.NewDeleteACLBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetACLHandlerImpl) Handle(params acl.GetACLParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetACLHandlerImpl) Handle(parentType cnconstants.CnParentType, params acl.GetACLBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rule, err := h.Client.Configuration.GetACL(params.ID, params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return acl.NewGetACLDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return acl.NewGetACLBackendDefault(int(*e.Code)).WithPayload(e) } - return acl.NewGetACLOK().WithPayload(&acl.GetACLOKBody{Version: v, Data: rule}).WithConfigurationVersion(v) + _, rule, err := configuration.GetACL(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return acl.NewGetACLBackendDefault(int(*e.Code)).WithPayload(e) + } + + return acl.NewGetACLBackendOK().WithPayload(rule) +} + +// Handle executing the request and returning a response +func (h *GetAllACLHandlerImpl) Handle(parentType cnconstants.CnParentType, params acl.GetAllACLBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + var aclName []string + if params.ACLName != nil { + aclName = []string{*params.ACLName} + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acl.NewGetACLBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetACLs(string(parentType), params.ParentName, t, aclName...) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return acl.NewGetAllACLBackendOK().WithPayload(rules) + } + return acl.NewGetAllACLBackendDefault(int(*e.Code)).WithPayload(e) + } + return acl.NewGetAllACLBackendOK().WithPayload(rules) } -//Handle executing the request and returning a response -func (h *GetAclsHandlerImpl) Handle(params acl.GetAclsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceACLHandlerImpl) Handle(parentType cnconstants.CnParentType, params acl.ReplaceACLBackendParams, principal any) middleware.Responder { t := "" + v := int64(0) if params.TransactionID != nil { t = *params.TransactionID } + if params.Version != nil { + v = *params.Version + } - v, rules, err := h.Client.Configuration.GetACLs(params.ParentType, params.ParentName, t) + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return acl.NewReplaceACLBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return acl.NewGetAclsDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return acl.NewReplaceACLBackendDefault(int(*e.Code)).WithPayload(e) } - return acl.NewGetAclsOK().WithPayload(&acl.GetAclsOKBody{Version: v, Data: rules}).WithConfigurationVersion(v) + err = configuration.EditACL(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return acl.NewReplaceACLBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return acl.NewReplaceACLBackendDefault(int(*e.Code)).WithPayload(e) + } + return acl.NewReplaceACLBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return acl.NewReplaceACLBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return acl.NewReplaceACLBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *ReplaceACLHandlerImpl) Handle(params acl.ReplaceACLParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceAllACLHandlerImpl) Handle(parentType cnconstants.CnParentType, params acl.ReplaceAllACLBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -184,25 +268,31 @@ func (h *ReplaceACLHandlerImpl) Handle(params acl.ReplaceACLParams, principal in Message: &msg, Code: &c, } - return acl.NewReplaceACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewReplaceAllACLBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditACL(params.ID, params.ParentType, params.ParentName, params.Data, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return acl.NewReplaceACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewReplaceAllACLBackendDefault(int(*e.Code)).WithPayload(e) } + err = configuration.ReplaceAcls(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return acl.NewReplaceAllACLBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return acl.NewReplaceACLDefault(int(*e.Code)).WithPayload(e) + return acl.NewReplaceAllACLBackendDefault(int(*e.Code)).WithPayload(e) } - return acl.NewReplaceACLOK().WithPayload(params.Data) + return acl.NewReplaceAllACLBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return acl.NewReplaceACLAccepted().WithReloadID(rID).WithPayload(params.Data) + return acl.NewReplaceAllACLBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return acl.NewReplaceACLAccepted().WithPayload(params.Data) + return acl.NewReplaceAllACLBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/acl_runtime.go b/handlers/acl_runtime.go new file mode 100644 index 00000000..4aba05c2 --- /dev/null +++ b/handlers/acl_runtime.go @@ -0,0 +1,152 @@ +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/acl_runtime" +) + +type GetACLSHandlerRuntimeImpl struct { + Client client_native.HAProxyClient +} + +func (h GetACLSHandlerRuntimeImpl) Handle(params acl_runtime.GetServicesHaproxyRuntimeAclsParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsDefault(int(*e.Code)).WithPayload(e) + } + + files, err := runtime.GetACLFiles() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsDefault(int(*e.Code)).WithPayload(e) + } + + return acl_runtime.NewGetServicesHaproxyRuntimeAclsOK().WithPayload(files) +} + +type GetACLHandlerRuntimeImpl struct { + Client client_native.HAProxyClient +} + +func (h GetACLHandlerRuntimeImpl) Handle(params acl_runtime.GetServicesHaproxyRuntimeAclsIDParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsIDDefault(int(*e.Code)).WithPayload(e) + } + + aclFile, err := runtime.GetACLFile(params.ID) + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsIDDefault(int(*e.Code)).WithPayload(e) + } + + return acl_runtime.NewGetServicesHaproxyRuntimeAclsIDOK().WithPayload(aclFile) +} + +type GetACLFileEntriesHandlerRuntimeImpl struct { + Client client_native.HAProxyClient +} + +func (h GetACLFileEntriesHandlerRuntimeImpl) Handle(params acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntriesDefault(int(*e.Code)).WithPayload(e) + } + files, err := runtime.GetACLFilesEntries(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntriesDefault(int(*e.Code)).WithPayload(e) + } + + return acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntriesOK().WithPayload(files) +} + +type PostACLFileEntryHandlerRuntimeImpl struct { + Client client_native.HAProxyClient +} + +func (h PostACLFileEntryHandlerRuntimeImpl) Handle(params acl_runtime.PostServicesHaproxyRuntimeAclsParentNameEntriesParams, i any) middleware.Responder { + var err error + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewPostServicesHaproxyRuntimeAclsParentNameEntriesDefault(int(*e.Code)).WithPayload(e) + } + + if err = runtime.AddACLFileEntry(params.ParentName, params.Data.Value); err != nil { + e := misc.HandleError(err) + return acl_runtime.NewPostServicesHaproxyRuntimeAclsParentNameEntriesDefault(int(*e.Code)).WithPayload(e) + } + + var fileEntry *models.ACLFileEntry + fileEntry, err = runtime.GetACLFileEntry(params.ParentName, params.Data.Value) + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewPostServicesHaproxyRuntimeAclsParentNameEntriesDefault(int(*e.Code)).WithPayload(e) + } + + return acl_runtime.NewPostServicesHaproxyRuntimeAclsParentNameEntriesCreated().WithPayload(fileEntry) +} + +type GetACLFileEntryRuntimeImpl struct { + Client client_native.HAProxyClient +} + +func (h GetACLFileEntryRuntimeImpl) Handle(params acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault(int(*e.Code)).WithPayload(e) + } + + fileEntry, err := runtime.GetACLFileEntry(params.ParentName, params.ID) + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault(int(*e.Code)).WithPayload(e) + } + + return acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDOK().WithPayload(fileEntry) +} + +type DeleteACLFileEntryHandlerRuntimeImpl struct { + Client client_native.HAProxyClient +} + +func (h DeleteACLFileEntryHandlerRuntimeImpl) Handle(params acl_runtime.DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault(int(*e.Code)).WithPayload(e) + } + if err := runtime.DeleteACLFileEntry(params.ParentName, "#"+params.ID); err != nil { + e := misc.HandleError(err) + return acl_runtime.NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault(int(*e.Code)).WithPayload(e) + } + + return acl_runtime.NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent() +} + +type ACLRuntimeAddPayloadRuntimeACLHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h ACLRuntimeAddPayloadRuntimeACLHandlerImpl) Handle(params acl_runtime.AddPayloadRuntimeACLParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acl_runtime.NewAddPayloadRuntimeACLDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.AddACLAtomic(params.ParentName, params.Data) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return acl_runtime.NewAddPayloadRuntimeACLDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + return acl_runtime.NewAddPayloadRuntimeACLCreated().WithPayload(params.Data) +} diff --git a/handlers/acme_provider.go b/handlers/acme_provider.go new file mode 100644 index 00000000..9a9eb99b --- /dev/null +++ b/handlers/acme_provider.go @@ -0,0 +1,219 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/acme" +) + +type GetAcmeProvidersHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *GetAcmeProvidersHandlerImpl) Handle(params acme.GetAcmeProvidersParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acme.NewGetAcmeProvidersDefault(int(*e.Code)).WithPayload(e) + } + + _, providers, err := configuration.GetAcmeProviders(t) + if err != nil { + e := misc.HandleError(err) + return acme.NewGetAcmeProvidersDefault(int(*e.Code)).WithPayload(e) + } + + return acme.NewGetAcmeProvidersOK().WithPayload(providers) +} + +type GetAcmeProviderHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *GetAcmeProviderHandlerImpl) Handle(params acme.GetAcmeProviderParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acme.NewGetAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + _, provider, err := configuration.GetAcmeProvider(params.Name, t) + if err != nil { + e := misc.HandleError(err) + return acme.NewGetAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + return acme.NewGetAcmeProviderOK().WithPayload(provider) +} + +type CreateAcmeProviderHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *CreateAcmeProviderHandlerImpl) Handle(params acme.CreateAcmeProviderParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return acme.NewCreateAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acme.NewCreateAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateAcmeProvider(params.Data, t, v); err != nil { + e := misc.HandleError(err) + return acme.NewCreateAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return acme.NewCreateAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + return acme.NewCreateAcmeProviderCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return acme.NewCreateAcmeProviderAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return acme.NewCreateAcmeProviderAccepted().WithPayload(params.Data) +} + +type EditAcmeProviderHandler struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *EditAcmeProviderHandler) Handle(params acme.EditAcmeProviderParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return acme.NewEditAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acme.NewEditAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditAcmeProvider(params.Name, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return acme.NewEditAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + return acme.NewEditAcmeProviderOK().WithPayload(params.Data) +} + +type DeleteAcmeProviderHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *DeleteAcmeProviderHandlerImpl) Handle(params acme.DeleteAcmeProviderParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return acme.NewDeleteAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return acme.NewDeleteAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteAcmeProvider(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return acme.NewDeleteAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return acme.NewDeleteAcmeProviderDefault(int(*e.Code)).WithPayload(e) + } + return acme.NewDeleteAcmeProviderNoContent() + } + rID := h.ReloadAgent.Reload() + return acme.NewDeleteAcmeProviderAccepted().WithReloadID(rID) + } + + return acme.NewDeleteAcmeProviderAccepted() +} diff --git a/handlers/acme_runtime.go b/handlers/acme_runtime.go new file mode 100644 index 00000000..0fafaea7 --- /dev/null +++ b/handlers/acme_runtime.go @@ -0,0 +1,62 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/acme_runtime" +) + +type GetAcmeStatusHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *GetAcmeStatusHandlerImpl) Handle(params acme_runtime.GetAcmeStatusParams, principal any) middleware.Responder { + rt, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acme_runtime.NewGetAcmeStatusDefault(int(*e.Code)).WithPayload(e) + } + + status, err := rt.AcmeStatus() + if err != nil { + e := misc.HandleError(err) + return acme_runtime.NewGetAcmeStatusDefault(int(*e.Code)).WithPayload(e) + } + + return acme_runtime.NewGetAcmeStatusOK().WithPayload(status) +} + +type RenewAcmeCertificateHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *RenewAcmeCertificateHandlerImpl) Handle(params acme_runtime.RenewAcmeCertificateParams, principal any) middleware.Responder { + rt, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return acme_runtime.NewRenewAcmeCertificateDefault(int(*e.Code)).WithPayload(e) + } + + if err := rt.AcmeRenew(params.Certificate); err != nil { + e := misc.HandleError(err) + return acme_runtime.NewRenewAcmeCertificateDefault(int(*e.Code)).WithPayload(e) + } + + return acme_runtime.NewRenewAcmeCertificateOK() +} diff --git a/handlers/aws.go b/handlers/aws.go new file mode 100644 index 00000000..3b12b567 --- /dev/null +++ b/handlers/aws.go @@ -0,0 +1,157 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "errors" + + "github.com/go-openapi/runtime/middleware" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/misc" + + sc "github.com/haproxytech/dataplaneapi/discovery" + "github.com/haproxytech/dataplaneapi/operations/service_discovery" +) + +// CreateConsulHandlerImpl implementation of the CreateConsulHandler interface using client-native client +type CreateAWSHandlerImpl struct { + Discovery sc.ServiceDiscoveries + PersistCallback func([]*models.AwsRegion) error + UseValidation bool +} + +func (c CreateAWSHandlerImpl) Handle(params service_discovery.CreateAWSRegionParams, i any) middleware.Responder { + var err error + handleError := func(err error) *service_discovery.CreateAWSRegionDefault { + e := misc.HandleError(err) + return service_discovery.NewCreateAWSRegionDefault(int(*e.Code)).WithPayload(e) + } + + params.Data.ID = sc.NewServiceDiscoveryUUID() + if err = sc.ValidateAWSData(params.Data, c.UseValidation); err != nil { + return handleError(err) + } + if err = c.Discovery.AddNode("aws", *params.Data.ID, params.Data); err != nil { + return handleError(err) + } + var regions models.AwsRegions + if regions, err = getAWSRegions(c.Discovery); err != nil { + return handleError(err) + } + if err = c.PersistCallback(regions); err != nil { + return handleError(err) + } + return service_discovery.NewCreateAWSRegionCreated().WithPayload(params.Data) +} + +func getAWSRegions(discovery sc.ServiceDiscoveries) (models.AwsRegions, error) { + nodes, err := discovery.GetNodes("aws") + if err != nil { + return nil, err + } + instances, ok := nodes.(models.AwsRegions) + if !ok { + return nil, errors.New("expected *models.AwsRegion") + } + return instances, nil +} + +type GetAWSRegionHandlerImpl struct { + Discovery sc.ServiceDiscoveries +} + +func (g GetAWSRegionHandlerImpl) Handle(params service_discovery.GetAWSRegionParams, i any) middleware.Responder { + handleError := func(err error) *service_discovery.GetAWSRegionDefault { + e := misc.HandleError(err) + return service_discovery.NewGetAWSRegionDefault(int(*e.Code)).WithPayload(e) + } + + nodes, err := g.Discovery.GetNode("aws", params.ID) + if err != nil { + return handleError(err) + } + region, ok := nodes.(*models.AwsRegion) + if !ok { + return handleError(err) + } + return service_discovery.NewGetAWSRegionOK().WithPayload(region) +} + +type GetAWSRegionsHandlerImpl struct { + Discovery sc.ServiceDiscoveries +} + +func (g GetAWSRegionsHandlerImpl) Handle(params service_discovery.GetAWSRegionsParams, i any) middleware.Responder { + regions, err := getAWSRegions(g.Discovery) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewGetAWSRegionsDefault(int(*e.Code)).WithPayload(e) + } + return service_discovery.NewGetAWSRegionsOK().WithPayload(regions) +} + +type ReplaceAWSRegionHandlerImpl struct { + Discovery sc.ServiceDiscoveries + PersistCallback func([]*models.AwsRegion) error + UseValidation bool +} + +func (r ReplaceAWSRegionHandlerImpl) Handle(params service_discovery.ReplaceAWSRegionParams, i any) middleware.Responder { + handleError := func(err error) *service_discovery.ReplaceAWSRegionDefault { + e := misc.HandleError(err) + return service_discovery.NewReplaceAWSRegionDefault(int(*e.Code)).WithPayload(e) + } + var err error + if err = sc.ValidateAWSData(params.Data, r.UseValidation); err != nil { + return handleError(err) + } + if err = r.Discovery.UpdateNode("aws", *params.Data.ID, params.Data); err != nil { + return handleError(err) + } + var regions models.AwsRegions + regions, err = getAWSRegions(r.Discovery) + if err != nil { + return handleError(err) + } + if err = r.PersistCallback(regions); err != nil { + return handleError(err) + } + return service_discovery.NewReplaceAWSRegionOK().WithPayload(params.Data) +} + +type DeleteAWSRegionHandlerImpl struct { + Discovery sc.ServiceDiscoveries + PersistCallback func([]*models.AwsRegion) error +} + +func (d DeleteAWSRegionHandlerImpl) Handle(params service_discovery.DeleteAWSRegionParams, i any) middleware.Responder { + handleError := func(err error) *service_discovery.DeleteAWSRegionDefault { + e := misc.HandleError(err) + return service_discovery.NewDeleteAWSRegionDefault(int(*e.Code)).WithPayload(e) + } + var err error + if err = d.Discovery.RemoveNode("aws", params.ID); err != nil { + return handleError(err) + } + var regions models.AwsRegions + if regions, err = getAWSRegions(d.Discovery); err != nil { + return handleError(err) + } + if err = d.PersistCallback(regions); err != nil { + return handleError(err) + } + return service_discovery.NewDeleteAWSRegionNoContent() +} diff --git a/handlers/backend.go b/handlers/backend.go index bd379ddb..358cc113 100644 --- a/handlers/backend.go +++ b/handlers/backend.go @@ -16,44 +16,149 @@ package handlers import ( + "net/http" + "slices" + "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/backend" - "github.com/haproxytech/models" ) -//CreateBackendHandlerImpl implementation of the CreateBackendHandler interface using client-native client +// CreateBackendHandlerImpl implementation of the CreateBackendHandler interface using client-native client type CreateBackendHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteBackendHandlerImpl implementation of the DeleteBackendHandler interface using client-native client +// DeleteBackendHandlerImpl implementation of the DeleteBackendHandler interface using client-native client type DeleteBackendHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetBackendHandlerImpl implementation of the GetBackendHandler interface using client-native client +// GetBackendHandlerImpl implementation of the GetBackendHandler interface using client-native client type GetBackendHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetBackendsHandlerImpl implementation of the GetBackendsHandler interface using client-native client +// GetBackendsHandlerImpl implementation of the GetBackendsHandler interface using client-native client type GetBackendsHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//ReplaceBackendHandlerImpl implementation of the ReplaceBackendHandler interface using client-native client +// ReplaceBackendHandlerImpl implementation of the ReplaceBackendHandler interface using client-native client type ReplaceBackendHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// handleDeprecatedBackendFields adds backward compatibility support for the fields +// force_persist and ignore_persist that are deprecated in favour of force_persist_list +// and ignore_persist_list. +func handleDeprecatedBackendFields(method string, payload *models.Backend, onDisk *models.Backend) { + // A fair amount of code duplication in this function is tolerated because this code is expected to be + // short-lived - it should be removed at the end of the sunset period for the deprecated fields. + + if method == http.MethodGet { + // Populate force_persist with the first element of force_persist_list if it is present. + if len(payload.ForcePersistList) > 0 { + payload.ForcePersist = &models.BackendForcePersist{ + Cond: payload.ForcePersistList[0].Cond, + CondTest: payload.ForcePersistList[0].CondTest, + } + } + // Populate ignore_persist with the first element of ignore_persist_list if it is present. + if len(payload.IgnorePersistList) > 0 { + payload.IgnorePersist = &models.BackendIgnorePersist{ + Cond: payload.IgnorePersistList[0].Cond, + CondTest: payload.IgnorePersistList[0].CondTest, + } + } + return + } + + if payload.ForcePersist != nil && len(payload.ForcePersistList) == 0 { + if method == http.MethodPost || (method == http.MethodPut && (onDisk == nil || len(onDisk.ForcePersistList) == 0)) { + // Deprecated force_persist is present in a POST payload, or in a PUT payload when force_persist_list does not yet exist in the backend. + // Transform it into force_persist_list with the only element. + payload.ForcePersistList = []*models.ForcePersist{{ + Cond: payload.ForcePersist.Cond, + CondTest: payload.ForcePersist.CondTest, + }} + } else { + // Deprecated force_persist is present in a PUT payload, and force_persist_list already exists in the backend. + // Preserve the existing force_persist_list, and add or reposition the submitted force_persist to be its first element. + found := -1 + for i, item := range onDisk.ForcePersistList { + if *item.Cond == *payload.ForcePersist.Cond && *item.CondTest == *payload.ForcePersist.CondTest { + found = i + break + } + } + switch found { + case -1: + // force_persist value is not part of existing force_persist_list - insert it in the first position. + payload.ForcePersistList = slices.Insert(onDisk.ForcePersistList, 0, &models.ForcePersist{ + Cond: payload.ForcePersist.Cond, + CondTest: payload.ForcePersist.CondTest, + }) + case 0: + // force_persist value matches the first element of force_persist_list - preserve it without modification. + payload.ForcePersistList = onDisk.ForcePersistList + default: + // force_persist value matches another element of force_persist_list - move it to the first position. + payload.ForcePersistList = slices.Concat(onDisk.ForcePersistList[found:found+1], onDisk.ForcePersistList[:found], onDisk.ForcePersistList[found+1:]) + } + } + } + + if payload.IgnorePersist != nil && len(payload.IgnorePersistList) == 0 { + if method == http.MethodPost || (method == http.MethodPut && (onDisk == nil || len(onDisk.IgnorePersistList) == 0)) { + // Deprecated ignore_persist is present in a POST payload, or in a PUT payload when ignore_persist_list does not yet exist in the backend. + // Transform it into ignore_persist_list with the only element. + payload.IgnorePersistList = []*models.IgnorePersist{{ + Cond: payload.IgnorePersist.Cond, + CondTest: payload.IgnorePersist.CondTest, + }} + } else { + // Deprecated ignore_persist is present in a PUT payload, and ignore_persist_list already exists in the backend. + // Preserve the existing ignore_persist_list, and add or reposition the submitted ignore_persist to be its first element. + found := -1 + for i, item := range onDisk.IgnorePersistList { + if *item.Cond == *payload.IgnorePersist.Cond && *item.CondTest == *payload.IgnorePersist.CondTest { + found = i + break + } + } + switch found { + case -1: + // ignore_persist value is not part of existing ignore_persist_list - insert it in the first position. + payload.IgnorePersistList = slices.Insert(onDisk.IgnorePersistList, 0, &models.IgnorePersist{ + Cond: payload.IgnorePersist.Cond, + CondTest: payload.IgnorePersist.CondTest, + }) + case 0: + // ignore_persist value matches the first element of ignore_persist_list - preserve it without modification. + payload.IgnorePersistList = onDisk.IgnorePersistList + default: + // ignore_persist value matches another element of ignore_persist_list - move it to the first position. + payload.IgnorePersistList = slices.Concat(onDisk.IgnorePersistList[found:found+1], onDisk.IgnorePersistList[:found], onDisk.IgnorePersistList[found+1:]) + } + } + } + + // Remove force_persist and ignore_persist from the payload - at this point, they were either processed, + // or not present in the payload, or will be ignored because non-deprecated variants were submitted at the same time. + payload.ForcePersist = nil + payload.IgnorePersist = nil } -//Handle executing the request and returning a response -func (h *CreateBackendHandlerImpl) Handle(params backend.CreateBackendParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateBackendHandlerImpl) Handle(params backend.CreateBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -73,7 +178,11 @@ func (h *CreateBackendHandlerImpl) Handle(params backend.CreateBackendParams, pr return backend.NewCreateBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateBackend(params.Data, t, v) + // Populate force_persist_list and ignore_persist_list if the corresponding + // deprecated fields force_persist or ignore_persist are present in the request payload. + handleDeprecatedBackendFields(http.MethodPost, params.Data, nil) + + err := h.createBackend(params, t, v) if err != nil { e := misc.HandleError(err) return backend.NewCreateBackendDefault(int(*e.Code)).WithPayload(e) @@ -94,8 +203,19 @@ func (h *CreateBackendHandlerImpl) Handle(params backend.CreateBackendParams, pr return backend.NewCreateBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteBackendHandlerImpl) Handle(params backend.DeleteBackendParams, principal interface{}) middleware.Responder { +func (h *CreateBackendHandlerImpl) createBackend(params backend.CreateBackendParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredBackend(params.Data, t, v) + } + return configuration.CreateBackend(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeleteBackendHandlerImpl) Handle(params backend.DeleteBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -115,7 +235,13 @@ func (h *DeleteBackendHandlerImpl) Handle(params backend.DeleteBackendParams, pr return backend.NewDeleteBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteBackend(params.Name, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return backend.NewDeleteBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteBackend(params.Name, t, v) if err != nil { e := misc.HandleError(err) return backend.NewDeleteBackendDefault(int(*e.Code)).WithPayload(e) @@ -135,38 +261,70 @@ func (h *DeleteBackendHandlerImpl) Handle(params backend.DeleteBackendParams, pr return backend.NewDeleteBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetBackendHandlerImpl) Handle(params backend.GetBackendParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetBackendHandlerImpl) Handle(params backend.GetBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, bck, err := h.Client.Configuration.GetBackend(params.Name, t) + _, bck, err := h.getBackend(params, t) if err != nil { e := misc.HandleError(err) - return backend.NewGetBackendDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return backend.NewGetBackendDefault(int(*e.Code)).WithPayload(e) } - return backend.NewGetBackendOK().WithPayload(&backend.GetBackendOKBody{Version: v, Data: bck}).WithConfigurationVersion(v) + + // Populate deprecated force_persist and ignore_persist fields in returned response. + handleDeprecatedBackendFields(http.MethodGet, bck, nil) + + return backend.NewGetBackendOK().WithPayload(bck) } -//Handle executing the request and returning a response -func (h *GetBackendsHandlerImpl) Handle(params backend.GetBackendsParams, principal interface{}) middleware.Responder { +func (h *GetBackendHandlerImpl) getBackend(params backend.GetBackendParams, t string) (int64, *models.Backend, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredBackend(params.Name, t) + } + return configuration.GetBackend(params.Name, t) +} + +// Handle executing the request and returning a response +func (h *GetBackendsHandlerImpl) Handle(params backend.GetBackendsParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, bcks, err := h.Client.Configuration.GetBackends(t) + _, bcks, err := h.getBackends(params, t) if err != nil { e := misc.HandleError(err) - return backend.NewGetBackendsDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return backend.NewGetBackendsDefault(int(*e.Code)).WithPayload(e) + } + + // Populate deprecated force_persist and ignore_persist fields in returned response. + for _, bck := range bcks { + handleDeprecatedBackendFields(http.MethodGet, bck, nil) + } + + return backend.NewGetBackendsOK().WithPayload(bcks) +} + +func (h *GetBackendsHandlerImpl) getBackends(params backend.GetBackendsParams, t string) (int64, models.Backends, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredBackends(t) } - return backend.NewGetBackendsOK().WithPayload(&backend.GetBackendsOKBody{Version: v, Data: bcks}).WithConfigurationVersion(v) + return configuration.GetBackends(t) } -//Handle executing the request and returning a response -func (h *ReplaceBackendHandlerImpl) Handle(params backend.ReplaceBackendParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceBackendHandlerImpl) Handle(params backend.ReplaceBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -186,7 +344,24 @@ func (h *ReplaceBackendHandlerImpl) Handle(params backend.ReplaceBackendParams, return backend.NewReplaceBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditBackend(params.Name, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return backend.NewReplaceBackendDefault(int(*e.Code)).WithPayload(e) + } + + // Populate or modify force_persist_list and ignore_persist_list if the corresponding + // deprecated fields force_persist or ignore_persist are present in the request payload. + if params.Data.ForcePersist != nil || params.Data.IgnorePersist != nil { + _, onDisk, confErr := configuration.GetBackend(params.Data.Name, t) + if confErr != nil { + e := misc.HandleError(confErr) + return backend.NewReplaceBackendDefault(int(*e.Code)).WithPayload(e) + } + handleDeprecatedBackendFields(http.MethodPut, params.Data, onDisk) + } + + err = h.editBackend(params, t, v) if err != nil { e := misc.HandleError(err) return backend.NewReplaceBackendDefault(int(*e.Code)).WithPayload(e) @@ -206,3 +381,14 @@ func (h *ReplaceBackendHandlerImpl) Handle(params backend.ReplaceBackendParams, } return backend.NewReplaceBackendAccepted().WithPayload(params.Data) } + +func (h *ReplaceBackendHandlerImpl) editBackend(params backend.ReplaceBackendParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredBackend(params.Name, params.Data, t, v) + } + return configuration.EditBackend(params.Name, params.Data, t, v) +} diff --git a/handlers/backend_switching_rule.go b/handlers/backend_switching_rule.go index cc1d11c9..ee691d7f 100644 --- a/handlers/backend_switching_rule.go +++ b/handlers/backend_switching_rule.go @@ -17,43 +17,50 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/backend_switching_rule" - "github.com/haproxytech/models" ) -//CreateBackendSwitchingRuleHandlerImpl implementation of the CreateBackendSwitchingRuleHandler interface using client-native client +// CreateBackendSwitchingRuleHandlerImpl implementation of the CreateBackendSwitchingRuleHandler interface using client-native client type CreateBackendSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteBackendSwitchingRuleHandlerImpl implementation of the DeleteBackendSwitchingRuleHandler interface using client-native client +// DeleteBackendSwitchingRuleHandlerImpl implementation of the DeleteBackendSwitchingRuleHandler interface using client-native client type DeleteBackendSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetBackendSwitchingRuleHandlerImpl implementation of the GetBackendSwitchingRuleHandler interface using client-native client +// GetBackendSwitchingRuleHandlerImpl implementation of the GetBackendSwitchingRuleHandler interface using client-native client type GetBackendSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetBackendSwitchingRulesHandlerImpl implementation of the GetBackendSwitchingRulesHandler interface using client-native client +// GetBackendSwitchingRulesHandlerImpl implementation of the GetBackendSwitchingRulesHandler interface using client-native client type GetBackendSwitchingRulesHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//ReplaceBackendSwitchingRuleHandlerImpl implementation of the ReplaceBackendSwitchingRuleHandler interface using client-native client +// ReplaceBackendSwitchingRuleHandlerImpl implementation of the ReplaceBackendSwitchingRuleHandler interface using client-native client type ReplaceBackendSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceBackendSwitchingRulesHandlerImpl implementation of the ReplaceBackendSwitchingRulesHandler interface using client-native client +type ReplaceBackendSwitchingRulesHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.CreateBackendSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.CreateBackendSwitchingRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -72,7 +79,12 @@ func (h *CreateBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_ return backend_switching_rule.NewCreateBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateBackendSwitchingRule(params.Frontend, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return backend_switching_rule.NewCreateBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.CreateBackendSwitchingRule(params.Index, params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) return backend_switching_rule.NewCreateBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) @@ -92,8 +104,8 @@ func (h *CreateBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_ return backend_switching_rule.NewCreateBackendSwitchingRuleAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.DeleteBackendSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.DeleteBackendSwitchingRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -113,7 +125,13 @@ func (h *DeleteBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_ return backend_switching_rule.NewDeleteBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteBackendSwitchingRule(params.ID, params.Frontend, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return backend_switching_rule.NewDeleteBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteBackendSwitchingRule(params.Index, params.ParentName, t, v) if err != nil { e := misc.HandleError(err) return backend_switching_rule.NewDeleteBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) @@ -134,38 +152,53 @@ func (h *DeleteBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_ return backend_switching_rule.NewDeleteBackendSwitchingRuleAccepted() } -//Handle executing the request and returning a response -func (h *GetBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.GetBackendSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.GetBackendSwitchingRuleParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, bckRule, err := h.Client.Configuration.GetBackendSwitchingRule(params.ID, params.Frontend, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return backend_switching_rule.NewGetBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return backend_switching_rule.NewCreateBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - return backend_switching_rule.NewGetBackendSwitchingRuleOK().WithPayload(&backend_switching_rule.GetBackendSwitchingRuleOKBody{Version: v, Data: bckRule}).WithConfigurationVersion(v) + + _, bckRule, err := configuration.GetBackendSwitchingRule(params.Index, params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return backend_switching_rule.NewGetBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + return backend_switching_rule.NewGetBackendSwitchingRuleOK().WithPayload(bckRule) } -//Handle executing the request and returning a response -func (h *GetBackendSwitchingRulesHandlerImpl) Handle(params backend_switching_rule.GetBackendSwitchingRulesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetBackendSwitchingRulesHandlerImpl) Handle(params backend_switching_rule.GetBackendSwitchingRulesParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, bckRules, err := h.Client.Configuration.GetBackendSwitchingRules(params.Frontend, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return backend_switching_rule.NewGetBackendSwitchingRulesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return backend_switching_rule.NewGetBackendSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + + _, bckRules, err := configuration.GetBackendSwitchingRules(params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return backend_switching_rule.NewGetBackendSwitchingRulesOK().WithPayload(models.BackendSwitchingRules{}) + } + return backend_switching_rule.NewGetBackendSwitchingRulesDefault(int(*e.Code)).WithPayload(e) } - return backend_switching_rule.NewGetBackendSwitchingRulesOK().WithPayload(&backend_switching_rule.GetBackendSwitchingRulesOKBody{Version: v, Data: bckRules}).WithConfigurationVersion(v) + return backend_switching_rule.NewGetBackendSwitchingRulesOK().WithPayload(bckRules) } -//Handle executing the request and returning a response -func (h *ReplaceBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.ReplaceBackendSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceBackendSwitchingRuleHandlerImpl) Handle(params backend_switching_rule.ReplaceBackendSwitchingRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -185,7 +218,13 @@ func (h *ReplaceBackendSwitchingRuleHandlerImpl) Handle(params backend_switching return backend_switching_rule.NewReplaceBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditBackendSwitchingRule(params.ID, params.Frontend, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return backend_switching_rule.NewReplaceBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditBackendSwitchingRule(params.Index, params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) return backend_switching_rule.NewReplaceBackendSwitchingRuleDefault(int(*e.Code)).WithPayload(e) @@ -204,3 +243,50 @@ func (h *ReplaceBackendSwitchingRuleHandlerImpl) Handle(params backend_switching } return backend_switching_rule.NewReplaceBackendSwitchingRuleAccepted().WithPayload(params.Data) } + +// Handle executing the request and returning a response +func (h *ReplaceBackendSwitchingRulesHandlerImpl) Handle(params backend_switching_rule.ReplaceBackendSwitchingRulesParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return backend_switching_rule.NewReplaceBackendSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return backend_switching_rule.NewReplaceBackendSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceBackendSwitchingRules(params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return backend_switching_rule.NewReplaceBackendSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return backend_switching_rule.NewReplaceBackendSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + return backend_switching_rule.NewReplaceBackendSwitchingRulesOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return backend_switching_rule.NewReplaceBackendSwitchingRulesAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return backend_switching_rule.NewReplaceBackendSwitchingRulesAccepted().WithPayload(params.Data) +} diff --git a/handlers/bind.go b/handlers/bind.go index 3d7ad6d6..9fd15de3 100644 --- a/handlers/bind.go +++ b/handlers/bind.go @@ -16,44 +16,61 @@ package handlers import ( + "errors" + "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/bind" - "github.com/haproxytech/models" ) -//CreateBindHandlerImpl implementation of the CreateBindHandler interface using client-native client +// CreateBindHandlerImpl implementation of the CreateBindHandler interface using client-native client type CreateBindHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteBindHandlerImpl implementation of the DeleteBindHandler interface using client-native client +// DeleteBindHandlerImpl implementation of the DeleteBindHandler interface using client-native client type DeleteBindHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetBindHandlerImpl implementation of the GetBindHandler interface using client-native client +// GetBindHandlerImpl implementation of the GetBindHandler interface using client-native client type GetBindHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetBindsHandlerImpl implementation of the GetBindsHandler interface using client-native client -type GetBindsHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllBindHandlerImpl implementation of the GetBindsHandler interface using client-native client +type GetAllBindHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceBindHandlerImpl implementation of the ReplaceBindHandler interface using client-native client +// ReplaceBindHandlerImpl implementation of the ReplaceBindHandler interface using client-native client type ReplaceBindHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateBindHandlerImpl) Handle(params bind.CreateBindParams, principal interface{}) middleware.Responder { +func bindTypeParams(frontend *string, parentType *string, parentName *string) (pType string, pName string, err error) { + if frontend != nil && *frontend != "" { + return "frontend", *frontend, nil + } + if parentType == nil || *parentType == "" { + return "", "", errors.New("parentType empty") + } + if parentName == nil || *parentName == "" { + return "", "", errors.New("parentName empty") + } + return *parentType, *parentName, nil +} + +// Handle executing the request and returning a response +func (h *CreateBindHandlerImpl) Handle(parentType cnconstants.CnParentType, params bind.CreateBindFrontendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,31 +87,42 @@ func (h *CreateBindHandlerImpl) Handle(params bind.CreateBindParams, principal i Message: &msg, Code: &c, } - return bind.NewCreateBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewCreateBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return bind.NewCreateBindFrontendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateBind(params.Frontend, params.Data, t, v) + pType, pName, err := bindTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) if err != nil { e := misc.HandleError(err) - return bind.NewCreateBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewCreateBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.CreateBind(pType, pName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return bind.NewCreateBindFrontendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return bind.NewCreateBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewCreateBindFrontendDefault(int(*e.Code)).WithPayload(e) } - return bind.NewCreateBindCreated().WithPayload(params.Data) + return bind.NewCreateBindFrontendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return bind.NewCreateBindAccepted().WithReloadID(rID).WithPayload(params.Data) + return bind.NewCreateBindFrontendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return bind.NewCreateBindAccepted().WithPayload(params.Data) + return bind.NewCreateBindFrontendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteBindHandlerImpl) Handle(params bind.DeleteBindParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteBindHandlerImpl) Handle(parentType cnconstants.CnParentType, params bind.DeleteBindFrontendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -111,61 +139,97 @@ func (h *DeleteBindHandlerImpl) Handle(params bind.DeleteBindParams, principal i Message: &msg, Code: &c, } - return bind.NewDeleteBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewDeleteBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return bind.NewDeleteBindFrontendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteBind(params.Name, params.Frontend, t, v) + pType, pName, err := bindTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) + if err != nil { + e := misc.HandleError(err) + return bind.NewDeleteBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.DeleteBind(params.Name, pType, pName, t, v) if err != nil { e := misc.HandleError(err) - return bind.NewDeleteBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewDeleteBindFrontendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return bind.NewDeleteBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewDeleteBindFrontendDefault(int(*e.Code)).WithPayload(e) } - return bind.NewDeleteBindNoContent() + return bind.NewDeleteBindFrontendNoContent() } rID := h.ReloadAgent.Reload() - return bind.NewDeleteBindAccepted().WithReloadID(rID) + return bind.NewDeleteBindFrontendAccepted().WithReloadID(rID) } - return bind.NewDeleteBindAccepted() + return bind.NewDeleteBindFrontendAccepted() } -//Handle executing the request and returning a response -func (h *GetBindHandlerImpl) Handle(params bind.GetBindParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetBindHandlerImpl) Handle(parentType cnconstants.CnParentType, params bind.GetBindFrontendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, b, err := h.Client.Configuration.GetBind(params.Name, params.Frontend, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return bind.NewGetBindDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return bind.NewGetBindFrontendDefault(int(*e.Code)).WithPayload(e) } - return bind.NewGetBindOK().WithPayload(&bind.GetBindOKBody{Version: v, Data: b}).WithConfigurationVersion(v) + + pType, pName, err := bindTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) + if err != nil { + e := misc.HandleError(err) + return bind.NewGetBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + _, b, err := configuration.GetBind(params.Name, pType, pName, t) + if err != nil { + e := misc.HandleError(err) + return bind.NewGetBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + return bind.NewGetBindFrontendOK().WithPayload(b) } -//Handle executing the request and returning a response -func (h *GetBindsHandlerImpl) Handle(params bind.GetBindsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllBindHandlerImpl) Handle(parentType cnconstants.CnParentType, params bind.GetAllBindFrontendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, bs, err := h.Client.Configuration.GetBinds(params.Frontend, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return bind.NewGetAllBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + + pType, pName, err := bindTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) if err != nil { e := misc.HandleError(err) - return bind.NewGetBindsDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return bind.NewGetAllBindFrontendDefault(int(*e.Code)).WithPayload(e) } - return bind.NewGetBindsOK().WithPayload(&bind.GetBindsOKBody{Version: v, Data: bs}).WithConfigurationVersion(v) + _, bs, err := configuration.GetBinds(pType, pName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return bind.NewGetAllBindFrontendOK().WithPayload(models.Binds{}) + } + return bind.NewGetAllBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + return bind.NewGetAllBindFrontendOK().WithPayload(bs) } -//Handle executing the request and returning a response -func (h *ReplaceBindHandlerImpl) Handle(params bind.ReplaceBindParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceBindHandlerImpl) Handle(parentType cnconstants.CnParentType, params bind.ReplaceBindFrontendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -182,25 +246,36 @@ func (h *ReplaceBindHandlerImpl) Handle(params bind.ReplaceBindParams, principal Message: &msg, Code: &c, } - return bind.NewReplaceBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewReplaceBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return bind.NewReplaceBindFrontendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditBind(params.Name, params.Frontend, params.Data, t, v) + pType, pName, err := bindTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) + if err != nil { + e := misc.HandleError(err) + return bind.NewReplaceBindFrontendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.EditBind(params.Name, pType, pName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return bind.NewReplaceBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewReplaceBindFrontendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return bind.NewReplaceBindDefault(int(*e.Code)).WithPayload(e) + return bind.NewReplaceBindFrontendDefault(int(*e.Code)).WithPayload(e) } - return bind.NewReplaceBindOK().WithPayload(params.Data) + return bind.NewReplaceBindFrontendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return bind.NewReplaceBindAccepted().WithReloadID(rID).WithPayload(params.Data) + return bind.NewReplaceBindFrontendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return bind.NewReplaceBindAccepted().WithPayload(params.Data) + return bind.NewReplaceBindFrontendAccepted().WithPayload(params.Data) } diff --git a/handlers/cache.go b/handlers/cache.go new file mode 100644 index 00000000..d5aa1afe --- /dev/null +++ b/handlers/cache.go @@ -0,0 +1,239 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/cache" +) + +// CreateCacheHandlerImpl implementation of the CreateCacheHandler interface using client-native client +type CreateCacheHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteCacheHandlerImpl implementation of the DeleteCacheHandler interface using client-native client +type DeleteCacheHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetCacheHandlerImpl implementation of the GetCacheHandler interface using client-native client +type GetCacheHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetCachesHandlerImpl implementation of the GetCachesHandler interface using client-native client +type GetCachesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceCacheHandlerImpl implementation of the ReplaceCacheHandler interface using client-native client +type ReplaceCacheHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateCacheHandlerImpl) Handle(params cache.CreateCacheParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return cache.NewCreateCacheDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return cache.NewCreateCacheDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateCache(params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return cache.NewCreateCacheDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return cache.NewCreateCacheDefault(int(*e.Code)).WithPayload(e) + } + return cache.NewCreateCacheCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return cache.NewCreateCacheAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return cache.NewCreateCacheAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteCacheHandlerImpl) Handle(params cache.DeleteCacheParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return cache.NewDeleteCacheDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return cache.NewDeleteCacheDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteCache(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return cache.NewDeleteCacheDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return cache.NewDeleteCacheDefault(int(*e.Code)).WithPayload(e) + } + return cache.NewDeleteCacheNoContent() + } + rID := h.ReloadAgent.Reload() + return cache.NewDeleteCacheAccepted().WithReloadID(rID) + } + return cache.NewDeleteCacheAccepted() +} + +// Handle executing the request and returning a response +func (h *GetCacheHandlerImpl) Handle(params cache.GetCacheParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return cache.NewGetCacheDefault(int(*e.Code)).WithPayload(e) + } + + _, r, err := configuration.GetCache(params.Name, t) + if err != nil { + e := misc.HandleError(err) + return cache.NewGetCacheDefault(int(*e.Code)).WithPayload(e) + } + return cache.NewGetCacheOK().WithPayload(r) +} + +// Handle executing the request and returning a response +func (h *GetCachesHandlerImpl) Handle(params cache.GetCachesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return cache.NewGetCachesDefault(int(*e.Code)).WithPayload(e) + } + + _, rs, err := configuration.GetCaches(t) + if err != nil { + e := misc.HandleError(err) + return cache.NewGetCachesDefault(int(*e.Code)).WithPayload(e) + } + return cache.NewGetCachesOK().WithPayload(rs) +} + +// Handle executing the request and returning a response +func (h *ReplaceCacheHandlerImpl) Handle(params cache.ReplaceCacheParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return cache.NewReplaceCacheDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return cache.NewReplaceCacheDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditCache(params.Name, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return cache.NewReplaceCacheDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return cache.NewReplaceCacheDefault(int(*e.Code)).WithPayload(e) + } + return cache.NewReplaceCacheOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return cache.NewReplaceCacheAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return cache.NewReplaceCacheAccepted().WithPayload(params.Data) +} diff --git a/handlers/capture.go b/handlers/capture.go new file mode 100644 index 00000000..d2f20f9f --- /dev/null +++ b/handlers/capture.go @@ -0,0 +1,305 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + capture "github.com/haproxytech/dataplaneapi/operations/declare_capture" +) + +type CreateDeclareCaptureHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +type DeleteDeclareCaptureHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +type GetDeclareCaptureHandlerImpl struct { + Client client_native.HAProxyClient +} + +type GetDeclareCapturesHandlerImpl struct { + Client client_native.HAProxyClient +} + +type ReplaceDeclareCaptureHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +type ReplaceDeclareCapturesHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *CreateDeclareCaptureHandlerImpl) Handle(params capture.CreateDeclareCaptureParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return capture.NewCreateDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return capture.NewGetDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + _, frontend, err := configuration.GetFrontend(params.ParentName, t) + if frontend == nil { + return capture.NewGetDeclareCaptureNotFound() + } + if err != nil { + return capture.NewGetDeclareCaptureNotFound() + } + err = configuration.CreateDeclareCapture(params.Index, params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return capture.NewCreateDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return capture.NewCreateDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + return capture.NewCreateDeclareCaptureCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return capture.NewCreateDeclareCaptureAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return capture.NewCreateDeclareCaptureAccepted().WithPayload(params.Data) +} + +func (h *DeleteDeclareCaptureHandlerImpl) Handle(params capture.DeleteDeclareCaptureParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return capture.NewCreateDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return capture.NewDeleteDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.DeleteDeclareCapture(params.Index, params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return capture.NewDeleteDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return capture.NewDeleteDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + return capture.NewDeleteDeclareCaptureNoContent() + } + rID := h.ReloadAgent.Reload() + return capture.NewCreateDeclareCaptureAccepted().WithReloadID(rID) + } + return capture.NewDeleteDeclareCaptureAccepted() +} + +func (h *GetDeclareCaptureHandlerImpl) Handle(params capture.GetDeclareCaptureParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return capture.NewGetDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + + _, frontend, err := configuration.GetFrontend(params.ParentName, t) + if frontend == nil { + return capture.NewGetDeclareCaptureNotFound() + } + if err != nil { + return capture.NewGetDeclareCaptureNotFound() + } + _, data, err := configuration.GetDeclareCapture(params.Index, params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return capture.NewGetDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + return capture.NewGetDeclareCaptureOK().WithPayload(data) +} + +func (h *GetDeclareCapturesHandlerImpl) Handle(params capture.GetDeclareCapturesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return capture.NewGetDeclareCapturesDefault(int(*e.Code)).WithPayload(e) + } + + _, frontend, err := configuration.GetFrontend(params.ParentName, t) + if frontend == nil { + return capture.NewGetDeclareCaptureNotFound() + } + if err != nil { + return capture.NewGetDeclareCaptureNotFound() + } + _, data, err := configuration.GetDeclareCaptures(params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return capture.NewGetDeclareCapturesOK().WithPayload(data) + } + return capture.NewGetDeclareCapturesDefault(int(*e.Code)).WithPayload(e) + } + return capture.NewGetDeclareCapturesOK().WithPayload(data) +} + +func (h *ReplaceDeclareCaptureHandlerImpl) Handle(params capture.ReplaceDeclareCaptureParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return capture.NewReplaceDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return capture.NewReplaceDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + + _, frontend, err := configuration.GetFrontend(params.ParentName, t) + if frontend == nil { + return capture.NewGetDeclareCaptureNotFound() + } + if err != nil { + return capture.NewGetDeclareCaptureNotFound() + } + err = configuration.EditDeclareCapture(params.Index, params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return capture.NewReplaceDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return capture.NewReplaceDeclareCaptureDefault(int(*e.Code)).WithPayload(e) + } + return capture.NewReplaceDeclareCaptureOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return capture.NewReplaceDeclareCaptureAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return capture.NewReplaceDeclareCaptureAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *ReplaceDeclareCapturesHandlerImpl) Handle(params capture.ReplaceDeclareCapturesParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return capture.NewReplaceDeclareCapturesDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return capture.NewReplaceDeclareCapturesDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceDeclareCaptures(params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return capture.NewReplaceDeclareCapturesDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return capture.NewReplaceDeclareCapturesDefault(int(*e.Code)).WithPayload(e) + } + return capture.NewReplaceDeclareCapturesOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return capture.NewReplaceDeclareCapturesAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return capture.NewReplaceDeclareCapturesAccepted().WithPayload(params.Data) +} diff --git a/handlers/cluster.go b/handlers/cluster.go new file mode 100644 index 00000000..28e8e2cb --- /dev/null +++ b/handlers/cluster.go @@ -0,0 +1,331 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "errors" + "fmt" + "reflect" + "strings" + "time" + + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/operations/cluster" + "github.com/haproxytech/dataplaneapi/storagetype" +) + +// CreateClusterHandlerImpl implementation of the CreateClusterHandler interface +type CreateClusterHandlerImpl struct { + Client client_native.HAProxyClient + Config *configuration.Configuration + ReloadAgent haproxy.IReloadAgent +} + +// GetClusterHandlerImpl implementation of the GetClusterHandler interface +type GetClusterHandlerImpl struct { + Config *configuration.Configuration +} + +// ClusterInitiateCertificateRefreshHandlerImpl implementation of the ClusterInitiateCertificateRefreshHandler interface +type ClusterInitiateCertificateRefreshHandlerImpl struct { + Config *configuration.Configuration +} + +type DeleteClusterHandlerImpl struct { + Client client_native.HAProxyClient + Config *configuration.Configuration + Users *configuration.Users + ReloadAgent haproxy.IReloadAgent +} + +type EditClusterHandlerImpl struct { + Config *configuration.Configuration +} + +// Handle executing the request and returning a response +func (h *ClusterInitiateCertificateRefreshHandlerImpl) Handle(params cluster.InitiateCertificateRefreshParams, principal any) middleware.Responder { + if h.Config.Mode.Load() != configuration.ModeCluster { + return cluster.NewInitiateCertificateRefreshForbidden() + } + h.Config.Notify.CertificateRefresh.Notify() + return cluster.NewInitiateCertificateRefreshOK() +} + +func (h *CreateClusterHandlerImpl) err500(err error, transaction *models.Transaction) middleware.Responder { + if transaction != nil { + configuration, confErr := h.Client.Configuration() + if confErr == nil { + _ = configuration.DeleteTransaction(transaction.ID) + } + } + msg := err.Error() + code := int64(500) + return cluster.NewPostClusterDefault(500).WithPayload(&models.Error{ + Code: &code, + Message: &msg, + }) +} + +func (h *CreateClusterHandlerImpl) err406(err error, transaction *models.Transaction) middleware.Responder { + // 406 Not Acceptable + if transaction != nil { + configuration, confErr := h.Client.Configuration() + if confErr == nil { + _ = configuration.DeleteTransaction(transaction.ID) + } + } + msg := err.Error() + code := int64(406) + return cluster.NewPostClusterDefault(406).WithPayload(&models.Error{ + Code: &code, + Message: &msg, + }) +} + +func (h *CreateClusterHandlerImpl) err409(err error, transaction *models.Transaction) middleware.Responder { + // 409 Conflict + if transaction != nil { + configuration, confErr := h.Client.Configuration() + if confErr == nil { + _ = configuration.DeleteTransaction(transaction.ID) + } + } + msg := err.Error() + code := int64(409) + return cluster.NewPostClusterDefault(409).WithPayload(&models.Error{ + Code: &code, + Message: &msg, + }) +} + +func (h *CreateClusterHandlerImpl) Handle(params cluster.PostClusterParams, principal any) middleware.Responder { + key := h.Config.Cluster.BootstrapKey.Load() + if params.Data.BootstrapKey != "" && key != params.Data.BootstrapKey { + // before we switch to cluster mode, check if folder for storage is compatible with dataplane + key, err := configuration.DecodeBootstrapKey(params.Data.BootstrapKey) + if err != nil { + return h.err406(err, nil) + } + log.Warningf("received instructions from %s to join cluster %s at %s", params.HTTPRequest.RemoteAddr, key["name"], key["address"]) + errStorageDir := configuration.CheckIfStorageDirIsOK(key["storage-dir"], h.Config) + if errStorageDir != nil { + log.Warningf("configured storage dir incompatible with cluster configuration: %s", errStorageDir) + return h.err409(errStorageDir, nil) + } + // Init NOTICE file to inform user that the cluster storage folder is programmatically managed by Fusion API + if errStorageInit := configuration.InitStorageNoticeFile(key["storage-dir"]); errStorageInit != nil { + log.Warningf("unable to create notice file, %s: skipping it", errStorageInit.Error()) + } + // enforcing API advertising options + if a := params.AdvertisedAddress; a != nil { + h.Config.APIOptions.APIAddress = *a + } + if p := params.AdvertisedPort; p != nil { + h.Config.APIOptions.APIPort = *p + } + h.Config.Mode.Store(configuration.ModeCluster) + h.Config.Cluster.BootstrapKey.Store(params.Data.BootstrapKey) + h.Config.Cluster.Clear() + // ensuring configuration file saving occurs before notifying the monitor about the bootstrap key change + defer func() { + h.Config.Notify.BootstrapKeyChanged.Notify() + }() + } + err := h.Config.SaveClusterModeData() + if err != nil { + return h.err500(err, nil) + } + return cluster.NewPostClusterOK().WithPayload(getClusterSettings(h.Config)) +} + +// Handle executing the request and returning a response +func (h *GetClusterHandlerImpl) Handle(params cluster.GetClusterParams, principal any) middleware.Responder { + return cluster.NewGetClusterOK().WithPayload(getClusterSettings(h.Config)) +} + +func (h *DeleteClusterHandlerImpl) Handle(params cluster.DeleteClusterParams, principal any) middleware.Responder { + log.Warningf("received instructions from %s to switch to standalone mode", params.HTTPRequest.RemoteAddr) + // Only do when dataplane is in cluster mode, if not, do nothing and return 204 + if h.Config.Mode.Load() == configuration.ModeCluster { + log.Warning("clearing cluster users") + for _, u := range h.Users.GetUsers() { + // remove all users for cluster communication + if strings.HasPrefix(u.Name, storagetype.DapiClusterUserPrefix) { + errRU := h.Users.RemoveUser(u) + if errRU != nil { + log.Error(errRU.Error()) + } + } + } + // If we don't want to keep the haproxy configuration, set it to dummy config + if params.Configuration == nil || *params.Configuration != "keep" { + log.Warning("clearing configuration as requested") + + conf, err := h.Client.Configuration() + if err != nil { + return h.err500(err, nil) + } + version, errVersion := conf.GetVersion("") + if errVersion != nil || version < 1 { + // silently fallback to 1 + version = 1 + } + + config := fmt.Sprintf(DummyConfig, time.Now().Format("01-02-2006 15:04:05 MST"), h.Config.Name.Load()) + if err = conf.PostRawConfiguration(&config, version, true); err != nil { + return h.err500(err, nil) + } + + // we need to restart haproxy + err = h.ReloadAgent.Restart() + if err != nil { + return h.err500(err, nil) + } + // Deleting the storage directory used by Fusion: + // avoiding at all entering any nil pointer dereference. + if storageData := h.Config.GetStorageData(); storageData != nil && storageData.DeprecatedCluster != nil && storageData.DeprecatedCluster.StorageDir != nil { + if storageErr := configuration.RemoveStorageFolder(*storageData.DeprecatedCluster.StorageDir); storageErr != nil { + log.Warningf("failed to clean-up the cluster storage directory: %s", storageErr.Error()) + } + } + } + h.Config.Cluster.BootstrapKey.Store("") + h.Config.Status.Store("active") + h.Config.HAProxy.ClusterTLSCertDir = "" + h.Config.Cluster.Clear() + defer func() { + log.Warning("reloading to apply configuration changes") + h.Config.Notify.Reload.Notify() + }() + } + err := h.Config.SaveClusterModeData() + if err != nil { + return h.err500(err, nil) + } + return cluster.NewDeleteClusterNoContent() +} + +func (h *DeleteClusterHandlerImpl) err500(err error, transaction *models.Transaction) middleware.Responder { + if transaction != nil { + configuration, confErr := h.Client.Configuration() + if confErr == nil { + _ = configuration.DeleteTransaction(transaction.ID) + } + } + msg := err.Error() + code := int64(500) + return cluster.NewDeleteClusterDefault(500).WithPayload(&models.Error{ + Code: &code, + Message: &msg, + }) +} + +func (h *EditClusterHandlerImpl) Handle(params cluster.EditClusterParams, principal any) middleware.Responder { + // Only do when dataplane is in cluster mode, if not, do nothing and return 204 + if h.Config.Mode.Load() == configuration.ModeCluster { + // for now change only cluster log targets in PUT method + if params.Data != nil && params.Data.Cluster != nil { + if clusterLogTargetsChanged(h.Config.Cluster.ClusterLogTargets, params.Data.Cluster.ClusterLogTargets) { + h.Config.Cluster.ClusterLogTargets = params.Data.Cluster.ClusterLogTargets + h.Config.Cluster.ClusterID.Store(params.Data.Cluster.ClusterID) + err := h.Config.Save() + if err != nil { + return h.err500(err) + } + defer h.Config.Notify.Reload.Notify() + } + } + return cluster.NewEditClusterOK().WithPayload(getClusterSettings(h.Config)) + } + return h.err406(errors.New("dataplaneapi in single mode")) +} + +func (h *EditClusterHandlerImpl) err406(err error) middleware.Responder { + // 406 Not Acceptable + msg := err.Error() + code := int64(406) + return cluster.NewEditClusterDefault(406).WithPayload(&models.Error{ + Code: &code, + Message: &msg, + }) +} + +func (h *EditClusterHandlerImpl) err500(err error) middleware.Responder { + msg := err.Error() + code := int64(500) + return cluster.NewEditClusterDefault(500).WithPayload(&models.Error{ + Code: &code, + Message: &msg, + }) +} + +func getClusterSettings(cfg *configuration.Configuration) *models.ClusterSettings { + portStr := cfg.Cluster.Port.Load() + port := int64(portStr) + var clusterSettings *models.ClusterSettingsCluster + if cfg.Mode.Load() == configuration.ModeCluster { + clusterSettings = &models.ClusterSettingsCluster{ + Address: cfg.Cluster.URL.Load(), + Port: &port, + APIBasePath: cfg.Cluster.APIBasePath.Load(), + Name: cfg.Cluster.Name.Load(), + Description: cfg.Cluster.Description.Load(), + ClusterLogTargets: cfg.Cluster.ClusterLogTargets, + } + } + settings := &models.ClusterSettings{ + BootstrapKey: cfg.Cluster.BootstrapKey.Load(), + Cluster: clusterSettings, + Mode: cfg.Mode.Load(), + Status: cfg.Status.Load(), + } + return settings +} + +func clusterLogTargetsChanged(oldCLT []*models.ClusterLogTarget, newCLT []*models.ClusterLogTarget) bool { + if len(oldCLT) == len(newCLT) { + eqCtr := 0 + for _, oldT := range oldCLT { + for _, newT := range newCLT { + if reflect.DeepEqual(oldT, newT) { + eqCtr++ + } + } + } + return eqCtr != len(oldCLT) + } + return true +} + +const DummyConfig = `# NOTE: This configuration file was managed by the Fusion Control Plane. +# Fusion released the control at %s + +defaults + mode http + timeout connect 5000 + timeout client 30000 + timeout server 10000 + +frontend disabled + bind /tmp/dataplaneapi-%s.sock name tmp + +` diff --git a/handlers/consul.go b/handlers/consul.go new file mode 100644 index 00000000..7f759204 --- /dev/null +++ b/handlers/consul.go @@ -0,0 +1,177 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "errors" + + "github.com/go-openapi/runtime/middleware" + "github.com/haproxytech/client-native/v6/models" + + sc "github.com/haproxytech/dataplaneapi/discovery" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/service_discovery" +) + +// CreateConsulHandlerImpl implementation of the CreateConsulHandler interface using client-native client +type CreateConsulHandlerImpl struct { + Discovery sc.ServiceDiscoveries + PersistCallback func([]*models.Consul) error + UseValidation bool +} + +// DeleteConsulHandlerImpl implementation of the DeleteConsulHandler interface using client-native client +type DeleteConsulHandlerImpl struct { + Discovery sc.ServiceDiscoveries + PersistCallback func([]*models.Consul) error +} + +// GetConsulHandlerImpl implementation of the GetConsulHandler interface using client-native client +type GetConsulHandlerImpl struct { + Discovery sc.ServiceDiscoveries +} + +// GetConsulsHandlerImpl implementation of the GetConsulsHandler interface using client-native client +type GetConsulsHandlerImpl struct { + Discovery sc.ServiceDiscoveries +} + +// ReplaceConsulHandlerImpl implementation of the ReplaceConsulHandler interface using client-native client +type ReplaceConsulHandlerImpl struct { + Discovery sc.ServiceDiscoveries + PersistCallback func([]*models.Consul) error + UseValidation bool +} + +// Handle executing the request and returning a response +func (c *CreateConsulHandlerImpl) Handle(params service_discovery.CreateConsulParams, principal any) middleware.Responder { + params.Data.ID = sc.NewServiceDiscoveryUUID() + if err := sc.ValidateConsulData(params.Data, c.UseValidation); err != nil { + e := misc.HandleError(err) + return service_discovery.NewCreateConsulDefault(int(*e.Code)).WithPayload(e) + } + if params.Data.HealthCheckPolicy != nil && *params.Data.HealthCheckPolicy == models.ConsulHealthCheckPolicyMin && params.Data.HealthCheckPolicyMin <= 0 { + e := &models.Error{ + Message: misc.StringP("health_check_policy_min is required for 'min' health_check_policy"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return service_discovery.NewCreateConsulDefault(int(*e.Code)).WithPayload(e) + } + err := c.Discovery.AddNode("consul", *params.Data.ID, params.Data) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewCreateConsulDefault(int(*e.Code)).WithPayload(e) + } + consuls, err := getConsuls(c.Discovery) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewCreateConsulDefault(int(*e.Code)).WithPayload(e) + } + err = c.PersistCallback(consuls) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewCreateConsulDefault(int(*e.Code)).WithPayload(e) + } + return service_discovery.NewCreateConsulCreated().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (c *DeleteConsulHandlerImpl) Handle(params service_discovery.DeleteConsulParams, principal any) middleware.Responder { + err := c.Discovery.RemoveNode("consul", params.ID) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewReplaceConsulDefault(int(*e.Code)).WithPayload(e) + } + consuls, err := getConsuls(c.Discovery) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewDeleteConsulDefault(int(*e.Code)).WithPayload(e) + } + err = c.PersistCallback(consuls) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewDeleteConsulDefault(int(*e.Code)).WithPayload(e) + } + return service_discovery.NewDeleteConsulNoContent() +} + +// Handle executing the request and returning a response +func (c *GetConsulHandlerImpl) Handle(params service_discovery.GetConsulParams, principal any) middleware.Responder { + nodes, err := c.Discovery.GetNode("consul", params.ID) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewGetConsulsDefault(int(*e.Code)).WithPayload(e) + } + consul, ok := nodes.(*models.Consul) + if !ok { + e := misc.HandleError(errors.New("expected *models.Consul")) + return service_discovery.NewGetConsulsDefault(int(*e.Code)).WithPayload(e) + } + return service_discovery.NewGetConsulOK().WithPayload(consul) +} + +// Handle executing the request and returning a response +func (c *GetConsulsHandlerImpl) Handle(params service_discovery.GetConsulsParams, principal any) middleware.Responder { + consuls, err := getConsuls(c.Discovery) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewGetConsulDefault(int(*e.Code)).WithPayload(e) + } + return service_discovery.NewGetConsulsOK().WithPayload(consuls) +} + +// Handle executing the request and returning a response +func (c *ReplaceConsulHandlerImpl) Handle(params service_discovery.ReplaceConsulParams, principal any) middleware.Responder { + if err := sc.ValidateConsulData(params.Data, c.UseValidation); err != nil { + e := misc.HandleError(err) + return service_discovery.NewReplaceConsulDefault(int(*e.Code)).WithPayload(e) + } + if params.Data.HealthCheckPolicy != nil && *params.Data.HealthCheckPolicy == models.ConsulHealthCheckPolicyMin && params.Data.HealthCheckPolicyMin <= 0 { + e := &models.Error{ + Message: misc.StringP("health_check_policy_min is required for 'min' health_check_policy"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return service_discovery.NewCreateConsulDefault(int(*e.Code)).WithPayload(e) + } + err := c.Discovery.UpdateNode("consul", *params.Data.ID, params.Data) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewReplaceConsulDefault(int(*e.Code)).WithPayload(e) + } + consuls, err := getConsuls(c.Discovery) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewReplaceConsulDefault(int(*e.Code)).WithPayload(e) + } + err = c.PersistCallback(consuls) + if err != nil { + e := misc.HandleError(err) + return service_discovery.NewDeleteConsulDefault(int(*e.Code)).WithPayload(e) + } + return service_discovery.NewReplaceConsulOK().WithPayload(params.Data) +} + +func getConsuls(discovery sc.ServiceDiscoveries) (models.Consuls, error) { + nodes, err := discovery.GetNodes("consul") + if err != nil { + return nil, err + } + consuls, ok := nodes.(models.Consuls) + if !ok { + return nil, errors.New("expected models.Consuls") + } + return consuls, nil +} diff --git a/handlers/crt_load.go b/handlers/crt_load.go new file mode 100644 index 00000000..f52d303c --- /dev/null +++ b/handlers/crt_load.go @@ -0,0 +1,234 @@ +// Copyright 2024 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/crt_load" +) + +type GetCrtLoadsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Get all loads from crt-stores +func (h *GetCrtLoadsHandlerImpl) Handle(params crt_load.GetCrtLoadsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewGetCrtLoadsDefault(int(*e.Code)).WithPayload(e) + } + + _, stores, err := configuration.GetCrtLoads(params.CrtStore, t) + if err != nil { + e := misc.HandleError(err) + return crt_load.NewGetCrtLoadsDefault(int(*e.Code)).WithPayload(e) + } + + return crt_load.NewGetCrtLoadsOK().WithPayload(stores) +} + +type GetCrtLoadHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Get one load from a crt-store +func (h *GetCrtLoadHandlerImpl) Handle(params crt_load.GetCrtLoadParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewGetCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + _, store, err := configuration.GetCrtLoad(params.Certificate, params.CrtStore, t) + if err != nil { + e := misc.HandleError(err) + return crt_load.NewGetCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + return crt_load.NewGetCrtLoadOK().WithPayload(store) +} + +type CreateCrtLoadHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *CreateCrtLoadHandlerImpl) Handle(params crt_load.CreateCrtLoadParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return crt_load.NewCreateCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewCreateCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateCrtLoad(params.CrtStore, params.Data, t, v); err != nil { + e := misc.HandleError(err) + return crt_load.NewCreateCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewCreateCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + return crt_load.NewCreateCrtLoadCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return crt_load.NewCreateCrtLoadAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return crt_load.NewCreateCrtLoadAccepted().WithPayload(params.Data) +} + +type ReplaceCrtLoadHandler struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *ReplaceCrtLoadHandler) Handle(params crt_load.ReplaceCrtLoadParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return crt_load.NewReplaceCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewReplaceCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditCrtLoad(params.Certificate, params.CrtStore, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return crt_load.NewReplaceCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewReplaceCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + return crt_load.NewReplaceCrtLoadOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return crt_load.NewReplaceCrtLoadAccepted().WithReloadID(rID) + } + + return crt_load.NewReplaceCrtLoadOK().WithPayload(params.Data) +} + +type DeleteCrtLoadHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *DeleteCrtLoadHandlerImpl) Handle(params crt_load.DeleteCrtLoadParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return crt_load.NewDeleteCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewDeleteCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteCrtLoad(params.Certificate, params.CrtStore, t, v) + if err != nil { + e := misc.HandleError(err) + return crt_load.NewDeleteCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return crt_load.NewDeleteCrtLoadDefault(int(*e.Code)).WithPayload(e) + } + return crt_load.NewDeleteCrtLoadNoContent() + } + rID := h.ReloadAgent.Reload() + return crt_load.NewDeleteCrtLoadAccepted().WithReloadID(rID) + } + + return crt_load.NewDeleteCrtLoadAccepted() +} diff --git a/handlers/crt_store.go b/handlers/crt_store.go new file mode 100644 index 00000000..d07e05cc --- /dev/null +++ b/handlers/crt_store.go @@ -0,0 +1,221 @@ +// Copyright 2024 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/crt_store" +) + +type GetCrtStoresHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Get all crt-stores +func (h *GetCrtStoresHandlerImpl) Handle(params crt_store.GetCrtStoresParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_store.NewGetCrtStoresDefault(int(*e.Code)).WithPayload(e) + } + + _, stores, err := configuration.GetCrtStores(t) + if err != nil { + e := misc.HandleError(err) + return crt_store.NewGetCrtStoresDefault(int(*e.Code)).WithPayload(e) + } + + return crt_store.NewGetCrtStoresOK().WithPayload(stores) +} + +type GetCrtStoreHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Get one crt-store +func (h *GetCrtStoreHandlerImpl) Handle(params crt_store.GetCrtStoreParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_store.NewGetCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + _, store, err := configuration.GetCrtStore(params.Name, t) + if err != nil { + e := misc.HandleError(err) + return crt_store.NewGetCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + return crt_store.NewGetCrtStoreOK().WithPayload(store) +} + +type CreateCrtStoreHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *CreateCrtStoreHandlerImpl) Handle(params crt_store.CreateCrtStoreParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return crt_store.NewCreateCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_store.NewCreateCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateCrtStore(params.Data, t, v); err != nil { + e := misc.HandleError(err) + return crt_store.NewCreateCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return crt_store.NewCreateCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + return crt_store.NewCreateCrtStoreCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return crt_store.NewCreateCrtStoreAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return crt_store.NewCreateCrtStoreAccepted().WithPayload(params.Data) +} + +type EditCrtStoreHandler struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *EditCrtStoreHandler) Handle(params crt_store.EditCrtStoreParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return crt_store.NewEditCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_store.NewEditCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditCrtStore(params.Name, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return crt_store.NewEditCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + return crt_store.NewEditCrtStoreOK().WithPayload(params.Data) +} + +type DeleteCrtStoreHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *DeleteCrtStoreHandlerImpl) Handle(params crt_store.DeleteCrtStoreParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return crt_store.NewDeleteCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return crt_store.NewDeleteCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteCrtStore(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return crt_store.NewDeleteCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return crt_store.NewDeleteCrtStoreDefault(int(*e.Code)).WithPayload(e) + } + return crt_store.NewDeleteCrtStoreNoContent() + } + rID := h.ReloadAgent.Reload() + return crt_store.NewDeleteCrtStoreAccepted().WithReloadID(rID) + } + + return crt_store.NewDeleteCrtStoreAccepted() +} diff --git a/handlers/defaults.go b/handlers/defaults.go index 4d416c95..5e17e6e1 100644 --- a/handlers/defaults.go +++ b/handlers/defaults.go @@ -17,42 +17,53 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" - "github.com/haproxytech/dataplaneapi/operations/defaults" - "github.com/haproxytech/models" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/defaults" ) -//GetDefaultsHandlerImpl implementation of the GetDefaultsHandler interface +// GetDefaultsHandlerImpl implementation of the GetDefaultsHandler interface type GetDefaultsHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } // ReplaceDefaultsHandlerImpl implementation of the ReplaceDefaultsHandler interface type ReplaceDefaultsHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *GetDefaultsHandlerImpl) Handle(params defaults.GetDefaultsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetDefaultsHandlerImpl) Handle(params defaults.GetDefaultsSectionParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, data, err := h.Client.Configuration.GetDefaultsConfiguration(t) + _, data, err := h.getDefaultsConfiguration(params, t) if err != nil { e := misc.HandleError(err) - return defaults.NewGetDefaultsDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return defaults.NewGetDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + return defaults.NewGetDefaultsSectionOK().WithPayload(data) +} + +func (h *GetDefaultsHandlerImpl) getDefaultsConfiguration(params defaults.GetDefaultsSectionParams, t string) (int64, *models.Defaults, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredDefaultsConfiguration(t) } - return defaults.NewGetDefaultsOK().WithPayload(&defaults.GetDefaultsOKBody{Version: v, Data: data}).WithConfigurationVersion(v) + return configuration.GetDefaultsConfiguration(t) } -//Handle executing the request and returning a response -func (h *ReplaceDefaultsHandlerImpl) Handle(params defaults.ReplaceDefaultsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceDefaultsHandlerImpl) Handle(params defaults.ReplaceDefaultsSectionParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -69,27 +80,316 @@ func (h *ReplaceDefaultsHandlerImpl) Handle(params defaults.ReplaceDefaultsParam Message: &msg, Code: &c, } - return defaults.NewReplaceDefaultsDefault(int(*e.Code)).WithPayload(e) + return defaults.NewReplaceDefaultsSectionDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.PushDefaultsConfiguration(params.Data, t, v) + err := h.pushDefaultsConfiguration(params, t, v) + if err != nil { + e := misc.HandleError(err) + return defaults.NewReplaceDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return defaults.NewReplaceDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + return defaults.NewReplaceDefaultsSectionOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return defaults.NewReplaceDefaultsSectionAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return defaults.NewReplaceDefaultsSectionAccepted().WithPayload(params.Data) +} +func (h *ReplaceDefaultsHandlerImpl) pushDefaultsConfiguration(params defaults.ReplaceDefaultsSectionParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.PushStructuredDefaultsConfiguration(params.Data, t, v) + } + return configuration.PushDefaultsConfiguration(params.Data, t, v) +} + +// GetDefaultsHandlerImpl implementation of the GetDefaultsHandler interface +type GetDefaultsSectionsHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetDefaultsSectionsHandlerImpl) Handle(params defaults.GetDefaultsSectionsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, fs, err := h.getDefaultsSections(params, t) if err != nil { e := misc.HandleError(err) - return defaults.NewReplaceDefaultsDefault(int(*e.Code)).WithPayload(e) + return defaults.NewGetDefaultsSectionsDefault(int(*e.Code)).WithPayload(e) } + return defaults.NewGetDefaultsSectionsOK().WithPayload(fs) +} + +func (h *GetDefaultsSectionsHandlerImpl) getDefaultsSections(params defaults.GetDefaultsSectionsParams, t string) (int64, models.DefaultsSections, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredDefaultsSections(t) + } + return configuration.GetDefaultsSections(t) +} + +type GetDefaultsSectionHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetDefaultsSectionHandlerImpl) Handle(params defaults.GetDefaultsSectionParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, f, err := h.getDefaultsSection(params, t) + if err != nil { + e := misc.HandleError(err) + return defaults.NewGetDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + return defaults.NewGetDefaultsSectionOK().WithPayload(f) +} +func (h *GetDefaultsSectionHandlerImpl) getDefaultsSection(params defaults.GetDefaultsSectionParams, t string) (int64, *models.Defaults, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredDefaultsSection(params.Name, t) + } + return configuration.GetDefaultsSection(params.Name, t) +} + +type CreateDefaultsSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h CreateDefaultsSectionHandlerImpl) Handle(params defaults.CreateDefaultsSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return defaults.NewCreateDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + + err := h.createDefaultsSection(params, t, v) + if err != nil { + e := misc.HandleError(err) + return defaults.NewCreateDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return defaults.NewCreateDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + return defaults.NewCreateDefaultsSectionCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return defaults.NewCreateDefaultsSectionAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return defaults.NewCreateDefaultsSectionAccepted().WithPayload(params.Data) +} + +func (h *CreateDefaultsSectionHandlerImpl) createDefaultsSection(params defaults.CreateDefaultsSectionParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredDefaultsSection(params.Data, t, v) + } + return configuration.CreateDefaultsSection(params.Data, t, v) +} + +type AddDefaultsSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h AddDefaultsSectionHandlerImpl) Handle(params defaults.AddDefaultsSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return defaults.NewAddDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + + err := h.createDefaultsSection(params, t, v) + if err != nil { + e := misc.HandleError(err) + return defaults.NewAddDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return defaults.NewAddDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + return defaults.NewAddDefaultsSectionCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return defaults.NewAddDefaultsSectionAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return defaults.NewAddDefaultsSectionAccepted().WithPayload(params.Data) +} + +func (h *AddDefaultsSectionHandlerImpl) createDefaultsSection(params defaults.AddDefaultsSectionParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredDefaultsSection(params.Data, t, v) + } + return configuration.CreateDefaultsSection(params.Data, t, v) +} + +// ReplaceDefaultsHandlerImpl implementation of the ReplaceDefaultsHandler interface +type ReplaceDefaultsSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h ReplaceDefaultsSectionHandlerImpl) Handle(params defaults.ReplaceDefaultsSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return defaults.NewReplaceDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + + err := h.editDefaultsSection(params, t, v) + if err != nil { + e := misc.HandleError(err) + return defaults.NewReplaceDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return defaults.NewReplaceDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + return defaults.NewReplaceDefaultsSectionOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return defaults.NewReplaceDefaultsSectionAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return defaults.NewReplaceDefaultsSectionAccepted().WithPayload(params.Data) +} + +func (h *ReplaceDefaultsSectionHandlerImpl) editDefaultsSection(params defaults.ReplaceDefaultsSectionParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredDefaultsSection(params.Name, params.Data, t, v) + } + return configuration.EditDefaultsSection(params.Name, params.Data, t, v) +} + +type DeleteDefaultsSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h DeleteDefaultsSectionHandlerImpl) Handle(params defaults.DeleteDefaultsSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return defaults.NewDeleteDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return defaults.NewDeleteDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteDefaultsSection(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return defaults.NewDeleteDefaultsSectionDefault(int(*e.Code)).WithPayload(e) + } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return defaults.NewReplaceDefaultsDefault(int(*e.Code)).WithPayload(e) + return defaults.NewDeleteDefaultsSectionDefault(int(*e.Code)).WithPayload(e) } - return defaults.NewReplaceDefaultsOK().WithPayload(params.Data) + return defaults.NewDeleteDefaultsSectionNoContent() } rID := h.ReloadAgent.Reload() - return defaults.NewReplaceDefaultsAccepted().WithReloadID(rID).WithPayload(params.Data) + return defaults.NewDeleteDefaultsSectionAccepted().WithReloadID(rID) } - return defaults.NewReplaceDefaultsAccepted().WithPayload(params.Data) + return defaults.NewDeleteDefaultsSectionAccepted() } diff --git a/handlers/dgram_bind.go b/handlers/dgram_bind.go new file mode 100644 index 00000000..2fbb772a --- /dev/null +++ b/handlers/dgram_bind.go @@ -0,0 +1,239 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/dgram_bind" +) + +// CreateDgramBindHandlerImpl implementation of the CreateDgramBindHandler interface using client-native client +type CreateDgramBindHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteDgramBindHandlerImpl implementation of the DeleteDgramBindHandler interface using client-native client +type DeleteDgramBindHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetDgramBindHandlerImpl implementation of the GetDgramBindHandler interface using client-native client +type GetDgramBindHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetDgramBindsHandlerImpl implementation of the GetDgramBindsHandler interface using client-native client +type GetDgramBindsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceDgramBindHandlerImpl implementation of the ReplaceDgramBindHandler interface using client-native client +type ReplaceDgramBindHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateDgramBindHandlerImpl) Handle(params dgram_bind.CreateDgramBindParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return dgram_bind.NewCreateDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewCreateDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateDgramBind(params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewCreateDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewCreateDgramBindDefault(int(*e.Code)).WithPayload(e) + } + return dgram_bind.NewCreateDgramBindCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return dgram_bind.NewCreateDgramBindAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return dgram_bind.NewCreateDgramBindAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteDgramBindHandlerImpl) Handle(params dgram_bind.DeleteDgramBindParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return dgram_bind.NewDeleteDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewDeleteDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteDgramBind(params.Name, params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewDeleteDgramBindDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewDeleteDgramBindDefault(int(*e.Code)).WithPayload(e) + } + return dgram_bind.NewDeleteDgramBindNoContent() + } + rID := h.ReloadAgent.Reload() + return dgram_bind.NewDeleteDgramBindAccepted().WithReloadID(rID) + } + return dgram_bind.NewDeleteDgramBindAccepted() +} + +// Handle executing the request and returning a response +func (h *GetDgramBindHandlerImpl) Handle(params dgram_bind.GetDgramBindParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewGetDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + _, bck, err := configuration.GetDgramBind(params.Name, params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewGetDgramBindDefault(int(*e.Code)).WithPayload(e) + } + return dgram_bind.NewGetDgramBindOK().WithPayload(bck) +} + +// Handle executing the request and returning a response +func (h *GetDgramBindsHandlerImpl) Handle(params dgram_bind.GetDgramBindsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewGetDgramBindsDefault(int(*e.Code)).WithPayload(e) + } + + _, bcks, err := configuration.GetDgramBinds(params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewGetDgramBindsDefault(int(*e.Code)).WithPayload(e) + } + return dgram_bind.NewGetDgramBindsOK().WithPayload(bcks) +} + +// Handle executing the request and returning a response +func (h *ReplaceDgramBindHandlerImpl) Handle(params dgram_bind.ReplaceDgramBindParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return dgram_bind.NewReplaceDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewReplaceDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditDgramBind(params.Name, params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewReplaceDgramBindDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return dgram_bind.NewReplaceDgramBindDefault(int(*e.Code)).WithPayload(e) + } + return dgram_bind.NewReplaceDgramBindOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return dgram_bind.NewReplaceDgramBindAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return dgram_bind.NewReplaceDgramBindAccepted().WithPayload(params.Data) +} diff --git a/handlers/fcgi_app.go b/handlers/fcgi_app.go new file mode 100644 index 00000000..5d182cab --- /dev/null +++ b/handlers/fcgi_app.go @@ -0,0 +1,269 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/fcgi_app" +) + +type CreateFCGIAppHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (c CreateFCGIAppHandlerImpl) Handle(params fcgi_app.CreateFCGIAppParams, _ any) middleware.Responder { + var t string + var v int64 + + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + code := misc.ErrHTTPBadRequest + + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: &code, + } + + return fcgi_app.NewCreateFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + var err error + if err = c.createFCGIApplication(params, t, v); err != nil { + e := misc.HandleError(err) + return fcgi_app.NewCreateFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = c.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + + return fcgi_app.NewCreateFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + return fcgi_app.NewCreateFCGIAppCreated().WithPayload(params.Data) + } + + return fcgi_app.NewCreateFCGIAppAccepted().WithReloadID(c.ReloadAgent.Reload()).WithPayload(params.Data) + } + return fcgi_app.NewCreateFCGIAppAccepted().WithPayload(params.Data) +} + +func (c CreateFCGIAppHandlerImpl) createFCGIApplication(params fcgi_app.CreateFCGIAppParams, t string, v int64) error { + configuration, err := c.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredFCGIApplication(params.Data, t, v) + } + return configuration.CreateFCGIApplication(params.Data, t, v) +} + +type DeleteFCGIAppHandlerImpl struct { + ReloadAgent haproxy.IReloadAgent + Client client_native.HAProxyClient +} + +func (d DeleteFCGIAppHandlerImpl) Handle(params fcgi_app.DeleteFCGIAppParams, _ any) middleware.Responder { + var t string + var v int64 + + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + code := misc.ErrHTTPBadRequest + + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: &code, + } + + return fcgi_app.NewDeleteFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := d.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return fcgi_app.NewDeleteFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.DeleteFCGIApplication(params.Name, t, v); err != nil { + e := misc.HandleError(err) + return fcgi_app.NewDeleteFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = d.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + + return fcgi_app.NewDeleteFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + return fcgi_app.NewDeleteFCGIAppNoContent() + } + + return fcgi_app.NewDeleteFCGIAppAccepted().WithReloadID(d.ReloadAgent.Reload()) + } + + return fcgi_app.NewDeleteFCGIAppAccepted() +} + +type GetFCGIAppHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetFCGIAppHandlerImpl) Handle(params fcgi_app.GetFCGIAppParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, r, err := g.getFCGIApplication(params, t) + if err != nil { + e := misc.HandleError(err) + + return fcgi_app.NewGetFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + return fcgi_app.NewGetFCGIAppOK().WithPayload(r) +} + +func (g GetFCGIAppHandlerImpl) getFCGIApplication(params fcgi_app.GetFCGIAppParams, t string) (int64, *models.FCGIApp, error) { + configuration, err := g.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredFCGIApplication(params.Name, t) + } + return configuration.GetFCGIApplication(params.Name, t) +} + +type GetFCGIAppsHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetFCGIAppsHandlerImpl) Handle(params fcgi_app.GetFCGIAppsParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, r, err := g.getFCGIApplications(params, t) + if err != nil { + e := misc.HandleError(err) + + return fcgi_app.NewGetFCGIAppsDefault(int(*e.Code)).WithPayload(e) + } + + return fcgi_app.NewGetFCGIAppsOK().WithPayload(r) +} + +func (g GetFCGIAppsHandlerImpl) getFCGIApplications(params fcgi_app.GetFCGIAppsParams, t string) (int64, models.FCGIApps, error) { + configuration, err := g.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredFCGIApplications(t) + } + return configuration.GetFCGIApplications(t) +} + +type ReplaceFCGIAppHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (r ReplaceFCGIAppHandlerImpl) Handle(params fcgi_app.ReplaceFCGIAppParams, _ any) middleware.Responder { + var t string + var v int64 + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + code := misc.ErrHTTPBadRequest + + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: &code, + } + + return fcgi_app.NewReplaceFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + params.Data.Name = params.Name + + var err error + if err = r.editFCGIApplication(params, t, v); err != nil { + e := misc.HandleError(err) + + return fcgi_app.NewReplaceFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = r.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + + return fcgi_app.NewReplaceFCGIAppDefault(int(*e.Code)).WithPayload(e) + } + + return fcgi_app.NewReplaceFCGIAppOK().WithPayload(params.Data) + } + + return fcgi_app.NewReplaceFCGIAppAccepted().WithReloadID(r.ReloadAgent.Reload()).WithPayload(params.Data) + } + + return fcgi_app.NewReplaceFCGIAppAccepted().WithPayload(params.Data) +} + +func (r ReplaceFCGIAppHandlerImpl) editFCGIApplication(params fcgi_app.ReplaceFCGIAppParams, t string, v int64) error { + configuration, err := r.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredFCGIApplication(params.Name, params.Data, t, v) + } + return configuration.EditFCGIApplication(params.Name, params.Data, t, v) +} diff --git a/handlers/filter.go b/handlers/filter.go index 7dc730c7..576d8d12 100644 --- a/handlers/filter.go +++ b/handlers/filter.go @@ -17,43 +17,51 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/filter" - "github.com/haproxytech/models" ) -//CreateFilterHandlerImpl implementation of the CreateFilterHandler interface using client-native client +// CreateFilterHandlerImpl implementation of the CreateFilterHandler interface using client-native client type CreateFilterHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteFilterHandlerImpl implementation of the DeleteFilterHandler interface using client-native client +// DeleteFilterHandlerImpl implementation of the DeleteFilterHandler interface using client-native client type DeleteFilterHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetFilterHandlerImpl implementation of the GetFilterHandler interface using client-native client +// GetFilterHandlerImpl implementation of the GetFilterHandler interface using client-native client type GetFilterHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetFiltersHandlerImpl implementation of the GetFiltersHandler interface using client-native client -type GetFiltersHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllFilterHandlerImpl implementation of the GetAllFilterHandler interface using client-native client +type GetAllFilterHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceFilterHandlerImpl implementation of the ReplaceFilterHandler interface using client-native client +// ReplaceFilterHandlerImpl implementation of the ReplaceFilterHandler interface using client-native client type ReplaceFilterHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllFilterHandlerImpl implementation of the ReplaceAllFilterHandler interface using client-native client +type ReplaceAllFilterHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateFilterHandlerImpl) Handle(params filter.CreateFilterParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateFilterHandlerImpl) Handle(parentType cnconstants.CnParentType, params filter.CreateFilterBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,31 +78,37 @@ func (h *CreateFilterHandlerImpl) Handle(params filter.CreateFilterParams, princ Message: &msg, Code: &c, } - return filter.NewCreateFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewCreateFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return filter.NewCreateFilterBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateFilter(params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.CreateFilter(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return filter.NewCreateFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewCreateFilterBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return filter.NewCreateFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewCreateFilterBackendDefault(int(*e.Code)).WithPayload(e) } - return filter.NewCreateFilterCreated().WithPayload(params.Data) + return filter.NewCreateFilterBackendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return filter.NewCreateFilterAccepted().WithReloadID(rID).WithPayload(params.Data) + return filter.NewCreateFilterBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return filter.NewCreateFilterAccepted().WithPayload(params.Data) + return filter.NewCreateFilterBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteFilterHandlerImpl) Handle(params filter.DeleteFilterParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteFilterHandlerImpl) Handle(parentType cnconstants.CnParentType, params filter.DeleteFilterBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -111,61 +125,82 @@ func (h *DeleteFilterHandlerImpl) Handle(params filter.DeleteFilterParams, princ Message: &msg, Code: &c, } - return filter.NewDeleteFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewDeleteFilterBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteFilter(params.ID, params.ParentType, params.ParentName, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return filter.NewDeleteFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewDeleteFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteFilter(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return filter.NewDeleteFilterBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return filter.NewDeleteFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewDeleteFilterBackendDefault(int(*e.Code)).WithPayload(e) } - return filter.NewDeleteFilterNoContent() + return filter.NewDeleteFilterBackendNoContent() } rID := h.ReloadAgent.Reload() - return filter.NewDeleteFilterAccepted().WithReloadID(rID) + return filter.NewDeleteFilterBackendAccepted().WithReloadID(rID) } - return filter.NewDeleteFilterAccepted() + return filter.NewDeleteFilterBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetFilterHandlerImpl) Handle(params filter.GetFilterParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetFilterHandlerImpl) Handle(parentType cnconstants.CnParentType, params filter.GetFilterBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, f, err := h.Client.Configuration.GetFilter(params.ID, params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return filter.NewGetFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, f, err := configuration.GetFilter(params.Index, string(parentType), params.ParentName, t) if err != nil { e := misc.HandleError(err) - return filter.NewGetFilterDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return filter.NewGetFilterBackendDefault(int(*e.Code)).WithPayload(e) } - return filter.NewGetFilterOK().WithPayload(&filter.GetFilterOKBody{Version: v, Data: f}).WithConfigurationVersion(v) + return filter.NewGetFilterBackendOK().WithPayload(f) } -//Handle executing the request and returning a response -func (h *GetFiltersHandlerImpl) Handle(params filter.GetFiltersParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllFilterHandlerImpl) Handle(parentType cnconstants.CnParentType, params filter.GetAllFilterBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, fs, err := h.Client.Configuration.GetFilters(params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return filter.NewGetFiltersDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return filter.NewGetAllFilterBackendDefault(int(*e.Code)).WithPayload(e) } - return filter.NewGetFiltersOK().WithPayload(&filter.GetFiltersOKBody{Version: v, Data: fs}).WithConfigurationVersion(v) + + _, fs, err := configuration.GetFilters(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return filter.NewGetAllFilterBackendOK().WithPayload(models.Filters{}) + } + return filter.NewGetAllFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + return filter.NewGetAllFilterBackendOK().WithPayload(fs) } -//Handle executing the request and returning a response -func (h *ReplaceFilterHandlerImpl) Handle(params filter.ReplaceFilterParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceFilterHandlerImpl) Handle(parentType cnconstants.CnParentType, params filter.ReplaceFilterBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -182,25 +217,78 @@ func (h *ReplaceFilterHandlerImpl) Handle(params filter.ReplaceFilterParams, pri Message: &msg, Code: &c, } - return filter.NewReplaceFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewReplaceFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return filter.NewGetFilterBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditFilter(params.ID, params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.EditFilter(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return filter.NewReplaceFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewReplaceFilterBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return filter.NewReplaceFilterDefault(int(*e.Code)).WithPayload(e) + return filter.NewReplaceFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + return filter.NewReplaceFilterBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return filter.NewReplaceFilterBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return filter.NewReplaceFilterBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *ReplaceAllFilterHandlerImpl) Handle(parentType cnconstants.CnParentType, params filter.ReplaceAllFilterBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return filter.NewReplaceAllFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return filter.NewReplaceAllFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceFilters(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return filter.NewReplaceAllFilterBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return filter.NewReplaceAllFilterBackendDefault(int(*e.Code)).WithPayload(e) } - return filter.NewReplaceFilterOK().WithPayload(params.Data) + return filter.NewReplaceAllFilterBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return filter.NewReplaceFilterAccepted().WithReloadID(rID).WithPayload(params.Data) + return filter.NewReplaceAllFilterBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return filter.NewReplaceFilterAccepted().WithPayload(params.Data) + return filter.NewReplaceAllFilterBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/frontend.go b/handlers/frontend.go index 73b05e34..31c93193 100644 --- a/handlers/frontend.go +++ b/handlers/frontend.go @@ -17,43 +17,44 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/frontend" - "github.com/haproxytech/models" ) -//CreateFrontendHandlerImpl implementation of the CreateFrontendHandler interface using client-native client +// CreateFrontendHandlerImpl implementation of the CreateFrontendHandler interface using client-native client type CreateFrontendHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteFrontendHandlerImpl implementation of the DeleteFrontendHandler interface using client-native client +// DeleteFrontendHandlerImpl implementation of the DeleteFrontendHandler interface using client-native client type DeleteFrontendHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetFrontendHandlerImpl implementation of the GetFrontendHandler interface using client-native client +// GetFrontendHandlerImpl implementation of the GetFrontendHandler interface using client-native client type GetFrontendHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetFrontendsHandlerImpl implementation of the GetFrontendsHandler interface using client-native client +// GetFrontendsHandlerImpl implementation of the GetFrontendsHandler interface using client-native client type GetFrontendsHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//ReplaceFrontendHandlerImpl implementation of the ReplaceFrontendHandler interface using client-native client +// ReplaceFrontendHandlerImpl implementation of the ReplaceFrontendHandler interface using client-native client type ReplaceFrontendHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateFrontendHandlerImpl) Handle(params frontend.CreateFrontendParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateFrontendHandlerImpl) Handle(params frontend.CreateFrontendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -73,7 +74,7 @@ func (h *CreateFrontendHandlerImpl) Handle(params frontend.CreateFrontendParams, return frontend.NewCreateFrontendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateFrontend(params.Data, t, v) + err := h.createFrontend(params, t, v) if err != nil { e := misc.HandleError(err) return frontend.NewCreateFrontendDefault(int(*e.Code)).WithPayload(e) @@ -93,8 +94,19 @@ func (h *CreateFrontendHandlerImpl) Handle(params frontend.CreateFrontendParams, return frontend.NewCreateFrontendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteFrontendHandlerImpl) Handle(params frontend.DeleteFrontendParams, principal interface{}) middleware.Responder { +func (h *CreateFrontendHandlerImpl) createFrontend(params frontend.CreateFrontendParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredFrontend(params.Data, t, v) + } + return configuration.CreateFrontend(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeleteFrontendHandlerImpl) Handle(params frontend.DeleteFrontendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -114,7 +126,13 @@ func (h *DeleteFrontendHandlerImpl) Handle(params frontend.DeleteFrontendParams, return frontend.NewDeleteFrontendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteFrontend(params.Name, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return frontend.NewDeleteFrontendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteFrontend(params.Name, t, v) if err != nil { e := misc.HandleError(err) return frontend.NewDeleteFrontendDefault(int(*e.Code)).WithPayload(e) @@ -134,38 +152,60 @@ func (h *DeleteFrontendHandlerImpl) Handle(params frontend.DeleteFrontendParams, return frontend.NewDeleteFrontendAccepted() } -//Handle executing the request and returning a response -func (h *GetFrontendHandlerImpl) Handle(params frontend.GetFrontendParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetFrontendHandlerImpl) Handle(params frontend.GetFrontendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, f, err := h.Client.Configuration.GetFrontend(params.Name, t) + _, f, err := h.getFrontend(params, t) if err != nil { e := misc.HandleError(err) - return frontend.NewGetFrontendDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return frontend.NewGetFrontendDefault(int(*e.Code)).WithPayload(e) + } + return frontend.NewGetFrontendOK().WithPayload(f) +} + +func (h *GetFrontendHandlerImpl) getFrontend(params frontend.GetFrontendParams, t string) (int64, *models.Frontend, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredFrontend(params.Name, t) } - return frontend.NewGetFrontendOK().WithPayload(&frontend.GetFrontendOKBody{Version: v, Data: f}).WithConfigurationVersion(v) + return configuration.GetFrontend(params.Name, t) } -//Handle executing the request and returning a response -func (h *GetFrontendsHandlerImpl) Handle(params frontend.GetFrontendsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetFrontendsHandlerImpl) Handle(params frontend.GetFrontendsParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, fs, err := h.Client.Configuration.GetFrontends(t) + _, fs, err := h.getFrontends(params, t) if err != nil { e := misc.HandleError(err) - return frontend.NewGetFrontendsDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return frontend.NewGetFrontendsDefault(int(*e.Code)).WithPayload(e) } - return frontend.NewGetFrontendsOK().WithPayload(&frontend.GetFrontendsOKBody{Version: v, Data: fs}).WithConfigurationVersion(v) + return frontend.NewGetFrontendsOK().WithPayload(fs) } -//Handle executing the request and returning a response -func (h *ReplaceFrontendHandlerImpl) Handle(params frontend.ReplaceFrontendParams, principal interface{}) middleware.Responder { +func (h *GetFrontendsHandlerImpl) getFrontends(params frontend.GetFrontendsParams, t string) (int64, models.Frontends, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredFrontends(t) + } + return configuration.GetFrontends(t) +} + +// Handle executing the request and returning a response +func (h *ReplaceFrontendHandlerImpl) Handle(params frontend.ReplaceFrontendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -185,19 +225,25 @@ func (h *ReplaceFrontendHandlerImpl) Handle(params frontend.ReplaceFrontendParam return frontend.NewReplaceFrontendDefault(int(*e.Code)).WithPayload(e) } - _, ondisk, err := h.Client.Configuration.GetFrontend(params.Name, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) return frontend.NewReplaceFrontendDefault(int(*e.Code)).WithPayload(e) } - err = h.Client.Configuration.EditFrontend(params.Name, params.Data, t, v) + _, ondisk, err := configuration.GetFrontend(params.Name, t) + if err != nil { + e := misc.HandleError(err) + return frontend.NewReplaceFrontendDefault(int(*e.Code)).WithPayload(e) + } + + err = h.editFrontend(params, t, v) if err != nil { e := misc.HandleError(err) return frontend.NewReplaceFrontendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { - reload := changeThroughRuntimeAPI(*params.Data, *ondisk, "", "", h.Client) + reload := changeThroughRuntimeAPI(*params.Data, *ondisk, "", h.Client) if reload { if *params.ForceReload { err := h.ReloadAgent.ForceReload() @@ -214,3 +260,14 @@ func (h *ReplaceFrontendHandlerImpl) Handle(params frontend.ReplaceFrontendParam } return frontend.NewReplaceFrontendAccepted().WithPayload(params.Data) } + +func (h *ReplaceFrontendHandlerImpl) editFrontend(params frontend.ReplaceFrontendParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredFrontend(params.Name, params.Data, t, v) + } + return configuration.EditFrontend(params.Name, params.Data, t, v) +} diff --git a/handlers/general_storage.go b/handlers/general_storage.go new file mode 100644 index 00000000..eea32d87 --- /dev/null +++ b/handlers/general_storage.go @@ -0,0 +1,241 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "bufio" + "fmt" + "io" + "os" + "path/filepath" + "strings" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + models "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/storage" +) + +// StorageCreateStorageGeneralFileHandlerImpl implementation of the StorageCreateStorageGeneralFileHandler interface using client-native client +type StorageCreateStorageGeneralFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageCreateStorageGeneralFileHandlerImpl) Handle(params storage.CreateStorageGeneralFileParams, principal any) middleware.Responder { + if params.FileUpload == nil { + e := &models.Error{ + Code: misc.Int64P(400), + Message: misc.StringP("No file_upload form param specified"), + } + return storage.NewReplaceStorageGeneralFileBadRequest().WithPayload(e) + } + + file, ok := params.FileUpload.(*runtime.File) + if !ok { + return storage.NewCreateStorageGeneralFileBadRequest() + } + + gs, err := h.Client.GeneralStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + + filename, size, err := gs.Create(file.Header.Filename, params.FileUpload) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return storage.NewCreateStorageGeneralFileDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + + me := &models.GeneralFile{ + Description: "managed general use file", + File: filename, + StorageName: filepath.Base(filename), + Size: &size, + } + + return storage.NewCreateStorageGeneralFileCreated().WithPayload(me) +} + +// StorageGetAllStorageGeneralFilesHandlerImpl implementation of the StorageGetAllStorageGeneralFilesHandler interface +type StorageGetAllStorageGeneralFilesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *StorageGetAllStorageGeneralFilesHandlerImpl) Handle(params storage.GetAllStorageGeneralFilesParams, principal any) middleware.Responder { + gs, err := h.Client.GeneralStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageGeneralFilesDefault(int(*e.Code)).WithPayload(e) + } + + filenames, err := gs.GetAll() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageGeneralFilesDefault(int(*e.Code)).WithPayload(e) + } + + retFiles := models.GeneralFiles{} + for _, f := range filenames { + retFiles = append(retFiles, &models.GeneralFile{ + Description: "managed general use file", + File: f, + ID: "", + StorageName: filepath.Base(f), + }) + } + + return storage.NewGetAllStorageGeneralFilesOK().WithPayload(retFiles) +} + +// StorageGetOneStorageGeneralFileHandlerImpl implementation of the StorageGetOneStorageGeneralFileHandler interface +type StorageGetOneStorageGeneralFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageGetOneStorageGeneralFileHandlerImpl) Handle(params storage.GetOneStorageGeneralFileParams, principal any) middleware.Responder { + gs, err := h.Client.GeneralStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + + filename, _, err := gs.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + if filename == "" { + return storage.NewGetOneStorageGeneralFileNotFound() + } + f, err := os.Open(filename) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewGetOneStorageGeneralFileOK().WithPayload(f) +} + +// StorageDeleteStorageGeneralFileHandlerImpl implementation of the StorageDeleteStorageGeneralFileHandler interface +type StorageDeleteStorageGeneralFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageDeleteStorageGeneralFileHandlerImpl) Handle(params storage.DeleteStorageGeneralFileParams, principal any) middleware.Responder { + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + + gs, err := h.Client.GeneralStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + + runningConf := strings.NewReader(configuration.Parser().String()) + + filename, _, err := gs.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + + // this is far from perfect but should provide a basic level of protection + scanner := bufio.NewScanner(runningConf) + + lineNr := 0 + + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if strings.Contains(line, filename) && !strings.HasPrefix(line, "#") { + errCode := misc.ErrHTTPConflict + errMsg := fmt.Sprintf("rejecting attempt to delete file %s referenced in haproxy conf at line %d: %s", filename, lineNr-1, line) + e := &models.Error{Code: &errCode, Message: &errMsg} + return storage.NewDeleteStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + lineNr++ + } + + err = gs.Delete(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewDeleteStorageGeneralFileNoContent() +} + +// StorageReplaceStorageGeneralFileHandlerImpl implementation of the StorageReplaceStorageGeneralFileHandler interface +type StorageReplaceStorageGeneralFileHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageReplaceStorageGeneralFileHandlerImpl) Handle(params storage.ReplaceStorageGeneralFileParams, principal any) middleware.Responder { + gs, err := h.Client.GeneralStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + + if params.FileUpload == nil { + e := &models.Error{ + Code: misc.Int64P(400), + Message: misc.StringP("No file_upload form param specified"), + } + return storage.NewReplaceStorageGeneralFileBadRequest().WithPayload(e) + } + + data, err := io.ReadAll(params.FileUpload) + if err != nil { + return storage.NewReplaceStorageGeneralFileBadRequest() + } + _, err = gs.Replace(params.Name, string(data)) + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if skipReload { + return storage.NewReplaceStorageGeneralFileNoContent() + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageGeneralFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewReplaceStorageGeneralFileNoContent() + } + rID := h.ReloadAgent.Reload() + return storage.NewReplaceStorageGeneralFileAccepted().WithReloadID(rID) +} diff --git a/handlers/global.go b/handlers/global.go index ae365d0d..fcd5dca4 100644 --- a/handlers/global.go +++ b/handlers/global.go @@ -17,42 +17,54 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" - "github.com/haproxytech/dataplaneapi/operations/global" - "github.com/haproxytech/models" - + client_native "github.com/haproxytech/client-native/v6" + client_conf "github.com/haproxytech/client-native/v6/configuration" + "github.com/haproxytech/client-native/v6/models" + cn "github.com/haproxytech/dataplaneapi/client-native" "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/global" ) -//GetGlobalHandlerImpl implementation of the GetGlobalHandler interface +// GetGlobalHandlerImpl implementation of the GetGlobalHandler interface type GetGlobalHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } // ReplaceGlobalHandlerImpl implementation of the ReplaceGlobalHandler interface type ReplaceGlobalHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *GetGlobalHandlerImpl) Handle(params global.GetGlobalParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetGlobalHandlerImpl) Handle(params global.GetGlobalParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, data, err := h.Client.Configuration.GetGlobalConfiguration(t) + _, data, err := h.getGlobalConfiguration(params, t) if err != nil { e := misc.HandleError(err) - return global.NewGetGlobalDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return global.NewGetGlobalDefault(int(*e.Code)).WithPayload(e) } - return global.NewGetGlobalOK().WithPayload(&global.GetGlobalOKBody{Version: v, Data: data}).WithConfigurationVersion(v) + return global.NewGetGlobalOK().WithPayload(data) } -//Handle executing the request and returning a response -func (h *ReplaceGlobalHandlerImpl) Handle(params global.ReplaceGlobalParams, principal interface{}) middleware.Responder { +func (h *GetGlobalHandlerImpl) getGlobalConfiguration(params global.GetGlobalParams, t string) (int64, *models.Global, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredGlobalConfiguration(t) + } + return configuration.GetGlobalConfiguration(t) +} + +// Handle executing the request and returning a response +func (h *ReplaceGlobalHandlerImpl) Handle(params global.ReplaceGlobalParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -71,25 +83,59 @@ func (h *ReplaceGlobalHandlerImpl) Handle(params global.ReplaceGlobalParams, pri } return global.NewReplaceGlobalDefault(int(*e.Code)).WithPayload(e) } + // validate constraints that can not be validated by the swagger 2.0 spec. + if err := client_conf.ValidateGlobalSection(params.Data); err != nil { + code := misc.ErrHTTPBadRequest + msg := err.Error() + e := &models.Error{Code: &code, Message: &msg} + return global.NewReplaceGlobalDefault(int(misc.ErrHTTPBadRequest)).WithPayload(e) + } - err := h.Client.Configuration.PushGlobalConfiguration(params.Data, t, v) - + err := h.pushGlobalConfiguration(params, t, v) if err != nil { e := misc.HandleError(err) return global.NewReplaceGlobalDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { + callbackNeeded, reconfigureFunc, err := cn.ReconfigureRuntime(h.Client) + if err != nil { + e := misc.HandleError(err) + return global.NewReplaceGlobalDefault(int(*e.Code)).WithPayload(e) + } + if *params.ForceReload { - err := h.ReloadAgent.ForceReload() + if callbackNeeded { + err = h.ReloadAgent.ForceReloadWithCallback(reconfigureFunc) + } else { + err = h.ReloadAgent.ForceReload() + } + if err != nil { e := misc.HandleError(err) return global.NewReplaceGlobalDefault(int(*e.Code)).WithPayload(e) } return global.NewReplaceGlobalOK().WithPayload(params.Data) } - rID := h.ReloadAgent.Reload() + + var rID string + if callbackNeeded { + rID = h.ReloadAgent.ReloadWithCallback(reconfigureFunc) + } else { + rID = h.ReloadAgent.Reload() + } return global.NewReplaceGlobalAccepted().WithReloadID(rID).WithPayload(params.Data) } return global.NewReplaceGlobalAccepted().WithPayload(params.Data) } + +func (h *ReplaceGlobalHandlerImpl) pushGlobalConfiguration(params global.ReplaceGlobalParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.PushStructuredGlobalConfiguration(params.Data, t, v) + } + return configuration.PushGlobalConfiguration(params.Data, t, v) +} diff --git a/handlers/group.go b/handlers/group.go new file mode 100644 index 00000000..5d150079 --- /dev/null +++ b/handlers/group.go @@ -0,0 +1,277 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/group" +) + +// CreateGroupHandlerImpl implementation of the CreateGroupHandler interface using client-native client +type CreateGroupHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteGroupHandlerImpl implementation of the DeleteGroupHandler interface using client-native client +type DeleteGroupHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetGroupHandlerImpl implementation of the GetGroupHandler interface using client-native client +type GetGroupHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetGroupsHandlerImpl implementation of the GetGroupsHandler interface using client-native client +type GetGroupsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceGroupHandlerImpl implementation of the ReplaceGroupHandler interface using client-native client +type ReplaceGroupHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateGroupHandlerImpl) Handle(params group.CreateGroupParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return group.NewCreateGroupDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return group.NewCreateGroupDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateGroup(params.Userlist, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return group.NewCreateGroupDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return group.NewCreateGroupDefault(int(*e.Code)).WithPayload(e) + } + return group.NewCreateGroupCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return group.NewCreateGroupAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return group.NewCreateGroupAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteGroupHandlerImpl) Handle(params group.DeleteGroupParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return group.NewDeleteGroupDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return group.NewDeleteGroupDefault(int(*e.Code)).WithPayload(e) + } + + _, userlist, err := configuration.GetUserList(params.Userlist, t) + if err != nil { + e := misc.HandleError(err) + return group.NewDeleteGroupDefault(int(*e.Code)).WithPayload(e) + } + if userlist == nil { + return group.NewDeleteGroupNotFound() + } + + err = configuration.DeleteGroup(params.Name, params.Userlist, t, v) + if err != nil { + e := misc.HandleError(err) + return group.NewDeleteGroupDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return group.NewDeleteGroupDefault(int(*e.Code)).WithPayload(e) + } + return group.NewDeleteGroupNoContent() + } + rID := h.ReloadAgent.Reload() + return group.NewDeleteGroupAccepted().WithReloadID(rID) + } + return group.NewDeleteGroupAccepted() +} + +// Handle executing the request and returning a response +func (h *GetGroupHandlerImpl) Handle(params group.GetGroupParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return group.NewGetGroupDefault(int(*e.Code)).WithPayload(e) + } + + _, g, err := configuration.GetGroup(params.Name, params.Userlist, t) + if err != nil { + e := misc.HandleError(err) + return group.NewGetGroupDefault(int(*e.Code)).WithPayload(e) + } + + if g == nil { + return group.NewGetGroupNotFound() + } + + return group.NewGetGroupOK().WithPayload(g) +} + +// Handle executing the request and returning a response +func (h *GetGroupsHandlerImpl) Handle(params group.GetGroupsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return group.NewGetGroupsDefault(int(*e.Code)).WithPayload(e) + } + + _, userlist, err := configuration.GetUserList(params.Userlist, t) + if userlist == nil { + return group.NewGetGroupNotFound() + } + if err != nil { + return group.NewGetGroupNotFound() + } + + _, groups, err := configuration.GetGroups(params.Userlist, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return group.NewGetGroupsOK().WithPayload(models.Groups{}) + } + return group.NewGetGroupsDefault(int(*e.Code)).WithPayload(e) + } + return group.NewGetGroupsOK().WithPayload(groups) +} + +// Handle executing the request and returning a response +func (h *ReplaceGroupHandlerImpl) Handle(params group.ReplaceGroupParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return group.NewReplaceGroupDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return group.NewReplaceGroupDefault(int(*e.Code)).WithPayload(e) + } + + _, userlist, err := configuration.GetUserList(params.Userlist, t) + if userlist == nil { + return group.NewReplaceGroupNotFound() + } + if err != nil { + return group.NewReplaceGroupNotFound() + } + + _, g, err := configuration.GetGroup(params.Name, params.Userlist, t) + if err != nil { + e := misc.HandleError(err) + return group.NewGetGroupDefault(int(*e.Code)).WithPayload(e) + } + if g == nil { + return group.NewReplaceGroupNotFound() + } + + err = configuration.EditGroup(params.Name, params.Userlist, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return group.NewReplaceGroupDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return group.NewReplaceGroupDefault(int(*e.Code)).WithPayload(e) + } + return group.NewReplaceGroupOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return group.NewReplaceGroupAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return group.NewReplaceGroupAccepted().WithPayload(params.Data) +} diff --git a/handlers/health.go b/handlers/health.go new file mode 100644 index 00000000..910a9bd2 --- /dev/null +++ b/handlers/health.go @@ -0,0 +1,29 @@ +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/operations/health" +) + +// GetHaproxyProcessInfoHandlerImpl implementation of the GetHaproxyProcessInfoHandler interface using client-native client +type GetHealthHandlerImpl struct { + HAProxy haproxy.IReloadAgent +} + +func (h *GetHealthHandlerImpl) Handle(health.GetHealthParams, any) middleware.Responder { + data := models.Health{} + status, err := h.HAProxy.Status() + if err == nil { + if status { + data.Haproxy = models.HealthHaproxyUp + } else { + data.Haproxy = models.HealthHaproxyDown + } + } else { + data.Haproxy = models.HealthHaproxyUnknown + } + + return health.NewGetHealthOK().WithPayload(&data) +} diff --git a/handlers/http_after_response_rule.go b/handlers/http_after_response_rule.go new file mode 100644 index 00000000..9a58c44a --- /dev/null +++ b/handlers/http_after_response_rule.go @@ -0,0 +1,269 @@ +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/http_after_response_rule" +) + +type CreateHTTPAfterResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (c CreateHTTPAfterResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_after_response_rule.CreateHTTPAfterResponseRuleBackendParams, _ any) middleware.Responder { + t, v := "", int64(0) + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return http_after_response_rule.NewCreateHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := c.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewCreateHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateHTTPAfterResponseRule(params.Index, string(parentType), params.ParentName, params.Data, t, v); err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewCreateHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = c.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewCreateHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + return http_after_response_rule.NewCreateHTTPAfterResponseRuleBackendCreated().WithPayload(params.Data) + } + + return http_after_response_rule.NewCreateHTTPAfterResponseRuleBackendAccepted().WithReloadID(c.ReloadAgent.Reload()).WithPayload(params.Data) + } + + return http_after_response_rule.NewCreateHTTPAfterResponseRuleBackendAccepted().WithPayload(params.Data) +} + +type DeleteHTTPAfterResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (d DeleteHTTPAfterResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_after_response_rule.DeleteHTTPAfterResponseRuleBackendParams, _ any) middleware.Responder { + t, v := "", int64(0) + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := d.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.DeleteHTTPAfterResponseRule(params.Index, string(parentType), params.ParentName, t, v); err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = d.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + return http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackendNoContent() + } + + return http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackendAccepted().WithReloadID(d.ReloadAgent.Reload()) + } + + return http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackendAccepted() +} + +type GetHTTPAfterResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetHTTPAfterResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_after_response_rule.GetHTTPAfterResponseRuleBackendParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := g.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewGetHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rule, err := configuration.GetHTTPAfterResponseRule(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewGetHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + return http_after_response_rule.NewGetHTTPAfterResponseRuleBackendOK().WithPayload(rule) +} + +type GetAllHTTPAfterResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetAllHTTPAfterResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_after_response_rule.GetAllHTTPAfterResponseRuleBackendParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := g.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewGetAllHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetHTTPAfterResponseRules(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewGetAllHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + return http_after_response_rule.NewGetAllHTTPAfterResponseRuleBackendOK().WithPayload(rules) +} + +type ReplaceHTTPAfterResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (r ReplaceHTTPAfterResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendParams, _ any) middleware.Responder { + t, v := "", int64(0) + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := r.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.EditHTTPAfterResponseRule(params.Index, string(parentType), params.ParentName, params.Data, t, v); err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = r.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + return http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackendOK().WithPayload(params.Data) + } + + return http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackendAccepted().WithReloadID(r.ReloadAgent.Reload()).WithPayload(params.Data) + } + + return http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackendAccepted().WithPayload(params.Data) +} + +type ReplaceAllHTTPAfterResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *ReplaceAllHTTPAfterResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceHTTPAfterResponseRules(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackendAccepted().WithPayload(params.Data) +} diff --git a/handlers/http_check.go b/handlers/http_check.go new file mode 100644 index 00000000..76477ca8 --- /dev/null +++ b/handlers/http_check.go @@ -0,0 +1,295 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/http_check" +) + +// CreateHTTPCheckHandlerImpl implementation of the CreateHTTPCheckHandler interface using client-native client +type CreateHTTPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteHTTPCheckHandlerImpl implementation of the DeleteHTTPCheckHandler interface using client-native client +type DeleteHTTPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetHTTPCheckHandlerImpl implementation of the GetHTTPCheckHandler interface using client-native client +type GetHTTPCheckHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetAllHTTPCheckHandlerImpl implementation of the GetHTTPChecksHandler interface using client-native client +type GetAllHTTPCheckHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceHTTPCheckHandlerImpl implementation of the ReplaceHTTPCheckHandler interface using client-native client +type ReplaceHTTPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllHTTPCheckHandlerImpl implementation of the ReplaceHTTPChecksHandler interface using client-native client +type ReplaceAllHTTPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateHTTPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_check.CreateHTTPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_check.NewCreateHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_check.NewCreateHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateHTTPCheck(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_check.NewCreateHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_check.NewCreateHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_check.NewCreateHTTPCheckBackendCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_check.NewCreateHTTPCheckBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_check.NewCreateHTTPCheckBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteHTTPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_check.DeleteHTTPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_check.NewDeleteHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_check.NewDeleteHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteHTTPCheck(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return http_check.NewDeleteHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_check.NewDeleteHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_check.NewDeleteHTTPCheckBackendNoContent() + } + rID := h.ReloadAgent.Reload() + return http_check.NewDeleteHTTPCheckBackendAccepted().WithReloadID(rID) + } + return http_check.NewDeleteHTTPCheckBackendAccepted() +} + +// Handle executing the request and returning a response +func (h *GetHTTPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_check.GetHTTPCheckBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_check.NewGetHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rule, err := configuration.GetHTTPCheck(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return http_check.NewGetHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_check.NewGetHTTPCheckBackendOK().WithPayload(rule) +} + +// Handle executing the request and returning a response +func (h *GetAllHTTPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_check.GetAllHTTPCheckBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_check.NewGetAllHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetHTTPChecks(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return http_check.NewGetAllHTTPCheckBackendOK().WithPayload(models.HTTPChecks{}) + } + return http_check.NewGetAllHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_check.NewGetAllHTTPCheckBackendOK().WithPayload(rules) +} + +// Handle executing the request and returning a response +func (h *ReplaceHTTPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_check.ReplaceHTTPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_check.NewReplaceHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_check.NewReplaceHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditHTTPCheck(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_check.NewReplaceHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_check.NewReplaceHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_check.NewReplaceHTTPCheckBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_check.NewReplaceHTTPCheckBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_check.NewReplaceHTTPCheckBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *ReplaceAllHTTPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_check.ReplaceAllHTTPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_check.NewReplaceAllHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_check.NewReplaceAllHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceHTTPChecks(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_check.NewReplaceAllHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_check.NewReplaceAllHTTPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_check.NewReplaceAllHTTPCheckBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_check.NewReplaceAllHTTPCheckBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_check.NewReplaceAllHTTPCheckBackendAccepted().WithPayload(params.Data) +} diff --git a/handlers/http_error_rule.go b/handlers/http_error_rule.go new file mode 100644 index 00000000..ffa0015f --- /dev/null +++ b/handlers/http_error_rule.go @@ -0,0 +1,294 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/http_error_rule" +) + +// CreateHTTPErrorRuleHandlerImpl implementation of the CreateHTTPErrorRuleHandler interface using client-native client +type CreateHTTPErrorRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteHTTPErrorRuleHandlerImpl implementation of the DeleteHTTPErrorRuleHandler interface using client-native client +type DeleteHTTPErrorRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetHTTPErrorRuleHandlerImpl implementation of the GetHTTPErrorRuleHandler interface using client-native client +type GetHTTPErrorRuleHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetAllHTTPErrorRuleHandlerImpl implementation of the GetHTTPErrorRulesHandler interface using client-native client +type GetAllHTTPErrorRuleHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceHTTPErrorRuleHandlerImpl implementation of the ReplaceHTTPErrorRuleHandler interface using client-native client +type ReplaceHTTPErrorRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllHTTPErrorRuleHandlerImpl implementation of the ReplaceHTTPErrorRulesHandler interface using client-native client +type ReplaceAllHTTPErrorRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateHTTPErrorRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_error_rule.CreateHTTPErrorRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_error_rule.NewCreateHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewCreateHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateHTTPErrorRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewCreateHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewCreateHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_error_rule.NewCreateHTTPErrorRuleBackendCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_error_rule.NewCreateHTTPErrorRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_error_rule.NewCreateHTTPErrorRuleBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteHTTPErrorRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_error_rule.DeleteHTTPErrorRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_error_rule.NewDeleteHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewDeleteHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteHTTPErrorRule(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewDeleteHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewDeleteHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_error_rule.NewDeleteHTTPErrorRuleBackendNoContent() + } + rID := h.ReloadAgent.Reload() + return http_error_rule.NewDeleteHTTPErrorRuleBackendAccepted().WithReloadID(rID) + } + return http_error_rule.NewDeleteHTTPErrorRuleBackendAccepted() +} + +// Handle executing the request and returning a response +func (h *GetHTTPErrorRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_error_rule.GetHTTPErrorRuleBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewCreateHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rule, err := configuration.GetHTTPErrorRule(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewGetHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_error_rule.NewGetHTTPErrorRuleBackendOK().WithPayload(rule) +} + +// Handle executing the request and returning a response +func (h *GetAllHTTPErrorRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_error_rule.GetAllHTTPErrorRuleBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewGetAllHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetHTTPErrorRules(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return http_error_rule.NewGetAllHTTPErrorRuleBackendOK().WithPayload(models.HTTPErrorRules{}) + } + return http_error_rule.NewGetAllHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_error_rule.NewGetAllHTTPErrorRuleBackendOK().WithPayload(rules) +} + +// Handle executing the request and returning a response +func (h *ReplaceHTTPErrorRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_error_rule.ReplaceHTTPErrorRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_error_rule.NewReplaceHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewReplaceHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditHTTPErrorRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewReplaceHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewReplaceHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_error_rule.NewReplaceHTTPErrorRuleBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_error_rule.NewReplaceHTTPErrorRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_error_rule.NewReplaceHTTPErrorRuleBackendAccepted().WithPayload(params.Data) +} + +func (h *ReplaceAllHTTPErrorRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_error_rule.ReplaceAllHTTPErrorRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_error_rule.NewReplaceAllHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewReplaceAllHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.ReplaceHTTPErrorRules(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewReplaceAllHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_error_rule.NewReplaceAllHTTPErrorRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_error_rule.NewReplaceAllHTTPErrorRuleBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_error_rule.NewReplaceAllHTTPErrorRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_error_rule.NewReplaceAllHTTPErrorRuleBackendAccepted().WithPayload(params.Data) +} diff --git a/handlers/http_errors.go b/handlers/http_errors.go new file mode 100644 index 00000000..54879cf5 --- /dev/null +++ b/handlers/http_errors.go @@ -0,0 +1,228 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/http_errors" +) + +// CreateHTTPErrorsSectionHandlerImpl implementation of the CreateHTTPErrorsSectionHandler interface using client-native client +type CreateHTTPErrorsSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteHTTPErrorsSectionHandlerImpl implementation of the DeleteHTTPErrorsSectionHandler interface using client-native client +type DeleteHTTPErrorsSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetHTTPErrorsSectionHandlerImpl implementation of the GetHTTPErrorsSectionHandler interface using client-native client +type GetHTTPErrorsSectionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetHTTPErrorsSectionsHandlerImpl implementation of the GetHTTPErrorsSectionsHandler interface using client-native client +type GetHTTPErrorsSectionsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceHTTPErrorsSectionHandlerImpl implementation of the ReplaceHTTPErrorsSectionHandler interface using client-native client +type ReplaceHTTPErrorsSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateHTTPErrorsSectionHandlerImpl) Handle(params http_errors.CreateHTTPErrorsSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_errors.NewCreateHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_errors.NewCreateHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateHTTPErrorsSection(params.Data, t, v); err != nil { + e := misc.HandleError(err) + return http_errors.NewCreateHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_errors.NewCreateHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + return http_errors.NewCreateHTTPErrorsSectionCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_errors.NewCreateHTTPErrorsSectionAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return http_errors.NewCreateHTTPErrorsSectionAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteHTTPErrorsSectionHandlerImpl) Handle(params http_errors.DeleteHTTPErrorsSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_errors.NewDeleteHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_errors.NewDeleteHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteHTTPErrorsSection(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return http_errors.NewDeleteHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_errors.NewDeleteHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + return http_errors.NewDeleteHTTPErrorsSectionNoContent() + } + rID := h.ReloadAgent.Reload() + return http_errors.NewDeleteHTTPErrorsSectionAccepted().WithReloadID(rID) + } + + return http_errors.NewDeleteHTTPErrorsSectionAccepted() +} + +// Handle executing the request and returning a response +func (h *GetHTTPErrorsSectionHandlerImpl) Handle(params http_errors.GetHTTPErrorsSectionParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_errors.NewGetHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + _, ms, err := configuration.GetHTTPErrorsSection(params.Name, t) + if err != nil { + e := misc.HandleError(err) + return http_errors.NewGetHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + return http_errors.NewGetHTTPErrorsSectionOK().WithPayload(ms) +} + +// Handle executing the request and returning a response +func (h *GetHTTPErrorsSectionsHandlerImpl) Handle(params http_errors.GetHTTPErrorsSectionsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_errors.NewGetHTTPErrorsSectionsDefault(int(*e.Code)).WithPayload(e) + } + + _, ms, err := configuration.GetHTTPErrorsSections(t) + if err != nil { + e := misc.HandleError(err) + return http_errors.NewGetHTTPErrorsSectionsDefault(int(*e.Code)).WithPayload(e) + } + + return http_errors.NewGetHTTPErrorsSectionsOK().WithPayload(ms) +} + +func (h *ReplaceHTTPErrorsSectionHandlerImpl) Handle(params http_errors.ReplaceHTTPErrorsSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_errors.NewReplaceHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_errors.NewReplaceHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditHTTPErrorsSection(params.Name, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_errors.NewReplaceHTTPErrorsSectionDefault(int(*e.Code)).WithPayload(e) + } + + return http_errors.NewReplaceHTTPErrorsSectionOK().WithPayload(params.Data) +} diff --git a/handlers/http_request_rule.go b/handlers/http_request_rule.go index 59ae9f07..4e378f8e 100644 --- a/handlers/http_request_rule.go +++ b/handlers/http_request_rule.go @@ -17,43 +17,51 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/http_request_rule" - "github.com/haproxytech/models" ) -//CreateHTTPRequestRuleHandlerImpl implementation of the CreateHTTPRequestRuleHandler interface using client-native client +// CreateHTTPRequestRuleHandlerImpl implementation of the CreateHTTPRequestRuleHandler interface using client-native client type CreateHTTPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteHTTPRequestRuleHandlerImpl implementation of the DeleteHTTPRequestRuleHandler interface using client-native client +// DeleteHTTPRequestRuleHandlerImpl implementation of the DeleteHTTPRequestRuleHandler interface using client-native client type DeleteHTTPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetHTTPRequestRuleHandlerImpl implementation of the GetHTTPRequestRuleHandler interface using client-native client +// GetHTTPRequestRuleHandlerImpl implementation of the GetHTTPRequestRuleHandler interface using client-native client type GetHTTPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetHTTPRequestRulesHandlerImpl implementation of the GetHTTPRequestRulesHandler interface using client-native client -type GetHTTPRequestRulesHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllHTTPRequestRuleHandlerImpl implementation of the GetHTTPRequestRulesHandler interface using client-native client +type GetAllHTTPRequestRuleHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceHTTPRequestRuleHandlerImpl implementation of the ReplaceHTTPRequestRuleHandler interface using client-native client +// ReplaceHTTPRequestRuleHandlerImpl implementation of the ReplaceHTTPRequestRuleHandler interface using client-native client type ReplaceHTTPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllHTTPRequestRuleHandlerImpl implementation of the ReplaceHTTPRequestRulesHandler interface using client-native client +type ReplaceAllHTTPRequestRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.CreateHTTPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateHTTPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_request_rule.CreateHTTPRequestRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,13 +78,19 @@ func (h *CreateHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.Creat Message: &msg, Code: &c, } - return http_request_rule.NewCreateHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewCreateHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_request_rule.NewCreateHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateHTTPRequestRule(params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.CreateHTTPRequestRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return http_request_rule.NewCreateHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewCreateHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -84,18 +98,18 @@ func (h *CreateHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.Creat err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return http_request_rule.NewCreateHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewCreateHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_request_rule.NewCreateHTTPRequestRuleCreated().WithPayload(params.Data) + return http_request_rule.NewCreateHTTPRequestRuleBackendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return http_request_rule.NewCreateHTTPRequestRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return http_request_rule.NewCreateHTTPRequestRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return http_request_rule.NewCreateHTTPRequestRuleAccepted().WithPayload(params.Data) + return http_request_rule.NewCreateHTTPRequestRuleBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.DeleteHTTPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteHTTPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_request_rule.DeleteHTTPRequestRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -112,61 +126,82 @@ func (h *DeleteHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.Delet Message: &msg, Code: &c, } - return http_request_rule.NewDeleteHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewDeleteHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteHTTPRequestRule(params.ID, params.ParentType, params.ParentName, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return http_request_rule.NewDeleteHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewDeleteHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteHTTPRequestRule(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return http_request_rule.NewDeleteHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return http_request_rule.NewDeleteHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewDeleteHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_request_rule.NewDeleteHTTPRequestRuleNoContent() + return http_request_rule.NewDeleteHTTPRequestRuleBackendNoContent() } rID := h.ReloadAgent.Reload() - return http_request_rule.NewDeleteHTTPRequestRuleAccepted().WithReloadID(rID) + return http_request_rule.NewDeleteHTTPRequestRuleBackendAccepted().WithReloadID(rID) } - return http_request_rule.NewDeleteHTTPRequestRuleAccepted() + return http_request_rule.NewDeleteHTTPRequestRuleBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.GetHTTPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetHTTPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_request_rule.GetHTTPRequestRuleBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rule, err := h.Client.Configuration.GetHTTPRequestRule(params.ID, params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_request_rule.NewGetHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rule, err := configuration.GetHTTPRequestRule(params.Index, string(parentType), params.ParentName, t) if err != nil { e := misc.HandleError(err) - return http_request_rule.NewGetHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return http_request_rule.NewGetHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_request_rule.NewGetHTTPRequestRuleOK().WithPayload(&http_request_rule.GetHTTPRequestRuleOKBody{Version: v, Data: rule}).WithConfigurationVersion(v) + return http_request_rule.NewGetHTTPRequestRuleBackendOK().WithPayload(rule) } -//Handle executing the request and returning a response -func (h *GetHTTPRequestRulesHandlerImpl) Handle(params http_request_rule.GetHTTPRequestRulesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllHTTPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_request_rule.GetAllHTTPRequestRuleBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rules, err := h.Client.Configuration.GetHTTPRequestRules(params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return http_request_rule.NewGetHTTPRequestRulesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return http_request_rule.NewGetHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_request_rule.NewGetHTTPRequestRulesOK().WithPayload(&http_request_rule.GetHTTPRequestRulesOKBody{Version: v, Data: rules}).WithConfigurationVersion(v) + + _, rules, err := configuration.GetHTTPRequestRules(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return http_request_rule.NewGetAllHTTPRequestRuleBackendOK().WithPayload(models.HTTPRequestRules{}) + } + return http_request_rule.NewGetAllHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_request_rule.NewGetAllHTTPRequestRuleBackendOK().WithPayload(rules) } -//Handle executing the request and returning a response -func (h *ReplaceHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.ReplaceHTTPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceHTTPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_request_rule.ReplaceHTTPRequestRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -183,25 +218,78 @@ func (h *ReplaceHTTPRequestRuleHandlerImpl) Handle(params http_request_rule.Repl Message: &msg, Code: &c, } - return http_request_rule.NewReplaceHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewReplaceHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_request_rule.NewReplaceHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditHTTPRequestRule(params.ID, params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.EditHTTPRequestRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return http_request_rule.NewReplaceHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewReplaceHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return http_request_rule.NewReplaceHTTPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return http_request_rule.NewReplaceHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_request_rule.NewReplaceHTTPRequestRuleBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_request_rule.NewReplaceHTTPRequestRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_request_rule.NewReplaceHTTPRequestRuleBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *ReplaceAllHTTPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_request_rule.ReplaceAllHTTPRequestRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_request_rule.NewReplaceAllHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_request_rule.NewReplaceAllHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceHTTPRequestRules(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_request_rule.NewReplaceAllHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_request_rule.NewReplaceAllHTTPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_request_rule.NewReplaceHTTPRequestRuleOK().WithPayload(params.Data) + return http_request_rule.NewReplaceAllHTTPRequestRuleBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return http_request_rule.NewReplaceHTTPRequestRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return http_request_rule.NewReplaceAllHTTPRequestRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return http_request_rule.NewReplaceHTTPRequestRuleAccepted().WithPayload(params.Data) + return http_request_rule.NewReplaceAllHTTPRequestRuleBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/http_response_rule.go b/handlers/http_response_rule.go index f9174faa..b244a7bd 100644 --- a/handlers/http_response_rule.go +++ b/handlers/http_response_rule.go @@ -17,43 +17,51 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/http_response_rule" - "github.com/haproxytech/models" ) -//CreateHTTPResponseRuleHandlerImpl implementation of the CreateHTTPResponseRuleHandler interface using client-native client +// CreateHTTPResponseRuleHandlerImpl implementation of the CreateHTTPResponseRuleHandler interface using client-native client type CreateHTTPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteHTTPResponseRuleHandlerImpl implementation of the DeleteHTTPResponseRuleHandler interface using client-native client +// DeleteHTTPResponseRuleHandlerImpl implementation of the DeleteHTTPResponseRuleHandler interface using client-native client type DeleteHTTPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetHTTPResponseRuleHandlerImpl implementation of the GetHTTPResponseRuleHandler interface using client-native client +// GetHTTPResponseRuleHandlerImpl implementation of the GetHTTPResponseRuleHandler interface using client-native client type GetHTTPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetHTTPResponseRulesHandlerImpl implementation of the GetHTTPResponseRulesHandler interface using client-native client -type GetHTTPResponseRulesHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllHTTPResponseRuleHandlerImpl implementation of the GetHTTPResponseRulesHandler interface using client-native client +type GetAllHTTPResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceHTTPResponseRuleHandlerImpl implementation of the ReplaceHTTPResponseRuleHandler interface using client-native client +// ReplaceHTTPResponseRuleHandlerImpl implementation of the ReplaceHTTPResponseRuleHandler interface using client-native client type ReplaceHTTPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllHTTPResponseRuleHandlerImpl implementation of the ReplaceHTTPResponseRulesHandler interface using client-native client +type ReplaceAllHTTPResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.CreateHTTPResponseRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateHTTPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_response_rule.CreateHTTPResponseRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,13 +78,19 @@ func (h *CreateHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.Cre Message: &msg, Code: &c, } - return http_response_rule.NewCreateHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewCreateHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_response_rule.NewCreateHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateHTTPResponseRule(params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.CreateHTTPResponseRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return http_response_rule.NewCreateHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewCreateHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -84,18 +98,18 @@ func (h *CreateHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.Cre err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return http_response_rule.NewCreateHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewCreateHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_response_rule.NewCreateHTTPResponseRuleCreated().WithPayload(params.Data) + return http_response_rule.NewCreateHTTPResponseRuleBackendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return http_response_rule.NewCreateHTTPResponseRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return http_response_rule.NewCreateHTTPResponseRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return http_response_rule.NewCreateHTTPResponseRuleAccepted().WithPayload(params.Data) + return http_response_rule.NewCreateHTTPResponseRuleBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.DeleteHTTPResponseRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteHTTPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_response_rule.DeleteHTTPResponseRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -112,61 +126,82 @@ func (h *DeleteHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.Del Message: &msg, Code: &c, } - return http_response_rule.NewDeleteHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewDeleteHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteHTTPResponseRule(params.ID, params.ParentType, params.ParentName, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return http_response_rule.NewDeleteHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewDeleteHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteHTTPResponseRule(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return http_response_rule.NewDeleteHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return http_response_rule.NewDeleteHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewDeleteHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_response_rule.NewDeleteHTTPResponseRuleNoContent() + return http_response_rule.NewDeleteHTTPResponseRuleBackendNoContent() } rID := h.ReloadAgent.Reload() - return http_response_rule.NewDeleteHTTPResponseRuleAccepted().WithReloadID(rID) + return http_response_rule.NewDeleteHTTPResponseRuleBackendAccepted().WithReloadID(rID) } - return http_response_rule.NewDeleteHTTPResponseRuleAccepted() + return http_response_rule.NewDeleteHTTPResponseRuleBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.GetHTTPResponseRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetHTTPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_response_rule.GetHTTPResponseRuleBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rule, err := h.Client.Configuration.GetHTTPResponseRule(params.ID, params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_response_rule.NewCreateHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rule, err := configuration.GetHTTPResponseRule(params.Index, string(parentType), params.ParentName, t) if err != nil { e := misc.HandleError(err) - return http_response_rule.NewGetHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return http_response_rule.NewGetHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_response_rule.NewGetHTTPResponseRuleOK().WithPayload(&http_response_rule.GetHTTPResponseRuleOKBody{Version: v, Data: rule}).WithConfigurationVersion(v) + return http_response_rule.NewGetHTTPResponseRuleBackendOK().WithPayload(rule) } -//Handle executing the request and returning a response -func (h *GetHTTPResponseRulesHandlerImpl) Handle(params http_response_rule.GetHTTPResponseRulesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllHTTPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_response_rule.GetAllHTTPResponseRuleBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rules, err := h.Client.Configuration.GetHTTPResponseRules(params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return http_response_rule.NewGetHTTPResponseRulesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return http_response_rule.NewGetHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_response_rule.NewGetHTTPResponseRulesOK().WithPayload(&http_response_rule.GetHTTPResponseRulesOKBody{Version: v, Data: rules}).WithConfigurationVersion(v) + + _, rules, err := configuration.GetHTTPResponseRules(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return http_response_rule.NewGetAllHTTPResponseRuleBackendOK().WithPayload(models.HTTPResponseRules{}) + } + return http_response_rule.NewGetAllHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_response_rule.NewGetAllHTTPResponseRuleBackendOK().WithPayload(rules) } -//Handle executing the request and returning a response -func (h *ReplaceHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.ReplaceHTTPResponseRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceHTTPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_response_rule.ReplaceHTTPResponseRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -183,25 +218,78 @@ func (h *ReplaceHTTPResponseRuleHandlerImpl) Handle(params http_response_rule.Re Message: &msg, Code: &c, } - return http_response_rule.NewReplaceHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewReplaceHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_response_rule.NewReplaceHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditHTTPResponseRule(params.ID, params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.EditHTTPResponseRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return http_response_rule.NewReplaceHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewReplaceHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return http_response_rule.NewReplaceHTTPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return http_response_rule.NewReplaceHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return http_response_rule.NewReplaceHTTPResponseRuleBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return http_response_rule.NewReplaceHTTPResponseRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return http_response_rule.NewReplaceHTTPResponseRuleBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *ReplaceAllHTTPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params http_response_rule.ReplaceAllHTTPResponseRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return http_response_rule.NewReplaceAllHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return http_response_rule.NewReplaceAllHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceHTTPResponseRules(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return http_response_rule.NewReplaceAllHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return http_response_rule.NewReplaceAllHTTPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return http_response_rule.NewReplaceHTTPResponseRuleOK().WithPayload(params.Data) + return http_response_rule.NewReplaceAllHTTPResponseRuleBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return http_response_rule.NewReplaceHTTPResponseRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return http_response_rule.NewReplaceAllHTTPResponseRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return http_response_rule.NewReplaceHTTPResponseRuleAccepted().WithPayload(params.Data) + return http_response_rule.NewReplaceAllHTTPResponseRuleBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/information.go b/handlers/information.go index 7ab460de..723fcf5b 100644 --- a/handlers/information.go +++ b/handlers/information.go @@ -24,27 +24,32 @@ import ( "strings" "time" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" "github.com/shirou/gopsutil/host" "github.com/shirou/gopsutil/mem" "golang.org/x/sys/unix" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - client_native "github.com/haproxytech/client-native" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/information" - "github.com/haproxytech/models" ) -//GetHaproxyProcessInfoHandlerImpl implementation of the GetHaproxyProcessInfoHandler interface using client-native client +// GetHaproxyProcessInfoHandlerImpl implementation of the GetHaproxyProcessInfoHandler interface using client-native client type GetHaproxyProcessInfoHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//Handle executing the request and returning a response -func (h *GetHaproxyProcessInfoHandlerImpl) Handle(params information.GetHaproxyProcessInfoParams, principal interface{}) middleware.Responder { - info, err := h.Client.Runtime.GetInfo() - if err != nil || len(info) == 0 { +// Handle executing the request and returning a response +func (h *GetHaproxyProcessInfoHandlerImpl) Handle(params information.GetHaproxyProcessInfoParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return information.NewGetHaproxyProcessInfoDefault(int(*e.Code)).WithPayload(e) + } + info, err := runtime.GetInfo() + if err != nil { code := misc.ErrHTTPInternalServerError msg := err.Error() e := &models.Error{ @@ -54,25 +59,22 @@ func (h *GetHaproxyProcessInfoHandlerImpl) Handle(params information.GetHaproxyP return information.NewGetHaproxyProcessInfoDefault(int(misc.ErrHTTPInternalServerError)).WithPayload(e) } - data := models.ProcessInfo{} - data.Haproxy = &info[0] - - return information.NewGetHaproxyProcessInfoOK().WithPayload(&data) + return information.NewGetHaproxyProcessInfoOK().WithPayload(&info) } -//GetInfoHandlerImpl implementation of the GetInfoHandler interface +// GetInfoHandlerImpl implementation of the GetInfoHandler interface type GetInfoHandlerImpl struct { - SystemInfo bool BuildTime string Version string + SystemInfo bool } -//Handle executing the request and returning a response -func (h *GetInfoHandlerImpl) Handle(params information.GetInfoParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetInfoHandlerImpl) Handle(params information.GetInfoParams, principal any) middleware.Responder { api := &models.InfoAPI{ Version: h.Version, } - date, err := time.Parse("2006-01-02T15:04:05", h.BuildTime) + date, err := time.Parse("2006-01-02T15:04:05Z", h.BuildTime) if err == nil { api.BuildDate = strfmt.DateTime(date) } else { @@ -141,14 +143,3 @@ func parseCPUModel() string { return "" } - -func cutTrailingBytes(arr []byte) []byte { - r := make([]byte, len(arr)) - for _, b := range arr { - if b == 0 { - continue - } - r = append(r, b) - } - return r -} diff --git a/handlers/log_forward.go b/handlers/log_forward.go new file mode 100644 index 00000000..f66fec4b --- /dev/null +++ b/handlers/log_forward.go @@ -0,0 +1,259 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/log_forward" +) + +// CreateLogForwardHandlerImpl implementation of the CreateLogForwardHandler interface using client-native client +type CreateLogForwardHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteLogForwardHandlerImpl implementation of the DeleteLogForwardHandler interface using client-native client +type DeleteLogForwardHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetLogForwardHandlerImpl implementation of the GetLogForwardHandler interface using client-native client +type GetLogForwardHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetLogForwardsHandlerImpl implementation of the GetLogForwardsHandler interface using client-native client +type GetLogForwardsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceLogForwardHandlerImpl implementation of the ReplaceLogForwardHandler interface using client-native client +type ReplaceLogForwardHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateLogForwardHandlerImpl) Handle(params log_forward.CreateLogForwardParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return log_forward.NewCreateLogForwardDefault(int(*e.Code)).WithPayload(e) + } + + err := h.createLogForward(params, t, v) + if err != nil { + e := misc.HandleError(err) + return log_forward.NewCreateLogForwardDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return log_forward.NewCreateLogForwardDefault(int(*e.Code)).WithPayload(e) + } + return log_forward.NewCreateLogForwardCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return log_forward.NewCreateLogForwardAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return log_forward.NewCreateLogForwardAccepted().WithPayload(params.Data) +} + +func (h *CreateLogForwardHandlerImpl) createLogForward(params log_forward.CreateLogForwardParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredLogForward(params.Data, t, v) + } + return configuration.CreateLogForward(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeleteLogForwardHandlerImpl) Handle(params log_forward.DeleteLogForwardParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return log_forward.NewDeleteLogForwardDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_forward.NewDeleteLogForwardDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteLogForward(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return log_forward.NewDeleteLogForwardDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return log_forward.NewDeleteLogForwardDefault(int(*e.Code)).WithPayload(e) + } + return log_forward.NewDeleteLogForwardNoContent() + } + rID := h.ReloadAgent.Reload() + return log_forward.NewDeleteLogForwardAccepted().WithReloadID(rID) + } + return log_forward.NewDeleteLogForwardAccepted() +} + +// Handle executing the request and returning a response +func (h *GetLogForwardHandlerImpl) Handle(params log_forward.GetLogForwardParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, bck, err := h.getLogForward(params, t) + if err != nil { + e := misc.HandleError(err) + return log_forward.NewGetLogForwardDefault(int(*e.Code)).WithPayload(e) + } + return log_forward.NewGetLogForwardOK().WithPayload(bck) +} + +func (h *GetLogForwardHandlerImpl) getLogForward(params log_forward.GetLogForwardParams, t string) (int64, *models.LogForward, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredLogForward(params.Name, t) + } + return configuration.GetLogForward(params.Name, t) +} + +// Handle executing the request and returning a response +func (h *GetLogForwardsHandlerImpl) Handle(params log_forward.GetLogForwardsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, bcks, err := h.getLogForwards(params, t) + if err != nil { + e := misc.HandleError(err) + return log_forward.NewGetLogForwardsDefault(int(*e.Code)).WithPayload(e) + } + return log_forward.NewGetLogForwardsOK().WithPayload(bcks) +} + +func (h *GetLogForwardsHandlerImpl) getLogForwards(params log_forward.GetLogForwardsParams, t string) (int64, models.LogForwards, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredLogForwards(t) + } + return configuration.GetLogForwards(t) +} + +// Handle executing the request and returning a response +func (h *ReplaceLogForwardHandlerImpl) Handle(params log_forward.ReplaceLogForwardParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return log_forward.NewReplaceLogForwardDefault(int(*e.Code)).WithPayload(e) + } + + err := h.editLogForward(params, t, v) + if err != nil { + e := misc.HandleError(err) + return log_forward.NewReplaceLogForwardDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return log_forward.NewReplaceLogForwardDefault(int(*e.Code)).WithPayload(e) + } + return log_forward.NewReplaceLogForwardOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return log_forward.NewReplaceLogForwardAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return log_forward.NewReplaceLogForwardAccepted().WithPayload(params.Data) +} + +func (h *ReplaceLogForwardHandlerImpl) editLogForward(params log_forward.ReplaceLogForwardParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredLogForward(params.Name, params.Data, t, v) + } + return configuration.EditLogForward(params.Name, params.Data, t, v) +} diff --git a/handlers/log_profile.go b/handlers/log_profile.go new file mode 100644 index 00000000..f684a1be --- /dev/null +++ b/handlers/log_profile.go @@ -0,0 +1,221 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/log_profile" +) + +type GetLogProfilesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Get all log-profiles +func (h *GetLogProfilesHandlerImpl) Handle(params log_profile.GetLogProfilesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_profile.NewGetLogProfilesDefault(int(*e.Code)).WithPayload(e) + } + + _, profiles, err := configuration.GetLogProfiles(t) + if err != nil { + e := misc.HandleError(err) + return log_profile.NewGetLogProfilesDefault(int(*e.Code)).WithPayload(e) + } + + return log_profile.NewGetLogProfilesOK().WithPayload(profiles) +} + +type GetLogProfileHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Get one log-profile +func (h *GetLogProfileHandlerImpl) Handle(params log_profile.GetLogProfileParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_profile.NewGetLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + _, profile, err := configuration.GetLogProfile(params.Name, t) + if err != nil { + e := misc.HandleError(err) + return log_profile.NewGetLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + return log_profile.NewGetLogProfileOK().WithPayload(profile) +} + +type CreateLogProfileHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *CreateLogProfileHandlerImpl) Handle(params log_profile.CreateLogProfileParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return log_profile.NewCreateLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_profile.NewCreateLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateLogProfile(params.Data, t, v); err != nil { + e := misc.HandleError(err) + return log_profile.NewCreateLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return log_profile.NewCreateLogProfileDefault(int(*e.Code)).WithPayload(e) + } + return log_profile.NewCreateLogProfileCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return log_profile.NewCreateLogProfileAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return log_profile.NewCreateLogProfileAccepted().WithPayload(params.Data) +} + +type EditLogProfileHandler struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *EditLogProfileHandler) Handle(params log_profile.EditLogProfileParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return log_profile.NewEditLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_profile.NewEditLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditLogProfile(params.Name, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return log_profile.NewEditLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + return log_profile.NewEditLogProfileOK().WithPayload(params.Data) +} + +type DeleteLogProfileHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *DeleteLogProfileHandlerImpl) Handle(params log_profile.DeleteLogProfileParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return log_profile.NewDeleteLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_profile.NewDeleteLogProfileDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteLogProfile(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return log_profile.NewDeleteLogProfileDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return log_profile.NewDeleteLogProfileDefault(int(*e.Code)).WithPayload(e) + } + return log_profile.NewDeleteLogProfileNoContent() + } + rID := h.ReloadAgent.Reload() + return log_profile.NewDeleteLogProfileAccepted().WithReloadID(rID) + } + + return log_profile.NewDeleteLogProfileAccepted() +} diff --git a/handlers/log_target.go b/handlers/log_target.go index 85e6db34..e6767a9e 100644 --- a/handlers/log_target.go +++ b/handlers/log_target.go @@ -17,43 +17,51 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/log_target" - "github.com/haproxytech/models" ) -//CreateLogTargetHandlerImpl implementation of the CreateLogTargetHandler interface using client-native client +// CreateLogTargetHandlerImpl implementation of the CreateLogTargetHandler interface using client-native client type CreateLogTargetHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteLogTargetHandlerImpl implementation of the DeleteLogTargetHandler interface using client-native client +// DeleteLogTargetHandlerImpl implementation of the DeleteLogTargetHandler interface using client-native client type DeleteLogTargetHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetLogTargetHandlerImpl implementation of the GetLogTargetHandler interface using client-native client +// GetLogTargetHandlerImpl implementation of the GetLogTargetHandler interface using client-native client type GetLogTargetHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetLogTargetsHandlerImpl implementation of the GetLogTargetsHandler interface using client-native client -type GetLogTargetsHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllLogTargetHandlerImpl implementation of the GetLogTargetsHandler interface using client-native client +type GetAllLogTargetHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceLogTargetHandlerImpl implementation of the ReplaceLogTargetHandler interface using client-native client +// ReplaceLogTargetHandlerImpl implementation of the ReplaceLogTargetHandler interface using client-native client type ReplaceLogTargetHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllLogTargetHandlerImpl implementation of the ReplaceLogTargetsHandler interface using client-native client +type ReplaceAllLogTargetHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateLogTargetHandlerImpl) Handle(params log_target.CreateLogTargetParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateLogTargetHandlerImpl) Handle(parentType cnconstants.CnParentType, params log_target.CreateLogTargetBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,13 +78,19 @@ func (h *CreateLogTargetHandlerImpl) Handle(params log_target.CreateLogTargetPar Message: &msg, Code: &c, } - return log_target.NewCreateLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewCreateLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_target.NewCreateLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateLogTarget(params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.CreateLogTarget(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return log_target.NewCreateLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewCreateLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -84,18 +98,18 @@ func (h *CreateLogTargetHandlerImpl) Handle(params log_target.CreateLogTargetPar err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return log_target.NewCreateLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewCreateLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - return log_target.NewCreateLogTargetCreated().WithPayload(params.Data) + return log_target.NewCreateLogTargetBackendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return log_target.NewCreateLogTargetAccepted().WithReloadID(rID).WithPayload(params.Data) + return log_target.NewCreateLogTargetBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return log_target.NewCreateLogTargetAccepted().WithPayload(params.Data) + return log_target.NewCreateLogTargetBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteLogTargetHandlerImpl) Handle(params log_target.DeleteLogTargetParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteLogTargetHandlerImpl) Handle(parentType cnconstants.CnParentType, params log_target.DeleteLogTargetBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -112,13 +126,19 @@ func (h *DeleteLogTargetHandlerImpl) Handle(params log_target.DeleteLogTargetPar Message: &msg, Code: &c, } - return log_target.NewDeleteLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewDeleteLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_target.NewDeleteLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteLogTarget(params.ID, params.ParentType, params.ParentName, t, v) + err = configuration.DeleteLogTarget(params.Index, string(parentType), params.ParentName, t, v) if err != nil { e := misc.HandleError(err) - return log_target.NewDeleteLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewDeleteLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -126,48 +146,114 @@ func (h *DeleteLogTargetHandlerImpl) Handle(params log_target.DeleteLogTargetPar err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return log_target.NewDeleteLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewDeleteLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - return log_target.NewDeleteLogTargetNoContent() + return log_target.NewDeleteLogTargetBackendNoContent() } rID := h.ReloadAgent.Reload() - return log_target.NewDeleteLogTargetAccepted().WithReloadID(rID) + return log_target.NewDeleteLogTargetBackendAccepted().WithReloadID(rID) } - return log_target.NewDeleteLogTargetAccepted() + return log_target.NewDeleteLogTargetBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetLogTargetHandlerImpl) Handle(params log_target.GetLogTargetParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetLogTargetHandlerImpl) Handle(parentType cnconstants.CnParentType, params log_target.GetLogTargetBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, logTarget, err := h.Client.Configuration.GetLogTarget(params.ID, params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_target.NewGetLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, logTarget, err := configuration.GetLogTarget(params.Index, string(parentType), params.ParentName, t) if err != nil { e := misc.HandleError(err) - return log_target.NewGetLogTargetDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return log_target.NewGetLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - return log_target.NewGetLogTargetOK().WithPayload(&log_target.GetLogTargetOKBody{Version: v, Data: logTarget}).WithConfigurationVersion(v) + return log_target.NewGetLogTargetBackendOK().WithPayload(logTarget) } -//Handle executing the request and returning a response -func (h *GetLogTargetsHandlerImpl) Handle(params log_target.GetLogTargetsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllLogTargetHandlerImpl) Handle(parentType cnconstants.CnParentType, params log_target.GetAllLogTargetBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, logTargets, err := h.Client.Configuration.GetLogTargets(params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_target.NewGetAllLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, logTargets, err := configuration.GetLogTargets(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return log_target.NewGetAllLogTargetBackendOK().WithPayload(models.LogTargets{}) + } + return log_target.NewGetAllLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + return log_target.NewGetAllLogTargetBackendOK().WithPayload(logTargets) +} + +// Handle executing the request and returning a response +func (h *ReplaceLogTargetHandlerImpl) Handle(parentType cnconstants.CnParentType, params log_target.ReplaceLogTargetBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return log_target.NewReplaceLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return log_target.NewReplaceLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditLogTarget(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return log_target.NewGetLogTargetsDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return log_target.NewReplaceLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - return log_target.NewGetLogTargetsOK().WithPayload(&log_target.GetLogTargetsOKBody{Version: v, Data: logTargets}).WithConfigurationVersion(v) + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return log_target.NewReplaceLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + return log_target.NewReplaceLogTargetBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return log_target.NewReplaceLogTargetBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return log_target.NewReplaceLogTargetBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *ReplaceLogTargetHandlerImpl) Handle(params log_target.ReplaceLogTargetParams, principal interface{}) middleware.Responder { +func logTargetParentTypeRequiresParentName(parentType string) bool { + return (parentType == "frontend" || parentType == "backend" || parentType == "peers" || parentType == "log_forward") +} + +// Handle executing the request and returning a response +func (h *ReplaceAllLogTargetHandlerImpl) Handle(parentType cnconstants.CnParentType, params log_target.ReplaceAllLogTargetBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -184,25 +270,32 @@ func (h *ReplaceLogTargetHandlerImpl) Handle(params log_target.ReplaceLogTargetP Message: &msg, Code: &c, } - return log_target.NewReplaceLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewReplaceAllLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditLogTarget(params.ID, params.ParentType, params.ParentName, params.Data, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return log_target.NewReplaceLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewReplaceAllLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } + + err = configuration.ReplaceLogTargets(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return log_target.NewReplaceAllLogTargetBackendDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return log_target.NewReplaceLogTargetDefault(int(*e.Code)).WithPayload(e) + return log_target.NewReplaceAllLogTargetBackendDefault(int(*e.Code)).WithPayload(e) } - return log_target.NewReplaceLogTargetOK().WithPayload(params.Data) + return log_target.NewReplaceAllLogTargetBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return log_target.NewReplaceLogTargetAccepted().WithReloadID(rID).WithPayload(params.Data) + return log_target.NewReplaceAllLogTargetBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return log_target.NewReplaceLogTargetAccepted().WithPayload(params.Data) + return log_target.NewReplaceAllLogTargetBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/mailer_entry.go b/handlers/mailer_entry.go new file mode 100644 index 00000000..2f75df65 --- /dev/null +++ b/handlers/mailer_entry.go @@ -0,0 +1,231 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/mailer_entry" +) + +type CreateMailerEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +type DeleteMailerEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +type GetMailerEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +type GetMailerEntriesHandlerImpl struct { + Client client_native.HAProxyClient +} + +type ReplaceMailerEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateMailerEntryHandlerImpl) Handle(params mailer_entry.CreateMailerEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return mailer_entry.NewCreateMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewCreateMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateMailerEntry(params.MailersSection, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewCreateMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewCreateMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + return mailer_entry.NewCreateMailerEntryCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return mailer_entry.NewCreateMailerEntryAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return mailer_entry.NewCreateMailerEntryAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteMailerEntryHandlerImpl) Handle(params mailer_entry.DeleteMailerEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return mailer_entry.NewDeleteMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewDeleteMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteMailerEntry(params.Name, params.MailersSection, t, v) + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewDeleteMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewDeleteMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + return mailer_entry.NewDeleteMailerEntryNoContent() + } + rID := h.ReloadAgent.Reload() + return mailer_entry.NewDeleteMailerEntryAccepted().WithReloadID(rID) + } + return mailer_entry.NewDeleteMailerEntryAccepted() +} + +// Handle executing the request and returning a response +func (h *GetMailerEntryHandlerImpl) Handle(params mailer_entry.GetMailerEntryParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewGetMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + + _, me, err := configuration.GetMailerEntry(params.Name, params.MailersSection, t) + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewGetMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + return mailer_entry.NewGetMailerEntryOK().WithPayload(me) +} + +// Handle executing the request and returning a response +func (h *GetMailerEntriesHandlerImpl) Handle(params mailer_entry.GetMailerEntriesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewGetMailerEntriesDefault(int(*e.Code)).WithPayload(e) + } + + _, mes, err := configuration.GetMailerEntries(params.MailersSection, t) + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewGetMailerEntriesDefault(int(*e.Code)).WithPayload(e) + } + return mailer_entry.NewGetMailerEntriesOK().WithPayload(mes) +} + +// Handle executing the request and returning a response +func (h *ReplaceMailerEntryHandlerImpl) Handle(params mailer_entry.ReplaceMailerEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return mailer_entry.NewReplaceMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewReplaceMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditMailerEntry(params.Name, params.MailersSection, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewReplaceMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return mailer_entry.NewReplaceMailerEntryDefault(int(*e.Code)).WithPayload(e) + } + return mailer_entry.NewReplaceMailerEntryOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return mailer_entry.NewReplaceMailerEntryAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return mailer_entry.NewReplaceMailerEntryAccepted().WithPayload(params.Data) +} diff --git a/handlers/mailers.go b/handlers/mailers.go new file mode 100644 index 00000000..58584dd8 --- /dev/null +++ b/handlers/mailers.go @@ -0,0 +1,248 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/mailers" +) + +// CreateMailersSectionHandlerImpl implementation of the CreateMailersSectionHandler interface using client-native client +type CreateMailersSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteMailersSectionHandlerImpl implementation of the DeleteMailersSectionHandler interface using client-native client +type DeleteMailersSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetMailersSectionHandlerImpl implementation of the GetMailersSectionHandler interface using client-native client +type GetMailersSectionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetMailersSectionsHandlerImpl implementation of the GetMailersSectionsHandler interface using client-native client +type GetMailersSectionsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// EditMailersSectionHandlerImpl implementation of the EditMailersSectionHandler interface using client-native client +type EditMailersSectionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateMailersSectionHandlerImpl) Handle(params mailers.CreateMailersSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return mailers.NewCreateMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + + if err := h.createMailersSection(params, t, v); err != nil { + e := misc.HandleError(err) + return mailers.NewCreateMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return mailers.NewCreateMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + return mailers.NewCreateMailersSectionCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return mailers.NewCreateMailersSectionAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return mailers.NewCreateMailersSectionAccepted().WithPayload(params.Data) +} + +func (h *CreateMailersSectionHandlerImpl) createMailersSection(params mailers.CreateMailersSectionParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredMailersSection(params.Data, t, v) + } + return configuration.CreateMailersSection(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeleteMailersSectionHandlerImpl) Handle(params mailers.DeleteMailersSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return mailers.NewDeleteMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return mailers.NewDeleteMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteMailersSection(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return mailers.NewDeleteMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return mailers.NewDeleteMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + return mailers.NewDeleteMailersSectionNoContent() + } + rID := h.ReloadAgent.Reload() + return mailers.NewDeleteMailersSectionAccepted().WithReloadID(rID) + } + + return mailers.NewDeleteMailersSectionAccepted() +} + +// Handle executing the request and returning a response +func (h *GetMailersSectionHandlerImpl) Handle(params mailers.GetMailersSectionParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, ms, err := h.getMailersSection(params, t) + if err != nil { + e := misc.HandleError(err) + return mailers.NewGetMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + + return mailers.NewGetMailersSectionOK().WithPayload(ms) +} + +func (h *GetMailersSectionHandlerImpl) getMailersSection(params mailers.GetMailersSectionParams, t string) (int64, *models.MailersSection, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredMailersSection(params.Name, t) + } + return configuration.GetMailersSection(params.Name, t) +} + +// Handle executing the request and returning a response +func (h *GetMailersSectionsHandlerImpl) Handle(params mailers.GetMailersSectionsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, ms, err := h.getMailersSections(params, t) + if err != nil { + e := misc.HandleError(err) + return mailers.NewGetMailersSectionsDefault(int(*e.Code)).WithPayload(e) + } + + return mailers.NewGetMailersSectionsOK().WithPayload(ms) +} + +func (h *GetMailersSectionsHandlerImpl) getMailersSections(params mailers.GetMailersSectionsParams, t string) (int64, models.MailersSections, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredMailersSections(t) + } + return configuration.GetMailersSections(t) +} + +func (h *EditMailersSectionHandlerImpl) Handle(params mailers.EditMailersSectionParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return mailers.NewEditMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + + err := h.editMailersSection(params, t, v) + if err != nil { + e := misc.HandleError(err) + return mailers.NewEditMailersSectionDefault(int(*e.Code)).WithPayload(e) + } + + return mailers.NewEditMailersSectionOK().WithPayload(params.Data) +} + +func (h *EditMailersSectionHandlerImpl) editMailersSection(params mailers.EditMailersSectionParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredMailersSection(params.Name, params.Data, t, v) + } + return configuration.EditMailersSection(params.Name, params.Data, t, v) +} diff --git a/handlers/map.go b/handlers/map.go new file mode 100644 index 00000000..e7b0a8af --- /dev/null +++ b/handlers/map.go @@ -0,0 +1,306 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "path/filepath" + "strings" + + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + config "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/maps" +) + +// GetMapsHandlerImpl implementation of the GetAllRuntimeMapFilesHandler interface using client-native client +type GetMapsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *GetMapsHandlerImpl) Handle(params maps.GetAllRuntimeMapFilesParams, principal any) middleware.Responder { + mapList := []*models.Map{} + + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewShowRuntimeMapDefault(int(*e.Code)).WithPayload(e) + } + + runtimeMaps, err := runtime.ShowMaps() + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewShowRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + + mapsDir, err := runtime.GetMapsDir() + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewShowRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + + for _, m := range runtimeMaps { + if *params.IncludeUnmanaged || strings.HasPrefix(filepath.Dir(m.File), mapsDir) { + if strings.HasPrefix(filepath.Dir(m.File), mapsDir) { + m.StorageName = filepath.Base(m.File) + } + mapList = append(mapList, m) + } + } + return maps.NewGetAllRuntimeMapFilesOK().WithPayload(mapList) +} + +// GetMapHandlerImpl implementation of the MapsGetOneRuntimeMapHandler interface using client-native client +type GetMapHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *GetMapHandlerImpl) Handle(params maps.GetOneRuntimeMapParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewGetOneRuntimeMapDefault(int(*e.Code)).WithPayload(e) + } + + m, err := runtime.GetMap(params.Name) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewGetOneRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + if m == nil { + return maps.NewGetOneRuntimeMapNotFound() + } + return maps.NewGetOneRuntimeMapOK().WithPayload(m) +} + +// ClearMapHandlerImpl implementation of the ClearRuntimeMapHandler interface using client-native client +type ClearMapHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *ClearMapHandlerImpl) Handle(params maps.ClearRuntimeMapParams, principal any) middleware.Responder { + forceDelete := false + if params.ForceDelete != nil { + forceDelete = *params.ForceDelete + } + + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewClearRuntimeMapDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.ClearMap(params.Name, forceDelete) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewClearRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + if *params.ForceSync { + m, err := runtime.GetMap(params.Name) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewClearRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + ms := config.NewMapSync() + _, err = ms.Sync(m, h.Client) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewClearRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + } + return maps.NewClearRuntimeMapNoContent() +} + +// ShowMapHandlerImpl implementation of the ShowMapHandlerImpl interface using client-native client +type ShowMapHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *ShowMapHandlerImpl) Handle(params maps.ShowRuntimeMapParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewShowRuntimeMapDefault(int(*e.Code)).WithPayload(e) + } + m, err := runtime.ShowMapEntries(params.ParentName) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewShowRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + if m == nil { + return maps.NewShowRuntimeMapNotFound() + } + return maps.NewShowRuntimeMapOK().WithPayload(m) +} + +// AddMapEntryHandlerImpl implementation of the AddMapEntryHandler interface using client-native client +type AddMapEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *AddMapEntryHandlerImpl) Handle(params maps.AddMapEntryParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewAddMapEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.AddMapEntry(params.ParentName, params.Data.Key, params.Data.Value) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewAddMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + if *params.ForceSync { + m, err := runtime.GetMap(params.ParentName) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewAddMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + ms := config.NewMapSync() + _, err = ms.Sync(m, h.Client) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewAddMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + } + return maps.NewAddMapEntryCreated().WithPayload(params.Data) +} + +type MapsAddPayloadRuntimeMapHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *MapsAddPayloadRuntimeMapHandlerImpl) Handle(params maps.AddPayloadRuntimeMapParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewAddPayloadRuntimeMapDefault(int(*e.Code)).WithPayload(e) + } + err = runtime.AddMapPayloadVersioned(params.Name, params.Data) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewAddPayloadRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + if *params.ForceSync { + m, err := runtime.GetMap(params.Name) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewAddPayloadRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + ms := config.NewMapSync() + _, err = ms.Sync(m, h.Client) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewAddPayloadRuntimeMapDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + } + return maps.NewAddPayloadRuntimeMapCreated().WithPayload(params.Data) +} + +// GetRuntimeMapEntryHandlerImpl implementation of the GetRuntimeMapEntryHandler interface using client-native client +type GetRuntimeMapEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *GetRuntimeMapEntryHandlerImpl) Handle(params maps.GetRuntimeMapEntryParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewReplaceRuntimeMapEntryDefault(int(*e.Code)).WithPayload(e) + } + m, err := runtime.GetMapEntry(params.ParentName, params.ID) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewGetRuntimeMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + if m == nil { + return maps.NewGetRuntimeMapEntryNotFound() + } + return maps.NewGetRuntimeMapEntryOK().WithPayload(m) +} + +// ReplaceRuntimeMapEntryHandlerImpl implementation of the ReplaceRuntimeMapEntryHandler interface using client-native client +type ReplaceRuntimeMapEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *ReplaceRuntimeMapEntryHandlerImpl) Handle(params maps.ReplaceRuntimeMapEntryParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewReplaceRuntimeMapEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.SetMapEntry(params.ParentName, params.ID, *params.Data.Value) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewGetRuntimeMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + e, err := runtime.GetMapEntry(params.ParentName, params.ID) + if err != nil { + return maps.NewReplaceRuntimeMapEntryNotFound() + } + if *params.ForceSync { + m, err := runtime.GetMap(params.ParentName) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewGetRuntimeMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + ms := config.NewMapSync() + _, err = ms.Sync(m, h.Client) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewGetRuntimeMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + } + return maps.NewGetRuntimeMapEntryOK().WithPayload(e) +} + +// DeleteRuntimeMapEntryHandlerImpl implementation of the DeleteRuntimeMapEntryHandler interface using client-native client +type DeleteRuntimeMapEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *DeleteRuntimeMapEntryHandlerImpl) Handle(params maps.DeleteRuntimeMapEntryParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return maps.NewDeleteRuntimeMapEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.DeleteMapEntry(params.ParentName, params.ID) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewDeleteRuntimeMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + if *params.ForceSync { + m, err := runtime.GetMap(params.ParentName) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewDeleteRuntimeMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + ms := config.NewMapSync() + _, err = ms.Sync(m, h.Client) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return maps.NewDeleteRuntimeMapEntryDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + } + return maps.NewDeleteRuntimeMapEntryNoContent() +} diff --git a/handlers/map_storage.go b/handlers/map_storage.go new file mode 100644 index 00000000..f819fdb1 --- /dev/null +++ b/handlers/map_storage.go @@ -0,0 +1,222 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "bufio" + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + models "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/storage" +) + +// StorageCreateStorageMapFileHandlerImpl implementation of the StorageCreateStorageMapFileHandler interface using client-native client +type StorageCreateStorageMapFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageCreateStorageMapFileHandlerImpl) Handle(params storage.CreateStorageMapFileParams, principal any) middleware.Responder { + file, ok := params.FileUpload.(*runtime.File) + if !ok { + return storage.NewCreateStorageMapFileBadRequest() + } + + st, err := h.Client.MapStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + + filename, size, err := st.Create(file.Header.Filename, params.FileUpload) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return storage.NewCreateStorageMapFileDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + + me := &models.Map{ + Description: "managed but not loaded map file (no runtime ID)", + File: filename, + StorageName: filepath.Base(filename), + Size: &size, + } + // no reload or force reload since this is just a file upload, + // haproxy configuration has not been changed + return storage.NewCreateStorageMapFileCreated().WithPayload(me) +} + +// GetMapStorageHandlerImpl implementation of the StorageGetAllStorageMapFilesHandler interface +type GetAllStorageMapFilesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *GetAllStorageMapFilesHandlerImpl) Handle(params storage.GetAllStorageMapFilesParams, principal any) middleware.Responder { + st, err := h.Client.MapStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + + // get filenames for files in storage + filenames, err := st.GetAll() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageMapFilesDefault(int(*e.Code)).WithPayload(e) + } + + retMaps := models.Maps{} + for _, f := range filenames { + retMaps = append(retMaps, &models.Map{ + Description: "managed map file", + File: f, + ID: "", + StorageName: filepath.Base(f), + }) + } + + return &storage.GetAllStorageMapFilesOK{Payload: retMaps} +} + +// StorageGetOneStorageMapHandlerImpl implementation of the StorageGetOneStorageMapHandler interface +type GetOneStorageMapHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *GetOneStorageMapHandlerImpl) Handle(params storage.GetOneStorageMapParams, principal any) middleware.Responder { + st, err := h.Client.MapStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageMapFilesDefault(int(*e.Code)).WithPayload(e) + } + + filename, _, err := st.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageMapDefault(int(*e.Code)).WithPayload(e) + } + if filename == "" { + return storage.NewGetOneStorageMapNotFound() + } + f, err := os.Open(filename) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageMapDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewGetOneStorageMapOK().WithPayload(f) +} + +// StorageDeleteStorageMapHandlerImpl implementation of the StorageDeleteStorageMapHandler interface +type StorageDeleteStorageMapHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageDeleteStorageMapHandlerImpl) Handle(params storage.DeleteStorageMapParams, principal any) middleware.Responder { + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + + st, err := h.Client.MapStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + + runningConf := strings.NewReader(configuration.Parser().String()) + + filename, _, err := st.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + // this is far from perfect but should provide a basic level of protection + scanner := bufio.NewScanner(runningConf) + + lineNr := 0 + + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if strings.Contains(line, filename) && !strings.HasPrefix(line, "#") { + errCode := misc.ErrHTTPConflict + errMsg := fmt.Sprintf("rejecting attempt to delete file %s referenced in haproxy conf at line %d: %s", filename, lineNr-1, line) + e := &models.Error{Code: &errCode, Message: &errMsg} + return storage.NewDeleteStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + lineNr++ + } + + err = st.Delete(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageMapDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewDeleteStorageMapNoContent() +} + +// StorageReplaceStorageMapFileHandlerImpl implementation of the StorageReplaceStorageMapFileHandler interface +type StorageReplaceStorageMapFileHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageReplaceStorageMapFileHandlerImpl) Handle(params storage.ReplaceStorageMapFileParams, principal any) middleware.Responder { + st, err := h.Client.MapStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + + _, err = st.Replace(params.Name, params.Data) + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if skipReload { + return storage.NewReplaceStorageMapFileNoContent() + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewReplaceStorageMapFileNoContent() + } + rID := h.ReloadAgent.Reload() + return storage.NewReplaceStorageMapFileAccepted().WithReloadID(rID) +} diff --git a/handlers/nameserver.go b/handlers/nameserver.go new file mode 100644 index 00000000..50fa77ce --- /dev/null +++ b/handlers/nameserver.go @@ -0,0 +1,236 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/nameserver" +) + +// CreateNameserverHandlerImpl implementation of the CreateNameserverHandler interface using client-native client +type CreateNameserverHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteNameserverHandlerImpl implementation of the DeleteNameserverHandler interface using client-native client +type DeleteNameserverHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetNameserverHandlerImpl implementation of the GetNameserverHandler interface using client-native client +type GetNameserverHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetNameserversHandlerImpl implementation of the GetNameserversHandler interface using client-native client +type GetNameserversHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceNameserverHandlerImpl implementation of the ReplaceNameserverHandler interface using client-native client +type ReplaceNameserverHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateNameserverHandlerImpl) Handle(params nameserver.CreateNameserverParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return nameserver.NewCreateNameserverDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewCreateNameserverDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.CreateNameserver(params.Resolver, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return nameserver.NewCreateNameserverDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewCreateNameserverDefault(int(*e.Code)).WithPayload(e) + } + return nameserver.NewCreateNameserverCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return nameserver.NewCreateNameserverAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return nameserver.NewCreateNameserverAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteNameserverHandlerImpl) Handle(params nameserver.DeleteNameserverParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return nameserver.NewDeleteNameserverDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewDeleteNameserverDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteNameserver(params.Name, params.Resolver, t, v) + if err != nil { + e := misc.HandleError(err) + return nameserver.NewDeleteNameserverDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewDeleteNameserverDefault(int(*e.Code)).WithPayload(e) + } + return nameserver.NewDeleteNameserverNoContent() + } + rID := h.ReloadAgent.Reload() + return nameserver.NewDeleteNameserverAccepted().WithReloadID(rID) + } + return nameserver.NewDeleteNameserverAccepted() +} + +// Handle executing the request and returning a response +func (h *GetNameserverHandlerImpl) Handle(params nameserver.GetNameserverParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewGetNameserverDefault(int(*e.Code)).WithPayload(e) + } + + _, b, err := configuration.GetNameserver(params.Name, params.Resolver, t) + if err != nil { + e := misc.HandleError(err) + return nameserver.NewGetNameserverDefault(int(*e.Code)).WithPayload(e) + } + return nameserver.NewGetNameserverOK().WithPayload(b) +} + +// Handle executing the request and returning a response +func (h *GetNameserversHandlerImpl) Handle(params nameserver.GetNameserversParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewGetNameserversDefault(int(*e.Code)).WithPayload(e) + } + + _, bs, err := configuration.GetNameservers(params.Resolver, t) + if err != nil { + e := misc.HandleError(err) + return nameserver.NewGetNameserversDefault(int(*e.Code)).WithPayload(e) + } + return nameserver.NewGetNameserversOK().WithPayload(bs) +} + +// Handle executing the request and returning a response +func (h *ReplaceNameserverHandlerImpl) Handle(params nameserver.ReplaceNameserverParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return nameserver.NewReplaceNameserverDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewReplaceNameserverDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditNameserver(params.Name, params.Resolver, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return nameserver.NewReplaceNameserverDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return nameserver.NewReplaceNameserverDefault(int(*e.Code)).WithPayload(e) + } + return nameserver.NewReplaceNameserverOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return nameserver.NewReplaceNameserverAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return nameserver.NewReplaceNameserverAccepted().WithPayload(params.Data) +} diff --git a/handlers/parent_acl_generated.go b/handlers/parent_acl_generated.go new file mode 100644 index 00000000..1fb6f07c --- /dev/null +++ b/handlers/parent_acl_generated.go @@ -0,0 +1,201 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/acl" +) + +type ( + CreateACLBackendHandlerImpl CreateACLHandlerImpl + CreateACLFrontendHandlerImpl CreateACLHandlerImpl + CreateACLFCGIAppHandlerImpl CreateACLHandlerImpl + CreateACLDefaultsHandlerImpl CreateACLHandlerImpl +) + +type ( + GetACLBackendHandlerImpl GetACLHandlerImpl + GetACLFrontendHandlerImpl GetACLHandlerImpl + GetACLFCGIAppHandlerImpl GetACLHandlerImpl + GetACLDefaultsHandlerImpl GetACLHandlerImpl +) + +type ( + GetAllACLBackendHandlerImpl GetAllACLHandlerImpl + GetAllACLFrontendHandlerImpl GetAllACLHandlerImpl + GetAllACLFCGIAppHandlerImpl GetAllACLHandlerImpl + GetAllACLDefaultsHandlerImpl GetAllACLHandlerImpl +) + +type ( + DeleteACLBackendHandlerImpl DeleteACLHandlerImpl + DeleteACLFrontendHandlerImpl DeleteACLHandlerImpl + DeleteACLFCGIAppHandlerImpl DeleteACLHandlerImpl + DeleteACLDefaultsHandlerImpl DeleteACLHandlerImpl +) + +type ( + ReplaceACLBackendHandlerImpl ReplaceACLHandlerImpl + ReplaceACLFrontendHandlerImpl ReplaceACLHandlerImpl + ReplaceACLFCGIAppHandlerImpl ReplaceACLHandlerImpl + ReplaceACLDefaultsHandlerImpl ReplaceACLHandlerImpl +) + +type ( + ReplaceAllACLBackendHandlerImpl ReplaceAllACLHandlerImpl + ReplaceAllACLFrontendHandlerImpl ReplaceAllACLHandlerImpl + ReplaceAllACLFCGIAppHandlerImpl ReplaceAllACLHandlerImpl + ReplaceAllACLDefaultsHandlerImpl ReplaceAllACLHandlerImpl +) + +func (h *CreateACLBackendHandlerImpl) Handle(params acl.CreateACLBackendParams, principal any) middleware.Responder { + g := CreateACLHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateACLFrontendHandlerImpl) Handle(params acl.CreateACLFrontendParams, principal any) middleware.Responder { + g := CreateACLHandlerImpl(*h) + pg := acl.CreateACLBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *CreateACLFCGIAppHandlerImpl) Handle(params acl.CreateACLFCGIAppParams, principal any) middleware.Responder { + g := CreateACLHandlerImpl(*h) + pg := acl.CreateACLBackendParams(params) + return g.Handle(cnconstants.FCGIAppParentType, pg, principal) +} + +func (h *CreateACLDefaultsHandlerImpl) Handle(params acl.CreateACLDefaultsParams, principal any) middleware.Responder { + g := CreateACLHandlerImpl(*h) + pg := acl.CreateACLBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetACLBackendHandlerImpl) Handle(params acl.GetACLBackendParams, principal any) middleware.Responder { + g := GetACLHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetACLFrontendHandlerImpl) Handle(params acl.GetACLFrontendParams, principal any) middleware.Responder { + g := GetACLHandlerImpl(*h) + pg := acl.GetACLBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetACLFCGIAppHandlerImpl) Handle(params acl.GetACLFCGIAppParams, principal any) middleware.Responder { + g := GetACLHandlerImpl(*h) + pg := acl.GetACLBackendParams(params) + return g.Handle(cnconstants.FCGIAppParentType, pg, principal) +} + +func (h *GetACLDefaultsHandlerImpl) Handle(params acl.GetACLDefaultsParams, principal any) middleware.Responder { + g := GetACLHandlerImpl(*h) + pg := acl.GetACLBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllACLBackendHandlerImpl) Handle(params acl.GetAllACLBackendParams, principal any) middleware.Responder { + g := GetAllACLHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllACLFrontendHandlerImpl) Handle(params acl.GetAllACLFrontendParams, principal any) middleware.Responder { + g := GetAllACLHandlerImpl(*h) + pg := acl.GetAllACLBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllACLFCGIAppHandlerImpl) Handle(params acl.GetAllACLFCGIAppParams, principal any) middleware.Responder { + g := GetAllACLHandlerImpl(*h) + pg := acl.GetAllACLBackendParams(params) + return g.Handle(cnconstants.FCGIAppParentType, pg, principal) +} + +func (h *GetAllACLDefaultsHandlerImpl) Handle(params acl.GetAllACLDefaultsParams, principal any) middleware.Responder { + g := GetAllACLHandlerImpl(*h) + pg := acl.GetAllACLBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteACLBackendHandlerImpl) Handle(params acl.DeleteACLBackendParams, principal any) middleware.Responder { + g := DeleteACLHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteACLFrontendHandlerImpl) Handle(params acl.DeleteACLFrontendParams, principal any) middleware.Responder { + g := DeleteACLHandlerImpl(*h) + pg := acl.DeleteACLBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteACLFCGIAppHandlerImpl) Handle(params acl.DeleteACLFCGIAppParams, principal any) middleware.Responder { + g := DeleteACLHandlerImpl(*h) + pg := acl.DeleteACLBackendParams(params) + return g.Handle(cnconstants.FCGIAppParentType, pg, principal) +} + +func (h *DeleteACLDefaultsHandlerImpl) Handle(params acl.DeleteACLDefaultsParams, principal any) middleware.Responder { + g := DeleteACLHandlerImpl(*h) + pg := acl.DeleteACLBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceACLBackendHandlerImpl) Handle(params acl.ReplaceACLBackendParams, principal any) middleware.Responder { + g := ReplaceACLHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceACLFrontendHandlerImpl) Handle(params acl.ReplaceACLFrontendParams, principal any) middleware.Responder { + g := ReplaceACLHandlerImpl(*h) + pg := acl.ReplaceACLBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceACLFCGIAppHandlerImpl) Handle(params acl.ReplaceACLFCGIAppParams, principal any) middleware.Responder { + g := ReplaceACLHandlerImpl(*h) + pg := acl.ReplaceACLBackendParams(params) + return g.Handle(cnconstants.FCGIAppParentType, pg, principal) +} + +func (h *ReplaceACLDefaultsHandlerImpl) Handle(params acl.ReplaceACLDefaultsParams, principal any) middleware.Responder { + g := ReplaceACLHandlerImpl(*h) + pg := acl.ReplaceACLBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllACLBackendHandlerImpl) Handle(params acl.ReplaceAllACLBackendParams, principal any) middleware.Responder { + g := ReplaceAllACLHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllACLFrontendHandlerImpl) Handle(params acl.ReplaceAllACLFrontendParams, principal any) middleware.Responder { + g := ReplaceAllACLHandlerImpl(*h) + pg := acl.ReplaceAllACLBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllACLFCGIAppHandlerImpl) Handle(params acl.ReplaceAllACLFCGIAppParams, principal any) middleware.Responder { + g := ReplaceAllACLHandlerImpl(*h) + pg := acl.ReplaceAllACLBackendParams(params) + return g.Handle(cnconstants.FCGIAppParentType, pg, principal) +} + +func (h *ReplaceAllACLDefaultsHandlerImpl) Handle(params acl.ReplaceAllACLDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllACLHandlerImpl(*h) + pg := acl.ReplaceAllACLBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_bind_generated.go b/handlers/parent_bind_generated.go new file mode 100644 index 00000000..fe58c618 --- /dev/null +++ b/handlers/parent_bind_generated.go @@ -0,0 +1,136 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/bind" +) + +type ( + CreateBindFrontendHandlerImpl CreateBindHandlerImpl + CreateBindLogForwardHandlerImpl CreateBindHandlerImpl + CreateBindPeerHandlerImpl CreateBindHandlerImpl +) + +type ( + GetBindFrontendHandlerImpl GetBindHandlerImpl + GetBindLogForwardHandlerImpl GetBindHandlerImpl + GetBindPeerHandlerImpl GetBindHandlerImpl +) + +type ( + GetAllBindFrontendHandlerImpl GetAllBindHandlerImpl + GetAllBindLogForwardHandlerImpl GetAllBindHandlerImpl + GetAllBindPeerHandlerImpl GetAllBindHandlerImpl +) + +type ( + DeleteBindFrontendHandlerImpl DeleteBindHandlerImpl + DeleteBindLogForwardHandlerImpl DeleteBindHandlerImpl + DeleteBindPeerHandlerImpl DeleteBindHandlerImpl +) + +type ( + ReplaceBindFrontendHandlerImpl ReplaceBindHandlerImpl + ReplaceBindLogForwardHandlerImpl ReplaceBindHandlerImpl + ReplaceBindPeerHandlerImpl ReplaceBindHandlerImpl +) + +func (h *CreateBindFrontendHandlerImpl) Handle(params bind.CreateBindFrontendParams, principal any) middleware.Responder { + g := CreateBindHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *CreateBindLogForwardHandlerImpl) Handle(params bind.CreateBindLogForwardParams, principal any) middleware.Responder { + g := CreateBindHandlerImpl(*h) + pg := bind.CreateBindFrontendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *CreateBindPeerHandlerImpl) Handle(params bind.CreateBindPeerParams, principal any) middleware.Responder { + g := CreateBindHandlerImpl(*h) + pg := bind.CreateBindFrontendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *GetBindFrontendHandlerImpl) Handle(params bind.GetBindFrontendParams, principal any) middleware.Responder { + g := GetBindHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *GetBindLogForwardHandlerImpl) Handle(params bind.GetBindLogForwardParams, principal any) middleware.Responder { + g := GetBindHandlerImpl(*h) + pg := bind.GetBindFrontendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *GetBindPeerHandlerImpl) Handle(params bind.GetBindPeerParams, principal any) middleware.Responder { + g := GetBindHandlerImpl(*h) + pg := bind.GetBindFrontendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *GetAllBindFrontendHandlerImpl) Handle(params bind.GetAllBindFrontendParams, principal any) middleware.Responder { + g := GetAllBindHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *GetAllBindLogForwardHandlerImpl) Handle(params bind.GetAllBindLogForwardParams, principal any) middleware.Responder { + g := GetAllBindHandlerImpl(*h) + pg := bind.GetAllBindFrontendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *GetAllBindPeerHandlerImpl) Handle(params bind.GetAllBindPeerParams, principal any) middleware.Responder { + g := GetAllBindHandlerImpl(*h) + pg := bind.GetAllBindFrontendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *DeleteBindFrontendHandlerImpl) Handle(params bind.DeleteBindFrontendParams, principal any) middleware.Responder { + g := DeleteBindHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *DeleteBindLogForwardHandlerImpl) Handle(params bind.DeleteBindLogForwardParams, principal any) middleware.Responder { + g := DeleteBindHandlerImpl(*h) + pg := bind.DeleteBindFrontendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *DeleteBindPeerHandlerImpl) Handle(params bind.DeleteBindPeerParams, principal any) middleware.Responder { + g := DeleteBindHandlerImpl(*h) + pg := bind.DeleteBindFrontendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *ReplaceBindFrontendHandlerImpl) Handle(params bind.ReplaceBindFrontendParams, principal any) middleware.Responder { + g := ReplaceBindHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *ReplaceBindLogForwardHandlerImpl) Handle(params bind.ReplaceBindLogForwardParams, principal any) middleware.Responder { + g := ReplaceBindHandlerImpl(*h) + pg := bind.ReplaceBindFrontendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *ReplaceBindPeerHandlerImpl) Handle(params bind.ReplaceBindPeerParams, principal any) middleware.Responder { + g := ReplaceBindHandlerImpl(*h) + pg := bind.ReplaceBindFrontendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} diff --git a/handlers/parent_filter_generated.go b/handlers/parent_filter_generated.go new file mode 100644 index 00000000..a9401717 --- /dev/null +++ b/handlers/parent_filter_generated.go @@ -0,0 +1,117 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/filter" +) + +type ( + CreateFilterBackendHandlerImpl CreateFilterHandlerImpl + CreateFilterFrontendHandlerImpl CreateFilterHandlerImpl +) + +type ( + GetFilterBackendHandlerImpl GetFilterHandlerImpl + GetFilterFrontendHandlerImpl GetFilterHandlerImpl +) + +type ( + GetAllFilterBackendHandlerImpl GetAllFilterHandlerImpl + GetAllFilterFrontendHandlerImpl GetAllFilterHandlerImpl +) + +type ( + DeleteFilterBackendHandlerImpl DeleteFilterHandlerImpl + DeleteFilterFrontendHandlerImpl DeleteFilterHandlerImpl +) + +type ( + ReplaceFilterBackendHandlerImpl ReplaceFilterHandlerImpl + ReplaceFilterFrontendHandlerImpl ReplaceFilterHandlerImpl +) + +type ( + ReplaceAllFilterBackendHandlerImpl ReplaceAllFilterHandlerImpl + ReplaceAllFilterFrontendHandlerImpl ReplaceAllFilterHandlerImpl +) + +func (h *CreateFilterBackendHandlerImpl) Handle(params filter.CreateFilterBackendParams, principal any) middleware.Responder { + g := CreateFilterHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateFilterFrontendHandlerImpl) Handle(params filter.CreateFilterFrontendParams, principal any) middleware.Responder { + g := CreateFilterHandlerImpl(*h) + pg := filter.CreateFilterBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetFilterBackendHandlerImpl) Handle(params filter.GetFilterBackendParams, principal any) middleware.Responder { + g := GetFilterHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetFilterFrontendHandlerImpl) Handle(params filter.GetFilterFrontendParams, principal any) middleware.Responder { + g := GetFilterHandlerImpl(*h) + pg := filter.GetFilterBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllFilterBackendHandlerImpl) Handle(params filter.GetAllFilterBackendParams, principal any) middleware.Responder { + g := GetAllFilterHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllFilterFrontendHandlerImpl) Handle(params filter.GetAllFilterFrontendParams, principal any) middleware.Responder { + g := GetAllFilterHandlerImpl(*h) + pg := filter.GetAllFilterBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteFilterBackendHandlerImpl) Handle(params filter.DeleteFilterBackendParams, principal any) middleware.Responder { + g := DeleteFilterHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteFilterFrontendHandlerImpl) Handle(params filter.DeleteFilterFrontendParams, principal any) middleware.Responder { + g := DeleteFilterHandlerImpl(*h) + pg := filter.DeleteFilterBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceFilterBackendHandlerImpl) Handle(params filter.ReplaceFilterBackendParams, principal any) middleware.Responder { + g := ReplaceFilterHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceFilterFrontendHandlerImpl) Handle(params filter.ReplaceFilterFrontendParams, principal any) middleware.Responder { + g := ReplaceFilterHandlerImpl(*h) + pg := filter.ReplaceFilterBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllFilterBackendHandlerImpl) Handle(params filter.ReplaceAllFilterBackendParams, principal any) middleware.Responder { + g := ReplaceAllFilterHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllFilterFrontendHandlerImpl) Handle(params filter.ReplaceAllFilterFrontendParams, principal any) middleware.Responder { + g := ReplaceAllFilterHandlerImpl(*h) + pg := filter.ReplaceAllFilterBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} diff --git a/handlers/parent_http_after_response_rule_generated.go b/handlers/parent_http_after_response_rule_generated.go new file mode 100644 index 00000000..16d1dde5 --- /dev/null +++ b/handlers/parent_http_after_response_rule_generated.go @@ -0,0 +1,159 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/http_after_response_rule" +) + +type ( + CreateHTTPAfterResponseRuleBackendHandlerImpl CreateHTTPAfterResponseRuleHandlerImpl + CreateHTTPAfterResponseRuleFrontendHandlerImpl CreateHTTPAfterResponseRuleHandlerImpl + CreateHTTPAfterResponseRuleDefaultsHandlerImpl CreateHTTPAfterResponseRuleHandlerImpl +) + +type ( + GetHTTPAfterResponseRuleBackendHandlerImpl GetHTTPAfterResponseRuleHandlerImpl + GetHTTPAfterResponseRuleFrontendHandlerImpl GetHTTPAfterResponseRuleHandlerImpl + GetHTTPAfterResponseRuleDefaultsHandlerImpl GetHTTPAfterResponseRuleHandlerImpl +) + +type ( + GetAllHTTPAfterResponseRuleBackendHandlerImpl GetAllHTTPAfterResponseRuleHandlerImpl + GetAllHTTPAfterResponseRuleFrontendHandlerImpl GetAllHTTPAfterResponseRuleHandlerImpl + GetAllHTTPAfterResponseRuleDefaultsHandlerImpl GetAllHTTPAfterResponseRuleHandlerImpl +) + +type ( + DeleteHTTPAfterResponseRuleBackendHandlerImpl DeleteHTTPAfterResponseRuleHandlerImpl + DeleteHTTPAfterResponseRuleFrontendHandlerImpl DeleteHTTPAfterResponseRuleHandlerImpl + DeleteHTTPAfterResponseRuleDefaultsHandlerImpl DeleteHTTPAfterResponseRuleHandlerImpl +) + +type ( + ReplaceHTTPAfterResponseRuleBackendHandlerImpl ReplaceHTTPAfterResponseRuleHandlerImpl + ReplaceHTTPAfterResponseRuleFrontendHandlerImpl ReplaceHTTPAfterResponseRuleHandlerImpl + ReplaceHTTPAfterResponseRuleDefaultsHandlerImpl ReplaceHTTPAfterResponseRuleHandlerImpl +) + +type ( + ReplaceAllHTTPAfterResponseRuleBackendHandlerImpl ReplaceAllHTTPAfterResponseRuleHandlerImpl + ReplaceAllHTTPAfterResponseRuleFrontendHandlerImpl ReplaceAllHTTPAfterResponseRuleHandlerImpl + ReplaceAllHTTPAfterResponseRuleDefaultsHandlerImpl ReplaceAllHTTPAfterResponseRuleHandlerImpl +) + +func (h *CreateHTTPAfterResponseRuleBackendHandlerImpl) Handle(params http_after_response_rule.CreateHTTPAfterResponseRuleBackendParams, principal any) middleware.Responder { + g := CreateHTTPAfterResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateHTTPAfterResponseRuleFrontendHandlerImpl) Handle(params http_after_response_rule.CreateHTTPAfterResponseRuleFrontendParams, principal any) middleware.Responder { + g := CreateHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.CreateHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *CreateHTTPAfterResponseRuleDefaultsHandlerImpl) Handle(params http_after_response_rule.CreateHTTPAfterResponseRuleDefaultsParams, principal any) middleware.Responder { + g := CreateHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.CreateHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetHTTPAfterResponseRuleBackendHandlerImpl) Handle(params http_after_response_rule.GetHTTPAfterResponseRuleBackendParams, principal any) middleware.Responder { + g := GetHTTPAfterResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetHTTPAfterResponseRuleFrontendHandlerImpl) Handle(params http_after_response_rule.GetHTTPAfterResponseRuleFrontendParams, principal any) middleware.Responder { + g := GetHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.GetHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetHTTPAfterResponseRuleDefaultsHandlerImpl) Handle(params http_after_response_rule.GetHTTPAfterResponseRuleDefaultsParams, principal any) middleware.Responder { + g := GetHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.GetHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllHTTPAfterResponseRuleBackendHandlerImpl) Handle(params http_after_response_rule.GetAllHTTPAfterResponseRuleBackendParams, principal any) middleware.Responder { + g := GetAllHTTPAfterResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllHTTPAfterResponseRuleFrontendHandlerImpl) Handle(params http_after_response_rule.GetAllHTTPAfterResponseRuleFrontendParams, principal any) middleware.Responder { + g := GetAllHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.GetAllHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllHTTPAfterResponseRuleDefaultsHandlerImpl) Handle(params http_after_response_rule.GetAllHTTPAfterResponseRuleDefaultsParams, principal any) middleware.Responder { + g := GetAllHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.GetAllHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteHTTPAfterResponseRuleBackendHandlerImpl) Handle(params http_after_response_rule.DeleteHTTPAfterResponseRuleBackendParams, principal any) middleware.Responder { + g := DeleteHTTPAfterResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteHTTPAfterResponseRuleFrontendHandlerImpl) Handle(params http_after_response_rule.DeleteHTTPAfterResponseRuleFrontendParams, principal any) middleware.Responder { + g := DeleteHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.DeleteHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteHTTPAfterResponseRuleDefaultsHandlerImpl) Handle(params http_after_response_rule.DeleteHTTPAfterResponseRuleDefaultsParams, principal any) middleware.Responder { + g := DeleteHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.DeleteHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceHTTPAfterResponseRuleBackendHandlerImpl) Handle(params http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendParams, principal any) middleware.Responder { + g := ReplaceHTTPAfterResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceHTTPAfterResponseRuleFrontendHandlerImpl) Handle(params http_after_response_rule.ReplaceHTTPAfterResponseRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceHTTPAfterResponseRuleDefaultsHandlerImpl) Handle(params http_after_response_rule.ReplaceHTTPAfterResponseRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllHTTPAfterResponseRuleBackendHandlerImpl) Handle(params http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPAfterResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllHTTPAfterResponseRuleFrontendHandlerImpl) Handle(params http_after_response_rule.ReplaceAllHTTPAfterResponseRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllHTTPAfterResponseRuleDefaultsHandlerImpl) Handle(params http_after_response_rule.ReplaceAllHTTPAfterResponseRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllHTTPAfterResponseRuleHandlerImpl(*h) + pg := http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_http_check_generated.go b/handlers/parent_http_check_generated.go new file mode 100644 index 00000000..5746f4af --- /dev/null +++ b/handlers/parent_http_check_generated.go @@ -0,0 +1,117 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/http_check" +) + +type ( + CreateHTTPCheckBackendHandlerImpl CreateHTTPCheckHandlerImpl + CreateHTTPCheckDefaultsHandlerImpl CreateHTTPCheckHandlerImpl +) + +type ( + GetHTTPCheckBackendHandlerImpl GetHTTPCheckHandlerImpl + GetHTTPCheckDefaultsHandlerImpl GetHTTPCheckHandlerImpl +) + +type ( + GetAllHTTPCheckBackendHandlerImpl GetAllHTTPCheckHandlerImpl + GetAllHTTPCheckDefaultsHandlerImpl GetAllHTTPCheckHandlerImpl +) + +type ( + DeleteHTTPCheckBackendHandlerImpl DeleteHTTPCheckHandlerImpl + DeleteHTTPCheckDefaultsHandlerImpl DeleteHTTPCheckHandlerImpl +) + +type ( + ReplaceHTTPCheckBackendHandlerImpl ReplaceHTTPCheckHandlerImpl + ReplaceHTTPCheckDefaultsHandlerImpl ReplaceHTTPCheckHandlerImpl +) + +type ( + ReplaceAllHTTPCheckBackendHandlerImpl ReplaceAllHTTPCheckHandlerImpl + ReplaceAllHTTPCheckDefaultsHandlerImpl ReplaceAllHTTPCheckHandlerImpl +) + +func (h *CreateHTTPCheckBackendHandlerImpl) Handle(params http_check.CreateHTTPCheckBackendParams, principal any) middleware.Responder { + g := CreateHTTPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateHTTPCheckDefaultsHandlerImpl) Handle(params http_check.CreateHTTPCheckDefaultsParams, principal any) middleware.Responder { + g := CreateHTTPCheckHandlerImpl(*h) + pg := http_check.CreateHTTPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetHTTPCheckBackendHandlerImpl) Handle(params http_check.GetHTTPCheckBackendParams, principal any) middleware.Responder { + g := GetHTTPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetHTTPCheckDefaultsHandlerImpl) Handle(params http_check.GetHTTPCheckDefaultsParams, principal any) middleware.Responder { + g := GetHTTPCheckHandlerImpl(*h) + pg := http_check.GetHTTPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllHTTPCheckBackendHandlerImpl) Handle(params http_check.GetAllHTTPCheckBackendParams, principal any) middleware.Responder { + g := GetAllHTTPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllHTTPCheckDefaultsHandlerImpl) Handle(params http_check.GetAllHTTPCheckDefaultsParams, principal any) middleware.Responder { + g := GetAllHTTPCheckHandlerImpl(*h) + pg := http_check.GetAllHTTPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteHTTPCheckBackendHandlerImpl) Handle(params http_check.DeleteHTTPCheckBackendParams, principal any) middleware.Responder { + g := DeleteHTTPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteHTTPCheckDefaultsHandlerImpl) Handle(params http_check.DeleteHTTPCheckDefaultsParams, principal any) middleware.Responder { + g := DeleteHTTPCheckHandlerImpl(*h) + pg := http_check.DeleteHTTPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceHTTPCheckBackendHandlerImpl) Handle(params http_check.ReplaceHTTPCheckBackendParams, principal any) middleware.Responder { + g := ReplaceHTTPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceHTTPCheckDefaultsHandlerImpl) Handle(params http_check.ReplaceHTTPCheckDefaultsParams, principal any) middleware.Responder { + g := ReplaceHTTPCheckHandlerImpl(*h) + pg := http_check.ReplaceHTTPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllHTTPCheckBackendHandlerImpl) Handle(params http_check.ReplaceAllHTTPCheckBackendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllHTTPCheckDefaultsHandlerImpl) Handle(params http_check.ReplaceAllHTTPCheckDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllHTTPCheckHandlerImpl(*h) + pg := http_check.ReplaceAllHTTPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_http_error_rule_generated.go b/handlers/parent_http_error_rule_generated.go new file mode 100644 index 00000000..0949d140 --- /dev/null +++ b/handlers/parent_http_error_rule_generated.go @@ -0,0 +1,159 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/http_error_rule" +) + +type ( + CreateHTTPErrorRuleBackendHandlerImpl CreateHTTPErrorRuleHandlerImpl + CreateHTTPErrorRuleFrontendHandlerImpl CreateHTTPErrorRuleHandlerImpl + CreateHTTPErrorRuleDefaultsHandlerImpl CreateHTTPErrorRuleHandlerImpl +) + +type ( + GetHTTPErrorRuleBackendHandlerImpl GetHTTPErrorRuleHandlerImpl + GetHTTPErrorRuleFrontendHandlerImpl GetHTTPErrorRuleHandlerImpl + GetHTTPErrorRuleDefaultsHandlerImpl GetHTTPErrorRuleHandlerImpl +) + +type ( + GetAllHTTPErrorRuleBackendHandlerImpl GetAllHTTPErrorRuleHandlerImpl + GetAllHTTPErrorRuleFrontendHandlerImpl GetAllHTTPErrorRuleHandlerImpl + GetAllHTTPErrorRuleDefaultsHandlerImpl GetAllHTTPErrorRuleHandlerImpl +) + +type ( + DeleteHTTPErrorRuleBackendHandlerImpl DeleteHTTPErrorRuleHandlerImpl + DeleteHTTPErrorRuleFrontendHandlerImpl DeleteHTTPErrorRuleHandlerImpl + DeleteHTTPErrorRuleDefaultsHandlerImpl DeleteHTTPErrorRuleHandlerImpl +) + +type ( + ReplaceHTTPErrorRuleBackendHandlerImpl ReplaceHTTPErrorRuleHandlerImpl + ReplaceHTTPErrorRuleFrontendHandlerImpl ReplaceHTTPErrorRuleHandlerImpl + ReplaceHTTPErrorRuleDefaultsHandlerImpl ReplaceHTTPErrorRuleHandlerImpl +) + +type ( + ReplaceAllHTTPErrorRuleBackendHandlerImpl ReplaceAllHTTPErrorRuleHandlerImpl + ReplaceAllHTTPErrorRuleFrontendHandlerImpl ReplaceAllHTTPErrorRuleHandlerImpl + ReplaceAllHTTPErrorRuleDefaultsHandlerImpl ReplaceAllHTTPErrorRuleHandlerImpl +) + +func (h *CreateHTTPErrorRuleBackendHandlerImpl) Handle(params http_error_rule.CreateHTTPErrorRuleBackendParams, principal any) middleware.Responder { + g := CreateHTTPErrorRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateHTTPErrorRuleFrontendHandlerImpl) Handle(params http_error_rule.CreateHTTPErrorRuleFrontendParams, principal any) middleware.Responder { + g := CreateHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.CreateHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *CreateHTTPErrorRuleDefaultsHandlerImpl) Handle(params http_error_rule.CreateHTTPErrorRuleDefaultsParams, principal any) middleware.Responder { + g := CreateHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.CreateHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetHTTPErrorRuleBackendHandlerImpl) Handle(params http_error_rule.GetHTTPErrorRuleBackendParams, principal any) middleware.Responder { + g := GetHTTPErrorRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetHTTPErrorRuleFrontendHandlerImpl) Handle(params http_error_rule.GetHTTPErrorRuleFrontendParams, principal any) middleware.Responder { + g := GetHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.GetHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetHTTPErrorRuleDefaultsHandlerImpl) Handle(params http_error_rule.GetHTTPErrorRuleDefaultsParams, principal any) middleware.Responder { + g := GetHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.GetHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllHTTPErrorRuleBackendHandlerImpl) Handle(params http_error_rule.GetAllHTTPErrorRuleBackendParams, principal any) middleware.Responder { + g := GetAllHTTPErrorRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllHTTPErrorRuleFrontendHandlerImpl) Handle(params http_error_rule.GetAllHTTPErrorRuleFrontendParams, principal any) middleware.Responder { + g := GetAllHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.GetAllHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllHTTPErrorRuleDefaultsHandlerImpl) Handle(params http_error_rule.GetAllHTTPErrorRuleDefaultsParams, principal any) middleware.Responder { + g := GetAllHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.GetAllHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteHTTPErrorRuleBackendHandlerImpl) Handle(params http_error_rule.DeleteHTTPErrorRuleBackendParams, principal any) middleware.Responder { + g := DeleteHTTPErrorRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteHTTPErrorRuleFrontendHandlerImpl) Handle(params http_error_rule.DeleteHTTPErrorRuleFrontendParams, principal any) middleware.Responder { + g := DeleteHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.DeleteHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteHTTPErrorRuleDefaultsHandlerImpl) Handle(params http_error_rule.DeleteHTTPErrorRuleDefaultsParams, principal any) middleware.Responder { + g := DeleteHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.DeleteHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceHTTPErrorRuleBackendHandlerImpl) Handle(params http_error_rule.ReplaceHTTPErrorRuleBackendParams, principal any) middleware.Responder { + g := ReplaceHTTPErrorRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceHTTPErrorRuleFrontendHandlerImpl) Handle(params http_error_rule.ReplaceHTTPErrorRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.ReplaceHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceHTTPErrorRuleDefaultsHandlerImpl) Handle(params http_error_rule.ReplaceHTTPErrorRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.ReplaceHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllHTTPErrorRuleBackendHandlerImpl) Handle(params http_error_rule.ReplaceAllHTTPErrorRuleBackendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPErrorRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllHTTPErrorRuleFrontendHandlerImpl) Handle(params http_error_rule.ReplaceAllHTTPErrorRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.ReplaceAllHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllHTTPErrorRuleDefaultsHandlerImpl) Handle(params http_error_rule.ReplaceAllHTTPErrorRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllHTTPErrorRuleHandlerImpl(*h) + pg := http_error_rule.ReplaceAllHTTPErrorRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_http_request_rule_generated.go b/handlers/parent_http_request_rule_generated.go new file mode 100644 index 00000000..42b8c064 --- /dev/null +++ b/handlers/parent_http_request_rule_generated.go @@ -0,0 +1,159 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/http_request_rule" +) + +type ( + CreateHTTPRequestRuleBackendHandlerImpl CreateHTTPRequestRuleHandlerImpl + CreateHTTPRequestRuleFrontendHandlerImpl CreateHTTPRequestRuleHandlerImpl + CreateHTTPRequestRuleDefaultsHandlerImpl CreateHTTPRequestRuleHandlerImpl +) + +type ( + GetHTTPRequestRuleBackendHandlerImpl GetHTTPRequestRuleHandlerImpl + GetHTTPRequestRuleFrontendHandlerImpl GetHTTPRequestRuleHandlerImpl + GetHTTPRequestRuleDefaultsHandlerImpl GetHTTPRequestRuleHandlerImpl +) + +type ( + GetAllHTTPRequestRuleBackendHandlerImpl GetAllHTTPRequestRuleHandlerImpl + GetAllHTTPRequestRuleFrontendHandlerImpl GetAllHTTPRequestRuleHandlerImpl + GetAllHTTPRequestRuleDefaultsHandlerImpl GetAllHTTPRequestRuleHandlerImpl +) + +type ( + DeleteHTTPRequestRuleBackendHandlerImpl DeleteHTTPRequestRuleHandlerImpl + DeleteHTTPRequestRuleFrontendHandlerImpl DeleteHTTPRequestRuleHandlerImpl + DeleteHTTPRequestRuleDefaultsHandlerImpl DeleteHTTPRequestRuleHandlerImpl +) + +type ( + ReplaceHTTPRequestRuleBackendHandlerImpl ReplaceHTTPRequestRuleHandlerImpl + ReplaceHTTPRequestRuleFrontendHandlerImpl ReplaceHTTPRequestRuleHandlerImpl + ReplaceHTTPRequestRuleDefaultsHandlerImpl ReplaceHTTPRequestRuleHandlerImpl +) + +type ( + ReplaceAllHTTPRequestRuleBackendHandlerImpl ReplaceAllHTTPRequestRuleHandlerImpl + ReplaceAllHTTPRequestRuleFrontendHandlerImpl ReplaceAllHTTPRequestRuleHandlerImpl + ReplaceAllHTTPRequestRuleDefaultsHandlerImpl ReplaceAllHTTPRequestRuleHandlerImpl +) + +func (h *CreateHTTPRequestRuleBackendHandlerImpl) Handle(params http_request_rule.CreateHTTPRequestRuleBackendParams, principal any) middleware.Responder { + g := CreateHTTPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateHTTPRequestRuleFrontendHandlerImpl) Handle(params http_request_rule.CreateHTTPRequestRuleFrontendParams, principal any) middleware.Responder { + g := CreateHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.CreateHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *CreateHTTPRequestRuleDefaultsHandlerImpl) Handle(params http_request_rule.CreateHTTPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := CreateHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.CreateHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetHTTPRequestRuleBackendHandlerImpl) Handle(params http_request_rule.GetHTTPRequestRuleBackendParams, principal any) middleware.Responder { + g := GetHTTPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetHTTPRequestRuleFrontendHandlerImpl) Handle(params http_request_rule.GetHTTPRequestRuleFrontendParams, principal any) middleware.Responder { + g := GetHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.GetHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetHTTPRequestRuleDefaultsHandlerImpl) Handle(params http_request_rule.GetHTTPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := GetHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.GetHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllHTTPRequestRuleBackendHandlerImpl) Handle(params http_request_rule.GetAllHTTPRequestRuleBackendParams, principal any) middleware.Responder { + g := GetAllHTTPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllHTTPRequestRuleFrontendHandlerImpl) Handle(params http_request_rule.GetAllHTTPRequestRuleFrontendParams, principal any) middleware.Responder { + g := GetAllHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.GetAllHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllHTTPRequestRuleDefaultsHandlerImpl) Handle(params http_request_rule.GetAllHTTPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := GetAllHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.GetAllHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteHTTPRequestRuleBackendHandlerImpl) Handle(params http_request_rule.DeleteHTTPRequestRuleBackendParams, principal any) middleware.Responder { + g := DeleteHTTPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteHTTPRequestRuleFrontendHandlerImpl) Handle(params http_request_rule.DeleteHTTPRequestRuleFrontendParams, principal any) middleware.Responder { + g := DeleteHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.DeleteHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteHTTPRequestRuleDefaultsHandlerImpl) Handle(params http_request_rule.DeleteHTTPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := DeleteHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.DeleteHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceHTTPRequestRuleBackendHandlerImpl) Handle(params http_request_rule.ReplaceHTTPRequestRuleBackendParams, principal any) middleware.Responder { + g := ReplaceHTTPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceHTTPRequestRuleFrontendHandlerImpl) Handle(params http_request_rule.ReplaceHTTPRequestRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.ReplaceHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceHTTPRequestRuleDefaultsHandlerImpl) Handle(params http_request_rule.ReplaceHTTPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.ReplaceHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllHTTPRequestRuleBackendHandlerImpl) Handle(params http_request_rule.ReplaceAllHTTPRequestRuleBackendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllHTTPRequestRuleFrontendHandlerImpl) Handle(params http_request_rule.ReplaceAllHTTPRequestRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.ReplaceAllHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllHTTPRequestRuleDefaultsHandlerImpl) Handle(params http_request_rule.ReplaceAllHTTPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllHTTPRequestRuleHandlerImpl(*h) + pg := http_request_rule.ReplaceAllHTTPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_http_response_rule_generated.go b/handlers/parent_http_response_rule_generated.go new file mode 100644 index 00000000..27c4530f --- /dev/null +++ b/handlers/parent_http_response_rule_generated.go @@ -0,0 +1,159 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/http_response_rule" +) + +type ( + CreateHTTPResponseRuleBackendHandlerImpl CreateHTTPResponseRuleHandlerImpl + CreateHTTPResponseRuleFrontendHandlerImpl CreateHTTPResponseRuleHandlerImpl + CreateHTTPResponseRuleDefaultsHandlerImpl CreateHTTPResponseRuleHandlerImpl +) + +type ( + GetHTTPResponseRuleBackendHandlerImpl GetHTTPResponseRuleHandlerImpl + GetHTTPResponseRuleFrontendHandlerImpl GetHTTPResponseRuleHandlerImpl + GetHTTPResponseRuleDefaultsHandlerImpl GetHTTPResponseRuleHandlerImpl +) + +type ( + GetAllHTTPResponseRuleBackendHandlerImpl GetAllHTTPResponseRuleHandlerImpl + GetAllHTTPResponseRuleFrontendHandlerImpl GetAllHTTPResponseRuleHandlerImpl + GetAllHTTPResponseRuleDefaultsHandlerImpl GetAllHTTPResponseRuleHandlerImpl +) + +type ( + DeleteHTTPResponseRuleBackendHandlerImpl DeleteHTTPResponseRuleHandlerImpl + DeleteHTTPResponseRuleFrontendHandlerImpl DeleteHTTPResponseRuleHandlerImpl + DeleteHTTPResponseRuleDefaultsHandlerImpl DeleteHTTPResponseRuleHandlerImpl +) + +type ( + ReplaceHTTPResponseRuleBackendHandlerImpl ReplaceHTTPResponseRuleHandlerImpl + ReplaceHTTPResponseRuleFrontendHandlerImpl ReplaceHTTPResponseRuleHandlerImpl + ReplaceHTTPResponseRuleDefaultsHandlerImpl ReplaceHTTPResponseRuleHandlerImpl +) + +type ( + ReplaceAllHTTPResponseRuleBackendHandlerImpl ReplaceAllHTTPResponseRuleHandlerImpl + ReplaceAllHTTPResponseRuleFrontendHandlerImpl ReplaceAllHTTPResponseRuleHandlerImpl + ReplaceAllHTTPResponseRuleDefaultsHandlerImpl ReplaceAllHTTPResponseRuleHandlerImpl +) + +func (h *CreateHTTPResponseRuleBackendHandlerImpl) Handle(params http_response_rule.CreateHTTPResponseRuleBackendParams, principal any) middleware.Responder { + g := CreateHTTPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateHTTPResponseRuleFrontendHandlerImpl) Handle(params http_response_rule.CreateHTTPResponseRuleFrontendParams, principal any) middleware.Responder { + g := CreateHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.CreateHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *CreateHTTPResponseRuleDefaultsHandlerImpl) Handle(params http_response_rule.CreateHTTPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := CreateHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.CreateHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetHTTPResponseRuleBackendHandlerImpl) Handle(params http_response_rule.GetHTTPResponseRuleBackendParams, principal any) middleware.Responder { + g := GetHTTPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetHTTPResponseRuleFrontendHandlerImpl) Handle(params http_response_rule.GetHTTPResponseRuleFrontendParams, principal any) middleware.Responder { + g := GetHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.GetHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetHTTPResponseRuleDefaultsHandlerImpl) Handle(params http_response_rule.GetHTTPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := GetHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.GetHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllHTTPResponseRuleBackendHandlerImpl) Handle(params http_response_rule.GetAllHTTPResponseRuleBackendParams, principal any) middleware.Responder { + g := GetAllHTTPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllHTTPResponseRuleFrontendHandlerImpl) Handle(params http_response_rule.GetAllHTTPResponseRuleFrontendParams, principal any) middleware.Responder { + g := GetAllHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.GetAllHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllHTTPResponseRuleDefaultsHandlerImpl) Handle(params http_response_rule.GetAllHTTPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := GetAllHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.GetAllHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteHTTPResponseRuleBackendHandlerImpl) Handle(params http_response_rule.DeleteHTTPResponseRuleBackendParams, principal any) middleware.Responder { + g := DeleteHTTPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteHTTPResponseRuleFrontendHandlerImpl) Handle(params http_response_rule.DeleteHTTPResponseRuleFrontendParams, principal any) middleware.Responder { + g := DeleteHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.DeleteHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteHTTPResponseRuleDefaultsHandlerImpl) Handle(params http_response_rule.DeleteHTTPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := DeleteHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.DeleteHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceHTTPResponseRuleBackendHandlerImpl) Handle(params http_response_rule.ReplaceHTTPResponseRuleBackendParams, principal any) middleware.Responder { + g := ReplaceHTTPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceHTTPResponseRuleFrontendHandlerImpl) Handle(params http_response_rule.ReplaceHTTPResponseRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.ReplaceHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceHTTPResponseRuleDefaultsHandlerImpl) Handle(params http_response_rule.ReplaceHTTPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.ReplaceHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllHTTPResponseRuleBackendHandlerImpl) Handle(params http_response_rule.ReplaceAllHTTPResponseRuleBackendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllHTTPResponseRuleFrontendHandlerImpl) Handle(params http_response_rule.ReplaceAllHTTPResponseRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceAllHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.ReplaceAllHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllHTTPResponseRuleDefaultsHandlerImpl) Handle(params http_response_rule.ReplaceAllHTTPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllHTTPResponseRuleHandlerImpl(*h) + pg := http_response_rule.ReplaceAllHTTPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_log_target_generated.go b/handlers/parent_log_target_generated.go new file mode 100644 index 00000000..b2fb408d --- /dev/null +++ b/handlers/parent_log_target_generated.go @@ -0,0 +1,243 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/log_target" +) + +type ( + CreateLogTargetBackendHandlerImpl CreateLogTargetHandlerImpl + CreateLogTargetFrontendHandlerImpl CreateLogTargetHandlerImpl + CreateLogTargetDefaultsHandlerImpl CreateLogTargetHandlerImpl + CreateLogTargetPeerHandlerImpl CreateLogTargetHandlerImpl + CreateLogTargetLogForwardHandlerImpl CreateLogTargetHandlerImpl +) + +type ( + GetLogTargetBackendHandlerImpl GetLogTargetHandlerImpl + GetLogTargetFrontendHandlerImpl GetLogTargetHandlerImpl + GetLogTargetDefaultsHandlerImpl GetLogTargetHandlerImpl + GetLogTargetPeerHandlerImpl GetLogTargetHandlerImpl + GetLogTargetLogForwardHandlerImpl GetLogTargetHandlerImpl +) + +type ( + GetAllLogTargetBackendHandlerImpl GetAllLogTargetHandlerImpl + GetAllLogTargetFrontendHandlerImpl GetAllLogTargetHandlerImpl + GetAllLogTargetDefaultsHandlerImpl GetAllLogTargetHandlerImpl + GetAllLogTargetPeerHandlerImpl GetAllLogTargetHandlerImpl + GetAllLogTargetLogForwardHandlerImpl GetAllLogTargetHandlerImpl +) + +type ( + DeleteLogTargetBackendHandlerImpl DeleteLogTargetHandlerImpl + DeleteLogTargetFrontendHandlerImpl DeleteLogTargetHandlerImpl + DeleteLogTargetDefaultsHandlerImpl DeleteLogTargetHandlerImpl + DeleteLogTargetPeerHandlerImpl DeleteLogTargetHandlerImpl + DeleteLogTargetLogForwardHandlerImpl DeleteLogTargetHandlerImpl +) + +type ( + ReplaceLogTargetBackendHandlerImpl ReplaceLogTargetHandlerImpl + ReplaceLogTargetFrontendHandlerImpl ReplaceLogTargetHandlerImpl + ReplaceLogTargetDefaultsHandlerImpl ReplaceLogTargetHandlerImpl + ReplaceLogTargetPeerHandlerImpl ReplaceLogTargetHandlerImpl + ReplaceLogTargetLogForwardHandlerImpl ReplaceLogTargetHandlerImpl +) + +type ( + ReplaceAllLogTargetBackendHandlerImpl ReplaceAllLogTargetHandlerImpl + ReplaceAllLogTargetFrontendHandlerImpl ReplaceAllLogTargetHandlerImpl + ReplaceAllLogTargetDefaultsHandlerImpl ReplaceAllLogTargetHandlerImpl + ReplaceAllLogTargetPeerHandlerImpl ReplaceAllLogTargetHandlerImpl + ReplaceAllLogTargetLogForwardHandlerImpl ReplaceAllLogTargetHandlerImpl +) + +func (h *CreateLogTargetBackendHandlerImpl) Handle(params log_target.CreateLogTargetBackendParams, principal any) middleware.Responder { + g := CreateLogTargetHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateLogTargetFrontendHandlerImpl) Handle(params log_target.CreateLogTargetFrontendParams, principal any) middleware.Responder { + g := CreateLogTargetHandlerImpl(*h) + pg := log_target.CreateLogTargetBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *CreateLogTargetDefaultsHandlerImpl) Handle(params log_target.CreateLogTargetDefaultsParams, principal any) middleware.Responder { + g := CreateLogTargetHandlerImpl(*h) + pg := log_target.CreateLogTargetBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *CreateLogTargetPeerHandlerImpl) Handle(params log_target.CreateLogTargetPeerParams, principal any) middleware.Responder { + g := CreateLogTargetHandlerImpl(*h) + pg := log_target.CreateLogTargetBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *CreateLogTargetLogForwardHandlerImpl) Handle(params log_target.CreateLogTargetLogForwardParams, principal any) middleware.Responder { + g := CreateLogTargetHandlerImpl(*h) + pg := log_target.CreateLogTargetBackendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *GetLogTargetBackendHandlerImpl) Handle(params log_target.GetLogTargetBackendParams, principal any) middleware.Responder { + g := GetLogTargetHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetLogTargetFrontendHandlerImpl) Handle(params log_target.GetLogTargetFrontendParams, principal any) middleware.Responder { + g := GetLogTargetHandlerImpl(*h) + pg := log_target.GetLogTargetBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetLogTargetDefaultsHandlerImpl) Handle(params log_target.GetLogTargetDefaultsParams, principal any) middleware.Responder { + g := GetLogTargetHandlerImpl(*h) + pg := log_target.GetLogTargetBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetLogTargetPeerHandlerImpl) Handle(params log_target.GetLogTargetPeerParams, principal any) middleware.Responder { + g := GetLogTargetHandlerImpl(*h) + pg := log_target.GetLogTargetBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *GetLogTargetLogForwardHandlerImpl) Handle(params log_target.GetLogTargetLogForwardParams, principal any) middleware.Responder { + g := GetLogTargetHandlerImpl(*h) + pg := log_target.GetLogTargetBackendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *GetAllLogTargetBackendHandlerImpl) Handle(params log_target.GetAllLogTargetBackendParams, principal any) middleware.Responder { + g := GetAllLogTargetHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllLogTargetFrontendHandlerImpl) Handle(params log_target.GetAllLogTargetFrontendParams, principal any) middleware.Responder { + g := GetAllLogTargetHandlerImpl(*h) + pg := log_target.GetAllLogTargetBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllLogTargetDefaultsHandlerImpl) Handle(params log_target.GetAllLogTargetDefaultsParams, principal any) middleware.Responder { + g := GetAllLogTargetHandlerImpl(*h) + pg := log_target.GetAllLogTargetBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllLogTargetPeerHandlerImpl) Handle(params log_target.GetAllLogTargetPeerParams, principal any) middleware.Responder { + g := GetAllLogTargetHandlerImpl(*h) + pg := log_target.GetAllLogTargetBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *GetAllLogTargetLogForwardHandlerImpl) Handle(params log_target.GetAllLogTargetLogForwardParams, principal any) middleware.Responder { + g := GetAllLogTargetHandlerImpl(*h) + pg := log_target.GetAllLogTargetBackendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *DeleteLogTargetBackendHandlerImpl) Handle(params log_target.DeleteLogTargetBackendParams, principal any) middleware.Responder { + g := DeleteLogTargetHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteLogTargetFrontendHandlerImpl) Handle(params log_target.DeleteLogTargetFrontendParams, principal any) middleware.Responder { + g := DeleteLogTargetHandlerImpl(*h) + pg := log_target.DeleteLogTargetBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteLogTargetDefaultsHandlerImpl) Handle(params log_target.DeleteLogTargetDefaultsParams, principal any) middleware.Responder { + g := DeleteLogTargetHandlerImpl(*h) + pg := log_target.DeleteLogTargetBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteLogTargetPeerHandlerImpl) Handle(params log_target.DeleteLogTargetPeerParams, principal any) middleware.Responder { + g := DeleteLogTargetHandlerImpl(*h) + pg := log_target.DeleteLogTargetBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *DeleteLogTargetLogForwardHandlerImpl) Handle(params log_target.DeleteLogTargetLogForwardParams, principal any) middleware.Responder { + g := DeleteLogTargetHandlerImpl(*h) + pg := log_target.DeleteLogTargetBackendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *ReplaceLogTargetBackendHandlerImpl) Handle(params log_target.ReplaceLogTargetBackendParams, principal any) middleware.Responder { + g := ReplaceLogTargetHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceLogTargetFrontendHandlerImpl) Handle(params log_target.ReplaceLogTargetFrontendParams, principal any) middleware.Responder { + g := ReplaceLogTargetHandlerImpl(*h) + pg := log_target.ReplaceLogTargetBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceLogTargetDefaultsHandlerImpl) Handle(params log_target.ReplaceLogTargetDefaultsParams, principal any) middleware.Responder { + g := ReplaceLogTargetHandlerImpl(*h) + pg := log_target.ReplaceLogTargetBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceLogTargetPeerHandlerImpl) Handle(params log_target.ReplaceLogTargetPeerParams, principal any) middleware.Responder { + g := ReplaceLogTargetHandlerImpl(*h) + pg := log_target.ReplaceLogTargetBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *ReplaceLogTargetLogForwardHandlerImpl) Handle(params log_target.ReplaceLogTargetLogForwardParams, principal any) middleware.Responder { + g := ReplaceLogTargetHandlerImpl(*h) + pg := log_target.ReplaceLogTargetBackendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} + +func (h *ReplaceAllLogTargetBackendHandlerImpl) Handle(params log_target.ReplaceAllLogTargetBackendParams, principal any) middleware.Responder { + g := ReplaceAllLogTargetHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllLogTargetFrontendHandlerImpl) Handle(params log_target.ReplaceAllLogTargetFrontendParams, principal any) middleware.Responder { + g := ReplaceAllLogTargetHandlerImpl(*h) + pg := log_target.ReplaceAllLogTargetBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllLogTargetDefaultsHandlerImpl) Handle(params log_target.ReplaceAllLogTargetDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllLogTargetHandlerImpl(*h) + pg := log_target.ReplaceAllLogTargetBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllLogTargetPeerHandlerImpl) Handle(params log_target.ReplaceAllLogTargetPeerParams, principal any) middleware.Responder { + g := ReplaceAllLogTargetHandlerImpl(*h) + pg := log_target.ReplaceAllLogTargetBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *ReplaceAllLogTargetLogForwardHandlerImpl) Handle(params log_target.ReplaceAllLogTargetLogForwardParams, principal any) middleware.Responder { + g := ReplaceAllLogTargetHandlerImpl(*h) + pg := log_target.ReplaceAllLogTargetBackendParams(params) + return g.Handle(cnconstants.LogForwardParentType, pg, principal) +} diff --git a/handlers/parent_log_target_global.go b/handlers/parent_log_target_global.go new file mode 100644 index 00000000..7ff87fd2 --- /dev/null +++ b/handlers/parent_log_target_global.go @@ -0,0 +1,120 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/log_target" +) + +type ( + CreateLogTargetGlobalHandlerImpl CreateLogTargetHandlerImpl +) + +type ( + GetLogTargetGlobalHandlerImpl GetLogTargetHandlerImpl +) + +type ( + GetAllLogTargetGlobalHandlerImpl GetAllLogTargetHandlerImpl +) + +type ( + DeleteLogTargetGlobalHandlerImpl DeleteLogTargetHandlerImpl +) + +type ( + ReplaceLogTargetGlobalHandlerImpl ReplaceLogTargetHandlerImpl +) + +type ( + ReplaceAllLogTargetGlobalHandlerImpl ReplaceAllLogTargetHandlerImpl +) + +func (h *CreateLogTargetGlobalHandlerImpl) Handle(params log_target.CreateLogTargetGlobalParams, principal any) middleware.Responder { + g := CreateLogTargetHandlerImpl(*h) + paramsG := log_target.CreateLogTargetBackendParams{ + Data: params.Data, + HTTPRequest: params.HTTPRequest, + ForceReload: params.ForceReload, + Index: params.Index, + ParentName: "", // empty for Global + TransactionID: params.TransactionID, + Version: params.Version, + } + return g.Handle(cnconstants.GlobalParentType, paramsG, principal) +} + +func (h *GetLogTargetGlobalHandlerImpl) Handle(params log_target.GetLogTargetGlobalParams, principal any) middleware.Responder { + g := GetLogTargetHandlerImpl(*h) + paramsG := log_target.GetLogTargetBackendParams{ + HTTPRequest: params.HTTPRequest, + Index: params.Index, + ParentName: "", // empty for Global + TransactionID: params.TransactionID, + } + return g.Handle(cnconstants.GlobalParentType, paramsG, principal) +} + +func (h *GetAllLogTargetGlobalHandlerImpl) Handle(params log_target.GetAllLogTargetGlobalParams, principal any) middleware.Responder { + g := GetAllLogTargetHandlerImpl(*h) + paramsG := log_target.GetAllLogTargetBackendParams{ + HTTPRequest: params.HTTPRequest, + ParentName: "", // empty for Global + TransactionID: params.TransactionID, + } + return g.Handle(cnconstants.GlobalParentType, paramsG, principal) +} + +func (h *DeleteLogTargetGlobalHandlerImpl) Handle(params log_target.DeleteLogTargetGlobalParams, principal any) middleware.Responder { + g := DeleteLogTargetHandlerImpl(*h) + paramsG := log_target.DeleteLogTargetBackendParams{ + HTTPRequest: params.HTTPRequest, + ForceReload: params.ForceReload, + Index: params.Index, + ParentName: "", // empty for Global + TransactionID: params.TransactionID, + Version: params.Version, + } + return g.Handle(cnconstants.GlobalParentType, paramsG, principal) +} + +func (h *ReplaceLogTargetGlobalHandlerImpl) Handle(params log_target.ReplaceLogTargetGlobalParams, principal any) middleware.Responder { + g := ReplaceLogTargetHandlerImpl(*h) + paramsG := log_target.ReplaceLogTargetBackendParams{ + Data: params.Data, + HTTPRequest: params.HTTPRequest, + ForceReload: params.ForceReload, + Index: params.Index, + ParentName: "", // empty for Global + TransactionID: params.TransactionID, + Version: params.Version, + } + return g.Handle(cnconstants.GlobalParentType, paramsG, principal) +} + +func (h *ReplaceAllLogTargetGlobalHandlerImpl) Handle(params log_target.ReplaceAllLogTargetGlobalParams, principal any) middleware.Responder { + g := ReplaceAllLogTargetHandlerImpl(*h) + paramsG := log_target.ReplaceAllLogTargetBackendParams{ + Data: params.Data, + HTTPRequest: params.HTTPRequest, + ForceReload: params.ForceReload, + ParentName: "", // empty for Global + TransactionID: params.TransactionID, + Version: params.Version, + } + return g.Handle(cnconstants.GlobalParentType, paramsG, principal) +} diff --git a/handlers/parent_quic_initial_rule_generated.go b/handlers/parent_quic_initial_rule_generated.go new file mode 100644 index 00000000..53a5284c --- /dev/null +++ b/handlers/parent_quic_initial_rule_generated.go @@ -0,0 +1,117 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/quic_initial_rule" +) + +type ( + CreateQUICInitialRuleFrontendHandlerImpl CreateQUICInitialRuleHandlerImpl + CreateQUICInitialRuleDefaultsHandlerImpl CreateQUICInitialRuleHandlerImpl +) + +type ( + GetQUICInitialRuleFrontendHandlerImpl GetQUICInitialRuleHandlerImpl + GetQUICInitialRuleDefaultsHandlerImpl GetQUICInitialRuleHandlerImpl +) + +type ( + GetAllQUICInitialRuleFrontendHandlerImpl GetAllQUICInitialRuleHandlerImpl + GetAllQUICInitialRuleDefaultsHandlerImpl GetAllQUICInitialRuleHandlerImpl +) + +type ( + DeleteQUICInitialRuleFrontendHandlerImpl DeleteQUICInitialRuleHandlerImpl + DeleteQUICInitialRuleDefaultsHandlerImpl DeleteQUICInitialRuleHandlerImpl +) + +type ( + ReplaceQUICInitialRuleFrontendHandlerImpl ReplaceQUICInitialRuleHandlerImpl + ReplaceQUICInitialRuleDefaultsHandlerImpl ReplaceQUICInitialRuleHandlerImpl +) + +type ( + ReplaceAllQUICInitialRuleFrontendHandlerImpl ReplaceAllQUICInitialRuleHandlerImpl + ReplaceAllQUICInitialRuleDefaultsHandlerImpl ReplaceAllQUICInitialRuleHandlerImpl +) + +func (h *CreateQUICInitialRuleFrontendHandlerImpl) Handle(params quic_initial_rule.CreateQUICInitialRuleFrontendParams, principal any) middleware.Responder { + g := CreateQUICInitialRuleHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *CreateQUICInitialRuleDefaultsHandlerImpl) Handle(params quic_initial_rule.CreateQUICInitialRuleDefaultsParams, principal any) middleware.Responder { + g := CreateQUICInitialRuleHandlerImpl(*h) + pg := quic_initial_rule.CreateQUICInitialRuleFrontendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetQUICInitialRuleFrontendHandlerImpl) Handle(params quic_initial_rule.GetQUICInitialRuleFrontendParams, principal any) middleware.Responder { + g := GetQUICInitialRuleHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *GetQUICInitialRuleDefaultsHandlerImpl) Handle(params quic_initial_rule.GetQUICInitialRuleDefaultsParams, principal any) middleware.Responder { + g := GetQUICInitialRuleHandlerImpl(*h) + pg := quic_initial_rule.GetQUICInitialRuleFrontendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllQUICInitialRuleFrontendHandlerImpl) Handle(params quic_initial_rule.GetAllQUICInitialRuleFrontendParams, principal any) middleware.Responder { + g := GetAllQUICInitialRuleHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *GetAllQUICInitialRuleDefaultsHandlerImpl) Handle(params quic_initial_rule.GetAllQUICInitialRuleDefaultsParams, principal any) middleware.Responder { + g := GetAllQUICInitialRuleHandlerImpl(*h) + pg := quic_initial_rule.GetAllQUICInitialRuleFrontendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteQUICInitialRuleFrontendHandlerImpl) Handle(params quic_initial_rule.DeleteQUICInitialRuleFrontendParams, principal any) middleware.Responder { + g := DeleteQUICInitialRuleHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *DeleteQUICInitialRuleDefaultsHandlerImpl) Handle(params quic_initial_rule.DeleteQUICInitialRuleDefaultsParams, principal any) middleware.Responder { + g := DeleteQUICInitialRuleHandlerImpl(*h) + pg := quic_initial_rule.DeleteQUICInitialRuleFrontendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceQUICInitialRuleFrontendHandlerImpl) Handle(params quic_initial_rule.ReplaceQUICInitialRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceQUICInitialRuleHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *ReplaceQUICInitialRuleDefaultsHandlerImpl) Handle(params quic_initial_rule.ReplaceQUICInitialRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceQUICInitialRuleHandlerImpl(*h) + pg := quic_initial_rule.ReplaceQUICInitialRuleFrontendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllQUICInitialRuleFrontendHandlerImpl) Handle(params quic_initial_rule.ReplaceAllQUICInitialRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceAllQUICInitialRuleHandlerImpl(*h) + return g.Handle(cnconstants.FrontendParentType, params, principal) +} + +func (h *ReplaceAllQUICInitialRuleDefaultsHandlerImpl) Handle(params quic_initial_rule.ReplaceAllQUICInitialRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllQUICInitialRuleHandlerImpl(*h) + pg := quic_initial_rule.ReplaceAllQUICInitialRuleFrontendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_server_generated.go b/handlers/parent_server_generated.go new file mode 100644 index 00000000..147ddbd1 --- /dev/null +++ b/handlers/parent_server_generated.go @@ -0,0 +1,136 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/server" +) + +type ( + CreateServerBackendHandlerImpl CreateServerHandlerImpl + CreateServerPeerHandlerImpl CreateServerHandlerImpl + CreateServerRingHandlerImpl CreateServerHandlerImpl +) + +type ( + GetServerBackendHandlerImpl GetServerHandlerImpl + GetServerPeerHandlerImpl GetServerHandlerImpl + GetServerRingHandlerImpl GetServerHandlerImpl +) + +type ( + GetAllServerBackendHandlerImpl GetAllServerHandlerImpl + GetAllServerPeerHandlerImpl GetAllServerHandlerImpl + GetAllServerRingHandlerImpl GetAllServerHandlerImpl +) + +type ( + DeleteServerBackendHandlerImpl DeleteServerHandlerImpl + DeleteServerPeerHandlerImpl DeleteServerHandlerImpl + DeleteServerRingHandlerImpl DeleteServerHandlerImpl +) + +type ( + ReplaceServerBackendHandlerImpl ReplaceServerHandlerImpl + ReplaceServerPeerHandlerImpl ReplaceServerHandlerImpl + ReplaceServerRingHandlerImpl ReplaceServerHandlerImpl +) + +func (h *CreateServerBackendHandlerImpl) Handle(params server.CreateServerBackendParams, principal any) middleware.Responder { + g := CreateServerHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateServerPeerHandlerImpl) Handle(params server.CreateServerPeerParams, principal any) middleware.Responder { + g := CreateServerHandlerImpl(*h) + pg := server.CreateServerBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *CreateServerRingHandlerImpl) Handle(params server.CreateServerRingParams, principal any) middleware.Responder { + g := CreateServerHandlerImpl(*h) + pg := server.CreateServerBackendParams(params) + return g.Handle(cnconstants.RingParentType, pg, principal) +} + +func (h *GetServerBackendHandlerImpl) Handle(params server.GetServerBackendParams, principal any) middleware.Responder { + g := GetServerHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetServerPeerHandlerImpl) Handle(params server.GetServerPeerParams, principal any) middleware.Responder { + g := GetServerHandlerImpl(*h) + pg := server.GetServerBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *GetServerRingHandlerImpl) Handle(params server.GetServerRingParams, principal any) middleware.Responder { + g := GetServerHandlerImpl(*h) + pg := server.GetServerBackendParams(params) + return g.Handle(cnconstants.RingParentType, pg, principal) +} + +func (h *GetAllServerBackendHandlerImpl) Handle(params server.GetAllServerBackendParams, principal any) middleware.Responder { + g := GetAllServerHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllServerPeerHandlerImpl) Handle(params server.GetAllServerPeerParams, principal any) middleware.Responder { + g := GetAllServerHandlerImpl(*h) + pg := server.GetAllServerBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *GetAllServerRingHandlerImpl) Handle(params server.GetAllServerRingParams, principal any) middleware.Responder { + g := GetAllServerHandlerImpl(*h) + pg := server.GetAllServerBackendParams(params) + return g.Handle(cnconstants.RingParentType, pg, principal) +} + +func (h *DeleteServerBackendHandlerImpl) Handle(params server.DeleteServerBackendParams, principal any) middleware.Responder { + g := DeleteServerHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteServerPeerHandlerImpl) Handle(params server.DeleteServerPeerParams, principal any) middleware.Responder { + g := DeleteServerHandlerImpl(*h) + pg := server.DeleteServerBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *DeleteServerRingHandlerImpl) Handle(params server.DeleteServerRingParams, principal any) middleware.Responder { + g := DeleteServerHandlerImpl(*h) + pg := server.DeleteServerBackendParams(params) + return g.Handle(cnconstants.RingParentType, pg, principal) +} + +func (h *ReplaceServerBackendHandlerImpl) Handle(params server.ReplaceServerBackendParams, principal any) middleware.Responder { + g := ReplaceServerHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceServerPeerHandlerImpl) Handle(params server.ReplaceServerPeerParams, principal any) middleware.Responder { + g := ReplaceServerHandlerImpl(*h) + pg := server.ReplaceServerBackendParams(params) + return g.Handle(cnconstants.PeerParentType, pg, principal) +} + +func (h *ReplaceServerRingHandlerImpl) Handle(params server.ReplaceServerRingParams, principal any) middleware.Responder { + g := ReplaceServerHandlerImpl(*h) + pg := server.ReplaceServerBackendParams(params) + return g.Handle(cnconstants.RingParentType, pg, principal) +} diff --git a/handlers/parent_tcp_check_generated.go b/handlers/parent_tcp_check_generated.go new file mode 100644 index 00000000..26458608 --- /dev/null +++ b/handlers/parent_tcp_check_generated.go @@ -0,0 +1,117 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/tcp_check" +) + +type ( + CreateTCPCheckBackendHandlerImpl CreateTCPCheckHandlerImpl + CreateTCPCheckDefaultsHandlerImpl CreateTCPCheckHandlerImpl +) + +type ( + GetTCPCheckBackendHandlerImpl GetTCPCheckHandlerImpl + GetTCPCheckDefaultsHandlerImpl GetTCPCheckHandlerImpl +) + +type ( + GetAllTCPCheckBackendHandlerImpl GetAllTCPCheckHandlerImpl + GetAllTCPCheckDefaultsHandlerImpl GetAllTCPCheckHandlerImpl +) + +type ( + DeleteTCPCheckBackendHandlerImpl DeleteTCPCheckHandlerImpl + DeleteTCPCheckDefaultsHandlerImpl DeleteTCPCheckHandlerImpl +) + +type ( + ReplaceTCPCheckBackendHandlerImpl ReplaceTCPCheckHandlerImpl + ReplaceTCPCheckDefaultsHandlerImpl ReplaceTCPCheckHandlerImpl +) + +type ( + ReplaceAllTCPCheckBackendHandlerImpl ReplaceAllTCPCheckHandlerImpl + ReplaceAllTCPCheckDefaultsHandlerImpl ReplaceAllTCPCheckHandlerImpl +) + +func (h *CreateTCPCheckBackendHandlerImpl) Handle(params tcp_check.CreateTCPCheckBackendParams, principal any) middleware.Responder { + g := CreateTCPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateTCPCheckDefaultsHandlerImpl) Handle(params tcp_check.CreateTCPCheckDefaultsParams, principal any) middleware.Responder { + g := CreateTCPCheckHandlerImpl(*h) + pg := tcp_check.CreateTCPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetTCPCheckBackendHandlerImpl) Handle(params tcp_check.GetTCPCheckBackendParams, principal any) middleware.Responder { + g := GetTCPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetTCPCheckDefaultsHandlerImpl) Handle(params tcp_check.GetTCPCheckDefaultsParams, principal any) middleware.Responder { + g := GetTCPCheckHandlerImpl(*h) + pg := tcp_check.GetTCPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllTCPCheckBackendHandlerImpl) Handle(params tcp_check.GetAllTCPCheckBackendParams, principal any) middleware.Responder { + g := GetAllTCPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllTCPCheckDefaultsHandlerImpl) Handle(params tcp_check.GetAllTCPCheckDefaultsParams, principal any) middleware.Responder { + g := GetAllTCPCheckHandlerImpl(*h) + pg := tcp_check.GetAllTCPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteTCPCheckBackendHandlerImpl) Handle(params tcp_check.DeleteTCPCheckBackendParams, principal any) middleware.Responder { + g := DeleteTCPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteTCPCheckDefaultsHandlerImpl) Handle(params tcp_check.DeleteTCPCheckDefaultsParams, principal any) middleware.Responder { + g := DeleteTCPCheckHandlerImpl(*h) + pg := tcp_check.DeleteTCPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceTCPCheckBackendHandlerImpl) Handle(params tcp_check.ReplaceTCPCheckBackendParams, principal any) middleware.Responder { + g := ReplaceTCPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceTCPCheckDefaultsHandlerImpl) Handle(params tcp_check.ReplaceTCPCheckDefaultsParams, principal any) middleware.Responder { + g := ReplaceTCPCheckHandlerImpl(*h) + pg := tcp_check.ReplaceTCPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllTCPCheckBackendHandlerImpl) Handle(params tcp_check.ReplaceAllTCPCheckBackendParams, principal any) middleware.Responder { + g := ReplaceAllTCPCheckHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllTCPCheckDefaultsHandlerImpl) Handle(params tcp_check.ReplaceAllTCPCheckDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllTCPCheckHandlerImpl(*h) + pg := tcp_check.ReplaceAllTCPCheckBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_tcp_request_rule_generated.go b/handlers/parent_tcp_request_rule_generated.go new file mode 100644 index 00000000..a6ed2670 --- /dev/null +++ b/handlers/parent_tcp_request_rule_generated.go @@ -0,0 +1,159 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/tcp_request_rule" +) + +type ( + CreateTCPRequestRuleBackendHandlerImpl CreateTCPRequestRuleHandlerImpl + CreateTCPRequestRuleFrontendHandlerImpl CreateTCPRequestRuleHandlerImpl + CreateTCPRequestRuleDefaultsHandlerImpl CreateTCPRequestRuleHandlerImpl +) + +type ( + GetTCPRequestRuleBackendHandlerImpl GetTCPRequestRuleHandlerImpl + GetTCPRequestRuleFrontendHandlerImpl GetTCPRequestRuleHandlerImpl + GetTCPRequestRuleDefaultsHandlerImpl GetTCPRequestRuleHandlerImpl +) + +type ( + GetAllTCPRequestRuleBackendHandlerImpl GetAllTCPRequestRuleHandlerImpl + GetAllTCPRequestRuleFrontendHandlerImpl GetAllTCPRequestRuleHandlerImpl + GetAllTCPRequestRuleDefaultsHandlerImpl GetAllTCPRequestRuleHandlerImpl +) + +type ( + DeleteTCPRequestRuleBackendHandlerImpl DeleteTCPRequestRuleHandlerImpl + DeleteTCPRequestRuleFrontendHandlerImpl DeleteTCPRequestRuleHandlerImpl + DeleteTCPRequestRuleDefaultsHandlerImpl DeleteTCPRequestRuleHandlerImpl +) + +type ( + ReplaceTCPRequestRuleBackendHandlerImpl ReplaceTCPRequestRuleHandlerImpl + ReplaceTCPRequestRuleFrontendHandlerImpl ReplaceTCPRequestRuleHandlerImpl + ReplaceTCPRequestRuleDefaultsHandlerImpl ReplaceTCPRequestRuleHandlerImpl +) + +type ( + ReplaceAllTCPRequestRuleBackendHandlerImpl ReplaceAllTCPRequestRuleHandlerImpl + ReplaceAllTCPRequestRuleFrontendHandlerImpl ReplaceAllTCPRequestRuleHandlerImpl + ReplaceAllTCPRequestRuleDefaultsHandlerImpl ReplaceAllTCPRequestRuleHandlerImpl +) + +func (h *CreateTCPRequestRuleBackendHandlerImpl) Handle(params tcp_request_rule.CreateTCPRequestRuleBackendParams, principal any) middleware.Responder { + g := CreateTCPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateTCPRequestRuleFrontendHandlerImpl) Handle(params tcp_request_rule.CreateTCPRequestRuleFrontendParams, principal any) middleware.Responder { + g := CreateTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.CreateTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *CreateTCPRequestRuleDefaultsHandlerImpl) Handle(params tcp_request_rule.CreateTCPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := CreateTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.CreateTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetTCPRequestRuleBackendHandlerImpl) Handle(params tcp_request_rule.GetTCPRequestRuleBackendParams, principal any) middleware.Responder { + g := GetTCPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetTCPRequestRuleFrontendHandlerImpl) Handle(params tcp_request_rule.GetTCPRequestRuleFrontendParams, principal any) middleware.Responder { + g := GetTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.GetTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetTCPRequestRuleDefaultsHandlerImpl) Handle(params tcp_request_rule.GetTCPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := GetTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.GetTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllTCPRequestRuleBackendHandlerImpl) Handle(params tcp_request_rule.GetAllTCPRequestRuleBackendParams, principal any) middleware.Responder { + g := GetAllTCPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllTCPRequestRuleFrontendHandlerImpl) Handle(params tcp_request_rule.GetAllTCPRequestRuleFrontendParams, principal any) middleware.Responder { + g := GetAllTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.GetAllTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *GetAllTCPRequestRuleDefaultsHandlerImpl) Handle(params tcp_request_rule.GetAllTCPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := GetAllTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.GetAllTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteTCPRequestRuleBackendHandlerImpl) Handle(params tcp_request_rule.DeleteTCPRequestRuleBackendParams, principal any) middleware.Responder { + g := DeleteTCPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteTCPRequestRuleFrontendHandlerImpl) Handle(params tcp_request_rule.DeleteTCPRequestRuleFrontendParams, principal any) middleware.Responder { + g := DeleteTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.DeleteTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *DeleteTCPRequestRuleDefaultsHandlerImpl) Handle(params tcp_request_rule.DeleteTCPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := DeleteTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.DeleteTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceTCPRequestRuleBackendHandlerImpl) Handle(params tcp_request_rule.ReplaceTCPRequestRuleBackendParams, principal any) middleware.Responder { + g := ReplaceTCPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceTCPRequestRuleFrontendHandlerImpl) Handle(params tcp_request_rule.ReplaceTCPRequestRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.ReplaceTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceTCPRequestRuleDefaultsHandlerImpl) Handle(params tcp_request_rule.ReplaceTCPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.ReplaceTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllTCPRequestRuleBackendHandlerImpl) Handle(params tcp_request_rule.ReplaceAllTCPRequestRuleBackendParams, principal any) middleware.Responder { + g := ReplaceAllTCPRequestRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllTCPRequestRuleFrontendHandlerImpl) Handle(params tcp_request_rule.ReplaceAllTCPRequestRuleFrontendParams, principal any) middleware.Responder { + g := ReplaceAllTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.ReplaceAllTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.FrontendParentType, pg, principal) +} + +func (h *ReplaceAllTCPRequestRuleDefaultsHandlerImpl) Handle(params tcp_request_rule.ReplaceAllTCPRequestRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllTCPRequestRuleHandlerImpl(*h) + pg := tcp_request_rule.ReplaceAllTCPRequestRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/parent_tcp_response_rule_generated.go b/handlers/parent_tcp_response_rule_generated.go new file mode 100644 index 00000000..6835d06d --- /dev/null +++ b/handlers/parent_tcp_response_rule_generated.go @@ -0,0 +1,117 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/operations/tcp_response_rule" +) + +type ( + CreateTCPResponseRuleBackendHandlerImpl CreateTCPResponseRuleHandlerImpl + CreateTCPResponseRuleDefaultsHandlerImpl CreateTCPResponseRuleHandlerImpl +) + +type ( + GetTCPResponseRuleBackendHandlerImpl GetTCPResponseRuleHandlerImpl + GetTCPResponseRuleDefaultsHandlerImpl GetTCPResponseRuleHandlerImpl +) + +type ( + GetAllTCPResponseRuleBackendHandlerImpl GetAllTCPResponseRuleHandlerImpl + GetAllTCPResponseRuleDefaultsHandlerImpl GetAllTCPResponseRuleHandlerImpl +) + +type ( + DeleteTCPResponseRuleBackendHandlerImpl DeleteTCPResponseRuleHandlerImpl + DeleteTCPResponseRuleDefaultsHandlerImpl DeleteTCPResponseRuleHandlerImpl +) + +type ( + ReplaceTCPResponseRuleBackendHandlerImpl ReplaceTCPResponseRuleHandlerImpl + ReplaceTCPResponseRuleDefaultsHandlerImpl ReplaceTCPResponseRuleHandlerImpl +) + +type ( + ReplaceAllTCPResponseRuleBackendHandlerImpl ReplaceAllTCPResponseRuleHandlerImpl + ReplaceAllTCPResponseRuleDefaultsHandlerImpl ReplaceAllTCPResponseRuleHandlerImpl +) + +func (h *CreateTCPResponseRuleBackendHandlerImpl) Handle(params tcp_response_rule.CreateTCPResponseRuleBackendParams, principal any) middleware.Responder { + g := CreateTCPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *CreateTCPResponseRuleDefaultsHandlerImpl) Handle(params tcp_response_rule.CreateTCPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := CreateTCPResponseRuleHandlerImpl(*h) + pg := tcp_response_rule.CreateTCPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetTCPResponseRuleBackendHandlerImpl) Handle(params tcp_response_rule.GetTCPResponseRuleBackendParams, principal any) middleware.Responder { + g := GetTCPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetTCPResponseRuleDefaultsHandlerImpl) Handle(params tcp_response_rule.GetTCPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := GetTCPResponseRuleHandlerImpl(*h) + pg := tcp_response_rule.GetTCPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *GetAllTCPResponseRuleBackendHandlerImpl) Handle(params tcp_response_rule.GetAllTCPResponseRuleBackendParams, principal any) middleware.Responder { + g := GetAllTCPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *GetAllTCPResponseRuleDefaultsHandlerImpl) Handle(params tcp_response_rule.GetAllTCPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := GetAllTCPResponseRuleHandlerImpl(*h) + pg := tcp_response_rule.GetAllTCPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *DeleteTCPResponseRuleBackendHandlerImpl) Handle(params tcp_response_rule.DeleteTCPResponseRuleBackendParams, principal any) middleware.Responder { + g := DeleteTCPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *DeleteTCPResponseRuleDefaultsHandlerImpl) Handle(params tcp_response_rule.DeleteTCPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := DeleteTCPResponseRuleHandlerImpl(*h) + pg := tcp_response_rule.DeleteTCPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceTCPResponseRuleBackendHandlerImpl) Handle(params tcp_response_rule.ReplaceTCPResponseRuleBackendParams, principal any) middleware.Responder { + g := ReplaceTCPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceTCPResponseRuleDefaultsHandlerImpl) Handle(params tcp_response_rule.ReplaceTCPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceTCPResponseRuleHandlerImpl(*h) + pg := tcp_response_rule.ReplaceTCPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} + +func (h *ReplaceAllTCPResponseRuleBackendHandlerImpl) Handle(params tcp_response_rule.ReplaceAllTCPResponseRuleBackendParams, principal any) middleware.Responder { + g := ReplaceAllTCPResponseRuleHandlerImpl(*h) + return g.Handle(cnconstants.BackendParentType, params, principal) +} + +func (h *ReplaceAllTCPResponseRuleDefaultsHandlerImpl) Handle(params tcp_response_rule.ReplaceAllTCPResponseRuleDefaultsParams, principal any) middleware.Responder { + g := ReplaceAllTCPResponseRuleHandlerImpl(*h) + pg := tcp_response_rule.ReplaceAllTCPResponseRuleBackendParams(params) + return g.Handle(cnconstants.DefaultsParentType, pg, principal) +} diff --git a/handlers/peer.go b/handlers/peer.go new file mode 100644 index 00000000..de53734c --- /dev/null +++ b/handlers/peer.go @@ -0,0 +1,206 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/peer" +) + +// CreatePeerHandlerImpl implementation of the CreatePeerHandler interface using client-native client +type CreatePeerHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeletePeerHandlerImpl implementation of the DeletePeerHandler interface using client-native client +type DeletePeerHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetPeerHandlerImpl implementation of the GetPeerHandler interface using client-native client +type GetPeerHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetPeersHandlerImpl implementation of the GetPeersHandler interface using client-native client +type GetPeersHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplacePeerHandlerImpl implementation of the ReplacePeerHandler interface using client-native client +type ReplacePeerHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreatePeerHandlerImpl) Handle(params peer.CreatePeerParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return peer.NewCreatePeerDefault(int(*e.Code)).WithPayload(e) + } + + err := h.createPeerSection(params, t, v) + if err != nil { + e := misc.HandleError(err) + return peer.NewCreatePeerDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return peer.NewCreatePeerDefault(int(*e.Code)).WithPayload(e) + } + return peer.NewCreatePeerCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return peer.NewCreatePeerAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return peer.NewCreatePeerAccepted().WithPayload(params.Data) +} + +func (h *CreatePeerHandlerImpl) createPeerSection(params peer.CreatePeerParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredPeerSection(params.Data, t, v) + } + return configuration.CreatePeerSection(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeletePeerHandlerImpl) Handle(params peer.DeletePeerParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return peer.NewDeletePeerDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return peer.NewDeletePeerDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeletePeerSection(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return peer.NewDeletePeerDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return peer.NewDeletePeerDefault(int(*e.Code)).WithPayload(e) + } + return peer.NewDeletePeerNoContent() + } + rID := h.ReloadAgent.Reload() + return peer.NewDeletePeerAccepted().WithReloadID(rID) + } + return peer.NewDeletePeerAccepted() +} + +// Handle executing the request and returning a response +func (h *GetPeerHandlerImpl) Handle(params peer.GetPeerSectionParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, p, err := h.getPeerSection(params, t) + if err != nil { + e := misc.HandleError(err) + return peer.NewGetPeerSectionDefault(int(*e.Code)).WithPayload(e) + } + return peer.NewGetPeerSectionOK().WithPayload(p) +} + +func (h *GetPeerHandlerImpl) getPeerSection(params peer.GetPeerSectionParams, t string) (int64, *models.PeerSection, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredPeerSection(params.Name, t) + } + return configuration.GetPeerSection(params.Name, t) +} + +// Handle executing the request and returning a response +func (h *GetPeersHandlerImpl) Handle(params peer.GetPeerSectionsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, ps, err := h.getPeerSections(params, t) + if err != nil { + e := misc.HandleError(err) + return peer.NewGetPeerSectionsDefault(int(*e.Code)).WithPayload(e) + } + return peer.NewGetPeerSectionsOK().WithPayload(ps) +} + +func (h *GetPeersHandlerImpl) getPeerSections(params peer.GetPeerSectionsParams, t string) (int64, models.PeerSections, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredPeerSections(t) + } + return configuration.GetPeerSections(t) +} diff --git a/handlers/peer_entry.go b/handlers/peer_entry.go new file mode 100644 index 00000000..ec00a3c9 --- /dev/null +++ b/handlers/peer_entry.go @@ -0,0 +1,237 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/peer_entry" +) + +// CreatePeerEntryHandlerImpl implementation of the CreatePeerEntryHandler interface using client-native client +type CreatePeerEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeletePeerEntryHandlerImpl implementation of the DeletePeerEntryHandler interface using client-native client +type DeletePeerEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetPeerEntryHandlerImpl implementation of the GetPeerEntryHandler interface using client-native client +type GetPeerEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetPeerEntriesHandlerImpl implementation of the GetPeerEntriesHandler interface using client-native client +type GetPeerEntriesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplacePeerEntryHandlerImpl implementation of the ReplacePeerEntryHandler interface using client-native client +type ReplacePeerEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreatePeerEntryHandlerImpl) Handle(params peer_entry.CreatePeerEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return peer_entry.NewCreatePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewCreatePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreatePeerEntry(params.PeerSection, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewCreatePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewCreatePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + return peer_entry.NewCreatePeerEntryCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return peer_entry.NewCreatePeerEntryAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return peer_entry.NewCreatePeerEntryAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeletePeerEntryHandlerImpl) Handle(params peer_entry.DeletePeerEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return peer_entry.NewDeletePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewDeletePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeletePeerEntry(params.Name, params.PeerSection, t, v) + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewDeletePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewDeletePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + return peer_entry.NewDeletePeerEntryNoContent() + } + rID := h.ReloadAgent.Reload() + return peer_entry.NewDeletePeerEntryAccepted().WithReloadID(rID) + } + return peer_entry.NewDeletePeerEntryAccepted() +} + +// Handle executing the request and returning a response +func (h *GetPeerEntryHandlerImpl) Handle(params peer_entry.GetPeerEntryParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewGetPeerEntryDefault(int(*e.Code)).WithPayload(e) + } + + _, pe, err := configuration.GetPeerEntry(params.Name, params.PeerSection, t) + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewGetPeerEntryDefault(int(*e.Code)).WithPayload(e) + } + return peer_entry.NewGetPeerEntryOK().WithPayload(pe) +} + +// Handle executing the request and returning a response +func (h *GetPeerEntriesHandlerImpl) Handle(params peer_entry.GetPeerEntriesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewGetPeerEntriesDefault(int(*e.Code)).WithPayload(e) + } + + _, pes, err := configuration.GetPeerEntries(params.PeerSection, t) + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewGetPeerEntriesDefault(int(*e.Code)).WithPayload(e) + } + return peer_entry.NewGetPeerEntriesOK().WithPayload(pes) +} + +// Handle executing the request and returning a response +func (h *ReplacePeerEntryHandlerImpl) Handle(params peer_entry.ReplacePeerEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return peer_entry.NewReplacePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewReplacePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditPeerEntry(params.Name, params.PeerSection, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewReplacePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return peer_entry.NewReplacePeerEntryDefault(int(*e.Code)).WithPayload(e) + } + return peer_entry.NewReplacePeerEntryOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return peer_entry.NewReplacePeerEntryAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return peer_entry.NewReplacePeerEntryAccepted().WithPayload(params.Data) +} diff --git a/handlers/program.go b/handlers/program.go new file mode 100644 index 00000000..915db1a4 --- /dev/null +++ b/handlers/program.go @@ -0,0 +1,250 @@ +// Copyright 2022 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/process_manager" +) + +type DeleteProgramHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (d DeleteProgramHandlerImpl) Handle(params process_manager.DeleteProgramParams, _ any) middleware.Responder { + var t string + var v int64 + + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + code := misc.ErrHTTPBadRequest + + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: &code, + } + + return process_manager.NewDeleteProgramDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := d.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return process_manager.NewDeleteProgramDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.DeleteProgram(params.Name, t, v); err != nil { + e := misc.HandleError(err) + return process_manager.NewDeleteProgramDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = d.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + + return process_manager.NewDeleteProgramDefault(int(*e.Code)).WithPayload(e) + } + + return process_manager.NewDeleteProgramNoContent() + } + + return process_manager.NewDeleteProgramAccepted().WithReloadID(d.ReloadAgent.Reload()) + } + + return process_manager.NewDeleteProgramAccepted() +} + +type CreateProgramHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (c CreateProgramHandlerImpl) Handle(params process_manager.CreateProgramParams, _ any) middleware.Responder { + var t string + var v int64 + + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + code := misc.ErrHTTPBadRequest + + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: &code, + } + + return process_manager.NewCreateProgramDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := c.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return process_manager.NewCreateProgramDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateProgram(params.Data, t, v); err != nil { + e := misc.HandleError(err) + return process_manager.NewCreateProgramDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = c.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + + return process_manager.NewCreateProgramDefault(int(*e.Code)).WithPayload(e) + } + + return process_manager.NewCreateProgramCreated().WithPayload(params.Data) + } + + return process_manager.NewCreateProgramAccepted().WithReloadID(c.ReloadAgent.Reload()).WithPayload(params.Data) + } + + return process_manager.NewCreateProgramAccepted().WithPayload(params.Data) +} + +type GetProgramHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetProgramHandlerImpl) Handle(params process_manager.GetProgramParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := g.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + + return process_manager.NewGetProgramDefault(int(*e.Code)).WithPayload(e) + } + + _, r, err := configuration.GetProgram(params.Name, t) + if err != nil { + e := misc.HandleError(err) + + return process_manager.NewGetProgramDefault(int(*e.Code)).WithPayload(e) + } + + return process_manager.NewGetProgramOK().WithPayload(r) +} + +type GetProgramsHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetProgramsHandlerImpl) Handle(params process_manager.GetProgramsParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := g.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + + return process_manager.NewGetProgramsDefault(int(*e.Code)).WithPayload(e) + } + + _, r, err := configuration.GetPrograms(t) + if err != nil { + e := misc.HandleError(err) + + return process_manager.NewGetProgramsDefault(int(*e.Code)).WithPayload(e) + } + + return process_manager.NewGetProgramsOK().WithPayload(r) +} + +type ReplaceProgramHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (r ReplaceProgramHandlerImpl) Handle(params process_manager.ReplaceProgramParams, _ any) middleware.Responder { + var t string + var v int64 + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + code := misc.ErrHTTPBadRequest + + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: &code, + } + + return process_manager.NewReplaceProgramDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := r.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + + return process_manager.NewReplaceProgramDefault(int(*e.Code)).WithPayload(e) + } + + params.Data.Name = params.Name + + if err = configuration.EditProgram(params.Name, params.Data, t, v); err != nil { + e := misc.HandleError(err) + + return process_manager.NewReplaceProgramDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = r.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + + return process_manager.NewReplaceProgramDefault(int(*e.Code)).WithPayload(e) + } + + return process_manager.NewReplaceProgramOK().WithPayload(params.Data) + } + + return process_manager.NewReplaceProgramAccepted().WithReloadID(r.ReloadAgent.Reload()).WithPayload(params.Data) + } + + return process_manager.NewReplaceProgramAccepted().WithPayload(params.Data) +} diff --git a/handlers/quic_initial_rule.go b/handlers/quic_initial_rule.go new file mode 100644 index 00000000..a6c6493e --- /dev/null +++ b/handlers/quic_initial_rule.go @@ -0,0 +1,269 @@ +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/quic_initial_rule" +) + +type CreateQUICInitialRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (c CreateQUICInitialRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params quic_initial_rule.CreateQUICInitialRuleFrontendParams, _ any) middleware.Responder { + t, v := "", int64(0) + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return quic_initial_rule.NewCreateQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := c.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewCreateQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateQUICInitialRule(params.Index, string(parentType), params.ParentName, params.Data, t, v); err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewCreateQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = c.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewCreateQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + return quic_initial_rule.NewCreateQUICInitialRuleFrontendCreated().WithPayload(params.Data) + } + + return quic_initial_rule.NewCreateQUICInitialRuleFrontendAccepted().WithReloadID(c.ReloadAgent.Reload()).WithPayload(params.Data) + } + + return quic_initial_rule.NewCreateQUICInitialRuleFrontendAccepted().WithPayload(params.Data) +} + +type DeleteQUICInitialRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (d DeleteQUICInitialRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params quic_initial_rule.DeleteQUICInitialRuleFrontendParams, _ any) middleware.Responder { + t, v := "", int64(0) + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return quic_initial_rule.NewDeleteQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := d.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewDeleteQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.DeleteQUICInitialRule(params.Index, string(parentType), params.ParentName, t, v); err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewDeleteQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = d.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewDeleteQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + return quic_initial_rule.NewDeleteQUICInitialRuleFrontendNoContent() + } + + return quic_initial_rule.NewDeleteQUICInitialRuleFrontendAccepted().WithReloadID(d.ReloadAgent.Reload()) + } + + return quic_initial_rule.NewDeleteQUICInitialRuleFrontendAccepted() +} + +type GetQUICInitialRuleHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetQUICInitialRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params quic_initial_rule.GetQUICInitialRuleFrontendParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := g.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewGetQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + _, rule, err := configuration.GetQUICInitialRule(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewGetQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + return quic_initial_rule.NewGetQUICInitialRuleFrontendOK().WithPayload(rule) +} + +type GetAllQUICInitialRuleHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (g GetAllQUICInitialRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params quic_initial_rule.GetAllQUICInitialRuleFrontendParams, _ any) middleware.Responder { + var t string + + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := g.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewGetAllQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetQUICInitialRules(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewGetAllQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + return quic_initial_rule.NewGetAllQUICInitialRuleFrontendOK().WithPayload(rules) +} + +type ReplaceQUICInitialRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (r ReplaceQUICInitialRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params quic_initial_rule.ReplaceQUICInitialRuleFrontendParams, _ any) middleware.Responder { + t, v := "", int64(0) + + if params.TransactionID != nil { + t = *params.TransactionID + } + + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + e := &models.Error{ + Message: misc.StringP("Both force_reload and transaction specified, specify only one"), + Code: misc.Int64P(int(misc.ErrHTTPBadRequest)), + } + return quic_initial_rule.NewReplaceQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := r.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewReplaceQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.EditQUICInitialRule(params.Index, string(parentType), params.ParentName, params.Data, t, v); err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewReplaceQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + if err = r.ReloadAgent.ForceReload(); err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewReplaceQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + return quic_initial_rule.NewReplaceQUICInitialRuleFrontendOK().WithPayload(params.Data) + } + + return quic_initial_rule.NewReplaceQUICInitialRuleFrontendAccepted().WithReloadID(r.ReloadAgent.Reload()).WithPayload(params.Data) + } + + return quic_initial_rule.NewReplaceQUICInitialRuleFrontendAccepted().WithPayload(params.Data) +} + +type ReplaceAllQUICInitialRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *ReplaceAllQUICInitialRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params quic_initial_rule.ReplaceAllQUICInitialRuleFrontendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return quic_initial_rule.NewReplaceAllQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewReplaceAllQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceQUICInitialRules(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewReplaceAllQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return quic_initial_rule.NewReplaceAllQUICInitialRuleFrontendDefault(int(*e.Code)).WithPayload(e) + } + return quic_initial_rule.NewReplaceAllQUICInitialRuleFrontendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return quic_initial_rule.NewReplaceAllQUICInitialRuleFrontendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return quic_initial_rule.NewReplaceAllQUICInitialRuleFrontendAccepted().WithPayload(params.Data) +} diff --git a/handlers/raw.go b/handlers/raw.go index 9a0d00d4..01fe1e05 100644 --- a/handlers/raw.go +++ b/handlers/raw.go @@ -16,27 +16,34 @@ package handlers import ( - "github.com/go-openapi/runtime/middleware" + "encoding/json" + "fmt" + "net/http" + "strconv" + "strings" - client_native "github.com/haproxytech/client-native" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + cn "github.com/haproxytech/dataplaneapi/client-native" "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/configuration" ) -//GetRawConfigurationHandlerImpl implementation of the GetHAProxyConfigurationHandler interface +// GetRawConfigurationHandlerImpl implementation of the GetHAProxyConfigurationHandler interface type GetRawConfigurationHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } // PostRawConfigurationHandlerImpl implementation of the PostHAProxyConfigurationHandler interface type PostRawConfigurationHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *GetRawConfigurationHandlerImpl) Handle(params configuration.GetHAProxyConfigurationParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetRawConfigurationHandlerImpl) Handle(params configuration.GetHAProxyConfigurationParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID @@ -47,34 +54,282 @@ func (h *GetRawConfigurationHandlerImpl) Handle(params configuration.GetHAProxyC v = *params.Version } - v, data, err := h.Client.Configuration.GetRawConfiguration(t, v) + cfg, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return configuration.NewGetHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return configuration.NewGetConfigurationVersionDefault(int(*e.Code)).WithPayload(e) + } + + _, clusterVersion, md5Hash, data, err := cfg.GetRawConfigurationWithClusterData(t, v) + if err != nil { + e := misc.HandleError(err) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewGetHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) } - return configuration.NewGetHAProxyConfigurationOK().WithPayload(&configuration.GetHAProxyConfigurationOKBody{Version: v, Data: &data}).WithConfigurationVersion(v) + cVersion := "" + if clusterVersion != 0 { + cVersion = strconv.FormatInt(clusterVersion, 10) + } + return configuration.NewGetHAProxyConfigurationOK().WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash) } -//Handle executing the request and returning a response -func (h *PostRawConfigurationHandlerImpl) Handle(params configuration.PostHAProxyConfigurationParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *PostRawConfigurationHandlerImpl) Handle(params configuration.PostHAProxyConfigurationParams, principal any) middleware.Responder { v := int64(0) if params.Version != nil { v = *params.Version } + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + skipVersion := false + if params.SkipVersion != nil { + skipVersion = *params.SkipVersion + } + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + onlyValidate := false + if params.OnlyValidate != nil { + onlyValidate = *params.OnlyValidate + } - err := h.Client.Configuration.PostRawConfiguration(¶ms.Data, v) + // Check for a common error where the user ran `curl -d @haproxy.cfg` without + // converting the file to json, which removes all the \n from the configuration. + if len(params.Data) > 0 && !strings.ContainsRune(params.Data, '\n') { + code := misc.ErrHTTPBadRequest + msg := "invalid configuration: no newline character found" + e := &models.Error{Code: &code, Message: &msg} + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationBadRequest().WithPayload(string(errorStr)) + } + + cfg, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) + } + + err = cfg.PostRawConfiguration(¶ms.Data, v, skipVersion, onlyValidate) if err != nil { e := misc.HandleError(err) - return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) } - if *params.ForceReload { - err := h.ReloadAgent.ForceReload() + + _, clusterVersion, md5Hash, data, err := cfg.GetRawConfigurationWithClusterData("", 0) + if err != nil { + e := misc.HandleError(err) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) + } + + cVersion := "" + if clusterVersion != 0 { + cVersion = strconv.FormatInt(clusterVersion, 10) + } + if onlyValidate { + // return here without reloading, since config is only validated. + return configuration.NewPostHAProxyConfigurationAccepted().WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash) + } + if skipReload { + if params.XRuntimeActions != nil { + if err = executeRuntimeActions(*params.XRuntimeActions, h.Client); err != nil { + e := misc.HandleError(err) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) + } + } + return configuration.NewPostHAProxyConfigurationCreated().WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash) + } + if forceReload { + var callbackNeeded bool + var reconfigureFunc func() + callbackNeeded, reconfigureFunc, err = cn.ReconfigureRuntime(h.Client) if err != nil { e := misc.HandleError(err) - return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(e) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) + } + if callbackNeeded { + err = h.ReloadAgent.ForceReloadWithCallback(reconfigureFunc) + } else { + err = h.ReloadAgent.ForceReload() + } + if err != nil { + e := misc.HandleError(err) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) + } + return configuration.NewPostHAProxyConfigurationCreated().WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash) + } + callbackNeeded, reconfigureFunc, err := cn.ReconfigureRuntime(h.Client) + if err != nil { + e := misc.HandleError(err) + errorStr, marshallError := json.Marshal(e) + if marshallError != nil { + configuration.NewPostHAProxyConfigurationDefault(http.StatusInternalServerError).WithPayload(marshallError.Error()) + } + return configuration.NewPostHAProxyConfigurationDefault(int(*e.Code)).WithPayload(string(errorStr)) + } + + var rID string + if callbackNeeded { + rID = h.ReloadAgent.ReloadWithCallback(reconfigureFunc) + } else { + rID = h.ReloadAgent.Reload() + } + + return configuration.NewPostHAProxyConfigurationAccepted().WithReloadID(rID).WithPayload(data).WithClusterVersion(cVersion).WithConfigurationChecksum(md5Hash) +} + +func executeRuntimeActions(actionsStr string, client client_native.HAProxyClient) error { + runtime, err := client.Runtime() + if err != nil { + return err + } + actions := strings.SplitSeq(actionsStr, ";") + for a := range actions { + params := strings.Split(a, " ") + if len(params) == 0 { + continue + } + action := params[0] + switch action { + case "SetFrontendMaxConn": + if len(params) > 2 { + fName := params[1] + maxConn, err := strconv.ParseInt(params[2], 10, 64) + if err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + if err := runtime.SetFrontendMaxConn(fName, int(maxConn)); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "SetServerWeight": + if len(params) > 3 { + backend := params[1] + server := params[2] + weight := params[3] + if err := runtime.SetServerWeight(backend, server, weight); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "SetServerCheckPort": + if len(params) > 3 { + backend := params[1] + server := params[2] + port, err := strconv.ParseInt(params[3], 10, 64) + if err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + if err := runtime.SetServerCheckPort(backend, server, int(port)); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "SetServerAddr": + if len(params) > 4 { + backend := params[1] + server := params[2] + ip := params[3] + port, err := strconv.ParseInt(params[4], 10, 64) + if err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + if err := runtime.SetServerAddr(backend, server, ip, int(port)); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "SetServerState": + if len(params) > 3 { + backend := params[1] + server := params[2] + state := params[3] + if err := runtime.SetServerState(backend, server, state); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "EnableAgentCheck": + if len(params) > 2 { + backend := params[1] + server := params[2] + if err := runtime.EnableAgentCheck(backend, server); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "DisableAgentCheck": + if len(params) > 2 { + backend := params[1] + server := params[2] + if err := runtime.DisableAgentCheck(backend, server); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "SetServerAgentAddr": + if len(params) > 3 { + backend := params[1] + server := params[2] + addr := params[3] + if err := runtime.SetServerAgentAddr(backend, server, addr); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } + case "SetServerAgentSend": + if len(params) > 3 { + backend := params[1] + server := params[2] + send := params[3] + if err := runtime.SetServerAgentSend(backend, server, send); err != nil { + return fmt.Errorf("cannot execute %s: %s", action, err.Error()) + } + } else { + return fmt.Errorf("cannot execute %s: not enough parameters", action) + } } - return configuration.NewPostHAProxyConfigurationCreated().WithPayload(params.Data) } - rID := h.ReloadAgent.Reload() - return configuration.NewPostHAProxyConfigurationAccepted().WithReloadID(rID).WithPayload(params.Data) + return nil } diff --git a/handlers/reloads.go b/handlers/reloads.go index b0545c70..74d3a7da 100644 --- a/handlers/reloads.go +++ b/handlers/reloads.go @@ -19,24 +19,25 @@ import ( "fmt" "github.com/go-openapi/runtime/middleware" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/reloads" - "github.com/haproxytech/models" ) -//GetReloadHandlerImpl implementation of the GetReloadHandler interface using client-native client +// GetReloadHandlerImpl implementation of the GetReloadHandler interface using client-native client type GetReloadHandlerImpl struct { - ReloadAgent *haproxy.ReloadAgent + ReloadAgent haproxy.IReloadAgent } -//GetReloadsHandlerImpl implementation of the GetReloadsHandler interface using client-native client +// GetReloadsHandlerImpl implementation of the GetReloadsHandler interface using client-native client type GetReloadsHandlerImpl struct { - ReloadAgent *haproxy.ReloadAgent + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (rh *GetReloadHandlerImpl) Handle(params reloads.GetReloadParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (rh *GetReloadHandlerImpl) Handle(params reloads.GetReloadParams, principal any) middleware.Responder { r := rh.ReloadAgent.GetReload(params.ID) if r == nil { msg := fmt.Sprintf("Reload with ID %s does not exist", params.ID) @@ -50,8 +51,8 @@ func (rh *GetReloadHandlerImpl) Handle(params reloads.GetReloadParams, principal return reloads.NewGetReloadOK().WithPayload(r) } -//Handle executing the request and returning a response -func (rh *GetReloadsHandlerImpl) Handle(params reloads.GetReloadsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (rh *GetReloadsHandlerImpl) Handle(params reloads.GetReloadsParams, principal any) middleware.Responder { rs := rh.ReloadAgent.GetReloads() return reloads.NewGetReloadsOK().WithPayload(rs) } diff --git a/handlers/resolver.go b/handlers/resolver.go new file mode 100644 index 00000000..45a8ca7a --- /dev/null +++ b/handlers/resolver.go @@ -0,0 +1,265 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/resolver" +) + +// CreateResolverHandlerImpl implementation of the CreateResolverHandler interface using client-native client +type CreateResolverHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteResolverHandlerImpl implementation of the DeleteResolverHandler interface using client-native client +type DeleteResolverHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetResolverHandlerImpl implementation of the GetResolverHandler interface using client-native client +type GetResolverHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetResolversHandlerImpl implementation of the GetResolversHandler interface using client-native client +type GetResolversHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceResolverHandlerImpl implementation of the ReplaceResolverHandler interface using client-native client +type ReplaceResolverHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateResolverHandlerImpl) Handle(params resolver.CreateResolverParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return resolver.NewCreateResolverDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return resolver.NewCreateResolverDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateResolver(params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return resolver.NewCreateResolverDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return resolver.NewCreateResolverDefault(int(*e.Code)).WithPayload(e) + } + return resolver.NewCreateResolverCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return resolver.NewCreateResolverAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return resolver.NewCreateResolverAccepted().WithPayload(params.Data) +} + +func (h *CreateResolverHandlerImpl) getResolver(params resolver.CreateResolverParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredResolver(params.Data, t, v) + } + return configuration.CreateResolver(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeleteResolverHandlerImpl) Handle(params resolver.DeleteResolverParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return resolver.NewDeleteResolverDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return resolver.NewDeleteResolverDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteResolver(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return resolver.NewDeleteResolverDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return resolver.NewDeleteResolverDefault(int(*e.Code)).WithPayload(e) + } + return resolver.NewDeleteResolverNoContent() + } + rID := h.ReloadAgent.Reload() + return resolver.NewDeleteResolverAccepted().WithReloadID(rID) + } + return resolver.NewDeleteResolverAccepted() +} + +// Handle executing the request and returning a response +func (h *GetResolverHandlerImpl) Handle(params resolver.GetResolverParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, r, err := h.getResolver(params, t) + if err != nil { + e := misc.HandleError(err) + return resolver.NewGetResolverDefault(int(*e.Code)).WithPayload(e) + } + return resolver.NewGetResolverOK().WithPayload(r) +} + +func (h *GetResolverHandlerImpl) getResolver(params resolver.GetResolverParams, t string) (int64, *models.Resolver, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredResolver(params.Name, t) + } + return configuration.GetResolver(params.Name, t) +} + +// Handle executing the request and returning a response +func (h *GetResolversHandlerImpl) Handle(params resolver.GetResolversParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, rs, err := h.getResolvers(params, t) + if err != nil { + e := misc.HandleError(err) + return resolver.NewGetResolversDefault(int(*e.Code)).WithPayload(e) + } + return resolver.NewGetResolversOK().WithPayload(rs) +} + +func (h *GetResolversHandlerImpl) getResolvers(params resolver.GetResolversParams, t string) (int64, models.Resolvers, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredResolvers(t) + } + return configuration.GetResolvers(t) +} + +// Handle executing the request and returning a response +func (h *ReplaceResolverHandlerImpl) Handle(params resolver.ReplaceResolverParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return resolver.NewReplaceResolverDefault(int(*e.Code)).WithPayload(e) + } + + err := h.editResolver(params, t, v) + if err != nil { + e := misc.HandleError(err) + return resolver.NewReplaceResolverDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return resolver.NewReplaceResolverDefault(int(*e.Code)).WithPayload(e) + } + return resolver.NewReplaceResolverOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return resolver.NewReplaceResolverAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return resolver.NewReplaceResolverAccepted().WithPayload(params.Data) +} + +func (h *ReplaceResolverHandlerImpl) editResolver(params resolver.ReplaceResolverParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredResolver(params.Name, params.Data, t, v) + } + return configuration.EditResolver(params.Name, params.Data, t, v) +} diff --git a/handlers/ring.go b/handlers/ring.go new file mode 100644 index 00000000..fa09e6d5 --- /dev/null +++ b/handlers/ring.go @@ -0,0 +1,259 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/ring" +) + +// CreateRingHandlerImpl implementation of the CreateRingHandler interface using client-native client +type CreateRingHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteRingHandlerImpl implementation of the DeleteRingHandler interface using client-native client +type DeleteRingHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetRingHandlerImpl implementation of the GetRingHandler interface using client-native client +type GetRingHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetRingsHandlerImpl implementation of the GetRingsHandler interface using client-native client +type GetRingsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceRingHandlerImpl implementation of the ReplaceRingHandler interface using client-native client +type ReplaceRingHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateRingHandlerImpl) Handle(params ring.CreateRingParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return ring.NewCreateRingDefault(int(*e.Code)).WithPayload(e) + } + + err := h.createRing(params, t, v) + if err != nil { + e := misc.HandleError(err) + return ring.NewCreateRingDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return ring.NewCreateRingDefault(int(*e.Code)).WithPayload(e) + } + return ring.NewCreateRingCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return ring.NewCreateRingAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return ring.NewCreateRingAccepted().WithPayload(params.Data) +} + +func (h *CreateRingHandlerImpl) createRing(params ring.CreateRingParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredRing(params.Data, t, v) + } + return configuration.CreateRing(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeleteRingHandlerImpl) Handle(params ring.DeleteRingParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return ring.NewDeleteRingDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return ring.NewDeleteRingDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteRing(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return ring.NewDeleteRingDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return ring.NewDeleteRingDefault(int(*e.Code)).WithPayload(e) + } + return ring.NewDeleteRingNoContent() + } + rID := h.ReloadAgent.Reload() + return ring.NewDeleteRingAccepted().WithReloadID(rID) + } + return ring.NewDeleteRingAccepted() +} + +// Handle executing the request and returning a response +func (h *GetRingHandlerImpl) Handle(params ring.GetRingParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, bck, err := h.getRing(params, t) + if err != nil { + e := misc.HandleError(err) + return ring.NewGetRingDefault(int(*e.Code)).WithPayload(e) + } + return ring.NewGetRingOK().WithPayload(bck) +} + +func (h *GetRingHandlerImpl) getRing(params ring.GetRingParams, t string) (int64, *models.Ring, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredRing(params.Name, t) + } + return configuration.GetRing(params.Name, t) +} + +// Handle executing the request and returning a response +func (h *GetRingsHandlerImpl) Handle(params ring.GetRingsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, bcks, err := h.getRings(params, t) + if err != nil { + e := misc.HandleError(err) + return ring.NewGetRingsDefault(int(*e.Code)).WithPayload(e) + } + return ring.NewGetRingsOK().WithPayload(bcks) +} + +func (h *GetRingsHandlerImpl) getRings(params ring.GetRingsParams, t string) (int64, models.Rings, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredRings(t) + } + return configuration.GetRings(t) +} + +// Handle executing the request and returning a response +func (h *ReplaceRingHandlerImpl) Handle(params ring.ReplaceRingParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return ring.NewReplaceRingDefault(int(*e.Code)).WithPayload(e) + } + + err := h.editRing(params, t, v) + if err != nil { + e := misc.HandleError(err) + return ring.NewReplaceRingDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return ring.NewReplaceRingDefault(int(*e.Code)).WithPayload(e) + } + return ring.NewReplaceRingOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return ring.NewReplaceRingAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return ring.NewReplaceRingAccepted().WithPayload(params.Data) +} + +func (h *ReplaceRingHandlerImpl) editRing(params ring.ReplaceRingParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.EditStructuredRing(params.Name, params.Data, t, v) + } + return configuration.EditRing(params.Name, params.Data, t, v) +} diff --git a/handlers/runtime.go b/handlers/runtime.go index dea59d0e..3b54d5de 100644 --- a/handlers/runtime.go +++ b/handlers/runtime.go @@ -19,38 +19,37 @@ import ( "reflect" "strconv" - log "github.com/sirupsen/logrus" - - client_native "github.com/haproxytech/client-native" - "github.com/haproxytech/models" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/log" ) -//RuntimeSupportedFields is a map of fields supported through the runtime API for +// RuntimeSupportedFields is a map of fields supported through the runtime API for // it's respectable object type var RuntimeSupportedFields = map[string][]string{ - "frontend": []string{"Maxconn"}, - "server": []string{"Weigth", "Address", "Port", "Maintenance", "AgentCheck", "AgentAddr", "AgentSend"}, + "frontend": {"Maxconn"}, + "server": {"Weight", "Address", "Port", "Maintenance", "AgentCheck", "AgentAddr", "AgentSend", "HealthCheckPort"}, } // ChangeThroughRuntimeAPI checks if something can be changed through the runtime API, and // returns false if reload is not needed, or true if needed. -func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType string, client *client_native.HAProxyClient) (reload bool) { +func changeThroughRuntimeAPI(data, ondisk any, parentName string, client client_native.HAProxyClient) (reload bool) { // reflect kinds and values are loosely checked as they are bound strictly in // schema, but in case of any panic, we will log and reload to ensure // changes go through defer func() { if r := recover(); r != nil { - log.Warn("Change Through API Panic: ", r) + log.Warning("Change Through API Panic: ", r) // we are panicking, so reload to ensure changes are through reload = true } }() // check if runtime client is valid, if not, return reload needed - if client.Runtime == nil { + runtime, err := client.Runtime() + if err != nil { return true } - // objects are the same, do nothing and don't reload diff := compareObjects(data, ondisk) if len(diff) == 0 { @@ -63,10 +62,11 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st for _, field := range diff { fieldValue := reflect.ValueOf(vData).FieldByName(field) if fieldValue.IsValid() { + //nolint:gocritic switch field { case "Maxconn": maxConn := fieldValue.Elem().Int() - err := client.Runtime.SetFrontendMaxConn(vData.Name, int(maxConn)) + err := runtime.SetFrontendMaxConn(vData.Name, int(maxConn)) if err != nil { // we have error's in runtime API changes, bail and reload return true @@ -88,7 +88,14 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st switch field { case "Weight": weight := strconv.FormatInt(fieldValue.Elem().Int(), 10) - err := client.Runtime.SetServerWeight(parentName, vData.Name, weight) + err := runtime.SetServerWeight(parentName, vData.Name, weight) + if err != nil { + // we have error's in runtime API changes, bail and reload + return true + } + case "HealthCheckPort": + portVal := fieldValue.Elem().Int() + err := runtime.SetServerCheckPort(parentName, vData.Name, int(portVal)) if err != nil { // we have error's in runtime API changes, bail and reload return true @@ -97,7 +104,7 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st if !addrPortChanged { portVal := reflect.ValueOf(vData).FieldByName("Port").Elem().Int() addrVal := fieldValue.String() - err := client.Runtime.SetServerAddr(parentName, vData.Name, addrVal, int(portVal)) + err := runtime.SetServerAddr(parentName, vData.Name, addrVal, int(portVal)) if err != nil { // we have error's in runtime API changes, bail and reload return true @@ -108,7 +115,7 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st if !addrPortChanged { portVal := fieldValue.Elem().Int() addrVal := reflect.ValueOf(vData).FieldByName("Address").String() - err := client.Runtime.SetServerAddr(parentName, vData.Name, addrVal, int(portVal)) + err := runtime.SetServerAddr(parentName, vData.Name, addrVal, int(portVal)) if err != nil { // we have error's in runtime API changes, bail and reload return true @@ -122,7 +129,7 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st } else { maint = "ready" } - err := client.Runtime.SetServerState(parentName, vData.Name, maint) + err := runtime.SetServerState(parentName, vData.Name, maint) if err != nil { // we have error's in runtime API changes, bail and reload return true @@ -130,14 +137,14 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st case "AgentCheck": aCheck := fieldValue.String() if aCheck == "enabled" { - err := client.Runtime.EnableAgentCheck(parentName, vData.Name) + err := runtime.EnableAgentCheck(parentName, vData.Name) if err != nil { // we have error's in runtime API changes, bail and reload return true } } if aCheck == "disabled" { - err := client.Runtime.DisableAgentCheck(parentName, vData.Name) + err := runtime.DisableAgentCheck(parentName, vData.Name) if err != nil { // we have error's in runtime API changes, bail and reload return true @@ -145,14 +152,14 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st } case "AgentAddr": aAddr := fieldValue.String() - err := client.Runtime.SetServerAgentAddr(parentName, vData.Name, aAddr) + err := runtime.SetServerAgentAddr(parentName, vData.Name, aAddr) if err != nil { // we have error's in runtime API changes, bail and reload return true } case "AgentSend": aSend := fieldValue.String() - err := client.Runtime.SetServerAgentSend(parentName, vData.Name, aSend) + err := runtime.SetServerAgentSend(parentName, vData.Name, aSend) if err != nil { // we have error's in runtime API changes, bail and reload return true @@ -172,11 +179,11 @@ func changeThroughRuntimeAPI(data, ondisk interface{}, parentName, parentType st } // return string of field names that have a diff -func compareObjects(data, ondisk interface{}) []string { - diff := make([]string, 0, 0) +func compareObjects(data, ondisk any) []string { + diff := make([]string, 0) dataVal := reflect.ValueOf(data) ondiskVal := reflect.ValueOf(ondisk) - for i := 0; i < dataVal.NumField(); i++ { + for i := range dataVal.NumField() { fName := dataVal.Type().Field(i).Name dataField := dataVal.FieldByName(fName) ondiskField := ondiskVal.FieldByName(fName) @@ -223,14 +230,16 @@ func compareObjects(data, ondisk interface{}) []string { if dataField.String() != ondiskField.String() { diff = append(diff, fName) } + case reflect.Struct: + diff = append(diff, compareObjects(dataField.Interface(), ondiskField.Interface())...) } } return diff } -// this returns true if only changable fields have been changed -func compareChanged(changed, changable []string) bool { - if len(changed) > len(changable) { +// this returns true if only changeable fields have been changed +func compareChanged(changed, changeable []string) bool { + if len(changed) > len(changeable) { return false } @@ -239,12 +248,9 @@ func compareChanged(changed, changable []string) bool { diff[elem] = true } - for _, elem := range changable { + for _, elem := range changeable { delete(diff, elem) } - if len(diff) == 0 { - return true - } - return false + return len(diff) == 0 } diff --git a/handlers/runtime_server.go b/handlers/runtime_server.go new file mode 100644 index 00000000..71370de1 --- /dev/null +++ b/handlers/runtime_server.go @@ -0,0 +1,498 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "fmt" + "strings" + + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + native_errors "github.com/haproxytech/client-native/v6/errors" + "github.com/haproxytech/client-native/v6/models" + cn_runtime "github.com/haproxytech/client-native/v6/runtime" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/server" +) + +// GetRuntimeServerHandlerImpl implementation of the GetRuntimeServerHandler interface using client-native client +type GetRuntimeServerHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetAllRuntimeServerHandlerImpl implementation of the GetRuntimeServersHandler interface using client-native client +type GetAllRuntimeServerHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceRuntimeServerHandlerImpl implementation of the ReplaceRuntimeServerHandler interface using client-native client +type ReplaceRuntimeServerHandlerImpl struct { + Client client_native.HAProxyClient +} + +// AddRuntimeServerHandlerImpl implementation of the ServerAddRuntimeServerHandler interface using client-native client +type AddRuntimeServerHandlerImpl struct { + Client client_native.HAProxyClient +} + +// DeleteRuntimeServerHandlerImpl implementation of the ServerDeleteRuntimeServerHandler interface using client-native client +type DeleteRuntimeServerHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *GetRuntimeServerHandlerImpl) Handle(params server.GetRuntimeServerParams, principal any) middleware.Responder { + rn, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return server.NewGetRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + rs, err := rn.GetServerState(params.ParentName, params.Name) + if err != nil { + if isNotFoundError(err) { + code := int64(404) + msg := err.Error() + return server.NewGetRuntimeServerNotFound().WithPayload(&models.Error{Code: &code, Message: &msg}) + } + e := misc.HandleError(err) + return server.NewGetRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + if rs == nil { + code := int64(404) + msg := fmt.Sprintf("Runtime server %s not found in backend %s", params.Name, params.ParentName) + return server.NewGetRuntimeServerNotFound().WithPayload(&models.Error{Code: &code, Message: &msg}) + } + + return server.NewGetRuntimeServerOK().WithPayload(rs) +} + +// Handle executing the request and returning a response +func (h *GetAllRuntimeServerHandlerImpl) Handle(params server.GetAllRuntimeServerParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return server.NewGetAllRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + rs, err := runtime.GetServersState(params.ParentName) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return server.NewGetAllRuntimeServerOK().WithPayload(models.RuntimeServers{}) + } + return server.NewGetAllRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + return server.NewGetAllRuntimeServerOK().WithPayload(rs) +} + +// Handle executing the request and returning a response +func (h *ReplaceRuntimeServerHandlerImpl) Handle(params server.ReplaceRuntimeServerParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return server.NewReplaceRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + rs, err := runtime.GetServerState(params.ParentName, params.Name) + if err != nil { + e := misc.HandleError(err) + return server.NewReplaceRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + if rs == nil { + code := int64(404) + msg := fmt.Sprintf("Runtime server %s not found in backend %s", params.Name, params.ParentName) + return server.NewReplaceRuntimeServerNotFound().WithPayload(&models.Error{Code: &code, Message: &msg}) + } + + // change operational state + if params.Data.OperationalState != "" && rs.OperationalState != params.Data.OperationalState { + err = runtime.SetServerHealth(params.ParentName, params.Name, params.Data.OperationalState) + if err != nil { + e := misc.HandleError(err) + return server.NewReplaceRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + } + + // change admin state + if params.Data.AdminState != "" && rs.AdminState != params.Data.AdminState { + err = runtime.SetServerState(params.ParentName, params.Name, params.Data.AdminState) + if err != nil { + e := misc.HandleError(err) + + // try to revert operational state and fall silently + //nolint:errcheck + runtime.SetServerHealth(params.ParentName, params.Name, rs.OperationalState) + return server.NewReplaceRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + } + + rs, err = runtime.GetServerState(params.ParentName, params.Name) + if err != nil { + e := misc.HandleError(err) + return server.NewReplaceRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + return server.NewReplaceRuntimeServerOK().WithPayload(rs) +} + +// Adds a new server dynamically without modifying the configuration. +// Warning: this only works if you have not defined a `default_server` in the defaults +// or in the current `backend` section. +func (h *AddRuntimeServerHandlerImpl) Handle(params server.AddRuntimeServerParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return server.NewAddRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + if params.Data.Name == "" { + code := int64(400) + msg := "the new server must have a name" + return server.NewAddRuntimeServerBadRequest().WithPayload(&models.Error{Code: &code, Message: &msg}) + } + + haversion, err := runtime.GetVersion() + if err != nil { + e := misc.HandleError(err) + return server.NewAddRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.AddServer(params.ParentName, params.Data.Name, SerializeRuntimeAddServer(params.Data, &haversion)) + if err != nil { + msg := err.Error() + switch { + case strings.Contains(msg, "No such backend"): + code := int64(404) + return server.NewAddRuntimeServerNotFound().WithPayload(&models.Error{Code: &code, Message: &msg}) + case strings.Contains(msg, "Already exists"): + code := int64(409) + return server.NewAddRuntimeServerConflict().WithPayload(&models.Error{Code: &code, Message: &msg}) + default: + e := misc.HandleError(err) + return server.NewAddRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + } + + return server.NewAddRuntimeServerCreated().WithPayload(params.Data) +} + +func isNotFoundError(err error) bool { + msg := err.Error() + return strings.Contains(msg, "No such backend") || + strings.Contains(msg, native_errors.ErrNotFound.Error()) +} + +// Deletes a server from a backend immediately, without waiting for connections to drain. +func (h *DeleteRuntimeServerHandlerImpl) Handle(params server.DeleteRuntimeServerParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return server.NewDeleteRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + // Check if this server exists. + rs, err := runtime.GetServerState(params.ParentName, params.Name) + if err != nil { + if isNotFoundError(err) { + code := int64(404) + msg := err.Error() + return server.NewDeleteRuntimeServerNotFound().WithPayload(&models.Error{Code: &code, Message: &msg}) + } + e := misc.HandleError(err) + return server.NewDeleteRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + // Put the server in maintenance state before deleting it. + if rs.AdminState != "maint" { + err = runtime.DisableServer(params.ParentName, params.Name) + if err != nil { + e := misc.HandleError(err) + return server.NewDeleteRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + } + + // TODO: wait for connections to drain. This is not yet possible with HAProxy 2.6. + + err = runtime.DeleteServer(params.ParentName, params.Name) + if err != nil { + e := misc.HandleError(err) + return server.NewDeleteRuntimeServerDefault(int(*e.Code)).WithPayload(e) + } + + return server.NewDeleteRuntimeServerNoContent() +} + +// SerializeRuntimeAddServer returns a string in the HAProxy config format, suitable +// for the "add server" operation over the control socket. +// Not all the Server attributes are available in this case. +func SerializeRuntimeAddServer(srv *models.RuntimeAddServer, version *cn_runtime.HAProxyVersion) string { //nolint: cyclop,maintidx + b := &strings.Builder{} + + push := func(s string) { + b.WriteByte(' ') + b.WriteString(s) + } + pushi := func(key string, val *int64) { + fmt.Fprintf(b, " %s %d", key, *val) + } + // push a quoted string + pushq := func(key, val string) { + fmt.Fprintf(b, ` %s %s`, key, val) + } + enabled := func(s string) bool { + return s == "enabled" + } + disabled := func(s string) bool { + return s == "disabled" + } + + // Address is mandatory and must come first, with an optional port number. + addr := srv.Address + if srv.Port != nil { + addr += fmt.Sprintf(":%d", *srv.Port) + } + push(addr) + + if enabled(srv.AgentCheck) { + push("agent-check") + } + if srv.AgentAddr != "" { + pushq("agent-addr", srv.AgentAddr) + } + if srv.AgentPort != nil { + pushi("agent-port", srv.AgentPort) + } + if srv.AgentInter != nil { + pushi("agent-inter", srv.AgentInter) + } + if srv.AgentSend != "" { + pushq("agent-send", srv.AgentSend) + } + if srv.Allow0rtt { + push("allow-0rtt") + } + if srv.Alpn != "" { + pushq("alpn", srv.Alpn) + } + if enabled(srv.Backup) { + push("backup") + } + if srv.SslCafile != "" { + pushq("ca-file", srv.SslCafile) + } + if enabled(srv.Check) { + push("check") + } + if srv.CheckAlpn != "" { + pushq("check-alpn", srv.CheckAlpn) + } + if srv.HealthCheckAddress != "" { + pushq("addr", srv.HealthCheckAddress) + } + if srv.HealthCheckPort != nil { + pushi("port", srv.HealthCheckPort) + } + if srv.CheckProto != "" { + pushq("check-proto", srv.CheckProto) + } + if enabled(srv.CheckSendProxy) { + push("check-send-proxy") + } + if srv.CheckSni != "" { + pushq("check-sni", srv.CheckSni) + } + if enabled(srv.CheckSsl) { + push("check-ssl") + } + if enabled(srv.CheckViaSocks4) { + push("check-via-socks4") + } + if srv.Ciphers != "" { + pushq("ciphers", srv.Ciphers) + } + if srv.Ciphersuites != "" { + pushq("ciphersuites", srv.Ciphersuites) + } + if srv.CrlFile != "" { + pushq("crl-file", srv.CrlFile) + } + if srv.SslCertificate != "" { + pushq("crt", srv.SslCertificate) + } + if enabled(srv.Maintenance) { + push("disabled") + } + if srv.Downinter != nil { + pushi("downinter", srv.Downinter) + } + if disabled(srv.Maintenance) { + required := new(cn_runtime.HAProxyVersion) + required.ParseHAProxyVersion("3.0.0") + if !cn_runtime.IsBiggerOrEqual(required, version) { + push("enabled") + } + } + if srv.ErrorLimit != nil { + pushi("error-limit", srv.ErrorLimit) + } + if srv.Fall != nil { + pushi("fall", srv.Fall) + } + if srv.Fastinter != nil { + pushi("fastinter", srv.Fastinter) + } + if enabled(srv.ForceSslv3) { + push("force-sslv3") + } + if enabled(srv.ForceTlsv10) { + push("force-tlsv10") + } + if enabled(srv.ForceTlsv11) { + push("force-tlsv11") + } + if enabled(srv.ForceTlsv12) { + push("force-tlsv12") + } + if enabled(srv.ForceTlsv13) { + push("force-tlsv13") + } + if srv.ID != "" { + pushq("id", srv.ID) + } + if srv.Inter != nil { + pushi("inter", srv.Inter) + } + if srv.Maxconn != nil { + pushi("maxconn", srv.Maxconn) + } + if srv.Maxqueue != nil { + pushi("maxqueue", srv.Maxqueue) + } + if srv.Minconn != nil { + pushi("minconn", srv.Minconn) + } + if disabled(srv.SslReuse) { + push("no-ssl-reuse") + } + if enabled(srv.NoSslv3) { + push("no-sslv3") + } + if enabled(srv.NoTlsv10) { + push("no-tlsv10") + } + if enabled(srv.NoTlsv11) { + push("no-tlsv11") + } + if enabled(srv.NoTlsv12) { + push("no-tlsv12") + } + if enabled(srv.NoTlsv13) { + push("no-tlsv13") + } + if disabled(srv.TLSTickets) { + push("no-tls-tickets") + } + if srv.Npn != "" { + pushq("npm", srv.Npn) + } + if srv.Observe != "" { + pushq("observe", srv.Observe) + } + if srv.OnError != "" { + pushq("on-error", srv.OnError) + } + if srv.OnMarkedDown != "" { + pushq("on-marked-down", srv.OnMarkedDown) + } + if srv.OnMarkedUp != "" { + pushq("on-marked-up", srv.OnMarkedUp) + } + if srv.PoolLowConn != nil { + pushi("pool-low-conn", srv.PoolLowConn) + } + if srv.PoolMaxConn != nil { + pushi("pool-max-conn", srv.PoolMaxConn) + } + if srv.PoolPurgeDelay != nil { + pushi("pool-purge-delay", srv.PoolPurgeDelay) + } + if srv.Proto != "" { + pushq("proto", srv.Proto) + } + if len(srv.ProxyV2Options) > 0 { + pushq("proxy-v2-options", strings.Join(srv.ProxyV2Options, ",")) + } + if srv.Rise != nil { + pushi("rise", srv.Rise) + } + if enabled(srv.SendProxy) { + push("send-proxy") + } + if enabled(srv.SendProxyV2) { + push("send-proxy-v2") + } + if enabled(srv.SendProxyV2Ssl) { + push("send-proxy-v2-ssl") + } + if enabled(srv.SendProxyV2SslCn) { + push("send-proxy-v2-ssl-cn") + } + if srv.Slowstart != nil { + pushi("slowstart", srv.Slowstart) + } + if srv.Sni != "" { + pushq("sni", srv.Sni) + } + if srv.Source != "" { + pushq("source", srv.Source) + } + if enabled(srv.Ssl) { + push("ssl") + } + if srv.SslMaxVer != "" { + pushq("ssl-max-ver", srv.SslMaxVer) + } + if srv.SslMinVer != "" { + pushq("ssl-min-ver", srv.SslMinVer) + } + if enabled(srv.Tfo) { + push("tfo") + } + if enabled(srv.TLSTickets) { + push("tls-tickets") + } + if srv.Track != "" { + pushq("track", srv.Track) + } + if srv.Verify != "" { + pushq("verify", srv.Verify) + } + if srv.Verifyhost != "" { + pushq("verifyhost", srv.Verifyhost) + } + if srv.Weight != nil { + pushi("weight", srv.Weight) + } + if srv.Ws != "" { + pushq("ws", srv.Ws) + } + return b.String() +} diff --git a/handlers/runtime_server_test.go b/handlers/runtime_server_test.go new file mode 100644 index 00000000..8b39597f --- /dev/null +++ b/handlers/runtime_server_test.go @@ -0,0 +1,160 @@ +package handlers + +import ( + "testing" + + "github.com/haproxytech/client-native/v6/models" + cn_runtime "github.com/haproxytech/client-native/v6/runtime" + "github.com/haproxytech/dataplaneapi/misc" +) + +func TestSerializeRuntimeAddServer(t *testing.T) { + tests := []struct { + name string + srv *models.RuntimeAddServer + version *cn_runtime.HAProxyVersion + want string + }{ + { + name: "basic server", + srv: &models.RuntimeAddServer{ + Address: "127.0.0.1", + Port: misc.Int64P(8080), + }, + version: &cn_runtime.HAProxyVersion{}, + want: " 127.0.0.1:8080", + }, + { + name: "server with weight", + srv: &models.RuntimeAddServer{ + Address: "192.168.1.100", + Port: misc.Int64P(9000), + Weight: misc.Int64P(50), + }, + version: &cn_runtime.HAProxyVersion{}, + want: " 192.168.1.100:9000 weight 50", + }, + { + name: "server with maintenance", + srv: &models.RuntimeAddServer{ + Address: "10.0.0.10", + Maintenance: "enabled", + }, + version: &cn_runtime.HAProxyVersion{}, + want: " 10.0.0.10 disabled", + }, + { + name: "server with maintenance disabled", + srv: &models.RuntimeAddServer{ + Address: "10.0.0.10", + Maintenance: "disabled", + }, + version: &cn_runtime.HAProxyVersion{}, + want: " 10.0.0.10 enabled", + }, + { + name: "server with maintenance disabled, HAProxy 3.0", + srv: &models.RuntimeAddServer{ + Address: "10.0.0.10", + Maintenance: "disabled", + }, + version: func() *cn_runtime.HAProxyVersion { + v := new(cn_runtime.HAProxyVersion) + v.ParseHAProxyVersion("3.0.0") + return v + }(), + want: " 10.0.0.10", + }, + { + name: "server with agent check", + srv: &models.RuntimeAddServer{ + Address: "172.16.0.5", + AgentCheck: "enabled", + }, + version: &cn_runtime.HAProxyVersion{}, + want: " 172.16.0.5 agent-check", + }, + { + name: "server with agent addr", + srv: &models.RuntimeAddServer{ + Address: "172.16.0.6", + AgentAddr: "127.0.0.1", + }, + version: &cn_runtime.HAProxyVersion{}, + want: ` 172.16.0.6 agent-addr 127.0.0.1`, + }, + { + name: "server with multiple options", + srv: &models.RuntimeAddServer{ + Address: "10.1.1.10", + Port: misc.Int64P(80), + Weight: misc.Int64P(10), + Check: "enabled", + Backup: "enabled", + Maintenance: "enabled", + AgentCheck: "enabled", + AgentAddr: "127.0.0.1", + AgentPort: misc.Int64P(5000), + HealthCheckAddress: "127.0.0.2", + }, + version: &cn_runtime.HAProxyVersion{}, + want: ` 10.1.1.10:80 agent-check agent-addr 127.0.0.1 agent-port 5000 backup check addr 127.0.0.2 disabled weight 10`, + }, + { + name: "server with all fields", + srv: &models.RuntimeAddServer{ + Address: "10.1.1.10", + Port: misc.Int64P(80), + Weight: misc.Int64P(10), + Check: "enabled", + Backup: "enabled", + Maintenance: "enabled", + AgentCheck: "enabled", + AgentAddr: "127.0.0.1", + AgentPort: misc.Int64P(5000), + AgentInter: misc.Int64P(1000), + AgentSend: "foobar", + Allow0rtt: true, + Alpn: "h2,http/1.1", + CheckAlpn: "h2", + CheckProto: "HTTP", + CheckSendProxy: "enabled", + CheckSni: "example.com", + CheckSsl: "enabled", + CheckViaSocks4: "enabled", + Ciphers: "HIGH:!aNULL:!MD5", + Ciphersuites: "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256", + CrlFile: "/path/to/crl.pem", + SslCertificate: "/path/to/cert.pem", + Downinter: misc.Int64P(2000), + ErrorLimit: misc.Int64P(10), + Fall: misc.Int64P(2), + Fastinter: misc.Int64P(500), + ForceSslv3: "enabled", + ForceTlsv10: "enabled", + ForceTlsv11: "enabled", + ForceTlsv12: "enabled", + ForceTlsv13: "enabled", + HealthCheckAddress: "127.0.0.2", + HealthCheckPort: misc.Int64P(8080), + Inter: misc.Int64P(3000), + Maxconn: misc.Int64P(100), + Maxqueue: misc.Int64P(200), + Minconn: misc.Int64P(50), + Rise: misc.Int64P(1), + }, + version: &cn_runtime.HAProxyVersion{}, + want: ` 10.1.1.10:80 agent-check agent-addr 127.0.0.1 agent-port 5000 agent-inter 1000 agent-send foobar allow-0rtt alpn h2,http/1.1 backup check check-alpn h2 addr 127.0.0.2 port 8080 check-proto HTTP check-send-proxy check-sni example.com check-ssl check-via-socks4 ciphers HIGH:!aNULL:!MD5 ciphersuites TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 crl-file /path/to/crl.pem crt /path/to/cert.pem disabled downinter 2000 error-limit 10 fall 2 fastinter 500 force-sslv3 force-tlsv10 force-tlsv11 force-tlsv12 force-tlsv13 inter 3000 maxconn 100 maxqueue 200 minconn 50 rise 1 weight 10`, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.version == nil { + tt.version = &cn_runtime.HAProxyVersion{} + } + if got := SerializeRuntimeAddServer(tt.srv, tt.version); got != tt.want { + t.Errorf("SerializeRuntimeAddServer() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/handlers/server.go b/handlers/server.go index f3dd9a0d..1377daf3 100644 --- a/handlers/server.go +++ b/handlers/server.go @@ -16,44 +16,64 @@ package handlers import ( + "errors" + + "github.com/haproxytech/client-native/v6/runtime" + "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/log" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/server" - "github.com/haproxytech/models" ) -//CreateServerHandlerImpl implementation of the CreateServerHandler interface using client-native client +// CreateServerHandlerImpl implementation of the CreateServerHandler interface using client-native client type CreateServerHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteServerHandlerImpl implementation of the DeleteServerHandler interface using client-native client +// DeleteServerHandlerImpl implementation of the DeleteServerHandler interface using client-native client type DeleteServerHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetServerHandlerImpl implementation of the GetServerHandler interface using client-native client +// GetServerHandlerImpl implementation of the GetServerHandler interface using client-native client type GetServerHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetServersHandlerImpl implementation of the GetServersHandler interface using client-native client -type GetServersHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllServerHandlerImpl implementation of the GetServersHandler interface using client-native client +type GetAllServerHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceServerHandlerImpl implementation of the ReplaceServerHandler interface using client-native client +// ReplaceServerHandlerImpl implementation of the ReplaceServerHandler interface using client-native client type ReplaceServerHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func serverTypeParams(backend *string, parentType *string, parentName *string) (pType string, pName string, err error) { + if backend != nil && *backend != "" { + return "backend", *backend, nil + } + if parentType == nil || *parentType == "" { + return "", "", errors.New("parentType empty") + } + if parentName == nil || *parentName == "" { + return "", "", errors.New("parentName empty") + } + return *parentType, *parentName, nil } -//Handle executing the request and returning a response -func (h *CreateServerHandlerImpl) Handle(params server.CreateServerParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateServerHandlerImpl) Handle(parentType cnconstants.CnParentType, params server.CreateServerBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,31 +90,78 @@ func (h *CreateServerHandlerImpl) Handle(params server.CreateServerParams, princ Message: &msg, Code: &c, } - return server.NewCreateServerDefault(int(*e.Code)).WithPayload(e) + return server.NewCreateServerBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateServer(params.Backend, params.Data, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return server.NewCreateServerDefault(int(*e.Code)).WithPayload(e) + return server.NewCreateServerBackendDefault(int(*e.Code)).WithPayload(e) } + + pType, pName, err := serverTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) + if err != nil { + e := misc.HandleError(err) + return server.NewCreateServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateServer(pType, pName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return server.NewCreateServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + // Try to create the new server dynamically. This is only possible if parentType is `backend` and no `default_server` + // was defined in the current backend or in the `defaults` section. + useRuntime := false + ras := &models.RuntimeAddServer{} + var runtimeClient runtime.Runtime + if pType == "backend" { + _, defaults, errRuntime := configuration.GetDefaultsConfiguration(t) + if errRuntime != nil { + e := misc.HandleError(errRuntime) + return server.NewCreateServerBackendDefault(int(*e.Code)).WithPayload(e) + } + _, backend, errRuntime := configuration.GetBackend(pName, t) + if errRuntime != nil { + e := misc.HandleError(errRuntime) + return server.NewCreateServerBackendDefault(int(*e.Code)).WithPayload(e) + } + runtimeClient, errRuntime = h.Client.Runtime() + if errRuntime == nil && defaults.DefaultServer == nil && backend.DefaultServer == nil { + // Also make sure the server attributes are supported by the runtime API. + errRuntime = misc.ConvertStruct(params.Data, ras) + useRuntime = errRuntime == nil + } + } + if params.TransactionID == nil { if *params.ForceReload { - err := h.ReloadAgent.ForceReload() + err = h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return server.NewCreateServerDefault(int(*e.Code)).WithPayload(e) + return server.NewCreateServerBackendDefault(int(*e.Code)).WithPayload(e) + } + return server.NewCreateServerBackendCreated().WithPayload(params.Data) + } + if useRuntime { + haversion, _ := runtimeClient.GetVersion() + err = runtimeClient.AddServer(pName, params.Data.Name, SerializeRuntimeAddServer(ras, &haversion)) + if err == nil { + // No need to reload. + log.Debugf("backend %s: server %s added though runtime", pName, params.Data.Name) + return server.NewCreateServerBackendCreated().WithPayload(params.Data) } - return server.NewCreateServerCreated().WithPayload(params.Data) + log.Warning("failed to add server through runtime:", err) } rID := h.ReloadAgent.Reload() - return server.NewCreateServerAccepted().WithReloadID(rID).WithPayload(params.Data) + return server.NewCreateServerBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return server.NewCreateServerAccepted().WithPayload(params.Data) + return server.NewCreateServerBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteServerHandlerImpl) Handle(params server.DeleteServerParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteServerHandlerImpl) Handle(parentType cnconstants.CnParentType, params server.DeleteServerBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -111,13 +178,25 @@ func (h *DeleteServerHandlerImpl) Handle(params server.DeleteServerParams, princ Message: &msg, Code: &c, } - return server.NewDeleteServerDefault(int(*e.Code)).WithPayload(e) + return server.NewDeleteServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server.NewDeleteServerBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteServer(params.Name, params.Backend, t, v) + pType, pName, err := serverTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) if err != nil { e := misc.HandleError(err) - return server.NewDeleteServerDefault(int(*e.Code)).WithPayload(e) + return server.NewDeleteServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteServer(params.Name, pType, pName, t, v) + if err != nil { + e := misc.HandleError(err) + return server.NewDeleteServerBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -125,48 +204,75 @@ func (h *DeleteServerHandlerImpl) Handle(params server.DeleteServerParams, princ err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return server.NewDeleteServerDefault(int(*e.Code)).WithPayload(e) + return server.NewDeleteServerBackendDefault(int(*e.Code)).WithPayload(e) } - return server.NewDeleteServerNoContent() + return server.NewDeleteServerBackendNoContent() } rID := h.ReloadAgent.Reload() - return server.NewDeleteServerAccepted().WithReloadID(rID) + return server.NewDeleteServerBackendAccepted().WithReloadID(rID) } - return server.NewDeleteServerAccepted() + return server.NewDeleteServerBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetServerHandlerImpl) Handle(params server.GetServerParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetServerHandlerImpl) Handle(parentType cnconstants.CnParentType, params server.GetServerBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, srv, err := h.Client.Configuration.GetServer(params.Name, params.Backend, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server.NewGetServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + pType, pName, err := serverTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) if err != nil { e := misc.HandleError(err) - return server.NewGetServerDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return server.NewGetServerBackendDefault(int(*e.Code)).WithPayload(e) } - return server.NewGetServerOK().WithPayload(&server.GetServerOKBody{Version: v, Data: srv}).WithConfigurationVersion(v) + + _, srv, err := configuration.GetServer(params.Name, pType, pName, t) + if err != nil { + e := misc.HandleError(err) + return server.NewGetServerBackendDefault(int(*e.Code)).WithPayload(e) + } + return server.NewGetServerBackendOK().WithPayload(srv) } -//Handle executing the request and returning a response -func (h *GetServersHandlerImpl) Handle(params server.GetServersParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllServerHandlerImpl) Handle(parentType cnconstants.CnParentType, params server.GetAllServerBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, srvs, err := h.Client.Configuration.GetServers(params.Backend, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server.NewGetAllServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + pType, pName, err := serverTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) if err != nil { e := misc.HandleError(err) - return server.NewGetServersDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return server.NewGetAllServerBackendDefault(int(*e.Code)).WithPayload(e) } - return server.NewGetServersOK().WithPayload(&server.GetServersOKBody{Version: v, Data: srvs}).WithConfigurationVersion(v) + + _, srvs, err := configuration.GetServers(pType, pName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return server.NewGetAllServerBackendOK().WithPayload(models.Servers{}) + } + return server.NewGetAllServerBackendDefault(int(*e.Code)).WithPayload(e) + } + return server.NewGetAllServerBackendOK().WithPayload(srvs) } -//Handle executing the request and returning a response -func (h *ReplaceServerHandlerImpl) Handle(params server.ReplaceServerParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceServerHandlerImpl) Handle(parentType cnconstants.CnParentType, params server.ReplaceServerBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -183,35 +289,47 @@ func (h *ReplaceServerHandlerImpl) Handle(params server.ReplaceServerParams, pri Message: &msg, Code: &c, } - return server.NewReplaceServerDefault(int(*e.Code)).WithPayload(e) + return server.NewReplaceServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server.NewReplaceServerBackendDefault(int(*e.Code)).WithPayload(e) + } + + pType, pName, err := serverTypeParams(nil, misc.StringP(string(parentType)), ¶ms.ParentName) + if err != nil { + e := misc.HandleError(err) + return server.NewReplaceServerBackendDefault(int(*e.Code)).WithPayload(e) } - _, ondisk, err := h.Client.Configuration.GetServer(params.Name, params.Backend, t) + _, ondisk, err := configuration.GetServer(params.Name, pType, pName, t) if err != nil { e := misc.HandleError(err) - return server.NewReplaceServerDefault(int(*e.Code)).WithPayload(e) + return server.NewReplaceServerBackendDefault(int(*e.Code)).WithPayload(e) } - err = h.Client.Configuration.EditServer(params.Name, params.Backend, params.Data, t, v) + err = configuration.EditServer(params.Name, pType, pName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return server.NewReplaceServerDefault(int(*e.Code)).WithPayload(e) + return server.NewReplaceServerBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { - reload := changeThroughRuntimeAPI(*params.Data, *ondisk, params.Backend, "", h.Client) + reload := changeThroughRuntimeAPI(*params.Data, *ondisk, pName, h.Client) if reload { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return server.NewReplaceServerDefault(int(*e.Code)).WithPayload(e) + return server.NewReplaceServerBackendDefault(int(*e.Code)).WithPayload(e) } - return server.NewReplaceServerOK().WithPayload(params.Data) + return server.NewReplaceServerBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return server.NewReplaceServerAccepted().WithReloadID(rID).WithPayload(params.Data) + return server.NewReplaceServerBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return server.NewReplaceServerOK().WithPayload(params.Data) + return server.NewReplaceServerBackendOK().WithPayload(params.Data) } - return server.NewReplaceServerAccepted().WithPayload(params.Data) + return server.NewReplaceServerBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/server_switching_rule.go b/handlers/server_switching_rule.go index c28a5a36..036ae378 100644 --- a/handlers/server_switching_rule.go +++ b/handlers/server_switching_rule.go @@ -17,43 +17,49 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/server_switching_rule" - "github.com/haproxytech/models" ) -//CreateServerSwitchingRuleHandlerImpl implementation of the CreateServerSwitchingRuleHandler interface using client-native client +// CreateServerSwitchingRuleHandlerImpl implementation of the CreateServerSwitchingRuleHandler interface using client-native client type CreateServerSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteServerSwitchingRuleHandlerImpl implementation of the DeleteServerSwitchingRuleHandler interface using client-native client +// DeleteServerSwitchingRuleHandlerImpl implementation of the DeleteServerSwitchingRuleHandler interface using client-native client type DeleteServerSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetServerSwitchingRuleHandlerImpl implementation of the GetServerSwitchingRuleHandler interface using client-native client +// GetServerSwitchingRuleHandlerImpl implementation of the GetServerSwitchingRuleHandler interface using client-native client type GetServerSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetServerSwitchingRulesHandlerImpl implementation of the GetServerSwitchingRulesHandler interface using client-native client +// GetServerSwitchingRulesHandlerImpl implementation of the GetServerSwitchingRulesHandler interface using client-native client type GetServerSwitchingRulesHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//ReplaceServerSwitchingRuleHandlerImpl implementation of the ReplaceServerSwitchingRuleHandler interface using client-native client +// ReplaceServerSwitchingRuleHandlerImpl implementation of the ReplaceServerSwitchingRuleHandler interface using client-native client type ReplaceServerSwitchingRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +type ReplaceServerSwitchingRulesHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.CreateServerSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.CreateServerSwitchingRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -73,7 +79,13 @@ func (h *CreateServerSwitchingRuleHandlerImpl) Handle(params server_switching_ru return server_switching_rule.NewCreateServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateServerSwitchingRule(params.Backend, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_switching_rule.NewCreateServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateServerSwitchingRule(params.Index, params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) return server_switching_rule.NewCreateServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) @@ -94,8 +106,8 @@ func (h *CreateServerSwitchingRuleHandlerImpl) Handle(params server_switching_ru return server_switching_rule.NewCreateServerSwitchingRuleAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.DeleteServerSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.DeleteServerSwitchingRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -115,7 +127,13 @@ func (h *DeleteServerSwitchingRuleHandlerImpl) Handle(params server_switching_ru return server_switching_rule.NewDeleteServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteServerSwitchingRule(params.ID, params.Backend, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_switching_rule.NewDeleteServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteServerSwitchingRule(params.Index, params.ParentName, t, v) if err != nil { e := misc.HandleError(err) return server_switching_rule.NewDeleteServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) @@ -136,38 +154,53 @@ func (h *DeleteServerSwitchingRuleHandlerImpl) Handle(params server_switching_ru return server_switching_rule.NewDeleteServerSwitchingRuleAccepted() } -//Handle executing the request and returning a response -func (h *GetServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.GetServerSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.GetServerSwitchingRuleParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rule, err := h.Client.Configuration.GetServerSwitchingRule(params.ID, params.Backend, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return server_switching_rule.NewGetServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return server_switching_rule.NewGetServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - return server_switching_rule.NewGetServerSwitchingRuleOK().WithPayload(&server_switching_rule.GetServerSwitchingRuleOKBody{Version: v, Data: rule}).WithConfigurationVersion(v) + + _, rule, err := configuration.GetServerSwitchingRule(params.Index, params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return server_switching_rule.NewGetServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + return server_switching_rule.NewGetServerSwitchingRuleOK().WithPayload(rule) } -//Handle executing the request and returning a response -func (h *GetServerSwitchingRulesHandlerImpl) Handle(params server_switching_rule.GetServerSwitchingRulesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetServerSwitchingRulesHandlerImpl) Handle(params server_switching_rule.GetServerSwitchingRulesParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rules, err := h.Client.Configuration.GetServerSwitchingRules(params.Backend, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return server_switching_rule.NewGetServerSwitchingRulesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return server_switching_rule.NewGetServerSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetServerSwitchingRules(params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return server_switching_rule.NewGetServerSwitchingRulesOK().WithPayload(models.ServerSwitchingRules{}) + } + return server_switching_rule.NewGetServerSwitchingRulesDefault(int(*e.Code)).WithPayload(e) } - return server_switching_rule.NewGetServerSwitchingRulesOK().WithPayload(&server_switching_rule.GetServerSwitchingRulesOKBody{Version: v, Data: rules}).WithConfigurationVersion(v) + return server_switching_rule.NewGetServerSwitchingRulesOK().WithPayload(rules) } -//Handle executing the request and returning a response -func (h *ReplaceServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.ReplaceServerSwitchingRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceServerSwitchingRuleHandlerImpl) Handle(params server_switching_rule.ReplaceServerSwitchingRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -187,7 +220,13 @@ func (h *ReplaceServerSwitchingRuleHandlerImpl) Handle(params server_switching_r return server_switching_rule.NewReplaceServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditServerSwitchingRule(params.ID, params.Backend, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_switching_rule.NewReplaceServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditServerSwitchingRule(params.Index, params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) return server_switching_rule.NewReplaceServerSwitchingRuleDefault(int(*e.Code)).WithPayload(e) @@ -207,3 +246,50 @@ func (h *ReplaceServerSwitchingRuleHandlerImpl) Handle(params server_switching_r } return server_switching_rule.NewReplaceServerSwitchingRuleAccepted().WithPayload(params.Data) } + +// Handle executing the request and returning a response +func (h *ReplaceServerSwitchingRulesHandlerImpl) Handle(params server_switching_rule.ReplaceServerSwitchingRulesParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return server_switching_rule.NewReplaceServerSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_switching_rule.NewReplaceServerSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceServerSwitchingRules(params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return server_switching_rule.NewReplaceServerSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return server_switching_rule.NewReplaceServerSwitchingRulesDefault(int(*e.Code)).WithPayload(e) + } + return server_switching_rule.NewReplaceServerSwitchingRulesOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return server_switching_rule.NewReplaceServerSwitchingRulesAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return server_switching_rule.NewReplaceServerSwitchingRulesAccepted().WithPayload(params.Data) +} diff --git a/handlers/server_template.go b/handlers/server_template.go new file mode 100644 index 00000000..84f9ec3c --- /dev/null +++ b/handlers/server_template.go @@ -0,0 +1,251 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/server_template" +) + +// CreateServerTemplateHandlerImpl implementation of the CreateServerTemplateHandler interface using client-native client +type CreateServerTemplateHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteServerTemplateHandlerImpl implementation of the DeleteServerTemplateHandler interface using client-native client +type DeleteServerTemplateHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetServerTemplateHandlerImpl implementation of the GetServerTemplateHandler interface using client-native client +type GetServerTemplateHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetServerTemplatesHandlerImpl implementation of the GetServerTemplatesHandler interface using client-native client +type GetServerTemplatesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceServerTemplateHandlerImpl implementation of the ReplaceServerTemplateHandler interface using client-native client +type ReplaceServerTemplateHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateServerTemplateHandlerImpl) Handle(params server_template.CreateServerTemplateParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return server_template.NewCreateServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_template.NewCreateServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateServerTemplate(params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return server_template.NewCreateServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return server_template.NewCreateServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + return server_template.NewCreateServerTemplateCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return server_template.NewCreateServerTemplateAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return server_template.NewCreateServerTemplateAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteServerTemplateHandlerImpl) Handle(params server_template.DeleteServerTemplateParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return server_template.NewDeleteServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_template.NewDeleteServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteServerTemplate(params.Prefix, params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return server_template.NewDeleteServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return server_template.NewDeleteServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + return server_template.NewDeleteServerTemplateNoContent() + } + rID := h.ReloadAgent.Reload() + return server_template.NewDeleteServerTemplateAccepted().WithReloadID(rID) + } + return server_template.NewDeleteServerTemplateAccepted() +} + +// Handle executing the request and returning a response +func (h *GetServerTemplateHandlerImpl) Handle(params server_template.GetServerTemplateParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_template.NewGetServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + _, template, err := configuration.GetServerTemplate(params.Prefix, params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return server_template.NewGetServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + return server_template.NewGetServerTemplateOK().WithPayload(template) +} + +// Handle executing the request and returning a response +func (h *GetServerTemplatesHandlerImpl) Handle(params server_template.GetServerTemplatesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_template.NewGetServerTemplatesDefault(int(*e.Code)).WithPayload(e) + } + + _, templates, err := configuration.GetServerTemplates(params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return server_template.NewGetServerTemplatesOK().WithPayload(models.ServerTemplates{}) + } + return server_template.NewGetServerTemplatesDefault(int(*e.Code)).WithPayload(e) + } + return server_template.NewGetServerTemplatesOK().WithPayload(templates) +} + +// Handle executing the request and returning a response +func (h *ReplaceServerTemplateHandlerImpl) Handle(params server_template.ReplaceServerTemplateParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return server_template.NewReplaceServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return server_template.NewReplaceServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + _, ondisk, err := configuration.GetServerTemplate(params.Prefix, params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return server_template.NewReplaceServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditServerTemplate(params.Prefix, params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return server_template.NewReplaceServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + reload := changeThroughRuntimeAPI(*params.Data, *ondisk, params.ParentName, h.Client) + if reload { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return server_template.NewReplaceServerTemplateDefault(int(*e.Code)).WithPayload(e) + } + return server_template.NewReplaceServerTemplateOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return server_template.NewReplaceServerTemplateAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return server_template.NewReplaceServerTemplateOK().WithPayload(params.Data) + } + return server_template.NewReplaceServerTemplateAccepted().WithPayload(params.Data) +} diff --git a/handlers/site.go b/handlers/site.go index af077bef..031d1f59 100644 --- a/handlers/site.go +++ b/handlers/site.go @@ -17,43 +17,44 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/sites" - "github.com/haproxytech/models" ) -//CreateSiteHandlerImpl implementation of the CreateSiteHandler interface using client-native client +// CreateSiteHandlerImpl implementation of the CreateSiteHandler interface using client-native client type CreateSiteHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteSiteHandlerImpl implementation of the DeleteSiteHandler interface using client-native client +// DeleteSiteHandlerImpl implementation of the DeleteSiteHandler interface using client-native client type DeleteSiteHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetSiteHandlerImpl implementation of the GetSiteHandler interface using client-native client +// GetSiteHandlerImpl implementation of the GetSiteHandler interface using client-native client type GetSiteHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetSitesHandlerImpl implementation of the GetSitesHandler interface using client-native client +// GetSitesHandlerImpl implementation of the GetSitesHandler interface using client-native client type GetSitesHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//ReplaceSiteHandlerImpl implementation of the ReplaceSiteHandler interface using client-native client +// ReplaceSiteHandlerImpl implementation of the ReplaceSiteHandler interface using client-native client type ReplaceSiteHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateSiteHandlerImpl) Handle(params sites.CreateSiteParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateSiteHandlerImpl) Handle(params sites.CreateSiteParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -73,7 +74,13 @@ func (h *CreateSiteHandlerImpl) Handle(params sites.CreateSiteParams, principal return sites.NewCreateSiteDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateSite(params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sites.NewCreateSiteDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateSite(params.Data, t, v) if err != nil { e := misc.HandleError(err) return sites.NewCreateSiteDefault(int(*e.Code)).WithPayload(e) @@ -93,8 +100,8 @@ func (h *CreateSiteHandlerImpl) Handle(params sites.CreateSiteParams, principal return sites.NewCreateSiteAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteSiteHandlerImpl) Handle(params sites.DeleteSiteParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteSiteHandlerImpl) Handle(params sites.DeleteSiteParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -114,7 +121,13 @@ func (h *DeleteSiteHandlerImpl) Handle(params sites.DeleteSiteParams, principal return sites.NewDeleteSiteDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteSite(params.Name, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sites.NewCreateSiteDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteSite(params.Name, t, v) if err != nil { e := misc.HandleError(err) return sites.NewDeleteSiteDefault(int(*e.Code)).WithPayload(e) @@ -134,38 +147,53 @@ func (h *DeleteSiteHandlerImpl) Handle(params sites.DeleteSiteParams, principal return sites.NewDeleteSiteAccepted() } -//Handle executing the request and returning a response -func (h *GetSiteHandlerImpl) Handle(params sites.GetSiteParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetSiteHandlerImpl) Handle(params sites.GetSiteParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, site, err := h.Client.Configuration.GetSite(params.Name, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sites.NewGetSiteDefault(int(*e.Code)).WithPayload(e) + } + + _, site, err := configuration.GetSite(params.Name, t) if err != nil { e := misc.HandleError(err) - return sites.NewGetSiteDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return sites.NewGetSiteDefault(int(*e.Code)).WithPayload(e) } - return sites.NewGetSiteOK().WithPayload(&sites.GetSiteOKBody{Version: v, Data: site}).WithConfigurationVersion(v) + return sites.NewGetSiteOK().WithPayload(site) } -//Handle executing the request and returning a response -func (h *GetSitesHandlerImpl) Handle(params sites.GetSitesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetSitesHandlerImpl) Handle(params sites.GetSitesParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, s, err := h.Client.Configuration.GetSites(t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return sites.NewGetSitesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return sites.NewGetSitesDefault(int(*e.Code)).WithPayload(e) + } + + _, s, err := configuration.GetSites(t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return sites.NewGetSitesOK().WithPayload(models.Sites{}) + } + return sites.NewGetSitesDefault(int(*e.Code)).WithPayload(e) } - return sites.NewGetSitesOK().WithPayload(&sites.GetSitesOKBody{Version: v, Data: s}).WithConfigurationVersion(v) + return sites.NewGetSitesOK().WithPayload(s) } -//Handle executing the request and returning a response -func (h *ReplaceSiteHandlerImpl) Handle(params sites.ReplaceSiteParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceSiteHandlerImpl) Handle(params sites.ReplaceSiteParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -185,7 +213,13 @@ func (h *ReplaceSiteHandlerImpl) Handle(params sites.ReplaceSiteParams, principa return sites.NewReplaceSiteDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditSite(params.Name, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sites.NewReplaceSiteDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditSite(params.Name, params.Data, t, v) if err != nil { e := misc.HandleError(err) return sites.NewReplaceSiteDefault(int(*e.Code)).WithPayload(e) diff --git a/handlers/spoe.go b/handlers/spoe.go new file mode 100644 index 00000000..970d6ad5 --- /dev/null +++ b/handlers/spoe.go @@ -0,0 +1,114 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/spoe" +) + +// SpoeCreateSpoeHandlerImpl implementation of the SpoeCreateSpoeAgentHandler interface +type SpoeCreateSpoeHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeCreateSpoeHandlerImpl) Handle(params spoe.CreateSpoeParams, principal any) middleware.Responder { + file, ok := params.FileUpload.(*runtime.File) + if !ok { + return spoe.NewCreateSpoeBadRequest() + } + + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeDefault(int(*e.Code)).WithPayload(e) + } + + path, err := spoeStorage.Create(file.Header.Filename, params.FileUpload) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewCreateSpoeCreated().WithPayload(path) +} + +// SpoeDeleteSpoeFileHandlerImpl implementation of the SpoeDeleteSpoeFileHandler interface +type SpoeDeleteSpoeFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeDeleteSpoeFileHandlerImpl) Handle(params spoe.DeleteSpoeFileParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeFileDefault(int(*e.Code)).WithPayload(e) + } + + err = spoeStorage.Delete(params.Name) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeFileDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewDeleteSpoeFileNoContent() +} + +// SpoeGetAllSpoeFilesHandlerImpl implementation of the SpoeGetAllSpoeFilesHandler interface +type SpoeGetAllSpoeFilesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// SpoeGetAllSpoeFilesHandlerImpl implementation of the SpoeGetAllSpoeFilesHandler +func (h *SpoeGetAllSpoeFilesHandlerImpl) Handle(params spoe.GetAllSpoeFilesParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + + files, err := spoeStorage.GetAll() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewGetAllSpoeFilesOK().WithPayload(files) +} + +// SpoeGetOneSpoeFileHandlerImpl implementation of the MapsGetOneRuntimeMapHandler interface +type SpoeGetOneSpoeFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeGetOneSpoeFileHandlerImpl) Handle(params spoe.GetOneSpoeFileParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetOneSpoeFileDefault(int(*e.Code)).WithPayload(e) + } + + path, err := spoeStorage.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetOneSpoeFileDefault(int(*e.Code)).WithPayload(e) + } + if path == "" { + return spoe.NewGetOneSpoeFileNotFound() + } + return spoe.NewGetOneSpoeFileOK().WithPayload(&spoe.GetOneSpoeFileOKBody{Data: path}) +} diff --git a/handlers/spoe_agent.go b/handlers/spoe_agent.go new file mode 100644 index 00000000..1cbe03f4 --- /dev/null +++ b/handlers/spoe_agent.go @@ -0,0 +1,184 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/spoe" +) + +// SpoeCreateSpoeAgentHandlerImpl implementation of the SpoeCreateSpoeAgentHandler interface +type SpoeCreateSpoeAgentHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeCreateSpoeAgentHandlerImpl) Handle(params spoe.CreateSpoeAgentParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.CreateAgent(params.ScopeName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewCreateSpoeAgentCreated().WithPayload(spoe.NewCreateSpoeAgentCreated().Payload) +} + +// SpoeDeleteSpoeAgentHandlerImpl implementation of the SpoeDeleteSpoeAgentHandler interface +type SpoeDeleteSpoeAgentHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeDeleteSpoeAgentHandlerImpl) Handle(params spoe.DeleteSpoeAgentParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.DeleteAgent(params.ScopeName, params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewDeleteSpoeAgentNoContent() +} + +// SpoeGetAllSpoeAgentHandlerImpl implementation of the SpoeGetSpoeAgentsHandler interface +type SpoeGetAllSpoeAgentHandlerImpl struct { + Client client_native.HAProxyClient +} + +// SpoeGetAllSpoeFilesHandlerImpl implementation of the SpoeGetAllSpoeFilesHandler +func (h *SpoeGetAllSpoeAgentHandlerImpl) Handle(params spoe.GetAllSpoeAgentParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, agents, err := ss.GetAgents(params.ScopeName, t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewGetAllSpoeAgentOK().WithPayload(agents) +} + +// SpoeGetSpoeAgentHandlerImpl implementation of the SpoeGetSpoeAgentHandler interface +type SpoeGetSpoeAgentHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeGetSpoeAgentHandlerImpl) Handle(params spoe.GetSpoeAgentParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, agent, err := ss.GetAgent(params.ScopeName, params.Name, t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + if agent == nil { + return spoe.NewGetSpoeAgentNotFound() + } + return spoe.NewGetSpoeAgentOK().WithPayload(agent) +} + +// SpoeReplaceSpoeAgentHandlerImpl implementation of the SpoeReplaceSpoeAgentHandler interface +type SpoeReplaceSpoeAgentHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeReplaceSpoeAgentHandlerImpl) Handle(params spoe.ReplaceSpoeAgentParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.EditAgent(params.ScopeName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeAgentDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewReplaceSpoeAgentOK() +} diff --git a/handlers/spoe_group.go b/handlers/spoe_group.go new file mode 100644 index 00000000..32191a11 --- /dev/null +++ b/handlers/spoe_group.go @@ -0,0 +1,184 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/spoe" +) + +// SpoeCreateSpoeGroupHandlerImpl implementation of the SpoeCreateSpoeGroupHandler interface +type SpoeCreateSpoeGroupHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeCreateSpoeGroupHandlerImpl) Handle(params spoe.CreateSpoeGroupParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.CreateGroup(params.ScopeName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewCreateSpoeGroupCreated().WithPayload(spoe.NewCreateSpoeGroupCreated().Payload) +} + +// SpoeDeleteSpoeGroupHandlerImpl implementation of the SpoeDeleteSpoeGroupHandler interface +type SpoeDeleteSpoeGroupHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeDeleteSpoeGroupHandlerImpl) Handle(params spoe.DeleteSpoeGroupParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.DeleteGroup(params.ScopeName, params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewDeleteSpoeAgentNoContent() +} + +// SpoeGetAllSpoeGroupHandlerImpl implementation of the SpoeGetSpoeGroupsHandler interface +type SpoeGetAllSpoeGroupHandlerImpl struct { + Client client_native.HAProxyClient +} + +// SpoeGetAllSpoeGroupHandlerImpl implementation of the SpoeGetAllSpoeFilesHandler +func (h *SpoeGetAllSpoeGroupHandlerImpl) Handle(params spoe.GetAllSpoeGroupParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, groups, err := ss.GetGroups(params.ScopeName, t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewGetAllSpoeGroupOK().WithPayload(groups) +} + +// SpoeGetSpoeGroupHandlerImpl implementation of the SpoeGetSpoeGroupHandler interface +type SpoeGetSpoeGroupHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeGetSpoeGroupHandlerImpl) Handle(params spoe.GetSpoeGroupParams, c any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, group, err := ss.GetGroup(params.ScopeName, params.Name, t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + if group == nil { + return spoe.NewGetSpoeGroupNotFound() + } + return spoe.NewGetSpoeGroupOK().WithPayload(group) +} + +// SpoeReplaceSpoeGroupHandlerImpl implementation of the SpoeReplaceSpoeGroupHandler interface +type SpoeReplaceSpoeGroupHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeReplaceSpoeGroupHandlerImpl) Handle(params spoe.ReplaceSpoeGroupParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.EditGroup(params.ScopeName, params.Data, params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeGroupDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewReplaceSpoeGroupOK() +} diff --git a/handlers/spoe_message.go b/handlers/spoe_message.go new file mode 100644 index 00000000..3d97c542 --- /dev/null +++ b/handlers/spoe_message.go @@ -0,0 +1,185 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/spoe" +) + +// SpoeCreateSpoeMessageHandlerImpl implementation of the SpoeCreateSpoeMessageHandler interface +type SpoeCreateSpoeMessageHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeCreateSpoeMessageHandlerImpl) Handle(params spoe.CreateSpoeMessageParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.CreateMessage(params.ScopeName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewCreateSpoeMessageCreated().WithPayload(spoe.NewCreateSpoeMessageCreated().Payload) +} + +// SpoeDeleteSpoeMessageHandlerImpl implementation of the SpoeDeleteSpoeMessageHandler interface +type SpoeDeleteSpoeMessageHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeDeleteSpoeMessageHandlerImpl) Handle(params spoe.DeleteSpoeMessageParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.DeleteMessage(params.ScopeName, params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewDeleteSpoeAgentNoContent() +} + +// SpoeGetAllSpoeMessageHandlerImpl implementation of the SpoeGetSpoeMessagesHandler interface +type SpoeGetAllSpoeMessageHandlerImpl struct { + Client client_native.HAProxyClient +} + +// SpoeGetAllSpoeMessageHandlerImpl implementation of the SpoeGetAllSpoeFilesHandler +func (h *SpoeGetAllSpoeMessageHandlerImpl) Handle(params spoe.GetAllSpoeMessageParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, messages, err := ss.GetMessages(params.ScopeName, t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewGetAllSpoeMessageOK().WithPayload(messages) +} + +// SpoeGetSpoeMessageHandlerImpl implementation of the SpoeGetSpoeMessageHandler interface +type SpoeGetSpoeMessageHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeGetSpoeMessageHandlerImpl) Handle(params spoe.GetSpoeMessageParams, c any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, message, err := ss.GetMessage(params.ScopeName, params.Name, t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + if message == nil { + return spoe.NewGetSpoeMessageNotFound() + } + return spoe.NewGetSpoeMessageOK().WithPayload(message) +} + +// SpoeReplaceSpoeMessageHandlerImpl implementation of the SpoeReplaceSpoeMessageHandler interface +type SpoeReplaceSpoeMessageHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeReplaceSpoeMessageHandlerImpl) Handle(params spoe.ReplaceSpoeMessageParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.EditMessage(params.ScopeName, params.Data, params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewReplaceSpoeMessageDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewReplaceSpoeMessageOK() +} diff --git a/handlers/spoe_scope.go b/handlers/spoe_scope.go new file mode 100644 index 00000000..0c124ae3 --- /dev/null +++ b/handlers/spoe_scope.go @@ -0,0 +1,152 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/spoe" +) + +// SpoeCreateSpoeScopeHandlerImpl implementation of the SpoeCreateSpoeScopeHandler interface +type SpoeCreateSpoeScopeHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeCreateSpoeScopeHandlerImpl) Handle(params spoe.CreateSpoeScopeParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.CreateScope(¶ms.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewCreateSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewCreateSpoeScopeCreated().WithPayload(spoe.NewCreateSpoeScopeCreated().Payload) +} + +// SpoeDeleteSpoeScopeHandlerImpl implementation of the SpoeDeleteSpoeScopeHandler interface +type SpoeDeleteSpoeScopeHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeDeleteSpoeScopeHandlerImpl) Handle(params spoe.DeleteSpoeScopeParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + v := int64(0) + if params.Version != nil { + v = *params.Version + } + err = ss.DeleteScope(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return spoe.NewDeleteSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewDeleteSpoeScopeNoContent() +} + +// SpoeGetAllSpoeScopeHandlerImpl implementation of the SpoeGetSpoeScopesHandler interface +type SpoeGetAllSpoeScopeHandlerImpl struct { + Client client_native.HAProxyClient +} + +// SpoeGetAllSpoeFilesHandlerImpl implementation of the SpoeGetAllSpoeFilesHandler +func (h *SpoeGetAllSpoeScopeHandlerImpl) Handle(params spoe.GetAllSpoeScopeParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, scopes, err := ss.GetScopes(t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetAllSpoeFilesDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewGetAllSpoeScopeOK().WithPayload(scopes) +} + +// SpoeGetSpoeScopeHandlerImpl implementation of the SpoeGetSpoeScopeHandler interface +type SpoeGetSpoeScopeHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *SpoeGetSpoeScopeHandlerImpl) Handle(params spoe.GetSpoeScopeParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + _, scope, err := ss.GetScope(params.Name, t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + if scope == nil { + return spoe.NewGetSpoeScopeNotFound() + } + return spoe.NewGetSpoeScopeOK().WithPayload(*scope) +} diff --git a/handlers/spoe_transaction.go b/handlers/spoe_transaction.go new file mode 100644 index 00000000..d545b7f0 --- /dev/null +++ b/handlers/spoe_transaction.go @@ -0,0 +1,196 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/spoe_transactions" +) + +// SpoeTransactionsStartSpoeTransactionHandlerImpl implementation of the SpoeTransactionsStartSpoeTransactionHandler interface +type SpoeTransactionsStartSpoeTransactionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *SpoeTransactionsStartSpoeTransactionHandlerImpl) Handle(params spoe_transactions.StartSpoeTransactionParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + t, err := ss.Transaction.StartTransaction(params.Version) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + m := &models.SpoeTransaction{ + ID: t.ID, + Version: t.Version, + Status: t.Status, + } + return spoe_transactions.NewStartSpoeTransactionCreated().WithPayload(m) +} + +// SpoeTransactionsDeleteSpoeTransactionHandlerImpl implementation of the DeleteTransactionHandler interface +type SpoeTransactionsDeleteSpoeTransactionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *SpoeTransactionsDeleteSpoeTransactionHandlerImpl) Handle(params spoe_transactions.DeleteSpoeTransactionParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + err = ss.Transaction.DeleteTransaction(params.ID) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewDeleteSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + return spoe_transactions.NewDeleteSpoeTransactionNoContent() +} + +// SpoeTransactionsGetSpoeTransactionHandlerImpl implementation of the SpoeTransactionsGetSpoeTransactionHandler interface +type SpoeTransactionsGetSpoeTransactionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *SpoeTransactionsGetSpoeTransactionHandlerImpl) Handle(params spoe_transactions.GetSpoeTransactionParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + t, err := ss.Transaction.GetTransaction(params.ID) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + m := &models.SpoeTransaction{ + ID: t.ID, + Version: t.Version, + Status: t.Status, + } + return spoe_transactions.NewGetSpoeTransactionOK().WithPayload(m) +} + +// SpoeTransactionsGetAllSpoeTransactionHandlerImpl implementation of the SpoeTransactionsGetSpoeTransactionsHandler interface +type SpoeTransactionsGetAllSpoeTransactionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *SpoeTransactionsGetAllSpoeTransactionHandlerImpl) Handle(params spoe_transactions.GetAllSpoeTransactionParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewGetAllSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewGetAllSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + s := "" + if params.Status != nil { + s = *params.Status + } + ts, err := ss.Transaction.GetTransactions(s) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewGetAllSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + var ms models.SpoeTransactions + if *ts != nil && len(*ts) > 0 { + for _, t := range *ts { + m := &models.SpoeTransaction{ + Version: t.Version, + ID: t.ID, + Status: t.Status, + } + ms = append(ms, m) + } + } + return spoe_transactions.NewGetAllSpoeTransactionOK().WithPayload(ms) +} + +// SpoeTransactionsCommitSpoeTransactionHandlerImpl implementation of the SpoeTransactionsCommitSpoeTransactionHandler interface +type SpoeTransactionsCommitSpoeTransactionHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *SpoeTransactionsCommitSpoeTransactionHandlerImpl) Handle(params spoe_transactions.CommitSpoeTransactionParams, principal any) middleware.Responder { + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewStartSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + t, err := ss.Transaction.CommitTransaction(params.ID) + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewCommitSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + m := &models.SpoeTransaction{ + ID: t.ID, + Version: t.Version, + Status: t.Status, + } + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return spoe_transactions.NewCommitSpoeTransactionDefault(int(*e.Code)).WithPayload(e) + } + return spoe_transactions.NewCommitSpoeTransactionOK().WithPayload(m) + } + rID := h.ReloadAgent.Reload() + return spoe_transactions.NewCommitSpoeTransactionAccepted().WithReloadID(rID).WithPayload(m) +} diff --git a/handlers/spoe_version.go b/handlers/spoe_version.go new file mode 100644 index 00000000..8847da2d --- /dev/null +++ b/handlers/spoe_version.go @@ -0,0 +1,55 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/spoe" +) + +// SpoeGetSpoeConfigurationVersionHandlerImpl implementation of the SpoeGetSpoeConfigurationVersionHandler interface +type SpoeGetSpoeConfigurationVersionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *SpoeGetSpoeConfigurationVersionHandlerImpl) Handle(params spoe.GetSpoeConfigurationVersionParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + spoeStorage, err := h.Client.Spoe() + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeScopeDefault(int(*e.Code)).WithPayload(e) + } + + ss, err := spoeStorage.GetSingleSpoe(params.ParentName) + if err != nil { + status := misc.GetHTTPStatusFromErr(err) + return spoe.NewGetSpoeScopeDefault(status).WithPayload(misc.SetError(status, err.Error())) + } + v, err := ss.GetConfigurationVersion(t) + if err != nil { + e := misc.HandleError(err) + return spoe.NewGetSpoeConfigurationVersionDefault(int(*e.Code)).WithPayload(e) + } + return spoe.NewGetSpoeConfigurationVersionOK().WithPayload(v) +} diff --git a/handlers/ssl_ca_runtime.go b/handlers/ssl_ca_runtime.go new file mode 100644 index 00000000..3d113d68 --- /dev/null +++ b/handlers/ssl_ca_runtime.go @@ -0,0 +1,207 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "io" + + oapi "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/dataplaneapi/misc" + ssl_runtime "github.com/haproxytech/dataplaneapi/operations/s_s_l_runtime" +) + +type GetAllCaFilesHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetAllCaFilesHandlerImpl) Handle(params ssl_runtime.GetAllCaFilesParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCaFilesDefault(int(*e.Code)).WithPayload(e) + } + + files, err := runtime.ShowCAFiles() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCaFilesDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetAllCaFilesOK().WithPayload(files) +} + +type CreateCaFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h CreateCaFileHandlerImpl) Handle(params ssl_runtime.CreateCaFileParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCaFileDefault(int(*e.Code)).WithPayload(e) + } + + file, ok := params.FileUpload.(*oapi.File) + if !ok { + return ssl_runtime.NewCreateCaFileBadRequest() + } + + // Create a new empty file. + if err = runtime.NewCAFile(file.Header.Filename); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCaFileDefault(int(*e.Code)).WithPayload(e) + } + + // Set its contents. + payload, err := io.ReadAll(file) + file.Close() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCaFileDefault(int(*e.Code)).WithPayload(e) + } + if err = runtime.SetCAFile(file.Header.Filename, string(payload)); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCaFileDefault(int(*e.Code)).WithPayload(e) + } + + // Commit. + if err = runtime.CommitCAFile(file.Header.Filename); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCaFileDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewCreateCaFileCreated() +} + +type GetCaFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetCaFileHandlerImpl) Handle(params ssl_runtime.GetCaFileParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCaFileDefault(int(*e.Code)).WithPayload(e) + } + + caFile, err := runtime.GetCAFile(params.Name) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCaFileDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetCaFileOK().WithPayload(caFile) +} + +type SetCaFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h SetCaFileHandlerImpl) Handle(params ssl_runtime.SetCaFileParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewSetCaFileDefault(int(*e.Code)).WithPayload(e) + } + + payload, err := io.ReadAll(params.FileUpload) + params.FileUpload.Close() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewSetCaFileDefault(int(*e.Code)).WithPayload(e) + } + if err = runtime.SetCAFile(params.Name, string(payload)); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewSetCaFileDefault(int(*e.Code)).WithPayload(e) + } + + if err = runtime.CommitCAFile(params.Name); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewSetCaFileDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewCreateCaFileCreated() +} + +type DeleteCaFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h DeleteCaFileHandlerImpl) Handle(params ssl_runtime.DeleteCaFileParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCaFileDefault(int(*e.Code)).WithPayload(e) + } + + if err = runtime.DeleteCAFile(params.Name); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCaFileDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewDeleteCaFileNoContent() +} + +type AddCaEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h AddCaEntryHandlerImpl) Handle(params ssl_runtime.AddCaEntryParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewAddCaEntryDefault(int(*e.Code)).WithPayload(e) + } + + payload, err := io.ReadAll(params.FileUpload) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewAddCaEntryDefault(int(*e.Code)).WithPayload(e) + } + + if err = runtime.AddCAFileEntry(params.Name, string(payload)); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewAddCaEntryDefault(int(*e.Code)).WithPayload(e) + } + + if err = runtime.CommitCAFile(params.Name); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewAddCaEntryDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewAddCaEntryCreated() +} + +type GetCaEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetCaEntryHandlerImpl) Handle(params ssl_runtime.GetCaEntryParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCaEntryDefault(int(*e.Code)).WithPayload(e) + } + entry, err := runtime.ShowCAFile(params.Name, ¶ms.Index) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCaEntryDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetCaEntryOK().WithPayload(entry) +} diff --git a/handlers/ssl_cert_storage.go b/handlers/ssl_cert_storage.go new file mode 100644 index 00000000..9f4100a1 --- /dev/null +++ b/handlers/ssl_cert_storage.go @@ -0,0 +1,364 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "bufio" + "bytes" + "fmt" + "io" + "path/filepath" + "strings" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + client_native "github.com/haproxytech/client-native/v6" + models "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/storage" +) + +// StorageGetAllStorageSSLCertificatesHandlerImpl implementation of the StorageGetAllStorageSSLCertificatesHandler interface +type StorageGetAllStorageSSLCertificatesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *StorageGetAllStorageSSLCertificatesHandlerImpl) Handle(params storage.GetAllStorageSSLCertificatesParams, principal any) middleware.Responder { + sslStorage, err := h.Client.SSLCertStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageSSLCertificatesDefault(int(*e.Code)).WithPayload(e) + } + + filelist, err := sslStorage.GetAll() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageSSLCertificatesDefault(int(*e.Code)).WithPayload(e) + } + + retFiles := []*models.SslCertificate{} + for _, f := range filelist { + retFiles = append(retFiles, &models.SslCertificate{ + File: f, + Description: "managed SSL file", + StorageName: filepath.Base(f), + }) + } + return &storage.GetAllStorageSSLCertificatesOK{Payload: retFiles} +} + +// StorageGetOneStorageMapHandlerImpl implementation of the StorageGetOneStorageSSLCertificateHandler interface +type StorageGetOneStorageSSLCertificateHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageGetOneStorageSSLCertificateHandlerImpl) Handle(params storage.GetOneStorageSSLCertificateParams, principal any) middleware.Responder { + sslStorage, err := h.Client.SSLCertStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + filename, size, err := sslStorage.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + if filename == "" { + return storage.NewGetOneStorageSSLCertificateNotFound() + } + info, err := sslStorage.GetCertificatesInfo(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + retf := &models.SslCertificate{ + File: filename, + Description: "managed SSL file", + StorageName: filepath.Base(filename), + Size: &size, + NotAfter: (*strfmt.DateTime)(info.NotAfter), + NotBefore: (*strfmt.DateTime)(info.NotBefore), + Issuers: info.Issuers, + Domains: info.DNS, + IPAddresses: info.IPs, + Subject: info.Subject, + Serial: info.Serial, + } + return storage.NewGetOneStorageSSLCertificateOK().WithPayload(retf) +} + +// StorageDeleteStorageSSLCertificateHandlerImpl implementation of the StorageDeleteStorageSSLCertificateHandler interface +type StorageDeleteStorageSSLCertificateHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageDeleteStorageSSLCertificateHandlerImpl) Handle(params storage.DeleteStorageSSLCertificateParams, principal any) middleware.Responder { + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + runningConf := strings.NewReader(configuration.Parser().String()) + + sslStorage, err := h.Client.SSLCertStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + filename, _, err := sslStorage.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + // this is far from perfect but should provide a basic level of protection + scanner := bufio.NewScanner(runningConf) + + lineNr := 0 + + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if strings.Contains(line, filename) && !strings.HasPrefix(line, "#") { + errCode := misc.ErrHTTPConflict + errMsg := fmt.Sprintf("rejecting attempt to delete file %s referenced in haproxy conf at line %d: %s", filename, lineNr-1, line) + e := &models.Error{Code: &errCode, Message: &errMsg} + return storage.NewDeleteStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + lineNr++ + } + + err = sslStorage.Delete(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if skipReload { + return storage.NewDeleteStorageSSLCertificateNoContent() + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewDeleteStorageSSLCertificateNoContent() + } + + if runtime, err := h.Client.Runtime(); err != nil { + if err = runtime.DeleteCertEntry(params.Name); err == nil { + return storage.NewDeleteStorageSSLCertificateNoContent() + } + log.Debugf("failed to delete certificate via runtime, reloading instead: %s", err.Error()) + } + + rID := h.ReloadAgent.Reload() + return storage.NewDeleteStorageSSLCertificateAccepted().WithReloadID(rID) +} + +// StorageReplaceStorageSSLCertificateHandlerImpl implementation of the StorageReplaceStorageSSLCertificateHandler interface +type StorageReplaceStorageSSLCertificateHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageReplaceStorageSSLCertificateHandlerImpl) Handle(params storage.ReplaceStorageSSLCertificateParams, principal any) middleware.Responder { + sslStorage, err := h.Client.SSLCertStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + filename, err := sslStorage.Replace(params.Name, params.Data) + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + info, err := sslStorage.GetCertificatesInfo(filename) + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + retf := &models.SslCertificate{ + File: filename, + Description: "managed SSL file", + StorageName: filepath.Base(filename), + Size: misc.Int64P(len(params.Data)), + NotAfter: (*strfmt.DateTime)(info.NotAfter), + NotBefore: (*strfmt.DateTime)(info.NotBefore), + Issuers: info.Issuers, + Domains: info.DNS, + IPAddresses: info.IPs, + Subject: info.Subject, + Serial: info.Serial, + } + + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if skipReload { + return storage.NewReplaceStorageSSLCertificateOK().WithPayload(retf) + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewReplaceStorageSSLCertificateOK().WithPayload(retf) + } + + // Try to push the new cert to HAProxy using the runtime socket. + err = pushCertToRuntime(h.Client, filename, params.Data, false) + if err != nil { + log.Debugf("failed to push certificate via runtime, reloading instead: %s", err.Error()) + rID := h.ReloadAgent.Reload() + return storage.NewReplaceStorageSSLCertificateAccepted().WithReloadID(rID).WithPayload(retf) + } + + return storage.NewReplaceStorageSSLCertificateOK().WithPayload(retf) +} + +// StorageCreateStorageSSLCertificateHandlerImpl implementation of the StorageCreateStorageSSLCertificateHandler interface +type StorageCreateStorageSSLCertificateHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageCreateStorageSSLCertificateHandlerImpl) Handle(params storage.CreateStorageSSLCertificateParams, principal any) middleware.Responder { + sslStorage, err := h.Client.SSLCertStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + file, ok := params.FileUpload.(*runtime.File) + if !ok { + return storage.NewCreateStorageSSLCertificateBadRequest() + } + + // We need to read the cert here because we are going to write it twice: + // once to the filesystem, and (optionally) to HAProxy's runtime socket. + certBody, err := io.ReadAll(file) + file.Close() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + + filename, size, err := sslStorage.Create(file.Header.Filename, io.NopCloser(bytes.NewReader(certBody))) + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + info, err := sslStorage.GetCertificatesInfo(filename) + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + retf := &models.SslCertificate{ + File: filename, + Description: "managed SSL file", + StorageName: filepath.Base(filename), + Size: &size, + NotAfter: (*strfmt.DateTime)(info.NotAfter), + NotBefore: (*strfmt.DateTime)(info.NotBefore), + Issuers: info.Issuers, + Domains: info.DNS, + IPAddresses: info.IPs, + Subject: info.Subject, + Serial: info.Serial, + } + + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if skipReload { + return storage.NewCreateStorageSSLCertificateCreated().WithPayload(retf) + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCertificateDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewCreateStorageSSLCertificateCreated().WithPayload(retf) + } + + // Try to push the new cert to HAProxy using the runtime socket. + err = pushCertToRuntime(h.Client, filename, string(certBody), true) + if err != nil { + log.Debugf("failed to push certificate via runtime, reloading instead: %s", err.Error()) + rID := h.ReloadAgent.Reload() + return storage.NewCreateStorageSSLCertificateAccepted().WithReloadID(rID).WithPayload(retf) + } + + return storage.NewCreateStorageSSLCertificateCreated().WithPayload(retf) +} + +func pushCertToRuntime(c client_native.HAProxyClient, filename, body string, newCert bool) error { + runtime, err := c.Runtime() + if err != nil { + return err + } + + if newCert { + err = runtime.NewCertEntry(filename) + if err != nil { + return err + } + } + + err = runtime.SetCertEntry(filename, body) + if err != nil { + return err + } + + return runtime.CommitCertEntry(filename) +} diff --git a/handlers/ssl_certs_runtime.go b/handlers/ssl_certs_runtime.go new file mode 100644 index 00000000..51c337f2 --- /dev/null +++ b/handlers/ssl_certs_runtime.go @@ -0,0 +1,164 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "io" + + oapi "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/dataplaneapi/misc" + ssl_runtime "github.com/haproxytech/dataplaneapi/operations/s_s_l_runtime" +) + +type GetAllCertsHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetAllCertsHandlerImpl) Handle(params ssl_runtime.GetAllCertsParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCertsDefault(int(*e.Code)).WithPayload(e) + } + + files, err := runtime.ShowCerts() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCertsDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetAllCertsOK().WithPayload(files) +} + +type CreateCertHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h CreateCertHandlerImpl) Handle(params ssl_runtime.CreateCertParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCertDefault(int(*e.Code)).WithPayload(e) + } + + file, ok := params.FileUpload.(*oapi.File) + if !ok { + return ssl_runtime.NewCreateCertBadRequest() + } + + payload, err := io.ReadAll(file) + file.Close() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCertDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.NewCertEntry(file.Header.Filename) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCertDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.SetCertEntry(file.Header.Filename, string(payload)) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCertDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.CommitCertEntry(file.Header.Filename) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCertDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewCreateCertCreated() +} + +type GetCertHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetCertHandlerImpl) Handle(params ssl_runtime.GetCertParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCertDefault(int(*e.Code)).WithPayload(e) + } + + cert, err := runtime.ShowCertificate(params.Name) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCertDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetCertOK().WithPayload(cert) +} + +type ReplaceCertHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h ReplaceCertHandlerImpl) Handle(params ssl_runtime.ReplaceCertParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCertDefault(int(*e.Code)).WithPayload(e) + } + + payload, err := io.ReadAll(params.FileUpload) + params.FileUpload.Close() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCertDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.SetCertEntry(params.Name, string(payload)) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCertDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.CommitCertEntry(params.Name) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCertDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewReplaceCertOK() +} + +// api.SslRuntimeDeleteCertHandler = nil +type DeleteCertHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h DeleteCertHandlerImpl) Handle(params ssl_runtime.DeleteCertParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCertDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.DeleteCertEntry(params.Name) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCertDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewDeleteCertNoContent() +} diff --git a/handlers/ssl_crl_lists_runtime.go b/handlers/ssl_crl_lists_runtime.go new file mode 100644 index 00000000..a2253ed2 --- /dev/null +++ b/handlers/ssl_crl_lists_runtime.go @@ -0,0 +1,160 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "io" + + oapi "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/dataplaneapi/misc" + ssl_runtime "github.com/haproxytech/dataplaneapi/operations/s_s_l_runtime" +) + +type GetAllCrlHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetAllCrlHandlerImpl) Handle(params ssl_runtime.GetAllCrlParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCrlDefault(int(*e.Code)).WithPayload(e) + } + + files, err := runtime.ShowCrlFiles() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCrlDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetAllCrlOK().WithPayload(files) +} + +type CreateCrlHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h CreateCrlHandlerImpl) Handle(params ssl_runtime.CreateCrlParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCrlDefault(int(*e.Code)).WithPayload(e) + } + + file, ok := params.FileUpload.(*oapi.File) + if !ok { + return ssl_runtime.NewCreateCaFileBadRequest() + } + + payload, err := io.ReadAll(file) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCrlDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.NewCrlFile(file.Header.Filename) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCrlDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.SetCrlFile(file.Header.Filename, string(payload)) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCrlDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.CommitCrlFile(file.Header.Filename) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewCreateCrlDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewCreateCrlCreated() +} + +type GetCrlHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetCrlHandlerImpl) Handle(params ssl_runtime.GetCrlParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCrlDefault(int(*e.Code)).WithPayload(e) + } + + entries, err := runtime.ShowCrlFile(params.Name, params.Index) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetCrlDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetCrlOK().WithPayload(*entries) +} + +type ReplaceCrlHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h ReplaceCrlHandlerImpl) Handle(params ssl_runtime.ReplaceCrlParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCrlDefault(int(*e.Code)).WithPayload(e) + } + + payload, err := io.ReadAll(params.FileUpload) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCrlDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.SetCrlFile(params.Name, string(payload)) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCrlDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.CommitCrlFile(params.Name) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewReplaceCrlDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewReplaceCrlOK() +} + +type DeleteCrlHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h DeleteCrlHandlerImpl) Handle(params ssl_runtime.DeleteCrlParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCrlDefault(int(*e.Code)).WithPayload(e) + } + + if err = runtime.DeleteCrlFile(params.Name); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCrlDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewDeleteCrlNoContent() +} diff --git a/handlers/ssl_crt_list_storage.go b/handlers/ssl_crt_list_storage.go new file mode 100644 index 00000000..2c8e8a53 --- /dev/null +++ b/handlers/ssl_crt_list_storage.go @@ -0,0 +1,441 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "bufio" + "errors" + "fmt" + "io" + "os" + "path/filepath" + "strings" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + cnconf "github.com/haproxytech/client-native/v6/configuration" + models "github.com/haproxytech/client-native/v6/models" + cnruntime "github.com/haproxytech/client-native/v6/runtime" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/storage" +) + +type StorageGetAllStorageSSLCrtListFilesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *StorageGetAllStorageSSLCrtListFilesHandlerImpl) Handle(params storage.GetAllStorageSSLCrtListFilesParams, principal any) middleware.Responder { + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageSSLCrtListFilesDefault(int(*e.Code)).WithPayload(e) + } + + filelist, err := crtListStorage.GetAll() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetAllStorageSSLCrtListFilesDefault(int(*e.Code)).WithPayload(e) + } + + retFiles := models.SslCrtListFiles{} + for _, f := range filelist { + retFiles = append(retFiles, &models.SslCrtListFile{ + File: f, + Description: "managed certificate list", + StorageName: filepath.Base(f), + }) + } + return &storage.GetAllStorageSSLCrtListFilesOK{Payload: retFiles} +} + +type StorageGetOneStorageSSLCrtListFileHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageGetOneStorageSSLCrtListFileHandlerImpl) Handle(params storage.GetOneStorageSSLCrtListFileParams, principal any) middleware.Responder { + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + filename, _, err := crtListStorage.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + if filename == "" { + return storage.NewGetOneStorageSSLCrtListFileNotFound() + } + + f, err := os.Open(filename) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetOneStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + return storage.NewGetOneStorageSSLCrtListFileOK().WithPayload(f) +} + +type StorageDeleteStorageSSLCrtListFileHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageDeleteStorageSSLCrtListFileHandlerImpl) Handle(params storage.DeleteStorageSSLCrtListFileParams, principal any) middleware.Responder { + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + runningConf := strings.NewReader(configuration.Parser().String()) + + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + filename, _, err := crtListStorage.Get(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + // this is far from perfect but should provide a basic level of protection + scanner := bufio.NewScanner(runningConf) + + lineNr := 0 + + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if len(line) > 0 && line[0] != '#' && strings.Contains(line, filename) { + errCode := misc.ErrHTTPConflict + errMsg := fmt.Sprintf("rejecting attempt to delete file %s referenced in haproxy conf at line %d: %s", filename, lineNr-1, line) + e := &models.Error{Code: &errCode, Message: &errMsg} + return storage.NewDeleteStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + lineNr++ + } + + err = crtListStorage.Delete(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if skipReload { + return storage.NewDeleteStorageSSLCrtListFileNoContent() + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewDeleteStorageSSLCrtListFileNoContent() + } + + rID := h.ReloadAgent.Reload() + return storage.NewDeleteStorageSSLCrtListFileAccepted().WithReloadID(rID) +} + +type StorageReplaceStorageSSLCrtListFileHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageReplaceStorageSSLCrtListFileHandlerImpl) Handle(params storage.ReplaceStorageSSLCrtListFileParams, principal any) middleware.Responder { + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + filename, err := crtListStorage.Replace(params.Name, params.Data) + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + retf := &models.SslCrtListFile{ + File: filename, + Description: "managed certificate list", + StorageName: filepath.Base(filename), + Size: misc.Int64P(len(params.Data)), + } + + skipReload := false + if params.SkipReload != nil { + skipReload = *params.SkipReload + } + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if skipReload { + return storage.NewReplaceStorageSSLCrtListFileOK().WithPayload(retf) + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewReplaceStorageSSLCrtListFileOK().WithPayload(retf) + } + + rID := h.ReloadAgent.Reload() + return storage.NewReplaceStorageSSLCrtListFileAccepted().WithReloadID(rID).WithPayload(retf) +} + +type StorageCreateStorageSSLCrtListFileHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageCreateStorageSSLCrtListFileHandlerImpl) Handle(params storage.CreateStorageSSLCrtListFileParams, principal any) middleware.Responder { + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + file, ok := params.FileUpload.(*runtime.File) + if !ok { + return storage.NewCreateStorageSSLCrtListFileBadRequest() + } + filename, size, err := crtListStorage.Create(file.Header.Filename, params.FileUpload) + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCrtListFileDefault(int(*e.Code)).WithPayload(e) + } + + retf := &models.SslCrtListFile{ + File: filename, + Description: "managed certificate list", + StorageName: filepath.Base(filename), + Size: &size, + } + + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewReplaceStorageMapFileDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewCreateStorageSSLCrtListFileCreated().WithPayload(retf) + } + rID := h.ReloadAgent.Reload() + return storage.NewCreateStorageSSLCrtListFileAccepted().WithReloadID(rID).WithPayload(retf) +} + +// +// crt-list entries +// + +type StorageGetStorageSSLCrtListEntriesHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h *StorageGetStorageSSLCrtListEntriesHandlerImpl) Handle(params storage.GetStorageSSLCrtListEntriesParams, principal any) middleware.Responder { + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewGetStorageSSLCrtListEntriesDefault(int(*e.Code)).WithPayload(e) + } + contents, err := crtListStorage.GetContents(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetStorageSSLCrtListEntriesDefault(int(*e.Code)).WithPayload(e) + } + entries, err := cnruntime.ParseCrtListEntries(contents) + if err != nil { + e := misc.HandleError(err) + return storage.NewGetStorageSSLCrtListEntriesDefault(int(*e.Code)).WithPayload(e) + } + + return storage.NewGetStorageSSLCrtListEntriesOK().WithPayload(entries) +} + +type StorageCreateStorageSSLCrtListEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *StorageCreateStorageSSLCrtListEntryHandlerImpl) Handle(params storage.CreateStorageSSLCrtListEntryParams, principal any) middleware.Responder { + entry := params.Data + if entry.File == "" { + e := misc.SetError(400, "missing certificate file name") + return storage.NewCreateStorageSSLCrtListEntryBadRequest().WithPayload(e) + } + + // Serialize the entry to a single line. + var sb strings.Builder + sb.Grow(len(entry.File) + len(entry.SSLBindConfig) + 32) + sb.WriteString(entry.File) + if entry.SSLBindConfig != "" { + sb.WriteString(" [") + sb.WriteString(entry.SSLBindConfig) + sb.WriteByte(']') + } + if len(entry.SNIFilter) > 0 { + sb.WriteByte(' ') + sb.WriteString(strings.Join(entry.SNIFilter, " ")) + } + sb.WriteByte('\n') + line := sb.String() + + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + // Append the entry to the crt-list file. + content, err := crtListStorage.GetContents(params.Name) + if err == nil { + _, err = crtListStorage.Replace(params.Name, content+line) + } else if errors.Is(err, cnconf.ErrObjectDoesNotExist) { + _, _, err = crtListStorage.Create(params.Name, io.NopCloser(strings.NewReader(line))) + } + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + // Try to add the entry to the HAProxy runtime. Force the reload if that fails. + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + rt, err := h.Client.Runtime() + if err != nil { + forceReload = true + } else { + if errAdd := rt.AddCrtListEntry(params.Name, *entry); errAdd != nil { + log.Warning("failed to add crt-list entry via runtime: ", errAdd) + forceReload = true + } + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewCreateStorageSSLCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewCreateStorageSSLCrtListEntryCreated().WithPayload(entry) + } + rID := h.ReloadAgent.Reload() + return storage.NewCreateStorageSSLCrtListEntryAccepted().WithReloadID(rID) +} + +type StorageDeleteStorageSSLCrtListEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Delete an entry in a crt-list. If the line_number is not provided, +// delete the first match, which is what the runtime API does. +func (h *StorageDeleteStorageSSLCrtListEntryHandlerImpl) Handle(params storage.DeleteStorageSSLCrtListEntryParams, principal any) middleware.Responder { + crtListStorage, err := h.Client.CrtListStorage() + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + // Modify the crt-file on storage. + content, err := crtListStorage.GetContents(params.Name) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + lineno := int64(0) + firstMatch := params.LineNumber > 0 + var sb strings.Builder // the modified contents + sb.Grow(len(content)) + strings.SplitSeq(content, "\n")(func(line string) bool { + lineno++ + if strings.HasPrefix(line, params.Certificate) { + if params.LineNumber == lineno || firstMatch { + // skip that line + firstMatch = false + return true + } + } + sb.WriteString(line) + sb.WriteByte('\n') + return true + }) + _, err = crtListStorage.Replace(params.Name, sb.String()) + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + // Try to delete the entry with the HAProxy runtime. Force the reload if that fails. + forceReload := false + if params.ForceReload != nil { + forceReload = *params.ForceReload + } + rt, err := h.Client.Runtime() + if err != nil { + forceReload = true + } else { + num := ¶ms.LineNumber + if params.LineNumber == 0 { + num = nil + } + if errDel := rt.DeleteCrtListEntry(params.Name, params.Certificate, num); errDel != nil { + log.Warning("failed to delete crt-list entry via runtime: ", errDel) + forceReload = true + } + } + + if forceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return storage.NewDeleteStorageSSLCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + return storage.NewDeleteStorageSSLCrtListEntryNoContent() + } + rID := h.ReloadAgent.Reload() + return storage.NewDeleteStorageSSLCrtListEntryAccepted().WithReloadID(rID) +} diff --git a/handlers/ssl_crt_lists_runtime.go b/handlers/ssl_crt_lists_runtime.go new file mode 100644 index 00000000..4fd069f4 --- /dev/null +++ b/handlers/ssl_crt_lists_runtime.go @@ -0,0 +1,102 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/dataplaneapi/misc" + ssl_runtime "github.com/haproxytech/dataplaneapi/operations/s_s_l_runtime" +) + +type GetAllCrtListsHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetAllCrtListsHandlerImpl) Handle(params ssl_runtime.GetAllCrtListsParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCrtListsDefault(int(*e.Code)).WithPayload(e) + } + + files, err := runtime.ShowCrtLists() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCrtListsDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetAllCrtListsOK().WithPayload(files) +} + +type GetAllCrtListEntriesHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h GetAllCrtListEntriesHandlerImpl) Handle(params ssl_runtime.GetAllCrtListEntriesParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCrtListEntriesDefault(int(*e.Code)).WithPayload(e) + } + + crtList, err := runtime.ShowCrtListEntries(params.Name) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewGetAllCrtListEntriesDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewGetAllCrtListEntriesOK().WithPayload(crtList) +} + +type AddCrtListEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h AddCrtListEntryHandlerImpl) Handle(params ssl_runtime.AddCrtListEntryParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewAddCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.AddCrtListEntry(params.Name, *params.Data) + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewAddCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewAddCrtListEntryCreated() +} + +type DeleteCrtListEntryHandlerImpl struct { + Client client_native.HAProxyClient +} + +func (h DeleteCrtListEntryHandlerImpl) Handle(params ssl_runtime.DeleteCrtListEntryParams, i any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + if err = runtime.DeleteCrtListEntry(params.Name, params.CertFile, params.LineNumber); err != nil { + e := misc.HandleError(err) + return ssl_runtime.NewDeleteCrtListEntryDefault(int(*e.Code)).WithPayload(e) + } + + return ssl_runtime.NewDeleteCrtListEntryNoContent() +} diff --git a/handlers/ssl_front_use.go b/handlers/ssl_front_use.go new file mode 100644 index 00000000..62abee7a --- /dev/null +++ b/handlers/ssl_front_use.go @@ -0,0 +1,235 @@ +// Copyright 2025 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + cn "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + sfu "github.com/haproxytech/dataplaneapi/operations/s_s_l_front_use" +) + +type GetAllSSLFrontUsesHandlerImpl struct { + Client cn.HAProxyClient +} + +func (h GetAllSSLFrontUsesHandlerImpl) Handle(params sfu.GetAllSSLFrontUsesParams, i any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sfu.NewGetAllSSLFrontUsesDefault(int(*e.Code)).WithPayload(e) + } + + _, uses, err := configuration.GetSSLFrontUses(string(parents.FrontendParentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return sfu.NewGetAllSSLFrontUsesDefault(int(*e.Code)).WithPayload(e) + } + + return sfu.NewGetAllSSLFrontUsesOK().WithPayload(uses) +} + +type CreateSSLFrontUseHandlerImpl struct { + Client cn.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h CreateSSLFrontUseHandlerImpl) Handle(params sfu.CreateSSLFrontUseParams, i any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return sfu.NewCreateSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sfu.NewCreateSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateSSLFrontUse(string(parents.FrontendParentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return sfu.NewCreateSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return sfu.NewCreateSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + return sfu.NewCreateSSLFrontUseCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return sfu.NewCreateSSLFrontUseAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return sfu.NewCreateSSLFrontUseAccepted().WithPayload(params.Data) +} + +type GetSSLFrontUseHandlerImpl struct { + Client cn.HAProxyClient +} + +func (h GetSSLFrontUseHandlerImpl) Handle(params sfu.GetSSLFrontUseParams, i any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sfu.NewGetSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + _, use, err := configuration.GetSSLFrontUse(params.Index, string(parents.FrontendParentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return sfu.NewGetSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + return sfu.NewGetSSLFrontUseOK().WithPayload(use) +} + +type ReplaceSSLFrontUseHandlerImpl struct { + Client cn.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h ReplaceSSLFrontUseHandlerImpl) Handle(params sfu.ReplaceSSLFrontUseParams, i any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return sfu.NewReplaceSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sfu.NewReplaceSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditSSLFrontUse(params.Index, string(parents.FrontendParentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return sfu.NewReplaceSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return sfu.NewReplaceSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + return sfu.NewReplaceSSLFrontUseOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return sfu.NewReplaceSSLFrontUseAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return sfu.NewReplaceSSLFrontUseOK().WithPayload(params.Data) +} + +type DeleteSSLFrontUseHandlerImpl struct { + Client cn.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h DeleteSSLFrontUseHandlerImpl) Handle(params sfu.DeleteSSLFrontUseParams, i any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return sfu.NewDeleteSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return sfu.NewDeleteSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteSSLFrontUse(params.Index, string(parents.FrontendParentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return sfu.NewDeleteSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return sfu.NewDeleteSSLFrontUseDefault(int(*e.Code)).WithPayload(e) + } + return sfu.NewDeleteSSLFrontUseNoContent() + } + rID := h.ReloadAgent.Reload() + return sfu.NewDeleteSSLFrontUseAccepted().WithReloadID(rID) + } + + return sfu.NewDeleteSSLFrontUseAccepted() +} diff --git a/handlers/stats.go b/handlers/stats.go index 1f11e0c7..ed8dd461 100644 --- a/handlers/stats.go +++ b/handlers/stats.go @@ -17,19 +17,20 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/stats" - "github.com/haproxytech/models" ) -//GetStatsHandlerImpl implementation of the GetStatsHandler interface using client-native client +// GetStatsHandlerImpl implementation of the GetStatsHandler interface using client-native client type GetStatsHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//Handle executing the request and returning a response -func (h *GetStatsHandlerImpl) Handle(params stats.GetStatsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetStatsHandlerImpl) Handle(params stats.GetStatsParams, principal any) middleware.Responder { if params.Name != nil { if params.Type == nil { code := misc.ErrHTTPBadRequest @@ -46,44 +47,44 @@ func (h *GetStatsHandlerImpl) Handle(params stats.GetStatsParams, principal inte } } - s := h.Client.Runtime.GetStats() + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return stats.NewGetStatsDefault(int(*e.Code)).WithPayload(e) + } - errorFound := false - for _, nStat := range s { - if nStat.Error != "" { - errorFound = true - continue - } - retVal := make([]*models.NativeStat, 0, len(nStat.Stats)) - for _, item := range nStat.Stats { - if params.Name != nil { - if item.Type == "server" { - if item.Name == *params.Name && item.Type == *params.Type && item.BackendName == *params.Parent { - retVal = append(retVal, item) - } - } else if item.Name == *params.Name && item.Type == *params.Type { + nStat := runtime.GetStats() + + if nStat.Error != "" { + return stats.NewGetStatsInternalServerError().WithPayload(&nStat) + } + retVal := make([]*models.NativeStat, 0, len(nStat.Stats)) + for _, item := range nStat.Stats { + if params.Name != nil { + if item.Type == "server" { + if item.Name == *params.Name && item.Type == *params.Type && item.BackendName == *params.Parent { retVal = append(retVal, item) } - } else { - if params.Type != nil { - if *params.Type == "server" && params.Parent != nil { - if item.Type == *params.Type && item.BackendName == *params.Parent { - retVal = append(retVal, item) - } - } else { - if item.Type == *params.Type { - retVal = append(retVal, item) - } + } else if item.Name == *params.Name && item.Type == *params.Type { + retVal = append(retVal, item) + } + } else { + if params.Type != nil { + if *params.Type == "server" && params.Parent != nil { + if item.Type == *params.Type && item.BackendName == *params.Parent { + retVal = append(retVal, item) } } else { - retVal = append(retVal, item) + if item.Type == *params.Type { + retVal = append(retVal, item) + } } + } else { + retVal = append(retVal, item) } } - nStat.Stats = retVal } - if errorFound { - return stats.NewGetStatsInternalServerError().WithPayload(s) - } - return stats.NewGetStatsOK().WithPayload(s) + nStat.Stats = retVal + + return stats.NewGetStatsOK().WithPayload(&nStat) } diff --git a/handlers/stick_rule.go b/handlers/stick_rule.go index 08944fb5..358e3df5 100644 --- a/handlers/stick_rule.go +++ b/handlers/stick_rule.go @@ -17,43 +17,50 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/stick_rule" - "github.com/haproxytech/models" ) -//CreateStickRuleHandlerImpl implementation of the CreateStickRuleHandler interface using client-native client +// CreateStickRuleHandlerImpl implementation of the CreateStickRuleHandler interface using client-native client type CreateStickRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteStickRuleHandlerImpl implementation of the DeleteStickRuleHandler interface using client-native client +// DeleteStickRuleHandlerImpl implementation of the DeleteStickRuleHandler interface using client-native client type DeleteStickRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetStickRuleHandlerImpl implementation of the GetStickRuleHandler interface using client-native client +// GetStickRuleHandlerImpl implementation of the GetStickRuleHandler interface using client-native client type GetStickRuleHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetStickRulesHandlerImpl implementation of the GetStickRulesHandler interface using client-native client +// GetStickRulesHandlerImpl implementation of the GetStickRulesHandler interface using client-native client type GetStickRulesHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//ReplaceStickRuleHandlerImpl implementation of the ReplaceStickRuleHandler interface using client-native client +// ReplaceStickRuleHandlerImpl implementation of the ReplaceStickRuleHandler interface using client-native client type ReplaceStickRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceStickRulesHandlerImpl implementation of the ReplaceStickRulesHandler interface using client-native client +type ReplaceStickRulesHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateStickRuleHandlerImpl) Handle(params stick_rule.CreateStickRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateStickRuleHandlerImpl) Handle(params stick_rule.CreateStickRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -73,7 +80,13 @@ func (h *CreateStickRuleHandlerImpl) Handle(params stick_rule.CreateStickRulePar return stick_rule.NewCreateStickRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateStickRule(params.Backend, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return stick_rule.NewCreateStickRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateStickRule(params.Index, params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) return stick_rule.NewCreateStickRuleDefault(int(*e.Code)).WithPayload(e) @@ -93,8 +106,8 @@ func (h *CreateStickRuleHandlerImpl) Handle(params stick_rule.CreateStickRulePar return stick_rule.NewCreateStickRuleAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteStickRuleHandlerImpl) Handle(params stick_rule.DeleteStickRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteStickRuleHandlerImpl) Handle(params stick_rule.DeleteStickRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -114,7 +127,13 @@ func (h *DeleteStickRuleHandlerImpl) Handle(params stick_rule.DeleteStickRulePar return stick_rule.NewDeleteStickRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteStickRule(params.ID, params.Backend, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return stick_rule.NewDeleteStickRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteStickRule(params.Index, params.ParentName, t, v) if err != nil { e := misc.HandleError(err) return stick_rule.NewDeleteStickRuleDefault(int(*e.Code)).WithPayload(e) @@ -135,38 +154,53 @@ func (h *DeleteStickRuleHandlerImpl) Handle(params stick_rule.DeleteStickRulePar return stick_rule.NewDeleteStickRuleAccepted() } -//Handle executing the request and returning a response -func (h *GetStickRuleHandlerImpl) Handle(params stick_rule.GetStickRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetStickRuleHandlerImpl) Handle(params stick_rule.GetStickRuleParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rule, err := h.Client.Configuration.GetStickRule(params.ID, params.Backend, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return stick_rule.NewGetStickRuleDefault(int(*e.Code)).WithPayload(e) + } + + _, rule, err := configuration.GetStickRule(params.Index, params.ParentName, t) if err != nil { e := misc.HandleError(err) - return stick_rule.NewGetStickRuleDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return stick_rule.NewGetStickRuleDefault(int(*e.Code)).WithPayload(e) } - return stick_rule.NewGetStickRuleOK().WithPayload(&stick_rule.GetStickRuleOKBody{Version: v, Data: rule}).WithConfigurationVersion(v) + return stick_rule.NewGetStickRuleOK().WithPayload(rule) } -//Handle executing the request and returning a response -func (h *GetStickRulesHandlerImpl) Handle(params stick_rule.GetStickRulesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetStickRulesHandlerImpl) Handle(params stick_rule.GetStickRulesParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rules, err := h.Client.Configuration.GetStickRules(params.Backend, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return stick_rule.NewGetStickRulesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return stick_rule.NewGetStickRulesDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetStickRules(params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return stick_rule.NewGetStickRulesOK().WithPayload(models.StickRules{}) + } + return stick_rule.NewGetStickRulesDefault(int(*e.Code)).WithPayload(e) } - return stick_rule.NewGetStickRulesOK().WithPayload(&stick_rule.GetStickRulesOKBody{Version: v, Data: rules}).WithConfigurationVersion(v) + return stick_rule.NewGetStickRulesOK().WithPayload(rules) } -//Handle executing the request and returning a response -func (h *ReplaceStickRuleHandlerImpl) Handle(params stick_rule.ReplaceStickRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceStickRuleHandlerImpl) Handle(params stick_rule.ReplaceStickRuleParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -186,7 +220,13 @@ func (h *ReplaceStickRuleHandlerImpl) Handle(params stick_rule.ReplaceStickRuleP return stick_rule.NewReplaceStickRuleDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditStickRule(params.ID, params.Backend, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return stick_rule.NewReplaceStickRuleDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditStickRule(params.Index, params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) return stick_rule.NewReplaceStickRuleDefault(int(*e.Code)).WithPayload(e) @@ -206,3 +246,50 @@ func (h *ReplaceStickRuleHandlerImpl) Handle(params stick_rule.ReplaceStickRuleP } return stick_rule.NewReplaceStickRuleAccepted().WithPayload(params.Data) } + +// Handle executing the request and returning a response +func (h *ReplaceStickRulesHandlerImpl) Handle(params stick_rule.ReplaceStickRulesParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return stick_rule.NewReplaceStickRulesDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return stick_rule.NewReplaceStickRulesDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceStickRules(params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return stick_rule.NewReplaceStickRulesDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return stick_rule.NewReplaceStickRuleDefault(int(*e.Code)).WithPayload(e) + } + return stick_rule.NewReplaceStickRulesOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return stick_rule.NewReplaceStickRulesAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return stick_rule.NewReplaceStickRulesAccepted().WithPayload(params.Data) +} diff --git a/handlers/stick_table.go b/handlers/stick_table.go new file mode 100644 index 00000000..28806a0b --- /dev/null +++ b/handlers/stick_table.go @@ -0,0 +1,207 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "fmt" + "strings" + + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/stick_table" +) + +// GetStickTablesHandlerImpl implementation of the GetStickTablesHandler interface using client-native client +type GetStickTablesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetStickTableHandlerImpl implementation of the GetStickTableHandler interface using client-native client +type GetStickTableHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetStickTableEntriesHandlerImpl implementation of the GetStickTableEntriesHandler interface using client-native client +type GetStickTableEntriesHandlerImpl struct { + Client client_native.HAProxyClient +} + +type SetStickTableEntriesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *GetStickTablesHandlerImpl) Handle(params stick_table.GetStickTablesParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return stick_table.NewGetStickTablesDefault(int(*e.Code)).WithPayload(e) + } + + stkTS, err := runtime.ShowTables() + if err != nil { + e := misc.HandleError(err) + return stick_table.NewGetStickTablesDefault(int(*e.Code)).WithPayload(e) + } + + for _, table := range stkTS { + table.Fields = findTableFields(table.Name, h.Client) + } + + return stick_table.NewGetStickTablesOK().WithPayload(stkTS) +} + +// Handle executing the request and returning a response +func (h *GetStickTableHandlerImpl) Handle(params stick_table.GetStickTableParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return stick_table.NewGetStickTableDefault(int(*e.Code)).WithPayload(e) + } + + stkT, err := runtime.ShowTable(params.Name) + if stkT == nil { + msg := fmt.Sprintf("Stick table %s not found", params.Name) + c := misc.ErrHTTPNotFound + e := &models.Error{ + Message: &msg, + Code: &c, + } + return stick_table.NewGetStickTableDefault(int(*e.Code)).WithPayload(e) + } + + stkT.Fields = findTableFields(stkT.Name, h.Client) + if err != nil { + e := misc.HandleError(err) + return stick_table.NewGetStickTableDefault(int(*e.Code)).WithPayload(e) + } + + return stick_table.NewGetStickTableOK().WithPayload(stkT) +} + +// Handle executing the request and returning a response +func (h *SetStickTableEntriesHandlerImpl) Handle(params stick_table.SetStickTableEntriesParams, principal any) middleware.Responder { + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return stick_table.NewSetStickTableEntriesDefault(int(*e.Code)).WithPayload(e) + } + + err = runtime.SetTableEntry(params.ParentName, *params.StickTableEntry.Key, *params.StickTableEntry.DataType) + if err != nil { + e := misc.HandleError(err) + return stick_table.NewSetStickTableEntriesDefault(int(*e.Code)).WithPayload(e) + } + + return stick_table.NewSetStickTableEntriesNoContent() +} + +// Handle executing the request and returning a response +func (h *GetStickTableEntriesHandlerImpl) Handle(params stick_table.GetStickTableEntriesParams, principal any) middleware.Responder { + filter := make([]string, 0) + if params.Filter != nil { + filter = strings.Split(*params.Filter, ",") + } + + key := "" + if params.Key != nil { + key = *params.Key + } + runtime, err := h.Client.Runtime() + if err != nil { + e := misc.HandleError(err) + return stick_table.NewGetStickTableEntriesDefault(int(*e.Code)).WithPayload(e) + } + + stkEntries, err := runtime.GetTableEntries(params.ParentName, filter, key) + if err != nil { + e := misc.HandleError(err) + return stick_table.NewGetStickTableEntriesDefault(int(*e.Code)).WithPayload(e) + } + + // if no entries return empty array + if len(stkEntries) == 0 { + return stick_table.NewGetStickTableEntriesOK().WithPayload(stkEntries) + } + + // else check for pagination + offset := int64(0) + if params.Offset != nil { + offset = *params.Offset + } + + if int(offset) >= len(stkEntries) { + msg := fmt.Sprintf("Offset %d is larger than the slice size %d", offset, len(stkEntries)) + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return stick_table.NewGetStickTableEntriesDefault(int(*e.Code)).WithPayload(e) + } + + if params.Count != nil { + if int(offset+*params.Count) >= len(stkEntries) { + stkEntries = stkEntries[offset:] + } else { + stkEntries = stkEntries[offset : offset+*params.Count] + } + } else { + stkEntries = stkEntries[offset:] + } + return stick_table.NewGetStickTableEntriesOK().WithPayload(stkEntries) +} + +func findTableFields(name string, client client_native.HAProxyClient) []*models.StickTableField { + configuration, err := client.Configuration() + if err != nil { + return nil + } + + _, bck, err := configuration.GetBackend(name, "") + if err != nil { + return nil + } + + if bck.StickTable == nil { + return nil + } + + data := strings.Split(bck.StickTable.Store, ",") + fields := make([]*models.StickTableField, 0) + for _, d := range data { + f := &models.StickTableField{} + spl := strings.Split(d, "(") + if len(spl) == 1 { + f.Field = d + f.Type = "counter" + fields = append(fields, f) + } else if len(spl) == 2 { + p := misc.ParseTimeout(spl[1][:len(spl[1])-1]) + if p != nil { + f.Field = spl[0] + f.Period = *p + f.Type = "rate" + fields = append(fields, f) + } + } + } + + return fields +} diff --git a/handlers/table.go b/handlers/table.go new file mode 100644 index 00000000..3e9a4056 --- /dev/null +++ b/handlers/table.go @@ -0,0 +1,237 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/table" +) + +// CreateTableHandlerImpl implementation of the CreateTableHandler interface using client-native client +type CreateTableHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteTableHandlerImpl implementation of the DeleteTableHandler interface using client-native client +type DeleteTableHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetTableHandlerImpl implementation of the GetTableHandler interface using client-native client +type GetTableHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetTablesHandlerImpl implementation of the GetTablesHandler interface using client-native client +type GetTablesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceTableHandlerImpl implementation of the ReplaceTableHandler interface using client-native client +type ReplaceTableHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateTableHandlerImpl) Handle(params table.CreateTableParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return table.NewCreateTableDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return table.NewCreateTableDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateTable(params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return table.NewCreateTableDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return table.NewCreateTableDefault(int(*e.Code)).WithPayload(e) + } + return table.NewCreateTableCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return table.NewCreateTableAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return table.NewCreateTableAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteTableHandlerImpl) Handle(params table.DeleteTableParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return table.NewDeleteTableDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return table.NewDeleteTableDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteTable(params.Name, params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return table.NewDeleteTableDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return table.NewDeleteTableDefault(int(*e.Code)).WithPayload(e) + } + return table.NewDeleteTableNoContent() + } + rID := h.ReloadAgent.Reload() + return table.NewDeleteTableAccepted().WithReloadID(rID) + } + return table.NewDeleteTableAccepted() +} + +// Handle executing the request and returning a response +func (h *GetTableHandlerImpl) Handle(params table.GetTableParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return table.NewGetTableDefault(int(*e.Code)).WithPayload(e) + } + + _, ta, err := configuration.GetTable(params.Name, params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return table.NewGetTableDefault(int(*e.Code)).WithPayload(e) + } + return table.NewGetTableOK().WithPayload(ta) +} + +// Handle executing the request and returning a response +func (h *GetTablesHandlerImpl) Handle(params table.GetTablesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return table.NewGetTablesDefault(int(*e.Code)).WithPayload(e) + } + + _, tables, err := configuration.GetTables(params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return table.NewGetTablesDefault(int(*e.Code)).WithPayload(e) + } + return table.NewGetTablesOK().WithPayload(tables) +} + +// Handle executing the request and returning a response +func (h *ReplaceTableHandlerImpl) Handle(params table.ReplaceTableParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return table.NewReplaceTableDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return table.NewReplaceTableDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditTable(params.Name, params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return table.NewReplaceTableDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return table.NewReplaceTableDefault(int(*e.Code)).WithPayload(e) + } + return table.NewReplaceTableOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return table.NewReplaceTableAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return table.NewReplaceTableAccepted().WithPayload(params.Data) +} diff --git a/handlers/tcp_check.go b/handlers/tcp_check.go new file mode 100644 index 00000000..903f3ffb --- /dev/null +++ b/handlers/tcp_check.go @@ -0,0 +1,302 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/tcp_check" +) + +// CreateTCPCheckHandlerImpl implementation of the CreateTCPCheckHandler interface using client-native client +type CreateTCPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteTCPCheckHandlerImpl implementation of the DeleteTCPCheckHandler interface using client-native client +type DeleteTCPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetTCPCheckHandlerImpl implementation of the GetTCPCheckHandler interface using client-native client +type GetTCPCheckHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetAllTCPCheckHandlerImpl implementation of the GetTCPChecksHandler interface using client-native client +type GetAllTCPCheckHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceTCPCheckHandlerImpl implementation of the ReplaceTCPCheckHandler interface using client-native client +type ReplaceTCPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllTCPCheckHandlerImpl implementation of the ReplaceTCPChecksHandler interface using client-native client +type ReplaceAllTCPCheckHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateTCPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_check.CreateTCPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return tcp_check.NewCreateTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewCreateTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateTCPCheck(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewCreateTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewCreateTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_check.NewCreateTCPCheckBackendCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return tcp_check.NewCreateTCPCheckBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return tcp_check.NewCreateTCPCheckBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteTCPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_check.DeleteTCPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return tcp_check.NewDeleteTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewDeleteTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteTCPCheck(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewDeleteTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewDeleteTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_check.NewDeleteTCPCheckBackendNoContent() + } + rID := h.ReloadAgent.Reload() + return tcp_check.NewCreateTCPCheckBackendAccepted().WithReloadID(rID) + } + + return tcp_check.NewDeleteTCPCheckBackendAccepted() +} + +// Handle executing the request and returning a response +func (h *GetTCPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_check.GetTCPCheckBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewGetTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, data, err := configuration.GetTCPCheck(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewGetTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + return tcp_check.NewGetTCPCheckBackendOK().WithPayload(data) +} + +// Handle executing the request and returning a response +func (h *GetAllTCPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_check.GetAllTCPCheckBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewGetAllTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, data, err := configuration.GetTCPChecks(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return tcp_check.NewGetAllTCPCheckBackendOK().WithPayload(models.TCPChecks{}) + } + return tcp_check.NewGetAllTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + return tcp_check.NewGetAllTCPCheckBackendOK().WithPayload(data) +} + +// Handle executing the request and returning a response +func (h *ReplaceTCPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_check.ReplaceTCPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return tcp_check.NewReplaceTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewReplaceTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.EditTCPCheck(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewReplaceTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewReplaceTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_check.NewReplaceTCPCheckBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return tcp_check.NewReplaceTCPCheckBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return tcp_check.NewReplaceTCPCheckBackendAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *ReplaceAllTCPCheckHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_check.ReplaceAllTCPCheckBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return tcp_check.NewReplaceAllTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewReplaceAllTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceTCPChecks(string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewReplaceAllTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return tcp_check.NewReplaceAllTCPCheckBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_check.NewReplaceAllTCPCheckBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return tcp_check.NewReplaceAllTCPCheckBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return tcp_check.NewReplaceAllTCPCheckBackendAccepted().WithPayload(params.Data) +} diff --git a/handlers/tcp_request_rule.go b/handlers/tcp_request_rule.go index 8ba5d458..856e0337 100644 --- a/handlers/tcp_request_rule.go +++ b/handlers/tcp_request_rule.go @@ -17,43 +17,51 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/tcp_request_rule" - "github.com/haproxytech/models" ) -//CreateTCPRequestRuleHandlerImpl implementation of the CreateTCPRequestRuleHandler interface using client-native client +// CreateTCPRequestRuleHandlerImpl implementation of the CreateTCPRequestRuleHandler interface using client-native client type CreateTCPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteTCPRequestRuleHandlerImpl implementation of the DeleteTCPRequestRuleHandler interface using client-native client +// DeleteTCPRequestRuleHandlerImpl implementation of the DeleteTCPRequestRuleHandler interface using client-native client type DeleteTCPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetTCPRequestRuleHandlerImpl implementation of the GetTCPRequestRuleHandler interface using client-native client +// GetTCPRequestRuleHandlerImpl implementation of the GetTCPRequestRuleHandler interface using client-native client type GetTCPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetTCPRequestRulesHandlerImpl implementation of the GetTCPRequestRulesHandler interface using client-native client -type GetTCPRequestRulesHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllTCPRequestRuleHandlerImpl implementation of the GetTCPRequestRulesHandler interface using client-native client +type GetAllTCPRequestRuleHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceTCPRequestRuleHandlerImpl implementation of the ReplaceTCPRequestRuleHandler interface using client-native client +// ReplaceTCPRequestRuleHandlerImpl implementation of the ReplaceTCPRequestRuleHandler interface using client-native client type ReplaceTCPRequestRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllTCPRequestRuleHandlerImpl implementation of the ReplaceTCPRequestRulesHandler interface using client-native client +type ReplaceAllTCPRequestRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.CreateTCPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateTCPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_request_rule.CreateTCPRequestRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,32 +78,37 @@ func (h *CreateTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.CreateT Message: &msg, Code: &c, } - return tcp_request_rule.NewCreateTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewCreateTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_request_rule.NewCreateTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateTCPRequestRule(params.ParentType, params.ParentName, params.Data, t, v) + err = configuration.CreateTCPRequestRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewCreateTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewCreateTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewCreateTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewCreateTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_request_rule.NewCreateTCPRequestRuleCreated().WithPayload(params.Data) + return tcp_request_rule.NewCreateTCPRequestRuleBackendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return tcp_request_rule.NewCreateTCPRequestRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return tcp_request_rule.NewCreateTCPRequestRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return tcp_request_rule.NewCreateTCPRequestRuleAccepted().WithPayload(params.Data) - + return tcp_request_rule.NewCreateTCPRequestRuleBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.DeleteTCPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteTCPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_request_rule.DeleteTCPRequestRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -112,13 +125,19 @@ func (h *DeleteTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.DeleteT Message: &msg, Code: &c, } - return tcp_request_rule.NewDeleteTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewDeleteTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteTCPRequestRule(params.ID, params.ParentType, params.ParentName, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewDeleteTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewDeleteTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteTCPRequestRule(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return tcp_request_rule.NewDeleteTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -126,48 +145,111 @@ func (h *DeleteTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.DeleteT err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewDeleteTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewDeleteTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_request_rule.NewDeleteTCPRequestRuleNoContent() + return tcp_request_rule.NewDeleteTCPRequestRuleBackendNoContent() } rID := h.ReloadAgent.Reload() - return tcp_request_rule.NewDeleteTCPRequestRuleAccepted().WithReloadID(rID) + return tcp_request_rule.NewDeleteTCPRequestRuleBackendAccepted().WithReloadID(rID) + } + return tcp_request_rule.NewDeleteTCPRequestRuleBackendAccepted() +} + +// Handle executing the request and returning a response +func (h *GetTCPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_request_rule.GetTCPRequestRuleBackendParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_request_rule.NewGetTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_request_rule.NewDeleteTCPRequestRuleAccepted() + + _, rule, err := configuration.GetTCPRequestRule(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return tcp_request_rule.NewGetTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_request_rule.NewGetTCPRequestRuleBackendOK().WithPayload(rule) } -//Handle executing the request and returning a response -func (h *GetTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.GetTCPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllTCPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_request_rule.GetAllTCPRequestRuleBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rule, err := h.Client.Configuration.GetTCPRequestRule(params.ID, params.ParentType, params.ParentName, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewGetTCPRequestRuleDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return tcp_request_rule.NewGetAllTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetTCPRequestRules(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return tcp_request_rule.NewGetAllTCPRequestRuleBackendOK().WithPayload(models.TCPRequestRules{}) + } + return tcp_request_rule.NewGetAllTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_request_rule.NewGetTCPRequestRuleOK().WithPayload(&tcp_request_rule.GetTCPRequestRuleOKBody{Version: v, Data: rule}).WithConfigurationVersion(v) + return tcp_request_rule.NewGetAllTCPRequestRuleBackendOK().WithPayload(rules) } -//Handle executing the request and returning a response -func (h *GetTCPRequestRulesHandlerImpl) Handle(params tcp_request_rule.GetTCPRequestRulesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceTCPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_request_rule.ReplaceTCPRequestRuleBackendParams, principal any) middleware.Responder { t := "" + v := int64(0) if params.TransactionID != nil { t = *params.TransactionID } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return tcp_request_rule.NewReplaceTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_request_rule.NewReplaceTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } - v, rules, err := h.Client.Configuration.GetTCPRequestRules(params.ParentType, params.ParentName, t) + err = configuration.EditTCPRequestRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewGetTCPRequestRulesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return tcp_request_rule.NewReplaceTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_request_rule.NewGetTCPRequestRulesOK().WithPayload(&tcp_request_rule.GetTCPRequestRulesOKBody{Version: v, Data: rules}).WithConfigurationVersion(v) + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return tcp_request_rule.NewReplaceTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_request_rule.NewReplaceTCPRequestRuleBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return tcp_request_rule.NewReplaceTCPRequestRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return tcp_request_rule.NewReplaceTCPRequestRuleBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *ReplaceTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.ReplaceTCPRequestRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *ReplaceAllTCPRequestRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_request_rule.ReplaceAllTCPRequestRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -184,13 +266,18 @@ func (h *ReplaceTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.Replac Message: &msg, Code: &c, } - return tcp_request_rule.NewReplaceTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewReplaceAllTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditTCPRequestRule(params.ID, params.ParentType, params.ParentName, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_request_rule.NewReplaceAllTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceTCPRequestRules(string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewReplaceTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewReplaceAllTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -198,12 +285,12 @@ func (h *ReplaceTCPRequestRuleHandlerImpl) Handle(params tcp_request_rule.Replac err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return tcp_request_rule.NewReplaceTCPRequestRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_request_rule.NewReplaceAllTCPRequestRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_request_rule.NewReplaceTCPRequestRuleOK().WithPayload(params.Data) + return tcp_request_rule.NewReplaceAllTCPRequestRuleBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return tcp_request_rule.NewReplaceTCPRequestRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return tcp_request_rule.NewReplaceAllTCPRequestRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return tcp_request_rule.NewReplaceTCPRequestRuleAccepted().WithPayload(params.Data) + return tcp_request_rule.NewReplaceAllTCPRequestRuleBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/tcp_response_rule.go b/handlers/tcp_response_rule.go index 9855dfec..3e03636e 100644 --- a/handlers/tcp_response_rule.go +++ b/handlers/tcp_response_rule.go @@ -17,43 +17,51 @@ package handlers import ( "github.com/go-openapi/runtime/middleware" - client_native "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + cnconstants "github.com/haproxytech/client-native/v6/configuration/parents" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/tcp_response_rule" - "github.com/haproxytech/models" ) -//CreateTCPResponseRuleHandlerImpl implementation of the CreateTCPResponseRuleHandler interface using client-native client +// CreateTCPResponseRuleHandlerImpl implementation of the CreateTCPResponseRuleHandler interface using client-native client type CreateTCPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//DeleteTCPResponseRuleHandlerImpl implementation of the DeleteTCPResponseRuleHandler interface using client-native client +// DeleteTCPResponseRuleHandlerImpl implementation of the DeleteTCPResponseRuleHandler interface using client-native client type DeleteTCPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//GetTCPResponseRuleHandlerImpl implementation of the GetTCPResponseRuleHandler interface using client-native client +// GetTCPResponseRuleHandlerImpl implementation of the GetTCPResponseRuleHandler interface using client-native client type GetTCPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetTCPResponseRulesHandlerImpl implementation of the GetTCPResponseRulesHandler interface using client-native client -type GetTCPResponseRulesHandlerImpl struct { - Client *client_native.HAProxyClient +// GetAllTCPResponseRuleHandlerImpl implementation of the GetTCPResponseRulesHandler interface using client-native client +type GetAllTCPResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient } -//ReplaceTCPResponseRuleHandlerImpl implementation of the ReplaceTCPResponseRuleHandler interface using client-native client +// ReplaceTCPResponseRuleHandlerImpl implementation of the ReplaceTCPResponseRuleHandler interface using client-native client type ReplaceTCPResponseRuleHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// ReplaceAllTCPResponseRuleHandlerImpl implementation of the ReplaceTCPResponseRulesHandler interface using client-native client +type ReplaceAllTCPResponseRuleHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent } -//Handle executing the request and returning a response -func (h *CreateTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.CreateTCPResponseRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *CreateTCPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_response_rule.CreateTCPResponseRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -70,13 +78,19 @@ func (h *CreateTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.Creat Message: &msg, Code: &c, } - return tcp_response_rule.NewCreateTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewCreateTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_response_rule.NewCreateTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.CreateTCPResponseRule(params.Backend, params.Data, t, v) + err = configuration.CreateTCPResponseRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewCreateTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewCreateTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -84,18 +98,18 @@ func (h *CreateTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.Creat err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewCreateTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewCreateTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_response_rule.NewCreateTCPResponseRuleCreated().WithPayload(params.Data) + return tcp_response_rule.NewCreateTCPResponseRuleBackendCreated().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return tcp_response_rule.NewCreateTCPResponseRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return tcp_response_rule.NewCreateTCPResponseRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return tcp_response_rule.NewCreateTCPResponseRuleAccepted().WithPayload(params.Data) + return tcp_response_rule.NewCreateTCPResponseRuleBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *DeleteTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.DeleteTCPResponseRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *DeleteTCPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_response_rule.DeleteTCPResponseRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -112,61 +126,128 @@ func (h *DeleteTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.Delet Message: &msg, Code: &c, } - return tcp_response_rule.NewDeleteTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewDeleteTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.DeleteTCPResponseRule(params.ID, params.Backend, t, v) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewDeleteTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewDeleteTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteTCPResponseRule(params.Index, string(parentType), params.ParentName, t, v) + if err != nil { + e := misc.HandleError(err) + return tcp_response_rule.NewDeleteTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { if *params.ForceReload { err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewDeleteTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewDeleteTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_response_rule.NewDeleteTCPResponseRuleNoContent() + return tcp_response_rule.NewDeleteTCPResponseRuleBackendNoContent() } rID := h.ReloadAgent.Reload() - return tcp_response_rule.NewDeleteTCPResponseRuleAccepted().WithReloadID(rID) + return tcp_response_rule.NewDeleteTCPResponseRuleBackendAccepted().WithReloadID(rID) } - return tcp_response_rule.NewDeleteTCPResponseRuleAccepted() + return tcp_response_rule.NewDeleteTCPResponseRuleBackendAccepted() } -//Handle executing the request and returning a response -func (h *GetTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.GetTCPResponseRuleParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetTCPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_response_rule.GetTCPResponseRuleBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rule, err := h.Client.Configuration.GetTCPResponseRule(params.ID, params.Backend, t) + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewGetTCPResponseRuleDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return tcp_response_rule.NewGetTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_response_rule.NewGetTCPResponseRuleOK().WithPayload(&tcp_response_rule.GetTCPResponseRuleOKBody{Version: v, Data: rule}).WithConfigurationVersion(v) + _, rule, err := configuration.GetTCPResponseRule(params.Index, string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleError(err) + return tcp_response_rule.NewGetTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_response_rule.NewGetTCPResponseRuleBackendOK().WithPayload(rule) } -//Handle executing the request and returning a response -func (h *GetTCPResponseRulesHandlerImpl) Handle(params tcp_response_rule.GetTCPResponseRulesParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetAllTCPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_response_rule.GetAllTCPResponseRuleBackendParams, principal any) middleware.Responder { t := "" if params.TransactionID != nil { t = *params.TransactionID } - v, rules, err := h.Client.Configuration.GetTCPResponseRules(params.Backend, t) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_response_rule.NewGetAllTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + _, rules, err := configuration.GetTCPResponseRules(string(parentType), params.ParentName, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return tcp_response_rule.NewGetAllTCPResponseRuleBackendOK().WithPayload(models.TCPResponseRules{}) + } + return tcp_response_rule.NewGetAllTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_response_rule.NewGetAllTCPResponseRuleBackendOK().WithPayload(rules) +} + +// Handle executing the request and returning a response +func (h *ReplaceTCPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_response_rule.ReplaceTCPResponseRuleBackendParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return tcp_response_rule.NewReplaceTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewGetTCPResponseRulesDefault(int(*e.Code)).WithPayload(e).WithConfigurationVersion(v) + return tcp_response_rule.NewReplaceTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_response_rule.NewGetTCPResponseRulesOK().WithPayload(&tcp_response_rule.GetTCPResponseRulesOKBody{Version: v, Data: rules}).WithConfigurationVersion(v) + + err = configuration.EditTCPResponseRule(params.Index, string(parentType), params.ParentName, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return tcp_response_rule.NewReplaceTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return tcp_response_rule.NewReplaceTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + return tcp_response_rule.NewReplaceTCPResponseRuleBackendOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return tcp_response_rule.NewReplaceTCPResponseRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return tcp_response_rule.NewReplaceTCPResponseRuleBackendAccepted().WithPayload(params.Data) } -//Handle executing the request and returning a response -func (h *ReplaceTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.ReplaceTCPResponseRuleParams, principal interface{}) middleware.Responder { +func (h *ReplaceAllTCPResponseRuleHandlerImpl) Handle(parentType cnconstants.CnParentType, params tcp_response_rule.ReplaceAllTCPResponseRuleBackendParams, principal any) middleware.Responder { t := "" v := int64(0) if params.TransactionID != nil { @@ -183,13 +264,18 @@ func (h *ReplaceTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.Repl Message: &msg, Code: &c, } - return tcp_response_rule.NewReplaceTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewReplaceAllTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - err := h.Client.Configuration.EditTCPResponseRule(params.ID, params.Backend, params.Data, t, v) + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return tcp_response_rule.NewReplaceAllTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) + } + err = configuration.ReplaceTCPResponseRules(string(parentType), params.ParentName, params.Data, t, v) if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewReplaceTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewReplaceAllTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } if params.TransactionID == nil { @@ -197,12 +283,12 @@ func (h *ReplaceTCPResponseRuleHandlerImpl) Handle(params tcp_response_rule.Repl err := h.ReloadAgent.ForceReload() if err != nil { e := misc.HandleError(err) - return tcp_response_rule.NewReplaceTCPResponseRuleDefault(int(*e.Code)).WithPayload(e) + return tcp_response_rule.NewReplaceAllTCPResponseRuleBackendDefault(int(*e.Code)).WithPayload(e) } - return tcp_response_rule.NewReplaceTCPResponseRuleOK().WithPayload(params.Data) + return tcp_response_rule.NewReplaceAllTCPResponseRuleBackendOK().WithPayload(params.Data) } rID := h.ReloadAgent.Reload() - return tcp_response_rule.NewReplaceTCPResponseRuleAccepted().WithReloadID(rID).WithPayload(params.Data) + return tcp_response_rule.NewReplaceAllTCPResponseRuleBackendAccepted().WithReloadID(rID).WithPayload(params.Data) } - return tcp_response_rule.NewReplaceTCPResponseRuleAccepted().WithPayload(params.Data) + return tcp_response_rule.NewReplaceAllTCPResponseRuleBackendAccepted().WithPayload(params.Data) } diff --git a/handlers/traces.go b/handlers/traces.go new file mode 100644 index 00000000..bfddbf92 --- /dev/null +++ b/handlers/traces.go @@ -0,0 +1,327 @@ +// Copyright 2024 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/traces" +) + +type GetTracesHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Get the traces section (it is unique) +func (h *GetTracesHandlerImpl) Handle(params traces.GetTracesParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return traces.NewGetTracesDefault(int(*e.Code)).WithPayload(e) + } + + var ts *models.Traces + + if params.FullSection != nil && *params.FullSection { + _, ts, err = configuration.GetStructuredTraces(t) + } else { + _, ts, err = configuration.GetTraces(t) + } + + if err != nil { + e := misc.HandleError(err) + return traces.NewGetTracesDefault(int(*e.Code)).WithPayload(e) + } + + return traces.NewGetTracesOK().WithPayload(ts) +} + +type CreateTracesHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *CreateTracesHandlerImpl) Handle(params traces.CreateTracesParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return traces.NewCreateTracesDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return traces.NewCreateTracesDefault(int(*e.Code)).WithPayload(e) + } + + if err = configuration.CreateTraces(params.Data, t, v); err != nil { + e := misc.HandleError(err) + return traces.NewCreateTracesDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return traces.NewCreateTracesDefault(int(*e.Code)).WithPayload(e) + } + return traces.NewCreateTracesCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return traces.NewCreateTracesAccepted().WithReloadID(rID).WithPayload(params.Data) + } + + return traces.NewCreateTracesAccepted().WithPayload(params.Data) +} + +type ReplaceTracesHandler struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *ReplaceTracesHandler) Handle(params traces.ReplaceTracesParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return traces.NewReplaceTracesDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return traces.NewReplaceTracesDefault(int(*e.Code)).WithPayload(e) + } + + if params.FullSection != nil && *params.FullSection { + err = configuration.PushStructuredTraces(params.Data, t, v) + } else { + err = configuration.EditTraces(params.Data, t, v) + } + + if err != nil { + e := misc.HandleError(err) + return traces.NewReplaceTracesDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return traces.NewReplaceTracesDefault(int(*e.Code)).WithPayload(e) + } + return traces.NewReplaceTracesOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return traces.NewReplaceTracesAccepted().WithReloadID(rID) + } + + return traces.NewReplaceTracesOK().WithPayload(params.Data) +} + +type DeleteTracesHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *DeleteTracesHandlerImpl) Handle(params traces.DeleteTracesParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return traces.NewDeleteTracesDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return traces.NewDeleteTracesDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteTraces(t, v) + if err != nil { + e := misc.HandleError(err) + return traces.NewDeleteTracesDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return traces.NewDeleteTracesDefault(int(*e.Code)).WithPayload(e) + } + return traces.NewDeleteTracesNoContent() + } + rID := h.ReloadAgent.Reload() + return traces.NewDeleteTracesAccepted().WithReloadID(rID) + } + + return traces.NewDeleteTracesAccepted() +} + +// Trace Entries + +type CreateTraceEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *CreateTraceEntryHandlerImpl) Handle(params traces.CreateTraceEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return traces.NewCreateTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return traces.NewCreateTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.CreateTraceEntry(params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return traces.NewCreateTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return traces.NewCreateTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + return traces.NewCreateTraceEntryCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return traces.NewCreateTraceEntryAccepted().WithReloadID(rID) + } + + return traces.NewCreateTraceEntryCreated().WithPayload(params.Data) +} + +type DeleteTraceEntryHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +func (h *DeleteTraceEntryHandlerImpl) Handle(params traces.DeleteTraceEntryParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return traces.NewDeleteTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return traces.NewDeleteTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteTraceEntry(params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return traces.NewDeleteTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return traces.NewDeleteTraceEntryDefault(int(*e.Code)).WithPayload(e) + } + return traces.NewDeleteTraceEntryNoContent() + } + rID := h.ReloadAgent.Reload() + return traces.NewDeleteTraceEntryAccepted().WithReloadID(rID) + } + + return traces.NewDeleteTraceEntryAccepted() +} diff --git a/handlers/transaction.go b/handlers/transaction.go index 080b51b8..1c496862 100644 --- a/handlers/transaction.go +++ b/handlers/transaction.go @@ -16,42 +16,61 @@ package handlers import ( + "strings" + "sync" + "github.com/go-openapi/runtime/middleware" - "github.com/haproxytech/client-native" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + cn "github.com/haproxytech/dataplaneapi/client-native" + "github.com/haproxytech/dataplaneapi/haproxy" "github.com/haproxytech/dataplaneapi/misc" "github.com/haproxytech/dataplaneapi/operations/transactions" + "github.com/haproxytech/dataplaneapi/rate" ) -//StartTransactionHandlerImpl implementation of the StartTransactionHandler interface using client-native client +// RateLimitedStartTransactionHandlerImpl decorates StartTransactionHandlerImpl with the rate limiting logic +type RateLimitedStartTransactionHandlerImpl struct { + TransactionCounter rate.Threshold + Handler transactions.StartTransactionHandler +} + +// StartTransactionHandlerImpl implementation of the StartTransactionHandler interface using client-native client type StartTransactionHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//DeleteTransactionHandlerImpl implementation of the DeleteTransactionHandler interface using client-native client +// DeleteTransactionHandlerImpl implementation of the DeleteTransactionHandler interface using client-native client type DeleteTransactionHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetTransactionHandlerImpl implementation of the GetTransactionHandler interface using client-native client +// GetTransactionHandlerImpl implementation of the GetTransactionHandler interface using client-native client type GetTransactionHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//GetTransactionsHandlerImpl implementation of the GetTransactionsHandler interface using client-native client +// GetTransactionsHandlerImpl implementation of the GetTransactionsHandler interface using client-native client type GetTransactionsHandlerImpl struct { - Client *client_native.HAProxyClient + Client client_native.HAProxyClient } -//CommitTransactionHandlerImpl implementation of the CommitTransactionHandlerImpl interface using client-native client +// CommitTransactionHandlerImpl implementation of the CommitTransactionHandlerImpl interface using client-native client type CommitTransactionHandlerImpl struct { - Client *client_native.HAProxyClient - ReloadAgent *haproxy.ReloadAgent + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent + Mutex *sync.Mutex } -//Handle executing the request and returning a response -func (th *StartTransactionHandlerImpl) Handle(params transactions.StartTransactionParams, principal interface{}) middleware.Responder { - t, err := th.Client.Configuration.StartTransaction(params.Version) +// Handle executing the request and returning a response +func (h *StartTransactionHandlerImpl) Handle(params transactions.StartTransactionParams, principal any) middleware.Responder { + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return transactions.NewStartTransactionDefault(int(*e.Code)).WithPayload(e) + } + t, err := configuration.StartTransaction(params.Version) if err != nil { e := misc.HandleError(err) return transactions.NewStartTransactionDefault(int(*e.Code)).WithPayload(e) @@ -59,33 +78,58 @@ func (th *StartTransactionHandlerImpl) Handle(params transactions.StartTransacti return transactions.NewStartTransactionCreated().WithPayload(t) } -//Handle executing the request and returning a response -func (th *DeleteTransactionHandlerImpl) Handle(params transactions.DeleteTransactionParams, principal interface{}) middleware.Responder { - err := th.Client.Configuration.DeleteTransaction(params.ID) +// Handle executing the request and returning a response +func (h *DeleteTransactionHandlerImpl) Handle(params transactions.DeleteTransactionParams, principal any) middleware.Responder { + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) return transactions.NewDeleteTransactionDefault(int(*e.Code)).WithPayload(e) } + err = configuration.DeleteTransaction(params.ID) + if err != nil { + e := misc.HandleError(err) + if strings.HasSuffix(*e.Message, "does not exist") { + e.Code = misc.Int64P(404) + return transactions.NewDeleteTransactionNotFound().WithPayload(e) + } + return transactions.NewDeleteTransactionDefault(int(*e.Code)).WithPayload(e) + } return transactions.NewDeleteTransactionNoContent() } -//Handle executing the request and returning a response -func (th *GetTransactionHandlerImpl) Handle(params transactions.GetTransactionParams, principal interface{}) middleware.Responder { - t, err := th.Client.Configuration.GetTransaction(params.ID) +// Handle executing the request and returning a response +func (h *GetTransactionHandlerImpl) Handle(params transactions.GetTransactionParams, principal any) middleware.Responder { + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return transactions.NewGetTransactionDefault(int(*e.Code)).WithPayload(e) + } + t, err := configuration.GetTransaction(params.ID) if err != nil { e := misc.HandleError(err) + if strings.HasSuffix(*e.Message, "does not exist") { + e.Code = misc.Int64P(404) + return transactions.NewDeleteTransactionNotFound().WithPayload(e) + } return transactions.NewGetTransactionsDefault(int(*e.Code)).WithPayload(e) } return transactions.NewGetTransactionOK().WithPayload(t) } -//Handle executing the request and returning a response -func (th *GetTransactionsHandlerImpl) Handle(params transactions.GetTransactionsParams, principal interface{}) middleware.Responder { +// Handle executing the request and returning a response +func (h *GetTransactionsHandlerImpl) Handle(params transactions.GetTransactionsParams, principal any) middleware.Responder { s := "" if params.Status != nil { s = *params.Status } - ts, err := th.Client.Configuration.GetTransactions(s) + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return transactions.NewGetTransactionsDefault(int(*e.Code)).WithPayload(e) + } + + ts, err := configuration.GetTransactions(s) if err != nil { e := misc.HandleError(err) return transactions.NewGetTransactionsDefault(int(*e.Code)).WithPayload(e) @@ -93,21 +137,95 @@ func (th *GetTransactionsHandlerImpl) Handle(params transactions.GetTransactions return transactions.NewGetTransactionsOK().WithPayload(*ts) } -//Handle executing the request and returning a response -func (th *CommitTransactionHandlerImpl) Handle(params transactions.CommitTransactionParams, principal interface{}) middleware.Responder { - t, err := th.Client.Configuration.CommitTransaction(params.ID) +// Handle executing the request and returning a response +func (h *CommitTransactionHandlerImpl) Handle(params transactions.CommitTransactionParams, principal any) middleware.Responder { + h.Mutex.Lock() + defer h.Mutex.Unlock() + + var err error + + var transaction *models.Transaction + + configuration, err := h.Client.Configuration() if err != nil { e := misc.HandleError(err) return transactions.NewCommitTransactionDefault(int(*e.Code)).WithPayload(e) } + + if transaction, err = configuration.GetTransaction(params.ID); err != nil { + e := misc.HandleError(err) + if strings.HasSuffix(*e.Message, "does not exist") { + e.Code = misc.Int64P(404) + return transactions.NewDeleteTransactionNotFound().WithPayload(e) + } + return transactions.NewCommitTransactionDefault(int(*e.Code)).WithPayload(e) + } + switch transaction.Status { + case models.TransactionStatusOutdated: + return transactions.NewCommitTransactionNotAcceptable().WithPayload(misc.OutdatedTransactionError(transaction.ID)) + case models.TransactionStatusFailed: + return transactions.NewCommitTransactionNotAcceptable().WithPayload(misc.FailedTransactionError(transaction.ID)) + } + + var t *models.Transaction + t, err = configuration.CommitTransaction(params.ID) + if err != nil { + e := misc.HandleError(err) + if strings.HasSuffix(*e.Message, "does not exist") { + e.Code = misc.Int64P(404) + return transactions.NewDeleteTransactionNotFound().WithPayload(e) + } + return transactions.NewCommitTransactionDefault(int(*e.Code)).WithPayload(e) + } + + // Deleting outdated transactions with mismatching version ID + var txs *models.Transactions + txs, err = configuration.GetTransactions(models.TransactionStatusInProgress) + if err != nil { + e := misc.HandleError(err) + return transactions.NewCommitTransactionDefault(int(*e.Code)).WithPayload(e) + } + for _, tx := range *txs { + if tx.Version <= t.Version { + _ = configuration.MarkTransactionOutdated(tx.ID) + } + } + + callbackNeeded, reconfigureFunc, err := cn.ReconfigureRuntime(h.Client) + if err != nil { + e := misc.HandleError(err) + return transactions.NewCommitTransactionDefault(int(*e.Code)).WithPayload(e) + } + if *params.ForceReload { - err := th.ReloadAgent.ForceReload() + if callbackNeeded { + err = h.ReloadAgent.ForceReloadWithCallback(reconfigureFunc) + } else { + err = h.ReloadAgent.ForceReload() + } + if err != nil { e := misc.HandleError(err) return transactions.NewCommitTransactionDefault(int(*e.Code)).WithPayload(e) } return transactions.NewCommitTransactionOK().WithPayload(t) } - rID := th.ReloadAgent.Reload() + + var rID string + if callbackNeeded { + rID = h.ReloadAgent.ReloadWithCallback(reconfigureFunc) + } else { + rID = h.ReloadAgent.Reload() + } + return transactions.NewCommitTransactionAccepted().WithReloadID(rID).WithPayload(t) } + +// Handle executes the decorated Handler and, in case of successful creation, increase the counter if this is +func (r RateLimitedStartTransactionHandlerImpl) Handle(params transactions.StartTransactionParams, principal any) middleware.Responder { + if err := r.TransactionCounter.LimitReached(); err != nil { + e := misc.HandleError(err) + return transactions.NewStartTransactionDefault(int(*e.Code)).WithPayload(e) + } + return r.Handler.Handle(params, principal) +} diff --git a/handlers/user.go b/handlers/user.go new file mode 100644 index 00000000..745c025d --- /dev/null +++ b/handlers/user.go @@ -0,0 +1,289 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/user" +) + +// CreateUserHandlerImpl implementation of the CreateUserHandler interface using client-native client +type CreateUserHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteUserHandlerImpl implementation of the DeleteUserHandler interface using client-native client +type DeleteUserHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetUserHandlerImpl implementation of the GetUserHandler interface using client-native client +type GetUserHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetUsersHandlerImpl implementation of the GetUsersHandler interface using client-native client +type GetUsersHandlerImpl struct { + Client client_native.HAProxyClient +} + +// ReplaceUserHandlerImpl implementation of the ReplaceUserHandler interface using client-native client +type ReplaceUserHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// Handle executing the request and returning a response +func (h *CreateUserHandlerImpl) Handle(params user.CreateUserParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return user.NewCreateUserDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return user.NewCreateUserDefault(int(*e.Code)).WithPayload(e) + } + + _, userlist, _ := configuration.GetUserList(params.Userlist, t) + if userlist == nil { + return user.NewCreateUserBadRequest() + } + + err = configuration.CreateUser(params.Userlist, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return user.NewCreateUserDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return user.NewCreateUserDefault(int(*e.Code)).WithPayload(e) + } + return user.NewCreateUserCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return user.NewCreateUserAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return user.NewCreateUserAccepted().WithPayload(params.Data) +} + +// Handle executing the request and returning a response +func (h *DeleteUserHandlerImpl) Handle(params user.DeleteUserParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return user.NewDeleteUserDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return user.NewDeleteUserDefault(int(*e.Code)).WithPayload(e) + } + + _, userlist, err := configuration.GetUserList(params.Userlist, t) + if userlist == nil { + return user.NewDeleteUserNotFound() + } + if err != nil { + return user.NewDeleteUserNotFound() + } + + _, u, err := configuration.GetUser(params.Username, params.Userlist, t) + if u == nil { + return user.NewDeleteUserNotFound() + } + if err != nil { + return user.NewDeleteUserNotFound() + } + + err = configuration.DeleteUser(params.Username, params.Userlist, t, v) + if err != nil { + e := misc.HandleError(err) + return user.NewDeleteUserDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return user.NewDeleteUserDefault(int(*e.Code)).WithPayload(e) + } + return user.NewDeleteUserNoContent() + } + rID := h.ReloadAgent.Reload() + return user.NewDeleteUserAccepted().WithReloadID(rID) + } + return user.NewDeleteUserAccepted() +} + +// Handle executing the request and returning a response +func (h *GetUserHandlerImpl) Handle(params user.GetUserParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return user.NewGetUserDefault(int(*e.Code)).WithPayload(e) + } + + _, userlist, err := configuration.GetUserList(params.Userlist, t) + if userlist == nil { + return user.NewGetUserNotFound() + } + if err != nil { + return user.NewGetUserNotFound() + } + + _, u, err := configuration.GetUser(params.Username, params.Userlist, t) + if u == nil { + return user.NewGetUserNotFound() + } + if err != nil { + e := misc.HandleError(err) + return user.NewGetUserDefault(int(*e.Code)).WithPayload(e) + } + + return user.NewGetUserOK().WithPayload(u) +} + +// Handle executing the request and returning a response +func (h *GetUsersHandlerImpl) Handle(params user.GetUsersParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return user.NewGetUsersDefault(int(*e.Code)).WithPayload(e) + } + _, userlist, err := configuration.GetUserList(params.Userlist, t) + if userlist == nil { + return user.NewGetUserNotFound() + } + if err != nil { + return user.NewGetUserNotFound() + } + _, users, err := configuration.GetUsers(params.Userlist, t) + if err != nil { + e := misc.HandleContainerGetError(err) + if *e.Code == misc.ErrHTTPOk { + return user.NewGetUsersOK().WithPayload(models.Users{}) + } + return user.NewGetUsersDefault(int(*e.Code)).WithPayload(e) + } + return user.NewGetUsersOK().WithPayload(users) +} + +// Handle executing the request and returning a response +func (h *ReplaceUserHandlerImpl) Handle(params user.ReplaceUserParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return user.NewReplaceUserDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return user.NewReplaceUserDefault(int(*e.Code)).WithPayload(e) + } + _, userlist, err := configuration.GetUserList(params.Userlist, t) + if userlist == nil { + return user.NewReplaceUserNotFound() + } + if err != nil { + return user.NewReplaceUserNotFound() + } + + _, u, err := configuration.GetUser(params.Username, params.Userlist, t) + if u == nil { + return user.NewReplaceUserNotFound() + } + if err != nil { + return user.NewReplaceUserNotFound() + } + + err = configuration.EditUser(params.Username, params.Userlist, params.Data, t, v) + if err != nil { + e := misc.HandleError(err) + return user.NewReplaceUserDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return user.NewReplaceUserDefault(int(*e.Code)).WithPayload(e) + } + return user.NewReplaceUserOK().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return user.NewReplaceUserAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return user.NewReplaceUserAccepted().WithPayload(params.Data) +} diff --git a/handlers/userlist.go b/handlers/userlist.go new file mode 100644 index 00000000..eb6cf15c --- /dev/null +++ b/handlers/userlist.go @@ -0,0 +1,199 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/models" + + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/userlist" +) + +// CreateUserListHandlerImpl implementation of the CreateUserlistHandler interface using client-native client +type CreateUserListHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// DeleteUserListHandlerImpl implementation of the DeleteUserListHandler interface using client-native client +type DeleteUserListHandlerImpl struct { + Client client_native.HAProxyClient + ReloadAgent haproxy.IReloadAgent +} + +// GetUserListHandlerImpl implementation of the GetUserListHandler interface using client-native client +type GetUserListHandlerImpl struct { + Client client_native.HAProxyClient +} + +// GetUserListsHandlerImpl implementation of the GetUserListsHandler interface using client-native client +type GetUserListsHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *CreateUserListHandlerImpl) Handle(params userlist.CreateUserlistParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return userlist.NewCreateUserlistDefault(int(*e.Code)).WithPayload(e) + } + + err := h.createUserList(params, t, v) + if err != nil { + e := misc.HandleError(err) + return userlist.NewCreateUserlistDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return userlist.NewCreateUserlistDefault(int(*e.Code)).WithPayload(e) + } + return userlist.NewCreateUserlistCreated().WithPayload(params.Data) + } + rID := h.ReloadAgent.Reload() + return userlist.NewCreateUserlistAccepted().WithReloadID(rID).WithPayload(params.Data) + } + return userlist.NewCreateUserlistAccepted().WithPayload(params.Data) +} + +func (h *CreateUserListHandlerImpl) createUserList(params userlist.CreateUserlistParams, t string, v int64) error { + configuration, err := h.Client.Configuration() + if err != nil { + return err + } + if params.FullSection != nil && *params.FullSection { + return configuration.CreateStructuredUserList(params.Data, t, v) + } + return configuration.CreateUserList(params.Data, t, v) +} + +// Handle executing the request and returning a response +func (h *DeleteUserListHandlerImpl) Handle(params userlist.DeleteUserlistParams, principal any) middleware.Responder { + t := "" + v := int64(0) + if params.TransactionID != nil { + t = *params.TransactionID + } + if params.Version != nil { + v = *params.Version + } + + if t != "" && *params.ForceReload { + msg := "Both force_reload and transaction specified, specify only one" + c := misc.ErrHTTPBadRequest + e := &models.Error{ + Message: &msg, + Code: &c, + } + return userlist.NewDeleteUserlistDefault(int(*e.Code)).WithPayload(e) + } + + configuration, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return userlist.NewDeleteUserlistDefault(int(*e.Code)).WithPayload(e) + } + + err = configuration.DeleteUserList(params.Name, t, v) + if err != nil { + e := misc.HandleError(err) + return userlist.NewDeleteUserlistDefault(int(*e.Code)).WithPayload(e) + } + if params.TransactionID == nil { + if *params.ForceReload { + err := h.ReloadAgent.ForceReload() + if err != nil { + e := misc.HandleError(err) + return userlist.NewDeleteUserlistDefault(int(*e.Code)).WithPayload(e) + } + return userlist.NewDeleteUserlistNoContent() + } + rID := h.ReloadAgent.Reload() + return userlist.NewDeleteUserlistAccepted().WithReloadID(rID) + } + return userlist.NewDeleteUserlistAccepted() +} + +// Handle executing the request and returning a response +func (h *GetUserListHandlerImpl) Handle(params userlist.GetUserlistParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, u, err := h.getUserList(params, t) + if err != nil { + e := misc.HandleError(err) + return userlist.NewGetUserlistDefault(int(*e.Code)).WithPayload(e) + } + return userlist.NewGetUserlistOK().WithPayload(u) +} + +func (h *GetUserListHandlerImpl) getUserList(params userlist.GetUserlistParams, t string) (int64, *models.Userlist, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredUserList(params.Name, t) + } + return configuration.GetUserList(params.Name, t) +} + +// Handle executing the request and returning a response +func (h *GetUserListsHandlerImpl) Handle(params userlist.GetUserlistsParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + _, userlists, err := h.getUserLists(params, t) + if err != nil { + e := misc.HandleError(err) + return userlist.NewGetUserlistsDefault(int(*e.Code)).WithPayload(e) + } + return userlist.NewGetUserlistsOK().WithPayload(userlists) +} + +func (h *GetUserListsHandlerImpl) getUserLists(params userlist.GetUserlistsParams, t string) (int64, models.Userlists, error) { + configuration, err := h.Client.Configuration() + if err != nil { + return 0, nil, err + } + if params.FullSection != nil && *params.FullSection { + return configuration.GetStructuredUserLists(t) + } + return configuration.GetUserLists(t) +} diff --git a/handlers/version.go b/handlers/version.go new file mode 100644 index 00000000..2726d612 --- /dev/null +++ b/handlers/version.go @@ -0,0 +1,50 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package handlers + +import ( + "github.com/go-openapi/runtime/middleware" + client_native "github.com/haproxytech/client-native/v6" + + "github.com/haproxytech/dataplaneapi/misc" + "github.com/haproxytech/dataplaneapi/operations/configuration" +) + +// GetMapsHandlerImpl implementation of the GetAllRuntimeMapFilesHandler interface using client-native client +type ConfigurationGetConfigurationVersionHandlerImpl struct { + Client client_native.HAProxyClient +} + +// Handle executing the request and returning a response +func (h *ConfigurationGetConfigurationVersionHandlerImpl) Handle(params configuration.GetConfigurationVersionParams, principal any) middleware.Responder { + t := "" + if params.TransactionID != nil { + t = *params.TransactionID + } + + cfg, err := h.Client.Configuration() + if err != nil { + e := misc.HandleError(err) + return configuration.NewGetConfigurationVersionDefault(int(*e.Code)).WithPayload(e) + } + + v, err := cfg.GetConfigurationVersion(t) + if err != nil { + e := misc.HandleError(err) + return configuration.NewGetConfigurationVersionDefault(int(*e.Code)).WithPayload(e) + } + return configuration.NewGetConfigurationVersionOK().WithPayload(v) +} diff --git a/haproxy/reload_agent.go b/haproxy/reload_agent.go index 0c275886..7408339f 100644 --- a/haproxy/reload_agent.go +++ b/haproxy/reload_agent.go @@ -17,23 +17,45 @@ package haproxy import ( "bytes" + "context" + "errors" "fmt" "io" "os" "os/exec" + "path/filepath" "strconv" "strings" "sync" "time" - "github.com/haproxytech/models" + "github.com/google/renameio" + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/misc" + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/client-native/v6/runtime" + "github.com/haproxytech/dataplaneapi/log" +) - log "github.com/sirupsen/logrus" +const ( + logFieldReloadID = "reload_id" ) +type IReloadAgent interface { + Reload() string + ReloadWithCallback(callback func()) string + Restart() error + ForceReload() error + ForceReloadWithCallback(callback func()) error + Status() (bool, error) + GetReloads() models.Reloads + GetReload(id string) *models.Reload +} + type reloadCache struct { failedReloads map[string]*models.Reload lastSuccess *models.Reload + callbacks map[string]func() next string current string index int64 @@ -41,104 +63,184 @@ type reloadCache struct { mu sync.RWMutex } +type ReloadAgentParams struct { + Client client_native.HAProxyClient + Ctx context.Context + ReloadCmd string + RestartCmd string + StatusCmd string + ConfigFile string + BackupDir string + Delay int + Retention int + UseMasterSocket bool +} + // ReloadAgent handles all reloads, scheduled or forced type ReloadAgent struct { - delay int - reloadCmd string - restartCmd string - configFile string - lkgConfigFile string - cache reloadCache -} - -// Init a new reload agent -func (ra *ReloadAgent) Init(delay int, reloadCmd string, restartCmd string, configFile string, retention int) error { - ra.reloadCmd = reloadCmd - ra.restartCmd = restartCmd - ra.configFile = configFile - if delay == 0 { - delay = 5 - } - ra.delay = delay - ra.lkgConfigFile = configFile + ".lkg" + runtime runtime.Runtime + done <-chan struct{} + reloadCmd string + restartCmd string + statusCmd string + configFile string + lkgConfigFile string + cache reloadCache + delay int + useMasterSocket bool +} + +func NewReloadAgent(params ReloadAgentParams) (*ReloadAgent, error) { + ra := &ReloadAgent{} + + ra.reloadCmd = params.ReloadCmd + ra.useMasterSocket = params.UseMasterSocket + ra.restartCmd = params.RestartCmd + ra.statusCmd = params.StatusCmd + ra.configFile = params.ConfigFile + + if params.Ctx == nil { + params.Ctx = context.Background() + } + ra.done = params.Ctx.Done() + + if ra.useMasterSocket { + rt, err := params.Client.Runtime() + if err != nil { + return nil, err + } + ra.runtime = rt + } + + params.Delay *= 1000 // delay is defined in seconds - internally in miliseconds + d := os.Getenv("CI_DATAPLANE_RELOAD_DELAY_OVERRIDE") + if d != "" { + params.Delay, _ = strconv.Atoi(d) // in case of err in conversion 0 is returned + } + if params.Delay == 0 { + params.Delay = 5000 + } + ra.delay = params.Delay + + if err := ra.setLkgPath(params.ConfigFile, params.BackupDir); err != nil { + return nil, err + } // create last known good file, assume it is valid when starting if err := copyFile(ra.configFile, ra.lkgConfigFile); err != nil { - return err + return nil, err } - ra.cache.Init(retention) + ra.cache.Init(params.Retention) go ra.handleReloads() + + return ra, nil +} + +func (ra *ReloadAgent) setLkgPath(configFile, path string) error { + if path != "" { + var err error + path, err = misc.CheckOrCreateWritableDirectory(path) + if err != nil { + return err + } + ra.lkgConfigFile = fmt.Sprintf("%s/%s.lkg", path, filepath.Base(configFile)) + return nil + } + ra.lkgConfigFile = configFile + ".lkg" return nil } +func (ra *ReloadAgent) handleReload(id string) (string, error) { + logFields := map[string]any{logFieldReloadID: id} + ra.cache.mu.Lock() + ra.cache.current = id + + defer func() { + ra.cache.next = "" + ra.cache.mu.Unlock() + }() + + response, err := ra.reloadHAProxy(id) + if err != nil { + ra.cache.failReload(response) + log.WithFieldsf(logFields, log.WarnLevel, "Reload failed: %s", err) + } else { + ra.cache.succeedReload(response) + callback, ok := ra.cache.callbacks[id] + if ok { + callback() + } + log.WithFields(logFields, log.DebugLevel, "Handling reload completed, waiting for new requests") + } + delete(ra.cache.callbacks, id) + + return response, err +} + func (ra *ReloadAgent) handleReloads() { + ticker := time.NewTicker(time.Duration(ra.delay) * time.Millisecond) for { select { - case <-time.After(time.Duration(ra.delay) * time.Second): - if ra.cache.next != "" { - ra.cache.mu.Lock() - ra.cache.current = ra.cache.next - ra.cache.next = "" - ra.cache.mu.Unlock() - response, err := ra.reloadHAProxy() - if err != nil { - ra.cache.failReload(response) - log.Warning("Reload failed " + err.Error()) - } else { - ra.cache.succeedReload(response) - } + case <-ticker.C: + if next := ra.cache.getNext(); next != "" { + ra.handleReload(next) //nolint:errcheck } + case <-ra.done: + ticker.Stop() + return } } } -func (ra *ReloadAgent) reloadHAProxy() (string, error) { +func (ra *ReloadAgent) reloadHAProxy(id string) (string, error) { + logFields := map[string]any{logFieldReloadID: id} // try the reload - log.Debug("Reload started...") + log.WithFields(logFields, log.DebugLevel, "Reload started") + var output string + var err error t := time.Now() - output, err := execCmd(ra.reloadCmd) - log.Debug("Reload finished.") - log.Debug("Time elapsed: ", time.Since(t)) + + if ra.useMasterSocket { + output, err = ra.runtime.Reload() + } else { + output, err = execCmd(ra.reloadCmd) + } if err != nil { - // if failed, return to last known good file and restart and return the original file - log.Info("Reload failed, restarting with last known good config...") + reloadFailedError := err + // If failed, return to last known good file. + log.WithFields(logFields, log.InfoLevel, "Reload failed, reverting the last working config...") if err := copyFile(ra.configFile, ra.configFile+".bck"); err != nil { - return fmt.Sprintf("Reload failed: %s, failed to backup original config file for restart.", output), err + return fmt.Sprintf("Reload failed: %s. Failed to backup the current config file.", output), err } defer func() { - copyFile(ra.configFile+".bck", ra.configFile) os.Remove(ra.configFile + ".bck") }() if err := copyFile(ra.lkgConfigFile, ra.configFile); err != nil { - return fmt.Sprintf("Reload failed: %s, failed to revert to last known good config file", output), err - } - if err := ra.restartHAProxy(); err != nil { - log.Warn("Restart failed, please check the reason and restart manually: ", err) - return fmt.Sprintf("Reload failed: %s, failed to restart HAProxy, please check and start manually", output), err + return fmt.Sprintf("Reload failed: %s. Failed to revert to the last working config file.", output), err } - log.Debug("HAProxy restarted with last known good config.") - return output, err + + return output, reloadFailedError } - log.Debug("Reload succesful") + log.WithFieldsf(logFields, log.DebugLevel, "Reload finished in %s", time.Since(t)) + log.WithFields(logFields, log.DebugLevel, "Reload successful") // if success, replace last known good file - copyFile(ra.configFile, ra.lkgConfigFile) + copyFile(ra.configFile, ra.lkgConfigFile) //nolint:errcheck return output, nil } func (ra *ReloadAgent) restartHAProxy() error { _, err := execCmd(ra.restartCmd) - if err != nil { - return err - } - return nil + return err } func execCmd(cmd string) (string, error) { strArr := strings.Split(cmd, " ") var c *exec.Cmd if len(strArr) == 1 { + //nolint:gosec c = exec.Command(strArr[0]) } else { + //nolint:gosec c = exec.Command(strArr[0], strArr[1:]...) } var stdout, stderr bytes.Buffer @@ -147,25 +249,70 @@ func execCmd(cmd string) (string, error) { err := c.Run() if err != nil { - return string(stderr.Bytes()), fmt.Errorf("Executing %s failed: %s", cmd, err) + return stderr.String(), fmt.Errorf("executing %s failed: %s", cmd, err) } - return string(stdout.Bytes()), nil + return stdout.String(), nil } // Reload schedules a reload func (ra *ReloadAgent) Reload() string { - if ra.cache.next == "" { - ra.cache.newReload() + next := ra.cache.getNext() + if next == "" { + next = ra.cache.newReload() + log.WithFields(map[string]any{logFieldReloadID: next}, log.DebugLevel, "Scheduling a new reload...") } - return ra.cache.next + + return next } // ForceReload calls reload directly func (ra *ReloadAgent) ForceReload() error { - r, err := ra.reloadHAProxy() + next := ra.cache.getNext() + if next != "" { + r, err := ra.handleReload(next) + if err != nil { + return NewReloadError(fmt.Sprintf("Reload failed: %v, %v", err, r)) + } + return nil + } + + r, err := ra.reloadHAProxy("force") + if err != nil { + return NewReloadError(fmt.Sprintf("Reload failed: %v, %v", err, r)) + } + return nil +} + +// Reload schedules a reload, callback is called only if reload is successful +func (ra *ReloadAgent) ReloadWithCallback(callback func()) string { + next := ra.cache.getNext() + if next == "" { + next = ra.cache.newReloadWithCallback(callback) + log.WithFields(map[string]any{logFieldReloadID: next}, log.DebugLevel, "Scheduling a new reload...") + } + ra.cache.mu.Lock() + ra.cache.callbacks[next] = callback + ra.cache.mu.Unlock() + return next +} + +// ForceReload calls reload directly, callback is called only if reload is successful +func (ra *ReloadAgent) ForceReloadWithCallback(callback func()) error { + next := ra.cache.getNext() + if next != "" { + r, err := ra.handleReload(next) + if err != nil { + return NewReloadError(fmt.Sprintf("Reload failed: %v, %v", err, r)) + } + callback() + return nil + } + + r, err := ra.reloadHAProxy("force") if err != nil { return NewReloadError(fmt.Sprintf("Reload failed: %v, %v", err, r)) } + callback() return nil } @@ -178,21 +325,36 @@ func (rc *reloadCache) Init(retention int) { rc.lastSuccess = nil rc.index = 0 rc.retention = retention + rc.callbacks = make(map[string]func()) } -func (rc *reloadCache) newReload() { +func (rc *reloadCache) newReload() string { rc.mu.Lock() defer rc.mu.Unlock() - rc.next = rc.generateID() + id := fmt.Sprintf("%s-%v", time.Now().Format("2006-01-02"), rc.index) + rc.index++ + rc.next = id + return rc.next } -func (rc *reloadCache) failReload(response string) { +func (rc *reloadCache) newReloadWithCallback(callback func()) string { + next := rc.newReload() rc.mu.Lock() - defer rc.mu.Unlock() + rc.callbacks[next] = callback + rc.mu.Unlock() + return next +} + +func (rc *reloadCache) getNext() string { + rc.mu.RLock() + defer rc.mu.RUnlock() + return rc.next +} +func (rc *reloadCache) failReload(response string) { r := &models.Reload{ ID: rc.current, - Status: "failed", + Status: models.ReloadStatusFailed, Response: response, ReloadTimestamp: time.Now().Unix(), } @@ -203,12 +365,9 @@ func (rc *reloadCache) failReload(response string) { } func (rc *reloadCache) succeedReload(response string) { - rc.mu.Lock() - defer rc.mu.Unlock() - r := &models.Reload{ ID: rc.current, - Status: "succeeded", + Status: models.ReloadStatusSucceeded, Response: response, ReloadTimestamp: time.Now().Unix(), } @@ -243,7 +402,7 @@ func (ra *ReloadAgent) GetReloads() models.Reloads { if ra.cache.current != "" { r := &models.Reload{ ID: ra.cache.current, - Status: "in_progress", + Status: models.ReloadStatusInProgress, } v = append(v, r) } @@ -251,7 +410,7 @@ func (ra *ReloadAgent) GetReloads() models.Reloads { if ra.cache.next != "" { r := &models.Reload{ ID: ra.cache.next, - Status: "in_progress", + Status: models.ReloadStatusInProgress, } v = append(v, r) } @@ -265,13 +424,13 @@ func (ra *ReloadAgent) GetReload(id string) *models.Reload { if ra.cache.current == id { return &models.Reload{ ID: ra.cache.current, - Status: "in_progress", + Status: models.ReloadStatusInProgress, } } if ra.cache.next == id { return &models.Reload{ ID: ra.cache.current, - Status: "in_progress", + Status: models.ReloadStatusInProgress, } } @@ -297,25 +456,39 @@ func (ra *ReloadAgent) GetReload(id string) *models.Reload { if gDate.Before(sDate) { return &models.Reload{ ID: id, - Status: "succeeded", + Status: models.ReloadStatusSucceeded, } } if sIndex > gIndex { return &models.Reload{ ID: id, - Status: "succeeded", + Status: models.ReloadStatusSucceeded, } } } return nil } -func (rc *reloadCache) generateID() string { - defer func() { - rc.index++ - }() - return fmt.Sprintf("%s-%v", time.Now().Format("2006-01-02"), rc.index) +func (ra *ReloadAgent) Restart() error { + return ra.restartHAProxy() +} + +func (ra *ReloadAgent) Status() (bool, error) { + return ra.status() +} + +func (ra *ReloadAgent) status() (bool, error) { + if ra.statusCmd == "" { + return false, errors.New("status command not configured") + } + resp, err := execCmd(ra.statusCmd) + if err != nil { + log.Debugf("haproxy status check failed: %s", resp) + return false, nil //nolint:nilerr + } + log.Debugf("haproxy status check successful: %s", resp) + return true, nil } func getTimeIndexFromID(id string) (time.Time, int64, error) { @@ -325,7 +498,6 @@ func getTimeIndexFromID(id string) (time.Time, int64, error) { return time.Now(), 0, err } date, err := time.Parse("2006-01-02", strings.Join(data[:len(data)-1], "-")) - if err != nil { return date, 0, err } @@ -340,10 +512,10 @@ type ReloadError struct { // Error implementation for ConfError func (e *ReloadError) Error() string { - return fmt.Sprintf(e.msg) + return e.msg } -// NewReloadError contstructor for ReloadError +// NewReloadError constructor for ReloadError func NewReloadError(msg string) *ReloadError { return &ReloadError{msg: msg} } @@ -355,15 +527,9 @@ func copyFile(src, dest string) error { } defer srcContent.Close() - destContent, err := os.Create(dest) - if err != nil { - return err - } - defer destContent.Close() - - _, err = io.Copy(destContent, srcContent) + data, err := io.ReadAll(srcContent) if err != nil { return err } - return destContent.Sync() + return renameio.WriteFile(dest, data, 0o644) } diff --git a/haproxy/reload_agent_test.go b/haproxy/reload_agent_test.go new file mode 100644 index 00000000..d3ac7658 --- /dev/null +++ b/haproxy/reload_agent_test.go @@ -0,0 +1,75 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package haproxy + +import ( + "context" + "os" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestReloadAgentDoesntMissReloads(t *testing.T) { + ctx, cancel := context.WithCancel(t.Context()) + f, err := os.CreateTemp(t.TempDir(), "config.cfg") + require.NoError(t, err) + assert.NotNil(t, f) + t.Cleanup(func() { + cancel() + assert.NoError(t, os.Remove(f.Name())) + }) + + reloadAgentParams := ReloadAgentParams{ + Delay: 1, + ReloadCmd: `echo "systemctl reload haproxy"`, + RestartCmd: `echo "systemctl restart haproxy"`, + ConfigFile: f.Name(), + BackupDir: "", + Retention: 1, + Ctx: ctx, + } + + ra, err := NewReloadAgent(reloadAgentParams) + require.NoError(t, err) + assert.NotNil(t, ra) + + var reloadID, firstReloadID, secondReloadID string + + // trigger a reload + reloadID = ra.Reload() + assert.NotEmpty(t, reloadID) + firstReloadID = reloadID + + // trigger another reload shortly after the first one but before the + // delay has elapsed which should yield the first reload ID + time.Sleep(10 * time.Millisecond) + reloadID = ra.Reload() + assert.EqualValues(t, firstReloadID, reloadID) + + // sleep for as long as the delay duration to mimic a slightly + // slower DataplaneAPI operation + time.Sleep(time.Duration(reloadAgentParams.Delay) * time.Second) + + // Since this is happening after the delay has elapsed, it should create + // a new reload ID + reloadID = ra.Reload() + assert.NotEmpty(t, reloadID) + secondReloadID = reloadID + assert.NotEqualValues(t, firstReloadID, secondReloadID) +} diff --git a/log/configuration.go b/log/configuration.go new file mode 100644 index 00000000..658c214b --- /dev/null +++ b/log/configuration.go @@ -0,0 +1,39 @@ +package log + +const DefaultApacheLogFormat = "%h %l %u %t \"%m %U%q %H\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" + +type Target struct { + LogTo string `yaml:"log_to,omitempty" description:"Log target, can be stdout, file, or syslog"` + LogFile string `yaml:"log_file,omitempty" description:"Location of the log file"` + LogLevel string `yaml:"log_level,omitempty" description:"Logging level, allowed values: trace|debug|info|warning|error"` + LogFormat string `yaml:"log_format,omitempty" description:"Logging format, allowed values: text|JSON"` + ACLFormat string `yaml:"acl_format,omitempty" description:"Apache Common Log Format to format the access log entries, default:\"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-agent}i\\\" %{us}T"` + SyslogAddr string `yaml:"syslog_address,omitempty" description:"Syslog address (with port declaration in case of TCP type) where logs should be forwarded: accepting socket path in case of unix or unixgram"` + SyslogProto string `yaml:"syslog_protocol,omitempty" description:"Syslog server protocol, allowed values: tcp|tcp4|tcp6|unix|unixgram"` + SyslogTag string `yaml:"syslog_tag,omitempty" description:"String to tag the syslog messages"` + SyslogLevel string `yaml:"syslog_level,omitempty" description:"Define the required syslog messages level, allowed values: debug|info|notice|warning|error|critical|alert|emergency"` + SyslogFacility string `yaml:"syslog_facility,omitempty" description:"Define the Syslog facility number, allowed values: kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|authpriv|ftp|local0|local1|local2|local3|local4|local5|local6|local7"` + SyslogMsgID string `yaml:"-"` + LogTypes []string `yaml:"log_types,omitempty" description:"Define which log types to log to this target, allowed values: app|access" save:"true"` +} + +type Targets []Target + +// Deprecated: use configuration file options instead +type LoggingOptions struct { + LogTo string `long:"log-to" description:"Log target, can be stdout, file, or syslog" default:"stdout" choice:"stdout" choice:"file" choice:"syslog" group:"log"` + LogFile string `long:"log-file" description:"Location of the log file" default:"/var/log/dataplaneapi/dataplaneapi.log" group:"log"` + LogLevel string `long:"log-level" description:"Logging level" default:"warning" choice:"trace" choice:"debug" choice:"info" choice:"warning" choice:"error" group:"log"` + LogFormat string `long:"log-format" description:"Logging format" default:"text" choice:"text" choice:"JSON" group:"log"` + ACLFormat string `long:"apache-common-log-format" description:"Apache Common Log Format to format the access log entries" default:"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %{us}T" group:"log"` +} + +// Deprecated: use configuration file options instead +type SyslogOptions struct { + SyslogAddr string `long:"syslog-address" description:"Syslog address (with port declaration in case of TCP type) where logs should be forwarded: accepting socket path in case of unix or unixgram" default:"" group:"syslog"` + SyslogProto string `long:"syslog-protocol" description:"Syslog server protocol" default:"tcp" choice:"tcp" choice:"tcp4" choice:"tcp6" choice:"unix" choice:"unixgram" group:"syslog"` + SyslogTag string `long:"syslog-tag" description:"String to tag the syslog messages" default:"dataplaneapi" group:"syslog"` + SyslogLevel string `long:"syslog-level" description:"Define the required syslog messages level, allowed values: debug|info|notice|warning|error|critical|alert|emergency " default:"debug" group:"syslog"` + SyslogFacility string `long:"syslog-facility" description:"Define the Syslog facility number, allowed values: kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|authpriv|ftp|local0|local1|local2|local3|local4|local5|local6|local7" default:"local0" group:"syslog"` + SyslogMsgID string +} diff --git a/log/log.go b/log/log.go new file mode 100644 index 00000000..695b4ebe --- /dev/null +++ b/log/log.go @@ -0,0 +1,364 @@ +package log + +import ( + "errors" + "fmt" + "io" + "os" + "path/filepath" + + "github.com/haproxytech/client-native/v6/models" + apache_log "github.com/lestrrat-go/apache-logformat" + "github.com/sirupsen/logrus" +) + +const ( + PanicLevel logrus.Level = logrus.PanicLevel + FatalLevel logrus.Level = logrus.FatalLevel + ErrorLevel logrus.Level = logrus.ErrorLevel + WarnLevel logrus.Level = logrus.WarnLevel + InfoLevel logrus.Level = logrus.InfoLevel + DebugLevel logrus.Level = logrus.DebugLevel + TraceLevel logrus.Level = logrus.TraceLevel +) + +var ( + appLogger *Logger + accessLogger *Logger + config Targets + oldConfig LoggingOptions + oldSyslogConfig SyslogOptions + clusterConfig []*models.ClusterLogTarget + node string +) + +func InitWithConfiguration(targets Targets, old LoggingOptions, oldSyslog SyslogOptions, clusterTargets []*models.ClusterLogTarget, nodeID string) error { + config = targets + oldConfig = old + oldSyslogConfig = oldSyslog + clusterConfig = clusterTargets + node = nodeID + appLogger = nil + accessLogger = nil + return Init() +} + +func Init() error { + if len(config) > 0 { + for _, target := range config { + switch len(target.LogTypes) { + case 0: + // by default use only app loggers + configureAppLogger(target) + case 1: + switch target.LogTypes[0] { + case "app": + configureAppLogger(target) + case "access": + configureAccessLogger(target) + } + case 2: + if target.LogTypes[0] != target.LogTypes[1] { + configureAppLogger(target) + configureAccessLogger(target) + } + } + } + } else { + // Deprecated: if no log targets are set in the configuration file, use old way + target := Target{ + LogTo: oldConfig.LogTo, + LogLevel: oldConfig.LogLevel, + LogFile: oldConfig.LogFile, + LogFormat: oldConfig.LogFormat, + LogTypes: []string{"access", "app"}, + ACLFormat: oldConfig.ACLFormat, + SyslogAddr: oldSyslogConfig.SyslogAddr, + SyslogProto: oldSyslogConfig.SyslogProto, + SyslogTag: oldSyslogConfig.SyslogTag, + SyslogLevel: oldSyslogConfig.SyslogLevel, + SyslogFacility: oldSyslogConfig.SyslogFacility, + } + configureAccessLogger(target) + configureAppLogger(target) + } + for _, ct := range clusterConfig { + clusterTarget := *ct + var syslogAddr string + var syslogProto string + switch { + case clusterTarget.Protocol != nil && *clusterTarget.Protocol == "tcp": + port := 514 + if clusterTarget.Port != nil { + port = int(*clusterTarget.Port) + } + syslogAddr = fmt.Sprintf("%s:%v", *clusterTarget.Address, port) + syslogProto = "tcp" + case clusterTarget.Protocol != nil && *clusterTarget.Protocol == "udp": + if clusterTarget.Port == nil { + syslogAddr = *clusterTarget.Address + } else { + syslogAddr = fmt.Sprintf("%s:%v", *clusterTarget.Address, *clusterTarget.Port) + } + syslogProto = "unixgram" + } + access := Target{ + LogTo: "syslog", + LogTypes: []string{"access"}, + ACLFormat: clusterTarget.LogFormat, + SyslogAddr: syslogAddr, + SyslogProto: syslogProto, + SyslogTag: "dataplaneapi-access", + SyslogLevel: "debug", + SyslogFacility: "user", + SyslogMsgID: node, + } + configureAccessLogger(access) + app := Target{ + LogTo: "syslog", + LogLevel: "info", + LogFormat: "json", + LogTypes: []string{"app"}, + ACLFormat: clusterTarget.LogFormat, + SyslogAddr: syslogAddr, + SyslogProto: syslogProto, + SyslogTag: "dataplaneapi-app", + SyslogLevel: "debug", + SyslogFacility: "user", + SyslogMsgID: node, + } + configureAppLogger(app) + } + return nil +} + +func configureAppLogger(target Target) { + logger := logrus.New() + configureLogger(logger, target) + if appLogger == nil { + appLogger = &Logger{} + } + aclLogger := &ACLLogger{ + Logger: logger, + } + appLogger.loggers = append(appLogger.loggers, aclLogger) +} + +func configureAccessLogger(target Target) { + logger := logrus.New() + configureLogger(logger, target) + if accessLogger == nil { + accessLogger = &Logger{} + } + var al *apache_log.ApacheLog + if target.ACLFormat == "" { + al, _ = apache_log.New(DefaultApacheLogFormat) + } else { + al, _ = apache_log.New(target.ACLFormat) + } + if al == nil { + return + } + aclLogger := &ACLLogger{ + Logger: logger, + ApacheLog: al, + } + accessLogger.loggers = append(accessLogger.loggers, aclLogger) +} + +func AppLogger() (*Logger, error) { + if appLogger == nil { + if err := Init(); err != nil { + return nil, err + } + } + if appLogger == nil { + return nil, errors.New("no application loggers configured") + } + return appLogger, nil +} + +func AccessLogger() (*Logger, error) { + if accessLogger == nil { + if err := Init(); err != nil { + return nil, err + } + } + if accessLogger == nil { + return nil, errors.New("no access loggers configured") + } + return accessLogger, nil +} + +func Log(level logrus.Level, args ...any) { + if appLogger != nil { + appLogger.Log(level, args...) + } +} + +func Logf(level logrus.Level, format string, args ...any) { + if appLogger != nil { + appLogger.Logf(level, format, args...) + } +} + +func Print(args ...any) { + if appLogger != nil { + appLogger.Print(args...) + } +} + +func Trace(args ...any) { + if appLogger != nil { + appLogger.Trace(args...) + } +} + +func Debug(args ...any) { + if appLogger != nil { + appLogger.Debug(args...) + } +} + +func Info(args ...any) { + if appLogger != nil { + appLogger.Info(args...) + } +} + +func Warning(args ...any) { + if appLogger != nil { + appLogger.Warning(args...) + } +} + +func Error(args ...any) { + if appLogger != nil { + appLogger.Error(args...) + } +} + +func Panic(args ...any) { + if appLogger != nil { + appLogger.Panic(args...) + } +} + +func Fatal(args ...any) { + if appLogger != nil { + appLogger.Panic(args...) + } +} + +func Printf(format string, args ...any) { + if appLogger != nil { + appLogger.Printf(format, args...) + } +} + +func Tracef(format string, args ...any) { + if appLogger != nil { + appLogger.Tracef(format, args...) + } +} + +func Debugf(format string, args ...any) { + if appLogger != nil { + appLogger.Debugf(format, args...) + } +} + +func Infof(format string, args ...any) { + if appLogger != nil { + appLogger.Infof(format, args...) + } +} + +func Warningf(format string, args ...any) { + if appLogger != nil { + appLogger.Warningf(format, args...) + } +} + +func Errorf(format string, args ...any) { + if appLogger != nil { + appLogger.Errorf(format, args...) + } +} + +func Panicf(format string, args ...any) { + if appLogger != nil { + appLogger.Panicf(format, args...) + } +} + +func Fatalf(format string, args ...any) { + if appLogger != nil { + appLogger.Fatalf(format, args...) + } +} + +func Fatalln(format string, args ...any) { //nolint:goprintffuncname + if appLogger != nil { + appLogger.Fatalln(args...) + } +} + +func WithFields(fields map[string]any, level logrus.Level, args ...any) { + if appLogger != nil { + appLogger.WithFields(fields, level, args...) + } +} + +func WithFieldsf(fields map[string]any, level logrus.Level, format string, args ...any) { + if appLogger != nil { + appLogger.WithFieldsf(fields, level, format, args...) + } +} + +func configureLogger(logger *logrus.Logger, target Target) { + switch target.LogFormat { + case "text": + logger.SetFormatter(&logrus.TextFormatter{ + FullTimestamp: true, + DisableColors: true, + }) + case "JSON": + case "json": + logger.SetFormatter(&logrus.JSONFormatter{}) + } + + switch target.LogTo { + case "stdout": + logger.SetOutput(os.Stdout) + case "file": + dir := filepath.Dir(target.LogFile) + if err := os.MkdirAll(dir, os.ModePerm); err != nil { + Warning("Error opening log file, no logging implemented: " + err.Error()) + } + logFile, err := os.OpenFile(target.LogFile, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0o666) + if err != nil { + Warning("Error opening log file, no logging implemented: " + err.Error()) + } + logger.SetOutput(logFile) + case "syslog": + logger.SetOutput(io.Discard) + hook, err := NewRFC5424Hook(target) + if err != nil { + Warningf("Error configuring Syslog logging: %s", err.Error()) + break + } + logger.AddHook(hook) + } + + switch target.LogLevel { + case "debug": + logger.SetLevel(logrus.DebugLevel) + case "info": + logger.SetLevel(logrus.InfoLevel) + case "warning": + logger.SetLevel(logrus.WarnLevel) + case "error": + logger.SetLevel(logrus.ErrorLevel) + } +} diff --git a/log/logger.go b/log/logger.go new file mode 100644 index 00000000..5d50c661 --- /dev/null +++ b/log/logger.go @@ -0,0 +1,151 @@ +package log + +import ( + "os" + + apache_log "github.com/lestrrat-go/apache-logformat" + "github.com/sirupsen/logrus" +) + +type Logger struct { + loggers []*ACLLogger +} + +type ACLLogger struct { + *logrus.Logger + + ApacheLog *apache_log.ApacheLog +} + +func (l *Logger) Log(level logrus.Level, args ...any) { + for _, log := range l.loggers { + go log.Log(level, args...) + } +} + +func (l *Logger) Logf(level logrus.Level, format string, args ...any) { + for _, log := range l.loggers { + go log.Logf(level, format, args...) + } +} + +func (l *Logger) Print(args ...any) { + for _, log := range l.loggers { + go log.Print(args...) + } +} + +func (l *Logger) Trace(args ...any) { + for _, log := range l.loggers { + go log.Trace(args...) + } +} + +func (l *Logger) Debug(args ...any) { + for _, log := range l.loggers { + go log.Debug(args...) + } +} + +func (l *Logger) Info(args ...any) { + for _, log := range l.loggers { + go log.Info(args...) + } +} + +func (l *Logger) Warning(args ...any) { + for _, log := range l.loggers { + go log.Warning(args...) + } +} + +func (l *Logger) Error(args ...any) { + for _, log := range l.loggers { + go log.Error(args...) + } +} + +func (l *Logger) Panic(args ...any) { + for _, log := range l.loggers { + go log.Panic(args...) + } +} + +func (l *Logger) Printf(format string, args ...any) { + for _, log := range l.loggers { + go log.Printf(format, args...) + } +} + +func (l *Logger) Tracef(format string, args ...any) { + for _, log := range l.loggers { + go log.Tracef(format, args...) + } +} + +func (l *Logger) Debugf(format string, args ...any) { + for _, log := range l.loggers { + go log.Debugf(format, args...) + } +} + +func (l *Logger) Infof(format string, args ...any) { + for _, log := range l.loggers { + go log.Infof(format, args...) + } +} + +func (l *Logger) Warningf(format string, args ...any) { + for _, log := range l.loggers { + go log.Warningf(format, args...) + } +} + +func (l *Logger) Errorf(format string, args ...any) { + for _, log := range l.loggers { + go log.Errorf(format, args...) + } +} + +func (l *Logger) Panicf(format string, args ...any) { + for _, log := range l.loggers { + go log.Panicf(format, args...) + } +} + +func (l *Logger) Fatalln(args ...any) { + for _, log := range l.loggers { + log.Logln(logrus.FatalLevel, args...) + } + os.Exit(1) +} + +func (l *Logger) Fatal(args ...any) { + for _, log := range l.loggers { + log.Log(logrus.FatalLevel, args...) + } + os.Exit(1) +} + +func (l *Logger) Fatalf(format string, args ...any) { + for _, log := range l.loggers { + log.Logf(logrus.FatalLevel, format, args...) + } + os.Exit(1) +} + +func (l *Logger) WithFieldsf(fields map[string]any, level logrus.Level, format string, args ...any) { + for _, log := range l.loggers { + go log.WithFields(fields).Logf(level, format, args...) + } +} + +func (l *Logger) WithFields(fields map[string]any, level logrus.Level, args ...any) { + for _, log := range l.loggers { + go log.WithFields(fields).Log(level, args...) + } +} + +func (l *Logger) Loggers() []*ACLLogger { + return l.loggers +} diff --git a/log/rfc5424.go b/log/rfc5424.go new file mode 100644 index 00000000..b29ba17b --- /dev/null +++ b/log/rfc5424.go @@ -0,0 +1,162 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log + +import ( + "errors" + "fmt" + "strings" + "time" + + "github.com/nathanaelle/syslog5424/v2" + circuit "github.com/rubyist/circuitbreaker" + "github.com/sirupsen/logrus" +) + +type RFC5424Hook struct { + syslog *syslog5424.Syslog + sender *syslog5424.Sender + msgID string + + // Use a circuit breaker to pause sending messages to the syslog target + // in the presence of connection errors. + cb *circuit.Breaker +} + +func (r RFC5424Hook) Levels() []logrus.Level { + return logrus.AllLevels +} + +func (r RFC5424Hook) Fire(entry *logrus.Entry) (err error) { + var sev syslog5424.Priority + switch entry.Level { + case logrus.PanicLevel: + sev = syslog5424.LogALERT + case logrus.FatalLevel: + sev = syslog5424.LogCRIT + case logrus.ErrorLevel: + sev = syslog5424.LogERR + case logrus.WarnLevel: + sev = syslog5424.LogWARNING + case logrus.InfoLevel: + sev = syslog5424.LogINFO + case logrus.DebugLevel, logrus.TraceLevel: + sev = syslog5424.LogDEBUG + } + + messages := []string{entry.Message} + for k, v := range entry.Data { + // TODO: we should deal with structured data properly + messages = append(messages, fmt.Sprintf("%s=%v", k, v)) + } + + msg := strings.Join(messages, " ") + + // Do not perform any action unless the circuit breaker is either closed (reset), or is ready to retry. + if r.cb.Ready() { + r.syslog.Channel(sev).Msgid(r.msgID).Log(msg) + // Register any call as successful to enable automatic resets. + // Failures are registered asynchronously by the goroutine that consumes errors from the corresponding channel. + r.cb.Success() + } + + return err +} + +func NewRFC5424Hook(opts Target) (logrus.Hook, error) { + if len(opts.SyslogAddr) == 0 { + return nil, errors.New("no address has been declared") + } + + priority := strings.Join([]string{opts.SyslogFacility, opts.SyslogLevel}, ".") + var priorityParsed syslog5424.Priority + if err := priorityParsed.Set(priority); err != nil { + return nil, err + } + + // syslog5424.Dial() returns an error channel, which needs to be drained + // in order to avoid blocking. + slConn, errCh, err := syslog5424.Dial(opts.SyslogProto, opts.SyslogAddr) + if err != nil { + return nil, err + } + + syslogServer, err := syslog5424.New(slConn, priorityParsed, opts.SyslogTag) + if err != nil { + return nil, err + } + + r := &RFC5424Hook{ + syslog: syslogServer, sender: slConn, msgID: opts.SyslogMsgID, + // We can change the circuit breaker settings as desired - including making + // them configurable and/or dynamically adjustable based on runtime conditions. + // + // Please note, however, that a 3-failure threshold breaker with default settings + // was found to work well with varying load and different states of a log target. + // Specifically, the breaker will remain tripped when sending messages to the target + // that is consistently failing, and will reset quickly when delivery begins to succeed. + cb: circuit.NewThresholdBreaker(3), + } + + // A signal channel that is used to stop the goroutine reporting on circuit breaker state changes. + doneCh := make(chan struct{}) + + // Consume errors from errCh until it is closed. + go func() { + for { + err, ok := <-errCh + if err != nil { + r.cb.Fail() // Register a failure with the circuit breaker. + } + if !ok { + close(doneCh) + return + } + } + }() + + // Report on circuit breaker state changes. + cbStateCh := r.cb.Subscribe() + go func() { + for { + select { + case e, ok := <-cbStateCh: + if !ok { + return + } + var state string + switch e { + case circuit.BreakerTripped: + state = "too many connection errors, log delivery is stopped until this improves" + case circuit.BreakerReset: + state = "resuming log delivery" + default: + continue + } + fmt.Println(time.Now().Format(time.RFC3339), "syslog target", opts.SyslogAddr, "("+opts.SyslogTag+"):", state) + case <-doneCh: + return + } + } + }() + + return r, nil +} + +func (r RFC5424Hook) Close() error { + r.sender.End() // This will also close errCh returned by syslog.Dial() in NewRFC5424Hook(), causing related goroutines to exit. + return nil +} diff --git a/misc/misc.go b/misc/misc.go index 2cfade77..31ecc8a6 100644 --- a/misc/misc.go +++ b/misc/misc.go @@ -16,13 +16,27 @@ package misc import ( + "crypto/rand" + "encoding/base64" "encoding/json" + "errors" + "fmt" + "net" + "net/http" + "os" + "strconv" "strings" - "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/GehirnInc/crypt" + "github.com/haproxytech/client-native/v6/config-parser/types" + "github.com/haproxytech/client-native/v6/configuration" + client_errors "github.com/haproxytech/client-native/v6/errors" + "github.com/haproxytech/client-native/v6/models" + jsoniter "github.com/json-iterator/go" - "github.com/haproxytech/client-native/configuration" - "github.com/haproxytech/models" + "github.com/haproxytech/dataplaneapi/haproxy" + "github.com/haproxytech/dataplaneapi/log" + "github.com/haproxytech/dataplaneapi/rate" ) const ( @@ -34,22 +48,44 @@ const ( ErrHTTPInternalServerError = int64(500) // ErrHTTPBadRequest HTTP status code 400 ErrHTTPBadRequest = int64(400) + // ErrHTTPRateLimit HTTP status code 429 + ErrHTTPRateLimit = int64(429) + // ErrHTTPOk HTTP status code 200 + ErrHTTPOk = int64(200) ) +func OutdatedTransactionError(id string) *models.Error { + var code int64 = 406 + msg := fmt.Sprintf("transaction %s is outdated and cannot be committed", id) + return &models.Error{ + Code: &code, + Message: &msg, + } +} + +func FailedTransactionError(id string) *models.Error { + var code int64 = 406 + msg := fmt.Sprintf("transaction %s is failed and cannot be committed", id) + return &models.Error{ + Code: &code, + Message: &msg, + } +} + // HandleError translates error codes from client native into models.Error with appropriate http status code func HandleError(err error) *models.Error { switch t := err.(type) { case *configuration.ConfError: msg := t.Error() httpCode := ErrHTTPInternalServerError - switch t.Code() { + switch t.Err() { case configuration.ErrObjectDoesNotExist: httpCode = ErrHTTPNotFound - case configuration.ErrObjectAlreadyExists, configuration.ErrVersionMismatch, configuration.ErrTransactionAlredyExists: + case configuration.ErrObjectAlreadyExists, configuration.ErrVersionMismatch, configuration.ErrTransactionAlreadyExists: httpCode = ErrHTTPConflict case configuration.ErrObjectIndexOutOfRange, configuration.ErrValidationError, configuration.ErrBothVersionTransaction, configuration.ErrNoVersionTransaction, configuration.ErrNoParentSpecified, configuration.ErrParentDoesNotExist, - configuration.ErrTransactionDoesNotExist: + configuration.ErrTransactionDoesNotExist, configuration.ErrGeneralError: httpCode = ErrHTTPBadRequest } return &models.Error{Code: &httpCode, Message: &msg} @@ -57,38 +93,258 @@ func HandleError(err error) *models.Error { httpCode := ErrHTTPBadRequest msg := t.Error() return &models.Error{Code: &httpCode, Message: &msg} + case *rate.TransactionLimitReachedError: + httpCode := ErrHTTPRateLimit + msg := t.Error() + return &models.Error{Code: &httpCode, Message: &msg} default: msg := t.Error() code := ErrHTTPInternalServerError + if errors.Is(t, client_errors.ErrNotFound) { + code = ErrHTTPNotFound + } return &models.Error{Code: &code, Message: &msg} } } +// HandleContainerGetError translates error codes from client native into models.Error with appropriate http status code. Intended for get requests on container endpoints. +func HandleContainerGetError(err error) *models.Error { + if t, ok := err.(*configuration.ConfError); ok { + if t.Is(configuration.ErrParentDoesNotExist) { + code := ErrHTTPOk + return &models.Error{Code: &code} + } + } + return HandleError(err) +} + // DiscoverChildPaths return children models.Endpoints given path func DiscoverChildPaths(path string, spec json.RawMessage) (models.Endpoints, error) { - var m map[string]interface{} + var m map[string]any + json := jsoniter.ConfigCompatibleWithStandardLibrary err := json.Unmarshal(spec, &m) if err != nil { return nil, err } es := make(models.Endpoints, 0, 1) - paths := m["paths"].(map[string]interface{}) + paths := m["paths"].(map[string]any) for key, value := range paths { - v := value.(map[string]interface{}) - g := v["get"].(map[string]interface{}) - title := g["summary"].(string) - description := g["description"].(string) - - if strings.HasPrefix(key, path) && key != path { - if len(strings.Split(key[len(path)+1:], "/")) == 1 { - e := models.Endpoint{ - URL: key, - Title: title, - Description: description, + v := value.(map[string]any) + if g, ok := v["get"].(map[string]any); ok { + title := "" + if titleInterface, ok := g["summary"]; ok && titleInterface != nil { + title = titleInterface.(string) + } + description := "" + if descInterface, ok := g["description"]; ok && descInterface != nil { + description = descInterface.(string) + } + + if strings.HasPrefix(key, path) && key != path { + resource := key[len(path):] + if strings.HasPrefix(resource, "/") && len(strings.Split(resource[1:], "/")) == 1 { + e := models.Endpoint{ + URL: key, + Title: title, + Description: description, + } + es = append(es, &e) } - es = append(es, &e) } } } return es, nil } + +func IsUnixSocketAddr(addr string) bool { + if strings.HasPrefix(addr, "ipv4@") || strings.HasPrefix(addr, "ipv6@") { + return false + } + + // check if it has semicolon + if strings.Contains(addr, ":") { + return false + } + return true +} + +func ParseTimeout(tOut string) *int64 { + var v int64 + switch { + case strings.HasSuffix(tOut, "ms"): + v, _ = strconv.ParseInt(strings.TrimSuffix(tOut, "ms"), 10, 64) + case strings.HasSuffix(tOut, "s"): + v, _ = strconv.ParseInt(strings.TrimSuffix(tOut, "s"), 10, 64) + v *= 1000 + case strings.HasSuffix(tOut, "m"): + v, _ = strconv.ParseInt(strings.TrimSuffix(tOut, "m"), 10, 64) + v = v * 1000 * 60 + case strings.HasSuffix(tOut, "h"): + v, _ = strconv.ParseInt(strings.TrimSuffix(tOut, "h"), 10, 64) + v = v * 1000 * 60 * 60 + case strings.HasSuffix(tOut, "d"): + v, _ = strconv.ParseInt(strings.TrimSuffix(tOut, "d"), 10, 64) + v = v * 1000 * 60 * 60 * 24 + default: + v, _ = strconv.ParseInt(tOut, 10, 64) + } + if v != 0 { + return &v + } + return nil +} + +func GetHTTPStatusFromConfErr(err *configuration.ConfError) int { + switch err.Err() { + case configuration.ErrObjectDoesNotExist: + return http.StatusNotFound + case configuration.ErrObjectAlreadyExists: + return http.StatusConflict + case configuration.ErrNoParentSpecified: + return http.StatusBadRequest + default: + return http.StatusInternalServerError + } +} + +func GetHTTPStatusFromErr(err error) int { + confError := &configuration.ConfError{} + + switch { + case errors.As(err, &confError): + return GetHTTPStatusFromConfErr(confError) + case errors.Is(err, client_errors.ErrAlreadyExists): + return http.StatusConflict + case errors.Is(err, client_errors.ErrNotFound): + return http.StatusNotFound + case errors.Is(err, client_errors.ErrGeneral): + return http.StatusBadRequest + default: + return http.StatusInternalServerError + } +} + +func SetError(code int, msg string) *models.Error { + return &models.Error{ + Code: Int64P(code), + Message: StringP(msg), + } +} + +func StringP(s string) *string { + return &s +} + +func Int64P(i int) *int64 { + i64 := int64(i) + return &i64 +} + +func PtrTo[T any](v T) *T { + return &v +} + +// extractEnvVar extracts and returns env variable from HAProxy variable +// provided in "${SOME_VAR}" format +func ExtractEnvVar(pass string) string { + return strings.TrimLeft(strings.TrimRight(pass, "\"}"), "\"${") +} + +func HasOSArg(short, long, env string) bool { + if short == "" && long == "" && env == "" { + return false + } + target1 := "--" + long + hasShort := short != "" + target2 := "-" + short + + if env != "" { + if os.Getenv(env) != "" { + return true + } + } + for _, arg := range os.Args { + if hasShort && arg == target2 { + return true + } + if arg == target1 { + return true + } + if strings.HasPrefix(arg, target1) { + p := strings.Split(arg, "=") + if len(p) > 1 { + return true + } + } + } + return false +} + +func RandomString(size int) (string, error) { + str, err := randomString(size) + if err != nil { + return "", err + } + for len(str) < size { + str2, _ := randomString(size) + str += str2 + } + return str[:size], nil +} + +// randomString generates a random string of the recommended size. +// Result is not guaranteed to be correct length. +func randomString(recommendedSize int) (string, error) { + b := make([]byte, recommendedSize+8) + _, err := rand.Read(b) + result := strings.ReplaceAll(base64.URLEncoding.EncodeToString(b), `=`, ``) + result = strings.ReplaceAll(result, `-`, ``) + result = strings.ReplaceAll(result, `_`, ``) + return result, err +} + +func IsNetworkErr(err error) bool { + if err == nil { + return false + } + if _, ok := err.(net.Error); ok { + return true + } + return false +} + +func CreateClusterUser() (types.User, string, error) { + // create a new user for connecting to cluster + name, err := RandomString(8) + if err != nil { + return types.User{}, "", err + } + pwd, err := RandomString(24) + if err != nil { + return types.User{}, "", err + } + + cryptAlg := crypt.New(crypt.SHA512) + hash, err := cryptAlg.Generate([]byte(pwd), nil) + if err != nil { + return types.User{}, "", err + } + name = "dpapi-c-" + name + log.Infof("Creating user %s for cluster connection", name) + user := types.User{ + Name: name, + IsInsecure: false, + Password: hash, + } + return user, pwd, nil +} + +// ConvertStruct tries to convert a struct from one type to another. +func ConvertStruct[T1 any, T2 any](from T1, to T2) error { + json := jsoniter.ConfigCompatibleWithStandardLibrary + js, err := json.Marshal(from) + if err != nil { + return err + } + return json.Unmarshal(js, to) +} diff --git a/misc/misc_test.go b/misc/misc_test.go new file mode 100644 index 00000000..297c9522 --- /dev/null +++ b/misc/misc_test.go @@ -0,0 +1,34 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package misc + +import ( + "math/rand" + "testing" +) + +func TestRandomString(t *testing.T) { + for range 1024 { + size := rand.Intn(512) + str, err := RandomString(size) + if err != nil { + t.Errorf("RandomString returned an error for size %d: %v", size, err) + } + if len(str) != size { + t.Errorf("RandomString returned a string of length %d for size %d", len(str), size) + } + } +} diff --git a/operations/acl/create_acl.go b/operations/acl/create_acl.go deleted file mode 100644 index eed6d2f6..00000000 --- a/operations/acl/create_acl.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateACLHandlerFunc turns a function with the right signature into a create Acl handler -type CreateACLHandlerFunc func(CreateACLParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateACLHandlerFunc) Handle(params CreateACLParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateACLHandler interface for that can handle valid create Acl params -type CreateACLHandler interface { - Handle(CreateACLParams, interface{}) middleware.Responder -} - -// NewCreateACL creates a new http.Handler for the create Acl operation -func NewCreateACL(ctx *middleware.Context, handler CreateACLHandler) *CreateACL { - return &CreateACL{Context: ctx, Handler: handler} -} - -/*CreateACL swagger:route POST /services/haproxy/configuration/acls ACL createAcl - -Add a new ACL line - -Adds a new ACL line of the specified type in the specified parent. - -*/ -type CreateACL struct { - Context *middleware.Context - Handler CreateACLHandler -} - -func (o *CreateACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateACLParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/acl/create_acl_backend.go b/operations/acl/create_acl_backend.go new file mode 100644 index 00000000..ce52e01c --- /dev/null +++ b/operations/acl/create_acl_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateACLBackendHandlerFunc turns a function with the right signature into a create Acl backend handler +type CreateACLBackendHandlerFunc func(CreateACLBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateACLBackendHandlerFunc) Handle(params CreateACLBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateACLBackendHandler interface for that can handle valid create Acl backend params +type CreateACLBackendHandler interface { + Handle(CreateACLBackendParams, interface{}) middleware.Responder +} + +// NewCreateACLBackend creates a new http.Handler for the create Acl backend operation +func NewCreateACLBackend(ctx *middleware.Context, handler CreateACLBackendHandler) *CreateACLBackend { + return &CreateACLBackend{Context: ctx, Handler: handler} +} + +/* + CreateACLBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/acls/{index} ACL createAclBackend + +# Add a new ACL line + +Adds a new ACL line of the specified type in the specified parent. +*/ +type CreateACLBackend struct { + Context *middleware.Context + Handler CreateACLBackendHandler +} + +func (o *CreateACLBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateACLBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/create_acl_backend_parameters.go b/operations/acl/create_acl_backend_parameters.go new file mode 100644 index 00000000..4cc2c5db --- /dev/null +++ b/operations/acl/create_acl_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateACLBackendParams creates a new CreateACLBackendParams object +// with the default values initialized. +func NewCreateACLBackendParams() CreateACLBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateACLBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateACLBackendParams contains all the bound params for the create Acl backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createAclBackend +type CreateACLBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateACLBackendParams() beforehand. +func (o *CreateACLBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateACLBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateACLBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateACLBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateACLBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateACLBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateACLBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/create_acl_backend_responses.go b/operations/acl/create_acl_backend_responses.go new file mode 100644 index 00000000..9d924cd7 --- /dev/null +++ b/operations/acl/create_acl_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateACLBackendCreatedCode is the HTTP code returned for type CreateACLBackendCreated +const CreateACLBackendCreatedCode int = 201 + +/* +CreateACLBackendCreated ACL line created + +swagger:response createAclBackendCreated +*/ +type CreateACLBackendCreated struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLBackendCreated creates CreateACLBackendCreated with default headers values +func NewCreateACLBackendCreated() *CreateACLBackendCreated { + + return &CreateACLBackendCreated{} +} + +// WithPayload adds the payload to the create Acl backend created response +func (o *CreateACLBackendCreated) WithPayload(payload *models.ACL) *CreateACLBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl backend created response +func (o *CreateACLBackendCreated) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLBackendAcceptedCode is the HTTP code returned for type CreateACLBackendAccepted +const CreateACLBackendAcceptedCode int = 202 + +/* +CreateACLBackendAccepted Configuration change accepted and reload requested + +swagger:response createAclBackendAccepted +*/ +type CreateACLBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLBackendAccepted creates CreateACLBackendAccepted with default headers values +func NewCreateACLBackendAccepted() *CreateACLBackendAccepted { + + return &CreateACLBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Acl backend accepted response +func (o *CreateACLBackendAccepted) WithReloadID(reloadID string) *CreateACLBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Acl backend accepted response +func (o *CreateACLBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Acl backend accepted response +func (o *CreateACLBackendAccepted) WithPayload(payload *models.ACL) *CreateACLBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl backend accepted response +func (o *CreateACLBackendAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLBackendBadRequestCode is the HTTP code returned for type CreateACLBackendBadRequest +const CreateACLBackendBadRequestCode int = 400 + +/* +CreateACLBackendBadRequest Bad request + +swagger:response createAclBackendBadRequest +*/ +type CreateACLBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLBackendBadRequest creates CreateACLBackendBadRequest with default headers values +func NewCreateACLBackendBadRequest() *CreateACLBackendBadRequest { + + return &CreateACLBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl backend bad request response +func (o *CreateACLBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateACLBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl backend bad request response +func (o *CreateACLBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl backend bad request response +func (o *CreateACLBackendBadRequest) WithPayload(payload *models.Error) *CreateACLBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl backend bad request response +func (o *CreateACLBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLBackendConflictCode is the HTTP code returned for type CreateACLBackendConflict +const CreateACLBackendConflictCode int = 409 + +/* +CreateACLBackendConflict The specified resource already exists + +swagger:response createAclBackendConflict +*/ +type CreateACLBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLBackendConflict creates CreateACLBackendConflict with default headers values +func NewCreateACLBackendConflict() *CreateACLBackendConflict { + + return &CreateACLBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl backend conflict response +func (o *CreateACLBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateACLBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl backend conflict response +func (o *CreateACLBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl backend conflict response +func (o *CreateACLBackendConflict) WithPayload(payload *models.Error) *CreateACLBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl backend conflict response +func (o *CreateACLBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateACLBackendDefault General Error + +swagger:response createAclBackendDefault +*/ +type CreateACLBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLBackendDefault creates CreateACLBackendDefault with default headers values +func NewCreateACLBackendDefault(code int) *CreateACLBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateACLBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create Acl backend default response +func (o *CreateACLBackendDefault) WithStatusCode(code int) *CreateACLBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create Acl backend default response +func (o *CreateACLBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl backend default response +func (o *CreateACLBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateACLBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl backend default response +func (o *CreateACLBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl backend default response +func (o *CreateACLBackendDefault) WithPayload(payload *models.Error) *CreateACLBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl backend default response +func (o *CreateACLBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/create_acl_backend_urlbuilder.go b/operations/acl/create_acl_backend_urlbuilder.go new file mode 100644 index 00000000..6cfbe3e1 --- /dev/null +++ b/operations/acl/create_acl_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateACLBackendURL generates an URL for the create Acl backend operation +type CreateACLBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLBackendURL) WithBasePath(bp string) *CreateACLBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateACLBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateACLBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateACLBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateACLBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateACLBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateACLBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateACLBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateACLBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateACLBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/create_acl_defaults.go b/operations/acl/create_acl_defaults.go new file mode 100644 index 00000000..fa218d8a --- /dev/null +++ b/operations/acl/create_acl_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateACLDefaultsHandlerFunc turns a function with the right signature into a create Acl defaults handler +type CreateACLDefaultsHandlerFunc func(CreateACLDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateACLDefaultsHandlerFunc) Handle(params CreateACLDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateACLDefaultsHandler interface for that can handle valid create Acl defaults params +type CreateACLDefaultsHandler interface { + Handle(CreateACLDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateACLDefaults creates a new http.Handler for the create Acl defaults operation +func NewCreateACLDefaults(ctx *middleware.Context, handler CreateACLDefaultsHandler) *CreateACLDefaults { + return &CreateACLDefaults{Context: ctx, Handler: handler} +} + +/* + CreateACLDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/acls/{index} ACL createAclDefaults + +# Add a new ACL line + +Adds a new ACL line of the specified type in the specified parent. +*/ +type CreateACLDefaults struct { + Context *middleware.Context + Handler CreateACLDefaultsHandler +} + +func (o *CreateACLDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateACLDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/create_acl_defaults_parameters.go b/operations/acl/create_acl_defaults_parameters.go new file mode 100644 index 00000000..f1768048 --- /dev/null +++ b/operations/acl/create_acl_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateACLDefaultsParams creates a new CreateACLDefaultsParams object +// with the default values initialized. +func NewCreateACLDefaultsParams() CreateACLDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateACLDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateACLDefaultsParams contains all the bound params for the create Acl defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createAclDefaults +type CreateACLDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateACLDefaultsParams() beforehand. +func (o *CreateACLDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateACLDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateACLDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateACLDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateACLDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateACLDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateACLDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/create_acl_defaults_responses.go b/operations/acl/create_acl_defaults_responses.go new file mode 100644 index 00000000..db1ad6a2 --- /dev/null +++ b/operations/acl/create_acl_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateACLDefaultsCreatedCode is the HTTP code returned for type CreateACLDefaultsCreated +const CreateACLDefaultsCreatedCode int = 201 + +/* +CreateACLDefaultsCreated ACL line created + +swagger:response createAclDefaultsCreated +*/ +type CreateACLDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLDefaultsCreated creates CreateACLDefaultsCreated with default headers values +func NewCreateACLDefaultsCreated() *CreateACLDefaultsCreated { + + return &CreateACLDefaultsCreated{} +} + +// WithPayload adds the payload to the create Acl defaults created response +func (o *CreateACLDefaultsCreated) WithPayload(payload *models.ACL) *CreateACLDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl defaults created response +func (o *CreateACLDefaultsCreated) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLDefaultsAcceptedCode is the HTTP code returned for type CreateACLDefaultsAccepted +const CreateACLDefaultsAcceptedCode int = 202 + +/* +CreateACLDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createAclDefaultsAccepted +*/ +type CreateACLDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLDefaultsAccepted creates CreateACLDefaultsAccepted with default headers values +func NewCreateACLDefaultsAccepted() *CreateACLDefaultsAccepted { + + return &CreateACLDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Acl defaults accepted response +func (o *CreateACLDefaultsAccepted) WithReloadID(reloadID string) *CreateACLDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Acl defaults accepted response +func (o *CreateACLDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Acl defaults accepted response +func (o *CreateACLDefaultsAccepted) WithPayload(payload *models.ACL) *CreateACLDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl defaults accepted response +func (o *CreateACLDefaultsAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLDefaultsBadRequestCode is the HTTP code returned for type CreateACLDefaultsBadRequest +const CreateACLDefaultsBadRequestCode int = 400 + +/* +CreateACLDefaultsBadRequest Bad request + +swagger:response createAclDefaultsBadRequest +*/ +type CreateACLDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLDefaultsBadRequest creates CreateACLDefaultsBadRequest with default headers values +func NewCreateACLDefaultsBadRequest() *CreateACLDefaultsBadRequest { + + return &CreateACLDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl defaults bad request response +func (o *CreateACLDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateACLDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl defaults bad request response +func (o *CreateACLDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl defaults bad request response +func (o *CreateACLDefaultsBadRequest) WithPayload(payload *models.Error) *CreateACLDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl defaults bad request response +func (o *CreateACLDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLDefaultsConflictCode is the HTTP code returned for type CreateACLDefaultsConflict +const CreateACLDefaultsConflictCode int = 409 + +/* +CreateACLDefaultsConflict The specified resource already exists + +swagger:response createAclDefaultsConflict +*/ +type CreateACLDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLDefaultsConflict creates CreateACLDefaultsConflict with default headers values +func NewCreateACLDefaultsConflict() *CreateACLDefaultsConflict { + + return &CreateACLDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl defaults conflict response +func (o *CreateACLDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateACLDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl defaults conflict response +func (o *CreateACLDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl defaults conflict response +func (o *CreateACLDefaultsConflict) WithPayload(payload *models.Error) *CreateACLDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl defaults conflict response +func (o *CreateACLDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateACLDefaultsDefault General Error + +swagger:response createAclDefaultsDefault +*/ +type CreateACLDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLDefaultsDefault creates CreateACLDefaultsDefault with default headers values +func NewCreateACLDefaultsDefault(code int) *CreateACLDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateACLDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create Acl defaults default response +func (o *CreateACLDefaultsDefault) WithStatusCode(code int) *CreateACLDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create Acl defaults default response +func (o *CreateACLDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl defaults default response +func (o *CreateACLDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateACLDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl defaults default response +func (o *CreateACLDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl defaults default response +func (o *CreateACLDefaultsDefault) WithPayload(payload *models.Error) *CreateACLDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl defaults default response +func (o *CreateACLDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/create_acl_defaults_urlbuilder.go b/operations/acl/create_acl_defaults_urlbuilder.go new file mode 100644 index 00000000..89cc6e14 --- /dev/null +++ b/operations/acl/create_acl_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateACLDefaultsURL generates an URL for the create Acl defaults operation +type CreateACLDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLDefaultsURL) WithBasePath(bp string) *CreateACLDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateACLDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateACLDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateACLDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateACLDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateACLDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateACLDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateACLDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateACLDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateACLDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/create_acl_fcgi_app.go b/operations/acl/create_acl_fcgi_app.go new file mode 100644 index 00000000..694ad7f4 --- /dev/null +++ b/operations/acl/create_acl_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateACLFCGIAppHandlerFunc turns a function with the right signature into a create Acl FCGI app handler +type CreateACLFCGIAppHandlerFunc func(CreateACLFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateACLFCGIAppHandlerFunc) Handle(params CreateACLFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateACLFCGIAppHandler interface for that can handle valid create Acl FCGI app params +type CreateACLFCGIAppHandler interface { + Handle(CreateACLFCGIAppParams, interface{}) middleware.Responder +} + +// NewCreateACLFCGIApp creates a new http.Handler for the create Acl FCGI app operation +func NewCreateACLFCGIApp(ctx *middleware.Context, handler CreateACLFCGIAppHandler) *CreateACLFCGIApp { + return &CreateACLFCGIApp{Context: ctx, Handler: handler} +} + +/* + CreateACLFCGIApp swagger:route POST /services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index} ACL createAclFcgiApp + +# Add a new ACL line + +Adds a new ACL line of the specified type in the specified parent. +*/ +type CreateACLFCGIApp struct { + Context *middleware.Context + Handler CreateACLFCGIAppHandler +} + +func (o *CreateACLFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateACLFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/create_acl_fcgi_app_parameters.go b/operations/acl/create_acl_fcgi_app_parameters.go new file mode 100644 index 00000000..b4dc7d85 --- /dev/null +++ b/operations/acl/create_acl_fcgi_app_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateACLFCGIAppParams creates a new CreateACLFCGIAppParams object +// with the default values initialized. +func NewCreateACLFCGIAppParams() CreateACLFCGIAppParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateACLFCGIAppParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateACLFCGIAppParams contains all the bound params for the create Acl FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters createAclFCGIApp +type CreateACLFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateACLFCGIAppParams() beforehand. +func (o *CreateACLFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateACLFCGIAppParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateACLFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateACLFCGIAppParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateACLFCGIAppParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateACLFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateACLFCGIAppParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/create_acl_fcgi_app_responses.go b/operations/acl/create_acl_fcgi_app_responses.go new file mode 100644 index 00000000..1e7ed59d --- /dev/null +++ b/operations/acl/create_acl_fcgi_app_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateACLFCGIAppCreatedCode is the HTTP code returned for type CreateACLFCGIAppCreated +const CreateACLFCGIAppCreatedCode int = 201 + +/* +CreateACLFCGIAppCreated ACL line created + +swagger:response createAclFcgiAppCreated +*/ +type CreateACLFCGIAppCreated struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLFCGIAppCreated creates CreateACLFCGIAppCreated with default headers values +func NewCreateACLFCGIAppCreated() *CreateACLFCGIAppCreated { + + return &CreateACLFCGIAppCreated{} +} + +// WithPayload adds the payload to the create Acl Fcgi app created response +func (o *CreateACLFCGIAppCreated) WithPayload(payload *models.ACL) *CreateACLFCGIAppCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl Fcgi app created response +func (o *CreateACLFCGIAppCreated) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFCGIAppCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLFCGIAppAcceptedCode is the HTTP code returned for type CreateACLFCGIAppAccepted +const CreateACLFCGIAppAcceptedCode int = 202 + +/* +CreateACLFCGIAppAccepted Configuration change accepted and reload requested + +swagger:response createAclFcgiAppAccepted +*/ +type CreateACLFCGIAppAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLFCGIAppAccepted creates CreateACLFCGIAppAccepted with default headers values +func NewCreateACLFCGIAppAccepted() *CreateACLFCGIAppAccepted { + + return &CreateACLFCGIAppAccepted{} +} + +// WithReloadID adds the reloadId to the create Acl Fcgi app accepted response +func (o *CreateACLFCGIAppAccepted) WithReloadID(reloadID string) *CreateACLFCGIAppAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Acl Fcgi app accepted response +func (o *CreateACLFCGIAppAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Acl Fcgi app accepted response +func (o *CreateACLFCGIAppAccepted) WithPayload(payload *models.ACL) *CreateACLFCGIAppAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl Fcgi app accepted response +func (o *CreateACLFCGIAppAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFCGIAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLFCGIAppBadRequestCode is the HTTP code returned for type CreateACLFCGIAppBadRequest +const CreateACLFCGIAppBadRequestCode int = 400 + +/* +CreateACLFCGIAppBadRequest Bad request + +swagger:response createAclFcgiAppBadRequest +*/ +type CreateACLFCGIAppBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLFCGIAppBadRequest creates CreateACLFCGIAppBadRequest with default headers values +func NewCreateACLFCGIAppBadRequest() *CreateACLFCGIAppBadRequest { + + return &CreateACLFCGIAppBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl Fcgi app bad request response +func (o *CreateACLFCGIAppBadRequest) WithConfigurationVersion(configurationVersion string) *CreateACLFCGIAppBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl Fcgi app bad request response +func (o *CreateACLFCGIAppBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl Fcgi app bad request response +func (o *CreateACLFCGIAppBadRequest) WithPayload(payload *models.Error) *CreateACLFCGIAppBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl Fcgi app bad request response +func (o *CreateACLFCGIAppBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFCGIAppBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLFCGIAppConflictCode is the HTTP code returned for type CreateACLFCGIAppConflict +const CreateACLFCGIAppConflictCode int = 409 + +/* +CreateACLFCGIAppConflict The specified resource already exists + +swagger:response createAclFcgiAppConflict +*/ +type CreateACLFCGIAppConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLFCGIAppConflict creates CreateACLFCGIAppConflict with default headers values +func NewCreateACLFCGIAppConflict() *CreateACLFCGIAppConflict { + + return &CreateACLFCGIAppConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl Fcgi app conflict response +func (o *CreateACLFCGIAppConflict) WithConfigurationVersion(configurationVersion string) *CreateACLFCGIAppConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl Fcgi app conflict response +func (o *CreateACLFCGIAppConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl Fcgi app conflict response +func (o *CreateACLFCGIAppConflict) WithPayload(payload *models.Error) *CreateACLFCGIAppConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl Fcgi app conflict response +func (o *CreateACLFCGIAppConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFCGIAppConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateACLFCGIAppDefault General Error + +swagger:response createAclFcgiAppDefault +*/ +type CreateACLFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLFCGIAppDefault creates CreateACLFCGIAppDefault with default headers values +func NewCreateACLFCGIAppDefault(code int) *CreateACLFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &CreateACLFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create Acl FCGI app default response +func (o *CreateACLFCGIAppDefault) WithStatusCode(code int) *CreateACLFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create Acl FCGI app default response +func (o *CreateACLFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl FCGI app default response +func (o *CreateACLFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *CreateACLFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl FCGI app default response +func (o *CreateACLFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl FCGI app default response +func (o *CreateACLFCGIAppDefault) WithPayload(payload *models.Error) *CreateACLFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl FCGI app default response +func (o *CreateACLFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/create_acl_fcgi_app_urlbuilder.go b/operations/acl/create_acl_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..82209b87 --- /dev/null +++ b/operations/acl/create_acl_fcgi_app_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateACLFCGIAppURL generates an URL for the create Acl FCGI app operation +type CreateACLFCGIAppURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLFCGIAppURL) WithBasePath(bp string) *CreateACLFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateACLFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateACLFCGIAppURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateACLFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateACLFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateACLFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateACLFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateACLFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateACLFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateACLFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/create_acl_frontend.go b/operations/acl/create_acl_frontend.go new file mode 100644 index 00000000..1de8f32a --- /dev/null +++ b/operations/acl/create_acl_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateACLFrontendHandlerFunc turns a function with the right signature into a create Acl frontend handler +type CreateACLFrontendHandlerFunc func(CreateACLFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateACLFrontendHandlerFunc) Handle(params CreateACLFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateACLFrontendHandler interface for that can handle valid create Acl frontend params +type CreateACLFrontendHandler interface { + Handle(CreateACLFrontendParams, interface{}) middleware.Responder +} + +// NewCreateACLFrontend creates a new http.Handler for the create Acl frontend operation +func NewCreateACLFrontend(ctx *middleware.Context, handler CreateACLFrontendHandler) *CreateACLFrontend { + return &CreateACLFrontend{Context: ctx, Handler: handler} +} + +/* + CreateACLFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/acls/{index} ACL createAclFrontend + +# Add a new ACL line + +Adds a new ACL line of the specified type in the specified parent. +*/ +type CreateACLFrontend struct { + Context *middleware.Context + Handler CreateACLFrontendHandler +} + +func (o *CreateACLFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateACLFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/create_acl_frontend_parameters.go b/operations/acl/create_acl_frontend_parameters.go new file mode 100644 index 00000000..aad64edf --- /dev/null +++ b/operations/acl/create_acl_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateACLFrontendParams creates a new CreateACLFrontendParams object +// with the default values initialized. +func NewCreateACLFrontendParams() CreateACLFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateACLFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateACLFrontendParams contains all the bound params for the create Acl frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createAclFrontend +type CreateACLFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateACLFrontendParams() beforehand. +func (o *CreateACLFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateACLFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateACLFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateACLFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateACLFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateACLFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateACLFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/create_acl_frontend_responses.go b/operations/acl/create_acl_frontend_responses.go new file mode 100644 index 00000000..d646ace2 --- /dev/null +++ b/operations/acl/create_acl_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateACLFrontendCreatedCode is the HTTP code returned for type CreateACLFrontendCreated +const CreateACLFrontendCreatedCode int = 201 + +/* +CreateACLFrontendCreated ACL line created + +swagger:response createAclFrontendCreated +*/ +type CreateACLFrontendCreated struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLFrontendCreated creates CreateACLFrontendCreated with default headers values +func NewCreateACLFrontendCreated() *CreateACLFrontendCreated { + + return &CreateACLFrontendCreated{} +} + +// WithPayload adds the payload to the create Acl frontend created response +func (o *CreateACLFrontendCreated) WithPayload(payload *models.ACL) *CreateACLFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl frontend created response +func (o *CreateACLFrontendCreated) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLFrontendAcceptedCode is the HTTP code returned for type CreateACLFrontendAccepted +const CreateACLFrontendAcceptedCode int = 202 + +/* +CreateACLFrontendAccepted Configuration change accepted and reload requested + +swagger:response createAclFrontendAccepted +*/ +type CreateACLFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewCreateACLFrontendAccepted creates CreateACLFrontendAccepted with default headers values +func NewCreateACLFrontendAccepted() *CreateACLFrontendAccepted { + + return &CreateACLFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create Acl frontend accepted response +func (o *CreateACLFrontendAccepted) WithReloadID(reloadID string) *CreateACLFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Acl frontend accepted response +func (o *CreateACLFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Acl frontend accepted response +func (o *CreateACLFrontendAccepted) WithPayload(payload *models.ACL) *CreateACLFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl frontend accepted response +func (o *CreateACLFrontendAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLFrontendBadRequestCode is the HTTP code returned for type CreateACLFrontendBadRequest +const CreateACLFrontendBadRequestCode int = 400 + +/* +CreateACLFrontendBadRequest Bad request + +swagger:response createAclFrontendBadRequest +*/ +type CreateACLFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLFrontendBadRequest creates CreateACLFrontendBadRequest with default headers values +func NewCreateACLFrontendBadRequest() *CreateACLFrontendBadRequest { + + return &CreateACLFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl frontend bad request response +func (o *CreateACLFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateACLFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl frontend bad request response +func (o *CreateACLFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl frontend bad request response +func (o *CreateACLFrontendBadRequest) WithPayload(payload *models.Error) *CreateACLFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl frontend bad request response +func (o *CreateACLFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateACLFrontendConflictCode is the HTTP code returned for type CreateACLFrontendConflict +const CreateACLFrontendConflictCode int = 409 + +/* +CreateACLFrontendConflict The specified resource already exists + +swagger:response createAclFrontendConflict +*/ +type CreateACLFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLFrontendConflict creates CreateACLFrontendConflict with default headers values +func NewCreateACLFrontendConflict() *CreateACLFrontendConflict { + + return &CreateACLFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl frontend conflict response +func (o *CreateACLFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateACLFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl frontend conflict response +func (o *CreateACLFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl frontend conflict response +func (o *CreateACLFrontendConflict) WithPayload(payload *models.Error) *CreateACLFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl frontend conflict response +func (o *CreateACLFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateACLFrontendDefault General Error + +swagger:response createAclFrontendDefault +*/ +type CreateACLFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateACLFrontendDefault creates CreateACLFrontendDefault with default headers values +func NewCreateACLFrontendDefault(code int) *CreateACLFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateACLFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create Acl frontend default response +func (o *CreateACLFrontendDefault) WithStatusCode(code int) *CreateACLFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create Acl frontend default response +func (o *CreateACLFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create Acl frontend default response +func (o *CreateACLFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateACLFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Acl frontend default response +func (o *CreateACLFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Acl frontend default response +func (o *CreateACLFrontendDefault) WithPayload(payload *models.Error) *CreateACLFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Acl frontend default response +func (o *CreateACLFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateACLFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/create_acl_frontend_urlbuilder.go b/operations/acl/create_acl_frontend_urlbuilder.go new file mode 100644 index 00000000..579199fe --- /dev/null +++ b/operations/acl/create_acl_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateACLFrontendURL generates an URL for the create Acl frontend operation +type CreateACLFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLFrontendURL) WithBasePath(bp string) *CreateACLFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateACLFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateACLFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateACLFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateACLFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateACLFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateACLFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateACLFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateACLFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateACLFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateACLFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/create_acl_parameters.go b/operations/acl/create_acl_parameters.go deleted file mode 100644 index 87cb67b6..00000000 --- a/operations/acl/create_acl_parameters.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateACLParams creates a new CreateACLParams object -// with the default values initialized. -func NewCreateACLParams() CreateACLParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateACLParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateACLParams contains all the bound params for the create Acl operation -// typically these are obtained from a http.Request -// -// swagger:parameters createAcl -type CreateACLParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.ACL - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateACLParams() beforehand. -func (o *CreateACLParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.ACL - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateACLParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateACLParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *CreateACLParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *CreateACLParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *CreateACLParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateACLParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateACLParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/acl/create_acl_responses.go b/operations/acl/create_acl_responses.go deleted file mode 100644 index 0fd13e4b..00000000 --- a/operations/acl/create_acl_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateACLCreatedCode is the HTTP code returned for type CreateACLCreated -const CreateACLCreatedCode int = 201 - -/*CreateACLCreated ACL line created - -swagger:response createAclCreated -*/ -type CreateACLCreated struct { - - /* - In: Body - */ - Payload *models.ACL `json:"body,omitempty"` -} - -// NewCreateACLCreated creates CreateACLCreated with default headers values -func NewCreateACLCreated() *CreateACLCreated { - - return &CreateACLCreated{} -} - -// WithPayload adds the payload to the create Acl created response -func (o *CreateACLCreated) WithPayload(payload *models.ACL) *CreateACLCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Acl created response -func (o *CreateACLCreated) SetPayload(payload *models.ACL) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateACLCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateACLAcceptedCode is the HTTP code returned for type CreateACLAccepted -const CreateACLAcceptedCode int = 202 - -/*CreateACLAccepted Configuration change accepted and reload requested - -swagger:response createAclAccepted -*/ -type CreateACLAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.ACL `json:"body,omitempty"` -} - -// NewCreateACLAccepted creates CreateACLAccepted with default headers values -func NewCreateACLAccepted() *CreateACLAccepted { - - return &CreateACLAccepted{} -} - -// WithReloadID adds the reloadId to the create Acl accepted response -func (o *CreateACLAccepted) WithReloadID(reloadID string) *CreateACLAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create Acl accepted response -func (o *CreateACLAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create Acl accepted response -func (o *CreateACLAccepted) WithPayload(payload *models.ACL) *CreateACLAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Acl accepted response -func (o *CreateACLAccepted) SetPayload(payload *models.ACL) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateACLAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateACLBadRequestCode is the HTTP code returned for type CreateACLBadRequest -const CreateACLBadRequestCode int = 400 - -/*CreateACLBadRequest Bad request - -swagger:response createAclBadRequest -*/ -type CreateACLBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateACLBadRequest creates CreateACLBadRequest with default headers values -func NewCreateACLBadRequest() *CreateACLBadRequest { - - return &CreateACLBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Acl bad request response -func (o *CreateACLBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateACLBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Acl bad request response -func (o *CreateACLBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Acl bad request response -func (o *CreateACLBadRequest) WithPayload(payload *models.Error) *CreateACLBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Acl bad request response -func (o *CreateACLBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateACLBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateACLConflictCode is the HTTP code returned for type CreateACLConflict -const CreateACLConflictCode int = 409 - -/*CreateACLConflict The specified resource already exists - -swagger:response createAclConflict -*/ -type CreateACLConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateACLConflict creates CreateACLConflict with default headers values -func NewCreateACLConflict() *CreateACLConflict { - - return &CreateACLConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Acl conflict response -func (o *CreateACLConflict) WithConfigurationVersion(configurationVersion int64) *CreateACLConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Acl conflict response -func (o *CreateACLConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Acl conflict response -func (o *CreateACLConflict) WithPayload(payload *models.Error) *CreateACLConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Acl conflict response -func (o *CreateACLConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateACLConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateACLDefault General Error - -swagger:response createAclDefault -*/ -type CreateACLDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateACLDefault creates CreateACLDefault with default headers values -func NewCreateACLDefault(code int) *CreateACLDefault { - if code <= 0 { - code = 500 - } - - return &CreateACLDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create Acl default response -func (o *CreateACLDefault) WithStatusCode(code int) *CreateACLDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create Acl default response -func (o *CreateACLDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create Acl default response -func (o *CreateACLDefault) WithConfigurationVersion(configurationVersion int64) *CreateACLDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Acl default response -func (o *CreateACLDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Acl default response -func (o *CreateACLDefault) WithPayload(payload *models.Error) *CreateACLDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Acl default response -func (o *CreateACLDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateACLDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/acl/create_acl_urlbuilder.go b/operations/acl/create_acl_urlbuilder.go deleted file mode 100644 index acc1667f..00000000 --- a/operations/acl/create_acl_urlbuilder.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateACLURL generates an URL for the create Acl operation -type CreateACLURL struct { - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateACLURL) WithBasePath(bp string) *CreateACLURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateACLURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateACLURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/acls" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateACLURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateACLURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateACLURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateACLURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateACLURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateACLURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/acl/delete_acl.go b/operations/acl/delete_acl.go deleted file mode 100644 index 4b0b6b4d..00000000 --- a/operations/acl/delete_acl.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteACLHandlerFunc turns a function with the right signature into a delete Acl handler -type DeleteACLHandlerFunc func(DeleteACLParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteACLHandlerFunc) Handle(params DeleteACLParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteACLHandler interface for that can handle valid delete Acl params -type DeleteACLHandler interface { - Handle(DeleteACLParams, interface{}) middleware.Responder -} - -// NewDeleteACL creates a new http.Handler for the delete Acl operation -func NewDeleteACL(ctx *middleware.Context, handler DeleteACLHandler) *DeleteACL { - return &DeleteACL{Context: ctx, Handler: handler} -} - -/*DeleteACL swagger:route DELETE /services/haproxy/configuration/acls/{id} ACL deleteAcl - -Delete a ACL line - -Deletes a ACL line configuration by it's ID from the specified parent. - -*/ -type DeleteACL struct { - Context *middleware.Context - Handler DeleteACLHandler -} - -func (o *DeleteACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteACLParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/acl/delete_acl_backend.go b/operations/acl/delete_acl_backend.go new file mode 100644 index 00000000..daad1184 --- /dev/null +++ b/operations/acl/delete_acl_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteACLBackendHandlerFunc turns a function with the right signature into a delete Acl backend handler +type DeleteACLBackendHandlerFunc func(DeleteACLBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteACLBackendHandlerFunc) Handle(params DeleteACLBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteACLBackendHandler interface for that can handle valid delete Acl backend params +type DeleteACLBackendHandler interface { + Handle(DeleteACLBackendParams, interface{}) middleware.Responder +} + +// NewDeleteACLBackend creates a new http.Handler for the delete Acl backend operation +func NewDeleteACLBackend(ctx *middleware.Context, handler DeleteACLBackendHandler) *DeleteACLBackend { + return &DeleteACLBackend{Context: ctx, Handler: handler} +} + +/* + DeleteACLBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/acls/{index} ACL deleteAclBackend + +# Delete a ACL line + +Deletes a ACL line configuration by it's index from the specified parent. +*/ +type DeleteACLBackend struct { + Context *middleware.Context + Handler DeleteACLBackendHandler +} + +func (o *DeleteACLBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteACLBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/delete_acl_backend_parameters.go b/operations/acl/delete_acl_backend_parameters.go new file mode 100644 index 00000000..0227d37b --- /dev/null +++ b/operations/acl/delete_acl_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteACLBackendParams creates a new DeleteACLBackendParams object +// with the default values initialized. +func NewDeleteACLBackendParams() DeleteACLBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteACLBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteACLBackendParams contains all the bound params for the delete Acl backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteAclBackend +type DeleteACLBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteACLBackendParams() beforehand. +func (o *DeleteACLBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteACLBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteACLBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteACLBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteACLBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteACLBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteACLBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/delete_acl_backend_responses.go b/operations/acl/delete_acl_backend_responses.go new file mode 100644 index 00000000..1308a8ed --- /dev/null +++ b/operations/acl/delete_acl_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteACLBackendAcceptedCode is the HTTP code returned for type DeleteACLBackendAccepted +const DeleteACLBackendAcceptedCode int = 202 + +/* +DeleteACLBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteAclBackendAccepted +*/ +type DeleteACLBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteACLBackendAccepted creates DeleteACLBackendAccepted with default headers values +func NewDeleteACLBackendAccepted() *DeleteACLBackendAccepted { + + return &DeleteACLBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Acl backend accepted response +func (o *DeleteACLBackendAccepted) WithReloadID(reloadID string) *DeleteACLBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Acl backend accepted response +func (o *DeleteACLBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteACLBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteACLBackendNoContentCode is the HTTP code returned for type DeleteACLBackendNoContent +const DeleteACLBackendNoContentCode int = 204 + +/* +DeleteACLBackendNoContent ACL line deleted + +swagger:response deleteAclBackendNoContent +*/ +type DeleteACLBackendNoContent struct { +} + +// NewDeleteACLBackendNoContent creates DeleteACLBackendNoContent with default headers values +func NewDeleteACLBackendNoContent() *DeleteACLBackendNoContent { + + return &DeleteACLBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteACLBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteACLBackendNotFoundCode is the HTTP code returned for type DeleteACLBackendNotFound +const DeleteACLBackendNotFoundCode int = 404 + +/* +DeleteACLBackendNotFound The specified resource was not found + +swagger:response deleteAclBackendNotFound +*/ +type DeleteACLBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLBackendNotFound creates DeleteACLBackendNotFound with default headers values +func NewDeleteACLBackendNotFound() *DeleteACLBackendNotFound { + + return &DeleteACLBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl backend not found response +func (o *DeleteACLBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteACLBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl backend not found response +func (o *DeleteACLBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl backend not found response +func (o *DeleteACLBackendNotFound) WithPayload(payload *models.Error) *DeleteACLBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl backend not found response +func (o *DeleteACLBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteACLBackendDefault General Error + +swagger:response deleteAclBackendDefault +*/ +type DeleteACLBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLBackendDefault creates DeleteACLBackendDefault with default headers values +func NewDeleteACLBackendDefault(code int) *DeleteACLBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteACLBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete Acl backend default response +func (o *DeleteACLBackendDefault) WithStatusCode(code int) *DeleteACLBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete Acl backend default response +func (o *DeleteACLBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl backend default response +func (o *DeleteACLBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteACLBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl backend default response +func (o *DeleteACLBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl backend default response +func (o *DeleteACLBackendDefault) WithPayload(payload *models.Error) *DeleteACLBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl backend default response +func (o *DeleteACLBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/delete_acl_backend_urlbuilder.go b/operations/acl/delete_acl_backend_urlbuilder.go new file mode 100644 index 00000000..676b0b0d --- /dev/null +++ b/operations/acl/delete_acl_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteACLBackendURL generates an URL for the delete Acl backend operation +type DeleteACLBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLBackendURL) WithBasePath(bp string) *DeleteACLBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteACLBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteACLBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteACLBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteACLBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteACLBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteACLBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteACLBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteACLBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteACLBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/delete_acl_defaults.go b/operations/acl/delete_acl_defaults.go new file mode 100644 index 00000000..d560f37b --- /dev/null +++ b/operations/acl/delete_acl_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteACLDefaultsHandlerFunc turns a function with the right signature into a delete Acl defaults handler +type DeleteACLDefaultsHandlerFunc func(DeleteACLDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteACLDefaultsHandlerFunc) Handle(params DeleteACLDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteACLDefaultsHandler interface for that can handle valid delete Acl defaults params +type DeleteACLDefaultsHandler interface { + Handle(DeleteACLDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteACLDefaults creates a new http.Handler for the delete Acl defaults operation +func NewDeleteACLDefaults(ctx *middleware.Context, handler DeleteACLDefaultsHandler) *DeleteACLDefaults { + return &DeleteACLDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteACLDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/acls/{index} ACL deleteAclDefaults + +# Delete a ACL line + +Deletes a ACL line configuration by it's index from the specified parent. +*/ +type DeleteACLDefaults struct { + Context *middleware.Context + Handler DeleteACLDefaultsHandler +} + +func (o *DeleteACLDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteACLDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/delete_acl_defaults_parameters.go b/operations/acl/delete_acl_defaults_parameters.go new file mode 100644 index 00000000..8f069b4e --- /dev/null +++ b/operations/acl/delete_acl_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteACLDefaultsParams creates a new DeleteACLDefaultsParams object +// with the default values initialized. +func NewDeleteACLDefaultsParams() DeleteACLDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteACLDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteACLDefaultsParams contains all the bound params for the delete Acl defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteAclDefaults +type DeleteACLDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteACLDefaultsParams() beforehand. +func (o *DeleteACLDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteACLDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteACLDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteACLDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteACLDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteACLDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteACLDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/delete_acl_defaults_responses.go b/operations/acl/delete_acl_defaults_responses.go new file mode 100644 index 00000000..95f9c43d --- /dev/null +++ b/operations/acl/delete_acl_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteACLDefaultsAcceptedCode is the HTTP code returned for type DeleteACLDefaultsAccepted +const DeleteACLDefaultsAcceptedCode int = 202 + +/* +DeleteACLDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteAclDefaultsAccepted +*/ +type DeleteACLDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteACLDefaultsAccepted creates DeleteACLDefaultsAccepted with default headers values +func NewDeleteACLDefaultsAccepted() *DeleteACLDefaultsAccepted { + + return &DeleteACLDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Acl defaults accepted response +func (o *DeleteACLDefaultsAccepted) WithReloadID(reloadID string) *DeleteACLDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Acl defaults accepted response +func (o *DeleteACLDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteACLDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteACLDefaultsNoContentCode is the HTTP code returned for type DeleteACLDefaultsNoContent +const DeleteACLDefaultsNoContentCode int = 204 + +/* +DeleteACLDefaultsNoContent ACL line deleted + +swagger:response deleteAclDefaultsNoContent +*/ +type DeleteACLDefaultsNoContent struct { +} + +// NewDeleteACLDefaultsNoContent creates DeleteACLDefaultsNoContent with default headers values +func NewDeleteACLDefaultsNoContent() *DeleteACLDefaultsNoContent { + + return &DeleteACLDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteACLDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteACLDefaultsNotFoundCode is the HTTP code returned for type DeleteACLDefaultsNotFound +const DeleteACLDefaultsNotFoundCode int = 404 + +/* +DeleteACLDefaultsNotFound The specified resource was not found + +swagger:response deleteAclDefaultsNotFound +*/ +type DeleteACLDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLDefaultsNotFound creates DeleteACLDefaultsNotFound with default headers values +func NewDeleteACLDefaultsNotFound() *DeleteACLDefaultsNotFound { + + return &DeleteACLDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl defaults not found response +func (o *DeleteACLDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteACLDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl defaults not found response +func (o *DeleteACLDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl defaults not found response +func (o *DeleteACLDefaultsNotFound) WithPayload(payload *models.Error) *DeleteACLDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl defaults not found response +func (o *DeleteACLDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteACLDefaultsDefault General Error + +swagger:response deleteAclDefaultsDefault +*/ +type DeleteACLDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLDefaultsDefault creates DeleteACLDefaultsDefault with default headers values +func NewDeleteACLDefaultsDefault(code int) *DeleteACLDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteACLDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete Acl defaults default response +func (o *DeleteACLDefaultsDefault) WithStatusCode(code int) *DeleteACLDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete Acl defaults default response +func (o *DeleteACLDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl defaults default response +func (o *DeleteACLDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteACLDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl defaults default response +func (o *DeleteACLDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl defaults default response +func (o *DeleteACLDefaultsDefault) WithPayload(payload *models.Error) *DeleteACLDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl defaults default response +func (o *DeleteACLDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/delete_acl_defaults_urlbuilder.go b/operations/acl/delete_acl_defaults_urlbuilder.go new file mode 100644 index 00000000..6c5caecc --- /dev/null +++ b/operations/acl/delete_acl_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteACLDefaultsURL generates an URL for the delete Acl defaults operation +type DeleteACLDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLDefaultsURL) WithBasePath(bp string) *DeleteACLDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteACLDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteACLDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteACLDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteACLDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteACLDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteACLDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteACLDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteACLDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteACLDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/delete_acl_fcgi_app.go b/operations/acl/delete_acl_fcgi_app.go new file mode 100644 index 00000000..71837377 --- /dev/null +++ b/operations/acl/delete_acl_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteACLFCGIAppHandlerFunc turns a function with the right signature into a delete Acl FCGI app handler +type DeleteACLFCGIAppHandlerFunc func(DeleteACLFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteACLFCGIAppHandlerFunc) Handle(params DeleteACLFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteACLFCGIAppHandler interface for that can handle valid delete Acl FCGI app params +type DeleteACLFCGIAppHandler interface { + Handle(DeleteACLFCGIAppParams, interface{}) middleware.Responder +} + +// NewDeleteACLFCGIApp creates a new http.Handler for the delete Acl FCGI app operation +func NewDeleteACLFCGIApp(ctx *middleware.Context, handler DeleteACLFCGIAppHandler) *DeleteACLFCGIApp { + return &DeleteACLFCGIApp{Context: ctx, Handler: handler} +} + +/* + DeleteACLFCGIApp swagger:route DELETE /services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index} ACL deleteAclFcgiApp + +# Delete a ACL line + +Deletes a ACL line configuration by it's index from the specified parent. +*/ +type DeleteACLFCGIApp struct { + Context *middleware.Context + Handler DeleteACLFCGIAppHandler +} + +func (o *DeleteACLFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteACLFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/delete_acl_fcgi_app_parameters.go b/operations/acl/delete_acl_fcgi_app_parameters.go new file mode 100644 index 00000000..41120243 --- /dev/null +++ b/operations/acl/delete_acl_fcgi_app_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteACLFCGIAppParams creates a new DeleteACLFCGIAppParams object +// with the default values initialized. +func NewDeleteACLFCGIAppParams() DeleteACLFCGIAppParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteACLFCGIAppParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteACLFCGIAppParams contains all the bound params for the delete Acl FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteAclFCGIApp +type DeleteACLFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteACLFCGIAppParams() beforehand. +func (o *DeleteACLFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteACLFCGIAppParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteACLFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteACLFCGIAppParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteACLFCGIAppParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteACLFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteACLFCGIAppParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/delete_acl_fcgi_app_responses.go b/operations/acl/delete_acl_fcgi_app_responses.go new file mode 100644 index 00000000..a8d162ab --- /dev/null +++ b/operations/acl/delete_acl_fcgi_app_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteACLFCGIAppAcceptedCode is the HTTP code returned for type DeleteACLFCGIAppAccepted +const DeleteACLFCGIAppAcceptedCode int = 202 + +/* +DeleteACLFCGIAppAccepted Configuration change accepted and reload requested + +swagger:response deleteAclFcgiAppAccepted +*/ +type DeleteACLFCGIAppAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteACLFCGIAppAccepted creates DeleteACLFCGIAppAccepted with default headers values +func NewDeleteACLFCGIAppAccepted() *DeleteACLFCGIAppAccepted { + + return &DeleteACLFCGIAppAccepted{} +} + +// WithReloadID adds the reloadId to the delete Acl Fcgi app accepted response +func (o *DeleteACLFCGIAppAccepted) WithReloadID(reloadID string) *DeleteACLFCGIAppAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Acl Fcgi app accepted response +func (o *DeleteACLFCGIAppAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteACLFCGIAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteACLFCGIAppNoContentCode is the HTTP code returned for type DeleteACLFCGIAppNoContent +const DeleteACLFCGIAppNoContentCode int = 204 + +/* +DeleteACLFCGIAppNoContent ACL line deleted + +swagger:response deleteAclFcgiAppNoContent +*/ +type DeleteACLFCGIAppNoContent struct { +} + +// NewDeleteACLFCGIAppNoContent creates DeleteACLFCGIAppNoContent with default headers values +func NewDeleteACLFCGIAppNoContent() *DeleteACLFCGIAppNoContent { + + return &DeleteACLFCGIAppNoContent{} +} + +// WriteResponse to the client +func (o *DeleteACLFCGIAppNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteACLFCGIAppNotFoundCode is the HTTP code returned for type DeleteACLFCGIAppNotFound +const DeleteACLFCGIAppNotFoundCode int = 404 + +/* +DeleteACLFCGIAppNotFound The specified resource was not found + +swagger:response deleteAclFcgiAppNotFound +*/ +type DeleteACLFCGIAppNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLFCGIAppNotFound creates DeleteACLFCGIAppNotFound with default headers values +func NewDeleteACLFCGIAppNotFound() *DeleteACLFCGIAppNotFound { + + return &DeleteACLFCGIAppNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl Fcgi app not found response +func (o *DeleteACLFCGIAppNotFound) WithConfigurationVersion(configurationVersion string) *DeleteACLFCGIAppNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl Fcgi app not found response +func (o *DeleteACLFCGIAppNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl Fcgi app not found response +func (o *DeleteACLFCGIAppNotFound) WithPayload(payload *models.Error) *DeleteACLFCGIAppNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl Fcgi app not found response +func (o *DeleteACLFCGIAppNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLFCGIAppNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteACLFCGIAppDefault General Error + +swagger:response deleteAclFcgiAppDefault +*/ +type DeleteACLFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLFCGIAppDefault creates DeleteACLFCGIAppDefault with default headers values +func NewDeleteACLFCGIAppDefault(code int) *DeleteACLFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &DeleteACLFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete Acl FCGI app default response +func (o *DeleteACLFCGIAppDefault) WithStatusCode(code int) *DeleteACLFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete Acl FCGI app default response +func (o *DeleteACLFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl FCGI app default response +func (o *DeleteACLFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *DeleteACLFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl FCGI app default response +func (o *DeleteACLFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl FCGI app default response +func (o *DeleteACLFCGIAppDefault) WithPayload(payload *models.Error) *DeleteACLFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl FCGI app default response +func (o *DeleteACLFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/delete_acl_fcgi_app_urlbuilder.go b/operations/acl/delete_acl_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..e2685a93 --- /dev/null +++ b/operations/acl/delete_acl_fcgi_app_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteACLFCGIAppURL generates an URL for the delete Acl FCGI app operation +type DeleteACLFCGIAppURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLFCGIAppURL) WithBasePath(bp string) *DeleteACLFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteACLFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteACLFCGIAppURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteACLFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteACLFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteACLFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteACLFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteACLFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteACLFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteACLFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/delete_acl_frontend.go b/operations/acl/delete_acl_frontend.go new file mode 100644 index 00000000..d4e8eb96 --- /dev/null +++ b/operations/acl/delete_acl_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteACLFrontendHandlerFunc turns a function with the right signature into a delete Acl frontend handler +type DeleteACLFrontendHandlerFunc func(DeleteACLFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteACLFrontendHandlerFunc) Handle(params DeleteACLFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteACLFrontendHandler interface for that can handle valid delete Acl frontend params +type DeleteACLFrontendHandler interface { + Handle(DeleteACLFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteACLFrontend creates a new http.Handler for the delete Acl frontend operation +func NewDeleteACLFrontend(ctx *middleware.Context, handler DeleteACLFrontendHandler) *DeleteACLFrontend { + return &DeleteACLFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteACLFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/acls/{index} ACL deleteAclFrontend + +# Delete a ACL line + +Deletes a ACL line configuration by it's index from the specified parent. +*/ +type DeleteACLFrontend struct { + Context *middleware.Context + Handler DeleteACLFrontendHandler +} + +func (o *DeleteACLFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteACLFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/delete_acl_frontend_parameters.go b/operations/acl/delete_acl_frontend_parameters.go new file mode 100644 index 00000000..f05ad3d2 --- /dev/null +++ b/operations/acl/delete_acl_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteACLFrontendParams creates a new DeleteACLFrontendParams object +// with the default values initialized. +func NewDeleteACLFrontendParams() DeleteACLFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteACLFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteACLFrontendParams contains all the bound params for the delete Acl frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteAclFrontend +type DeleteACLFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteACLFrontendParams() beforehand. +func (o *DeleteACLFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteACLFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteACLFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteACLFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteACLFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteACLFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteACLFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/delete_acl_frontend_responses.go b/operations/acl/delete_acl_frontend_responses.go new file mode 100644 index 00000000..519f20e0 --- /dev/null +++ b/operations/acl/delete_acl_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteACLFrontendAcceptedCode is the HTTP code returned for type DeleteACLFrontendAccepted +const DeleteACLFrontendAcceptedCode int = 202 + +/* +DeleteACLFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteAclFrontendAccepted +*/ +type DeleteACLFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteACLFrontendAccepted creates DeleteACLFrontendAccepted with default headers values +func NewDeleteACLFrontendAccepted() *DeleteACLFrontendAccepted { + + return &DeleteACLFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Acl frontend accepted response +func (o *DeleteACLFrontendAccepted) WithReloadID(reloadID string) *DeleteACLFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Acl frontend accepted response +func (o *DeleteACLFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteACLFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteACLFrontendNoContentCode is the HTTP code returned for type DeleteACLFrontendNoContent +const DeleteACLFrontendNoContentCode int = 204 + +/* +DeleteACLFrontendNoContent ACL line deleted + +swagger:response deleteAclFrontendNoContent +*/ +type DeleteACLFrontendNoContent struct { +} + +// NewDeleteACLFrontendNoContent creates DeleteACLFrontendNoContent with default headers values +func NewDeleteACLFrontendNoContent() *DeleteACLFrontendNoContent { + + return &DeleteACLFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteACLFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteACLFrontendNotFoundCode is the HTTP code returned for type DeleteACLFrontendNotFound +const DeleteACLFrontendNotFoundCode int = 404 + +/* +DeleteACLFrontendNotFound The specified resource was not found + +swagger:response deleteAclFrontendNotFound +*/ +type DeleteACLFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLFrontendNotFound creates DeleteACLFrontendNotFound with default headers values +func NewDeleteACLFrontendNotFound() *DeleteACLFrontendNotFound { + + return &DeleteACLFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl frontend not found response +func (o *DeleteACLFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteACLFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl frontend not found response +func (o *DeleteACLFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl frontend not found response +func (o *DeleteACLFrontendNotFound) WithPayload(payload *models.Error) *DeleteACLFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl frontend not found response +func (o *DeleteACLFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteACLFrontendDefault General Error + +swagger:response deleteAclFrontendDefault +*/ +type DeleteACLFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteACLFrontendDefault creates DeleteACLFrontendDefault with default headers values +func NewDeleteACLFrontendDefault(code int) *DeleteACLFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteACLFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete Acl frontend default response +func (o *DeleteACLFrontendDefault) WithStatusCode(code int) *DeleteACLFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete Acl frontend default response +func (o *DeleteACLFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete Acl frontend default response +func (o *DeleteACLFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteACLFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Acl frontend default response +func (o *DeleteACLFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Acl frontend default response +func (o *DeleteACLFrontendDefault) WithPayload(payload *models.Error) *DeleteACLFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Acl frontend default response +func (o *DeleteACLFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteACLFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/delete_acl_frontend_urlbuilder.go b/operations/acl/delete_acl_frontend_urlbuilder.go new file mode 100644 index 00000000..7b83e866 --- /dev/null +++ b/operations/acl/delete_acl_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteACLFrontendURL generates an URL for the delete Acl frontend operation +type DeleteACLFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLFrontendURL) WithBasePath(bp string) *DeleteACLFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteACLFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteACLFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteACLFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteACLFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteACLFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteACLFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteACLFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteACLFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteACLFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteACLFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/delete_acl_parameters.go b/operations/acl/delete_acl_parameters.go deleted file mode 100644 index 66ce6b38..00000000 --- a/operations/acl/delete_acl_parameters.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteACLParams creates a new DeleteACLParams object -// with the default values initialized. -func NewDeleteACLParams() DeleteACLParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteACLParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteACLParams contains all the bound params for the delete Acl operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteAcl -type DeleteACLParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*ACL line ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteACLParams() beforehand. -func (o *DeleteACLParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteACLParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteACLParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *DeleteACLParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *DeleteACLParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *DeleteACLParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *DeleteACLParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteACLParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteACLParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/acl/delete_acl_responses.go b/operations/acl/delete_acl_responses.go deleted file mode 100644 index e4f248a6..00000000 --- a/operations/acl/delete_acl_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteACLAcceptedCode is the HTTP code returned for type DeleteACLAccepted -const DeleteACLAcceptedCode int = 202 - -/*DeleteACLAccepted Configuration change accepted and reload requested - -swagger:response deleteAclAccepted -*/ -type DeleteACLAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteACLAccepted creates DeleteACLAccepted with default headers values -func NewDeleteACLAccepted() *DeleteACLAccepted { - - return &DeleteACLAccepted{} -} - -// WithReloadID adds the reloadId to the delete Acl accepted response -func (o *DeleteACLAccepted) WithReloadID(reloadID string) *DeleteACLAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete Acl accepted response -func (o *DeleteACLAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteACLAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteACLNoContentCode is the HTTP code returned for type DeleteACLNoContent -const DeleteACLNoContentCode int = 204 - -/*DeleteACLNoContent ACL line deleted - -swagger:response deleteAclNoContent -*/ -type DeleteACLNoContent struct { -} - -// NewDeleteACLNoContent creates DeleteACLNoContent with default headers values -func NewDeleteACLNoContent() *DeleteACLNoContent { - - return &DeleteACLNoContent{} -} - -// WriteResponse to the client -func (o *DeleteACLNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteACLNotFoundCode is the HTTP code returned for type DeleteACLNotFound -const DeleteACLNotFoundCode int = 404 - -/*DeleteACLNotFound The specified resource was not found - -swagger:response deleteAclNotFound -*/ -type DeleteACLNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteACLNotFound creates DeleteACLNotFound with default headers values -func NewDeleteACLNotFound() *DeleteACLNotFound { - - return &DeleteACLNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete Acl not found response -func (o *DeleteACLNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteACLNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete Acl not found response -func (o *DeleteACLNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete Acl not found response -func (o *DeleteACLNotFound) WithPayload(payload *models.Error) *DeleteACLNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete Acl not found response -func (o *DeleteACLNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteACLNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteACLDefault General Error - -swagger:response deleteAclDefault -*/ -type DeleteACLDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteACLDefault creates DeleteACLDefault with default headers values -func NewDeleteACLDefault(code int) *DeleteACLDefault { - if code <= 0 { - code = 500 - } - - return &DeleteACLDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete Acl default response -func (o *DeleteACLDefault) WithStatusCode(code int) *DeleteACLDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete Acl default response -func (o *DeleteACLDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete Acl default response -func (o *DeleteACLDefault) WithConfigurationVersion(configurationVersion int64) *DeleteACLDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete Acl default response -func (o *DeleteACLDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete Acl default response -func (o *DeleteACLDefault) WithPayload(payload *models.Error) *DeleteACLDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete Acl default response -func (o *DeleteACLDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteACLDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/acl/delete_acl_urlbuilder.go b/operations/acl/delete_acl_urlbuilder.go deleted file mode 100644 index 382dd919..00000000 --- a/operations/acl/delete_acl_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteACLURL generates an URL for the delete Acl operation -type DeleteACLURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteACLURL) WithBasePath(bp string) *DeleteACLURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteACLURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteACLURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/acls/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on DeleteACLURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteACLURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteACLURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteACLURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteACLURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteACLURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteACLURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/acl/get_acl.go b/operations/acl/get_acl.go deleted file mode 100644 index a58c59b5..00000000 --- a/operations/acl/get_acl.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetACLHandlerFunc turns a function with the right signature into a get Acl handler -type GetACLHandlerFunc func(GetACLParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetACLHandlerFunc) Handle(params GetACLParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetACLHandler interface for that can handle valid get Acl params -type GetACLHandler interface { - Handle(GetACLParams, interface{}) middleware.Responder -} - -// NewGetACL creates a new http.Handler for the get Acl operation -func NewGetACL(ctx *middleware.Context, handler GetACLHandler) *GetACL { - return &GetACL{Context: ctx, Handler: handler} -} - -/*GetACL swagger:route GET /services/haproxy/configuration/acls/{id} ACL getAcl - -Return one ACL line - -Returns one ACL line configuration by it's ID in the specified parent. - -*/ -type GetACL struct { - Context *middleware.Context - Handler GetACLHandler -} - -func (o *GetACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetACLParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetACLOKBody get ACL o k body -// swagger:model GetACLOKBody -type GetACLOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.ACL `json:"data,omitempty"` -} - -// Validate validates this get ACL o k body -func (o *GetACLOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetACLOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getAclOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetACLOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetACLOKBody) UnmarshalBinary(b []byte) error { - var res GetACLOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/acl/get_acl_backend.go b/operations/acl/get_acl_backend.go new file mode 100644 index 00000000..a7bec7db --- /dev/null +++ b/operations/acl/get_acl_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetACLBackendHandlerFunc turns a function with the right signature into a get Acl backend handler +type GetACLBackendHandlerFunc func(GetACLBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetACLBackendHandlerFunc) Handle(params GetACLBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetACLBackendHandler interface for that can handle valid get Acl backend params +type GetACLBackendHandler interface { + Handle(GetACLBackendParams, interface{}) middleware.Responder +} + +// NewGetACLBackend creates a new http.Handler for the get Acl backend operation +func NewGetACLBackend(ctx *middleware.Context, handler GetACLBackendHandler) *GetACLBackend { + return &GetACLBackend{Context: ctx, Handler: handler} +} + +/* + GetACLBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/acls/{index} ACL getAclBackend + +# Return one ACL line + +Returns one ACL line configuration by it's index in the specified parent. +*/ +type GetACLBackend struct { + Context *middleware.Context + Handler GetACLBackendHandler +} + +func (o *GetACLBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetACLBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_acl_backend_parameters.go b/operations/acl/get_acl_backend_parameters.go new file mode 100644 index 00000000..34ac388e --- /dev/null +++ b/operations/acl/get_acl_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetACLBackendParams creates a new GetACLBackendParams object +// +// There are no default values defined in the spec. +func NewGetACLBackendParams() GetACLBackendParams { + + return GetACLBackendParams{} +} + +// GetACLBackendParams contains all the bound params for the get Acl backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAclBackend +type GetACLBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetACLBackendParams() beforehand. +func (o *GetACLBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetACLBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetACLBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetACLBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_acl_backend_responses.go b/operations/acl/get_acl_backend_responses.go new file mode 100644 index 00000000..8c495777 --- /dev/null +++ b/operations/acl/get_acl_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetACLBackendOKCode is the HTTP code returned for type GetACLBackendOK +const GetACLBackendOKCode int = 200 + +/* +GetACLBackendOK Successful operation + +swagger:response getAclBackendOK +*/ +type GetACLBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewGetACLBackendOK creates GetACLBackendOK with default headers values +func NewGetACLBackendOK() *GetACLBackendOK { + + return &GetACLBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl backend o k response +func (o *GetACLBackendOK) WithConfigurationVersion(configurationVersion string) *GetACLBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl backend o k response +func (o *GetACLBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl backend o k response +func (o *GetACLBackendOK) WithPayload(payload *models.ACL) *GetACLBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl backend o k response +func (o *GetACLBackendOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetACLBackendNotFoundCode is the HTTP code returned for type GetACLBackendNotFound +const GetACLBackendNotFoundCode int = 404 + +/* +GetACLBackendNotFound The specified resource was not found + +swagger:response getAclBackendNotFound +*/ +type GetACLBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLBackendNotFound creates GetACLBackendNotFound with default headers values +func NewGetACLBackendNotFound() *GetACLBackendNotFound { + + return &GetACLBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl backend not found response +func (o *GetACLBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetACLBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl backend not found response +func (o *GetACLBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl backend not found response +func (o *GetACLBackendNotFound) WithPayload(payload *models.Error) *GetACLBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl backend not found response +func (o *GetACLBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetACLBackendDefault General Error + +swagger:response getAclBackendDefault +*/ +type GetACLBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLBackendDefault creates GetACLBackendDefault with default headers values +func NewGetACLBackendDefault(code int) *GetACLBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetACLBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get Acl backend default response +func (o *GetACLBackendDefault) WithStatusCode(code int) *GetACLBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get Acl backend default response +func (o *GetACLBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl backend default response +func (o *GetACLBackendDefault) WithConfigurationVersion(configurationVersion string) *GetACLBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl backend default response +func (o *GetACLBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl backend default response +func (o *GetACLBackendDefault) WithPayload(payload *models.Error) *GetACLBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl backend default response +func (o *GetACLBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_acl_backend_urlbuilder.go b/operations/acl/get_acl_backend_urlbuilder.go new file mode 100644 index 00000000..c64b3e7a --- /dev/null +++ b/operations/acl/get_acl_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetACLBackendURL generates an URL for the get Acl backend operation +type GetACLBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLBackendURL) WithBasePath(bp string) *GetACLBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetACLBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetACLBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetACLBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetACLBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetACLBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetACLBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetACLBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetACLBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetACLBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/get_acl_defaults.go b/operations/acl/get_acl_defaults.go new file mode 100644 index 00000000..b46681ad --- /dev/null +++ b/operations/acl/get_acl_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetACLDefaultsHandlerFunc turns a function with the right signature into a get Acl defaults handler +type GetACLDefaultsHandlerFunc func(GetACLDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetACLDefaultsHandlerFunc) Handle(params GetACLDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetACLDefaultsHandler interface for that can handle valid get Acl defaults params +type GetACLDefaultsHandler interface { + Handle(GetACLDefaultsParams, interface{}) middleware.Responder +} + +// NewGetACLDefaults creates a new http.Handler for the get Acl defaults operation +func NewGetACLDefaults(ctx *middleware.Context, handler GetACLDefaultsHandler) *GetACLDefaults { + return &GetACLDefaults{Context: ctx, Handler: handler} +} + +/* + GetACLDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/acls/{index} ACL getAclDefaults + +# Return one ACL line + +Returns one ACL line configuration by it's index in the specified parent. +*/ +type GetACLDefaults struct { + Context *middleware.Context + Handler GetACLDefaultsHandler +} + +func (o *GetACLDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetACLDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_acl_defaults_parameters.go b/operations/acl/get_acl_defaults_parameters.go new file mode 100644 index 00000000..4a6cf33c --- /dev/null +++ b/operations/acl/get_acl_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetACLDefaultsParams creates a new GetACLDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetACLDefaultsParams() GetACLDefaultsParams { + + return GetACLDefaultsParams{} +} + +// GetACLDefaultsParams contains all the bound params for the get Acl defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAclDefaults +type GetACLDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetACLDefaultsParams() beforehand. +func (o *GetACLDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetACLDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetACLDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetACLDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_acl_defaults_responses.go b/operations/acl/get_acl_defaults_responses.go new file mode 100644 index 00000000..670f3a21 --- /dev/null +++ b/operations/acl/get_acl_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetACLDefaultsOKCode is the HTTP code returned for type GetACLDefaultsOK +const GetACLDefaultsOKCode int = 200 + +/* +GetACLDefaultsOK Successful operation + +swagger:response getAclDefaultsOK +*/ +type GetACLDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewGetACLDefaultsOK creates GetACLDefaultsOK with default headers values +func NewGetACLDefaultsOK() *GetACLDefaultsOK { + + return &GetACLDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl defaults o k response +func (o *GetACLDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetACLDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl defaults o k response +func (o *GetACLDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl defaults o k response +func (o *GetACLDefaultsOK) WithPayload(payload *models.ACL) *GetACLDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl defaults o k response +func (o *GetACLDefaultsOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetACLDefaultsNotFoundCode is the HTTP code returned for type GetACLDefaultsNotFound +const GetACLDefaultsNotFoundCode int = 404 + +/* +GetACLDefaultsNotFound The specified resource was not found + +swagger:response getAclDefaultsNotFound +*/ +type GetACLDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLDefaultsNotFound creates GetACLDefaultsNotFound with default headers values +func NewGetACLDefaultsNotFound() *GetACLDefaultsNotFound { + + return &GetACLDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl defaults not found response +func (o *GetACLDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetACLDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl defaults not found response +func (o *GetACLDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl defaults not found response +func (o *GetACLDefaultsNotFound) WithPayload(payload *models.Error) *GetACLDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl defaults not found response +func (o *GetACLDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetACLDefaultsDefault General Error + +swagger:response getAclDefaultsDefault +*/ +type GetACLDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLDefaultsDefault creates GetACLDefaultsDefault with default headers values +func NewGetACLDefaultsDefault(code int) *GetACLDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetACLDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get Acl defaults default response +func (o *GetACLDefaultsDefault) WithStatusCode(code int) *GetACLDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get Acl defaults default response +func (o *GetACLDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl defaults default response +func (o *GetACLDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetACLDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl defaults default response +func (o *GetACLDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl defaults default response +func (o *GetACLDefaultsDefault) WithPayload(payload *models.Error) *GetACLDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl defaults default response +func (o *GetACLDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_acl_defaults_urlbuilder.go b/operations/acl/get_acl_defaults_urlbuilder.go new file mode 100644 index 00000000..1269c31d --- /dev/null +++ b/operations/acl/get_acl_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetACLDefaultsURL generates an URL for the get Acl defaults operation +type GetACLDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLDefaultsURL) WithBasePath(bp string) *GetACLDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetACLDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetACLDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetACLDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetACLDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetACLDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetACLDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetACLDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetACLDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetACLDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/get_acl_fcgi_app.go b/operations/acl/get_acl_fcgi_app.go new file mode 100644 index 00000000..27f75b76 --- /dev/null +++ b/operations/acl/get_acl_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetACLFCGIAppHandlerFunc turns a function with the right signature into a get Acl FCGI app handler +type GetACLFCGIAppHandlerFunc func(GetACLFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetACLFCGIAppHandlerFunc) Handle(params GetACLFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetACLFCGIAppHandler interface for that can handle valid get Acl FCGI app params +type GetACLFCGIAppHandler interface { + Handle(GetACLFCGIAppParams, interface{}) middleware.Responder +} + +// NewGetACLFCGIApp creates a new http.Handler for the get Acl FCGI app operation +func NewGetACLFCGIApp(ctx *middleware.Context, handler GetACLFCGIAppHandler) *GetACLFCGIApp { + return &GetACLFCGIApp{Context: ctx, Handler: handler} +} + +/* + GetACLFCGIApp swagger:route GET /services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index} ACL getAclFcgiApp + +# Return one ACL line + +Returns one ACL line configuration by it's index in the specified parent. +*/ +type GetACLFCGIApp struct { + Context *middleware.Context + Handler GetACLFCGIAppHandler +} + +func (o *GetACLFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetACLFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_acl_fcgi_app_parameters.go b/operations/acl/get_acl_fcgi_app_parameters.go new file mode 100644 index 00000000..ce5ab160 --- /dev/null +++ b/operations/acl/get_acl_fcgi_app_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetACLFCGIAppParams creates a new GetACLFCGIAppParams object +// +// There are no default values defined in the spec. +func NewGetACLFCGIAppParams() GetACLFCGIAppParams { + + return GetACLFCGIAppParams{} +} + +// GetACLFCGIAppParams contains all the bound params for the get Acl FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAclFCGIApp +type GetACLFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetACLFCGIAppParams() beforehand. +func (o *GetACLFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetACLFCGIAppParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetACLFCGIAppParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetACLFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_acl_fcgi_app_responses.go b/operations/acl/get_acl_fcgi_app_responses.go new file mode 100644 index 00000000..d6898f96 --- /dev/null +++ b/operations/acl/get_acl_fcgi_app_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetACLFCGIAppOKCode is the HTTP code returned for type GetACLFCGIAppOK +const GetACLFCGIAppOKCode int = 200 + +/* +GetACLFCGIAppOK Successful operation + +swagger:response getAclFcgiAppOK +*/ +type GetACLFCGIAppOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewGetACLFCGIAppOK creates GetACLFCGIAppOK with default headers values +func NewGetACLFCGIAppOK() *GetACLFCGIAppOK { + + return &GetACLFCGIAppOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl Fcgi app o k response +func (o *GetACLFCGIAppOK) WithConfigurationVersion(configurationVersion string) *GetACLFCGIAppOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl Fcgi app o k response +func (o *GetACLFCGIAppOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl Fcgi app o k response +func (o *GetACLFCGIAppOK) WithPayload(payload *models.ACL) *GetACLFCGIAppOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl Fcgi app o k response +func (o *GetACLFCGIAppOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLFCGIAppOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetACLFCGIAppNotFoundCode is the HTTP code returned for type GetACLFCGIAppNotFound +const GetACLFCGIAppNotFoundCode int = 404 + +/* +GetACLFCGIAppNotFound The specified resource was not found + +swagger:response getAclFcgiAppNotFound +*/ +type GetACLFCGIAppNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLFCGIAppNotFound creates GetACLFCGIAppNotFound with default headers values +func NewGetACLFCGIAppNotFound() *GetACLFCGIAppNotFound { + + return &GetACLFCGIAppNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl Fcgi app not found response +func (o *GetACLFCGIAppNotFound) WithConfigurationVersion(configurationVersion string) *GetACLFCGIAppNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl Fcgi app not found response +func (o *GetACLFCGIAppNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl Fcgi app not found response +func (o *GetACLFCGIAppNotFound) WithPayload(payload *models.Error) *GetACLFCGIAppNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl Fcgi app not found response +func (o *GetACLFCGIAppNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLFCGIAppNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetACLFCGIAppDefault General Error + +swagger:response getAclFcgiAppDefault +*/ +type GetACLFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLFCGIAppDefault creates GetACLFCGIAppDefault with default headers values +func NewGetACLFCGIAppDefault(code int) *GetACLFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &GetACLFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get Acl FCGI app default response +func (o *GetACLFCGIAppDefault) WithStatusCode(code int) *GetACLFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get Acl FCGI app default response +func (o *GetACLFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl FCGI app default response +func (o *GetACLFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *GetACLFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl FCGI app default response +func (o *GetACLFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl FCGI app default response +func (o *GetACLFCGIAppDefault) WithPayload(payload *models.Error) *GetACLFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl FCGI app default response +func (o *GetACLFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_acl_fcgi_app_urlbuilder.go b/operations/acl/get_acl_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..3bfd1473 --- /dev/null +++ b/operations/acl/get_acl_fcgi_app_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetACLFCGIAppURL generates an URL for the get Acl FCGI app operation +type GetACLFCGIAppURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLFCGIAppURL) WithBasePath(bp string) *GetACLFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetACLFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetACLFCGIAppURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetACLFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetACLFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetACLFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetACLFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetACLFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetACLFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetACLFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/get_acl_frontend.go b/operations/acl/get_acl_frontend.go new file mode 100644 index 00000000..6b27e1de --- /dev/null +++ b/operations/acl/get_acl_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetACLFrontendHandlerFunc turns a function with the right signature into a get Acl frontend handler +type GetACLFrontendHandlerFunc func(GetACLFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetACLFrontendHandlerFunc) Handle(params GetACLFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetACLFrontendHandler interface for that can handle valid get Acl frontend params +type GetACLFrontendHandler interface { + Handle(GetACLFrontendParams, interface{}) middleware.Responder +} + +// NewGetACLFrontend creates a new http.Handler for the get Acl frontend operation +func NewGetACLFrontend(ctx *middleware.Context, handler GetACLFrontendHandler) *GetACLFrontend { + return &GetACLFrontend{Context: ctx, Handler: handler} +} + +/* + GetACLFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/acls/{index} ACL getAclFrontend + +# Return one ACL line + +Returns one ACL line configuration by it's index in the specified parent. +*/ +type GetACLFrontend struct { + Context *middleware.Context + Handler GetACLFrontendHandler +} + +func (o *GetACLFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetACLFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_acl_frontend_parameters.go b/operations/acl/get_acl_frontend_parameters.go new file mode 100644 index 00000000..1c850bdd --- /dev/null +++ b/operations/acl/get_acl_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetACLFrontendParams creates a new GetACLFrontendParams object +// +// There are no default values defined in the spec. +func NewGetACLFrontendParams() GetACLFrontendParams { + + return GetACLFrontendParams{} +} + +// GetACLFrontendParams contains all the bound params for the get Acl frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAclFrontend +type GetACLFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetACLFrontendParams() beforehand. +func (o *GetACLFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetACLFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetACLFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetACLFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_acl_frontend_responses.go b/operations/acl/get_acl_frontend_responses.go new file mode 100644 index 00000000..bbd1bad4 --- /dev/null +++ b/operations/acl/get_acl_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetACLFrontendOKCode is the HTTP code returned for type GetACLFrontendOK +const GetACLFrontendOKCode int = 200 + +/* +GetACLFrontendOK Successful operation + +swagger:response getAclFrontendOK +*/ +type GetACLFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewGetACLFrontendOK creates GetACLFrontendOK with default headers values +func NewGetACLFrontendOK() *GetACLFrontendOK { + + return &GetACLFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl frontend o k response +func (o *GetACLFrontendOK) WithConfigurationVersion(configurationVersion string) *GetACLFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl frontend o k response +func (o *GetACLFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl frontend o k response +func (o *GetACLFrontendOK) WithPayload(payload *models.ACL) *GetACLFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl frontend o k response +func (o *GetACLFrontendOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetACLFrontendNotFoundCode is the HTTP code returned for type GetACLFrontendNotFound +const GetACLFrontendNotFoundCode int = 404 + +/* +GetACLFrontendNotFound The specified resource was not found + +swagger:response getAclFrontendNotFound +*/ +type GetACLFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLFrontendNotFound creates GetACLFrontendNotFound with default headers values +func NewGetACLFrontendNotFound() *GetACLFrontendNotFound { + + return &GetACLFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl frontend not found response +func (o *GetACLFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetACLFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl frontend not found response +func (o *GetACLFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl frontend not found response +func (o *GetACLFrontendNotFound) WithPayload(payload *models.Error) *GetACLFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl frontend not found response +func (o *GetACLFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetACLFrontendDefault General Error + +swagger:response getAclFrontendDefault +*/ +type GetACLFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetACLFrontendDefault creates GetACLFrontendDefault with default headers values +func NewGetACLFrontendDefault(code int) *GetACLFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetACLFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get Acl frontend default response +func (o *GetACLFrontendDefault) WithStatusCode(code int) *GetACLFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get Acl frontend default response +func (o *GetACLFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get Acl frontend default response +func (o *GetACLFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetACLFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Acl frontend default response +func (o *GetACLFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Acl frontend default response +func (o *GetACLFrontendDefault) WithPayload(payload *models.Error) *GetACLFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Acl frontend default response +func (o *GetACLFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetACLFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_acl_frontend_urlbuilder.go b/operations/acl/get_acl_frontend_urlbuilder.go new file mode 100644 index 00000000..7c4abab1 --- /dev/null +++ b/operations/acl/get_acl_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetACLFrontendURL generates an URL for the get Acl frontend operation +type GetACLFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLFrontendURL) WithBasePath(bp string) *GetACLFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetACLFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetACLFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetACLFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetACLFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetACLFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetACLFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetACLFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetACLFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetACLFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetACLFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/get_acl_parameters.go b/operations/acl/get_acl_parameters.go deleted file mode 100644 index 74832585..00000000 --- a/operations/acl/get_acl_parameters.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetACLParams creates a new GetACLParams object -// no default values defined in spec. -func NewGetACLParams() GetACLParams { - - return GetACLParams{} -} - -// GetACLParams contains all the bound params for the get Acl operation -// typically these are obtained from a http.Request -// -// swagger:parameters getAcl -type GetACLParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*ACL line ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetACLParams() beforehand. -func (o *GetACLParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *GetACLParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetACLParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetACLParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetACLParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetACLParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/acl/get_acl_responses.go b/operations/acl/get_acl_responses.go deleted file mode 100644 index 09870ba6..00000000 --- a/operations/acl/get_acl_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetACLOKCode is the HTTP code returned for type GetACLOK -const GetACLOKCode int = 200 - -/*GetACLOK Successful operation - -swagger:response getAclOK -*/ -type GetACLOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetACLOKBody `json:"body,omitempty"` -} - -// NewGetACLOK creates GetACLOK with default headers values -func NewGetACLOK() *GetACLOK { - - return &GetACLOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Acl o k response -func (o *GetACLOK) WithConfigurationVersion(configurationVersion int64) *GetACLOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Acl o k response -func (o *GetACLOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Acl o k response -func (o *GetACLOK) WithPayload(payload *GetACLOKBody) *GetACLOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Acl o k response -func (o *GetACLOK) SetPayload(payload *GetACLOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetACLOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetACLNotFoundCode is the HTTP code returned for type GetACLNotFound -const GetACLNotFoundCode int = 404 - -/*GetACLNotFound The specified resource was not found - -swagger:response getAclNotFound -*/ -type GetACLNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetACLNotFound creates GetACLNotFound with default headers values -func NewGetACLNotFound() *GetACLNotFound { - - return &GetACLNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Acl not found response -func (o *GetACLNotFound) WithConfigurationVersion(configurationVersion int64) *GetACLNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Acl not found response -func (o *GetACLNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Acl not found response -func (o *GetACLNotFound) WithPayload(payload *models.Error) *GetACLNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Acl not found response -func (o *GetACLNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetACLNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetACLDefault General Error - -swagger:response getAclDefault -*/ -type GetACLDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetACLDefault creates GetACLDefault with default headers values -func NewGetACLDefault(code int) *GetACLDefault { - if code <= 0 { - code = 500 - } - - return &GetACLDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get Acl default response -func (o *GetACLDefault) WithStatusCode(code int) *GetACLDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get Acl default response -func (o *GetACLDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get Acl default response -func (o *GetACLDefault) WithConfigurationVersion(configurationVersion int64) *GetACLDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Acl default response -func (o *GetACLDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Acl default response -func (o *GetACLDefault) WithPayload(payload *models.Error) *GetACLDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Acl default response -func (o *GetACLDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetACLDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/acl/get_acl_urlbuilder.go b/operations/acl/get_acl_urlbuilder.go deleted file mode 100644 index 9dbb42f7..00000000 --- a/operations/acl/get_acl_urlbuilder.go +++ /dev/null @@ -1,142 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// GetACLURL generates an URL for the get Acl operation -type GetACLURL struct { - ID int64 - - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetACLURL) WithBasePath(bp string) *GetACLURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetACLURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetACLURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/acls/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on GetACLURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetACLURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetACLURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetACLURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetACLURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetACLURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetACLURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/acl/get_acls.go b/operations/acl/get_acls.go deleted file mode 100644 index 5ddf6ded..00000000 --- a/operations/acl/get_acls.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetAclsHandlerFunc turns a function with the right signature into a get acls handler -type GetAclsHandlerFunc func(GetAclsParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetAclsHandlerFunc) Handle(params GetAclsParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetAclsHandler interface for that can handle valid get acls params -type GetAclsHandler interface { - Handle(GetAclsParams, interface{}) middleware.Responder -} - -// NewGetAcls creates a new http.Handler for the get acls operation -func NewGetAcls(ctx *middleware.Context, handler GetAclsHandler) *GetAcls { - return &GetAcls{Context: ctx, Handler: handler} -} - -/*GetAcls swagger:route GET /services/haproxy/configuration/acls ACL getAcls - -Return an array of all ACL lines - -Returns all ACL lines that are configured in specified parent. - -*/ -type GetAcls struct { - Context *middleware.Context - Handler GetAclsHandler -} - -func (o *GetAcls) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetAclsParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetAclsOKBody get acls o k body -// swagger:model GetAclsOKBody -type GetAclsOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.Acls `json:"data"` -} - -// Validate validates this get acls o k body -func (o *GetAclsOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetAclsOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getAclsOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getAclsOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetAclsOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetAclsOKBody) UnmarshalBinary(b []byte) error { - var res GetAclsOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/acl/get_acls_parameters.go b/operations/acl/get_acls_parameters.go deleted file mode 100644 index c01c03a7..00000000 --- a/operations/acl/get_acls_parameters.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetAclsParams creates a new GetAclsParams object -// no default values defined in spec. -func NewGetAclsParams() GetAclsParams { - - return GetAclsParams{} -} - -// GetAclsParams contains all the bound params for the get acls operation -// typically these are obtained from a http.Request -// -// swagger:parameters getAcls -type GetAclsParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetAclsParams() beforehand. -func (o *GetAclsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetAclsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetAclsParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetAclsParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetAclsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/acl/get_acls_responses.go b/operations/acl/get_acls_responses.go deleted file mode 100644 index 57e969d4..00000000 --- a/operations/acl/get_acls_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetAclsOKCode is the HTTP code returned for type GetAclsOK -const GetAclsOKCode int = 200 - -/*GetAclsOK Successful operation - -swagger:response getAclsOK -*/ -type GetAclsOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetAclsOKBody `json:"body,omitempty"` -} - -// NewGetAclsOK creates GetAclsOK with default headers values -func NewGetAclsOK() *GetAclsOK { - - return &GetAclsOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get acls o k response -func (o *GetAclsOK) WithConfigurationVersion(configurationVersion int64) *GetAclsOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get acls o k response -func (o *GetAclsOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get acls o k response -func (o *GetAclsOK) WithPayload(payload *GetAclsOKBody) *GetAclsOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get acls o k response -func (o *GetAclsOK) SetPayload(payload *GetAclsOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetAclsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetAclsDefault General Error - -swagger:response getAclsDefault -*/ -type GetAclsDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetAclsDefault creates GetAclsDefault with default headers values -func NewGetAclsDefault(code int) *GetAclsDefault { - if code <= 0 { - code = 500 - } - - return &GetAclsDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get acls default response -func (o *GetAclsDefault) WithStatusCode(code int) *GetAclsDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get acls default response -func (o *GetAclsDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get acls default response -func (o *GetAclsDefault) WithConfigurationVersion(configurationVersion int64) *GetAclsDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get acls default response -func (o *GetAclsDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get acls default response -func (o *GetAclsDefault) WithPayload(payload *models.Error) *GetAclsDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get acls default response -func (o *GetAclsDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetAclsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/acl/get_acls_urlbuilder.go b/operations/acl/get_acls_urlbuilder.go deleted file mode 100644 index 6a5937ff..00000000 --- a/operations/acl/get_acls_urlbuilder.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetAclsURL generates an URL for the get acls operation -type GetAclsURL struct { - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetAclsURL) WithBasePath(bp string) *GetAclsURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetAclsURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetAclsURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/acls" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetAclsURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetAclsURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetAclsURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetAclsURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetAclsURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetAclsURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/acl/get_all_acl_backend.go b/operations/acl/get_all_acl_backend.go new file mode 100644 index 00000000..6faeb27d --- /dev/null +++ b/operations/acl/get_all_acl_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllACLBackendHandlerFunc turns a function with the right signature into a get all Acl backend handler +type GetAllACLBackendHandlerFunc func(GetAllACLBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllACLBackendHandlerFunc) Handle(params GetAllACLBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllACLBackendHandler interface for that can handle valid get all Acl backend params +type GetAllACLBackendHandler interface { + Handle(GetAllACLBackendParams, interface{}) middleware.Responder +} + +// NewGetAllACLBackend creates a new http.Handler for the get all Acl backend operation +func NewGetAllACLBackend(ctx *middleware.Context, handler GetAllACLBackendHandler) *GetAllACLBackend { + return &GetAllACLBackend{Context: ctx, Handler: handler} +} + +/* + GetAllACLBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/acls ACL getAllAclBackend + +# Return an array of all ACL lines + +Returns all ACL lines that are configured in specified parent. +*/ +type GetAllACLBackend struct { + Context *middleware.Context + Handler GetAllACLBackendHandler +} + +func (o *GetAllACLBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllACLBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_all_acl_backend_parameters.go b/operations/acl/get_all_acl_backend_parameters.go new file mode 100644 index 00000000..afe3db8f --- /dev/null +++ b/operations/acl/get_all_acl_backend_parameters.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllACLBackendParams creates a new GetAllACLBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllACLBackendParams() GetAllACLBackendParams { + + return GetAllACLBackendParams{} +} + +// GetAllACLBackendParams contains all the bound params for the get all Acl backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllAclBackend +type GetAllACLBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL name + In: query + */ + ACLName *string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllACLBackendParams() beforehand. +func (o *GetAllACLBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qACLName, qhkACLName, _ := qs.GetOK("acl_name") + if err := o.bindACLName(qACLName, qhkACLName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindACLName binds and validates parameter ACLName from query. +func (o *GetAllACLBackendParams) bindACLName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.ACLName = &raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllACLBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllACLBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_all_acl_backend_responses.go b/operations/acl/get_all_acl_backend_responses.go new file mode 100644 index 00000000..2d1d9251 --- /dev/null +++ b/operations/acl/get_all_acl_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllACLBackendOKCode is the HTTP code returned for type GetAllACLBackendOK +const GetAllACLBackendOKCode int = 200 + +/* +GetAllACLBackendOK Successful operation + +swagger:response getAllAclBackendOK +*/ +type GetAllACLBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewGetAllACLBackendOK creates GetAllACLBackendOK with default headers values +func NewGetAllACLBackendOK() *GetAllACLBackendOK { + + return &GetAllACLBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl backend o k response +func (o *GetAllACLBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllACLBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl backend o k response +func (o *GetAllACLBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl backend o k response +func (o *GetAllACLBackendOK) WithPayload(payload models.Acls) *GetAllACLBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl backend o k response +func (o *GetAllACLBackendOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllACLBackendDefault General Error + +swagger:response getAllAclBackendDefault +*/ +type GetAllACLBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllACLBackendDefault creates GetAllACLBackendDefault with default headers values +func NewGetAllACLBackendDefault(code int) *GetAllACLBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllACLBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all Acl backend default response +func (o *GetAllACLBackendDefault) WithStatusCode(code int) *GetAllACLBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all Acl backend default response +func (o *GetAllACLBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl backend default response +func (o *GetAllACLBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllACLBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl backend default response +func (o *GetAllACLBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl backend default response +func (o *GetAllACLBackendDefault) WithPayload(payload *models.Error) *GetAllACLBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl backend default response +func (o *GetAllACLBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_all_acl_backend_urlbuilder.go b/operations/acl/get_all_acl_backend_urlbuilder.go new file mode 100644 index 00000000..a3bf1698 --- /dev/null +++ b/operations/acl/get_all_acl_backend_urlbuilder.go @@ -0,0 +1,137 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllACLBackendURL generates an URL for the get all Acl backend operation +type GetAllACLBackendURL struct { + ParentName string + + ACLName *string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLBackendURL) WithBasePath(bp string) *GetAllACLBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllACLBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllACLBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var aCLNameQ string + if o.ACLName != nil { + aCLNameQ = *o.ACLName + } + if aCLNameQ != "" { + qs.Set("acl_name", aCLNameQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllACLBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllACLBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllACLBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllACLBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllACLBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllACLBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/get_all_acl_defaults.go b/operations/acl/get_all_acl_defaults.go new file mode 100644 index 00000000..dfa70f3a --- /dev/null +++ b/operations/acl/get_all_acl_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllACLDefaultsHandlerFunc turns a function with the right signature into a get all Acl defaults handler +type GetAllACLDefaultsHandlerFunc func(GetAllACLDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllACLDefaultsHandlerFunc) Handle(params GetAllACLDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllACLDefaultsHandler interface for that can handle valid get all Acl defaults params +type GetAllACLDefaultsHandler interface { + Handle(GetAllACLDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllACLDefaults creates a new http.Handler for the get all Acl defaults operation +func NewGetAllACLDefaults(ctx *middleware.Context, handler GetAllACLDefaultsHandler) *GetAllACLDefaults { + return &GetAllACLDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllACLDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/acls ACL getAllAclDefaults + +# Return an array of all ACL lines + +Returns all ACL lines that are configured in specified parent. +*/ +type GetAllACLDefaults struct { + Context *middleware.Context + Handler GetAllACLDefaultsHandler +} + +func (o *GetAllACLDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllACLDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_all_acl_defaults_parameters.go b/operations/acl/get_all_acl_defaults_parameters.go new file mode 100644 index 00000000..b1c06a7b --- /dev/null +++ b/operations/acl/get_all_acl_defaults_parameters.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllACLDefaultsParams creates a new GetAllACLDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllACLDefaultsParams() GetAllACLDefaultsParams { + + return GetAllACLDefaultsParams{} +} + +// GetAllACLDefaultsParams contains all the bound params for the get all Acl defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllAclDefaults +type GetAllACLDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL name + In: query + */ + ACLName *string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllACLDefaultsParams() beforehand. +func (o *GetAllACLDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qACLName, qhkACLName, _ := qs.GetOK("acl_name") + if err := o.bindACLName(qACLName, qhkACLName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindACLName binds and validates parameter ACLName from query. +func (o *GetAllACLDefaultsParams) bindACLName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.ACLName = &raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllACLDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllACLDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_all_acl_defaults_responses.go b/operations/acl/get_all_acl_defaults_responses.go new file mode 100644 index 00000000..aee7dd69 --- /dev/null +++ b/operations/acl/get_all_acl_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllACLDefaultsOKCode is the HTTP code returned for type GetAllACLDefaultsOK +const GetAllACLDefaultsOKCode int = 200 + +/* +GetAllACLDefaultsOK Successful operation + +swagger:response getAllAclDefaultsOK +*/ +type GetAllACLDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewGetAllACLDefaultsOK creates GetAllACLDefaultsOK with default headers values +func NewGetAllACLDefaultsOK() *GetAllACLDefaultsOK { + + return &GetAllACLDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl defaults o k response +func (o *GetAllACLDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllACLDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl defaults o k response +func (o *GetAllACLDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl defaults o k response +func (o *GetAllACLDefaultsOK) WithPayload(payload models.Acls) *GetAllACLDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl defaults o k response +func (o *GetAllACLDefaultsOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllACLDefaultsDefault General Error + +swagger:response getAllAclDefaultsDefault +*/ +type GetAllACLDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllACLDefaultsDefault creates GetAllACLDefaultsDefault with default headers values +func NewGetAllACLDefaultsDefault(code int) *GetAllACLDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllACLDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all Acl defaults default response +func (o *GetAllACLDefaultsDefault) WithStatusCode(code int) *GetAllACLDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all Acl defaults default response +func (o *GetAllACLDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl defaults default response +func (o *GetAllACLDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllACLDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl defaults default response +func (o *GetAllACLDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl defaults default response +func (o *GetAllACLDefaultsDefault) WithPayload(payload *models.Error) *GetAllACLDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl defaults default response +func (o *GetAllACLDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_all_acl_defaults_urlbuilder.go b/operations/acl/get_all_acl_defaults_urlbuilder.go new file mode 100644 index 00000000..d1a2eba8 --- /dev/null +++ b/operations/acl/get_all_acl_defaults_urlbuilder.go @@ -0,0 +1,137 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllACLDefaultsURL generates an URL for the get all Acl defaults operation +type GetAllACLDefaultsURL struct { + ParentName string + + ACLName *string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLDefaultsURL) WithBasePath(bp string) *GetAllACLDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllACLDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllACLDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var aCLNameQ string + if o.ACLName != nil { + aCLNameQ = *o.ACLName + } + if aCLNameQ != "" { + qs.Set("acl_name", aCLNameQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllACLDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllACLDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllACLDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllACLDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllACLDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllACLDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/get_all_acl_fcgi_app.go b/operations/acl/get_all_acl_fcgi_app.go new file mode 100644 index 00000000..45c7d98a --- /dev/null +++ b/operations/acl/get_all_acl_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllACLFCGIAppHandlerFunc turns a function with the right signature into a get all Acl FCGI app handler +type GetAllACLFCGIAppHandlerFunc func(GetAllACLFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllACLFCGIAppHandlerFunc) Handle(params GetAllACLFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllACLFCGIAppHandler interface for that can handle valid get all Acl FCGI app params +type GetAllACLFCGIAppHandler interface { + Handle(GetAllACLFCGIAppParams, interface{}) middleware.Responder +} + +// NewGetAllACLFCGIApp creates a new http.Handler for the get all Acl FCGI app operation +func NewGetAllACLFCGIApp(ctx *middleware.Context, handler GetAllACLFCGIAppHandler) *GetAllACLFCGIApp { + return &GetAllACLFCGIApp{Context: ctx, Handler: handler} +} + +/* + GetAllACLFCGIApp swagger:route GET /services/haproxy/configuration/fcgi_apps/{parent_name}/acls ACL getAllAclFcgiApp + +# Return an array of all ACL lines + +Returns all ACL lines that are configured in specified parent. +*/ +type GetAllACLFCGIApp struct { + Context *middleware.Context + Handler GetAllACLFCGIAppHandler +} + +func (o *GetAllACLFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllACLFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_all_acl_fcgi_app_parameters.go b/operations/acl/get_all_acl_fcgi_app_parameters.go new file mode 100644 index 00000000..16e39a18 --- /dev/null +++ b/operations/acl/get_all_acl_fcgi_app_parameters.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllACLFCGIAppParams creates a new GetAllACLFCGIAppParams object +// +// There are no default values defined in the spec. +func NewGetAllACLFCGIAppParams() GetAllACLFCGIAppParams { + + return GetAllACLFCGIAppParams{} +} + +// GetAllACLFCGIAppParams contains all the bound params for the get all Acl FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllAclFCGIApp +type GetAllACLFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL name + In: query + */ + ACLName *string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllACLFCGIAppParams() beforehand. +func (o *GetAllACLFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qACLName, qhkACLName, _ := qs.GetOK("acl_name") + if err := o.bindACLName(qACLName, qhkACLName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindACLName binds and validates parameter ACLName from query. +func (o *GetAllACLFCGIAppParams) bindACLName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.ACLName = &raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllACLFCGIAppParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllACLFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_all_acl_fcgi_app_responses.go b/operations/acl/get_all_acl_fcgi_app_responses.go new file mode 100644 index 00000000..0463500d --- /dev/null +++ b/operations/acl/get_all_acl_fcgi_app_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllACLFCGIAppOKCode is the HTTP code returned for type GetAllACLFCGIAppOK +const GetAllACLFCGIAppOKCode int = 200 + +/* +GetAllACLFCGIAppOK Successful operation + +swagger:response getAllAclFcgiAppOK +*/ +type GetAllACLFCGIAppOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewGetAllACLFCGIAppOK creates GetAllACLFCGIAppOK with default headers values +func NewGetAllACLFCGIAppOK() *GetAllACLFCGIAppOK { + + return &GetAllACLFCGIAppOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl Fcgi app o k response +func (o *GetAllACLFCGIAppOK) WithConfigurationVersion(configurationVersion string) *GetAllACLFCGIAppOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl Fcgi app o k response +func (o *GetAllACLFCGIAppOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl Fcgi app o k response +func (o *GetAllACLFCGIAppOK) WithPayload(payload models.Acls) *GetAllACLFCGIAppOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl Fcgi app o k response +func (o *GetAllACLFCGIAppOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLFCGIAppOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllACLFCGIAppDefault General Error + +swagger:response getAllAclFcgiAppDefault +*/ +type GetAllACLFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllACLFCGIAppDefault creates GetAllACLFCGIAppDefault with default headers values +func NewGetAllACLFCGIAppDefault(code int) *GetAllACLFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &GetAllACLFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all Acl FCGI app default response +func (o *GetAllACLFCGIAppDefault) WithStatusCode(code int) *GetAllACLFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all Acl FCGI app default response +func (o *GetAllACLFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl FCGI app default response +func (o *GetAllACLFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *GetAllACLFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl FCGI app default response +func (o *GetAllACLFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl FCGI app default response +func (o *GetAllACLFCGIAppDefault) WithPayload(payload *models.Error) *GetAllACLFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl FCGI app default response +func (o *GetAllACLFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_all_acl_fcgi_app_urlbuilder.go b/operations/acl/get_all_acl_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..2ab15370 --- /dev/null +++ b/operations/acl/get_all_acl_fcgi_app_urlbuilder.go @@ -0,0 +1,137 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllACLFCGIAppURL generates an URL for the get all Acl FCGI app operation +type GetAllACLFCGIAppURL struct { + ParentName string + + ACLName *string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLFCGIAppURL) WithBasePath(bp string) *GetAllACLFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllACLFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllACLFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var aCLNameQ string + if o.ACLName != nil { + aCLNameQ = *o.ACLName + } + if aCLNameQ != "" { + qs.Set("acl_name", aCLNameQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllACLFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllACLFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllACLFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllACLFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllACLFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllACLFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/get_all_acl_frontend.go b/operations/acl/get_all_acl_frontend.go new file mode 100644 index 00000000..8a1010bd --- /dev/null +++ b/operations/acl/get_all_acl_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllACLFrontendHandlerFunc turns a function with the right signature into a get all Acl frontend handler +type GetAllACLFrontendHandlerFunc func(GetAllACLFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllACLFrontendHandlerFunc) Handle(params GetAllACLFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllACLFrontendHandler interface for that can handle valid get all Acl frontend params +type GetAllACLFrontendHandler interface { + Handle(GetAllACLFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllACLFrontend creates a new http.Handler for the get all Acl frontend operation +func NewGetAllACLFrontend(ctx *middleware.Context, handler GetAllACLFrontendHandler) *GetAllACLFrontend { + return &GetAllACLFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllACLFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/acls ACL getAllAclFrontend + +# Return an array of all ACL lines + +Returns all ACL lines that are configured in specified parent. +*/ +type GetAllACLFrontend struct { + Context *middleware.Context + Handler GetAllACLFrontendHandler +} + +func (o *GetAllACLFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllACLFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/get_all_acl_frontend_parameters.go b/operations/acl/get_all_acl_frontend_parameters.go new file mode 100644 index 00000000..d3f51e84 --- /dev/null +++ b/operations/acl/get_all_acl_frontend_parameters.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllACLFrontendParams creates a new GetAllACLFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllACLFrontendParams() GetAllACLFrontendParams { + + return GetAllACLFrontendParams{} +} + +// GetAllACLFrontendParams contains all the bound params for the get all Acl frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllAclFrontend +type GetAllACLFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL name + In: query + */ + ACLName *string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllACLFrontendParams() beforehand. +func (o *GetAllACLFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qACLName, qhkACLName, _ := qs.GetOK("acl_name") + if err := o.bindACLName(qACLName, qhkACLName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindACLName binds and validates parameter ACLName from query. +func (o *GetAllACLFrontendParams) bindACLName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.ACLName = &raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllACLFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllACLFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acl/get_all_acl_frontend_responses.go b/operations/acl/get_all_acl_frontend_responses.go new file mode 100644 index 00000000..a60ee50a --- /dev/null +++ b/operations/acl/get_all_acl_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllACLFrontendOKCode is the HTTP code returned for type GetAllACLFrontendOK +const GetAllACLFrontendOKCode int = 200 + +/* +GetAllACLFrontendOK Successful operation + +swagger:response getAllAclFrontendOK +*/ +type GetAllACLFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewGetAllACLFrontendOK creates GetAllACLFrontendOK with default headers values +func NewGetAllACLFrontendOK() *GetAllACLFrontendOK { + + return &GetAllACLFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl frontend o k response +func (o *GetAllACLFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllACLFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl frontend o k response +func (o *GetAllACLFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl frontend o k response +func (o *GetAllACLFrontendOK) WithPayload(payload models.Acls) *GetAllACLFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl frontend o k response +func (o *GetAllACLFrontendOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllACLFrontendDefault General Error + +swagger:response getAllAclFrontendDefault +*/ +type GetAllACLFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllACLFrontendDefault creates GetAllACLFrontendDefault with default headers values +func NewGetAllACLFrontendDefault(code int) *GetAllACLFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllACLFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all Acl frontend default response +func (o *GetAllACLFrontendDefault) WithStatusCode(code int) *GetAllACLFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all Acl frontend default response +func (o *GetAllACLFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all Acl frontend default response +func (o *GetAllACLFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllACLFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Acl frontend default response +func (o *GetAllACLFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Acl frontend default response +func (o *GetAllACLFrontendDefault) WithPayload(payload *models.Error) *GetAllACLFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Acl frontend default response +func (o *GetAllACLFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllACLFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/get_all_acl_frontend_urlbuilder.go b/operations/acl/get_all_acl_frontend_urlbuilder.go new file mode 100644 index 00000000..db85701d --- /dev/null +++ b/operations/acl/get_all_acl_frontend_urlbuilder.go @@ -0,0 +1,137 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllACLFrontendURL generates an URL for the get all Acl frontend operation +type GetAllACLFrontendURL struct { + ParentName string + + ACLName *string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLFrontendURL) WithBasePath(bp string) *GetAllACLFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllACLFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllACLFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllACLFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var aCLNameQ string + if o.ACLName != nil { + aCLNameQ = *o.ACLName + } + if aCLNameQ != "" { + qs.Set("acl_name", aCLNameQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllACLFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllACLFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllACLFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllACLFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllACLFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllACLFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_acl.go b/operations/acl/replace_acl.go deleted file mode 100644 index 3c384e27..00000000 --- a/operations/acl/replace_acl.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceACLHandlerFunc turns a function with the right signature into a replace Acl handler -type ReplaceACLHandlerFunc func(ReplaceACLParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceACLHandlerFunc) Handle(params ReplaceACLParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceACLHandler interface for that can handle valid replace Acl params -type ReplaceACLHandler interface { - Handle(ReplaceACLParams, interface{}) middleware.Responder -} - -// NewReplaceACL creates a new http.Handler for the replace Acl operation -func NewReplaceACL(ctx *middleware.Context, handler ReplaceACLHandler) *ReplaceACL { - return &ReplaceACL{Context: ctx, Handler: handler} -} - -/*ReplaceACL swagger:route PUT /services/haproxy/configuration/acls/{id} ACL replaceAcl - -Replace a ACL line - -Replaces a ACL line configuration by it's ID in the specified parent. - -*/ -type ReplaceACL struct { - Context *middleware.Context - Handler ReplaceACLHandler -} - -func (o *ReplaceACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceACLParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/acl/replace_acl_backend.go b/operations/acl/replace_acl_backend.go new file mode 100644 index 00000000..bcb260ee --- /dev/null +++ b/operations/acl/replace_acl_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceACLBackendHandlerFunc turns a function with the right signature into a replace Acl backend handler +type ReplaceACLBackendHandlerFunc func(ReplaceACLBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceACLBackendHandlerFunc) Handle(params ReplaceACLBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceACLBackendHandler interface for that can handle valid replace Acl backend params +type ReplaceACLBackendHandler interface { + Handle(ReplaceACLBackendParams, interface{}) middleware.Responder +} + +// NewReplaceACLBackend creates a new http.Handler for the replace Acl backend operation +func NewReplaceACLBackend(ctx *middleware.Context, handler ReplaceACLBackendHandler) *ReplaceACLBackend { + return &ReplaceACLBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceACLBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/acls/{index} ACL replaceAclBackend + +# Replace a ACL line + +Replaces a ACL line configuration by it's index in the specified parent. +*/ +type ReplaceACLBackend struct { + Context *middleware.Context + Handler ReplaceACLBackendHandler +} + +func (o *ReplaceACLBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceACLBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_acl_backend_parameters.go b/operations/acl/replace_acl_backend_parameters.go new file mode 100644 index 00000000..b0c54444 --- /dev/null +++ b/operations/acl/replace_acl_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceACLBackendParams creates a new ReplaceACLBackendParams object +// with the default values initialized. +func NewReplaceACLBackendParams() ReplaceACLBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceACLBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceACLBackendParams contains all the bound params for the replace Acl backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAclBackend +type ReplaceACLBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceACLBackendParams() beforehand. +func (o *ReplaceACLBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceACLBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceACLBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceACLBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceACLBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceACLBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceACLBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_acl_backend_responses.go b/operations/acl/replace_acl_backend_responses.go new file mode 100644 index 00000000..d05cdcea --- /dev/null +++ b/operations/acl/replace_acl_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceACLBackendOKCode is the HTTP code returned for type ReplaceACLBackendOK +const ReplaceACLBackendOKCode int = 200 + +/* +ReplaceACLBackendOK ACL line replaced + +swagger:response replaceAclBackendOK +*/ +type ReplaceACLBackendOK struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLBackendOK creates ReplaceACLBackendOK with default headers values +func NewReplaceACLBackendOK() *ReplaceACLBackendOK { + + return &ReplaceACLBackendOK{} +} + +// WithPayload adds the payload to the replace Acl backend o k response +func (o *ReplaceACLBackendOK) WithPayload(payload *models.ACL) *ReplaceACLBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl backend o k response +func (o *ReplaceACLBackendOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLBackendAcceptedCode is the HTTP code returned for type ReplaceACLBackendAccepted +const ReplaceACLBackendAcceptedCode int = 202 + +/* +ReplaceACLBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAclBackendAccepted +*/ +type ReplaceACLBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLBackendAccepted creates ReplaceACLBackendAccepted with default headers values +func NewReplaceACLBackendAccepted() *ReplaceACLBackendAccepted { + + return &ReplaceACLBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Acl backend accepted response +func (o *ReplaceACLBackendAccepted) WithReloadID(reloadID string) *ReplaceACLBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Acl backend accepted response +func (o *ReplaceACLBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Acl backend accepted response +func (o *ReplaceACLBackendAccepted) WithPayload(payload *models.ACL) *ReplaceACLBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl backend accepted response +func (o *ReplaceACLBackendAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLBackendBadRequestCode is the HTTP code returned for type ReplaceACLBackendBadRequest +const ReplaceACLBackendBadRequestCode int = 400 + +/* +ReplaceACLBackendBadRequest Bad request + +swagger:response replaceAclBackendBadRequest +*/ +type ReplaceACLBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLBackendBadRequest creates ReplaceACLBackendBadRequest with default headers values +func NewReplaceACLBackendBadRequest() *ReplaceACLBackendBadRequest { + + return &ReplaceACLBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl backend bad request response +func (o *ReplaceACLBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceACLBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl backend bad request response +func (o *ReplaceACLBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl backend bad request response +func (o *ReplaceACLBackendBadRequest) WithPayload(payload *models.Error) *ReplaceACLBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl backend bad request response +func (o *ReplaceACLBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLBackendNotFoundCode is the HTTP code returned for type ReplaceACLBackendNotFound +const ReplaceACLBackendNotFoundCode int = 404 + +/* +ReplaceACLBackendNotFound The specified resource was not found + +swagger:response replaceAclBackendNotFound +*/ +type ReplaceACLBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLBackendNotFound creates ReplaceACLBackendNotFound with default headers values +func NewReplaceACLBackendNotFound() *ReplaceACLBackendNotFound { + + return &ReplaceACLBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl backend not found response +func (o *ReplaceACLBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceACLBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl backend not found response +func (o *ReplaceACLBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl backend not found response +func (o *ReplaceACLBackendNotFound) WithPayload(payload *models.Error) *ReplaceACLBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl backend not found response +func (o *ReplaceACLBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceACLBackendDefault General Error + +swagger:response replaceAclBackendDefault +*/ +type ReplaceACLBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLBackendDefault creates ReplaceACLBackendDefault with default headers values +func NewReplaceACLBackendDefault(code int) *ReplaceACLBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceACLBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace Acl backend default response +func (o *ReplaceACLBackendDefault) WithStatusCode(code int) *ReplaceACLBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace Acl backend default response +func (o *ReplaceACLBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl backend default response +func (o *ReplaceACLBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceACLBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl backend default response +func (o *ReplaceACLBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl backend default response +func (o *ReplaceACLBackendDefault) WithPayload(payload *models.Error) *ReplaceACLBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl backend default response +func (o *ReplaceACLBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_acl_backend_urlbuilder.go b/operations/acl/replace_acl_backend_urlbuilder.go new file mode 100644 index 00000000..64481a09 --- /dev/null +++ b/operations/acl/replace_acl_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceACLBackendURL generates an URL for the replace Acl backend operation +type ReplaceACLBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLBackendURL) WithBasePath(bp string) *ReplaceACLBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceACLBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceACLBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceACLBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceACLBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceACLBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceACLBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceACLBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceACLBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceACLBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_acl_defaults.go b/operations/acl/replace_acl_defaults.go new file mode 100644 index 00000000..a1b9745c --- /dev/null +++ b/operations/acl/replace_acl_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceACLDefaultsHandlerFunc turns a function with the right signature into a replace Acl defaults handler +type ReplaceACLDefaultsHandlerFunc func(ReplaceACLDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceACLDefaultsHandlerFunc) Handle(params ReplaceACLDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceACLDefaultsHandler interface for that can handle valid replace Acl defaults params +type ReplaceACLDefaultsHandler interface { + Handle(ReplaceACLDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceACLDefaults creates a new http.Handler for the replace Acl defaults operation +func NewReplaceACLDefaults(ctx *middleware.Context, handler ReplaceACLDefaultsHandler) *ReplaceACLDefaults { + return &ReplaceACLDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceACLDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/acls/{index} ACL replaceAclDefaults + +# Replace a ACL line + +Replaces a ACL line configuration by it's index in the specified parent. +*/ +type ReplaceACLDefaults struct { + Context *middleware.Context + Handler ReplaceACLDefaultsHandler +} + +func (o *ReplaceACLDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceACLDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_acl_defaults_parameters.go b/operations/acl/replace_acl_defaults_parameters.go new file mode 100644 index 00000000..30d95a54 --- /dev/null +++ b/operations/acl/replace_acl_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceACLDefaultsParams creates a new ReplaceACLDefaultsParams object +// with the default values initialized. +func NewReplaceACLDefaultsParams() ReplaceACLDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceACLDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceACLDefaultsParams contains all the bound params for the replace Acl defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAclDefaults +type ReplaceACLDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceACLDefaultsParams() beforehand. +func (o *ReplaceACLDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceACLDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceACLDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceACLDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceACLDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceACLDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceACLDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_acl_defaults_responses.go b/operations/acl/replace_acl_defaults_responses.go new file mode 100644 index 00000000..ebc3ee78 --- /dev/null +++ b/operations/acl/replace_acl_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceACLDefaultsOKCode is the HTTP code returned for type ReplaceACLDefaultsOK +const ReplaceACLDefaultsOKCode int = 200 + +/* +ReplaceACLDefaultsOK ACL line replaced + +swagger:response replaceAclDefaultsOK +*/ +type ReplaceACLDefaultsOK struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLDefaultsOK creates ReplaceACLDefaultsOK with default headers values +func NewReplaceACLDefaultsOK() *ReplaceACLDefaultsOK { + + return &ReplaceACLDefaultsOK{} +} + +// WithPayload adds the payload to the replace Acl defaults o k response +func (o *ReplaceACLDefaultsOK) WithPayload(payload *models.ACL) *ReplaceACLDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl defaults o k response +func (o *ReplaceACLDefaultsOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLDefaultsAcceptedCode is the HTTP code returned for type ReplaceACLDefaultsAccepted +const ReplaceACLDefaultsAcceptedCode int = 202 + +/* +ReplaceACLDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAclDefaultsAccepted +*/ +type ReplaceACLDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLDefaultsAccepted creates ReplaceACLDefaultsAccepted with default headers values +func NewReplaceACLDefaultsAccepted() *ReplaceACLDefaultsAccepted { + + return &ReplaceACLDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Acl defaults accepted response +func (o *ReplaceACLDefaultsAccepted) WithReloadID(reloadID string) *ReplaceACLDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Acl defaults accepted response +func (o *ReplaceACLDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Acl defaults accepted response +func (o *ReplaceACLDefaultsAccepted) WithPayload(payload *models.ACL) *ReplaceACLDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl defaults accepted response +func (o *ReplaceACLDefaultsAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLDefaultsBadRequestCode is the HTTP code returned for type ReplaceACLDefaultsBadRequest +const ReplaceACLDefaultsBadRequestCode int = 400 + +/* +ReplaceACLDefaultsBadRequest Bad request + +swagger:response replaceAclDefaultsBadRequest +*/ +type ReplaceACLDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLDefaultsBadRequest creates ReplaceACLDefaultsBadRequest with default headers values +func NewReplaceACLDefaultsBadRequest() *ReplaceACLDefaultsBadRequest { + + return &ReplaceACLDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl defaults bad request response +func (o *ReplaceACLDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceACLDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl defaults bad request response +func (o *ReplaceACLDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl defaults bad request response +func (o *ReplaceACLDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceACLDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl defaults bad request response +func (o *ReplaceACLDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLDefaultsNotFoundCode is the HTTP code returned for type ReplaceACLDefaultsNotFound +const ReplaceACLDefaultsNotFoundCode int = 404 + +/* +ReplaceACLDefaultsNotFound The specified resource was not found + +swagger:response replaceAclDefaultsNotFound +*/ +type ReplaceACLDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLDefaultsNotFound creates ReplaceACLDefaultsNotFound with default headers values +func NewReplaceACLDefaultsNotFound() *ReplaceACLDefaultsNotFound { + + return &ReplaceACLDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl defaults not found response +func (o *ReplaceACLDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceACLDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl defaults not found response +func (o *ReplaceACLDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl defaults not found response +func (o *ReplaceACLDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceACLDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl defaults not found response +func (o *ReplaceACLDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceACLDefaultsDefault General Error + +swagger:response replaceAclDefaultsDefault +*/ +type ReplaceACLDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLDefaultsDefault creates ReplaceACLDefaultsDefault with default headers values +func NewReplaceACLDefaultsDefault(code int) *ReplaceACLDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceACLDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace Acl defaults default response +func (o *ReplaceACLDefaultsDefault) WithStatusCode(code int) *ReplaceACLDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace Acl defaults default response +func (o *ReplaceACLDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl defaults default response +func (o *ReplaceACLDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceACLDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl defaults default response +func (o *ReplaceACLDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl defaults default response +func (o *ReplaceACLDefaultsDefault) WithPayload(payload *models.Error) *ReplaceACLDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl defaults default response +func (o *ReplaceACLDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_acl_defaults_urlbuilder.go b/operations/acl/replace_acl_defaults_urlbuilder.go new file mode 100644 index 00000000..8b20eed0 --- /dev/null +++ b/operations/acl/replace_acl_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceACLDefaultsURL generates an URL for the replace Acl defaults operation +type ReplaceACLDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLDefaultsURL) WithBasePath(bp string) *ReplaceACLDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceACLDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceACLDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceACLDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceACLDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceACLDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceACLDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceACLDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceACLDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceACLDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_acl_fcgi_app.go b/operations/acl/replace_acl_fcgi_app.go new file mode 100644 index 00000000..70c33850 --- /dev/null +++ b/operations/acl/replace_acl_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceACLFCGIAppHandlerFunc turns a function with the right signature into a replace Acl FCGI app handler +type ReplaceACLFCGIAppHandlerFunc func(ReplaceACLFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceACLFCGIAppHandlerFunc) Handle(params ReplaceACLFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceACLFCGIAppHandler interface for that can handle valid replace Acl FCGI app params +type ReplaceACLFCGIAppHandler interface { + Handle(ReplaceACLFCGIAppParams, interface{}) middleware.Responder +} + +// NewReplaceACLFCGIApp creates a new http.Handler for the replace Acl FCGI app operation +func NewReplaceACLFCGIApp(ctx *middleware.Context, handler ReplaceACLFCGIAppHandler) *ReplaceACLFCGIApp { + return &ReplaceACLFCGIApp{Context: ctx, Handler: handler} +} + +/* + ReplaceACLFCGIApp swagger:route PUT /services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index} ACL replaceAclFcgiApp + +# Replace a ACL line + +Replaces a ACL line configuration by it's index in the specified parent. +*/ +type ReplaceACLFCGIApp struct { + Context *middleware.Context + Handler ReplaceACLFCGIAppHandler +} + +func (o *ReplaceACLFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceACLFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_acl_fcgi_app_parameters.go b/operations/acl/replace_acl_fcgi_app_parameters.go new file mode 100644 index 00000000..b6ad5b8f --- /dev/null +++ b/operations/acl/replace_acl_fcgi_app_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceACLFCGIAppParams creates a new ReplaceACLFCGIAppParams object +// with the default values initialized. +func NewReplaceACLFCGIAppParams() ReplaceACLFCGIAppParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceACLFCGIAppParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceACLFCGIAppParams contains all the bound params for the replace Acl FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAclFCGIApp +type ReplaceACLFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceACLFCGIAppParams() beforehand. +func (o *ReplaceACLFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceACLFCGIAppParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceACLFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceACLFCGIAppParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceACLFCGIAppParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceACLFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceACLFCGIAppParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_acl_fcgi_app_responses.go b/operations/acl/replace_acl_fcgi_app_responses.go new file mode 100644 index 00000000..71c0d224 --- /dev/null +++ b/operations/acl/replace_acl_fcgi_app_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceACLFCGIAppOKCode is the HTTP code returned for type ReplaceACLFCGIAppOK +const ReplaceACLFCGIAppOKCode int = 200 + +/* +ReplaceACLFCGIAppOK ACL line replaced + +swagger:response replaceAclFcgiAppOK +*/ +type ReplaceACLFCGIAppOK struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLFCGIAppOK creates ReplaceACLFCGIAppOK with default headers values +func NewReplaceACLFCGIAppOK() *ReplaceACLFCGIAppOK { + + return &ReplaceACLFCGIAppOK{} +} + +// WithPayload adds the payload to the replace Acl Fcgi app o k response +func (o *ReplaceACLFCGIAppOK) WithPayload(payload *models.ACL) *ReplaceACLFCGIAppOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl Fcgi app o k response +func (o *ReplaceACLFCGIAppOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFCGIAppOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLFCGIAppAcceptedCode is the HTTP code returned for type ReplaceACLFCGIAppAccepted +const ReplaceACLFCGIAppAcceptedCode int = 202 + +/* +ReplaceACLFCGIAppAccepted Configuration change accepted and reload requested + +swagger:response replaceAclFcgiAppAccepted +*/ +type ReplaceACLFCGIAppAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLFCGIAppAccepted creates ReplaceACLFCGIAppAccepted with default headers values +func NewReplaceACLFCGIAppAccepted() *ReplaceACLFCGIAppAccepted { + + return &ReplaceACLFCGIAppAccepted{} +} + +// WithReloadID adds the reloadId to the replace Acl Fcgi app accepted response +func (o *ReplaceACLFCGIAppAccepted) WithReloadID(reloadID string) *ReplaceACLFCGIAppAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Acl Fcgi app accepted response +func (o *ReplaceACLFCGIAppAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Acl Fcgi app accepted response +func (o *ReplaceACLFCGIAppAccepted) WithPayload(payload *models.ACL) *ReplaceACLFCGIAppAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl Fcgi app accepted response +func (o *ReplaceACLFCGIAppAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFCGIAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLFCGIAppBadRequestCode is the HTTP code returned for type ReplaceACLFCGIAppBadRequest +const ReplaceACLFCGIAppBadRequestCode int = 400 + +/* +ReplaceACLFCGIAppBadRequest Bad request + +swagger:response replaceAclFcgiAppBadRequest +*/ +type ReplaceACLFCGIAppBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLFCGIAppBadRequest creates ReplaceACLFCGIAppBadRequest with default headers values +func NewReplaceACLFCGIAppBadRequest() *ReplaceACLFCGIAppBadRequest { + + return &ReplaceACLFCGIAppBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl Fcgi app bad request response +func (o *ReplaceACLFCGIAppBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceACLFCGIAppBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl Fcgi app bad request response +func (o *ReplaceACLFCGIAppBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl Fcgi app bad request response +func (o *ReplaceACLFCGIAppBadRequest) WithPayload(payload *models.Error) *ReplaceACLFCGIAppBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl Fcgi app bad request response +func (o *ReplaceACLFCGIAppBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFCGIAppBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLFCGIAppNotFoundCode is the HTTP code returned for type ReplaceACLFCGIAppNotFound +const ReplaceACLFCGIAppNotFoundCode int = 404 + +/* +ReplaceACLFCGIAppNotFound The specified resource was not found + +swagger:response replaceAclFcgiAppNotFound +*/ +type ReplaceACLFCGIAppNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLFCGIAppNotFound creates ReplaceACLFCGIAppNotFound with default headers values +func NewReplaceACLFCGIAppNotFound() *ReplaceACLFCGIAppNotFound { + + return &ReplaceACLFCGIAppNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl Fcgi app not found response +func (o *ReplaceACLFCGIAppNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceACLFCGIAppNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl Fcgi app not found response +func (o *ReplaceACLFCGIAppNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl Fcgi app not found response +func (o *ReplaceACLFCGIAppNotFound) WithPayload(payload *models.Error) *ReplaceACLFCGIAppNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl Fcgi app not found response +func (o *ReplaceACLFCGIAppNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFCGIAppNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceACLFCGIAppDefault General Error + +swagger:response replaceAclFcgiAppDefault +*/ +type ReplaceACLFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLFCGIAppDefault creates ReplaceACLFCGIAppDefault with default headers values +func NewReplaceACLFCGIAppDefault(code int) *ReplaceACLFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceACLFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace Acl FCGI app default response +func (o *ReplaceACLFCGIAppDefault) WithStatusCode(code int) *ReplaceACLFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace Acl FCGI app default response +func (o *ReplaceACLFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl FCGI app default response +func (o *ReplaceACLFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *ReplaceACLFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl FCGI app default response +func (o *ReplaceACLFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl FCGI app default response +func (o *ReplaceACLFCGIAppDefault) WithPayload(payload *models.Error) *ReplaceACLFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl FCGI app default response +func (o *ReplaceACLFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_acl_fcgi_app_urlbuilder.go b/operations/acl/replace_acl_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..da60f787 --- /dev/null +++ b/operations/acl/replace_acl_fcgi_app_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceACLFCGIAppURL generates an URL for the replace Acl FCGI app operation +type ReplaceACLFCGIAppURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLFCGIAppURL) WithBasePath(bp string) *ReplaceACLFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceACLFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceACLFCGIAppURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceACLFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceACLFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceACLFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceACLFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceACLFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceACLFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceACLFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_acl_frontend.go b/operations/acl/replace_acl_frontend.go new file mode 100644 index 00000000..2b41554e --- /dev/null +++ b/operations/acl/replace_acl_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceACLFrontendHandlerFunc turns a function with the right signature into a replace Acl frontend handler +type ReplaceACLFrontendHandlerFunc func(ReplaceACLFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceACLFrontendHandlerFunc) Handle(params ReplaceACLFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceACLFrontendHandler interface for that can handle valid replace Acl frontend params +type ReplaceACLFrontendHandler interface { + Handle(ReplaceACLFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceACLFrontend creates a new http.Handler for the replace Acl frontend operation +func NewReplaceACLFrontend(ctx *middleware.Context, handler ReplaceACLFrontendHandler) *ReplaceACLFrontend { + return &ReplaceACLFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceACLFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/acls/{index} ACL replaceAclFrontend + +# Replace a ACL line + +Replaces a ACL line configuration by it's index in the specified parent. +*/ +type ReplaceACLFrontend struct { + Context *middleware.Context + Handler ReplaceACLFrontendHandler +} + +func (o *ReplaceACLFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceACLFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_acl_frontend_parameters.go b/operations/acl/replace_acl_frontend_parameters.go new file mode 100644 index 00000000..e98e70a4 --- /dev/null +++ b/operations/acl/replace_acl_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceACLFrontendParams creates a new ReplaceACLFrontendParams object +// with the default values initialized. +func NewReplaceACLFrontendParams() ReplaceACLFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceACLFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceACLFrontendParams contains all the bound params for the replace Acl frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAclFrontend +type ReplaceACLFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACL + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ACL line Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceACLFrontendParams() beforehand. +func (o *ReplaceACLFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACL + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceACLFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceACLFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceACLFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceACLFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceACLFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceACLFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_acl_frontend_responses.go b/operations/acl/replace_acl_frontend_responses.go new file mode 100644 index 00000000..7f5f356d --- /dev/null +++ b/operations/acl/replace_acl_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceACLFrontendOKCode is the HTTP code returned for type ReplaceACLFrontendOK +const ReplaceACLFrontendOKCode int = 200 + +/* +ReplaceACLFrontendOK ACL line replaced + +swagger:response replaceAclFrontendOK +*/ +type ReplaceACLFrontendOK struct { + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLFrontendOK creates ReplaceACLFrontendOK with default headers values +func NewReplaceACLFrontendOK() *ReplaceACLFrontendOK { + + return &ReplaceACLFrontendOK{} +} + +// WithPayload adds the payload to the replace Acl frontend o k response +func (o *ReplaceACLFrontendOK) WithPayload(payload *models.ACL) *ReplaceACLFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl frontend o k response +func (o *ReplaceACLFrontendOK) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLFrontendAcceptedCode is the HTTP code returned for type ReplaceACLFrontendAccepted +const ReplaceACLFrontendAcceptedCode int = 202 + +/* +ReplaceACLFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAclFrontendAccepted +*/ +type ReplaceACLFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ACL `json:"body,omitempty"` +} + +// NewReplaceACLFrontendAccepted creates ReplaceACLFrontendAccepted with default headers values +func NewReplaceACLFrontendAccepted() *ReplaceACLFrontendAccepted { + + return &ReplaceACLFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Acl frontend accepted response +func (o *ReplaceACLFrontendAccepted) WithReloadID(reloadID string) *ReplaceACLFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Acl frontend accepted response +func (o *ReplaceACLFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Acl frontend accepted response +func (o *ReplaceACLFrontendAccepted) WithPayload(payload *models.ACL) *ReplaceACLFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl frontend accepted response +func (o *ReplaceACLFrontendAccepted) SetPayload(payload *models.ACL) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLFrontendBadRequestCode is the HTTP code returned for type ReplaceACLFrontendBadRequest +const ReplaceACLFrontendBadRequestCode int = 400 + +/* +ReplaceACLFrontendBadRequest Bad request + +swagger:response replaceAclFrontendBadRequest +*/ +type ReplaceACLFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLFrontendBadRequest creates ReplaceACLFrontendBadRequest with default headers values +func NewReplaceACLFrontendBadRequest() *ReplaceACLFrontendBadRequest { + + return &ReplaceACLFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl frontend bad request response +func (o *ReplaceACLFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceACLFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl frontend bad request response +func (o *ReplaceACLFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl frontend bad request response +func (o *ReplaceACLFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceACLFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl frontend bad request response +func (o *ReplaceACLFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceACLFrontendNotFoundCode is the HTTP code returned for type ReplaceACLFrontendNotFound +const ReplaceACLFrontendNotFoundCode int = 404 + +/* +ReplaceACLFrontendNotFound The specified resource was not found + +swagger:response replaceAclFrontendNotFound +*/ +type ReplaceACLFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLFrontendNotFound creates ReplaceACLFrontendNotFound with default headers values +func NewReplaceACLFrontendNotFound() *ReplaceACLFrontendNotFound { + + return &ReplaceACLFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl frontend not found response +func (o *ReplaceACLFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceACLFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl frontend not found response +func (o *ReplaceACLFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl frontend not found response +func (o *ReplaceACLFrontendNotFound) WithPayload(payload *models.Error) *ReplaceACLFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl frontend not found response +func (o *ReplaceACLFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceACLFrontendDefault General Error + +swagger:response replaceAclFrontendDefault +*/ +type ReplaceACLFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceACLFrontendDefault creates ReplaceACLFrontendDefault with default headers values +func NewReplaceACLFrontendDefault(code int) *ReplaceACLFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceACLFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace Acl frontend default response +func (o *ReplaceACLFrontendDefault) WithStatusCode(code int) *ReplaceACLFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace Acl frontend default response +func (o *ReplaceACLFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace Acl frontend default response +func (o *ReplaceACLFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceACLFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Acl frontend default response +func (o *ReplaceACLFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Acl frontend default response +func (o *ReplaceACLFrontendDefault) WithPayload(payload *models.Error) *ReplaceACLFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Acl frontend default response +func (o *ReplaceACLFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceACLFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_acl_frontend_urlbuilder.go b/operations/acl/replace_acl_frontend_urlbuilder.go new file mode 100644 index 00000000..260cd733 --- /dev/null +++ b/operations/acl/replace_acl_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceACLFrontendURL generates an URL for the replace Acl frontend operation +type ReplaceACLFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLFrontendURL) WithBasePath(bp string) *ReplaceACLFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceACLFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceACLFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/acls/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceACLFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceACLFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceACLFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceACLFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceACLFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceACLFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceACLFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceACLFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_acl_parameters.go b/operations/acl/replace_acl_parameters.go deleted file mode 100644 index cebc43c6..00000000 --- a/operations/acl/replace_acl_parameters.go +++ /dev/null @@ -1,302 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceACLParams creates a new ReplaceACLParams object -// with the default values initialized. -func NewReplaceACLParams() ReplaceACLParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceACLParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceACLParams contains all the bound params for the replace Acl operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceAcl -type ReplaceACLParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.ACL - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*ACL line ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceACLParams() beforehand. -func (o *ReplaceACLParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.ACL - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceACLParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceACLParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *ReplaceACLParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *ReplaceACLParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *ReplaceACLParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *ReplaceACLParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceACLParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceACLParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/acl/replace_acl_responses.go b/operations/acl/replace_acl_responses.go deleted file mode 100644 index 150f87ae..00000000 --- a/operations/acl/replace_acl_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceACLOKCode is the HTTP code returned for type ReplaceACLOK -const ReplaceACLOKCode int = 200 - -/*ReplaceACLOK ACL line replaced - -swagger:response replaceAclOK -*/ -type ReplaceACLOK struct { - - /* - In: Body - */ - Payload *models.ACL `json:"body,omitempty"` -} - -// NewReplaceACLOK creates ReplaceACLOK with default headers values -func NewReplaceACLOK() *ReplaceACLOK { - - return &ReplaceACLOK{} -} - -// WithPayload adds the payload to the replace Acl o k response -func (o *ReplaceACLOK) WithPayload(payload *models.ACL) *ReplaceACLOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Acl o k response -func (o *ReplaceACLOK) SetPayload(payload *models.ACL) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceACLOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceACLAcceptedCode is the HTTP code returned for type ReplaceACLAccepted -const ReplaceACLAcceptedCode int = 202 - -/*ReplaceACLAccepted Configuration change accepted and reload requested - -swagger:response replaceAclAccepted -*/ -type ReplaceACLAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.ACL `json:"body,omitempty"` -} - -// NewReplaceACLAccepted creates ReplaceACLAccepted with default headers values -func NewReplaceACLAccepted() *ReplaceACLAccepted { - - return &ReplaceACLAccepted{} -} - -// WithReloadID adds the reloadId to the replace Acl accepted response -func (o *ReplaceACLAccepted) WithReloadID(reloadID string) *ReplaceACLAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace Acl accepted response -func (o *ReplaceACLAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace Acl accepted response -func (o *ReplaceACLAccepted) WithPayload(payload *models.ACL) *ReplaceACLAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Acl accepted response -func (o *ReplaceACLAccepted) SetPayload(payload *models.ACL) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceACLAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceACLBadRequestCode is the HTTP code returned for type ReplaceACLBadRequest -const ReplaceACLBadRequestCode int = 400 - -/*ReplaceACLBadRequest Bad request - -swagger:response replaceAclBadRequest -*/ -type ReplaceACLBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceACLBadRequest creates ReplaceACLBadRequest with default headers values -func NewReplaceACLBadRequest() *ReplaceACLBadRequest { - - return &ReplaceACLBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Acl bad request response -func (o *ReplaceACLBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceACLBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Acl bad request response -func (o *ReplaceACLBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Acl bad request response -func (o *ReplaceACLBadRequest) WithPayload(payload *models.Error) *ReplaceACLBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Acl bad request response -func (o *ReplaceACLBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceACLBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceACLNotFoundCode is the HTTP code returned for type ReplaceACLNotFound -const ReplaceACLNotFoundCode int = 404 - -/*ReplaceACLNotFound The specified resource was not found - -swagger:response replaceAclNotFound -*/ -type ReplaceACLNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceACLNotFound creates ReplaceACLNotFound with default headers values -func NewReplaceACLNotFound() *ReplaceACLNotFound { - - return &ReplaceACLNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Acl not found response -func (o *ReplaceACLNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceACLNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Acl not found response -func (o *ReplaceACLNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Acl not found response -func (o *ReplaceACLNotFound) WithPayload(payload *models.Error) *ReplaceACLNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Acl not found response -func (o *ReplaceACLNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceACLNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceACLDefault General Error - -swagger:response replaceAclDefault -*/ -type ReplaceACLDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceACLDefault creates ReplaceACLDefault with default headers values -func NewReplaceACLDefault(code int) *ReplaceACLDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceACLDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace Acl default response -func (o *ReplaceACLDefault) WithStatusCode(code int) *ReplaceACLDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace Acl default response -func (o *ReplaceACLDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace Acl default response -func (o *ReplaceACLDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceACLDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Acl default response -func (o *ReplaceACLDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Acl default response -func (o *ReplaceACLDefault) WithPayload(payload *models.Error) *ReplaceACLDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Acl default response -func (o *ReplaceACLDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceACLDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/acl/replace_acl_urlbuilder.go b/operations/acl/replace_acl_urlbuilder.go deleted file mode 100644 index 7c503dd1..00000000 --- a/operations/acl/replace_acl_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package acl - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceACLURL generates an URL for the replace Acl operation -type ReplaceACLURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceACLURL) WithBasePath(bp string) *ReplaceACLURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceACLURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceACLURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/acls/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on ReplaceACLURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceACLURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceACLURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceACLURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceACLURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceACLURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceACLURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/acl/replace_all_acl_backend.go b/operations/acl/replace_all_acl_backend.go new file mode 100644 index 00000000..80b897b6 --- /dev/null +++ b/operations/acl/replace_all_acl_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllACLBackendHandlerFunc turns a function with the right signature into a replace all Acl backend handler +type ReplaceAllACLBackendHandlerFunc func(ReplaceAllACLBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllACLBackendHandlerFunc) Handle(params ReplaceAllACLBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllACLBackendHandler interface for that can handle valid replace all Acl backend params +type ReplaceAllACLBackendHandler interface { + Handle(ReplaceAllACLBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllACLBackend creates a new http.Handler for the replace all Acl backend operation +func NewReplaceAllACLBackend(ctx *middleware.Context, handler ReplaceAllACLBackendHandler) *ReplaceAllACLBackend { + return &ReplaceAllACLBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllACLBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/acls ACL replaceAllAclBackend + +# Replace an ACL list + +Replaces a whole list of ACLs with the list given in parameter +*/ +type ReplaceAllACLBackend struct { + Context *middleware.Context + Handler ReplaceAllACLBackendHandler +} + +func (o *ReplaceAllACLBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllACLBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_all_acl_backend_parameters.go b/operations/acl/replace_all_acl_backend_parameters.go new file mode 100644 index 00000000..4a34a42a --- /dev/null +++ b/operations/acl/replace_all_acl_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllACLBackendParams creates a new ReplaceAllACLBackendParams object +// with the default values initialized. +func NewReplaceAllACLBackendParams() ReplaceAllACLBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllACLBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllACLBackendParams contains all the bound params for the replace all Acl backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllAclBackend +type ReplaceAllACLBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.Acls + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllACLBackendParams() beforehand. +func (o *ReplaceAllACLBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Acls + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllACLBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllACLBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllACLBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllACLBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllACLBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_all_acl_backend_responses.go b/operations/acl/replace_all_acl_backend_responses.go new file mode 100644 index 00000000..52390845 --- /dev/null +++ b/operations/acl/replace_all_acl_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllACLBackendOKCode is the HTTP code returned for type ReplaceAllACLBackendOK +const ReplaceAllACLBackendOKCode int = 200 + +/* +ReplaceAllACLBackendOK All ACL lines replaced + +swagger:response replaceAllAclBackendOK +*/ +type ReplaceAllACLBackendOK struct { + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLBackendOK creates ReplaceAllACLBackendOK with default headers values +func NewReplaceAllACLBackendOK() *ReplaceAllACLBackendOK { + + return &ReplaceAllACLBackendOK{} +} + +// WithPayload adds the payload to the replace all Acl backend o k response +func (o *ReplaceAllACLBackendOK) WithPayload(payload models.Acls) *ReplaceAllACLBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl backend o k response +func (o *ReplaceAllACLBackendOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLBackendAcceptedCode is the HTTP code returned for type ReplaceAllACLBackendAccepted +const ReplaceAllACLBackendAcceptedCode int = 202 + +/* +ReplaceAllACLBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllAclBackendAccepted +*/ +type ReplaceAllACLBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLBackendAccepted creates ReplaceAllACLBackendAccepted with default headers values +func NewReplaceAllACLBackendAccepted() *ReplaceAllACLBackendAccepted { + + return &ReplaceAllACLBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Acl backend accepted response +func (o *ReplaceAllACLBackendAccepted) WithReloadID(reloadID string) *ReplaceAllACLBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Acl backend accepted response +func (o *ReplaceAllACLBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Acl backend accepted response +func (o *ReplaceAllACLBackendAccepted) WithPayload(payload models.Acls) *ReplaceAllACLBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl backend accepted response +func (o *ReplaceAllACLBackendAccepted) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLBackendBadRequestCode is the HTTP code returned for type ReplaceAllACLBackendBadRequest +const ReplaceAllACLBackendBadRequestCode int = 400 + +/* +ReplaceAllACLBackendBadRequest Bad request + +swagger:response replaceAllAclBackendBadRequest +*/ +type ReplaceAllACLBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLBackendBadRequest creates ReplaceAllACLBackendBadRequest with default headers values +func NewReplaceAllACLBackendBadRequest() *ReplaceAllACLBackendBadRequest { + + return &ReplaceAllACLBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl backend bad request response +func (o *ReplaceAllACLBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl backend bad request response +func (o *ReplaceAllACLBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl backend bad request response +func (o *ReplaceAllACLBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllACLBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl backend bad request response +func (o *ReplaceAllACLBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllACLBackendDefault General Error + +swagger:response replaceAllAclBackendDefault +*/ +type ReplaceAllACLBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLBackendDefault creates ReplaceAllACLBackendDefault with default headers values +func NewReplaceAllACLBackendDefault(code int) *ReplaceAllACLBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllACLBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all Acl backend default response +func (o *ReplaceAllACLBackendDefault) WithStatusCode(code int) *ReplaceAllACLBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all Acl backend default response +func (o *ReplaceAllACLBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl backend default response +func (o *ReplaceAllACLBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl backend default response +func (o *ReplaceAllACLBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl backend default response +func (o *ReplaceAllACLBackendDefault) WithPayload(payload *models.Error) *ReplaceAllACLBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl backend default response +func (o *ReplaceAllACLBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_all_acl_backend_urlbuilder.go b/operations/acl/replace_all_acl_backend_urlbuilder.go new file mode 100644 index 00000000..3b3c0809 --- /dev/null +++ b/operations/acl/replace_all_acl_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllACLBackendURL generates an URL for the replace all Acl backend operation +type ReplaceAllACLBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLBackendURL) WithBasePath(bp string) *ReplaceAllACLBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllACLBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllACLBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllACLBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllACLBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllACLBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllACLBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllACLBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllACLBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_all_acl_defaults.go b/operations/acl/replace_all_acl_defaults.go new file mode 100644 index 00000000..92bbc674 --- /dev/null +++ b/operations/acl/replace_all_acl_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllACLDefaultsHandlerFunc turns a function with the right signature into a replace all Acl defaults handler +type ReplaceAllACLDefaultsHandlerFunc func(ReplaceAllACLDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllACLDefaultsHandlerFunc) Handle(params ReplaceAllACLDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllACLDefaultsHandler interface for that can handle valid replace all Acl defaults params +type ReplaceAllACLDefaultsHandler interface { + Handle(ReplaceAllACLDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllACLDefaults creates a new http.Handler for the replace all Acl defaults operation +func NewReplaceAllACLDefaults(ctx *middleware.Context, handler ReplaceAllACLDefaultsHandler) *ReplaceAllACLDefaults { + return &ReplaceAllACLDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllACLDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/acls ACL replaceAllAclDefaults + +# Replace an ACL list + +Replaces a whole list of ACLs with the list given in parameter +*/ +type ReplaceAllACLDefaults struct { + Context *middleware.Context + Handler ReplaceAllACLDefaultsHandler +} + +func (o *ReplaceAllACLDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllACLDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_all_acl_defaults_parameters.go b/operations/acl/replace_all_acl_defaults_parameters.go new file mode 100644 index 00000000..febfff9b --- /dev/null +++ b/operations/acl/replace_all_acl_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllACLDefaultsParams creates a new ReplaceAllACLDefaultsParams object +// with the default values initialized. +func NewReplaceAllACLDefaultsParams() ReplaceAllACLDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllACLDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllACLDefaultsParams contains all the bound params for the replace all Acl defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllAclDefaults +type ReplaceAllACLDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.Acls + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllACLDefaultsParams() beforehand. +func (o *ReplaceAllACLDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Acls + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllACLDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllACLDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllACLDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllACLDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllACLDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_all_acl_defaults_responses.go b/operations/acl/replace_all_acl_defaults_responses.go new file mode 100644 index 00000000..28d73898 --- /dev/null +++ b/operations/acl/replace_all_acl_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllACLDefaultsOKCode is the HTTP code returned for type ReplaceAllACLDefaultsOK +const ReplaceAllACLDefaultsOKCode int = 200 + +/* +ReplaceAllACLDefaultsOK All ACL lines replaced + +swagger:response replaceAllAclDefaultsOK +*/ +type ReplaceAllACLDefaultsOK struct { + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLDefaultsOK creates ReplaceAllACLDefaultsOK with default headers values +func NewReplaceAllACLDefaultsOK() *ReplaceAllACLDefaultsOK { + + return &ReplaceAllACLDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Acl defaults o k response +func (o *ReplaceAllACLDefaultsOK) WithPayload(payload models.Acls) *ReplaceAllACLDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl defaults o k response +func (o *ReplaceAllACLDefaultsOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllACLDefaultsAccepted +const ReplaceAllACLDefaultsAcceptedCode int = 202 + +/* +ReplaceAllACLDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllAclDefaultsAccepted +*/ +type ReplaceAllACLDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLDefaultsAccepted creates ReplaceAllACLDefaultsAccepted with default headers values +func NewReplaceAllACLDefaultsAccepted() *ReplaceAllACLDefaultsAccepted { + + return &ReplaceAllACLDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Acl defaults accepted response +func (o *ReplaceAllACLDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllACLDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Acl defaults accepted response +func (o *ReplaceAllACLDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Acl defaults accepted response +func (o *ReplaceAllACLDefaultsAccepted) WithPayload(payload models.Acls) *ReplaceAllACLDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl defaults accepted response +func (o *ReplaceAllACLDefaultsAccepted) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllACLDefaultsBadRequest +const ReplaceAllACLDefaultsBadRequestCode int = 400 + +/* +ReplaceAllACLDefaultsBadRequest Bad request + +swagger:response replaceAllAclDefaultsBadRequest +*/ +type ReplaceAllACLDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLDefaultsBadRequest creates ReplaceAllACLDefaultsBadRequest with default headers values +func NewReplaceAllACLDefaultsBadRequest() *ReplaceAllACLDefaultsBadRequest { + + return &ReplaceAllACLDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl defaults bad request response +func (o *ReplaceAllACLDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl defaults bad request response +func (o *ReplaceAllACLDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl defaults bad request response +func (o *ReplaceAllACLDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllACLDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl defaults bad request response +func (o *ReplaceAllACLDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllACLDefaultsDefault General Error + +swagger:response replaceAllAclDefaultsDefault +*/ +type ReplaceAllACLDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLDefaultsDefault creates ReplaceAllACLDefaultsDefault with default headers values +func NewReplaceAllACLDefaultsDefault(code int) *ReplaceAllACLDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllACLDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all Acl defaults default response +func (o *ReplaceAllACLDefaultsDefault) WithStatusCode(code int) *ReplaceAllACLDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all Acl defaults default response +func (o *ReplaceAllACLDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl defaults default response +func (o *ReplaceAllACLDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl defaults default response +func (o *ReplaceAllACLDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl defaults default response +func (o *ReplaceAllACLDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllACLDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl defaults default response +func (o *ReplaceAllACLDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_all_acl_defaults_urlbuilder.go b/operations/acl/replace_all_acl_defaults_urlbuilder.go new file mode 100644 index 00000000..e297a56c --- /dev/null +++ b/operations/acl/replace_all_acl_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllACLDefaultsURL generates an URL for the replace all Acl defaults operation +type ReplaceAllACLDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLDefaultsURL) WithBasePath(bp string) *ReplaceAllACLDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllACLDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllACLDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllACLDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllACLDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllACLDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllACLDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllACLDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllACLDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_all_acl_fcgi_app.go b/operations/acl/replace_all_acl_fcgi_app.go new file mode 100644 index 00000000..28564885 --- /dev/null +++ b/operations/acl/replace_all_acl_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllACLFCGIAppHandlerFunc turns a function with the right signature into a replace all Acl FCGI app handler +type ReplaceAllACLFCGIAppHandlerFunc func(ReplaceAllACLFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllACLFCGIAppHandlerFunc) Handle(params ReplaceAllACLFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllACLFCGIAppHandler interface for that can handle valid replace all Acl FCGI app params +type ReplaceAllACLFCGIAppHandler interface { + Handle(ReplaceAllACLFCGIAppParams, interface{}) middleware.Responder +} + +// NewReplaceAllACLFCGIApp creates a new http.Handler for the replace all Acl FCGI app operation +func NewReplaceAllACLFCGIApp(ctx *middleware.Context, handler ReplaceAllACLFCGIAppHandler) *ReplaceAllACLFCGIApp { + return &ReplaceAllACLFCGIApp{Context: ctx, Handler: handler} +} + +/* + ReplaceAllACLFCGIApp swagger:route PUT /services/haproxy/configuration/fcgi_apps/{parent_name}/acls ACL replaceAllAclFcgiApp + +# Replace an ACL list + +Replaces a whole list of ACLs with the list given in parameter +*/ +type ReplaceAllACLFCGIApp struct { + Context *middleware.Context + Handler ReplaceAllACLFCGIAppHandler +} + +func (o *ReplaceAllACLFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllACLFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_all_acl_fcgi_app_parameters.go b/operations/acl/replace_all_acl_fcgi_app_parameters.go new file mode 100644 index 00000000..c3b0d8d8 --- /dev/null +++ b/operations/acl/replace_all_acl_fcgi_app_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllACLFCGIAppParams creates a new ReplaceAllACLFCGIAppParams object +// with the default values initialized. +func NewReplaceAllACLFCGIAppParams() ReplaceAllACLFCGIAppParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllACLFCGIAppParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllACLFCGIAppParams contains all the bound params for the replace all Acl FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllAclFCGIApp +type ReplaceAllACLFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.Acls + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllACLFCGIAppParams() beforehand. +func (o *ReplaceAllACLFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Acls + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllACLFCGIAppParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllACLFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllACLFCGIAppParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllACLFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllACLFCGIAppParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_all_acl_fcgi_app_responses.go b/operations/acl/replace_all_acl_fcgi_app_responses.go new file mode 100644 index 00000000..a88857e8 --- /dev/null +++ b/operations/acl/replace_all_acl_fcgi_app_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllACLFCGIAppOKCode is the HTTP code returned for type ReplaceAllACLFCGIAppOK +const ReplaceAllACLFCGIAppOKCode int = 200 + +/* +ReplaceAllACLFCGIAppOK All ACL lines replaced + +swagger:response replaceAllAclFcgiAppOK +*/ +type ReplaceAllACLFCGIAppOK struct { + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLFCGIAppOK creates ReplaceAllACLFCGIAppOK with default headers values +func NewReplaceAllACLFCGIAppOK() *ReplaceAllACLFCGIAppOK { + + return &ReplaceAllACLFCGIAppOK{} +} + +// WithPayload adds the payload to the replace all Acl Fcgi app o k response +func (o *ReplaceAllACLFCGIAppOK) WithPayload(payload models.Acls) *ReplaceAllACLFCGIAppOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl Fcgi app o k response +func (o *ReplaceAllACLFCGIAppOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFCGIAppOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLFCGIAppAcceptedCode is the HTTP code returned for type ReplaceAllACLFCGIAppAccepted +const ReplaceAllACLFCGIAppAcceptedCode int = 202 + +/* +ReplaceAllACLFCGIAppAccepted Configuration change accepted and reload requested + +swagger:response replaceAllAclFcgiAppAccepted +*/ +type ReplaceAllACLFCGIAppAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLFCGIAppAccepted creates ReplaceAllACLFCGIAppAccepted with default headers values +func NewReplaceAllACLFCGIAppAccepted() *ReplaceAllACLFCGIAppAccepted { + + return &ReplaceAllACLFCGIAppAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Acl Fcgi app accepted response +func (o *ReplaceAllACLFCGIAppAccepted) WithReloadID(reloadID string) *ReplaceAllACLFCGIAppAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Acl Fcgi app accepted response +func (o *ReplaceAllACLFCGIAppAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Acl Fcgi app accepted response +func (o *ReplaceAllACLFCGIAppAccepted) WithPayload(payload models.Acls) *ReplaceAllACLFCGIAppAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl Fcgi app accepted response +func (o *ReplaceAllACLFCGIAppAccepted) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFCGIAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLFCGIAppBadRequestCode is the HTTP code returned for type ReplaceAllACLFCGIAppBadRequest +const ReplaceAllACLFCGIAppBadRequestCode int = 400 + +/* +ReplaceAllACLFCGIAppBadRequest Bad request + +swagger:response replaceAllAclFcgiAppBadRequest +*/ +type ReplaceAllACLFCGIAppBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLFCGIAppBadRequest creates ReplaceAllACLFCGIAppBadRequest with default headers values +func NewReplaceAllACLFCGIAppBadRequest() *ReplaceAllACLFCGIAppBadRequest { + + return &ReplaceAllACLFCGIAppBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl Fcgi app bad request response +func (o *ReplaceAllACLFCGIAppBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLFCGIAppBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl Fcgi app bad request response +func (o *ReplaceAllACLFCGIAppBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl Fcgi app bad request response +func (o *ReplaceAllACLFCGIAppBadRequest) WithPayload(payload *models.Error) *ReplaceAllACLFCGIAppBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl Fcgi app bad request response +func (o *ReplaceAllACLFCGIAppBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFCGIAppBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllACLFCGIAppDefault General Error + +swagger:response replaceAllAclFcgiAppDefault +*/ +type ReplaceAllACLFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLFCGIAppDefault creates ReplaceAllACLFCGIAppDefault with default headers values +func NewReplaceAllACLFCGIAppDefault(code int) *ReplaceAllACLFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllACLFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all Acl FCGI app default response +func (o *ReplaceAllACLFCGIAppDefault) WithStatusCode(code int) *ReplaceAllACLFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all Acl FCGI app default response +func (o *ReplaceAllACLFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl FCGI app default response +func (o *ReplaceAllACLFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl FCGI app default response +func (o *ReplaceAllACLFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl FCGI app default response +func (o *ReplaceAllACLFCGIAppDefault) WithPayload(payload *models.Error) *ReplaceAllACLFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl FCGI app default response +func (o *ReplaceAllACLFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_all_acl_fcgi_app_urlbuilder.go b/operations/acl/replace_all_acl_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..b29f5800 --- /dev/null +++ b/operations/acl/replace_all_acl_fcgi_app_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllACLFCGIAppURL generates an URL for the replace all Acl FCGI app operation +type ReplaceAllACLFCGIAppURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLFCGIAppURL) WithBasePath(bp string) *ReplaceAllACLFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllACLFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllACLFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllACLFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllACLFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllACLFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllACLFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllACLFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllACLFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl/replace_all_acl_frontend.go b/operations/acl/replace_all_acl_frontend.go new file mode 100644 index 00000000..49acb9c0 --- /dev/null +++ b/operations/acl/replace_all_acl_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllACLFrontendHandlerFunc turns a function with the right signature into a replace all Acl frontend handler +type ReplaceAllACLFrontendHandlerFunc func(ReplaceAllACLFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllACLFrontendHandlerFunc) Handle(params ReplaceAllACLFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllACLFrontendHandler interface for that can handle valid replace all Acl frontend params +type ReplaceAllACLFrontendHandler interface { + Handle(ReplaceAllACLFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllACLFrontend creates a new http.Handler for the replace all Acl frontend operation +func NewReplaceAllACLFrontend(ctx *middleware.Context, handler ReplaceAllACLFrontendHandler) *ReplaceAllACLFrontend { + return &ReplaceAllACLFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllACLFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/acls ACL replaceAllAclFrontend + +# Replace an ACL list + +Replaces a whole list of ACLs with the list given in parameter +*/ +type ReplaceAllACLFrontend struct { + Context *middleware.Context + Handler ReplaceAllACLFrontendHandler +} + +func (o *ReplaceAllACLFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllACLFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl/replace_all_acl_frontend_parameters.go b/operations/acl/replace_all_acl_frontend_parameters.go new file mode 100644 index 00000000..6bfd0e8c --- /dev/null +++ b/operations/acl/replace_all_acl_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllACLFrontendParams creates a new ReplaceAllACLFrontendParams object +// with the default values initialized. +func NewReplaceAllACLFrontendParams() ReplaceAllACLFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllACLFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllACLFrontendParams contains all the bound params for the replace all Acl frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllAclFrontend +type ReplaceAllACLFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.Acls + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllACLFrontendParams() beforehand. +func (o *ReplaceAllACLFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Acls + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllACLFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllACLFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllACLFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllACLFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllACLFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acl/replace_all_acl_frontend_responses.go b/operations/acl/replace_all_acl_frontend_responses.go new file mode 100644 index 00000000..c72aee46 --- /dev/null +++ b/operations/acl/replace_all_acl_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllACLFrontendOKCode is the HTTP code returned for type ReplaceAllACLFrontendOK +const ReplaceAllACLFrontendOKCode int = 200 + +/* +ReplaceAllACLFrontendOK All ACL lines replaced + +swagger:response replaceAllAclFrontendOK +*/ +type ReplaceAllACLFrontendOK struct { + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLFrontendOK creates ReplaceAllACLFrontendOK with default headers values +func NewReplaceAllACLFrontendOK() *ReplaceAllACLFrontendOK { + + return &ReplaceAllACLFrontendOK{} +} + +// WithPayload adds the payload to the replace all Acl frontend o k response +func (o *ReplaceAllACLFrontendOK) WithPayload(payload models.Acls) *ReplaceAllACLFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl frontend o k response +func (o *ReplaceAllACLFrontendOK) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLFrontendAcceptedCode is the HTTP code returned for type ReplaceAllACLFrontendAccepted +const ReplaceAllACLFrontendAcceptedCode int = 202 + +/* +ReplaceAllACLFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllAclFrontendAccepted +*/ +type ReplaceAllACLFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.Acls `json:"body,omitempty"` +} + +// NewReplaceAllACLFrontendAccepted creates ReplaceAllACLFrontendAccepted with default headers values +func NewReplaceAllACLFrontendAccepted() *ReplaceAllACLFrontendAccepted { + + return &ReplaceAllACLFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Acl frontend accepted response +func (o *ReplaceAllACLFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllACLFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Acl frontend accepted response +func (o *ReplaceAllACLFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Acl frontend accepted response +func (o *ReplaceAllACLFrontendAccepted) WithPayload(payload models.Acls) *ReplaceAllACLFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl frontend accepted response +func (o *ReplaceAllACLFrontendAccepted) SetPayload(payload models.Acls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Acls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllACLFrontendBadRequestCode is the HTTP code returned for type ReplaceAllACLFrontendBadRequest +const ReplaceAllACLFrontendBadRequestCode int = 400 + +/* +ReplaceAllACLFrontendBadRequest Bad request + +swagger:response replaceAllAclFrontendBadRequest +*/ +type ReplaceAllACLFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLFrontendBadRequest creates ReplaceAllACLFrontendBadRequest with default headers values +func NewReplaceAllACLFrontendBadRequest() *ReplaceAllACLFrontendBadRequest { + + return &ReplaceAllACLFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl frontend bad request response +func (o *ReplaceAllACLFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl frontend bad request response +func (o *ReplaceAllACLFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl frontend bad request response +func (o *ReplaceAllACLFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllACLFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl frontend bad request response +func (o *ReplaceAllACLFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllACLFrontendDefault General Error + +swagger:response replaceAllAclFrontendDefault +*/ +type ReplaceAllACLFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllACLFrontendDefault creates ReplaceAllACLFrontendDefault with default headers values +func NewReplaceAllACLFrontendDefault(code int) *ReplaceAllACLFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllACLFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all Acl frontend default response +func (o *ReplaceAllACLFrontendDefault) WithStatusCode(code int) *ReplaceAllACLFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all Acl frontend default response +func (o *ReplaceAllACLFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Acl frontend default response +func (o *ReplaceAllACLFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllACLFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Acl frontend default response +func (o *ReplaceAllACLFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Acl frontend default response +func (o *ReplaceAllACLFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllACLFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Acl frontend default response +func (o *ReplaceAllACLFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllACLFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl/replace_all_acl_frontend_urlbuilder.go b/operations/acl/replace_all_acl_frontend_urlbuilder.go new file mode 100644 index 00000000..83b0dcac --- /dev/null +++ b/operations/acl/replace_all_acl_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllACLFrontendURL generates an URL for the replace all Acl frontend operation +type ReplaceAllACLFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLFrontendURL) WithBasePath(bp string) *ReplaceAllACLFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllACLFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllACLFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/acls" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllACLFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllACLFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllACLFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllACLFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllACLFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllACLFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllACLFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl_runtime/add_payload_runtime_acl.go b/operations/acl_runtime/add_payload_runtime_acl.go new file mode 100644 index 00000000..23fdd9e8 --- /dev/null +++ b/operations/acl_runtime/add_payload_runtime_acl.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddPayloadRuntimeACLHandlerFunc turns a function with the right signature into a add payload runtime ACL handler +type AddPayloadRuntimeACLHandlerFunc func(AddPayloadRuntimeACLParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddPayloadRuntimeACLHandlerFunc) Handle(params AddPayloadRuntimeACLParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddPayloadRuntimeACLHandler interface for that can handle valid add payload runtime ACL params +type AddPayloadRuntimeACLHandler interface { + Handle(AddPayloadRuntimeACLParams, interface{}) middleware.Responder +} + +// NewAddPayloadRuntimeACL creates a new http.Handler for the add payload runtime ACL operation +func NewAddPayloadRuntimeACL(ctx *middleware.Context, handler AddPayloadRuntimeACLHandler) *AddPayloadRuntimeACL { + return &AddPayloadRuntimeACL{Context: ctx, Handler: handler} +} + +/* + AddPayloadRuntimeACL swagger:route PUT /services/haproxy/runtime/acls/{parent_name}/entries ACL Runtime addPayloadRuntimeAcl + +# Add a new ACL payload + +Adds a new ACL payload. +*/ +type AddPayloadRuntimeACL struct { + Context *middleware.Context + Handler AddPayloadRuntimeACLHandler +} + +func (o *AddPayloadRuntimeACL) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewAddPayloadRuntimeACLParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl_runtime/add_payload_runtime_acl_parameters.go b/operations/acl_runtime/add_payload_runtime_acl_parameters.go new file mode 100644 index 00000000..c6db445d --- /dev/null +++ b/operations/acl_runtime/add_payload_runtime_acl_parameters.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewAddPayloadRuntimeACLParams creates a new AddPayloadRuntimeACLParams object +// +// There are no default values defined in the spec. +func NewAddPayloadRuntimeACLParams() AddPayloadRuntimeACLParams { + + return AddPayloadRuntimeACLParams{} +} + +// AddPayloadRuntimeACLParams contains all the bound params for the add payload runtime ACL operation +// typically these are obtained from a http.Request +// +// swagger:parameters addPayloadRuntimeACL +type AddPayloadRuntimeACLParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.ACLFilesEntries + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddPayloadRuntimeACLParams() beforehand. +func (o *AddPayloadRuntimeACLParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACLFilesEntries + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *AddPayloadRuntimeACLParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/acl_runtime/add_payload_runtime_acl_responses.go b/operations/acl_runtime/add_payload_runtime_acl_responses.go new file mode 100644 index 00000000..25dfdc6c --- /dev/null +++ b/operations/acl_runtime/add_payload_runtime_acl_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// AddPayloadRuntimeACLCreatedCode is the HTTP code returned for type AddPayloadRuntimeACLCreated +const AddPayloadRuntimeACLCreatedCode int = 201 + +/* +AddPayloadRuntimeACLCreated ACL payload added + +swagger:response addPayloadRuntimeAclCreated +*/ +type AddPayloadRuntimeACLCreated struct { + + /* + In: Body + */ + Payload models.ACLFilesEntries `json:"body,omitempty"` +} + +// NewAddPayloadRuntimeACLCreated creates AddPayloadRuntimeACLCreated with default headers values +func NewAddPayloadRuntimeACLCreated() *AddPayloadRuntimeACLCreated { + + return &AddPayloadRuntimeACLCreated{} +} + +// WithPayload adds the payload to the add payload runtime Acl created response +func (o *AddPayloadRuntimeACLCreated) WithPayload(payload models.ACLFilesEntries) *AddPayloadRuntimeACLCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add payload runtime Acl created response +func (o *AddPayloadRuntimeACLCreated) SetPayload(payload models.ACLFilesEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddPayloadRuntimeACLCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.ACLFilesEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// AddPayloadRuntimeACLBadRequestCode is the HTTP code returned for type AddPayloadRuntimeACLBadRequest +const AddPayloadRuntimeACLBadRequestCode int = 400 + +/* +AddPayloadRuntimeACLBadRequest Bad request + +swagger:response addPayloadRuntimeAclBadRequest +*/ +type AddPayloadRuntimeACLBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddPayloadRuntimeACLBadRequest creates AddPayloadRuntimeACLBadRequest with default headers values +func NewAddPayloadRuntimeACLBadRequest() *AddPayloadRuntimeACLBadRequest { + + return &AddPayloadRuntimeACLBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the add payload runtime Acl bad request response +func (o *AddPayloadRuntimeACLBadRequest) WithConfigurationVersion(configurationVersion string) *AddPayloadRuntimeACLBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add payload runtime Acl bad request response +func (o *AddPayloadRuntimeACLBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add payload runtime Acl bad request response +func (o *AddPayloadRuntimeACLBadRequest) WithPayload(payload *models.Error) *AddPayloadRuntimeACLBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add payload runtime Acl bad request response +func (o *AddPayloadRuntimeACLBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddPayloadRuntimeACLBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +AddPayloadRuntimeACLDefault General Error + +swagger:response addPayloadRuntimeAclDefault +*/ +type AddPayloadRuntimeACLDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddPayloadRuntimeACLDefault creates AddPayloadRuntimeACLDefault with default headers values +func NewAddPayloadRuntimeACLDefault(code int) *AddPayloadRuntimeACLDefault { + if code <= 0 { + code = 500 + } + + return &AddPayloadRuntimeACLDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the add payload runtime ACL default response +func (o *AddPayloadRuntimeACLDefault) WithStatusCode(code int) *AddPayloadRuntimeACLDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the add payload runtime ACL default response +func (o *AddPayloadRuntimeACLDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the add payload runtime ACL default response +func (o *AddPayloadRuntimeACLDefault) WithConfigurationVersion(configurationVersion string) *AddPayloadRuntimeACLDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add payload runtime ACL default response +func (o *AddPayloadRuntimeACLDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add payload runtime ACL default response +func (o *AddPayloadRuntimeACLDefault) WithPayload(payload *models.Error) *AddPayloadRuntimeACLDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add payload runtime ACL default response +func (o *AddPayloadRuntimeACLDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddPayloadRuntimeACLDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl_runtime/add_payload_runtime_acl_urlbuilder.go b/operations/acl_runtime/add_payload_runtime_acl_urlbuilder.go new file mode 100644 index 00000000..f26f4ac6 --- /dev/null +++ b/operations/acl_runtime/add_payload_runtime_acl_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// AddPayloadRuntimeACLURL generates an URL for the add payload runtime ACL operation +type AddPayloadRuntimeACLURL struct { + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddPayloadRuntimeACLURL) WithBasePath(bp string) *AddPayloadRuntimeACLURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddPayloadRuntimeACLURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddPayloadRuntimeACLURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acls/{parent_name}/entries" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on AddPayloadRuntimeACLURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddPayloadRuntimeACLURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddPayloadRuntimeACLURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddPayloadRuntimeACLURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddPayloadRuntimeACLURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddPayloadRuntimeACLURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddPayloadRuntimeACLURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id.go b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id.go new file mode 100644 index 00000000..4ca8c776 --- /dev/null +++ b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc turns a function with the right signature into a delete services haproxy runtime acls parent name entries ID handler +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc func(DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc) Handle(params DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler interface for that can handle valid delete services haproxy runtime acls parent name entries ID params +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler interface { + Handle(DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams, interface{}) middleware.Responder +} + +// NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesID creates a new http.Handler for the delete services haproxy runtime acls parent name entries ID operation +func NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesID(ctx *middleware.Context, handler DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesID { + return &DeleteServicesHaproxyRuntimeAclsParentNameEntriesID{Context: ctx, Handler: handler} +} + +/* + DeleteServicesHaproxyRuntimeAclsParentNameEntriesID swagger:route DELETE /services/haproxy/runtime/acls/{parent_name}/entries/{id} ACL Runtime deleteServicesHaproxyRuntimeAclsParentNameEntriesId + +# Delete an ACL entry + +Deletes the entry from the ACL by its value using the runtime socket. +*/ +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesID struct { + Context *middleware.Context + Handler DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler +} + +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesID) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_parameters.go b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_parameters.go new file mode 100644 index 00000000..b621688c --- /dev/null +++ b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_parameters.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams creates a new DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams object +// +// There are no default values defined in the spec. +func NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams() DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams { + + return DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams{} +} + +// DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams contains all the bound params for the delete services haproxy runtime acls parent name entries ID operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteServicesHaproxyRuntimeAclsParentNameEntriesID +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*File entry ID + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams() beforehand. +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_responses.go b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_responses.go new file mode 100644 index 00000000..c98d4663 --- /dev/null +++ b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_responses.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContentCode is the HTTP code returned for type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent +const DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContentCode int = 204 + +/* +DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent Successful operation + +swagger:response deleteServicesHaproxyRuntimeAclsParentNameEntriesIdNoContent +*/ +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent struct { +} + +// NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent creates DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent with default headers values +func NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent() *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent { + + return &DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent{} +} + +// WriteResponse to the client +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequestCode is the HTTP code returned for type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest +const DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequestCode int = 400 + +/* +DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest Bad request + +swagger:response deleteServicesHaproxyRuntimeAclsParentNameEntriesIdBadRequest +*/ +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest creates DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest with default headers values +func NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest() *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest { + + return &DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete services haproxy runtime acls parent name entries Id bad request response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) WithConfigurationVersion(configurationVersion string) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete services haproxy runtime acls parent name entries Id bad request response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete services haproxy runtime acls parent name entries Id bad request response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) WithPayload(payload *models.Error) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete services haproxy runtime acls parent name entries Id bad request response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFoundCode is the HTTP code returned for type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound +const DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFoundCode int = 404 + +/* +DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound The specified resource was not found + +swagger:response deleteServicesHaproxyRuntimeAclsParentNameEntriesIdNotFound +*/ +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound creates DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound with default headers values +func NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound() *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound { + + return &DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete services haproxy runtime acls parent name entries Id not found response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) WithConfigurationVersion(configurationVersion string) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete services haproxy runtime acls parent name entries Id not found response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete services haproxy runtime acls parent name entries Id not found response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) WithPayload(payload *models.Error) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete services haproxy runtime acls parent name entries Id not found response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault General Error + +swagger:response deleteServicesHaproxyRuntimeAclsParentNameEntriesIdDefault +*/ +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault creates DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault with default headers values +func NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault(code int) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + if code <= 0 { + code = 500 + } + + return &DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete services haproxy runtime acls parent name entries ID default response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WithStatusCode(code int) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete services haproxy runtime acls parent name entries ID default response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete services haproxy runtime acls parent name entries ID default response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WithConfigurationVersion(configurationVersion string) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete services haproxy runtime acls parent name entries ID default response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete services haproxy runtime acls parent name entries ID default response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WithPayload(payload *models.Error) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete services haproxy runtime acls parent name entries ID default response +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_urlbuilder.go b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_urlbuilder.go new file mode 100644 index 00000000..33b14a42 --- /dev/null +++ b/operations/acl_runtime/delete_services_haproxy_runtime_acls_parent_name_entries_id_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL generates an URL for the delete services haproxy runtime acls parent name entries ID operation +type DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL struct { + ID string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL) WithBasePath(bp string) *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acls/{parent_name}/entries/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls.go b/operations/acl_runtime/get_services_haproxy_runtime_acls.go new file mode 100644 index 00000000..ba12d062 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServicesHaproxyRuntimeAclsHandlerFunc turns a function with the right signature into a get services haproxy runtime acls handler +type GetServicesHaproxyRuntimeAclsHandlerFunc func(GetServicesHaproxyRuntimeAclsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServicesHaproxyRuntimeAclsHandlerFunc) Handle(params GetServicesHaproxyRuntimeAclsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServicesHaproxyRuntimeAclsHandler interface for that can handle valid get services haproxy runtime acls params +type GetServicesHaproxyRuntimeAclsHandler interface { + Handle(GetServicesHaproxyRuntimeAclsParams, interface{}) middleware.Responder +} + +// NewGetServicesHaproxyRuntimeAcls creates a new http.Handler for the get services haproxy runtime acls operation +func NewGetServicesHaproxyRuntimeAcls(ctx *middleware.Context, handler GetServicesHaproxyRuntimeAclsHandler) *GetServicesHaproxyRuntimeAcls { + return &GetServicesHaproxyRuntimeAcls{Context: ctx, Handler: handler} +} + +/* + GetServicesHaproxyRuntimeAcls swagger:route GET /services/haproxy/runtime/acls ACL Runtime getServicesHaproxyRuntimeAcls + +# Return an array of all ACL files + +Returns all ACL files using the runtime socket. +*/ +type GetServicesHaproxyRuntimeAcls struct { + Context *middleware.Context + Handler GetServicesHaproxyRuntimeAclsHandler +} + +func (o *GetServicesHaproxyRuntimeAcls) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServicesHaproxyRuntimeAclsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_id.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_id.go new file mode 100644 index 00000000..b51bc51d --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_id.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServicesHaproxyRuntimeAclsIDHandlerFunc turns a function with the right signature into a get services haproxy runtime acls ID handler +type GetServicesHaproxyRuntimeAclsIDHandlerFunc func(GetServicesHaproxyRuntimeAclsIDParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServicesHaproxyRuntimeAclsIDHandlerFunc) Handle(params GetServicesHaproxyRuntimeAclsIDParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServicesHaproxyRuntimeAclsIDHandler interface for that can handle valid get services haproxy runtime acls ID params +type GetServicesHaproxyRuntimeAclsIDHandler interface { + Handle(GetServicesHaproxyRuntimeAclsIDParams, interface{}) middleware.Responder +} + +// NewGetServicesHaproxyRuntimeAclsID creates a new http.Handler for the get services haproxy runtime acls ID operation +func NewGetServicesHaproxyRuntimeAclsID(ctx *middleware.Context, handler GetServicesHaproxyRuntimeAclsIDHandler) *GetServicesHaproxyRuntimeAclsID { + return &GetServicesHaproxyRuntimeAclsID{Context: ctx, Handler: handler} +} + +/* + GetServicesHaproxyRuntimeAclsID swagger:route GET /services/haproxy/runtime/acls/{id} ACL Runtime getServicesHaproxyRuntimeAclsId + +# Return an ACL file + +Returns an ACL file by id using the runtime socket. +*/ +type GetServicesHaproxyRuntimeAclsID struct { + Context *middleware.Context + Handler GetServicesHaproxyRuntimeAclsIDHandler +} + +func (o *GetServicesHaproxyRuntimeAclsID) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServicesHaproxyRuntimeAclsIDParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_id_parameters.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_id_parameters.go new file mode 100644 index 00000000..e9dfc131 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_id_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServicesHaproxyRuntimeAclsIDParams creates a new GetServicesHaproxyRuntimeAclsIDParams object +// +// There are no default values defined in the spec. +func NewGetServicesHaproxyRuntimeAclsIDParams() GetServicesHaproxyRuntimeAclsIDParams { + + return GetServicesHaproxyRuntimeAclsIDParams{} +} + +// GetServicesHaproxyRuntimeAclsIDParams contains all the bound params for the get services haproxy runtime acls ID operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetServicesHaproxyRuntimeAclsID +type GetServicesHaproxyRuntimeAclsIDParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ACL file entry ID + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServicesHaproxyRuntimeAclsIDParams() beforehand. +func (o *GetServicesHaproxyRuntimeAclsIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetServicesHaproxyRuntimeAclsIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_id_responses.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_id_responses.go new file mode 100644 index 00000000..f228d6cf --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_id_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServicesHaproxyRuntimeAclsIDOKCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsIDOK +const GetServicesHaproxyRuntimeAclsIDOKCode int = 200 + +/* +GetServicesHaproxyRuntimeAclsIDOK Successful operation + +swagger:response getServicesHaproxyRuntimeAclsIdOK +*/ +type GetServicesHaproxyRuntimeAclsIDOK struct { + + /* + In: Body + */ + Payload *models.ACLFile `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsIDOK creates GetServicesHaproxyRuntimeAclsIDOK with default headers values +func NewGetServicesHaproxyRuntimeAclsIDOK() *GetServicesHaproxyRuntimeAclsIDOK { + + return &GetServicesHaproxyRuntimeAclsIDOK{} +} + +// WithPayload adds the payload to the get services haproxy runtime acls Id o k response +func (o *GetServicesHaproxyRuntimeAclsIDOK) WithPayload(payload *models.ACLFile) *GetServicesHaproxyRuntimeAclsIDOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls Id o k response +func (o *GetServicesHaproxyRuntimeAclsIDOK) SetPayload(payload *models.ACLFile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServicesHaproxyRuntimeAclsIDNotFoundCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsIDNotFound +const GetServicesHaproxyRuntimeAclsIDNotFoundCode int = 404 + +/* +GetServicesHaproxyRuntimeAclsIDNotFound The specified resource was not found + +swagger:response getServicesHaproxyRuntimeAclsIdNotFound +*/ +type GetServicesHaproxyRuntimeAclsIDNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsIDNotFound creates GetServicesHaproxyRuntimeAclsIDNotFound with default headers values +func NewGetServicesHaproxyRuntimeAclsIDNotFound() *GetServicesHaproxyRuntimeAclsIDNotFound { + + return &GetServicesHaproxyRuntimeAclsIDNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls Id not found response +func (o *GetServicesHaproxyRuntimeAclsIDNotFound) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsIDNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls Id not found response +func (o *GetServicesHaproxyRuntimeAclsIDNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls Id not found response +func (o *GetServicesHaproxyRuntimeAclsIDNotFound) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsIDNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls Id not found response +func (o *GetServicesHaproxyRuntimeAclsIDNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetServicesHaproxyRuntimeAclsIDDefault General Error + +swagger:response getServicesHaproxyRuntimeAclsIdDefault +*/ +type GetServicesHaproxyRuntimeAclsIDDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsIDDefault creates GetServicesHaproxyRuntimeAclsIDDefault with default headers values +func NewGetServicesHaproxyRuntimeAclsIDDefault(code int) *GetServicesHaproxyRuntimeAclsIDDefault { + if code <= 0 { + code = 500 + } + + return &GetServicesHaproxyRuntimeAclsIDDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get services haproxy runtime acls ID default response +func (o *GetServicesHaproxyRuntimeAclsIDDefault) WithStatusCode(code int) *GetServicesHaproxyRuntimeAclsIDDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get services haproxy runtime acls ID default response +func (o *GetServicesHaproxyRuntimeAclsIDDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls ID default response +func (o *GetServicesHaproxyRuntimeAclsIDDefault) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsIDDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls ID default response +func (o *GetServicesHaproxyRuntimeAclsIDDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls ID default response +func (o *GetServicesHaproxyRuntimeAclsIDDefault) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsIDDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls ID default response +func (o *GetServicesHaproxyRuntimeAclsIDDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_id_urlbuilder.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_id_urlbuilder.go new file mode 100644 index 00000000..a9366eda --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_id_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServicesHaproxyRuntimeAclsIDURL generates an URL for the get services haproxy runtime acls ID operation +type GetServicesHaproxyRuntimeAclsIDURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsIDURL) WithBasePath(bp string) *GetServicesHaproxyRuntimeAclsIDURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsIDURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServicesHaproxyRuntimeAclsIDURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acls/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetServicesHaproxyRuntimeAclsIDURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServicesHaproxyRuntimeAclsIDURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServicesHaproxyRuntimeAclsIDURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServicesHaproxyRuntimeAclsIDURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServicesHaproxyRuntimeAclsIDURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServicesHaproxyRuntimeAclsIDURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServicesHaproxyRuntimeAclsIDURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parameters.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parameters.go new file mode 100644 index 00000000..e86f8cc9 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetServicesHaproxyRuntimeAclsParams creates a new GetServicesHaproxyRuntimeAclsParams object +// +// There are no default values defined in the spec. +func NewGetServicesHaproxyRuntimeAclsParams() GetServicesHaproxyRuntimeAclsParams { + + return GetServicesHaproxyRuntimeAclsParams{} +} + +// GetServicesHaproxyRuntimeAclsParams contains all the bound params for the get services haproxy runtime acls operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetServicesHaproxyRuntimeAcls +type GetServicesHaproxyRuntimeAclsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServicesHaproxyRuntimeAclsParams() beforehand. +func (o *GetServicesHaproxyRuntimeAclsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries.go new file mode 100644 index 00000000..e493bd92 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc turns a function with the right signature into a get services haproxy runtime acls parent name entries handler +type GetServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc func(GetServicesHaproxyRuntimeAclsParentNameEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc) Handle(params GetServicesHaproxyRuntimeAclsParentNameEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesHandler interface for that can handle valid get services haproxy runtime acls parent name entries params +type GetServicesHaproxyRuntimeAclsParentNameEntriesHandler interface { + Handle(GetServicesHaproxyRuntimeAclsParentNameEntriesParams, interface{}) middleware.Responder +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntries creates a new http.Handler for the get services haproxy runtime acls parent name entries operation +func NewGetServicesHaproxyRuntimeAclsParentNameEntries(ctx *middleware.Context, handler GetServicesHaproxyRuntimeAclsParentNameEntriesHandler) *GetServicesHaproxyRuntimeAclsParentNameEntries { + return &GetServicesHaproxyRuntimeAclsParentNameEntries{Context: ctx, Handler: handler} +} + +/* + GetServicesHaproxyRuntimeAclsParentNameEntries swagger:route GET /services/haproxy/runtime/acls/{parent_name}/entries ACL Runtime getServicesHaproxyRuntimeAclsParentNameEntries + +# Return an ACL entries + +Returns an ACL runtime setting using the runtime socket. +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntries struct { + Context *middleware.Context + Handler GetServicesHaproxyRuntimeAclsParentNameEntriesHandler +} + +func (o *GetServicesHaproxyRuntimeAclsParentNameEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServicesHaproxyRuntimeAclsParentNameEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id.go new file mode 100644 index 00000000..fc8f393b --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc turns a function with the right signature into a get services haproxy runtime acls parent name entries ID handler +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc func(GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc) Handle(params GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler interface for that can handle valid get services haproxy runtime acls parent name entries ID params +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler interface { + Handle(GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams, interface{}) middleware.Responder +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesID creates a new http.Handler for the get services haproxy runtime acls parent name entries ID operation +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesID(ctx *middleware.Context, handler GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler) *GetServicesHaproxyRuntimeAclsParentNameEntriesID { + return &GetServicesHaproxyRuntimeAclsParentNameEntriesID{Context: ctx, Handler: handler} +} + +/* + GetServicesHaproxyRuntimeAclsParentNameEntriesID swagger:route GET /services/haproxy/runtime/acls/{parent_name}/entries/{id} ACL Runtime getServicesHaproxyRuntimeAclsParentNameEntriesId + +# Return an ACL entry + +Returns the ACL entry by its ID using the runtime socket. +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesID struct { + Context *middleware.Context + Handler GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler +} + +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesID) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_parameters.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_parameters.go new file mode 100644 index 00000000..d8e86e8e --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_parameters.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDParams creates a new GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams object +// +// There are no default values defined in the spec. +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDParams() GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams { + + return GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams{} +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams contains all the bound params for the get services haproxy runtime acls parent name entries ID operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetServicesHaproxyRuntimeAclsParentNameEntriesID +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*File entry ID + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDParams() beforehand. +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_responses.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_responses.go new file mode 100644 index 00000000..9ff92249 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServicesHaproxyRuntimeAclsParentNameEntriesIDOKCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK +const GetServicesHaproxyRuntimeAclsParentNameEntriesIDOKCode int = 200 + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK Successful operation + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesIdOK +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK struct { + + /* + In: Body + */ + Payload *models.ACLFileEntry `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDOK creates GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDOK() *GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK { + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK{} +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries Id o k response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK) WithPayload(payload *models.ACLFileEntry) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries Id o k response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK) SetPayload(payload *models.ACLFileEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequestCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest +const GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequestCode int = 400 + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest Bad request + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesIdBadRequest +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest creates GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest() *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest { + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls parent name entries Id bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls parent name entries Id bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries Id bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries Id bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFoundCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound +const GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFoundCode int = 404 + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound The specified resource was not found + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesIdNotFound +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound creates GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound() *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound { + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls parent name entries Id not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls parent name entries Id not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries Id not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries Id not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault General Error + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesIdDefault +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault creates GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault(code int) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + if code <= 0 { + code = 500 + } + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get services haproxy runtime acls parent name entries ID default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WithStatusCode(code int) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get services haproxy runtime acls parent name entries ID default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls parent name entries ID default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls parent name entries ID default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries ID default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries ID default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_urlbuilder.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_urlbuilder.go new file mode 100644 index 00000000..fbe19135 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_id_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL generates an URL for the get services haproxy runtime acls parent name entries ID operation +type GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL struct { + ID string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL) WithBasePath(bp string) *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acls/{parent_name}/entries/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesIDURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_parameters.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_parameters.go new file mode 100644 index 00000000..db8ee71b --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesParams creates a new GetServicesHaproxyRuntimeAclsParentNameEntriesParams object +// +// There are no default values defined in the spec. +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesParams() GetServicesHaproxyRuntimeAclsParentNameEntriesParams { + + return GetServicesHaproxyRuntimeAclsParentNameEntriesParams{} +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesParams contains all the bound params for the get services haproxy runtime acls parent name entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetServicesHaproxyRuntimeAclsParentNameEntries +type GetServicesHaproxyRuntimeAclsParentNameEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServicesHaproxyRuntimeAclsParentNameEntriesParams() beforehand. +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_responses.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_responses.go new file mode 100644 index 00000000..67bfd627 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_responses.go @@ -0,0 +1,292 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServicesHaproxyRuntimeAclsParentNameEntriesOKCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsParentNameEntriesOK +const GetServicesHaproxyRuntimeAclsParentNameEntriesOKCode int = 200 + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesOK Successful operation + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesOK +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesOK struct { + + /* + In: Body + */ + Payload models.ACLFilesEntries `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesOK creates GetServicesHaproxyRuntimeAclsParentNameEntriesOK with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesOK() *GetServicesHaproxyRuntimeAclsParentNameEntriesOK { + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesOK{} +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries o k response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesOK) WithPayload(payload models.ACLFilesEntries) *GetServicesHaproxyRuntimeAclsParentNameEntriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries o k response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesOK) SetPayload(payload models.ACLFilesEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.ACLFilesEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequestCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest +const GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequestCode int = 400 + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest Bad request + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesBadRequest +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest creates GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest() *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest { + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls parent name entries bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls parent name entries bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries bad request response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServicesHaproxyRuntimeAclsParentNameEntriesNotFoundCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound +const GetServicesHaproxyRuntimeAclsParentNameEntriesNotFoundCode int = 404 + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound The specified resource was not found + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesNotFound +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesNotFound creates GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesNotFound() *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound { + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls parent name entries not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls parent name entries not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries not found response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetServicesHaproxyRuntimeAclsParentNameEntriesDefault General Error + +swagger:response getServicesHaproxyRuntimeAclsParentNameEntriesDefault +*/ +type GetServicesHaproxyRuntimeAclsParentNameEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsParentNameEntriesDefault creates GetServicesHaproxyRuntimeAclsParentNameEntriesDefault with default headers values +func NewGetServicesHaproxyRuntimeAclsParentNameEntriesDefault(code int) *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault { + if code <= 0 { + code = 500 + } + + return &GetServicesHaproxyRuntimeAclsParentNameEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get services haproxy runtime acls parent name entries default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault) WithStatusCode(code int) *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get services haproxy runtime acls parent name entries default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls parent name entries default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls parent name entries default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls parent name entries default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls parent name entries default response +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_urlbuilder.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_urlbuilder.go new file mode 100644 index 00000000..1e5d05be --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_parent_name_entries_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServicesHaproxyRuntimeAclsParentNameEntriesURL generates an URL for the get services haproxy runtime acls parent name entries operation +type GetServicesHaproxyRuntimeAclsParentNameEntriesURL struct { + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesURL) WithBasePath(bp string) *GetServicesHaproxyRuntimeAclsParentNameEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acls/{parent_name}/entries" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServicesHaproxyRuntimeAclsParentNameEntriesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServicesHaproxyRuntimeAclsParentNameEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServicesHaproxyRuntimeAclsParentNameEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServicesHaproxyRuntimeAclsParentNameEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_responses.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_responses.go new file mode 100644 index 00000000..21a6f7fa --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServicesHaproxyRuntimeAclsOKCode is the HTTP code returned for type GetServicesHaproxyRuntimeAclsOK +const GetServicesHaproxyRuntimeAclsOKCode int = 200 + +/* +GetServicesHaproxyRuntimeAclsOK Successful operation + +swagger:response getServicesHaproxyRuntimeAclsOK +*/ +type GetServicesHaproxyRuntimeAclsOK struct { + + /* + In: Body + */ + Payload models.ACLFiles `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsOK creates GetServicesHaproxyRuntimeAclsOK with default headers values +func NewGetServicesHaproxyRuntimeAclsOK() *GetServicesHaproxyRuntimeAclsOK { + + return &GetServicesHaproxyRuntimeAclsOK{} +} + +// WithPayload adds the payload to the get services haproxy runtime acls o k response +func (o *GetServicesHaproxyRuntimeAclsOK) WithPayload(payload models.ACLFiles) *GetServicesHaproxyRuntimeAclsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls o k response +func (o *GetServicesHaproxyRuntimeAclsOK) SetPayload(payload models.ACLFiles) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.ACLFiles{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetServicesHaproxyRuntimeAclsDefault General Error + +swagger:response getServicesHaproxyRuntimeAclsDefault +*/ +type GetServicesHaproxyRuntimeAclsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServicesHaproxyRuntimeAclsDefault creates GetServicesHaproxyRuntimeAclsDefault with default headers values +func NewGetServicesHaproxyRuntimeAclsDefault(code int) *GetServicesHaproxyRuntimeAclsDefault { + if code <= 0 { + code = 500 + } + + return &GetServicesHaproxyRuntimeAclsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get services haproxy runtime acls default response +func (o *GetServicesHaproxyRuntimeAclsDefault) WithStatusCode(code int) *GetServicesHaproxyRuntimeAclsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get services haproxy runtime acls default response +func (o *GetServicesHaproxyRuntimeAclsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get services haproxy runtime acls default response +func (o *GetServicesHaproxyRuntimeAclsDefault) WithConfigurationVersion(configurationVersion string) *GetServicesHaproxyRuntimeAclsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get services haproxy runtime acls default response +func (o *GetServicesHaproxyRuntimeAclsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get services haproxy runtime acls default response +func (o *GetServicesHaproxyRuntimeAclsDefault) WithPayload(payload *models.Error) *GetServicesHaproxyRuntimeAclsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get services haproxy runtime acls default response +func (o *GetServicesHaproxyRuntimeAclsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServicesHaproxyRuntimeAclsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl_runtime/get_services_haproxy_runtime_acls_urlbuilder.go b/operations/acl_runtime/get_services_haproxy_runtime_acls_urlbuilder.go new file mode 100644 index 00000000..71e33e09 --- /dev/null +++ b/operations/acl_runtime/get_services_haproxy_runtime_acls_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetServicesHaproxyRuntimeAclsURL generates an URL for the get services haproxy runtime acls operation +type GetServicesHaproxyRuntimeAclsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsURL) WithBasePath(bp string) *GetServicesHaproxyRuntimeAclsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServicesHaproxyRuntimeAclsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServicesHaproxyRuntimeAclsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acls" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServicesHaproxyRuntimeAclsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServicesHaproxyRuntimeAclsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServicesHaproxyRuntimeAclsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServicesHaproxyRuntimeAclsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServicesHaproxyRuntimeAclsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServicesHaproxyRuntimeAclsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries.go b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries.go new file mode 100644 index 00000000..d330221d --- /dev/null +++ b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PostServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc turns a function with the right signature into a post services haproxy runtime acls parent name entries handler +type PostServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc func(PostServicesHaproxyRuntimeAclsParentNameEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc) Handle(params PostServicesHaproxyRuntimeAclsParentNameEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PostServicesHaproxyRuntimeAclsParentNameEntriesHandler interface for that can handle valid post services haproxy runtime acls parent name entries params +type PostServicesHaproxyRuntimeAclsParentNameEntriesHandler interface { + Handle(PostServicesHaproxyRuntimeAclsParentNameEntriesParams, interface{}) middleware.Responder +} + +// NewPostServicesHaproxyRuntimeAclsParentNameEntries creates a new http.Handler for the post services haproxy runtime acls parent name entries operation +func NewPostServicesHaproxyRuntimeAclsParentNameEntries(ctx *middleware.Context, handler PostServicesHaproxyRuntimeAclsParentNameEntriesHandler) *PostServicesHaproxyRuntimeAclsParentNameEntries { + return &PostServicesHaproxyRuntimeAclsParentNameEntries{Context: ctx, Handler: handler} +} + +/* + PostServicesHaproxyRuntimeAclsParentNameEntries swagger:route POST /services/haproxy/runtime/acls/{parent_name}/entries ACL Runtime postServicesHaproxyRuntimeAclsParentNameEntries + +# Add entry to an ACL file + +Adds an entry into the ACL file using the runtime socket. +*/ +type PostServicesHaproxyRuntimeAclsParentNameEntries struct { + Context *middleware.Context + Handler PostServicesHaproxyRuntimeAclsParentNameEntriesHandler +} + +func (o *PostServicesHaproxyRuntimeAclsParentNameEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostServicesHaproxyRuntimeAclsParentNameEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_parameters.go b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_parameters.go new file mode 100644 index 00000000..ec3501af --- /dev/null +++ b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_parameters.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewPostServicesHaproxyRuntimeAclsParentNameEntriesParams creates a new PostServicesHaproxyRuntimeAclsParentNameEntriesParams object +// +// There are no default values defined in the spec. +func NewPostServicesHaproxyRuntimeAclsParentNameEntriesParams() PostServicesHaproxyRuntimeAclsParentNameEntriesParams { + + return PostServicesHaproxyRuntimeAclsParentNameEntriesParams{} +} + +// PostServicesHaproxyRuntimeAclsParentNameEntriesParams contains all the bound params for the post services haproxy runtime acls parent name entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostServicesHaproxyRuntimeAclsParentNameEntries +type PostServicesHaproxyRuntimeAclsParentNameEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ACLFileEntry + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostServicesHaproxyRuntimeAclsParentNameEntriesParams() beforehand. +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ACLFileEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_responses.go b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_responses.go new file mode 100644 index 00000000..d8955a19 --- /dev/null +++ b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// PostServicesHaproxyRuntimeAclsParentNameEntriesCreatedCode is the HTTP code returned for type PostServicesHaproxyRuntimeAclsParentNameEntriesCreated +const PostServicesHaproxyRuntimeAclsParentNameEntriesCreatedCode int = 201 + +/* +PostServicesHaproxyRuntimeAclsParentNameEntriesCreated ACL entry created + +swagger:response postServicesHaproxyRuntimeAclsParentNameEntriesCreated +*/ +type PostServicesHaproxyRuntimeAclsParentNameEntriesCreated struct { + + /* + In: Body + */ + Payload *models.ACLFileEntry `json:"body,omitempty"` +} + +// NewPostServicesHaproxyRuntimeAclsParentNameEntriesCreated creates PostServicesHaproxyRuntimeAclsParentNameEntriesCreated with default headers values +func NewPostServicesHaproxyRuntimeAclsParentNameEntriesCreated() *PostServicesHaproxyRuntimeAclsParentNameEntriesCreated { + + return &PostServicesHaproxyRuntimeAclsParentNameEntriesCreated{} +} + +// WithPayload adds the payload to the post services haproxy runtime acls parent name entries created response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesCreated) WithPayload(payload *models.ACLFileEntry) *PostServicesHaproxyRuntimeAclsParentNameEntriesCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post services haproxy runtime acls parent name entries created response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesCreated) SetPayload(payload *models.ACLFileEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequestCode is the HTTP code returned for type PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest +const PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequestCode int = 400 + +/* +PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest Bad request + +swagger:response postServicesHaproxyRuntimeAclsParentNameEntriesBadRequest +*/ +type PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest creates PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest with default headers values +func NewPostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest() *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest { + + return &PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the post services haproxy runtime acls parent name entries bad request response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) WithConfigurationVersion(configurationVersion string) *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the post services haproxy runtime acls parent name entries bad request response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the post services haproxy runtime acls parent name entries bad request response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) WithPayload(payload *models.Error) *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post services haproxy runtime acls parent name entries bad request response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostServicesHaproxyRuntimeAclsParentNameEntriesConflictCode is the HTTP code returned for type PostServicesHaproxyRuntimeAclsParentNameEntriesConflict +const PostServicesHaproxyRuntimeAclsParentNameEntriesConflictCode int = 409 + +/* +PostServicesHaproxyRuntimeAclsParentNameEntriesConflict The specified resource already exists + +swagger:response postServicesHaproxyRuntimeAclsParentNameEntriesConflict +*/ +type PostServicesHaproxyRuntimeAclsParentNameEntriesConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostServicesHaproxyRuntimeAclsParentNameEntriesConflict creates PostServicesHaproxyRuntimeAclsParentNameEntriesConflict with default headers values +func NewPostServicesHaproxyRuntimeAclsParentNameEntriesConflict() *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict { + + return &PostServicesHaproxyRuntimeAclsParentNameEntriesConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the post services haproxy runtime acls parent name entries conflict response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict) WithConfigurationVersion(configurationVersion string) *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the post services haproxy runtime acls parent name entries conflict response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the post services haproxy runtime acls parent name entries conflict response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict) WithPayload(payload *models.Error) *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post services haproxy runtime acls parent name entries conflict response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +PostServicesHaproxyRuntimeAclsParentNameEntriesDefault General Error + +swagger:response postServicesHaproxyRuntimeAclsParentNameEntriesDefault +*/ +type PostServicesHaproxyRuntimeAclsParentNameEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostServicesHaproxyRuntimeAclsParentNameEntriesDefault creates PostServicesHaproxyRuntimeAclsParentNameEntriesDefault with default headers values +func NewPostServicesHaproxyRuntimeAclsParentNameEntriesDefault(code int) *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault { + if code <= 0 { + code = 500 + } + + return &PostServicesHaproxyRuntimeAclsParentNameEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the post services haproxy runtime acls parent name entries default response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault) WithStatusCode(code int) *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the post services haproxy runtime acls parent name entries default response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the post services haproxy runtime acls parent name entries default response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault) WithConfigurationVersion(configurationVersion string) *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the post services haproxy runtime acls parent name entries default response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the post services haproxy runtime acls parent name entries default response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault) WithPayload(payload *models.Error) *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post services haproxy runtime acls parent name entries default response +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_urlbuilder.go b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_urlbuilder.go new file mode 100644 index 00000000..2b3e46f9 --- /dev/null +++ b/operations/acl_runtime/post_services_haproxy_runtime_acls_parent_name_entries_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acl_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// PostServicesHaproxyRuntimeAclsParentNameEntriesURL generates an URL for the post services haproxy runtime acls parent name entries operation +type PostServicesHaproxyRuntimeAclsParentNameEntriesURL struct { + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesURL) WithBasePath(bp string) *PostServicesHaproxyRuntimeAclsParentNameEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acls/{parent_name}/entries" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on PostServicesHaproxyRuntimeAclsParentNameEntriesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostServicesHaproxyRuntimeAclsParentNameEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostServicesHaproxyRuntimeAclsParentNameEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PostServicesHaproxyRuntimeAclsParentNameEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acme/create_acme_provider.go b/operations/acme/create_acme_provider.go new file mode 100644 index 00000000..abfc2954 --- /dev/null +++ b/operations/acme/create_acme_provider.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateAcmeProviderHandlerFunc turns a function with the right signature into a create acme provider handler +type CreateAcmeProviderHandlerFunc func(CreateAcmeProviderParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateAcmeProviderHandlerFunc) Handle(params CreateAcmeProviderParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateAcmeProviderHandler interface for that can handle valid create acme provider params +type CreateAcmeProviderHandler interface { + Handle(CreateAcmeProviderParams, interface{}) middleware.Responder +} + +// NewCreateAcmeProvider creates a new http.Handler for the create acme provider operation +func NewCreateAcmeProvider(ctx *middleware.Context, handler CreateAcmeProviderHandler) *CreateAcmeProvider { + return &CreateAcmeProvider{Context: ctx, Handler: handler} +} + +/* + CreateAcmeProvider swagger:route POST /services/haproxy/configuration/acme Acme createAcmeProvider + +# Add a new Acme provider + +Creates a new acme section +*/ +type CreateAcmeProvider struct { + Context *middleware.Context + Handler CreateAcmeProviderHandler +} + +func (o *CreateAcmeProvider) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateAcmeProviderParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acme/create_acme_provider_parameters.go b/operations/acme/create_acme_provider_parameters.go new file mode 100644 index 00000000..41a47b62 --- /dev/null +++ b/operations/acme/create_acme_provider_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateAcmeProviderParams creates a new CreateAcmeProviderParams object +// with the default values initialized. +func NewCreateAcmeProviderParams() CreateAcmeProviderParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateAcmeProviderParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateAcmeProviderParams contains all the bound params for the create acme provider operation +// typically these are obtained from a http.Request +// +// swagger:parameters createAcmeProvider +type CreateAcmeProviderParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.AcmeProvider + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateAcmeProviderParams() beforehand. +func (o *CreateAcmeProviderParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.AcmeProvider + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateAcmeProviderParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateAcmeProviderParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateAcmeProviderParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateAcmeProviderParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acme/create_acme_provider_responses.go b/operations/acme/create_acme_provider_responses.go new file mode 100644 index 00000000..ffd4395b --- /dev/null +++ b/operations/acme/create_acme_provider_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateAcmeProviderCreatedCode is the HTTP code returned for type CreateAcmeProviderCreated +const CreateAcmeProviderCreatedCode int = 201 + +/* +CreateAcmeProviderCreated Log Profile created + +swagger:response createAcmeProviderCreated +*/ +type CreateAcmeProviderCreated struct { + + /* + In: Body + */ + Payload *models.AcmeProvider `json:"body,omitempty"` +} + +// NewCreateAcmeProviderCreated creates CreateAcmeProviderCreated with default headers values +func NewCreateAcmeProviderCreated() *CreateAcmeProviderCreated { + + return &CreateAcmeProviderCreated{} +} + +// WithPayload adds the payload to the create acme provider created response +func (o *CreateAcmeProviderCreated) WithPayload(payload *models.AcmeProvider) *CreateAcmeProviderCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create acme provider created response +func (o *CreateAcmeProviderCreated) SetPayload(payload *models.AcmeProvider) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAcmeProviderCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateAcmeProviderAcceptedCode is the HTTP code returned for type CreateAcmeProviderAccepted +const CreateAcmeProviderAcceptedCode int = 202 + +/* +CreateAcmeProviderAccepted Configuration change accepted and reload requested + +swagger:response createAcmeProviderAccepted +*/ +type CreateAcmeProviderAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.AcmeProvider `json:"body,omitempty"` +} + +// NewCreateAcmeProviderAccepted creates CreateAcmeProviderAccepted with default headers values +func NewCreateAcmeProviderAccepted() *CreateAcmeProviderAccepted { + + return &CreateAcmeProviderAccepted{} +} + +// WithReloadID adds the reloadId to the create acme provider accepted response +func (o *CreateAcmeProviderAccepted) WithReloadID(reloadID string) *CreateAcmeProviderAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create acme provider accepted response +func (o *CreateAcmeProviderAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create acme provider accepted response +func (o *CreateAcmeProviderAccepted) WithPayload(payload *models.AcmeProvider) *CreateAcmeProviderAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create acme provider accepted response +func (o *CreateAcmeProviderAccepted) SetPayload(payload *models.AcmeProvider) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAcmeProviderAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateAcmeProviderBadRequestCode is the HTTP code returned for type CreateAcmeProviderBadRequest +const CreateAcmeProviderBadRequestCode int = 400 + +/* +CreateAcmeProviderBadRequest Bad request + +swagger:response createAcmeProviderBadRequest +*/ +type CreateAcmeProviderBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateAcmeProviderBadRequest creates CreateAcmeProviderBadRequest with default headers values +func NewCreateAcmeProviderBadRequest() *CreateAcmeProviderBadRequest { + + return &CreateAcmeProviderBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create acme provider bad request response +func (o *CreateAcmeProviderBadRequest) WithConfigurationVersion(configurationVersion string) *CreateAcmeProviderBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create acme provider bad request response +func (o *CreateAcmeProviderBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create acme provider bad request response +func (o *CreateAcmeProviderBadRequest) WithPayload(payload *models.Error) *CreateAcmeProviderBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create acme provider bad request response +func (o *CreateAcmeProviderBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAcmeProviderBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateAcmeProviderConflictCode is the HTTP code returned for type CreateAcmeProviderConflict +const CreateAcmeProviderConflictCode int = 409 + +/* +CreateAcmeProviderConflict The specified resource already exists + +swagger:response createAcmeProviderConflict +*/ +type CreateAcmeProviderConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateAcmeProviderConflict creates CreateAcmeProviderConflict with default headers values +func NewCreateAcmeProviderConflict() *CreateAcmeProviderConflict { + + return &CreateAcmeProviderConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create acme provider conflict response +func (o *CreateAcmeProviderConflict) WithConfigurationVersion(configurationVersion string) *CreateAcmeProviderConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create acme provider conflict response +func (o *CreateAcmeProviderConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create acme provider conflict response +func (o *CreateAcmeProviderConflict) WithPayload(payload *models.Error) *CreateAcmeProviderConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create acme provider conflict response +func (o *CreateAcmeProviderConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAcmeProviderConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateAcmeProviderDefault General Error + +swagger:response createAcmeProviderDefault +*/ +type CreateAcmeProviderDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateAcmeProviderDefault creates CreateAcmeProviderDefault with default headers values +func NewCreateAcmeProviderDefault(code int) *CreateAcmeProviderDefault { + if code <= 0 { + code = 500 + } + + return &CreateAcmeProviderDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create acme provider default response +func (o *CreateAcmeProviderDefault) WithStatusCode(code int) *CreateAcmeProviderDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create acme provider default response +func (o *CreateAcmeProviderDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create acme provider default response +func (o *CreateAcmeProviderDefault) WithConfigurationVersion(configurationVersion string) *CreateAcmeProviderDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create acme provider default response +func (o *CreateAcmeProviderDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create acme provider default response +func (o *CreateAcmeProviderDefault) WithPayload(payload *models.Error) *CreateAcmeProviderDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create acme provider default response +func (o *CreateAcmeProviderDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAcmeProviderDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acme/create_acme_provider_urlbuilder.go b/operations/acme/create_acme_provider_urlbuilder.go new file mode 100644 index 00000000..cca4d10b --- /dev/null +++ b/operations/acme/create_acme_provider_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateAcmeProviderURL generates an URL for the create acme provider operation +type CreateAcmeProviderURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateAcmeProviderURL) WithBasePath(bp string) *CreateAcmeProviderURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateAcmeProviderURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateAcmeProviderURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/acme" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateAcmeProviderURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateAcmeProviderURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateAcmeProviderURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateAcmeProviderURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateAcmeProviderURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateAcmeProviderURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acme/delete_acme_provider.go b/operations/acme/delete_acme_provider.go new file mode 100644 index 00000000..a49c2c48 --- /dev/null +++ b/operations/acme/delete_acme_provider.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteAcmeProviderHandlerFunc turns a function with the right signature into a delete acme provider handler +type DeleteAcmeProviderHandlerFunc func(DeleteAcmeProviderParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteAcmeProviderHandlerFunc) Handle(params DeleteAcmeProviderParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteAcmeProviderHandler interface for that can handle valid delete acme provider params +type DeleteAcmeProviderHandler interface { + Handle(DeleteAcmeProviderParams, interface{}) middleware.Responder +} + +// NewDeleteAcmeProvider creates a new http.Handler for the delete acme provider operation +func NewDeleteAcmeProvider(ctx *middleware.Context, handler DeleteAcmeProviderHandler) *DeleteAcmeProvider { + return &DeleteAcmeProvider{Context: ctx, Handler: handler} +} + +/* + DeleteAcmeProvider swagger:route DELETE /services/haproxy/configuration/acme/{name} Acme deleteAcmeProvider + +# Delete an ACME provider + +Deletes an acme section from the configuration +*/ +type DeleteAcmeProvider struct { + Context *middleware.Context + Handler DeleteAcmeProviderHandler +} + +func (o *DeleteAcmeProvider) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteAcmeProviderParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acme/delete_acme_provider_parameters.go b/operations/acme/delete_acme_provider_parameters.go new file mode 100644 index 00000000..c8b6041d --- /dev/null +++ b/operations/acme/delete_acme_provider_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteAcmeProviderParams creates a new DeleteAcmeProviderParams object +// with the default values initialized. +func NewDeleteAcmeProviderParams() DeleteAcmeProviderParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteAcmeProviderParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteAcmeProviderParams contains all the bound params for the delete acme provider operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteAcmeProvider +type DeleteAcmeProviderParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*acme section name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteAcmeProviderParams() beforehand. +func (o *DeleteAcmeProviderParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteAcmeProviderParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteAcmeProviderParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteAcmeProviderParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteAcmeProviderParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteAcmeProviderParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acme/delete_acme_provider_responses.go b/operations/acme/delete_acme_provider_responses.go new file mode 100644 index 00000000..bdc6e894 --- /dev/null +++ b/operations/acme/delete_acme_provider_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteAcmeProviderAcceptedCode is the HTTP code returned for type DeleteAcmeProviderAccepted +const DeleteAcmeProviderAcceptedCode int = 202 + +/* +DeleteAcmeProviderAccepted Configuration change accepted and reload requested + +swagger:response deleteAcmeProviderAccepted +*/ +type DeleteAcmeProviderAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteAcmeProviderAccepted creates DeleteAcmeProviderAccepted with default headers values +func NewDeleteAcmeProviderAccepted() *DeleteAcmeProviderAccepted { + + return &DeleteAcmeProviderAccepted{} +} + +// WithReloadID adds the reloadId to the delete acme provider accepted response +func (o *DeleteAcmeProviderAccepted) WithReloadID(reloadID string) *DeleteAcmeProviderAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete acme provider accepted response +func (o *DeleteAcmeProviderAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteAcmeProviderAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteAcmeProviderNoContentCode is the HTTP code returned for type DeleteAcmeProviderNoContent +const DeleteAcmeProviderNoContentCode int = 204 + +/* +DeleteAcmeProviderNoContent acme provider deleted + +swagger:response deleteAcmeProviderNoContent +*/ +type DeleteAcmeProviderNoContent struct { +} + +// NewDeleteAcmeProviderNoContent creates DeleteAcmeProviderNoContent with default headers values +func NewDeleteAcmeProviderNoContent() *DeleteAcmeProviderNoContent { + + return &DeleteAcmeProviderNoContent{} +} + +// WriteResponse to the client +func (o *DeleteAcmeProviderNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteAcmeProviderNotFoundCode is the HTTP code returned for type DeleteAcmeProviderNotFound +const DeleteAcmeProviderNotFoundCode int = 404 + +/* +DeleteAcmeProviderNotFound The specified resource was not found + +swagger:response deleteAcmeProviderNotFound +*/ +type DeleteAcmeProviderNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteAcmeProviderNotFound creates DeleteAcmeProviderNotFound with default headers values +func NewDeleteAcmeProviderNotFound() *DeleteAcmeProviderNotFound { + + return &DeleteAcmeProviderNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete acme provider not found response +func (o *DeleteAcmeProviderNotFound) WithConfigurationVersion(configurationVersion string) *DeleteAcmeProviderNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete acme provider not found response +func (o *DeleteAcmeProviderNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete acme provider not found response +func (o *DeleteAcmeProviderNotFound) WithPayload(payload *models.Error) *DeleteAcmeProviderNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete acme provider not found response +func (o *DeleteAcmeProviderNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteAcmeProviderNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteAcmeProviderDefault General Error + +swagger:response deleteAcmeProviderDefault +*/ +type DeleteAcmeProviderDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteAcmeProviderDefault creates DeleteAcmeProviderDefault with default headers values +func NewDeleteAcmeProviderDefault(code int) *DeleteAcmeProviderDefault { + if code <= 0 { + code = 500 + } + + return &DeleteAcmeProviderDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete acme provider default response +func (o *DeleteAcmeProviderDefault) WithStatusCode(code int) *DeleteAcmeProviderDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete acme provider default response +func (o *DeleteAcmeProviderDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete acme provider default response +func (o *DeleteAcmeProviderDefault) WithConfigurationVersion(configurationVersion string) *DeleteAcmeProviderDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete acme provider default response +func (o *DeleteAcmeProviderDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete acme provider default response +func (o *DeleteAcmeProviderDefault) WithPayload(payload *models.Error) *DeleteAcmeProviderDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete acme provider default response +func (o *DeleteAcmeProviderDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteAcmeProviderDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acme/delete_acme_provider_urlbuilder.go b/operations/acme/delete_acme_provider_urlbuilder.go new file mode 100644 index 00000000..b046f052 --- /dev/null +++ b/operations/acme/delete_acme_provider_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteAcmeProviderURL generates an URL for the delete acme provider operation +type DeleteAcmeProviderURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteAcmeProviderURL) WithBasePath(bp string) *DeleteAcmeProviderURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteAcmeProviderURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteAcmeProviderURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/acme/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteAcmeProviderURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteAcmeProviderURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteAcmeProviderURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteAcmeProviderURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteAcmeProviderURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteAcmeProviderURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteAcmeProviderURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acme/edit_acme_provider.go b/operations/acme/edit_acme_provider.go new file mode 100644 index 00000000..95d9c6b6 --- /dev/null +++ b/operations/acme/edit_acme_provider.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// EditAcmeProviderHandlerFunc turns a function with the right signature into a edit acme provider handler +type EditAcmeProviderHandlerFunc func(EditAcmeProviderParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn EditAcmeProviderHandlerFunc) Handle(params EditAcmeProviderParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// EditAcmeProviderHandler interface for that can handle valid edit acme provider params +type EditAcmeProviderHandler interface { + Handle(EditAcmeProviderParams, interface{}) middleware.Responder +} + +// NewEditAcmeProvider creates a new http.Handler for the edit acme provider operation +func NewEditAcmeProvider(ctx *middleware.Context, handler EditAcmeProviderHandler) *EditAcmeProvider { + return &EditAcmeProvider{Context: ctx, Handler: handler} +} + +/* + EditAcmeProvider swagger:route PUT /services/haproxy/configuration/acme/{name} Acme editAcmeProvider + +# Modify an ACME provider + +Modifies a acme_provider's configuration by its name +*/ +type EditAcmeProvider struct { + Context *middleware.Context + Handler EditAcmeProviderHandler +} + +func (o *EditAcmeProvider) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewEditAcmeProviderParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acme/edit_acme_provider_parameters.go b/operations/acme/edit_acme_provider_parameters.go new file mode 100644 index 00000000..cda306ba --- /dev/null +++ b/operations/acme/edit_acme_provider_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewEditAcmeProviderParams creates a new EditAcmeProviderParams object +// with the default values initialized. +func NewEditAcmeProviderParams() EditAcmeProviderParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return EditAcmeProviderParams{ + ForceReload: &forceReloadDefault, + } +} + +// EditAcmeProviderParams contains all the bound params for the edit acme provider operation +// typically these are obtained from a http.Request +// +// swagger:parameters editAcmeProvider +type EditAcmeProviderParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.AcmeProvider + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*acme section name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewEditAcmeProviderParams() beforehand. +func (o *EditAcmeProviderParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.AcmeProvider + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *EditAcmeProviderParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewEditAcmeProviderParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *EditAcmeProviderParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *EditAcmeProviderParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *EditAcmeProviderParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/acme/edit_acme_provider_responses.go b/operations/acme/edit_acme_provider_responses.go new file mode 100644 index 00000000..a01bd930 --- /dev/null +++ b/operations/acme/edit_acme_provider_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// EditAcmeProviderOKCode is the HTTP code returned for type EditAcmeProviderOK +const EditAcmeProviderOKCode int = 200 + +/* +EditAcmeProviderOK acme_provider configuration updated + +swagger:response editAcmeProviderOK +*/ +type EditAcmeProviderOK struct { + + /* + In: Body + */ + Payload *models.AcmeProvider `json:"body,omitempty"` +} + +// NewEditAcmeProviderOK creates EditAcmeProviderOK with default headers values +func NewEditAcmeProviderOK() *EditAcmeProviderOK { + + return &EditAcmeProviderOK{} +} + +// WithPayload adds the payload to the edit acme provider o k response +func (o *EditAcmeProviderOK) WithPayload(payload *models.AcmeProvider) *EditAcmeProviderOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit acme provider o k response +func (o *EditAcmeProviderOK) SetPayload(payload *models.AcmeProvider) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditAcmeProviderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditAcmeProviderAcceptedCode is the HTTP code returned for type EditAcmeProviderAccepted +const EditAcmeProviderAcceptedCode int = 202 + +/* +EditAcmeProviderAccepted Configuration change accepted and reload requested + +swagger:response editAcmeProviderAccepted +*/ +type EditAcmeProviderAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.AcmeProvider `json:"body,omitempty"` +} + +// NewEditAcmeProviderAccepted creates EditAcmeProviderAccepted with default headers values +func NewEditAcmeProviderAccepted() *EditAcmeProviderAccepted { + + return &EditAcmeProviderAccepted{} +} + +// WithReloadID adds the reloadId to the edit acme provider accepted response +func (o *EditAcmeProviderAccepted) WithReloadID(reloadID string) *EditAcmeProviderAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the edit acme provider accepted response +func (o *EditAcmeProviderAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the edit acme provider accepted response +func (o *EditAcmeProviderAccepted) WithPayload(payload *models.AcmeProvider) *EditAcmeProviderAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit acme provider accepted response +func (o *EditAcmeProviderAccepted) SetPayload(payload *models.AcmeProvider) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditAcmeProviderAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditAcmeProviderBadRequestCode is the HTTP code returned for type EditAcmeProviderBadRequest +const EditAcmeProviderBadRequestCode int = 400 + +/* +EditAcmeProviderBadRequest Bad request + +swagger:response editAcmeProviderBadRequest +*/ +type EditAcmeProviderBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditAcmeProviderBadRequest creates EditAcmeProviderBadRequest with default headers values +func NewEditAcmeProviderBadRequest() *EditAcmeProviderBadRequest { + + return &EditAcmeProviderBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit acme provider bad request response +func (o *EditAcmeProviderBadRequest) WithConfigurationVersion(configurationVersion string) *EditAcmeProviderBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit acme provider bad request response +func (o *EditAcmeProviderBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit acme provider bad request response +func (o *EditAcmeProviderBadRequest) WithPayload(payload *models.Error) *EditAcmeProviderBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit acme provider bad request response +func (o *EditAcmeProviderBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditAcmeProviderBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditAcmeProviderNotFoundCode is the HTTP code returned for type EditAcmeProviderNotFound +const EditAcmeProviderNotFoundCode int = 404 + +/* +EditAcmeProviderNotFound The specified resource was not found + +swagger:response editAcmeProviderNotFound +*/ +type EditAcmeProviderNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditAcmeProviderNotFound creates EditAcmeProviderNotFound with default headers values +func NewEditAcmeProviderNotFound() *EditAcmeProviderNotFound { + + return &EditAcmeProviderNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit acme provider not found response +func (o *EditAcmeProviderNotFound) WithConfigurationVersion(configurationVersion string) *EditAcmeProviderNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit acme provider not found response +func (o *EditAcmeProviderNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit acme provider not found response +func (o *EditAcmeProviderNotFound) WithPayload(payload *models.Error) *EditAcmeProviderNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit acme provider not found response +func (o *EditAcmeProviderNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditAcmeProviderNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +EditAcmeProviderDefault General Error + +swagger:response editAcmeProviderDefault +*/ +type EditAcmeProviderDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditAcmeProviderDefault creates EditAcmeProviderDefault with default headers values +func NewEditAcmeProviderDefault(code int) *EditAcmeProviderDefault { + if code <= 0 { + code = 500 + } + + return &EditAcmeProviderDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the edit acme provider default response +func (o *EditAcmeProviderDefault) WithStatusCode(code int) *EditAcmeProviderDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the edit acme provider default response +func (o *EditAcmeProviderDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the edit acme provider default response +func (o *EditAcmeProviderDefault) WithConfigurationVersion(configurationVersion string) *EditAcmeProviderDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit acme provider default response +func (o *EditAcmeProviderDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit acme provider default response +func (o *EditAcmeProviderDefault) WithPayload(payload *models.Error) *EditAcmeProviderDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit acme provider default response +func (o *EditAcmeProviderDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditAcmeProviderDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acme/edit_acme_provider_urlbuilder.go b/operations/acme/edit_acme_provider_urlbuilder.go new file mode 100644 index 00000000..2744d6ab --- /dev/null +++ b/operations/acme/edit_acme_provider_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// EditAcmeProviderURL generates an URL for the edit acme provider operation +type EditAcmeProviderURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditAcmeProviderURL) WithBasePath(bp string) *EditAcmeProviderURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditAcmeProviderURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *EditAcmeProviderURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/acme/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on EditAcmeProviderURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *EditAcmeProviderURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *EditAcmeProviderURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *EditAcmeProviderURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on EditAcmeProviderURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on EditAcmeProviderURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *EditAcmeProviderURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acme/get_acme_provider.go b/operations/acme/get_acme_provider.go new file mode 100644 index 00000000..e4f90e66 --- /dev/null +++ b/operations/acme/get_acme_provider.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAcmeProviderHandlerFunc turns a function with the right signature into a get acme provider handler +type GetAcmeProviderHandlerFunc func(GetAcmeProviderParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAcmeProviderHandlerFunc) Handle(params GetAcmeProviderParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAcmeProviderHandler interface for that can handle valid get acme provider params +type GetAcmeProviderHandler interface { + Handle(GetAcmeProviderParams, interface{}) middleware.Responder +} + +// NewGetAcmeProvider creates a new http.Handler for the get acme provider operation +func NewGetAcmeProvider(ctx *middleware.Context, handler GetAcmeProviderHandler) *GetAcmeProvider { + return &GetAcmeProvider{Context: ctx, Handler: handler} +} + +/* + GetAcmeProvider swagger:route GET /services/haproxy/configuration/acme/{name} Acme getAcmeProvider + +# Find an ACME provider + +Find an acme section by its name +*/ +type GetAcmeProvider struct { + Context *middleware.Context + Handler GetAcmeProviderHandler +} + +func (o *GetAcmeProvider) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAcmeProviderParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acme/get_acme_provider_parameters.go b/operations/acme/get_acme_provider_parameters.go new file mode 100644 index 00000000..2f5548e9 --- /dev/null +++ b/operations/acme/get_acme_provider_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAcmeProviderParams creates a new GetAcmeProviderParams object +// +// There are no default values defined in the spec. +func NewGetAcmeProviderParams() GetAcmeProviderParams { + + return GetAcmeProviderParams{} +} + +// GetAcmeProviderParams contains all the bound params for the get acme provider operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAcmeProvider +type GetAcmeProviderParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*acme section name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAcmeProviderParams() beforehand. +func (o *GetAcmeProviderParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetAcmeProviderParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAcmeProviderParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acme/get_acme_provider_responses.go b/operations/acme/get_acme_provider_responses.go new file mode 100644 index 00000000..db80566c --- /dev/null +++ b/operations/acme/get_acme_provider_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAcmeProviderOKCode is the HTTP code returned for type GetAcmeProviderOK +const GetAcmeProviderOKCode int = 200 + +/* +GetAcmeProviderOK Successful operation + +swagger:response getAcmeProviderOK +*/ +type GetAcmeProviderOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.AcmeProvider `json:"body,omitempty"` +} + +// NewGetAcmeProviderOK creates GetAcmeProviderOK with default headers values +func NewGetAcmeProviderOK() *GetAcmeProviderOK { + + return &GetAcmeProviderOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get acme provider o k response +func (o *GetAcmeProviderOK) WithConfigurationVersion(configurationVersion string) *GetAcmeProviderOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get acme provider o k response +func (o *GetAcmeProviderOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get acme provider o k response +func (o *GetAcmeProviderOK) WithPayload(payload *models.AcmeProvider) *GetAcmeProviderOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme provider o k response +func (o *GetAcmeProviderOK) SetPayload(payload *models.AcmeProvider) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeProviderOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetAcmeProviderNotFoundCode is the HTTP code returned for type GetAcmeProviderNotFound +const GetAcmeProviderNotFoundCode int = 404 + +/* +GetAcmeProviderNotFound The specified resource was not found + +swagger:response getAcmeProviderNotFound +*/ +type GetAcmeProviderNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAcmeProviderNotFound creates GetAcmeProviderNotFound with default headers values +func NewGetAcmeProviderNotFound() *GetAcmeProviderNotFound { + + return &GetAcmeProviderNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get acme provider not found response +func (o *GetAcmeProviderNotFound) WithConfigurationVersion(configurationVersion string) *GetAcmeProviderNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get acme provider not found response +func (o *GetAcmeProviderNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get acme provider not found response +func (o *GetAcmeProviderNotFound) WithPayload(payload *models.Error) *GetAcmeProviderNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme provider not found response +func (o *GetAcmeProviderNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeProviderNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAcmeProviderDefault General Error + +swagger:response getAcmeProviderDefault +*/ +type GetAcmeProviderDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAcmeProviderDefault creates GetAcmeProviderDefault with default headers values +func NewGetAcmeProviderDefault(code int) *GetAcmeProviderDefault { + if code <= 0 { + code = 500 + } + + return &GetAcmeProviderDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get acme provider default response +func (o *GetAcmeProviderDefault) WithStatusCode(code int) *GetAcmeProviderDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get acme provider default response +func (o *GetAcmeProviderDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get acme provider default response +func (o *GetAcmeProviderDefault) WithConfigurationVersion(configurationVersion string) *GetAcmeProviderDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get acme provider default response +func (o *GetAcmeProviderDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get acme provider default response +func (o *GetAcmeProviderDefault) WithPayload(payload *models.Error) *GetAcmeProviderDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme provider default response +func (o *GetAcmeProviderDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeProviderDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acme/get_acme_provider_urlbuilder.go b/operations/acme/get_acme_provider_urlbuilder.go new file mode 100644 index 00000000..d3d07bff --- /dev/null +++ b/operations/acme/get_acme_provider_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAcmeProviderURL generates an URL for the get acme provider operation +type GetAcmeProviderURL struct { + Name string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAcmeProviderURL) WithBasePath(bp string) *GetAcmeProviderURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAcmeProviderURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAcmeProviderURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/acme/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetAcmeProviderURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAcmeProviderURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAcmeProviderURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAcmeProviderURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAcmeProviderURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAcmeProviderURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAcmeProviderURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acme/get_acme_providers.go b/operations/acme/get_acme_providers.go new file mode 100644 index 00000000..3efa1e30 --- /dev/null +++ b/operations/acme/get_acme_providers.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAcmeProvidersHandlerFunc turns a function with the right signature into a get acme providers handler +type GetAcmeProvidersHandlerFunc func(GetAcmeProvidersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAcmeProvidersHandlerFunc) Handle(params GetAcmeProvidersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAcmeProvidersHandler interface for that can handle valid get acme providers params +type GetAcmeProvidersHandler interface { + Handle(GetAcmeProvidersParams, interface{}) middleware.Responder +} + +// NewGetAcmeProviders creates a new http.Handler for the get acme providers operation +func NewGetAcmeProviders(ctx *middleware.Context, handler GetAcmeProvidersHandler) *GetAcmeProviders { + return &GetAcmeProviders{Context: ctx, Handler: handler} +} + +/* + GetAcmeProviders swagger:route GET /services/haproxy/configuration/acme Acme getAcmeProviders + +# Return all the ACME providers + +Returns an array of all the configured ACME providers +*/ +type GetAcmeProviders struct { + Context *middleware.Context + Handler GetAcmeProvidersHandler +} + +func (o *GetAcmeProviders) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAcmeProvidersParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acme/get_acme_providers_parameters.go b/operations/acme/get_acme_providers_parameters.go new file mode 100644 index 00000000..88b45317 --- /dev/null +++ b/operations/acme/get_acme_providers_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAcmeProvidersParams creates a new GetAcmeProvidersParams object +// +// There are no default values defined in the spec. +func NewGetAcmeProvidersParams() GetAcmeProvidersParams { + + return GetAcmeProvidersParams{} +} + +// GetAcmeProvidersParams contains all the bound params for the get acme providers operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAcmeProviders +type GetAcmeProvidersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAcmeProvidersParams() beforehand. +func (o *GetAcmeProvidersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAcmeProvidersParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/acme/get_acme_providers_responses.go b/operations/acme/get_acme_providers_responses.go new file mode 100644 index 00000000..d844b61b --- /dev/null +++ b/operations/acme/get_acme_providers_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAcmeProvidersOKCode is the HTTP code returned for type GetAcmeProvidersOK +const GetAcmeProvidersOKCode int = 200 + +/* +GetAcmeProvidersOK Successful operation + +swagger:response getAcmeProvidersOK +*/ +type GetAcmeProvidersOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.AcmeProviders `json:"body,omitempty"` +} + +// NewGetAcmeProvidersOK creates GetAcmeProvidersOK with default headers values +func NewGetAcmeProvidersOK() *GetAcmeProvidersOK { + + return &GetAcmeProvidersOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get acme providers o k response +func (o *GetAcmeProvidersOK) WithConfigurationVersion(configurationVersion string) *GetAcmeProvidersOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get acme providers o k response +func (o *GetAcmeProvidersOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get acme providers o k response +func (o *GetAcmeProvidersOK) WithPayload(payload models.AcmeProviders) *GetAcmeProvidersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme providers o k response +func (o *GetAcmeProvidersOK) SetPayload(payload models.AcmeProviders) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeProvidersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.AcmeProviders{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAcmeProvidersDefault General Error + +swagger:response getAcmeProvidersDefault +*/ +type GetAcmeProvidersDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAcmeProvidersDefault creates GetAcmeProvidersDefault with default headers values +func NewGetAcmeProvidersDefault(code int) *GetAcmeProvidersDefault { + if code <= 0 { + code = 500 + } + + return &GetAcmeProvidersDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get acme providers default response +func (o *GetAcmeProvidersDefault) WithStatusCode(code int) *GetAcmeProvidersDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get acme providers default response +func (o *GetAcmeProvidersDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get acme providers default response +func (o *GetAcmeProvidersDefault) WithConfigurationVersion(configurationVersion string) *GetAcmeProvidersDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get acme providers default response +func (o *GetAcmeProvidersDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get acme providers default response +func (o *GetAcmeProvidersDefault) WithPayload(payload *models.Error) *GetAcmeProvidersDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme providers default response +func (o *GetAcmeProvidersDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeProvidersDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acme/get_acme_providers_urlbuilder.go b/operations/acme/get_acme_providers_urlbuilder.go new file mode 100644 index 00000000..e8835c11 --- /dev/null +++ b/operations/acme/get_acme_providers_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAcmeProvidersURL generates an URL for the get acme providers operation +type GetAcmeProvidersURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAcmeProvidersURL) WithBasePath(bp string) *GetAcmeProvidersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAcmeProvidersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAcmeProvidersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/acme" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAcmeProvidersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAcmeProvidersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAcmeProvidersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAcmeProvidersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAcmeProvidersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAcmeProvidersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acme_runtime/get_acme_status.go b/operations/acme_runtime/get_acme_status.go new file mode 100644 index 00000000..ce81bba2 --- /dev/null +++ b/operations/acme_runtime/get_acme_status.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAcmeStatusHandlerFunc turns a function with the right signature into a get acme status handler +type GetAcmeStatusHandlerFunc func(GetAcmeStatusParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAcmeStatusHandlerFunc) Handle(params GetAcmeStatusParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAcmeStatusHandler interface for that can handle valid get acme status params +type GetAcmeStatusHandler interface { + Handle(GetAcmeStatusParams, interface{}) middleware.Responder +} + +// NewGetAcmeStatus creates a new http.Handler for the get acme status operation +func NewGetAcmeStatus(ctx *middleware.Context, handler GetAcmeStatusHandler) *GetAcmeStatus { + return &GetAcmeStatus{Context: ctx, Handler: handler} +} + +/* + GetAcmeStatus swagger:route GET /services/haproxy/runtime/acme AcmeRuntime getAcmeStatus + +# ACME Status + +Returns the status of each managed ACME certificate. +*/ +type GetAcmeStatus struct { + Context *middleware.Context + Handler GetAcmeStatusHandler +} + +func (o *GetAcmeStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAcmeStatusParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acme_runtime/get_acme_status_parameters.go b/operations/acme_runtime/get_acme_status_parameters.go new file mode 100644 index 00000000..1ba7da24 --- /dev/null +++ b/operations/acme_runtime/get_acme_status_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAcmeStatusParams creates a new GetAcmeStatusParams object +// +// There are no default values defined in the spec. +func NewGetAcmeStatusParams() GetAcmeStatusParams { + + return GetAcmeStatusParams{} +} + +// GetAcmeStatusParams contains all the bound params for the get acme status operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAcmeStatus +type GetAcmeStatusParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAcmeStatusParams() beforehand. +func (o *GetAcmeStatusParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/acme_runtime/get_acme_status_responses.go b/operations/acme_runtime/get_acme_status_responses.go new file mode 100644 index 00000000..b574dcab --- /dev/null +++ b/operations/acme_runtime/get_acme_status_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAcmeStatusOKCode is the HTTP code returned for type GetAcmeStatusOK +const GetAcmeStatusOKCode int = 200 + +/* +GetAcmeStatusOK Successful operation + +swagger:response getAcmeStatusOK +*/ +type GetAcmeStatusOK struct { + + /* + In: Body + */ + Payload models.AcmeStatus `json:"body,omitempty"` +} + +// NewGetAcmeStatusOK creates GetAcmeStatusOK with default headers values +func NewGetAcmeStatusOK() *GetAcmeStatusOK { + + return &GetAcmeStatusOK{} +} + +// WithPayload adds the payload to the get acme status o k response +func (o *GetAcmeStatusOK) WithPayload(payload models.AcmeStatus) *GetAcmeStatusOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme status o k response +func (o *GetAcmeStatusOK) SetPayload(payload models.AcmeStatus) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeStatusOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.AcmeStatus{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAcmeStatusNotFoundCode is the HTTP code returned for type GetAcmeStatusNotFound +const GetAcmeStatusNotFoundCode int = 404 + +/* +GetAcmeStatusNotFound The specified resource was not found + +swagger:response getAcmeStatusNotFound +*/ +type GetAcmeStatusNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAcmeStatusNotFound creates GetAcmeStatusNotFound with default headers values +func NewGetAcmeStatusNotFound() *GetAcmeStatusNotFound { + + return &GetAcmeStatusNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get acme status not found response +func (o *GetAcmeStatusNotFound) WithConfigurationVersion(configurationVersion string) *GetAcmeStatusNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get acme status not found response +func (o *GetAcmeStatusNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get acme status not found response +func (o *GetAcmeStatusNotFound) WithPayload(payload *models.Error) *GetAcmeStatusNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme status not found response +func (o *GetAcmeStatusNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeStatusNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAcmeStatusDefault General Error + +swagger:response getAcmeStatusDefault +*/ +type GetAcmeStatusDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAcmeStatusDefault creates GetAcmeStatusDefault with default headers values +func NewGetAcmeStatusDefault(code int) *GetAcmeStatusDefault { + if code <= 0 { + code = 500 + } + + return &GetAcmeStatusDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get acme status default response +func (o *GetAcmeStatusDefault) WithStatusCode(code int) *GetAcmeStatusDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get acme status default response +func (o *GetAcmeStatusDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get acme status default response +func (o *GetAcmeStatusDefault) WithConfigurationVersion(configurationVersion string) *GetAcmeStatusDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get acme status default response +func (o *GetAcmeStatusDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get acme status default response +func (o *GetAcmeStatusDefault) WithPayload(payload *models.Error) *GetAcmeStatusDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get acme status default response +func (o *GetAcmeStatusDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAcmeStatusDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acme_runtime/get_acme_status_urlbuilder.go b/operations/acme_runtime/get_acme_status_urlbuilder.go new file mode 100644 index 00000000..e3612f41 --- /dev/null +++ b/operations/acme_runtime/get_acme_status_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAcmeStatusURL generates an URL for the get acme status operation +type GetAcmeStatusURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAcmeStatusURL) WithBasePath(bp string) *GetAcmeStatusURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAcmeStatusURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAcmeStatusURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acme" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAcmeStatusURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAcmeStatusURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAcmeStatusURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAcmeStatusURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAcmeStatusURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAcmeStatusURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/acme_runtime/renew_acme_certificate.go b/operations/acme_runtime/renew_acme_certificate.go new file mode 100644 index 00000000..318ee2de --- /dev/null +++ b/operations/acme_runtime/renew_acme_certificate.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RenewAcmeCertificateHandlerFunc turns a function with the right signature into a renew acme certificate handler +type RenewAcmeCertificateHandlerFunc func(RenewAcmeCertificateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn RenewAcmeCertificateHandlerFunc) Handle(params RenewAcmeCertificateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// RenewAcmeCertificateHandler interface for that can handle valid renew acme certificate params +type RenewAcmeCertificateHandler interface { + Handle(RenewAcmeCertificateParams, interface{}) middleware.Responder +} + +// NewRenewAcmeCertificate creates a new http.Handler for the renew acme certificate operation +func NewRenewAcmeCertificate(ctx *middleware.Context, handler RenewAcmeCertificateHandler) *RenewAcmeCertificate { + return &RenewAcmeCertificate{Context: ctx, Handler: handler} +} + +/* + RenewAcmeCertificate swagger:route PUT /services/haproxy/runtime/acme AcmeRuntime renewAcmeCertificate + +# Renew ACME certificate + +Force renewal of an ACME certificate. +*/ +type RenewAcmeCertificate struct { + Context *middleware.Context + Handler RenewAcmeCertificateHandler +} + +func (o *RenewAcmeCertificate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewRenewAcmeCertificateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/acme_runtime/renew_acme_certificate_parameters.go b/operations/acme_runtime/renew_acme_certificate_parameters.go new file mode 100644 index 00000000..7502ab8f --- /dev/null +++ b/operations/acme_runtime/renew_acme_certificate_parameters.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewRenewAcmeCertificateParams creates a new RenewAcmeCertificateParams object +// +// There are no default values defined in the spec. +func NewRenewAcmeCertificateParams() RenewAcmeCertificateParams { + + return RenewAcmeCertificateParams{} +} + +// RenewAcmeCertificateParams contains all the bound params for the renew acme certificate operation +// typically these are obtained from a http.Request +// +// swagger:parameters renewAcmeCertificate +type RenewAcmeCertificateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Certificate file name + Required: true + In: query + */ + Certificate string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRenewAcmeCertificateParams() beforehand. +func (o *RenewAcmeCertificateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qCertificate, qhkCertificate, _ := qs.GetOK("certificate") + if err := o.bindCertificate(qCertificate, qhkCertificate, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCertificate binds and validates parameter Certificate from query. +func (o *RenewAcmeCertificateParams) bindCertificate(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("certificate", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("certificate", "query", raw); err != nil { + return err + } + o.Certificate = raw + + return nil +} diff --git a/operations/acme_runtime/renew_acme_certificate_responses.go b/operations/acme_runtime/renew_acme_certificate_responses.go new file mode 100644 index 00000000..9796125e --- /dev/null +++ b/operations/acme_runtime/renew_acme_certificate_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// RenewAcmeCertificateOKCode is the HTTP code returned for type RenewAcmeCertificateOK +const RenewAcmeCertificateOKCode int = 200 + +/* +RenewAcmeCertificateOK Operation started + +swagger:response renewAcmeCertificateOK +*/ +type RenewAcmeCertificateOK struct { +} + +// NewRenewAcmeCertificateOK creates RenewAcmeCertificateOK with default headers values +func NewRenewAcmeCertificateOK() *RenewAcmeCertificateOK { + + return &RenewAcmeCertificateOK{} +} + +// WriteResponse to the client +func (o *RenewAcmeCertificateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// RenewAcmeCertificateNotFoundCode is the HTTP code returned for type RenewAcmeCertificateNotFound +const RenewAcmeCertificateNotFoundCode int = 404 + +/* +RenewAcmeCertificateNotFound The specified resource was not found + +swagger:response renewAcmeCertificateNotFound +*/ +type RenewAcmeCertificateNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewRenewAcmeCertificateNotFound creates RenewAcmeCertificateNotFound with default headers values +func NewRenewAcmeCertificateNotFound() *RenewAcmeCertificateNotFound { + + return &RenewAcmeCertificateNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the renew acme certificate not found response +func (o *RenewAcmeCertificateNotFound) WithConfigurationVersion(configurationVersion string) *RenewAcmeCertificateNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the renew acme certificate not found response +func (o *RenewAcmeCertificateNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the renew acme certificate not found response +func (o *RenewAcmeCertificateNotFound) WithPayload(payload *models.Error) *RenewAcmeCertificateNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the renew acme certificate not found response +func (o *RenewAcmeCertificateNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RenewAcmeCertificateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +RenewAcmeCertificateDefault General Error + +swagger:response renewAcmeCertificateDefault +*/ +type RenewAcmeCertificateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewRenewAcmeCertificateDefault creates RenewAcmeCertificateDefault with default headers values +func NewRenewAcmeCertificateDefault(code int) *RenewAcmeCertificateDefault { + if code <= 0 { + code = 500 + } + + return &RenewAcmeCertificateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the renew acme certificate default response +func (o *RenewAcmeCertificateDefault) WithStatusCode(code int) *RenewAcmeCertificateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the renew acme certificate default response +func (o *RenewAcmeCertificateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the renew acme certificate default response +func (o *RenewAcmeCertificateDefault) WithConfigurationVersion(configurationVersion string) *RenewAcmeCertificateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the renew acme certificate default response +func (o *RenewAcmeCertificateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the renew acme certificate default response +func (o *RenewAcmeCertificateDefault) WithPayload(payload *models.Error) *RenewAcmeCertificateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the renew acme certificate default response +func (o *RenewAcmeCertificateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RenewAcmeCertificateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/acme_runtime/renew_acme_certificate_urlbuilder.go b/operations/acme_runtime/renew_acme_certificate_urlbuilder.go new file mode 100644 index 00000000..066aa985 --- /dev/null +++ b/operations/acme_runtime/renew_acme_certificate_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package acme_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// RenewAcmeCertificateURL generates an URL for the renew acme certificate operation +type RenewAcmeCertificateURL struct { + Certificate string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RenewAcmeCertificateURL) WithBasePath(bp string) *RenewAcmeCertificateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RenewAcmeCertificateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RenewAcmeCertificateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/acme" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + certificateQ := o.Certificate + if certificateQ != "" { + qs.Set("certificate", certificateQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RenewAcmeCertificateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RenewAcmeCertificateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RenewAcmeCertificateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RenewAcmeCertificateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RenewAcmeCertificateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RenewAcmeCertificateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/backend/create_backend.go b/operations/backend/create_backend.go index 54ed9384..2079cfbd 100644 --- a/operations/backend/create_backend.go +++ b/operations/backend/create_backend.go @@ -23,7 +23,7 @@ package backend import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // CreateBackendHandlerFunc turns a function with the right signature into a create backend handler @@ -44,12 +44,12 @@ func NewCreateBackend(ctx *middleware.Context, handler CreateBackendHandler) *Cr return &CreateBackend{Context: ctx, Handler: handler} } -/*CreateBackend swagger:route POST /services/haproxy/configuration/backends Backend createBackend +/* + CreateBackend swagger:route POST /services/haproxy/configuration/backends Backend createBackend -Add a backend +# Add a backend Adds a new backend to the configuration file. - */ type CreateBackend struct { Context *middleware.Context @@ -59,21 +59,20 @@ type CreateBackend struct { func (o *CreateBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewCreateBackendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *CreateBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/backend/create_backend_parameters.go b/operations/backend/create_backend_parameters.go index 337f9f38..c6c88eb0 100644 --- a/operations/backend/create_backend_parameters.go +++ b/operations/backend/create_backend_parameters.go @@ -27,11 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewCreateBackendParams creates a new CreateBackendParams object @@ -42,10 +41,13 @@ func NewCreateBackendParams() CreateBackendParams { // initialize parameters with default values forceReloadDefault = bool(false) + fullSectionDefault = bool(false) ) return CreateBackendParams{ ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, } } @@ -68,6 +70,11 @@ type CreateBackendParams struct { Default: false */ ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -94,7 +101,7 @@ func (o *CreateBackendParams) BindRequest(r *http.Request, route *middleware.Mat var body models.Backend if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -109,13 +116,19 @@ func (o *CreateBackendParams) BindRequest(r *http.Request, route *middleware.Mat } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) @@ -125,7 +138,6 @@ func (o *CreateBackendParams) BindRequest(r *http.Request, route *middleware.Mat if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -141,6 +153,7 @@ func (o *CreateBackendParams) bindForceReload(rawData []string, hasKey bool, for // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewCreateBackendParams() return nil @@ -155,6 +168,30 @@ func (o *CreateBackendParams) bindForceReload(rawData []string, hasKey bool, for return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateBackendParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindTransactionID binds and validates parameter TransactionID from query. func (o *CreateBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -164,10 +201,10 @@ func (o *CreateBackendParams) bindTransactionID(rawData []string, hasKey bool, f // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -182,6 +219,7 @@ func (o *CreateBackendParams) bindVersion(rawData []string, hasKey bool, formats // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/backend/create_backend_responses.go b/operations/backend/create_backend_responses.go index d34d78b1..cb5bba2d 100644 --- a/operations/backend/create_backend_responses.go +++ b/operations/backend/create_backend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // CreateBackendCreatedCode is the HTTP code returned for type CreateBackendCreated const CreateBackendCreatedCode int = 201 -/*CreateBackendCreated Backend created +/* +CreateBackendCreated Backend created swagger:response createBackendCreated */ @@ -76,7 +76,8 @@ func (o *CreateBackendCreated) WriteResponse(rw http.ResponseWriter, producer ru // CreateBackendAcceptedCode is the HTTP code returned for type CreateBackendAccepted const CreateBackendAcceptedCode int = 202 -/*CreateBackendAccepted Configuration change accepted and reload requested +/* +CreateBackendAccepted Configuration change accepted and reload requested swagger:response createBackendAccepted */ @@ -142,7 +143,8 @@ func (o *CreateBackendAccepted) WriteResponse(rw http.ResponseWriter, producer r // CreateBackendBadRequestCode is the HTTP code returned for type CreateBackendBadRequest const CreateBackendBadRequestCode int = 400 -/*CreateBackendBadRequest Bad request +/* +CreateBackendBadRequest Bad request swagger:response createBackendBadRequest */ @@ -150,7 +152,7 @@ type CreateBackendBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewCreateBackendBadRequest() *CreateBackendBadRequest { } // WithConfigurationVersion adds the configurationVersion to the create backend bad request response -func (o *CreateBackendBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateBackendBadRequest { +func (o *CreateBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateBackendBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create backend bad request response -func (o *CreateBackendBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateBackendBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *CreateBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *CreateBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer // CreateBackendConflictCode is the HTTP code returned for type CreateBackendConflict const CreateBackendConflictCode int = 409 -/*CreateBackendConflict The specified resource already exists +/* +CreateBackendConflict The specified resource already exists swagger:response createBackendConflict */ @@ -216,7 +219,7 @@ type CreateBackendConflict struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewCreateBackendConflict() *CreateBackendConflict { } // WithConfigurationVersion adds the configurationVersion to the create backend conflict response -func (o *CreateBackendConflict) WithConfigurationVersion(configurationVersion int64) *CreateBackendConflict { +func (o *CreateBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateBackendConflict { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create backend conflict response -func (o *CreateBackendConflict) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateBackendConflict) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *CreateBackendConflict) WriteResponse(rw http.ResponseWriter, producer r // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *CreateBackendConflict) WriteResponse(rw http.ResponseWriter, producer r } } -/*CreateBackendDefault General Error +/* +CreateBackendDefault General Error swagger:response createBackendDefault */ @@ -280,7 +284,7 @@ type CreateBackendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *CreateBackendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the create backend default response -func (o *CreateBackendDefault) WithConfigurationVersion(configurationVersion int64) *CreateBackendDefault { +func (o *CreateBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateBackendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create backend default response -func (o *CreateBackendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateBackendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *CreateBackendDefault) WriteResponse(rw http.ResponseWriter, producer ru // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend/create_backend_urlbuilder.go b/operations/backend/create_backend_urlbuilder.go index addd98c5..19da06f0 100644 --- a/operations/backend/create_backend_urlbuilder.go +++ b/operations/backend/create_backend_urlbuilder.go @@ -31,6 +31,7 @@ import ( // CreateBackendURL generates an URL for the create backend operation type CreateBackendURL struct { ForceReload *bool + FullSection *bool TransactionID *string Version *int64 @@ -62,34 +63,42 @@ func (o *CreateBackendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend/delete_backend.go b/operations/backend/delete_backend.go index 89be4d45..659304c2 100644 --- a/operations/backend/delete_backend.go +++ b/operations/backend/delete_backend.go @@ -23,7 +23,7 @@ package backend import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // DeleteBackendHandlerFunc turns a function with the right signature into a delete backend handler @@ -44,12 +44,12 @@ func NewDeleteBackend(ctx *middleware.Context, handler DeleteBackendHandler) *De return &DeleteBackend{Context: ctx, Handler: handler} } -/*DeleteBackend swagger:route DELETE /services/haproxy/configuration/backends/{name} Backend deleteBackend +/* + DeleteBackend swagger:route DELETE /services/haproxy/configuration/backends/{name} Backend deleteBackend -Delete a backend - -Deletes a frontend from the configuration by it's name. +# Delete a backend +Deletes a backend from the configuration by it's name. */ type DeleteBackend struct { Context *middleware.Context @@ -59,21 +59,20 @@ type DeleteBackend struct { func (o *DeleteBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewDeleteBackendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *DeleteBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/backend/delete_backend_parameters.go b/operations/backend/delete_backend_parameters.go index aa45a418..ceec14c8 100644 --- a/operations/backend/delete_backend_parameters.go +++ b/operations/backend/delete_backend_parameters.go @@ -26,9 +26,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) // NewDeleteBackendParams creates a new DeleteBackendParams object @@ -105,7 +104,6 @@ func (o *DeleteBackendParams) BindRequest(r *http.Request, route *middleware.Mat if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -121,6 +119,7 @@ func (o *DeleteBackendParams) bindForceReload(rawData []string, hasKey bool, for // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewDeleteBackendParams() return nil @@ -144,7 +143,6 @@ func (o *DeleteBackendParams) bindName(rawData []string, hasKey bool, formats st // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -159,10 +157,10 @@ func (o *DeleteBackendParams) bindTransactionID(rawData []string, hasKey bool, f // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -177,6 +175,7 @@ func (o *DeleteBackendParams) bindVersion(rawData []string, hasKey bool, formats // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/backend/delete_backend_responses.go b/operations/backend/delete_backend_responses.go index a5c1a64e..b817aa42 100644 --- a/operations/backend/delete_backend_responses.go +++ b/operations/backend/delete_backend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // DeleteBackendAcceptedCode is the HTTP code returned for type DeleteBackendAccepted const DeleteBackendAcceptedCode int = 202 -/*DeleteBackendAccepted Configuration change accepted and reload requested +/* +DeleteBackendAccepted Configuration change accepted and reload requested swagger:response deleteBackendAccepted */ @@ -78,7 +78,8 @@ func (o *DeleteBackendAccepted) WriteResponse(rw http.ResponseWriter, producer r // DeleteBackendNoContentCode is the HTTP code returned for type DeleteBackendNoContent const DeleteBackendNoContentCode int = 204 -/*DeleteBackendNoContent Backend deleted +/* +DeleteBackendNoContent Backend deleted swagger:response deleteBackendNoContent */ @@ -102,7 +103,8 @@ func (o *DeleteBackendNoContent) WriteResponse(rw http.ResponseWriter, producer // DeleteBackendNotFoundCode is the HTTP code returned for type DeleteBackendNotFound const DeleteBackendNotFoundCode int = 404 -/*DeleteBackendNotFound The specified resource was not found +/* +DeleteBackendNotFound The specified resource was not found swagger:response deleteBackendNotFound */ @@ -110,7 +112,7 @@ type DeleteBackendNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -125,13 +127,13 @@ func NewDeleteBackendNotFound() *DeleteBackendNotFound { } // WithConfigurationVersion adds the configurationVersion to the delete backend not found response -func (o *DeleteBackendNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteBackendNotFound { +func (o *DeleteBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteBackendNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete backend not found response -func (o *DeleteBackendNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteBackendNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -151,7 +153,7 @@ func (o *DeleteBackendNotFound) WriteResponse(rw http.ResponseWriter, producer r // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -165,7 +167,8 @@ func (o *DeleteBackendNotFound) WriteResponse(rw http.ResponseWriter, producer r } } -/*DeleteBackendDefault General Error +/* +DeleteBackendDefault General Error swagger:response deleteBackendDefault */ @@ -174,7 +177,7 @@ type DeleteBackendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -205,13 +208,13 @@ func (o *DeleteBackendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the delete backend default response -func (o *DeleteBackendDefault) WithConfigurationVersion(configurationVersion int64) *DeleteBackendDefault { +func (o *DeleteBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteBackendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete backend default response -func (o *DeleteBackendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteBackendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -231,7 +234,7 @@ func (o *DeleteBackendDefault) WriteResponse(rw http.ResponseWriter, producer ru // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend/delete_backend_urlbuilder.go b/operations/backend/delete_backend_urlbuilder.go index 27779f1d..2765c360 100644 --- a/operations/backend/delete_backend_urlbuilder.go +++ b/operations/backend/delete_backend_urlbuilder.go @@ -72,34 +72,34 @@ func (o *DeleteBackendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend/get_backend.go b/operations/backend/get_backend.go index 295fc0ba..4d056929 100644 --- a/operations/backend/get_backend.go +++ b/operations/backend/get_backend.go @@ -23,12 +23,7 @@ package backend import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetBackendHandlerFunc turns a function with the right signature into a get backend handler @@ -49,12 +44,12 @@ func NewGetBackend(ctx *middleware.Context, handler GetBackendHandler) *GetBacke return &GetBackend{Context: ctx, Handler: handler} } -/*GetBackend swagger:route GET /services/haproxy/configuration/backends/{name} Backend getBackend +/* + GetBackend swagger:route GET /services/haproxy/configuration/backends/{name} Backend getBackend -Return a backend +# Return a backend Returns one backend configuration by it's name. - */ type GetBackend struct { Context *middleware.Context @@ -64,21 +59,20 @@ type GetBackend struct { func (o *GetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetBackendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -87,68 +81,6 @@ func (o *GetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetBackendOKBody get backend o k body -// swagger:model GetBackendOKBody -type GetBackendOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Backend `json:"data,omitempty"` -} - -// Validate validates this get backend o k body -func (o *GetBackendOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetBackendOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getBackendOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetBackendOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetBackendOKBody) UnmarshalBinary(b []byte) error { - var res GetBackendOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/backend/get_backend_parameters.go b/operations/backend/get_backend_parameters.go index 84fc2b1e..a213fd1d 100644 --- a/operations/backend/get_backend_parameters.go +++ b/operations/backend/get_backend_parameters.go @@ -26,15 +26,23 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetBackendParams creates a new GetBackendParams object -// no default values defined in spec. +// with the default values initialized. func NewGetBackendParams() GetBackendParams { - return GetBackendParams{} + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetBackendParams{ + FullSection: &fullSectionDefault, + } } // GetBackendParams contains all the bound params for the get backend operation @@ -46,6 +54,11 @@ type GetBackendParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*Backend name Required: true In: path @@ -68,6 +81,11 @@ func (o *GetBackendParams) BindRequest(r *http.Request, route *middleware.Matche qs := runtime.Values(r.URL.Query()) + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + rName, rhkName, _ := route.Params.GetOK("name") if err := o.bindName(rName, rhkName, route.Formats); err != nil { res = append(res, err) @@ -77,13 +95,36 @@ func (o *GetBackendParams) BindRequest(r *http.Request, route *middleware.Matche if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetBackendParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindName binds and validates parameter Name from path. func (o *GetBackendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -93,7 +134,6 @@ func (o *GetBackendParams) bindName(rawData []string, hasKey bool, formats strfm // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -108,10 +148,10 @@ func (o *GetBackendParams) bindTransactionID(rawData []string, hasKey bool, form // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/backend/get_backend_responses.go b/operations/backend/get_backend_responses.go index 1c84021f..5357488b 100644 --- a/operations/backend/get_backend_responses.go +++ b/operations/backend/get_backend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetBackendOKCode is the HTTP code returned for type GetBackendOK const GetBackendOKCode int = 200 -/*GetBackendOK Successful operation +/* +GetBackendOK Successful operation swagger:response getBackendOK */ @@ -40,12 +40,12 @@ type GetBackendOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetBackendOKBody `json:"body,omitempty"` + Payload *models.Backend `json:"body,omitempty"` } // NewGetBackendOK creates GetBackendOK with default headers values @@ -55,24 +55,24 @@ func NewGetBackendOK() *GetBackendOK { } // WithConfigurationVersion adds the configurationVersion to the get backend o k response -func (o *GetBackendOK) WithConfigurationVersion(configurationVersion int64) *GetBackendOK { +func (o *GetBackendOK) WithConfigurationVersion(configurationVersion string) *GetBackendOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend o k response -func (o *GetBackendOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get backend o k response -func (o *GetBackendOK) WithPayload(payload *GetBackendOKBody) *GetBackendOK { +func (o *GetBackendOK) WithPayload(payload *models.Backend) *GetBackendOK { o.Payload = payload return o } // SetPayload sets the payload to the get backend o k response -func (o *GetBackendOK) SetPayload(payload *GetBackendOKBody) { +func (o *GetBackendOK) SetPayload(payload *models.Backend) { o.Payload = payload } @@ -81,7 +81,7 @@ func (o *GetBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pr // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -98,7 +98,8 @@ func (o *GetBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pr // GetBackendNotFoundCode is the HTTP code returned for type GetBackendNotFound const GetBackendNotFoundCode int = 404 -/*GetBackendNotFound The specified resource was not found +/* +GetBackendNotFound The specified resource was not found swagger:response getBackendNotFound */ @@ -106,7 +107,7 @@ type GetBackendNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -121,13 +122,13 @@ func NewGetBackendNotFound() *GetBackendNotFound { } // WithConfigurationVersion adds the configurationVersion to the get backend not found response -func (o *GetBackendNotFound) WithConfigurationVersion(configurationVersion int64) *GetBackendNotFound { +func (o *GetBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetBackendNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend not found response -func (o *GetBackendNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -147,7 +148,7 @@ func (o *GetBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runt // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -161,7 +162,8 @@ func (o *GetBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runt } } -/*GetBackendDefault General Error +/* +GetBackendDefault General Error swagger:response getBackendDefault */ @@ -170,7 +172,7 @@ type GetBackendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -201,13 +203,13 @@ func (o *GetBackendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get backend default response -func (o *GetBackendDefault) WithConfigurationVersion(configurationVersion int64) *GetBackendDefault { +func (o *GetBackendDefault) WithConfigurationVersion(configurationVersion string) *GetBackendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend default response -func (o *GetBackendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -227,7 +229,7 @@ func (o *GetBackendDefault) WriteResponse(rw http.ResponseWriter, producer runti // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend/get_backend_urlbuilder.go b/operations/backend/get_backend_urlbuilder.go index 1237c17c..fde5203c 100644 --- a/operations/backend/get_backend_urlbuilder.go +++ b/operations/backend/get_backend_urlbuilder.go @@ -25,12 +25,15 @@ import ( "net/url" golangswaggerpaths "path" "strings" + + "github.com/go-openapi/swag" ) // GetBackendURL generates an URL for the get backend operation type GetBackendURL struct { Name string + FullSection *bool TransactionID *string _basePath string @@ -68,18 +71,26 @@ func (o *GetBackendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend/get_backends.go b/operations/backend/get_backends.go index f38ac2d3..38532255 100644 --- a/operations/backend/get_backends.go +++ b/operations/backend/get_backends.go @@ -23,13 +23,7 @@ package backend import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetBackendsHandlerFunc turns a function with the right signature into a get backends handler @@ -50,12 +44,12 @@ func NewGetBackends(ctx *middleware.Context, handler GetBackendsHandler) *GetBac return &GetBackends{Context: ctx, Handler: handler} } -/*GetBackends swagger:route GET /services/haproxy/configuration/backends Backend getBackends +/* + GetBackends swagger:route GET /services/haproxy/configuration/backends Backend getBackends -Return an array of backends +# Return an array of backends Returns an array of all configured backends. - */ type GetBackends struct { Context *middleware.Context @@ -65,21 +59,20 @@ type GetBackends struct { func (o *GetBackends) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetBackendsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -88,67 +81,6 @@ func (o *GetBackends) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetBackendsOKBody get backends o k body -// swagger:model GetBackendsOKBody -type GetBackendsOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.Backends `json:"data"` -} - -// Validate validates this get backends o k body -func (o *GetBackendsOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetBackendsOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getBackendsOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getBackendsOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetBackendsOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetBackendsOKBody) UnmarshalBinary(b []byte) error { - var res GetBackendsOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/backend/get_backends_parameters.go b/operations/backend/get_backends_parameters.go index 4077edb1..d1f0c0b5 100644 --- a/operations/backend/get_backends_parameters.go +++ b/operations/backend/get_backends_parameters.go @@ -26,15 +26,23 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetBackendsParams creates a new GetBackendsParams object -// no default values defined in spec. +// with the default values initialized. func NewGetBackendsParams() GetBackendsParams { - return GetBackendsParams{} + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetBackendsParams{ + FullSection: &fullSectionDefault, + } } // GetBackendsParams contains all the bound params for the get backends operation @@ -46,6 +54,11 @@ type GetBackendsParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -63,17 +76,45 @@ func (o *GetBackendsParams) BindRequest(r *http.Request, route *middleware.Match qs := runtime.Values(r.URL.Query()) + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetBackendsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetBackendsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindTransactionID binds and validates parameter TransactionID from query. func (o *GetBackendsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -83,10 +124,10 @@ func (o *GetBackendsParams) bindTransactionID(rawData []string, hasKey bool, for // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/backend/get_backends_responses.go b/operations/backend/get_backends_responses.go index 1d0428c5..ffac299c 100644 --- a/operations/backend/get_backends_responses.go +++ b/operations/backend/get_backends_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetBackendsOKCode is the HTTP code returned for type GetBackendsOK const GetBackendsOKCode int = 200 -/*GetBackendsOK Successful operation +/* +GetBackendsOK Successful operation swagger:response getBackendsOK */ @@ -40,12 +40,12 @@ type GetBackendsOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetBackendsOKBody `json:"body,omitempty"` + Payload models.Backends `json:"body,omitempty"` } // NewGetBackendsOK creates GetBackendsOK with default headers values @@ -55,24 +55,24 @@ func NewGetBackendsOK() *GetBackendsOK { } // WithConfigurationVersion adds the configurationVersion to the get backends o k response -func (o *GetBackendsOK) WithConfigurationVersion(configurationVersion int64) *GetBackendsOK { +func (o *GetBackendsOK) WithConfigurationVersion(configurationVersion string) *GetBackendsOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backends o k response -func (o *GetBackendsOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendsOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get backends o k response -func (o *GetBackendsOK) WithPayload(payload *GetBackendsOKBody) *GetBackendsOK { +func (o *GetBackendsOK) WithPayload(payload models.Backends) *GetBackendsOK { o.Payload = payload return o } // SetPayload sets the payload to the get backends o k response -func (o *GetBackendsOK) SetPayload(payload *GetBackendsOKBody) { +func (o *GetBackendsOK) SetPayload(payload models.Backends) { o.Payload = payload } @@ -81,21 +81,25 @@ func (o *GetBackendsOK) WriteResponse(rw http.ResponseWriter, producer runtime.P // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Backends{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*GetBackendsDefault General Error +/* +GetBackendsDefault General Error swagger:response getBackendsDefault */ @@ -104,7 +108,7 @@ type GetBackendsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -135,13 +139,13 @@ func (o *GetBackendsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get backends default response -func (o *GetBackendsDefault) WithConfigurationVersion(configurationVersion int64) *GetBackendsDefault { +func (o *GetBackendsDefault) WithConfigurationVersion(configurationVersion string) *GetBackendsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backends default response -func (o *GetBackendsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -161,7 +165,7 @@ func (o *GetBackendsDefault) WriteResponse(rw http.ResponseWriter, producer runt // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend/get_backends_urlbuilder.go b/operations/backend/get_backends_urlbuilder.go index f868f49a..437683ba 100644 --- a/operations/backend/get_backends_urlbuilder.go +++ b/operations/backend/get_backends_urlbuilder.go @@ -24,10 +24,13 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // GetBackendsURL generates an URL for the get backends operation type GetBackendsURL struct { + FullSection *bool TransactionID *string _basePath string @@ -58,18 +61,26 @@ func (o *GetBackendsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend/replace_backend.go b/operations/backend/replace_backend.go index c5cf34e3..40a06301 100644 --- a/operations/backend/replace_backend.go +++ b/operations/backend/replace_backend.go @@ -23,7 +23,7 @@ package backend import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // ReplaceBackendHandlerFunc turns a function with the right signature into a replace backend handler @@ -44,12 +44,12 @@ func NewReplaceBackend(ctx *middleware.Context, handler ReplaceBackendHandler) * return &ReplaceBackend{Context: ctx, Handler: handler} } -/*ReplaceBackend swagger:route PUT /services/haproxy/configuration/backends/{name} Backend replaceBackend +/* + ReplaceBackend swagger:route PUT /services/haproxy/configuration/backends/{name} Backend replaceBackend -Replace a backend +# Replace a backend Replaces a backend configuration by it's name. - */ type ReplaceBackend struct { Context *middleware.Context @@ -59,21 +59,20 @@ type ReplaceBackend struct { func (o *ReplaceBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewReplaceBackendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *ReplaceBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/backend/replace_backend_parameters.go b/operations/backend/replace_backend_parameters.go index c362cc9d..fcaca396 100644 --- a/operations/backend/replace_backend_parameters.go +++ b/operations/backend/replace_backend_parameters.go @@ -27,11 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewReplaceBackendParams creates a new ReplaceBackendParams object @@ -42,10 +41,13 @@ func NewReplaceBackendParams() ReplaceBackendParams { // initialize parameters with default values forceReloadDefault = bool(false) + fullSectionDefault = bool(false) ) return ReplaceBackendParams{ ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, } } @@ -68,6 +70,11 @@ type ReplaceBackendParams struct { Default: false */ ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*Backend name Required: true In: path @@ -99,7 +106,7 @@ func (o *ReplaceBackendParams) BindRequest(r *http.Request, route *middleware.Ma var body models.Backend if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -114,13 +121,19 @@ func (o *ReplaceBackendParams) BindRequest(r *http.Request, route *middleware.Ma } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + rName, rhkName, _ := route.Params.GetOK("name") if err := o.bindName(rName, rhkName, route.Formats); err != nil { res = append(res, err) @@ -135,7 +148,6 @@ func (o *ReplaceBackendParams) BindRequest(r *http.Request, route *middleware.Ma if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -151,6 +163,7 @@ func (o *ReplaceBackendParams) bindForceReload(rawData []string, hasKey bool, fo // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewReplaceBackendParams() return nil @@ -165,6 +178,30 @@ func (o *ReplaceBackendParams) bindForceReload(rawData []string, hasKey bool, fo return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceBackendParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindName binds and validates parameter Name from path. func (o *ReplaceBackendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -174,7 +211,6 @@ func (o *ReplaceBackendParams) bindName(rawData []string, hasKey bool, formats s // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -189,10 +225,10 @@ func (o *ReplaceBackendParams) bindTransactionID(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -207,6 +243,7 @@ func (o *ReplaceBackendParams) bindVersion(rawData []string, hasKey bool, format // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/backend/replace_backend_responses.go b/operations/backend/replace_backend_responses.go index 9df64ba8..0758fc61 100644 --- a/operations/backend/replace_backend_responses.go +++ b/operations/backend/replace_backend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // ReplaceBackendOKCode is the HTTP code returned for type ReplaceBackendOK const ReplaceBackendOKCode int = 200 -/*ReplaceBackendOK Backend replaced +/* +ReplaceBackendOK Backend replaced swagger:response replaceBackendOK */ @@ -76,7 +76,8 @@ func (o *ReplaceBackendOK) WriteResponse(rw http.ResponseWriter, producer runtim // ReplaceBackendAcceptedCode is the HTTP code returned for type ReplaceBackendAccepted const ReplaceBackendAcceptedCode int = 202 -/*ReplaceBackendAccepted Configuration change accepted and reload requested +/* +ReplaceBackendAccepted Configuration change accepted and reload requested swagger:response replaceBackendAccepted */ @@ -142,7 +143,8 @@ func (o *ReplaceBackendAccepted) WriteResponse(rw http.ResponseWriter, producer // ReplaceBackendBadRequestCode is the HTTP code returned for type ReplaceBackendBadRequest const ReplaceBackendBadRequestCode int = 400 -/*ReplaceBackendBadRequest Bad request +/* +ReplaceBackendBadRequest Bad request swagger:response replaceBackendBadRequest */ @@ -150,7 +152,7 @@ type ReplaceBackendBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewReplaceBackendBadRequest() *ReplaceBackendBadRequest { } // WithConfigurationVersion adds the configurationVersion to the replace backend bad request response -func (o *ReplaceBackendBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceBackendBadRequest { +func (o *ReplaceBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceBackendBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace backend bad request response -func (o *ReplaceBackendBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceBackendBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *ReplaceBackendBadRequest) WriteResponse(rw http.ResponseWriter, produce // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *ReplaceBackendBadRequest) WriteResponse(rw http.ResponseWriter, produce // ReplaceBackendNotFoundCode is the HTTP code returned for type ReplaceBackendNotFound const ReplaceBackendNotFoundCode int = 404 -/*ReplaceBackendNotFound The specified resource was not found +/* +ReplaceBackendNotFound The specified resource was not found swagger:response replaceBackendNotFound */ @@ -216,7 +219,7 @@ type ReplaceBackendNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewReplaceBackendNotFound() *ReplaceBackendNotFound { } // WithConfigurationVersion adds the configurationVersion to the replace backend not found response -func (o *ReplaceBackendNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceBackendNotFound { +func (o *ReplaceBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceBackendNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace backend not found response -func (o *ReplaceBackendNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceBackendNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *ReplaceBackendNotFound) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *ReplaceBackendNotFound) WriteResponse(rw http.ResponseWriter, producer } } -/*ReplaceBackendDefault General Error +/* +ReplaceBackendDefault General Error swagger:response replaceBackendDefault */ @@ -280,7 +284,7 @@ type ReplaceBackendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *ReplaceBackendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the replace backend default response -func (o *ReplaceBackendDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceBackendDefault { +func (o *ReplaceBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceBackendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace backend default response -func (o *ReplaceBackendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceBackendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *ReplaceBackendDefault) WriteResponse(rw http.ResponseWriter, producer r // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend/replace_backend_urlbuilder.go b/operations/backend/replace_backend_urlbuilder.go index 77c845d0..15a2b424 100644 --- a/operations/backend/replace_backend_urlbuilder.go +++ b/operations/backend/replace_backend_urlbuilder.go @@ -34,6 +34,7 @@ type ReplaceBackendURL struct { Name string ForceReload *bool + FullSection *bool TransactionID *string Version *int64 @@ -72,34 +73,42 @@ func (o *ReplaceBackendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend_switching_rule/create_backend_switching_rule.go b/operations/backend_switching_rule/create_backend_switching_rule.go index e123fd01..802d0908 100644 --- a/operations/backend_switching_rule/create_backend_switching_rule.go +++ b/operations/backend_switching_rule/create_backend_switching_rule.go @@ -23,7 +23,7 @@ package backend_switching_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // CreateBackendSwitchingRuleHandlerFunc turns a function with the right signature into a create backend switching rule handler @@ -44,12 +44,12 @@ func NewCreateBackendSwitchingRule(ctx *middleware.Context, handler CreateBacken return &CreateBackendSwitchingRule{Context: ctx, Handler: handler} } -/*CreateBackendSwitchingRule swagger:route POST /services/haproxy/configuration/backend_switching_rules BackendSwitchingRule createBackendSwitchingRule +/* + CreateBackendSwitchingRule swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index} BackendSwitchingRule createBackendSwitchingRule -Add a new Backend Switching Rule +# Add a new Backend Switching Rule Adds a new Backend Switching Rule of the specified type in the specified frontend. - */ type CreateBackendSwitchingRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type CreateBackendSwitchingRule struct { func (o *CreateBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewCreateBackendSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *CreateBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.R } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/backend_switching_rule/create_backend_switching_rule_parameters.go b/operations/backend_switching_rule/create_backend_switching_rule_parameters.go index f5633f63..4c1370e7 100644 --- a/operations/backend_switching_rule/create_backend_switching_rule_parameters.go +++ b/operations/backend_switching_rule/create_backend_switching_rule_parameters.go @@ -27,12 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewCreateBackendSwitchingRuleParams creates a new CreateBackendSwitchingRuleParams object @@ -69,11 +67,16 @@ type CreateBackendSwitchingRuleParams struct { Default: false */ ForceReload *bool - /*Frontend name + /*Switching Rule Index Required: true - In: query + In: path + */ + Index int64 + /*Parent name + Required: true + In: path */ - Frontend string + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -100,7 +103,7 @@ func (o *CreateBackendSwitchingRuleParams) BindRequest(r *http.Request, route *m var body models.BackendSwitchingRule if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -115,15 +118,21 @@ func (o *CreateBackendSwitchingRuleParams) BindRequest(r *http.Request, route *m } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -136,7 +145,6 @@ func (o *CreateBackendSwitchingRuleParams) BindRequest(r *http.Request, route *m if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -152,6 +160,7 @@ func (o *CreateBackendSwitchingRuleParams) bindForceReload(rawData []string, has // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewCreateBackendSwitchingRuleParams() return nil @@ -166,23 +175,35 @@ func (o *CreateBackendSwitchingRuleParams) bindForceReload(rawData []string, has return nil } -// bindFrontend binds and validates parameter Frontend from query. -func (o *CreateBackendSwitchingRuleParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } +// bindIndex binds and validates parameter Index from path. +func (o *CreateBackendSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) } + o.Index = value - o.Frontend = raw + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateBackendSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -196,10 +217,10 @@ func (o *CreateBackendSwitchingRuleParams) bindTransactionID(rawData []string, h // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -214,6 +235,7 @@ func (o *CreateBackendSwitchingRuleParams) bindVersion(rawData []string, hasKey // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/backend_switching_rule/create_backend_switching_rule_responses.go b/operations/backend_switching_rule/create_backend_switching_rule_responses.go index 0ae66ca8..0acfc71c 100644 --- a/operations/backend_switching_rule/create_backend_switching_rule_responses.go +++ b/operations/backend_switching_rule/create_backend_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // CreateBackendSwitchingRuleCreatedCode is the HTTP code returned for type CreateBackendSwitchingRuleCreated const CreateBackendSwitchingRuleCreatedCode int = 201 -/*CreateBackendSwitchingRuleCreated Backend Switching Rule created +/* +CreateBackendSwitchingRuleCreated Backend Switching Rule created swagger:response createBackendSwitchingRuleCreated */ @@ -76,7 +76,8 @@ func (o *CreateBackendSwitchingRuleCreated) WriteResponse(rw http.ResponseWriter // CreateBackendSwitchingRuleAcceptedCode is the HTTP code returned for type CreateBackendSwitchingRuleAccepted const CreateBackendSwitchingRuleAcceptedCode int = 202 -/*CreateBackendSwitchingRuleAccepted Configuration change accepted and reload requested +/* +CreateBackendSwitchingRuleAccepted Configuration change accepted and reload requested swagger:response createBackendSwitchingRuleAccepted */ @@ -142,7 +143,8 @@ func (o *CreateBackendSwitchingRuleAccepted) WriteResponse(rw http.ResponseWrite // CreateBackendSwitchingRuleBadRequestCode is the HTTP code returned for type CreateBackendSwitchingRuleBadRequest const CreateBackendSwitchingRuleBadRequestCode int = 400 -/*CreateBackendSwitchingRuleBadRequest Bad request +/* +CreateBackendSwitchingRuleBadRequest Bad request swagger:response createBackendSwitchingRuleBadRequest */ @@ -150,7 +152,7 @@ type CreateBackendSwitchingRuleBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewCreateBackendSwitchingRuleBadRequest() *CreateBackendSwitchingRuleBadReq } // WithConfigurationVersion adds the configurationVersion to the create backend switching rule bad request response -func (o *CreateBackendSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateBackendSwitchingRuleBadRequest { +func (o *CreateBackendSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion string) *CreateBackendSwitchingRuleBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create backend switching rule bad request response -func (o *CreateBackendSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateBackendSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *CreateBackendSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWri // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *CreateBackendSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWri // CreateBackendSwitchingRuleConflictCode is the HTTP code returned for type CreateBackendSwitchingRuleConflict const CreateBackendSwitchingRuleConflictCode int = 409 -/*CreateBackendSwitchingRuleConflict The specified resource already exists +/* +CreateBackendSwitchingRuleConflict The specified resource already exists swagger:response createBackendSwitchingRuleConflict */ @@ -216,7 +219,7 @@ type CreateBackendSwitchingRuleConflict struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewCreateBackendSwitchingRuleConflict() *CreateBackendSwitchingRuleConflict } // WithConfigurationVersion adds the configurationVersion to the create backend switching rule conflict response -func (o *CreateBackendSwitchingRuleConflict) WithConfigurationVersion(configurationVersion int64) *CreateBackendSwitchingRuleConflict { +func (o *CreateBackendSwitchingRuleConflict) WithConfigurationVersion(configurationVersion string) *CreateBackendSwitchingRuleConflict { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create backend switching rule conflict response -func (o *CreateBackendSwitchingRuleConflict) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateBackendSwitchingRuleConflict) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *CreateBackendSwitchingRuleConflict) WriteResponse(rw http.ResponseWrite // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *CreateBackendSwitchingRuleConflict) WriteResponse(rw http.ResponseWrite } } -/*CreateBackendSwitchingRuleDefault General Error +/* +CreateBackendSwitchingRuleDefault General Error swagger:response createBackendSwitchingRuleDefault */ @@ -280,7 +284,7 @@ type CreateBackendSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *CreateBackendSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the create backend switching rule default response -func (o *CreateBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *CreateBackendSwitchingRuleDefault { +func (o *CreateBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *CreateBackendSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create backend switching rule default response -func (o *CreateBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *CreateBackendSwitchingRuleDefault) WriteResponse(rw http.ResponseWriter // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend_switching_rule/create_backend_switching_rule_urlbuilder.go b/operations/backend_switching_rule/create_backend_switching_rule_urlbuilder.go index 9aca14c4..feda85b9 100644 --- a/operations/backend_switching_rule/create_backend_switching_rule_urlbuilder.go +++ b/operations/backend_switching_rule/create_backend_switching_rule_urlbuilder.go @@ -24,14 +24,17 @@ import ( "errors" "net/url" golangswaggerpaths "path" + "strings" "github.com/go-openapi/swag" ) // CreateBackendSwitchingRuleURL generates an URL for the create backend switching rule operation type CreateBackendSwitchingRuleURL struct { + Index int64 + ParentName string + ForceReload *bool - Frontend string TransactionID *string Version *int64 @@ -59,43 +62,52 @@ func (o *CreateBackendSwitchingRuleURL) SetBasePath(bp string) { func (o *CreateBackendSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/backend_switching_rules" + var _path = "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateBackendSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateBackendSwitchingRuleURL") + } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend_switching_rule/delete_backend_switching_rule.go b/operations/backend_switching_rule/delete_backend_switching_rule.go index 90bf589c..c3b87edb 100644 --- a/operations/backend_switching_rule/delete_backend_switching_rule.go +++ b/operations/backend_switching_rule/delete_backend_switching_rule.go @@ -23,7 +23,7 @@ package backend_switching_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // DeleteBackendSwitchingRuleHandlerFunc turns a function with the right signature into a delete backend switching rule handler @@ -44,12 +44,12 @@ func NewDeleteBackendSwitchingRule(ctx *middleware.Context, handler DeleteBacken return &DeleteBackendSwitchingRule{Context: ctx, Handler: handler} } -/*DeleteBackendSwitchingRule swagger:route DELETE /services/haproxy/configuration/backend_switching_rules/{id} BackendSwitchingRule deleteBackendSwitchingRule +/* + DeleteBackendSwitchingRule swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index} BackendSwitchingRule deleteBackendSwitchingRule -Delete a Backend Switching Rule - -Deletes a Backend Switching Rule configuration by it's ID from the specified frontend. +# Delete a Backend Switching Rule +Deletes a Backend Switching Rule configuration by it's index from the specified frontend. */ type DeleteBackendSwitchingRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type DeleteBackendSwitchingRule struct { func (o *DeleteBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewDeleteBackendSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *DeleteBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.R } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/backend_switching_rule/delete_backend_switching_rule_parameters.go b/operations/backend_switching_rule/delete_backend_switching_rule_parameters.go index 7a028f84..73c9dd82 100644 --- a/operations/backend_switching_rule/delete_backend_switching_rule_parameters.go +++ b/operations/backend_switching_rule/delete_backend_switching_rule_parameters.go @@ -26,10 +26,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewDeleteBackendSwitchingRuleParams creates a new DeleteBackendSwitchingRuleParams object @@ -61,16 +59,16 @@ type DeleteBackendSwitchingRuleParams struct { Default: false */ ForceReload *bool - /*Frontend name + /*Switching Rule Index Required: true - In: query + In: path */ - Frontend string - /*Switching Rule ID + Index int64 + /*Parent name Required: true In: path */ - ID int64 + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -97,13 +95,13 @@ func (o *DeleteBackendSwitchingRuleParams) BindRequest(r *http.Request, route *m res = append(res, err) } - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -116,7 +114,6 @@ func (o *DeleteBackendSwitchingRuleParams) BindRequest(r *http.Request, route *m if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -132,6 +129,7 @@ func (o *DeleteBackendSwitchingRuleParams) bindForceReload(rawData []string, has // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewDeleteBackendSwitchingRuleParams() return nil @@ -146,29 +144,27 @@ func (o *DeleteBackendSwitchingRuleParams) bindForceReload(rawData []string, has return nil } -// bindFrontend binds and validates parameter Frontend from query. -func (o *DeleteBackendSwitchingRuleParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } +// bindIndex binds and validates parameter Index from path. +func (o *DeleteBackendSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } + // Parameter is provided by construction from the route - o.Frontend = raw + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value return nil } -// bindID binds and validates parameter ID from path. -func (o *DeleteBackendSwitchingRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteBackendSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -176,12 +172,7 @@ func (o *DeleteBackendSwitchingRuleParams) bindID(rawData []string, hasKey bool, // Required: true // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value + o.ParentName = raw return nil } @@ -195,10 +186,10 @@ func (o *DeleteBackendSwitchingRuleParams) bindTransactionID(rawData []string, h // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -213,6 +204,7 @@ func (o *DeleteBackendSwitchingRuleParams) bindVersion(rawData []string, hasKey // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/backend_switching_rule/delete_backend_switching_rule_responses.go b/operations/backend_switching_rule/delete_backend_switching_rule_responses.go index fe379110..c72d4038 100644 --- a/operations/backend_switching_rule/delete_backend_switching_rule_responses.go +++ b/operations/backend_switching_rule/delete_backend_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // DeleteBackendSwitchingRuleAcceptedCode is the HTTP code returned for type DeleteBackendSwitchingRuleAccepted const DeleteBackendSwitchingRuleAcceptedCode int = 202 -/*DeleteBackendSwitchingRuleAccepted Configuration change accepted and reload requested +/* +DeleteBackendSwitchingRuleAccepted Configuration change accepted and reload requested swagger:response deleteBackendSwitchingRuleAccepted */ @@ -78,7 +78,8 @@ func (o *DeleteBackendSwitchingRuleAccepted) WriteResponse(rw http.ResponseWrite // DeleteBackendSwitchingRuleNoContentCode is the HTTP code returned for type DeleteBackendSwitchingRuleNoContent const DeleteBackendSwitchingRuleNoContentCode int = 204 -/*DeleteBackendSwitchingRuleNoContent Backend Switching Rule deleted +/* +DeleteBackendSwitchingRuleNoContent Backend Switching Rule deleted swagger:response deleteBackendSwitchingRuleNoContent */ @@ -102,7 +103,8 @@ func (o *DeleteBackendSwitchingRuleNoContent) WriteResponse(rw http.ResponseWrit // DeleteBackendSwitchingRuleNotFoundCode is the HTTP code returned for type DeleteBackendSwitchingRuleNotFound const DeleteBackendSwitchingRuleNotFoundCode int = 404 -/*DeleteBackendSwitchingRuleNotFound The specified resource was not found +/* +DeleteBackendSwitchingRuleNotFound The specified resource was not found swagger:response deleteBackendSwitchingRuleNotFound */ @@ -110,7 +112,7 @@ type DeleteBackendSwitchingRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -125,13 +127,13 @@ func NewDeleteBackendSwitchingRuleNotFound() *DeleteBackendSwitchingRuleNotFound } // WithConfigurationVersion adds the configurationVersion to the delete backend switching rule not found response -func (o *DeleteBackendSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteBackendSwitchingRuleNotFound { +func (o *DeleteBackendSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion string) *DeleteBackendSwitchingRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete backend switching rule not found response -func (o *DeleteBackendSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteBackendSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -151,7 +153,7 @@ func (o *DeleteBackendSwitchingRuleNotFound) WriteResponse(rw http.ResponseWrite // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -165,7 +167,8 @@ func (o *DeleteBackendSwitchingRuleNotFound) WriteResponse(rw http.ResponseWrite } } -/*DeleteBackendSwitchingRuleDefault General Error +/* +DeleteBackendSwitchingRuleDefault General Error swagger:response deleteBackendSwitchingRuleDefault */ @@ -174,7 +177,7 @@ type DeleteBackendSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -205,13 +208,13 @@ func (o *DeleteBackendSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the delete backend switching rule default response -func (o *DeleteBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *DeleteBackendSwitchingRuleDefault { +func (o *DeleteBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *DeleteBackendSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete backend switching rule default response -func (o *DeleteBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -231,7 +234,7 @@ func (o *DeleteBackendSwitchingRuleDefault) WriteResponse(rw http.ResponseWriter // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend_switching_rule/delete_backend_switching_rule_urlbuilder.go b/operations/backend_switching_rule/delete_backend_switching_rule_urlbuilder.go index 34553b22..048b6766 100644 --- a/operations/backend_switching_rule/delete_backend_switching_rule_urlbuilder.go +++ b/operations/backend_switching_rule/delete_backend_switching_rule_urlbuilder.go @@ -31,10 +31,10 @@ import ( // DeleteBackendSwitchingRuleURL generates an URL for the delete backend switching rule operation type DeleteBackendSwitchingRuleURL struct { - ID int64 + Index int64 + ParentName string ForceReload *bool - Frontend string TransactionID *string Version *int64 @@ -62,50 +62,52 @@ func (o *DeleteBackendSwitchingRuleURL) SetBasePath(bp string) { func (o *DeleteBackendSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/backend_switching_rules/{id}" + var _path = "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on DeleteBackendSwitchingRuleURL") + return nil, errors.New("index is required on DeleteBackendSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteBackendSwitchingRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend_switching_rule/get_backend_switching_rule.go b/operations/backend_switching_rule/get_backend_switching_rule.go index b01197fc..3afeafb0 100644 --- a/operations/backend_switching_rule/get_backend_switching_rule.go +++ b/operations/backend_switching_rule/get_backend_switching_rule.go @@ -23,12 +23,7 @@ package backend_switching_rule import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetBackendSwitchingRuleHandlerFunc turns a function with the right signature into a get backend switching rule handler @@ -49,12 +44,12 @@ func NewGetBackendSwitchingRule(ctx *middleware.Context, handler GetBackendSwitc return &GetBackendSwitchingRule{Context: ctx, Handler: handler} } -/*GetBackendSwitchingRule swagger:route GET /services/haproxy/configuration/backend_switching_rules/{id} BackendSwitchingRule getBackendSwitchingRule - -Return one Backend Switching Rule +/* + GetBackendSwitchingRule swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index} BackendSwitchingRule getBackendSwitchingRule -Returns one Backend Switching Rule configuration by it's ID in the specified frontend. +# Return one Backend Switching Rule +Returns one Backend Switching Rule configuration by it's index in the specified frontend. */ type GetBackendSwitchingRule struct { Context *middleware.Context @@ -64,21 +59,20 @@ type GetBackendSwitchingRule struct { func (o *GetBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetBackendSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -87,68 +81,6 @@ func (o *GetBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Requ } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetBackendSwitchingRuleOKBody get backend switching rule o k body -// swagger:model GetBackendSwitchingRuleOKBody -type GetBackendSwitchingRuleOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.BackendSwitchingRule `json:"data,omitempty"` -} - -// Validate validates this get backend switching rule o k body -func (o *GetBackendSwitchingRuleOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetBackendSwitchingRuleOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getBackendSwitchingRuleOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetBackendSwitchingRuleOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetBackendSwitchingRuleOKBody) UnmarshalBinary(b []byte) error { - var res GetBackendSwitchingRuleOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/backend_switching_rule/get_backend_switching_rule_parameters.go b/operations/backend_switching_rule/get_backend_switching_rule_parameters.go index 307f78a2..d8b2f113 100644 --- a/operations/backend_switching_rule/get_backend_switching_rule_parameters.go +++ b/operations/backend_switching_rule/get_backend_switching_rule_parameters.go @@ -26,14 +26,13 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewGetBackendSwitchingRuleParams creates a new GetBackendSwitchingRuleParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetBackendSwitchingRuleParams() GetBackendSwitchingRuleParams { return GetBackendSwitchingRuleParams{} @@ -48,16 +47,16 @@ type GetBackendSwitchingRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Frontend name + /*Switching Rule Index Required: true - In: query + In: path */ - Frontend string - /*Switching Rule ID + Index int64 + /*Parent name Required: true In: path */ - ID int64 + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -75,13 +74,13 @@ func (o *GetBackendSwitchingRuleParams) BindRequest(r *http.Request, route *midd qs := runtime.Values(r.URL.Query()) - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -89,36 +88,33 @@ func (o *GetBackendSwitchingRuleParams) BindRequest(r *http.Request, route *midd if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindFrontend binds and validates parameter Frontend from query. -func (o *GetBackendSwitchingRuleParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } +// bindIndex binds and validates parameter Index from path. +func (o *GetBackendSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } + // Parameter is provided by construction from the route - o.Frontend = raw + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value return nil } -// bindID binds and validates parameter ID from path. -func (o *GetBackendSwitchingRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindParentName binds and validates parameter ParentName from path. +func (o *GetBackendSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -126,12 +122,7 @@ func (o *GetBackendSwitchingRuleParams) bindID(rawData []string, hasKey bool, fo // Required: true // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value + o.ParentName = raw return nil } @@ -145,10 +136,10 @@ func (o *GetBackendSwitchingRuleParams) bindTransactionID(rawData []string, hasK // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/backend_switching_rule/get_backend_switching_rule_responses.go b/operations/backend_switching_rule/get_backend_switching_rule_responses.go index e4a11e9a..e8f22a42 100644 --- a/operations/backend_switching_rule/get_backend_switching_rule_responses.go +++ b/operations/backend_switching_rule/get_backend_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetBackendSwitchingRuleOKCode is the HTTP code returned for type GetBackendSwitchingRuleOK const GetBackendSwitchingRuleOKCode int = 200 -/*GetBackendSwitchingRuleOK Successful operation +/* +GetBackendSwitchingRuleOK Successful operation swagger:response getBackendSwitchingRuleOK */ @@ -40,12 +40,12 @@ type GetBackendSwitchingRuleOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetBackendSwitchingRuleOKBody `json:"body,omitempty"` + Payload *models.BackendSwitchingRule `json:"body,omitempty"` } // NewGetBackendSwitchingRuleOK creates GetBackendSwitchingRuleOK with default headers values @@ -55,24 +55,24 @@ func NewGetBackendSwitchingRuleOK() *GetBackendSwitchingRuleOK { } // WithConfigurationVersion adds the configurationVersion to the get backend switching rule o k response -func (o *GetBackendSwitchingRuleOK) WithConfigurationVersion(configurationVersion int64) *GetBackendSwitchingRuleOK { +func (o *GetBackendSwitchingRuleOK) WithConfigurationVersion(configurationVersion string) *GetBackendSwitchingRuleOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend switching rule o k response -func (o *GetBackendSwitchingRuleOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendSwitchingRuleOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get backend switching rule o k response -func (o *GetBackendSwitchingRuleOK) WithPayload(payload *GetBackendSwitchingRuleOKBody) *GetBackendSwitchingRuleOK { +func (o *GetBackendSwitchingRuleOK) WithPayload(payload *models.BackendSwitchingRule) *GetBackendSwitchingRuleOK { o.Payload = payload return o } // SetPayload sets the payload to the get backend switching rule o k response -func (o *GetBackendSwitchingRuleOK) SetPayload(payload *GetBackendSwitchingRuleOKBody) { +func (o *GetBackendSwitchingRuleOK) SetPayload(payload *models.BackendSwitchingRule) { o.Payload = payload } @@ -81,7 +81,7 @@ func (o *GetBackendSwitchingRuleOK) WriteResponse(rw http.ResponseWriter, produc // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -98,7 +98,8 @@ func (o *GetBackendSwitchingRuleOK) WriteResponse(rw http.ResponseWriter, produc // GetBackendSwitchingRuleNotFoundCode is the HTTP code returned for type GetBackendSwitchingRuleNotFound const GetBackendSwitchingRuleNotFoundCode int = 404 -/*GetBackendSwitchingRuleNotFound The specified resource was not found +/* +GetBackendSwitchingRuleNotFound The specified resource was not found swagger:response getBackendSwitchingRuleNotFound */ @@ -106,7 +107,7 @@ type GetBackendSwitchingRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -121,13 +122,13 @@ func NewGetBackendSwitchingRuleNotFound() *GetBackendSwitchingRuleNotFound { } // WithConfigurationVersion adds the configurationVersion to the get backend switching rule not found response -func (o *GetBackendSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion int64) *GetBackendSwitchingRuleNotFound { +func (o *GetBackendSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion string) *GetBackendSwitchingRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend switching rule not found response -func (o *GetBackendSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -147,7 +148,7 @@ func (o *GetBackendSwitchingRuleNotFound) WriteResponse(rw http.ResponseWriter, // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -161,7 +162,8 @@ func (o *GetBackendSwitchingRuleNotFound) WriteResponse(rw http.ResponseWriter, } } -/*GetBackendSwitchingRuleDefault General Error +/* +GetBackendSwitchingRuleDefault General Error swagger:response getBackendSwitchingRuleDefault */ @@ -170,7 +172,7 @@ type GetBackendSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -201,13 +203,13 @@ func (o *GetBackendSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get backend switching rule default response -func (o *GetBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *GetBackendSwitchingRuleDefault { +func (o *GetBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *GetBackendSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend switching rule default response -func (o *GetBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -227,7 +229,7 @@ func (o *GetBackendSwitchingRuleDefault) WriteResponse(rw http.ResponseWriter, p // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend_switching_rule/get_backend_switching_rule_urlbuilder.go b/operations/backend_switching_rule/get_backend_switching_rule_urlbuilder.go index 29a04b15..3f1ca69c 100644 --- a/operations/backend_switching_rule/get_backend_switching_rule_urlbuilder.go +++ b/operations/backend_switching_rule/get_backend_switching_rule_urlbuilder.go @@ -31,9 +31,9 @@ import ( // GetBackendSwitchingRuleURL generates an URL for the get backend switching rule operation type GetBackendSwitchingRuleURL struct { - ID int64 + Index int64 + ParentName string - Frontend string TransactionID *string _basePath string @@ -60,34 +60,36 @@ func (o *GetBackendSwitchingRuleURL) SetBasePath(bp string) { func (o *GetBackendSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/backend_switching_rules/{id}" + var _path = "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on GetBackendSwitchingRuleURL") + return nil, errors.New("index is required on GetBackendSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetBackendSwitchingRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) - } - - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend_switching_rule/get_backend_switching_rules.go b/operations/backend_switching_rule/get_backend_switching_rules.go index f3336de0..c5e3e987 100644 --- a/operations/backend_switching_rule/get_backend_switching_rules.go +++ b/operations/backend_switching_rule/get_backend_switching_rules.go @@ -23,13 +23,7 @@ package backend_switching_rule import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetBackendSwitchingRulesHandlerFunc turns a function with the right signature into a get backend switching rules handler @@ -50,12 +44,12 @@ func NewGetBackendSwitchingRules(ctx *middleware.Context, handler GetBackendSwit return &GetBackendSwitchingRules{Context: ctx, Handler: handler} } -/*GetBackendSwitchingRules swagger:route GET /services/haproxy/configuration/backend_switching_rules BackendSwitchingRule getBackendSwitchingRules +/* + GetBackendSwitchingRules swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules BackendSwitchingRule getBackendSwitchingRules -Return an array of all Backend Switching Rules +# Return an array of all Backend Switching Rules Returns all Backend Switching Rules that are configured in specified frontend. - */ type GetBackendSwitchingRules struct { Context *middleware.Context @@ -65,21 +59,20 @@ type GetBackendSwitchingRules struct { func (o *GetBackendSwitchingRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetBackendSwitchingRulesParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -88,67 +81,6 @@ func (o *GetBackendSwitchingRules) ServeHTTP(rw http.ResponseWriter, r *http.Req } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetBackendSwitchingRulesOKBody get backend switching rules o k body -// swagger:model GetBackendSwitchingRulesOKBody -type GetBackendSwitchingRulesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.BackendSwitchingRules `json:"data"` -} - -// Validate validates this get backend switching rules o k body -func (o *GetBackendSwitchingRulesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetBackendSwitchingRulesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getBackendSwitchingRulesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getBackendSwitchingRulesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetBackendSwitchingRulesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetBackendSwitchingRulesOKBody) UnmarshalBinary(b []byte) error { - var res GetBackendSwitchingRulesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/backend_switching_rule/get_backend_switching_rules_parameters.go b/operations/backend_switching_rule/get_backend_switching_rules_parameters.go index be75cbbc..a5a4c8ec 100644 --- a/operations/backend_switching_rule/get_backend_switching_rules_parameters.go +++ b/operations/backend_switching_rule/get_backend_switching_rules_parameters.go @@ -26,13 +26,12 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewGetBackendSwitchingRulesParams creates a new GetBackendSwitchingRulesParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetBackendSwitchingRulesParams() GetBackendSwitchingRulesParams { return GetBackendSwitchingRulesParams{} @@ -47,11 +46,11 @@ type GetBackendSwitchingRulesParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Frontend name + /*Parent name Required: true - In: query + In: path */ - Frontend string + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -69,8 +68,8 @@ func (o *GetBackendSwitchingRulesParams) BindRequest(r *http.Request, route *mid qs := runtime.Values(r.URL.Query()) - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -78,30 +77,22 @@ func (o *GetBackendSwitchingRulesParams) BindRequest(r *http.Request, route *mid if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindFrontend binds and validates parameter Frontend from query. -func (o *GetBackendSwitchingRulesParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } +// bindParentName binds and validates parameter ParentName from path. +func (o *GetBackendSwitchingRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } - - o.Frontend = raw + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -115,10 +106,10 @@ func (o *GetBackendSwitchingRulesParams) bindTransactionID(rawData []string, has // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/backend_switching_rule/get_backend_switching_rules_responses.go b/operations/backend_switching_rule/get_backend_switching_rules_responses.go index 6a7eb909..3dc60d0c 100644 --- a/operations/backend_switching_rule/get_backend_switching_rules_responses.go +++ b/operations/backend_switching_rule/get_backend_switching_rules_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetBackendSwitchingRulesOKCode is the HTTP code returned for type GetBackendSwitchingRulesOK const GetBackendSwitchingRulesOKCode int = 200 -/*GetBackendSwitchingRulesOK Successful operation +/* +GetBackendSwitchingRulesOK Successful operation swagger:response getBackendSwitchingRulesOK */ @@ -40,12 +40,12 @@ type GetBackendSwitchingRulesOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetBackendSwitchingRulesOKBody `json:"body,omitempty"` + Payload models.BackendSwitchingRules `json:"body,omitempty"` } // NewGetBackendSwitchingRulesOK creates GetBackendSwitchingRulesOK with default headers values @@ -55,24 +55,24 @@ func NewGetBackendSwitchingRulesOK() *GetBackendSwitchingRulesOK { } // WithConfigurationVersion adds the configurationVersion to the get backend switching rules o k response -func (o *GetBackendSwitchingRulesOK) WithConfigurationVersion(configurationVersion int64) *GetBackendSwitchingRulesOK { +func (o *GetBackendSwitchingRulesOK) WithConfigurationVersion(configurationVersion string) *GetBackendSwitchingRulesOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend switching rules o k response -func (o *GetBackendSwitchingRulesOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendSwitchingRulesOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get backend switching rules o k response -func (o *GetBackendSwitchingRulesOK) WithPayload(payload *GetBackendSwitchingRulesOKBody) *GetBackendSwitchingRulesOK { +func (o *GetBackendSwitchingRulesOK) WithPayload(payload models.BackendSwitchingRules) *GetBackendSwitchingRulesOK { o.Payload = payload return o } // SetPayload sets the payload to the get backend switching rules o k response -func (o *GetBackendSwitchingRulesOK) SetPayload(payload *GetBackendSwitchingRulesOKBody) { +func (o *GetBackendSwitchingRulesOK) SetPayload(payload models.BackendSwitchingRules) { o.Payload = payload } @@ -81,21 +81,25 @@ func (o *GetBackendSwitchingRulesOK) WriteResponse(rw http.ResponseWriter, produ // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if payload == nil { + // return empty array + payload = models.BackendSwitchingRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*GetBackendSwitchingRulesDefault General Error +/* +GetBackendSwitchingRulesDefault General Error swagger:response getBackendSwitchingRulesDefault */ @@ -104,7 +108,7 @@ type GetBackendSwitchingRulesDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -135,13 +139,13 @@ func (o *GetBackendSwitchingRulesDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get backend switching rules default response -func (o *GetBackendSwitchingRulesDefault) WithConfigurationVersion(configurationVersion int64) *GetBackendSwitchingRulesDefault { +func (o *GetBackendSwitchingRulesDefault) WithConfigurationVersion(configurationVersion string) *GetBackendSwitchingRulesDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get backend switching rules default response -func (o *GetBackendSwitchingRulesDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetBackendSwitchingRulesDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -161,7 +165,7 @@ func (o *GetBackendSwitchingRulesDefault) WriteResponse(rw http.ResponseWriter, // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend_switching_rule/get_backend_switching_rules_urlbuilder.go b/operations/backend_switching_rule/get_backend_switching_rules_urlbuilder.go index 2f6afc1b..0337e805 100644 --- a/operations/backend_switching_rule/get_backend_switching_rules_urlbuilder.go +++ b/operations/backend_switching_rule/get_backend_switching_rules_urlbuilder.go @@ -24,11 +24,13 @@ import ( "errors" "net/url" golangswaggerpaths "path" + "strings" ) // GetBackendSwitchingRulesURL generates an URL for the get backend switching rules operation type GetBackendSwitchingRulesURL struct { - Frontend string + ParentName string + TransactionID *string _basePath string @@ -55,27 +57,29 @@ func (o *GetBackendSwitchingRulesURL) SetBasePath(bp string) { func (o *GetBackendSwitchingRulesURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/backend_switching_rules" + var _path = "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetBackendSwitchingRulesURL") + } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) - } - - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend_switching_rule/replace_backend_switching_rule.go b/operations/backend_switching_rule/replace_backend_switching_rule.go index 9dac0a2f..60f532a7 100644 --- a/operations/backend_switching_rule/replace_backend_switching_rule.go +++ b/operations/backend_switching_rule/replace_backend_switching_rule.go @@ -23,7 +23,7 @@ package backend_switching_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // ReplaceBackendSwitchingRuleHandlerFunc turns a function with the right signature into a replace backend switching rule handler @@ -44,12 +44,12 @@ func NewReplaceBackendSwitchingRule(ctx *middleware.Context, handler ReplaceBack return &ReplaceBackendSwitchingRule{Context: ctx, Handler: handler} } -/*ReplaceBackendSwitchingRule swagger:route PUT /services/haproxy/configuration/backend_switching_rules/{id} BackendSwitchingRule replaceBackendSwitchingRule +/* + ReplaceBackendSwitchingRule swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index} BackendSwitchingRule replaceBackendSwitchingRule -Replace a Backend Switching Rule - -Replaces a Backend Switching Rule configuration by it's ID in the specified frontend. +# Replace a Backend Switching Rule +Replaces a Backend Switching Rule configuration by it's index in the specified frontend. */ type ReplaceBackendSwitchingRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type ReplaceBackendSwitchingRule struct { func (o *ReplaceBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewReplaceBackendSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *ReplaceBackendSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http. } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/backend_switching_rule/replace_backend_switching_rule_parameters.go b/operations/backend_switching_rule/replace_backend_switching_rule_parameters.go index 09d34388..6b471636 100644 --- a/operations/backend_switching_rule/replace_backend_switching_rule_parameters.go +++ b/operations/backend_switching_rule/replace_backend_switching_rule_parameters.go @@ -27,12 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewReplaceBackendSwitchingRuleParams creates a new ReplaceBackendSwitchingRuleParams object @@ -69,16 +67,16 @@ type ReplaceBackendSwitchingRuleParams struct { Default: false */ ForceReload *bool - /*Frontend name + /*Switching Rule Index Required: true - In: query + In: path */ - Frontend string - /*Switching Rule ID + Index int64 + /*Parent name Required: true In: path */ - ID int64 + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -105,7 +103,7 @@ func (o *ReplaceBackendSwitchingRuleParams) BindRequest(r *http.Request, route * var body models.BackendSwitchingRule if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -120,20 +118,21 @@ func (o *ReplaceBackendSwitchingRuleParams) BindRequest(r *http.Request, route * } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -146,7 +145,6 @@ func (o *ReplaceBackendSwitchingRuleParams) BindRequest(r *http.Request, route * if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -162,6 +160,7 @@ func (o *ReplaceBackendSwitchingRuleParams) bindForceReload(rawData []string, ha // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewReplaceBackendSwitchingRuleParams() return nil @@ -176,29 +175,27 @@ func (o *ReplaceBackendSwitchingRuleParams) bindForceReload(rawData []string, ha return nil } -// bindFrontend binds and validates parameter Frontend from query. -func (o *ReplaceBackendSwitchingRuleParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceBackendSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } + // Parameter is provided by construction from the route - o.Frontend = raw + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value return nil } -// bindID binds and validates parameter ID from path. -func (o *ReplaceBackendSwitchingRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceBackendSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -206,12 +203,7 @@ func (o *ReplaceBackendSwitchingRuleParams) bindID(rawData []string, hasKey bool // Required: true // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value + o.ParentName = raw return nil } @@ -225,10 +217,10 @@ func (o *ReplaceBackendSwitchingRuleParams) bindTransactionID(rawData []string, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -243,6 +235,7 @@ func (o *ReplaceBackendSwitchingRuleParams) bindVersion(rawData []string, hasKey // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/backend_switching_rule/replace_backend_switching_rule_responses.go b/operations/backend_switching_rule/replace_backend_switching_rule_responses.go index 547c43e4..b88adc8c 100644 --- a/operations/backend_switching_rule/replace_backend_switching_rule_responses.go +++ b/operations/backend_switching_rule/replace_backend_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // ReplaceBackendSwitchingRuleOKCode is the HTTP code returned for type ReplaceBackendSwitchingRuleOK const ReplaceBackendSwitchingRuleOKCode int = 200 -/*ReplaceBackendSwitchingRuleOK Backend Switching Rule replaced +/* +ReplaceBackendSwitchingRuleOK Backend Switching Rule replaced swagger:response replaceBackendSwitchingRuleOK */ @@ -76,7 +76,8 @@ func (o *ReplaceBackendSwitchingRuleOK) WriteResponse(rw http.ResponseWriter, pr // ReplaceBackendSwitchingRuleAcceptedCode is the HTTP code returned for type ReplaceBackendSwitchingRuleAccepted const ReplaceBackendSwitchingRuleAcceptedCode int = 202 -/*ReplaceBackendSwitchingRuleAccepted Configuration change accepted and reload requested +/* +ReplaceBackendSwitchingRuleAccepted Configuration change accepted and reload requested swagger:response replaceBackendSwitchingRuleAccepted */ @@ -142,7 +143,8 @@ func (o *ReplaceBackendSwitchingRuleAccepted) WriteResponse(rw http.ResponseWrit // ReplaceBackendSwitchingRuleBadRequestCode is the HTTP code returned for type ReplaceBackendSwitchingRuleBadRequest const ReplaceBackendSwitchingRuleBadRequestCode int = 400 -/*ReplaceBackendSwitchingRuleBadRequest Bad request +/* +ReplaceBackendSwitchingRuleBadRequest Bad request swagger:response replaceBackendSwitchingRuleBadRequest */ @@ -150,7 +152,7 @@ type ReplaceBackendSwitchingRuleBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewReplaceBackendSwitchingRuleBadRequest() *ReplaceBackendSwitchingRuleBadR } // WithConfigurationVersion adds the configurationVersion to the replace backend switching rule bad request response -func (o *ReplaceBackendSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceBackendSwitchingRuleBadRequest { +func (o *ReplaceBackendSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceBackendSwitchingRuleBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace backend switching rule bad request response -func (o *ReplaceBackendSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceBackendSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *ReplaceBackendSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWr // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *ReplaceBackendSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWr // ReplaceBackendSwitchingRuleNotFoundCode is the HTTP code returned for type ReplaceBackendSwitchingRuleNotFound const ReplaceBackendSwitchingRuleNotFoundCode int = 404 -/*ReplaceBackendSwitchingRuleNotFound The specified resource was not found +/* +ReplaceBackendSwitchingRuleNotFound The specified resource was not found swagger:response replaceBackendSwitchingRuleNotFound */ @@ -216,7 +219,7 @@ type ReplaceBackendSwitchingRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewReplaceBackendSwitchingRuleNotFound() *ReplaceBackendSwitchingRuleNotFou } // WithConfigurationVersion adds the configurationVersion to the replace backend switching rule not found response -func (o *ReplaceBackendSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceBackendSwitchingRuleNotFound { +func (o *ReplaceBackendSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceBackendSwitchingRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace backend switching rule not found response -func (o *ReplaceBackendSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceBackendSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *ReplaceBackendSwitchingRuleNotFound) WriteResponse(rw http.ResponseWrit // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *ReplaceBackendSwitchingRuleNotFound) WriteResponse(rw http.ResponseWrit } } -/*ReplaceBackendSwitchingRuleDefault General Error +/* +ReplaceBackendSwitchingRuleDefault General Error swagger:response replaceBackendSwitchingRuleDefault */ @@ -280,7 +284,7 @@ type ReplaceBackendSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *ReplaceBackendSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the replace backend switching rule default response -func (o *ReplaceBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceBackendSwitchingRuleDefault { +func (o *ReplaceBackendSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *ReplaceBackendSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace backend switching rule default response -func (o *ReplaceBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceBackendSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *ReplaceBackendSwitchingRuleDefault) WriteResponse(rw http.ResponseWrite // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/backend_switching_rule/replace_backend_switching_rule_urlbuilder.go b/operations/backend_switching_rule/replace_backend_switching_rule_urlbuilder.go index ec498134..efe93726 100644 --- a/operations/backend_switching_rule/replace_backend_switching_rule_urlbuilder.go +++ b/operations/backend_switching_rule/replace_backend_switching_rule_urlbuilder.go @@ -31,10 +31,10 @@ import ( // ReplaceBackendSwitchingRuleURL generates an URL for the replace backend switching rule operation type ReplaceBackendSwitchingRuleURL struct { - ID int64 + Index int64 + ParentName string ForceReload *bool - Frontend string TransactionID *string Version *int64 @@ -62,50 +62,52 @@ func (o *ReplaceBackendSwitchingRuleURL) SetBasePath(bp string) { func (o *ReplaceBackendSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/backend_switching_rules/{id}" + var _path = "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on ReplaceBackendSwitchingRuleURL") + return nil, errors.New("index is required on ReplaceBackendSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceBackendSwitchingRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/backend_switching_rule/replace_backend_switching_rules.go b/operations/backend_switching_rule/replace_backend_switching_rules.go new file mode 100644 index 00000000..a21a71e4 --- /dev/null +++ b/operations/backend_switching_rule/replace_backend_switching_rules.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package backend_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceBackendSwitchingRulesHandlerFunc turns a function with the right signature into a replace backend switching rules handler +type ReplaceBackendSwitchingRulesHandlerFunc func(ReplaceBackendSwitchingRulesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceBackendSwitchingRulesHandlerFunc) Handle(params ReplaceBackendSwitchingRulesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceBackendSwitchingRulesHandler interface for that can handle valid replace backend switching rules params +type ReplaceBackendSwitchingRulesHandler interface { + Handle(ReplaceBackendSwitchingRulesParams, interface{}) middleware.Responder +} + +// NewReplaceBackendSwitchingRules creates a new http.Handler for the replace backend switching rules operation +func NewReplaceBackendSwitchingRules(ctx *middleware.Context, handler ReplaceBackendSwitchingRulesHandler) *ReplaceBackendSwitchingRules { + return &ReplaceBackendSwitchingRules{Context: ctx, Handler: handler} +} + +/* + ReplaceBackendSwitchingRules swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules BackendSwitchingRule replaceBackendSwitchingRules + +# Replace an Backend Switching Rule list + +Replaces a whole list of Backend Switching Rules with the list given in parameter +*/ +type ReplaceBackendSwitchingRules struct { + Context *middleware.Context + Handler ReplaceBackendSwitchingRulesHandler +} + +func (o *ReplaceBackendSwitchingRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceBackendSwitchingRulesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/backend_switching_rule/replace_backend_switching_rules_parameters.go b/operations/backend_switching_rule/replace_backend_switching_rules_parameters.go new file mode 100644 index 00000000..9904b2f2 --- /dev/null +++ b/operations/backend_switching_rule/replace_backend_switching_rules_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package backend_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceBackendSwitchingRulesParams creates a new ReplaceBackendSwitchingRulesParams object +// with the default values initialized. +func NewReplaceBackendSwitchingRulesParams() ReplaceBackendSwitchingRulesParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceBackendSwitchingRulesParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceBackendSwitchingRulesParams contains all the bound params for the replace backend switching rules operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceBackendSwitchingRules +type ReplaceBackendSwitchingRulesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.BackendSwitchingRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceBackendSwitchingRulesParams() beforehand. +func (o *ReplaceBackendSwitchingRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.BackendSwitchingRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceBackendSwitchingRulesParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceBackendSwitchingRulesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceBackendSwitchingRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceBackendSwitchingRulesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceBackendSwitchingRulesParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/backend_switching_rule/replace_backend_switching_rules_responses.go b/operations/backend_switching_rule/replace_backend_switching_rules_responses.go new file mode 100644 index 00000000..c435561a --- /dev/null +++ b/operations/backend_switching_rule/replace_backend_switching_rules_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package backend_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceBackendSwitchingRulesOKCode is the HTTP code returned for type ReplaceBackendSwitchingRulesOK +const ReplaceBackendSwitchingRulesOKCode int = 200 + +/* +ReplaceBackendSwitchingRulesOK All Backend Switching Rule lines replaced + +swagger:response replaceBackendSwitchingRulesOK +*/ +type ReplaceBackendSwitchingRulesOK struct { + + /* + In: Body + */ + Payload models.BackendSwitchingRules `json:"body,omitempty"` +} + +// NewReplaceBackendSwitchingRulesOK creates ReplaceBackendSwitchingRulesOK with default headers values +func NewReplaceBackendSwitchingRulesOK() *ReplaceBackendSwitchingRulesOK { + + return &ReplaceBackendSwitchingRulesOK{} +} + +// WithPayload adds the payload to the replace backend switching rules o k response +func (o *ReplaceBackendSwitchingRulesOK) WithPayload(payload models.BackendSwitchingRules) *ReplaceBackendSwitchingRulesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace backend switching rules o k response +func (o *ReplaceBackendSwitchingRulesOK) SetPayload(payload models.BackendSwitchingRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBackendSwitchingRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.BackendSwitchingRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceBackendSwitchingRulesAcceptedCode is the HTTP code returned for type ReplaceBackendSwitchingRulesAccepted +const ReplaceBackendSwitchingRulesAcceptedCode int = 202 + +/* +ReplaceBackendSwitchingRulesAccepted Configuration change accepted and reload requested + +swagger:response replaceBackendSwitchingRulesAccepted +*/ +type ReplaceBackendSwitchingRulesAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.BackendSwitchingRules `json:"body,omitempty"` +} + +// NewReplaceBackendSwitchingRulesAccepted creates ReplaceBackendSwitchingRulesAccepted with default headers values +func NewReplaceBackendSwitchingRulesAccepted() *ReplaceBackendSwitchingRulesAccepted { + + return &ReplaceBackendSwitchingRulesAccepted{} +} + +// WithReloadID adds the reloadId to the replace backend switching rules accepted response +func (o *ReplaceBackendSwitchingRulesAccepted) WithReloadID(reloadID string) *ReplaceBackendSwitchingRulesAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace backend switching rules accepted response +func (o *ReplaceBackendSwitchingRulesAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace backend switching rules accepted response +func (o *ReplaceBackendSwitchingRulesAccepted) WithPayload(payload models.BackendSwitchingRules) *ReplaceBackendSwitchingRulesAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace backend switching rules accepted response +func (o *ReplaceBackendSwitchingRulesAccepted) SetPayload(payload models.BackendSwitchingRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBackendSwitchingRulesAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.BackendSwitchingRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceBackendSwitchingRulesBadRequestCode is the HTTP code returned for type ReplaceBackendSwitchingRulesBadRequest +const ReplaceBackendSwitchingRulesBadRequestCode int = 400 + +/* +ReplaceBackendSwitchingRulesBadRequest Bad request + +swagger:response replaceBackendSwitchingRulesBadRequest +*/ +type ReplaceBackendSwitchingRulesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBackendSwitchingRulesBadRequest creates ReplaceBackendSwitchingRulesBadRequest with default headers values +func NewReplaceBackendSwitchingRulesBadRequest() *ReplaceBackendSwitchingRulesBadRequest { + + return &ReplaceBackendSwitchingRulesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace backend switching rules bad request response +func (o *ReplaceBackendSwitchingRulesBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceBackendSwitchingRulesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace backend switching rules bad request response +func (o *ReplaceBackendSwitchingRulesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace backend switching rules bad request response +func (o *ReplaceBackendSwitchingRulesBadRequest) WithPayload(payload *models.Error) *ReplaceBackendSwitchingRulesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace backend switching rules bad request response +func (o *ReplaceBackendSwitchingRulesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBackendSwitchingRulesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceBackendSwitchingRulesDefault General Error + +swagger:response replaceBackendSwitchingRulesDefault +*/ +type ReplaceBackendSwitchingRulesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBackendSwitchingRulesDefault creates ReplaceBackendSwitchingRulesDefault with default headers values +func NewReplaceBackendSwitchingRulesDefault(code int) *ReplaceBackendSwitchingRulesDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceBackendSwitchingRulesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace backend switching rules default response +func (o *ReplaceBackendSwitchingRulesDefault) WithStatusCode(code int) *ReplaceBackendSwitchingRulesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace backend switching rules default response +func (o *ReplaceBackendSwitchingRulesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace backend switching rules default response +func (o *ReplaceBackendSwitchingRulesDefault) WithConfigurationVersion(configurationVersion string) *ReplaceBackendSwitchingRulesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace backend switching rules default response +func (o *ReplaceBackendSwitchingRulesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace backend switching rules default response +func (o *ReplaceBackendSwitchingRulesDefault) WithPayload(payload *models.Error) *ReplaceBackendSwitchingRulesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace backend switching rules default response +func (o *ReplaceBackendSwitchingRulesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBackendSwitchingRulesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/backend_switching_rule/replace_backend_switching_rules_urlbuilder.go b/operations/backend_switching_rule/replace_backend_switching_rules_urlbuilder.go new file mode 100644 index 00000000..aa88ed07 --- /dev/null +++ b/operations/backend_switching_rule/replace_backend_switching_rules_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package backend_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceBackendSwitchingRulesURL generates an URL for the replace backend switching rules operation +type ReplaceBackendSwitchingRulesURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBackendSwitchingRulesURL) WithBasePath(bp string) *ReplaceBackendSwitchingRulesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBackendSwitchingRulesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceBackendSwitchingRulesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceBackendSwitchingRulesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceBackendSwitchingRulesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceBackendSwitchingRulesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceBackendSwitchingRulesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceBackendSwitchingRulesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceBackendSwitchingRulesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceBackendSwitchingRulesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/create_bind.go b/operations/bind/create_bind.go deleted file mode 100644 index 61b9c221..00000000 --- a/operations/bind/create_bind.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateBindHandlerFunc turns a function with the right signature into a create bind handler -type CreateBindHandlerFunc func(CreateBindParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateBindHandlerFunc) Handle(params CreateBindParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateBindHandler interface for that can handle valid create bind params -type CreateBindHandler interface { - Handle(CreateBindParams, interface{}) middleware.Responder -} - -// NewCreateBind creates a new http.Handler for the create bind operation -func NewCreateBind(ctx *middleware.Context, handler CreateBindHandler) *CreateBind { - return &CreateBind{Context: ctx, Handler: handler} -} - -/*CreateBind swagger:route POST /services/haproxy/configuration/binds Bind createBind - -Add a new bind - -Adds a new bind in the specified frontend in the configuration file. - -*/ -type CreateBind struct { - Context *middleware.Context - Handler CreateBindHandler -} - -func (o *CreateBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateBindParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/bind/create_bind_frontend.go b/operations/bind/create_bind_frontend.go new file mode 100644 index 00000000..0e2113cf --- /dev/null +++ b/operations/bind/create_bind_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateBindFrontendHandlerFunc turns a function with the right signature into a create bind frontend handler +type CreateBindFrontendHandlerFunc func(CreateBindFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateBindFrontendHandlerFunc) Handle(params CreateBindFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateBindFrontendHandler interface for that can handle valid create bind frontend params +type CreateBindFrontendHandler interface { + Handle(CreateBindFrontendParams, interface{}) middleware.Responder +} + +// NewCreateBindFrontend creates a new http.Handler for the create bind frontend operation +func NewCreateBindFrontend(ctx *middleware.Context, handler CreateBindFrontendHandler) *CreateBindFrontend { + return &CreateBindFrontend{Context: ctx, Handler: handler} +} + +/* + CreateBindFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/binds Bind createBindFrontend + +# Add a new bind + +Adds a new bind in the specified frontend in the configuration file. +*/ +type CreateBindFrontend struct { + Context *middleware.Context + Handler CreateBindFrontendHandler +} + +func (o *CreateBindFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateBindFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/create_bind_frontend_parameters.go b/operations/bind/create_bind_frontend_parameters.go new file mode 100644 index 00000000..c4859589 --- /dev/null +++ b/operations/bind/create_bind_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateBindFrontendParams creates a new CreateBindFrontendParams object +// with the default values initialized. +func NewCreateBindFrontendParams() CreateBindFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateBindFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateBindFrontendParams contains all the bound params for the create bind frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createBindFrontend +type CreateBindFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Bind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateBindFrontendParams() beforehand. +func (o *CreateBindFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Bind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateBindFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateBindFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateBindFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateBindFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateBindFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/create_bind_frontend_responses.go b/operations/bind/create_bind_frontend_responses.go new file mode 100644 index 00000000..c0eb36d8 --- /dev/null +++ b/operations/bind/create_bind_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateBindFrontendCreatedCode is the HTTP code returned for type CreateBindFrontendCreated +const CreateBindFrontendCreatedCode int = 201 + +/* +CreateBindFrontendCreated Bind created + +swagger:response createBindFrontendCreated +*/ +type CreateBindFrontendCreated struct { + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewCreateBindFrontendCreated creates CreateBindFrontendCreated with default headers values +func NewCreateBindFrontendCreated() *CreateBindFrontendCreated { + + return &CreateBindFrontendCreated{} +} + +// WithPayload adds the payload to the create bind frontend created response +func (o *CreateBindFrontendCreated) WithPayload(payload *models.Bind) *CreateBindFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind frontend created response +func (o *CreateBindFrontendCreated) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindFrontendAcceptedCode is the HTTP code returned for type CreateBindFrontendAccepted +const CreateBindFrontendAcceptedCode int = 202 + +/* +CreateBindFrontendAccepted Configuration change accepted and reload requested + +swagger:response createBindFrontendAccepted +*/ +type CreateBindFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewCreateBindFrontendAccepted creates CreateBindFrontendAccepted with default headers values +func NewCreateBindFrontendAccepted() *CreateBindFrontendAccepted { + + return &CreateBindFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create bind frontend accepted response +func (o *CreateBindFrontendAccepted) WithReloadID(reloadID string) *CreateBindFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create bind frontend accepted response +func (o *CreateBindFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create bind frontend accepted response +func (o *CreateBindFrontendAccepted) WithPayload(payload *models.Bind) *CreateBindFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind frontend accepted response +func (o *CreateBindFrontendAccepted) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindFrontendBadRequestCode is the HTTP code returned for type CreateBindFrontendBadRequest +const CreateBindFrontendBadRequestCode int = 400 + +/* +CreateBindFrontendBadRequest Bad request + +swagger:response createBindFrontendBadRequest +*/ +type CreateBindFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindFrontendBadRequest creates CreateBindFrontendBadRequest with default headers values +func NewCreateBindFrontendBadRequest() *CreateBindFrontendBadRequest { + + return &CreateBindFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create bind frontend bad request response +func (o *CreateBindFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateBindFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind frontend bad request response +func (o *CreateBindFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind frontend bad request response +func (o *CreateBindFrontendBadRequest) WithPayload(payload *models.Error) *CreateBindFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind frontend bad request response +func (o *CreateBindFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindFrontendConflictCode is the HTTP code returned for type CreateBindFrontendConflict +const CreateBindFrontendConflictCode int = 409 + +/* +CreateBindFrontendConflict The specified resource already exists + +swagger:response createBindFrontendConflict +*/ +type CreateBindFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindFrontendConflict creates CreateBindFrontendConflict with default headers values +func NewCreateBindFrontendConflict() *CreateBindFrontendConflict { + + return &CreateBindFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create bind frontend conflict response +func (o *CreateBindFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateBindFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind frontend conflict response +func (o *CreateBindFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind frontend conflict response +func (o *CreateBindFrontendConflict) WithPayload(payload *models.Error) *CreateBindFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind frontend conflict response +func (o *CreateBindFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateBindFrontendDefault General Error + +swagger:response createBindFrontendDefault +*/ +type CreateBindFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindFrontendDefault creates CreateBindFrontendDefault with default headers values +func NewCreateBindFrontendDefault(code int) *CreateBindFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateBindFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create bind frontend default response +func (o *CreateBindFrontendDefault) WithStatusCode(code int) *CreateBindFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create bind frontend default response +func (o *CreateBindFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create bind frontend default response +func (o *CreateBindFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateBindFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind frontend default response +func (o *CreateBindFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind frontend default response +func (o *CreateBindFrontendDefault) WithPayload(payload *models.Error) *CreateBindFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind frontend default response +func (o *CreateBindFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/create_bind_frontend_urlbuilder.go b/operations/bind/create_bind_frontend_urlbuilder.go new file mode 100644 index 00000000..3077155a --- /dev/null +++ b/operations/bind/create_bind_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateBindFrontendURL generates an URL for the create bind frontend operation +type CreateBindFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateBindFrontendURL) WithBasePath(bp string) *CreateBindFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateBindFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateBindFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateBindFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateBindFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateBindFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateBindFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateBindFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateBindFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateBindFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/create_bind_log_forward.go b/operations/bind/create_bind_log_forward.go new file mode 100644 index 00000000..2c0acd4e --- /dev/null +++ b/operations/bind/create_bind_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateBindLogForwardHandlerFunc turns a function with the right signature into a create bind log forward handler +type CreateBindLogForwardHandlerFunc func(CreateBindLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateBindLogForwardHandlerFunc) Handle(params CreateBindLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateBindLogForwardHandler interface for that can handle valid create bind log forward params +type CreateBindLogForwardHandler interface { + Handle(CreateBindLogForwardParams, interface{}) middleware.Responder +} + +// NewCreateBindLogForward creates a new http.Handler for the create bind log forward operation +func NewCreateBindLogForward(ctx *middleware.Context, handler CreateBindLogForwardHandler) *CreateBindLogForward { + return &CreateBindLogForward{Context: ctx, Handler: handler} +} + +/* + CreateBindLogForward swagger:route POST /services/haproxy/configuration/log_forwards/{parent_name}/binds Bind createBindLogForward + +# Add a new bind + +Adds a new bind in the specified frontend in the configuration file. +*/ +type CreateBindLogForward struct { + Context *middleware.Context + Handler CreateBindLogForwardHandler +} + +func (o *CreateBindLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateBindLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/create_bind_log_forward_parameters.go b/operations/bind/create_bind_log_forward_parameters.go new file mode 100644 index 00000000..17e1ee63 --- /dev/null +++ b/operations/bind/create_bind_log_forward_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateBindLogForwardParams creates a new CreateBindLogForwardParams object +// with the default values initialized. +func NewCreateBindLogForwardParams() CreateBindLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateBindLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateBindLogForwardParams contains all the bound params for the create bind log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters createBindLogForward +type CreateBindLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Bind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateBindLogForwardParams() beforehand. +func (o *CreateBindLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Bind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateBindLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateBindLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateBindLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateBindLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateBindLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/create_bind_log_forward_responses.go b/operations/bind/create_bind_log_forward_responses.go new file mode 100644 index 00000000..49c97ba4 --- /dev/null +++ b/operations/bind/create_bind_log_forward_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateBindLogForwardCreatedCode is the HTTP code returned for type CreateBindLogForwardCreated +const CreateBindLogForwardCreatedCode int = 201 + +/* +CreateBindLogForwardCreated Bind created + +swagger:response createBindLogForwardCreated +*/ +type CreateBindLogForwardCreated struct { + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewCreateBindLogForwardCreated creates CreateBindLogForwardCreated with default headers values +func NewCreateBindLogForwardCreated() *CreateBindLogForwardCreated { + + return &CreateBindLogForwardCreated{} +} + +// WithPayload adds the payload to the create bind log forward created response +func (o *CreateBindLogForwardCreated) WithPayload(payload *models.Bind) *CreateBindLogForwardCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind log forward created response +func (o *CreateBindLogForwardCreated) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindLogForwardCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindLogForwardAcceptedCode is the HTTP code returned for type CreateBindLogForwardAccepted +const CreateBindLogForwardAcceptedCode int = 202 + +/* +CreateBindLogForwardAccepted Configuration change accepted and reload requested + +swagger:response createBindLogForwardAccepted +*/ +type CreateBindLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewCreateBindLogForwardAccepted creates CreateBindLogForwardAccepted with default headers values +func NewCreateBindLogForwardAccepted() *CreateBindLogForwardAccepted { + + return &CreateBindLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the create bind log forward accepted response +func (o *CreateBindLogForwardAccepted) WithReloadID(reloadID string) *CreateBindLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create bind log forward accepted response +func (o *CreateBindLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create bind log forward accepted response +func (o *CreateBindLogForwardAccepted) WithPayload(payload *models.Bind) *CreateBindLogForwardAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind log forward accepted response +func (o *CreateBindLogForwardAccepted) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindLogForwardBadRequestCode is the HTTP code returned for type CreateBindLogForwardBadRequest +const CreateBindLogForwardBadRequestCode int = 400 + +/* +CreateBindLogForwardBadRequest Bad request + +swagger:response createBindLogForwardBadRequest +*/ +type CreateBindLogForwardBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindLogForwardBadRequest creates CreateBindLogForwardBadRequest with default headers values +func NewCreateBindLogForwardBadRequest() *CreateBindLogForwardBadRequest { + + return &CreateBindLogForwardBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create bind log forward bad request response +func (o *CreateBindLogForwardBadRequest) WithConfigurationVersion(configurationVersion string) *CreateBindLogForwardBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind log forward bad request response +func (o *CreateBindLogForwardBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind log forward bad request response +func (o *CreateBindLogForwardBadRequest) WithPayload(payload *models.Error) *CreateBindLogForwardBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind log forward bad request response +func (o *CreateBindLogForwardBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindLogForwardBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindLogForwardConflictCode is the HTTP code returned for type CreateBindLogForwardConflict +const CreateBindLogForwardConflictCode int = 409 + +/* +CreateBindLogForwardConflict The specified resource already exists + +swagger:response createBindLogForwardConflict +*/ +type CreateBindLogForwardConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindLogForwardConflict creates CreateBindLogForwardConflict with default headers values +func NewCreateBindLogForwardConflict() *CreateBindLogForwardConflict { + + return &CreateBindLogForwardConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create bind log forward conflict response +func (o *CreateBindLogForwardConflict) WithConfigurationVersion(configurationVersion string) *CreateBindLogForwardConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind log forward conflict response +func (o *CreateBindLogForwardConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind log forward conflict response +func (o *CreateBindLogForwardConflict) WithPayload(payload *models.Error) *CreateBindLogForwardConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind log forward conflict response +func (o *CreateBindLogForwardConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindLogForwardConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateBindLogForwardDefault General Error + +swagger:response createBindLogForwardDefault +*/ +type CreateBindLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindLogForwardDefault creates CreateBindLogForwardDefault with default headers values +func NewCreateBindLogForwardDefault(code int) *CreateBindLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &CreateBindLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create bind log forward default response +func (o *CreateBindLogForwardDefault) WithStatusCode(code int) *CreateBindLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create bind log forward default response +func (o *CreateBindLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create bind log forward default response +func (o *CreateBindLogForwardDefault) WithConfigurationVersion(configurationVersion string) *CreateBindLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind log forward default response +func (o *CreateBindLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind log forward default response +func (o *CreateBindLogForwardDefault) WithPayload(payload *models.Error) *CreateBindLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind log forward default response +func (o *CreateBindLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/create_bind_log_forward_urlbuilder.go b/operations/bind/create_bind_log_forward_urlbuilder.go new file mode 100644 index 00000000..23b55c70 --- /dev/null +++ b/operations/bind/create_bind_log_forward_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateBindLogForwardURL generates an URL for the create bind log forward operation +type CreateBindLogForwardURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateBindLogForwardURL) WithBasePath(bp string) *CreateBindLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateBindLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateBindLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateBindLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateBindLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateBindLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateBindLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateBindLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateBindLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateBindLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/create_bind_parameters.go b/operations/bind/create_bind_parameters.go deleted file mode 100644 index fa80f065..00000000 --- a/operations/bind/create_bind_parameters.go +++ /dev/null @@ -1,228 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateBindParams creates a new CreateBindParams object -// with the default values initialized. -func NewCreateBindParams() CreateBindParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateBindParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateBindParams contains all the bound params for the create bind operation -// typically these are obtained from a http.Request -// -// swagger:parameters createBind -type CreateBindParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.Bind - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent frontend name - Required: true - In: query - */ - Frontend string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateBindParams() beforehand. -func (o *CreateBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.Bind - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateBindParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateBindParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindFrontend binds and validates parameter Frontend from query. -func (o *CreateBindParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } - - o.Frontend = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateBindParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/bind/create_bind_peer.go b/operations/bind/create_bind_peer.go new file mode 100644 index 00000000..e4dd4a47 --- /dev/null +++ b/operations/bind/create_bind_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateBindPeerHandlerFunc turns a function with the right signature into a create bind peer handler +type CreateBindPeerHandlerFunc func(CreateBindPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateBindPeerHandlerFunc) Handle(params CreateBindPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateBindPeerHandler interface for that can handle valid create bind peer params +type CreateBindPeerHandler interface { + Handle(CreateBindPeerParams, interface{}) middleware.Responder +} + +// NewCreateBindPeer creates a new http.Handler for the create bind peer operation +func NewCreateBindPeer(ctx *middleware.Context, handler CreateBindPeerHandler) *CreateBindPeer { + return &CreateBindPeer{Context: ctx, Handler: handler} +} + +/* + CreateBindPeer swagger:route POST /services/haproxy/configuration/peers/{parent_name}/binds Bind createBindPeer + +# Add a new bind + +Adds a new bind in the specified frontend in the configuration file. +*/ +type CreateBindPeer struct { + Context *middleware.Context + Handler CreateBindPeerHandler +} + +func (o *CreateBindPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateBindPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/create_bind_peer_parameters.go b/operations/bind/create_bind_peer_parameters.go new file mode 100644 index 00000000..34d1976c --- /dev/null +++ b/operations/bind/create_bind_peer_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateBindPeerParams creates a new CreateBindPeerParams object +// with the default values initialized. +func NewCreateBindPeerParams() CreateBindPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateBindPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateBindPeerParams contains all the bound params for the create bind peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters createBindPeer +type CreateBindPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Bind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateBindPeerParams() beforehand. +func (o *CreateBindPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Bind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateBindPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateBindPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateBindPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateBindPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateBindPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/create_bind_peer_responses.go b/operations/bind/create_bind_peer_responses.go new file mode 100644 index 00000000..05e819df --- /dev/null +++ b/operations/bind/create_bind_peer_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateBindPeerCreatedCode is the HTTP code returned for type CreateBindPeerCreated +const CreateBindPeerCreatedCode int = 201 + +/* +CreateBindPeerCreated Bind created + +swagger:response createBindPeerCreated +*/ +type CreateBindPeerCreated struct { + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewCreateBindPeerCreated creates CreateBindPeerCreated with default headers values +func NewCreateBindPeerCreated() *CreateBindPeerCreated { + + return &CreateBindPeerCreated{} +} + +// WithPayload adds the payload to the create bind peer created response +func (o *CreateBindPeerCreated) WithPayload(payload *models.Bind) *CreateBindPeerCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind peer created response +func (o *CreateBindPeerCreated) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindPeerCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindPeerAcceptedCode is the HTTP code returned for type CreateBindPeerAccepted +const CreateBindPeerAcceptedCode int = 202 + +/* +CreateBindPeerAccepted Configuration change accepted and reload requested + +swagger:response createBindPeerAccepted +*/ +type CreateBindPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewCreateBindPeerAccepted creates CreateBindPeerAccepted with default headers values +func NewCreateBindPeerAccepted() *CreateBindPeerAccepted { + + return &CreateBindPeerAccepted{} +} + +// WithReloadID adds the reloadId to the create bind peer accepted response +func (o *CreateBindPeerAccepted) WithReloadID(reloadID string) *CreateBindPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create bind peer accepted response +func (o *CreateBindPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create bind peer accepted response +func (o *CreateBindPeerAccepted) WithPayload(payload *models.Bind) *CreateBindPeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind peer accepted response +func (o *CreateBindPeerAccepted) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindPeerBadRequestCode is the HTTP code returned for type CreateBindPeerBadRequest +const CreateBindPeerBadRequestCode int = 400 + +/* +CreateBindPeerBadRequest Bad request + +swagger:response createBindPeerBadRequest +*/ +type CreateBindPeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindPeerBadRequest creates CreateBindPeerBadRequest with default headers values +func NewCreateBindPeerBadRequest() *CreateBindPeerBadRequest { + + return &CreateBindPeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create bind peer bad request response +func (o *CreateBindPeerBadRequest) WithConfigurationVersion(configurationVersion string) *CreateBindPeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind peer bad request response +func (o *CreateBindPeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind peer bad request response +func (o *CreateBindPeerBadRequest) WithPayload(payload *models.Error) *CreateBindPeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind peer bad request response +func (o *CreateBindPeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindPeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateBindPeerConflictCode is the HTTP code returned for type CreateBindPeerConflict +const CreateBindPeerConflictCode int = 409 + +/* +CreateBindPeerConflict The specified resource already exists + +swagger:response createBindPeerConflict +*/ +type CreateBindPeerConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindPeerConflict creates CreateBindPeerConflict with default headers values +func NewCreateBindPeerConflict() *CreateBindPeerConflict { + + return &CreateBindPeerConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create bind peer conflict response +func (o *CreateBindPeerConflict) WithConfigurationVersion(configurationVersion string) *CreateBindPeerConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind peer conflict response +func (o *CreateBindPeerConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind peer conflict response +func (o *CreateBindPeerConflict) WithPayload(payload *models.Error) *CreateBindPeerConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind peer conflict response +func (o *CreateBindPeerConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindPeerConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateBindPeerDefault General Error + +swagger:response createBindPeerDefault +*/ +type CreateBindPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateBindPeerDefault creates CreateBindPeerDefault with default headers values +func NewCreateBindPeerDefault(code int) *CreateBindPeerDefault { + if code <= 0 { + code = 500 + } + + return &CreateBindPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create bind peer default response +func (o *CreateBindPeerDefault) WithStatusCode(code int) *CreateBindPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create bind peer default response +func (o *CreateBindPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create bind peer default response +func (o *CreateBindPeerDefault) WithConfigurationVersion(configurationVersion string) *CreateBindPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create bind peer default response +func (o *CreateBindPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create bind peer default response +func (o *CreateBindPeerDefault) WithPayload(payload *models.Error) *CreateBindPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create bind peer default response +func (o *CreateBindPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateBindPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/create_bind_peer_urlbuilder.go b/operations/bind/create_bind_peer_urlbuilder.go new file mode 100644 index 00000000..76d4788a --- /dev/null +++ b/operations/bind/create_bind_peer_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateBindPeerURL generates an URL for the create bind peer operation +type CreateBindPeerURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateBindPeerURL) WithBasePath(bp string) *CreateBindPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateBindPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateBindPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateBindPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateBindPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateBindPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateBindPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateBindPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateBindPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateBindPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/create_bind_responses.go b/operations/bind/create_bind_responses.go deleted file mode 100644 index e2bf7d58..00000000 --- a/operations/bind/create_bind_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateBindCreatedCode is the HTTP code returned for type CreateBindCreated -const CreateBindCreatedCode int = 201 - -/*CreateBindCreated Bind created - -swagger:response createBindCreated -*/ -type CreateBindCreated struct { - - /* - In: Body - */ - Payload *models.Bind `json:"body,omitempty"` -} - -// NewCreateBindCreated creates CreateBindCreated with default headers values -func NewCreateBindCreated() *CreateBindCreated { - - return &CreateBindCreated{} -} - -// WithPayload adds the payload to the create bind created response -func (o *CreateBindCreated) WithPayload(payload *models.Bind) *CreateBindCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create bind created response -func (o *CreateBindCreated) SetPayload(payload *models.Bind) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateBindCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateBindAcceptedCode is the HTTP code returned for type CreateBindAccepted -const CreateBindAcceptedCode int = 202 - -/*CreateBindAccepted Configuration change accepted and reload requested - -swagger:response createBindAccepted -*/ -type CreateBindAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.Bind `json:"body,omitempty"` -} - -// NewCreateBindAccepted creates CreateBindAccepted with default headers values -func NewCreateBindAccepted() *CreateBindAccepted { - - return &CreateBindAccepted{} -} - -// WithReloadID adds the reloadId to the create bind accepted response -func (o *CreateBindAccepted) WithReloadID(reloadID string) *CreateBindAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create bind accepted response -func (o *CreateBindAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create bind accepted response -func (o *CreateBindAccepted) WithPayload(payload *models.Bind) *CreateBindAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create bind accepted response -func (o *CreateBindAccepted) SetPayload(payload *models.Bind) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateBindAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateBindBadRequestCode is the HTTP code returned for type CreateBindBadRequest -const CreateBindBadRequestCode int = 400 - -/*CreateBindBadRequest Bad request - -swagger:response createBindBadRequest -*/ -type CreateBindBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateBindBadRequest creates CreateBindBadRequest with default headers values -func NewCreateBindBadRequest() *CreateBindBadRequest { - - return &CreateBindBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create bind bad request response -func (o *CreateBindBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateBindBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create bind bad request response -func (o *CreateBindBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create bind bad request response -func (o *CreateBindBadRequest) WithPayload(payload *models.Error) *CreateBindBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create bind bad request response -func (o *CreateBindBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateBindBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateBindConflictCode is the HTTP code returned for type CreateBindConflict -const CreateBindConflictCode int = 409 - -/*CreateBindConflict The specified resource already exists - -swagger:response createBindConflict -*/ -type CreateBindConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateBindConflict creates CreateBindConflict with default headers values -func NewCreateBindConflict() *CreateBindConflict { - - return &CreateBindConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create bind conflict response -func (o *CreateBindConflict) WithConfigurationVersion(configurationVersion int64) *CreateBindConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create bind conflict response -func (o *CreateBindConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create bind conflict response -func (o *CreateBindConflict) WithPayload(payload *models.Error) *CreateBindConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create bind conflict response -func (o *CreateBindConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateBindConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateBindDefault General Error - -swagger:response createBindDefault -*/ -type CreateBindDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateBindDefault creates CreateBindDefault with default headers values -func NewCreateBindDefault(code int) *CreateBindDefault { - if code <= 0 { - code = 500 - } - - return &CreateBindDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create bind default response -func (o *CreateBindDefault) WithStatusCode(code int) *CreateBindDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create bind default response -func (o *CreateBindDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create bind default response -func (o *CreateBindDefault) WithConfigurationVersion(configurationVersion int64) *CreateBindDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create bind default response -func (o *CreateBindDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create bind default response -func (o *CreateBindDefault) WithPayload(payload *models.Error) *CreateBindDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create bind default response -func (o *CreateBindDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/bind/create_bind_urlbuilder.go b/operations/bind/create_bind_urlbuilder.go deleted file mode 100644 index cfe7008e..00000000 --- a/operations/bind/create_bind_urlbuilder.go +++ /dev/null @@ -1,144 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateBindURL generates an URL for the create bind operation -type CreateBindURL struct { - ForceReload *bool - Frontend string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateBindURL) WithBasePath(bp string) *CreateBindURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateBindURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateBindURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/binds" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateBindURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateBindURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateBindURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateBindURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateBindURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateBindURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/bind/delete_bind.go b/operations/bind/delete_bind.go deleted file mode 100644 index 89d1f929..00000000 --- a/operations/bind/delete_bind.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteBindHandlerFunc turns a function with the right signature into a delete bind handler -type DeleteBindHandlerFunc func(DeleteBindParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteBindHandlerFunc) Handle(params DeleteBindParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteBindHandler interface for that can handle valid delete bind params -type DeleteBindHandler interface { - Handle(DeleteBindParams, interface{}) middleware.Responder -} - -// NewDeleteBind creates a new http.Handler for the delete bind operation -func NewDeleteBind(ctx *middleware.Context, handler DeleteBindHandler) *DeleteBind { - return &DeleteBind{Context: ctx, Handler: handler} -} - -/*DeleteBind swagger:route DELETE /services/haproxy/configuration/binds/{name} Bind deleteBind - -Delete a bind - -Deletes a bind configuration by it's name in the specified frontend. - -*/ -type DeleteBind struct { - Context *middleware.Context - Handler DeleteBindHandler -} - -func (o *DeleteBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteBindParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/bind/delete_bind_frontend.go b/operations/bind/delete_bind_frontend.go new file mode 100644 index 00000000..aebef8c3 --- /dev/null +++ b/operations/bind/delete_bind_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteBindFrontendHandlerFunc turns a function with the right signature into a delete bind frontend handler +type DeleteBindFrontendHandlerFunc func(DeleteBindFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteBindFrontendHandlerFunc) Handle(params DeleteBindFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteBindFrontendHandler interface for that can handle valid delete bind frontend params +type DeleteBindFrontendHandler interface { + Handle(DeleteBindFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteBindFrontend creates a new http.Handler for the delete bind frontend operation +func NewDeleteBindFrontend(ctx *middleware.Context, handler DeleteBindFrontendHandler) *DeleteBindFrontend { + return &DeleteBindFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteBindFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/binds/{name} Bind deleteBindFrontend + +# Delete a bind + +Deletes a bind configuration by it's name in the specified frontend. +*/ +type DeleteBindFrontend struct { + Context *middleware.Context + Handler DeleteBindFrontendHandler +} + +func (o *DeleteBindFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteBindFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/delete_bind_frontend_parameters.go b/operations/bind/delete_bind_frontend_parameters.go new file mode 100644 index 00000000..d50810b8 --- /dev/null +++ b/operations/bind/delete_bind_frontend_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteBindFrontendParams creates a new DeleteBindFrontendParams object +// with the default values initialized. +func NewDeleteBindFrontendParams() DeleteBindFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteBindFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteBindFrontendParams contains all the bound params for the delete bind frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteBindFrontend +type DeleteBindFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteBindFrontendParams() beforehand. +func (o *DeleteBindFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteBindFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteBindFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteBindFrontendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteBindFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteBindFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteBindFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/delete_bind_frontend_responses.go b/operations/bind/delete_bind_frontend_responses.go new file mode 100644 index 00000000..fb08da1f --- /dev/null +++ b/operations/bind/delete_bind_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteBindFrontendAcceptedCode is the HTTP code returned for type DeleteBindFrontendAccepted +const DeleteBindFrontendAcceptedCode int = 202 + +/* +DeleteBindFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteBindFrontendAccepted +*/ +type DeleteBindFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteBindFrontendAccepted creates DeleteBindFrontendAccepted with default headers values +func NewDeleteBindFrontendAccepted() *DeleteBindFrontendAccepted { + + return &DeleteBindFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete bind frontend accepted response +func (o *DeleteBindFrontendAccepted) WithReloadID(reloadID string) *DeleteBindFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete bind frontend accepted response +func (o *DeleteBindFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteBindFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteBindFrontendNoContentCode is the HTTP code returned for type DeleteBindFrontendNoContent +const DeleteBindFrontendNoContentCode int = 204 + +/* +DeleteBindFrontendNoContent Bind deleted + +swagger:response deleteBindFrontendNoContent +*/ +type DeleteBindFrontendNoContent struct { +} + +// NewDeleteBindFrontendNoContent creates DeleteBindFrontendNoContent with default headers values +func NewDeleteBindFrontendNoContent() *DeleteBindFrontendNoContent { + + return &DeleteBindFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteBindFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteBindFrontendNotFoundCode is the HTTP code returned for type DeleteBindFrontendNotFound +const DeleteBindFrontendNotFoundCode int = 404 + +/* +DeleteBindFrontendNotFound The specified resource was not found + +swagger:response deleteBindFrontendNotFound +*/ +type DeleteBindFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteBindFrontendNotFound creates DeleteBindFrontendNotFound with default headers values +func NewDeleteBindFrontendNotFound() *DeleteBindFrontendNotFound { + + return &DeleteBindFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete bind frontend not found response +func (o *DeleteBindFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteBindFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete bind frontend not found response +func (o *DeleteBindFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete bind frontend not found response +func (o *DeleteBindFrontendNotFound) WithPayload(payload *models.Error) *DeleteBindFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete bind frontend not found response +func (o *DeleteBindFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteBindFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteBindFrontendDefault General Error + +swagger:response deleteBindFrontendDefault +*/ +type DeleteBindFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteBindFrontendDefault creates DeleteBindFrontendDefault with default headers values +func NewDeleteBindFrontendDefault(code int) *DeleteBindFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteBindFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete bind frontend default response +func (o *DeleteBindFrontendDefault) WithStatusCode(code int) *DeleteBindFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete bind frontend default response +func (o *DeleteBindFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete bind frontend default response +func (o *DeleteBindFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteBindFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete bind frontend default response +func (o *DeleteBindFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete bind frontend default response +func (o *DeleteBindFrontendDefault) WithPayload(payload *models.Error) *DeleteBindFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete bind frontend default response +func (o *DeleteBindFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteBindFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/delete_bind_frontend_urlbuilder.go b/operations/bind/delete_bind_frontend_urlbuilder.go new file mode 100644 index 00000000..4a68f891 --- /dev/null +++ b/operations/bind/delete_bind_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteBindFrontendURL generates an URL for the delete bind frontend operation +type DeleteBindFrontendURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteBindFrontendURL) WithBasePath(bp string) *DeleteBindFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteBindFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteBindFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteBindFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteBindFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteBindFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteBindFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteBindFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteBindFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteBindFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteBindFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/delete_bind_log_forward.go b/operations/bind/delete_bind_log_forward.go new file mode 100644 index 00000000..010b0328 --- /dev/null +++ b/operations/bind/delete_bind_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteBindLogForwardHandlerFunc turns a function with the right signature into a delete bind log forward handler +type DeleteBindLogForwardHandlerFunc func(DeleteBindLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteBindLogForwardHandlerFunc) Handle(params DeleteBindLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteBindLogForwardHandler interface for that can handle valid delete bind log forward params +type DeleteBindLogForwardHandler interface { + Handle(DeleteBindLogForwardParams, interface{}) middleware.Responder +} + +// NewDeleteBindLogForward creates a new http.Handler for the delete bind log forward operation +func NewDeleteBindLogForward(ctx *middleware.Context, handler DeleteBindLogForwardHandler) *DeleteBindLogForward { + return &DeleteBindLogForward{Context: ctx, Handler: handler} +} + +/* + DeleteBindLogForward swagger:route DELETE /services/haproxy/configuration/log_forwards/{parent_name}/binds/{name} Bind deleteBindLogForward + +# Delete a bind + +Deletes a bind configuration by it's name in the specified frontend. +*/ +type DeleteBindLogForward struct { + Context *middleware.Context + Handler DeleteBindLogForwardHandler +} + +func (o *DeleteBindLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteBindLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/delete_bind_log_forward_parameters.go b/operations/bind/delete_bind_log_forward_parameters.go new file mode 100644 index 00000000..337ceb87 --- /dev/null +++ b/operations/bind/delete_bind_log_forward_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteBindLogForwardParams creates a new DeleteBindLogForwardParams object +// with the default values initialized. +func NewDeleteBindLogForwardParams() DeleteBindLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteBindLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteBindLogForwardParams contains all the bound params for the delete bind log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteBindLogForward +type DeleteBindLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteBindLogForwardParams() beforehand. +func (o *DeleteBindLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteBindLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteBindLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteBindLogForwardParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteBindLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteBindLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteBindLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/delete_bind_log_forward_responses.go b/operations/bind/delete_bind_log_forward_responses.go new file mode 100644 index 00000000..b9ebb576 --- /dev/null +++ b/operations/bind/delete_bind_log_forward_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteBindLogForwardAcceptedCode is the HTTP code returned for type DeleteBindLogForwardAccepted +const DeleteBindLogForwardAcceptedCode int = 202 + +/* +DeleteBindLogForwardAccepted Configuration change accepted and reload requested + +swagger:response deleteBindLogForwardAccepted +*/ +type DeleteBindLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteBindLogForwardAccepted creates DeleteBindLogForwardAccepted with default headers values +func NewDeleteBindLogForwardAccepted() *DeleteBindLogForwardAccepted { + + return &DeleteBindLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the delete bind log forward accepted response +func (o *DeleteBindLogForwardAccepted) WithReloadID(reloadID string) *DeleteBindLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete bind log forward accepted response +func (o *DeleteBindLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteBindLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteBindLogForwardNoContentCode is the HTTP code returned for type DeleteBindLogForwardNoContent +const DeleteBindLogForwardNoContentCode int = 204 + +/* +DeleteBindLogForwardNoContent Bind deleted + +swagger:response deleteBindLogForwardNoContent +*/ +type DeleteBindLogForwardNoContent struct { +} + +// NewDeleteBindLogForwardNoContent creates DeleteBindLogForwardNoContent with default headers values +func NewDeleteBindLogForwardNoContent() *DeleteBindLogForwardNoContent { + + return &DeleteBindLogForwardNoContent{} +} + +// WriteResponse to the client +func (o *DeleteBindLogForwardNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteBindLogForwardNotFoundCode is the HTTP code returned for type DeleteBindLogForwardNotFound +const DeleteBindLogForwardNotFoundCode int = 404 + +/* +DeleteBindLogForwardNotFound The specified resource was not found + +swagger:response deleteBindLogForwardNotFound +*/ +type DeleteBindLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteBindLogForwardNotFound creates DeleteBindLogForwardNotFound with default headers values +func NewDeleteBindLogForwardNotFound() *DeleteBindLogForwardNotFound { + + return &DeleteBindLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete bind log forward not found response +func (o *DeleteBindLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *DeleteBindLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete bind log forward not found response +func (o *DeleteBindLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete bind log forward not found response +func (o *DeleteBindLogForwardNotFound) WithPayload(payload *models.Error) *DeleteBindLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete bind log forward not found response +func (o *DeleteBindLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteBindLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteBindLogForwardDefault General Error + +swagger:response deleteBindLogForwardDefault +*/ +type DeleteBindLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteBindLogForwardDefault creates DeleteBindLogForwardDefault with default headers values +func NewDeleteBindLogForwardDefault(code int) *DeleteBindLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &DeleteBindLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete bind log forward default response +func (o *DeleteBindLogForwardDefault) WithStatusCode(code int) *DeleteBindLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete bind log forward default response +func (o *DeleteBindLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete bind log forward default response +func (o *DeleteBindLogForwardDefault) WithConfigurationVersion(configurationVersion string) *DeleteBindLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete bind log forward default response +func (o *DeleteBindLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete bind log forward default response +func (o *DeleteBindLogForwardDefault) WithPayload(payload *models.Error) *DeleteBindLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete bind log forward default response +func (o *DeleteBindLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteBindLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/delete_bind_log_forward_urlbuilder.go b/operations/bind/delete_bind_log_forward_urlbuilder.go new file mode 100644 index 00000000..b290caa2 --- /dev/null +++ b/operations/bind/delete_bind_log_forward_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteBindLogForwardURL generates an URL for the delete bind log forward operation +type DeleteBindLogForwardURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteBindLogForwardURL) WithBasePath(bp string) *DeleteBindLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteBindLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteBindLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteBindLogForwardURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteBindLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteBindLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteBindLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteBindLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteBindLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteBindLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteBindLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/delete_bind_parameters.go b/operations/bind/delete_bind_parameters.go deleted file mode 100644 index 05819140..00000000 --- a/operations/bind/delete_bind_parameters.go +++ /dev/null @@ -1,223 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteBindParams creates a new DeleteBindParams object -// with the default values initialized. -func NewDeleteBindParams() DeleteBindParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteBindParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteBindParams contains all the bound params for the delete bind operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteBind -type DeleteBindParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent frontend name - Required: true - In: query - */ - Frontend string - /*Bind name - Required: true - In: path - */ - Name string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteBindParams() beforehand. -func (o *DeleteBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { - res = append(res, err) - } - - rName, rhkName, _ := route.Params.GetOK("name") - if err := o.bindName(rName, rhkName, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteBindParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteBindParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindFrontend binds and validates parameter Frontend from query. -func (o *DeleteBindParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } - - o.Frontend = raw - - return nil -} - -// bindName binds and validates parameter Name from path. -func (o *DeleteBindParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - o.Name = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteBindParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/bind/delete_bind_peer.go b/operations/bind/delete_bind_peer.go new file mode 100644 index 00000000..1aac9921 --- /dev/null +++ b/operations/bind/delete_bind_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteBindPeerHandlerFunc turns a function with the right signature into a delete bind peer handler +type DeleteBindPeerHandlerFunc func(DeleteBindPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteBindPeerHandlerFunc) Handle(params DeleteBindPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteBindPeerHandler interface for that can handle valid delete bind peer params +type DeleteBindPeerHandler interface { + Handle(DeleteBindPeerParams, interface{}) middleware.Responder +} + +// NewDeleteBindPeer creates a new http.Handler for the delete bind peer operation +func NewDeleteBindPeer(ctx *middleware.Context, handler DeleteBindPeerHandler) *DeleteBindPeer { + return &DeleteBindPeer{Context: ctx, Handler: handler} +} + +/* + DeleteBindPeer swagger:route DELETE /services/haproxy/configuration/peers/{parent_name}/binds/{name} Bind deleteBindPeer + +# Delete a bind + +Deletes a bind configuration by it's name in the specified frontend. +*/ +type DeleteBindPeer struct { + Context *middleware.Context + Handler DeleteBindPeerHandler +} + +func (o *DeleteBindPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteBindPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/delete_bind_peer_parameters.go b/operations/bind/delete_bind_peer_parameters.go new file mode 100644 index 00000000..9bbfd248 --- /dev/null +++ b/operations/bind/delete_bind_peer_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteBindPeerParams creates a new DeleteBindPeerParams object +// with the default values initialized. +func NewDeleteBindPeerParams() DeleteBindPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteBindPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteBindPeerParams contains all the bound params for the delete bind peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteBindPeer +type DeleteBindPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteBindPeerParams() beforehand. +func (o *DeleteBindPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteBindPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteBindPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteBindPeerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteBindPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteBindPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteBindPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/delete_bind_peer_responses.go b/operations/bind/delete_bind_peer_responses.go new file mode 100644 index 00000000..f438f5bf --- /dev/null +++ b/operations/bind/delete_bind_peer_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteBindPeerAcceptedCode is the HTTP code returned for type DeleteBindPeerAccepted +const DeleteBindPeerAcceptedCode int = 202 + +/* +DeleteBindPeerAccepted Configuration change accepted and reload requested + +swagger:response deleteBindPeerAccepted +*/ +type DeleteBindPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteBindPeerAccepted creates DeleteBindPeerAccepted with default headers values +func NewDeleteBindPeerAccepted() *DeleteBindPeerAccepted { + + return &DeleteBindPeerAccepted{} +} + +// WithReloadID adds the reloadId to the delete bind peer accepted response +func (o *DeleteBindPeerAccepted) WithReloadID(reloadID string) *DeleteBindPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete bind peer accepted response +func (o *DeleteBindPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteBindPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteBindPeerNoContentCode is the HTTP code returned for type DeleteBindPeerNoContent +const DeleteBindPeerNoContentCode int = 204 + +/* +DeleteBindPeerNoContent Bind deleted + +swagger:response deleteBindPeerNoContent +*/ +type DeleteBindPeerNoContent struct { +} + +// NewDeleteBindPeerNoContent creates DeleteBindPeerNoContent with default headers values +func NewDeleteBindPeerNoContent() *DeleteBindPeerNoContent { + + return &DeleteBindPeerNoContent{} +} + +// WriteResponse to the client +func (o *DeleteBindPeerNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteBindPeerNotFoundCode is the HTTP code returned for type DeleteBindPeerNotFound +const DeleteBindPeerNotFoundCode int = 404 + +/* +DeleteBindPeerNotFound The specified resource was not found + +swagger:response deleteBindPeerNotFound +*/ +type DeleteBindPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteBindPeerNotFound creates DeleteBindPeerNotFound with default headers values +func NewDeleteBindPeerNotFound() *DeleteBindPeerNotFound { + + return &DeleteBindPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete bind peer not found response +func (o *DeleteBindPeerNotFound) WithConfigurationVersion(configurationVersion string) *DeleteBindPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete bind peer not found response +func (o *DeleteBindPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete bind peer not found response +func (o *DeleteBindPeerNotFound) WithPayload(payload *models.Error) *DeleteBindPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete bind peer not found response +func (o *DeleteBindPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteBindPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteBindPeerDefault General Error + +swagger:response deleteBindPeerDefault +*/ +type DeleteBindPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteBindPeerDefault creates DeleteBindPeerDefault with default headers values +func NewDeleteBindPeerDefault(code int) *DeleteBindPeerDefault { + if code <= 0 { + code = 500 + } + + return &DeleteBindPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete bind peer default response +func (o *DeleteBindPeerDefault) WithStatusCode(code int) *DeleteBindPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete bind peer default response +func (o *DeleteBindPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete bind peer default response +func (o *DeleteBindPeerDefault) WithConfigurationVersion(configurationVersion string) *DeleteBindPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete bind peer default response +func (o *DeleteBindPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete bind peer default response +func (o *DeleteBindPeerDefault) WithPayload(payload *models.Error) *DeleteBindPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete bind peer default response +func (o *DeleteBindPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteBindPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/delete_bind_peer_urlbuilder.go b/operations/bind/delete_bind_peer_urlbuilder.go new file mode 100644 index 00000000..4c5a0974 --- /dev/null +++ b/operations/bind/delete_bind_peer_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteBindPeerURL generates an URL for the delete bind peer operation +type DeleteBindPeerURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteBindPeerURL) WithBasePath(bp string) *DeleteBindPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteBindPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteBindPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteBindPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteBindPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteBindPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteBindPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteBindPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteBindPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteBindPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteBindPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/delete_bind_responses.go b/operations/bind/delete_bind_responses.go deleted file mode 100644 index d9d819bc..00000000 --- a/operations/bind/delete_bind_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteBindAcceptedCode is the HTTP code returned for type DeleteBindAccepted -const DeleteBindAcceptedCode int = 202 - -/*DeleteBindAccepted Configuration change accepted and reload requested - -swagger:response deleteBindAccepted -*/ -type DeleteBindAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteBindAccepted creates DeleteBindAccepted with default headers values -func NewDeleteBindAccepted() *DeleteBindAccepted { - - return &DeleteBindAccepted{} -} - -// WithReloadID adds the reloadId to the delete bind accepted response -func (o *DeleteBindAccepted) WithReloadID(reloadID string) *DeleteBindAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete bind accepted response -func (o *DeleteBindAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteBindAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteBindNoContentCode is the HTTP code returned for type DeleteBindNoContent -const DeleteBindNoContentCode int = 204 - -/*DeleteBindNoContent Bind deleted - -swagger:response deleteBindNoContent -*/ -type DeleteBindNoContent struct { -} - -// NewDeleteBindNoContent creates DeleteBindNoContent with default headers values -func NewDeleteBindNoContent() *DeleteBindNoContent { - - return &DeleteBindNoContent{} -} - -// WriteResponse to the client -func (o *DeleteBindNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteBindNotFoundCode is the HTTP code returned for type DeleteBindNotFound -const DeleteBindNotFoundCode int = 404 - -/*DeleteBindNotFound The specified resource was not found - -swagger:response deleteBindNotFound -*/ -type DeleteBindNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteBindNotFound creates DeleteBindNotFound with default headers values -func NewDeleteBindNotFound() *DeleteBindNotFound { - - return &DeleteBindNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete bind not found response -func (o *DeleteBindNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteBindNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete bind not found response -func (o *DeleteBindNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete bind not found response -func (o *DeleteBindNotFound) WithPayload(payload *models.Error) *DeleteBindNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete bind not found response -func (o *DeleteBindNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteBindNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteBindDefault General Error - -swagger:response deleteBindDefault -*/ -type DeleteBindDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteBindDefault creates DeleteBindDefault with default headers values -func NewDeleteBindDefault(code int) *DeleteBindDefault { - if code <= 0 { - code = 500 - } - - return &DeleteBindDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete bind default response -func (o *DeleteBindDefault) WithStatusCode(code int) *DeleteBindDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete bind default response -func (o *DeleteBindDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete bind default response -func (o *DeleteBindDefault) WithConfigurationVersion(configurationVersion int64) *DeleteBindDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete bind default response -func (o *DeleteBindDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete bind default response -func (o *DeleteBindDefault) WithPayload(payload *models.Error) *DeleteBindDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete bind default response -func (o *DeleteBindDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/bind/delete_bind_urlbuilder.go b/operations/bind/delete_bind_urlbuilder.go deleted file mode 100644 index b171c81b..00000000 --- a/operations/bind/delete_bind_urlbuilder.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteBindURL generates an URL for the delete bind operation -type DeleteBindURL struct { - Name string - - ForceReload *bool - Frontend string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteBindURL) WithBasePath(bp string) *DeleteBindURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteBindURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteBindURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/binds/{name}" - - name := o.Name - if name != "" { - _path = strings.Replace(_path, "{name}", name, -1) - } else { - return nil, errors.New("name is required on DeleteBindURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteBindURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteBindURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteBindURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteBindURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteBindURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteBindURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/bind/get_all_bind_frontend.go b/operations/bind/get_all_bind_frontend.go new file mode 100644 index 00000000..b9988724 --- /dev/null +++ b/operations/bind/get_all_bind_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllBindFrontendHandlerFunc turns a function with the right signature into a get all bind frontend handler +type GetAllBindFrontendHandlerFunc func(GetAllBindFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllBindFrontendHandlerFunc) Handle(params GetAllBindFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllBindFrontendHandler interface for that can handle valid get all bind frontend params +type GetAllBindFrontendHandler interface { + Handle(GetAllBindFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllBindFrontend creates a new http.Handler for the get all bind frontend operation +func NewGetAllBindFrontend(ctx *middleware.Context, handler GetAllBindFrontendHandler) *GetAllBindFrontend { + return &GetAllBindFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllBindFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/binds Bind getAllBindFrontend + +# Return an array of binds + +Returns an array of all binds that are configured in specified frontend. +*/ +type GetAllBindFrontend struct { + Context *middleware.Context + Handler GetAllBindFrontendHandler +} + +func (o *GetAllBindFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllBindFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/get_all_bind_frontend_parameters.go b/operations/bind/get_all_bind_frontend_parameters.go new file mode 100644 index 00000000..69fb9cde --- /dev/null +++ b/operations/bind/get_all_bind_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllBindFrontendParams creates a new GetAllBindFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllBindFrontendParams() GetAllBindFrontendParams { + + return GetAllBindFrontendParams{} +} + +// GetAllBindFrontendParams contains all the bound params for the get all bind frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllBindFrontend +type GetAllBindFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllBindFrontendParams() beforehand. +func (o *GetAllBindFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllBindFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllBindFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/bind/get_all_bind_frontend_responses.go b/operations/bind/get_all_bind_frontend_responses.go new file mode 100644 index 00000000..3b3e2098 --- /dev/null +++ b/operations/bind/get_all_bind_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllBindFrontendOKCode is the HTTP code returned for type GetAllBindFrontendOK +const GetAllBindFrontendOKCode int = 200 + +/* +GetAllBindFrontendOK Successful operation + +swagger:response getAllBindFrontendOK +*/ +type GetAllBindFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Binds `json:"body,omitempty"` +} + +// NewGetAllBindFrontendOK creates GetAllBindFrontendOK with default headers values +func NewGetAllBindFrontendOK() *GetAllBindFrontendOK { + + return &GetAllBindFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all bind frontend o k response +func (o *GetAllBindFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllBindFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all bind frontend o k response +func (o *GetAllBindFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all bind frontend o k response +func (o *GetAllBindFrontendOK) WithPayload(payload models.Binds) *GetAllBindFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all bind frontend o k response +func (o *GetAllBindFrontendOK) SetPayload(payload models.Binds) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllBindFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Binds{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllBindFrontendDefault General Error + +swagger:response getAllBindFrontendDefault +*/ +type GetAllBindFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllBindFrontendDefault creates GetAllBindFrontendDefault with default headers values +func NewGetAllBindFrontendDefault(code int) *GetAllBindFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllBindFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all bind frontend default response +func (o *GetAllBindFrontendDefault) WithStatusCode(code int) *GetAllBindFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all bind frontend default response +func (o *GetAllBindFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all bind frontend default response +func (o *GetAllBindFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllBindFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all bind frontend default response +func (o *GetAllBindFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all bind frontend default response +func (o *GetAllBindFrontendDefault) WithPayload(payload *models.Error) *GetAllBindFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all bind frontend default response +func (o *GetAllBindFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllBindFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/get_all_bind_frontend_urlbuilder.go b/operations/bind/get_all_bind_frontend_urlbuilder.go new file mode 100644 index 00000000..0e5b505d --- /dev/null +++ b/operations/bind/get_all_bind_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllBindFrontendURL generates an URL for the get all bind frontend operation +type GetAllBindFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllBindFrontendURL) WithBasePath(bp string) *GetAllBindFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllBindFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllBindFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllBindFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllBindFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllBindFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllBindFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllBindFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllBindFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllBindFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/get_all_bind_log_forward.go b/operations/bind/get_all_bind_log_forward.go new file mode 100644 index 00000000..dd1c38f1 --- /dev/null +++ b/operations/bind/get_all_bind_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllBindLogForwardHandlerFunc turns a function with the right signature into a get all bind log forward handler +type GetAllBindLogForwardHandlerFunc func(GetAllBindLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllBindLogForwardHandlerFunc) Handle(params GetAllBindLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllBindLogForwardHandler interface for that can handle valid get all bind log forward params +type GetAllBindLogForwardHandler interface { + Handle(GetAllBindLogForwardParams, interface{}) middleware.Responder +} + +// NewGetAllBindLogForward creates a new http.Handler for the get all bind log forward operation +func NewGetAllBindLogForward(ctx *middleware.Context, handler GetAllBindLogForwardHandler) *GetAllBindLogForward { + return &GetAllBindLogForward{Context: ctx, Handler: handler} +} + +/* + GetAllBindLogForward swagger:route GET /services/haproxy/configuration/log_forwards/{parent_name}/binds Bind getAllBindLogForward + +# Return an array of binds + +Returns an array of all binds that are configured in specified frontend. +*/ +type GetAllBindLogForward struct { + Context *middleware.Context + Handler GetAllBindLogForwardHandler +} + +func (o *GetAllBindLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllBindLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/get_all_bind_log_forward_parameters.go b/operations/bind/get_all_bind_log_forward_parameters.go new file mode 100644 index 00000000..1559a030 --- /dev/null +++ b/operations/bind/get_all_bind_log_forward_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllBindLogForwardParams creates a new GetAllBindLogForwardParams object +// +// There are no default values defined in the spec. +func NewGetAllBindLogForwardParams() GetAllBindLogForwardParams { + + return GetAllBindLogForwardParams{} +} + +// GetAllBindLogForwardParams contains all the bound params for the get all bind log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllBindLogForward +type GetAllBindLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllBindLogForwardParams() beforehand. +func (o *GetAllBindLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllBindLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllBindLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/bind/get_all_bind_log_forward_responses.go b/operations/bind/get_all_bind_log_forward_responses.go new file mode 100644 index 00000000..a878f46b --- /dev/null +++ b/operations/bind/get_all_bind_log_forward_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllBindLogForwardOKCode is the HTTP code returned for type GetAllBindLogForwardOK +const GetAllBindLogForwardOKCode int = 200 + +/* +GetAllBindLogForwardOK Successful operation + +swagger:response getAllBindLogForwardOK +*/ +type GetAllBindLogForwardOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Binds `json:"body,omitempty"` +} + +// NewGetAllBindLogForwardOK creates GetAllBindLogForwardOK with default headers values +func NewGetAllBindLogForwardOK() *GetAllBindLogForwardOK { + + return &GetAllBindLogForwardOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all bind log forward o k response +func (o *GetAllBindLogForwardOK) WithConfigurationVersion(configurationVersion string) *GetAllBindLogForwardOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all bind log forward o k response +func (o *GetAllBindLogForwardOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all bind log forward o k response +func (o *GetAllBindLogForwardOK) WithPayload(payload models.Binds) *GetAllBindLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all bind log forward o k response +func (o *GetAllBindLogForwardOK) SetPayload(payload models.Binds) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllBindLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Binds{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllBindLogForwardDefault General Error + +swagger:response getAllBindLogForwardDefault +*/ +type GetAllBindLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllBindLogForwardDefault creates GetAllBindLogForwardDefault with default headers values +func NewGetAllBindLogForwardDefault(code int) *GetAllBindLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &GetAllBindLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all bind log forward default response +func (o *GetAllBindLogForwardDefault) WithStatusCode(code int) *GetAllBindLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all bind log forward default response +func (o *GetAllBindLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all bind log forward default response +func (o *GetAllBindLogForwardDefault) WithConfigurationVersion(configurationVersion string) *GetAllBindLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all bind log forward default response +func (o *GetAllBindLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all bind log forward default response +func (o *GetAllBindLogForwardDefault) WithPayload(payload *models.Error) *GetAllBindLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all bind log forward default response +func (o *GetAllBindLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllBindLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/get_all_bind_log_forward_urlbuilder.go b/operations/bind/get_all_bind_log_forward_urlbuilder.go new file mode 100644 index 00000000..41cf3525 --- /dev/null +++ b/operations/bind/get_all_bind_log_forward_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllBindLogForwardURL generates an URL for the get all bind log forward operation +type GetAllBindLogForwardURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllBindLogForwardURL) WithBasePath(bp string) *GetAllBindLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllBindLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllBindLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllBindLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllBindLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllBindLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllBindLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllBindLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllBindLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllBindLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/get_all_bind_peer.go b/operations/bind/get_all_bind_peer.go new file mode 100644 index 00000000..86de2e09 --- /dev/null +++ b/operations/bind/get_all_bind_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllBindPeerHandlerFunc turns a function with the right signature into a get all bind peer handler +type GetAllBindPeerHandlerFunc func(GetAllBindPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllBindPeerHandlerFunc) Handle(params GetAllBindPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllBindPeerHandler interface for that can handle valid get all bind peer params +type GetAllBindPeerHandler interface { + Handle(GetAllBindPeerParams, interface{}) middleware.Responder +} + +// NewGetAllBindPeer creates a new http.Handler for the get all bind peer operation +func NewGetAllBindPeer(ctx *middleware.Context, handler GetAllBindPeerHandler) *GetAllBindPeer { + return &GetAllBindPeer{Context: ctx, Handler: handler} +} + +/* + GetAllBindPeer swagger:route GET /services/haproxy/configuration/peers/{parent_name}/binds Bind getAllBindPeer + +# Return an array of binds + +Returns an array of all binds that are configured in specified frontend. +*/ +type GetAllBindPeer struct { + Context *middleware.Context + Handler GetAllBindPeerHandler +} + +func (o *GetAllBindPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllBindPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/get_all_bind_peer_parameters.go b/operations/bind/get_all_bind_peer_parameters.go new file mode 100644 index 00000000..38fedf4a --- /dev/null +++ b/operations/bind/get_all_bind_peer_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllBindPeerParams creates a new GetAllBindPeerParams object +// +// There are no default values defined in the spec. +func NewGetAllBindPeerParams() GetAllBindPeerParams { + + return GetAllBindPeerParams{} +} + +// GetAllBindPeerParams contains all the bound params for the get all bind peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllBindPeer +type GetAllBindPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllBindPeerParams() beforehand. +func (o *GetAllBindPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllBindPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllBindPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/bind/get_all_bind_peer_responses.go b/operations/bind/get_all_bind_peer_responses.go new file mode 100644 index 00000000..53f39b0e --- /dev/null +++ b/operations/bind/get_all_bind_peer_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllBindPeerOKCode is the HTTP code returned for type GetAllBindPeerOK +const GetAllBindPeerOKCode int = 200 + +/* +GetAllBindPeerOK Successful operation + +swagger:response getAllBindPeerOK +*/ +type GetAllBindPeerOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Binds `json:"body,omitempty"` +} + +// NewGetAllBindPeerOK creates GetAllBindPeerOK with default headers values +func NewGetAllBindPeerOK() *GetAllBindPeerOK { + + return &GetAllBindPeerOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all bind peer o k response +func (o *GetAllBindPeerOK) WithConfigurationVersion(configurationVersion string) *GetAllBindPeerOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all bind peer o k response +func (o *GetAllBindPeerOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all bind peer o k response +func (o *GetAllBindPeerOK) WithPayload(payload models.Binds) *GetAllBindPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all bind peer o k response +func (o *GetAllBindPeerOK) SetPayload(payload models.Binds) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllBindPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Binds{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllBindPeerDefault General Error + +swagger:response getAllBindPeerDefault +*/ +type GetAllBindPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllBindPeerDefault creates GetAllBindPeerDefault with default headers values +func NewGetAllBindPeerDefault(code int) *GetAllBindPeerDefault { + if code <= 0 { + code = 500 + } + + return &GetAllBindPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all bind peer default response +func (o *GetAllBindPeerDefault) WithStatusCode(code int) *GetAllBindPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all bind peer default response +func (o *GetAllBindPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all bind peer default response +func (o *GetAllBindPeerDefault) WithConfigurationVersion(configurationVersion string) *GetAllBindPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all bind peer default response +func (o *GetAllBindPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all bind peer default response +func (o *GetAllBindPeerDefault) WithPayload(payload *models.Error) *GetAllBindPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all bind peer default response +func (o *GetAllBindPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllBindPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/get_all_bind_peer_urlbuilder.go b/operations/bind/get_all_bind_peer_urlbuilder.go new file mode 100644 index 00000000..61b0ada7 --- /dev/null +++ b/operations/bind/get_all_bind_peer_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllBindPeerURL generates an URL for the get all bind peer operation +type GetAllBindPeerURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllBindPeerURL) WithBasePath(bp string) *GetAllBindPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllBindPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllBindPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllBindPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllBindPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllBindPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllBindPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllBindPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllBindPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllBindPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/get_bind.go b/operations/bind/get_bind.go deleted file mode 100644 index 15f505ef..00000000 --- a/operations/bind/get_bind.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetBindHandlerFunc turns a function with the right signature into a get bind handler -type GetBindHandlerFunc func(GetBindParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetBindHandlerFunc) Handle(params GetBindParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetBindHandler interface for that can handle valid get bind params -type GetBindHandler interface { - Handle(GetBindParams, interface{}) middleware.Responder -} - -// NewGetBind creates a new http.Handler for the get bind operation -func NewGetBind(ctx *middleware.Context, handler GetBindHandler) *GetBind { - return &GetBind{Context: ctx, Handler: handler} -} - -/*GetBind swagger:route GET /services/haproxy/configuration/binds/{name} Bind getBind - -Return one bind - -Returns one bind configuration by it's name in the specified frontend. - -*/ -type GetBind struct { - Context *middleware.Context - Handler GetBindHandler -} - -func (o *GetBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetBindParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetBindOKBody get bind o k body -// swagger:model GetBindOKBody -type GetBindOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Bind `json:"data,omitempty"` -} - -// Validate validates this get bind o k body -func (o *GetBindOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetBindOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getBindOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetBindOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetBindOKBody) UnmarshalBinary(b []byte) error { - var res GetBindOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/bind/get_bind_frontend.go b/operations/bind/get_bind_frontend.go new file mode 100644 index 00000000..1355753c --- /dev/null +++ b/operations/bind/get_bind_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetBindFrontendHandlerFunc turns a function with the right signature into a get bind frontend handler +type GetBindFrontendHandlerFunc func(GetBindFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetBindFrontendHandlerFunc) Handle(params GetBindFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetBindFrontendHandler interface for that can handle valid get bind frontend params +type GetBindFrontendHandler interface { + Handle(GetBindFrontendParams, interface{}) middleware.Responder +} + +// NewGetBindFrontend creates a new http.Handler for the get bind frontend operation +func NewGetBindFrontend(ctx *middleware.Context, handler GetBindFrontendHandler) *GetBindFrontend { + return &GetBindFrontend{Context: ctx, Handler: handler} +} + +/* + GetBindFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/binds/{name} Bind getBindFrontend + +# Return one bind + +Returns one bind configuration by it's name in the specified frontend. +*/ +type GetBindFrontend struct { + Context *middleware.Context + Handler GetBindFrontendHandler +} + +func (o *GetBindFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetBindFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/get_bind_frontend_parameters.go b/operations/bind/get_bind_frontend_parameters.go new file mode 100644 index 00000000..d321c349 --- /dev/null +++ b/operations/bind/get_bind_frontend_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetBindFrontendParams creates a new GetBindFrontendParams object +// +// There are no default values defined in the spec. +func NewGetBindFrontendParams() GetBindFrontendParams { + + return GetBindFrontendParams{} +} + +// GetBindFrontendParams contains all the bound params for the get bind frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getBindFrontend +type GetBindFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetBindFrontendParams() beforehand. +func (o *GetBindFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetBindFrontendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetBindFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetBindFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/bind/get_bind_frontend_responses.go b/operations/bind/get_bind_frontend_responses.go new file mode 100644 index 00000000..43bd642e --- /dev/null +++ b/operations/bind/get_bind_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetBindFrontendOKCode is the HTTP code returned for type GetBindFrontendOK +const GetBindFrontendOKCode int = 200 + +/* +GetBindFrontendOK Successful operation + +swagger:response getBindFrontendOK +*/ +type GetBindFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewGetBindFrontendOK creates GetBindFrontendOK with default headers values +func NewGetBindFrontendOK() *GetBindFrontendOK { + + return &GetBindFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get bind frontend o k response +func (o *GetBindFrontendOK) WithConfigurationVersion(configurationVersion string) *GetBindFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind frontend o k response +func (o *GetBindFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind frontend o k response +func (o *GetBindFrontendOK) WithPayload(payload *models.Bind) *GetBindFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind frontend o k response +func (o *GetBindFrontendOK) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetBindFrontendNotFoundCode is the HTTP code returned for type GetBindFrontendNotFound +const GetBindFrontendNotFoundCode int = 404 + +/* +GetBindFrontendNotFound The specified resource already exists + +swagger:response getBindFrontendNotFound +*/ +type GetBindFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetBindFrontendNotFound creates GetBindFrontendNotFound with default headers values +func NewGetBindFrontendNotFound() *GetBindFrontendNotFound { + + return &GetBindFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get bind frontend not found response +func (o *GetBindFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetBindFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind frontend not found response +func (o *GetBindFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind frontend not found response +func (o *GetBindFrontendNotFound) WithPayload(payload *models.Error) *GetBindFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind frontend not found response +func (o *GetBindFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetBindFrontendDefault General Error + +swagger:response getBindFrontendDefault +*/ +type GetBindFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetBindFrontendDefault creates GetBindFrontendDefault with default headers values +func NewGetBindFrontendDefault(code int) *GetBindFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetBindFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get bind frontend default response +func (o *GetBindFrontendDefault) WithStatusCode(code int) *GetBindFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get bind frontend default response +func (o *GetBindFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get bind frontend default response +func (o *GetBindFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetBindFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind frontend default response +func (o *GetBindFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind frontend default response +func (o *GetBindFrontendDefault) WithPayload(payload *models.Error) *GetBindFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind frontend default response +func (o *GetBindFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/get_bind_frontend_urlbuilder.go b/operations/bind/get_bind_frontend_urlbuilder.go new file mode 100644 index 00000000..88e32580 --- /dev/null +++ b/operations/bind/get_bind_frontend_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetBindFrontendURL generates an URL for the get bind frontend operation +type GetBindFrontendURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetBindFrontendURL) WithBasePath(bp string) *GetBindFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetBindFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetBindFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetBindFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetBindFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetBindFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetBindFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetBindFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetBindFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetBindFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetBindFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/get_bind_log_forward.go b/operations/bind/get_bind_log_forward.go new file mode 100644 index 00000000..e78f5cd8 --- /dev/null +++ b/operations/bind/get_bind_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetBindLogForwardHandlerFunc turns a function with the right signature into a get bind log forward handler +type GetBindLogForwardHandlerFunc func(GetBindLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetBindLogForwardHandlerFunc) Handle(params GetBindLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetBindLogForwardHandler interface for that can handle valid get bind log forward params +type GetBindLogForwardHandler interface { + Handle(GetBindLogForwardParams, interface{}) middleware.Responder +} + +// NewGetBindLogForward creates a new http.Handler for the get bind log forward operation +func NewGetBindLogForward(ctx *middleware.Context, handler GetBindLogForwardHandler) *GetBindLogForward { + return &GetBindLogForward{Context: ctx, Handler: handler} +} + +/* + GetBindLogForward swagger:route GET /services/haproxy/configuration/log_forwards/{parent_name}/binds/{name} Bind getBindLogForward + +# Return one bind + +Returns one bind configuration by it's name in the specified frontend. +*/ +type GetBindLogForward struct { + Context *middleware.Context + Handler GetBindLogForwardHandler +} + +func (o *GetBindLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetBindLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/get_bind_log_forward_parameters.go b/operations/bind/get_bind_log_forward_parameters.go new file mode 100644 index 00000000..d3f4e63f --- /dev/null +++ b/operations/bind/get_bind_log_forward_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetBindLogForwardParams creates a new GetBindLogForwardParams object +// +// There are no default values defined in the spec. +func NewGetBindLogForwardParams() GetBindLogForwardParams { + + return GetBindLogForwardParams{} +} + +// GetBindLogForwardParams contains all the bound params for the get bind log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters getBindLogForward +type GetBindLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetBindLogForwardParams() beforehand. +func (o *GetBindLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetBindLogForwardParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetBindLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetBindLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/bind/get_bind_log_forward_responses.go b/operations/bind/get_bind_log_forward_responses.go new file mode 100644 index 00000000..a46d7085 --- /dev/null +++ b/operations/bind/get_bind_log_forward_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetBindLogForwardOKCode is the HTTP code returned for type GetBindLogForwardOK +const GetBindLogForwardOKCode int = 200 + +/* +GetBindLogForwardOK Successful operation + +swagger:response getBindLogForwardOK +*/ +type GetBindLogForwardOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewGetBindLogForwardOK creates GetBindLogForwardOK with default headers values +func NewGetBindLogForwardOK() *GetBindLogForwardOK { + + return &GetBindLogForwardOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get bind log forward o k response +func (o *GetBindLogForwardOK) WithConfigurationVersion(configurationVersion string) *GetBindLogForwardOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind log forward o k response +func (o *GetBindLogForwardOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind log forward o k response +func (o *GetBindLogForwardOK) WithPayload(payload *models.Bind) *GetBindLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind log forward o k response +func (o *GetBindLogForwardOK) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetBindLogForwardNotFoundCode is the HTTP code returned for type GetBindLogForwardNotFound +const GetBindLogForwardNotFoundCode int = 404 + +/* +GetBindLogForwardNotFound The specified resource already exists + +swagger:response getBindLogForwardNotFound +*/ +type GetBindLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetBindLogForwardNotFound creates GetBindLogForwardNotFound with default headers values +func NewGetBindLogForwardNotFound() *GetBindLogForwardNotFound { + + return &GetBindLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get bind log forward not found response +func (o *GetBindLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *GetBindLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind log forward not found response +func (o *GetBindLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind log forward not found response +func (o *GetBindLogForwardNotFound) WithPayload(payload *models.Error) *GetBindLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind log forward not found response +func (o *GetBindLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetBindLogForwardDefault General Error + +swagger:response getBindLogForwardDefault +*/ +type GetBindLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetBindLogForwardDefault creates GetBindLogForwardDefault with default headers values +func NewGetBindLogForwardDefault(code int) *GetBindLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &GetBindLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get bind log forward default response +func (o *GetBindLogForwardDefault) WithStatusCode(code int) *GetBindLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get bind log forward default response +func (o *GetBindLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get bind log forward default response +func (o *GetBindLogForwardDefault) WithConfigurationVersion(configurationVersion string) *GetBindLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind log forward default response +func (o *GetBindLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind log forward default response +func (o *GetBindLogForwardDefault) WithPayload(payload *models.Error) *GetBindLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind log forward default response +func (o *GetBindLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/get_bind_log_forward_urlbuilder.go b/operations/bind/get_bind_log_forward_urlbuilder.go new file mode 100644 index 00000000..b2434e90 --- /dev/null +++ b/operations/bind/get_bind_log_forward_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetBindLogForwardURL generates an URL for the get bind log forward operation +type GetBindLogForwardURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetBindLogForwardURL) WithBasePath(bp string) *GetBindLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetBindLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetBindLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetBindLogForwardURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetBindLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetBindLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetBindLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetBindLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetBindLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetBindLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetBindLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/get_bind_parameters.go b/operations/bind/get_bind_parameters.go deleted file mode 100644 index c293dff0..00000000 --- a/operations/bind/get_bind_parameters.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetBindParams creates a new GetBindParams object -// no default values defined in spec. -func NewGetBindParams() GetBindParams { - - return GetBindParams{} -} - -// GetBindParams contains all the bound params for the get bind operation -// typically these are obtained from a http.Request -// -// swagger:parameters getBind -type GetBindParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent frontend name - Required: true - In: query - */ - Frontend string - /*Bind name - Required: true - In: path - */ - Name string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetBindParams() beforehand. -func (o *GetBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { - res = append(res, err) - } - - rName, rhkName, _ := route.Params.GetOK("name") - if err := o.bindName(rName, rhkName, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindFrontend binds and validates parameter Frontend from query. -func (o *GetBindParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } - - o.Frontend = raw - - return nil -} - -// bindName binds and validates parameter Name from path. -func (o *GetBindParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - o.Name = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/bind/get_bind_peer.go b/operations/bind/get_bind_peer.go new file mode 100644 index 00000000..87011428 --- /dev/null +++ b/operations/bind/get_bind_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetBindPeerHandlerFunc turns a function with the right signature into a get bind peer handler +type GetBindPeerHandlerFunc func(GetBindPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetBindPeerHandlerFunc) Handle(params GetBindPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetBindPeerHandler interface for that can handle valid get bind peer params +type GetBindPeerHandler interface { + Handle(GetBindPeerParams, interface{}) middleware.Responder +} + +// NewGetBindPeer creates a new http.Handler for the get bind peer operation +func NewGetBindPeer(ctx *middleware.Context, handler GetBindPeerHandler) *GetBindPeer { + return &GetBindPeer{Context: ctx, Handler: handler} +} + +/* + GetBindPeer swagger:route GET /services/haproxy/configuration/peers/{parent_name}/binds/{name} Bind getBindPeer + +# Return one bind + +Returns one bind configuration by it's name in the specified frontend. +*/ +type GetBindPeer struct { + Context *middleware.Context + Handler GetBindPeerHandler +} + +func (o *GetBindPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetBindPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/get_bind_peer_parameters.go b/operations/bind/get_bind_peer_parameters.go new file mode 100644 index 00000000..11b4d84d --- /dev/null +++ b/operations/bind/get_bind_peer_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetBindPeerParams creates a new GetBindPeerParams object +// +// There are no default values defined in the spec. +func NewGetBindPeerParams() GetBindPeerParams { + + return GetBindPeerParams{} +} + +// GetBindPeerParams contains all the bound params for the get bind peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters getBindPeer +type GetBindPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetBindPeerParams() beforehand. +func (o *GetBindPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetBindPeerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetBindPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetBindPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/bind/get_bind_peer_responses.go b/operations/bind/get_bind_peer_responses.go new file mode 100644 index 00000000..f59d3ff5 --- /dev/null +++ b/operations/bind/get_bind_peer_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetBindPeerOKCode is the HTTP code returned for type GetBindPeerOK +const GetBindPeerOKCode int = 200 + +/* +GetBindPeerOK Successful operation + +swagger:response getBindPeerOK +*/ +type GetBindPeerOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewGetBindPeerOK creates GetBindPeerOK with default headers values +func NewGetBindPeerOK() *GetBindPeerOK { + + return &GetBindPeerOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get bind peer o k response +func (o *GetBindPeerOK) WithConfigurationVersion(configurationVersion string) *GetBindPeerOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind peer o k response +func (o *GetBindPeerOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind peer o k response +func (o *GetBindPeerOK) WithPayload(payload *models.Bind) *GetBindPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind peer o k response +func (o *GetBindPeerOK) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetBindPeerNotFoundCode is the HTTP code returned for type GetBindPeerNotFound +const GetBindPeerNotFoundCode int = 404 + +/* +GetBindPeerNotFound The specified resource already exists + +swagger:response getBindPeerNotFound +*/ +type GetBindPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetBindPeerNotFound creates GetBindPeerNotFound with default headers values +func NewGetBindPeerNotFound() *GetBindPeerNotFound { + + return &GetBindPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get bind peer not found response +func (o *GetBindPeerNotFound) WithConfigurationVersion(configurationVersion string) *GetBindPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind peer not found response +func (o *GetBindPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind peer not found response +func (o *GetBindPeerNotFound) WithPayload(payload *models.Error) *GetBindPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind peer not found response +func (o *GetBindPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetBindPeerDefault General Error + +swagger:response getBindPeerDefault +*/ +type GetBindPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetBindPeerDefault creates GetBindPeerDefault with default headers values +func NewGetBindPeerDefault(code int) *GetBindPeerDefault { + if code <= 0 { + code = 500 + } + + return &GetBindPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get bind peer default response +func (o *GetBindPeerDefault) WithStatusCode(code int) *GetBindPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get bind peer default response +func (o *GetBindPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get bind peer default response +func (o *GetBindPeerDefault) WithConfigurationVersion(configurationVersion string) *GetBindPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get bind peer default response +func (o *GetBindPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get bind peer default response +func (o *GetBindPeerDefault) WithPayload(payload *models.Error) *GetBindPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get bind peer default response +func (o *GetBindPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetBindPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/get_bind_peer_urlbuilder.go b/operations/bind/get_bind_peer_urlbuilder.go new file mode 100644 index 00000000..f57bb532 --- /dev/null +++ b/operations/bind/get_bind_peer_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetBindPeerURL generates an URL for the get bind peer operation +type GetBindPeerURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetBindPeerURL) WithBasePath(bp string) *GetBindPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetBindPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetBindPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetBindPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetBindPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetBindPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetBindPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetBindPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetBindPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetBindPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetBindPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/get_bind_responses.go b/operations/bind/get_bind_responses.go deleted file mode 100644 index c8986c05..00000000 --- a/operations/bind/get_bind_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetBindOKCode is the HTTP code returned for type GetBindOK -const GetBindOKCode int = 200 - -/*GetBindOK Successful operation - -swagger:response getBindOK -*/ -type GetBindOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetBindOKBody `json:"body,omitempty"` -} - -// NewGetBindOK creates GetBindOK with default headers values -func NewGetBindOK() *GetBindOK { - - return &GetBindOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get bind o k response -func (o *GetBindOK) WithConfigurationVersion(configurationVersion int64) *GetBindOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get bind o k response -func (o *GetBindOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get bind o k response -func (o *GetBindOK) WithPayload(payload *GetBindOKBody) *GetBindOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get bind o k response -func (o *GetBindOK) SetPayload(payload *GetBindOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetBindOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetBindNotFoundCode is the HTTP code returned for type GetBindNotFound -const GetBindNotFoundCode int = 404 - -/*GetBindNotFound The specified resource already exists - -swagger:response getBindNotFound -*/ -type GetBindNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetBindNotFound creates GetBindNotFound with default headers values -func NewGetBindNotFound() *GetBindNotFound { - - return &GetBindNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get bind not found response -func (o *GetBindNotFound) WithConfigurationVersion(configurationVersion int64) *GetBindNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get bind not found response -func (o *GetBindNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get bind not found response -func (o *GetBindNotFound) WithPayload(payload *models.Error) *GetBindNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get bind not found response -func (o *GetBindNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetBindNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetBindDefault General Error - -swagger:response getBindDefault -*/ -type GetBindDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetBindDefault creates GetBindDefault with default headers values -func NewGetBindDefault(code int) *GetBindDefault { - if code <= 0 { - code = 500 - } - - return &GetBindDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get bind default response -func (o *GetBindDefault) WithStatusCode(code int) *GetBindDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get bind default response -func (o *GetBindDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get bind default response -func (o *GetBindDefault) WithConfigurationVersion(configurationVersion int64) *GetBindDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get bind default response -func (o *GetBindDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get bind default response -func (o *GetBindDefault) WithPayload(payload *models.Error) *GetBindDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get bind default response -func (o *GetBindDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/bind/get_bind_urlbuilder.go b/operations/bind/get_bind_urlbuilder.go deleted file mode 100644 index 61d9bb2c..00000000 --- a/operations/bind/get_bind_urlbuilder.go +++ /dev/null @@ -1,134 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" -) - -// GetBindURL generates an URL for the get bind operation -type GetBindURL struct { - Name string - - Frontend string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetBindURL) WithBasePath(bp string) *GetBindURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetBindURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetBindURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/binds/{name}" - - name := o.Name - if name != "" { - _path = strings.Replace(_path, "{name}", name, -1) - } else { - return nil, errors.New("name is required on GetBindURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetBindURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetBindURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetBindURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetBindURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetBindURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetBindURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/bind/get_binds.go b/operations/bind/get_binds.go deleted file mode 100644 index d1778fa9..00000000 --- a/operations/bind/get_binds.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetBindsHandlerFunc turns a function with the right signature into a get binds handler -type GetBindsHandlerFunc func(GetBindsParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetBindsHandlerFunc) Handle(params GetBindsParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetBindsHandler interface for that can handle valid get binds params -type GetBindsHandler interface { - Handle(GetBindsParams, interface{}) middleware.Responder -} - -// NewGetBinds creates a new http.Handler for the get binds operation -func NewGetBinds(ctx *middleware.Context, handler GetBindsHandler) *GetBinds { - return &GetBinds{Context: ctx, Handler: handler} -} - -/*GetBinds swagger:route GET /services/haproxy/configuration/binds Bind getBinds - -Return an array of binds - -Returns an array of all binds that are configured in specified frontend. - -*/ -type GetBinds struct { - Context *middleware.Context - Handler GetBindsHandler -} - -func (o *GetBinds) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetBindsParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetBindsOKBody get binds o k body -// swagger:model GetBindsOKBody -type GetBindsOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.Binds `json:"data"` -} - -// Validate validates this get binds o k body -func (o *GetBindsOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetBindsOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getBindsOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getBindsOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetBindsOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetBindsOKBody) UnmarshalBinary(b []byte) error { - var res GetBindsOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/bind/get_binds_parameters.go b/operations/bind/get_binds_parameters.go deleted file mode 100644 index e822e0ac..00000000 --- a/operations/bind/get_binds_parameters.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetBindsParams creates a new GetBindsParams object -// no default values defined in spec. -func NewGetBindsParams() GetBindsParams { - - return GetBindsParams{} -} - -// GetBindsParams contains all the bound params for the get binds operation -// typically these are obtained from a http.Request -// -// swagger:parameters getBinds -type GetBindsParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent frontend name - Required: true - In: query - */ - Frontend string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetBindsParams() beforehand. -func (o *GetBindsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindFrontend binds and validates parameter Frontend from query. -func (o *GetBindsParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } - - o.Frontend = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetBindsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/bind/get_binds_responses.go b/operations/bind/get_binds_responses.go deleted file mode 100644 index a8a27a1d..00000000 --- a/operations/bind/get_binds_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetBindsOKCode is the HTTP code returned for type GetBindsOK -const GetBindsOKCode int = 200 - -/*GetBindsOK Successful operation - -swagger:response getBindsOK -*/ -type GetBindsOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetBindsOKBody `json:"body,omitempty"` -} - -// NewGetBindsOK creates GetBindsOK with default headers values -func NewGetBindsOK() *GetBindsOK { - - return &GetBindsOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get binds o k response -func (o *GetBindsOK) WithConfigurationVersion(configurationVersion int64) *GetBindsOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get binds o k response -func (o *GetBindsOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get binds o k response -func (o *GetBindsOK) WithPayload(payload *GetBindsOKBody) *GetBindsOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get binds o k response -func (o *GetBindsOK) SetPayload(payload *GetBindsOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetBindsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetBindsDefault General Error - -swagger:response getBindsDefault -*/ -type GetBindsDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetBindsDefault creates GetBindsDefault with default headers values -func NewGetBindsDefault(code int) *GetBindsDefault { - if code <= 0 { - code = 500 - } - - return &GetBindsDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get binds default response -func (o *GetBindsDefault) WithStatusCode(code int) *GetBindsDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get binds default response -func (o *GetBindsDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get binds default response -func (o *GetBindsDefault) WithConfigurationVersion(configurationVersion int64) *GetBindsDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get binds default response -func (o *GetBindsDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get binds default response -func (o *GetBindsDefault) WithPayload(payload *models.Error) *GetBindsDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get binds default response -func (o *GetBindsDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetBindsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/bind/get_binds_urlbuilder.go b/operations/bind/get_binds_urlbuilder.go deleted file mode 100644 index 9fac1e55..00000000 --- a/operations/bind/get_binds_urlbuilder.go +++ /dev/null @@ -1,124 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetBindsURL generates an URL for the get binds operation -type GetBindsURL struct { - Frontend string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetBindsURL) WithBasePath(bp string) *GetBindsURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetBindsURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetBindsURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/binds" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetBindsURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetBindsURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetBindsURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetBindsURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetBindsURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetBindsURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/bind/replace_bind.go b/operations/bind/replace_bind.go deleted file mode 100644 index e3ff702d..00000000 --- a/operations/bind/replace_bind.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceBindHandlerFunc turns a function with the right signature into a replace bind handler -type ReplaceBindHandlerFunc func(ReplaceBindParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceBindHandlerFunc) Handle(params ReplaceBindParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceBindHandler interface for that can handle valid replace bind params -type ReplaceBindHandler interface { - Handle(ReplaceBindParams, interface{}) middleware.Responder -} - -// NewReplaceBind creates a new http.Handler for the replace bind operation -func NewReplaceBind(ctx *middleware.Context, handler ReplaceBindHandler) *ReplaceBind { - return &ReplaceBind{Context: ctx, Handler: handler} -} - -/*ReplaceBind swagger:route PUT /services/haproxy/configuration/binds/{name} Bind replaceBind - -Replace a bind - -Replaces a bind configuration by it's name in the specified frontend. - -*/ -type ReplaceBind struct { - Context *middleware.Context - Handler ReplaceBindHandler -} - -func (o *ReplaceBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceBindParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/bind/replace_bind_frontend.go b/operations/bind/replace_bind_frontend.go new file mode 100644 index 00000000..830f2452 --- /dev/null +++ b/operations/bind/replace_bind_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceBindFrontendHandlerFunc turns a function with the right signature into a replace bind frontend handler +type ReplaceBindFrontendHandlerFunc func(ReplaceBindFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceBindFrontendHandlerFunc) Handle(params ReplaceBindFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceBindFrontendHandler interface for that can handle valid replace bind frontend params +type ReplaceBindFrontendHandler interface { + Handle(ReplaceBindFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceBindFrontend creates a new http.Handler for the replace bind frontend operation +func NewReplaceBindFrontend(ctx *middleware.Context, handler ReplaceBindFrontendHandler) *ReplaceBindFrontend { + return &ReplaceBindFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceBindFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/binds/{name} Bind replaceBindFrontend + +# Replace a bind + +Replaces a bind configuration by it's name in the specified frontend. +*/ +type ReplaceBindFrontend struct { + Context *middleware.Context + Handler ReplaceBindFrontendHandler +} + +func (o *ReplaceBindFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceBindFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/replace_bind_frontend_parameters.go b/operations/bind/replace_bind_frontend_parameters.go new file mode 100644 index 00000000..eae20d28 --- /dev/null +++ b/operations/bind/replace_bind_frontend_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceBindFrontendParams creates a new ReplaceBindFrontendParams object +// with the default values initialized. +func NewReplaceBindFrontendParams() ReplaceBindFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceBindFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceBindFrontendParams contains all the bound params for the replace bind frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceBindFrontend +type ReplaceBindFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Bind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceBindFrontendParams() beforehand. +func (o *ReplaceBindFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Bind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceBindFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceBindFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceBindFrontendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceBindFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceBindFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceBindFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/replace_bind_frontend_responses.go b/operations/bind/replace_bind_frontend_responses.go new file mode 100644 index 00000000..79b1489d --- /dev/null +++ b/operations/bind/replace_bind_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceBindFrontendOKCode is the HTTP code returned for type ReplaceBindFrontendOK +const ReplaceBindFrontendOKCode int = 200 + +/* +ReplaceBindFrontendOK Bind replaced + +swagger:response replaceBindFrontendOK +*/ +type ReplaceBindFrontendOK struct { + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewReplaceBindFrontendOK creates ReplaceBindFrontendOK with default headers values +func NewReplaceBindFrontendOK() *ReplaceBindFrontendOK { + + return &ReplaceBindFrontendOK{} +} + +// WithPayload adds the payload to the replace bind frontend o k response +func (o *ReplaceBindFrontendOK) WithPayload(payload *models.Bind) *ReplaceBindFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind frontend o k response +func (o *ReplaceBindFrontendOK) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindFrontendAcceptedCode is the HTTP code returned for type ReplaceBindFrontendAccepted +const ReplaceBindFrontendAcceptedCode int = 202 + +/* +ReplaceBindFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceBindFrontendAccepted +*/ +type ReplaceBindFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewReplaceBindFrontendAccepted creates ReplaceBindFrontendAccepted with default headers values +func NewReplaceBindFrontendAccepted() *ReplaceBindFrontendAccepted { + + return &ReplaceBindFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace bind frontend accepted response +func (o *ReplaceBindFrontendAccepted) WithReloadID(reloadID string) *ReplaceBindFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace bind frontend accepted response +func (o *ReplaceBindFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace bind frontend accepted response +func (o *ReplaceBindFrontendAccepted) WithPayload(payload *models.Bind) *ReplaceBindFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind frontend accepted response +func (o *ReplaceBindFrontendAccepted) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindFrontendBadRequestCode is the HTTP code returned for type ReplaceBindFrontendBadRequest +const ReplaceBindFrontendBadRequestCode int = 400 + +/* +ReplaceBindFrontendBadRequest Bad request + +swagger:response replaceBindFrontendBadRequest +*/ +type ReplaceBindFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindFrontendBadRequest creates ReplaceBindFrontendBadRequest with default headers values +func NewReplaceBindFrontendBadRequest() *ReplaceBindFrontendBadRequest { + + return &ReplaceBindFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind frontend bad request response +func (o *ReplaceBindFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceBindFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind frontend bad request response +func (o *ReplaceBindFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind frontend bad request response +func (o *ReplaceBindFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceBindFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind frontend bad request response +func (o *ReplaceBindFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindFrontendNotFoundCode is the HTTP code returned for type ReplaceBindFrontendNotFound +const ReplaceBindFrontendNotFoundCode int = 404 + +/* +ReplaceBindFrontendNotFound The specified resource was not found + +swagger:response replaceBindFrontendNotFound +*/ +type ReplaceBindFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindFrontendNotFound creates ReplaceBindFrontendNotFound with default headers values +func NewReplaceBindFrontendNotFound() *ReplaceBindFrontendNotFound { + + return &ReplaceBindFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind frontend not found response +func (o *ReplaceBindFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceBindFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind frontend not found response +func (o *ReplaceBindFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind frontend not found response +func (o *ReplaceBindFrontendNotFound) WithPayload(payload *models.Error) *ReplaceBindFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind frontend not found response +func (o *ReplaceBindFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceBindFrontendDefault General Error + +swagger:response replaceBindFrontendDefault +*/ +type ReplaceBindFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindFrontendDefault creates ReplaceBindFrontendDefault with default headers values +func NewReplaceBindFrontendDefault(code int) *ReplaceBindFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceBindFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace bind frontend default response +func (o *ReplaceBindFrontendDefault) WithStatusCode(code int) *ReplaceBindFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace bind frontend default response +func (o *ReplaceBindFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind frontend default response +func (o *ReplaceBindFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceBindFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind frontend default response +func (o *ReplaceBindFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind frontend default response +func (o *ReplaceBindFrontendDefault) WithPayload(payload *models.Error) *ReplaceBindFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind frontend default response +func (o *ReplaceBindFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/replace_bind_frontend_urlbuilder.go b/operations/bind/replace_bind_frontend_urlbuilder.go new file mode 100644 index 00000000..df71a4fa --- /dev/null +++ b/operations/bind/replace_bind_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceBindFrontendURL generates an URL for the replace bind frontend operation +type ReplaceBindFrontendURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBindFrontendURL) WithBasePath(bp string) *ReplaceBindFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBindFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceBindFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceBindFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceBindFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceBindFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceBindFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceBindFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceBindFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceBindFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceBindFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/replace_bind_log_forward.go b/operations/bind/replace_bind_log_forward.go new file mode 100644 index 00000000..d982e5d9 --- /dev/null +++ b/operations/bind/replace_bind_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceBindLogForwardHandlerFunc turns a function with the right signature into a replace bind log forward handler +type ReplaceBindLogForwardHandlerFunc func(ReplaceBindLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceBindLogForwardHandlerFunc) Handle(params ReplaceBindLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceBindLogForwardHandler interface for that can handle valid replace bind log forward params +type ReplaceBindLogForwardHandler interface { + Handle(ReplaceBindLogForwardParams, interface{}) middleware.Responder +} + +// NewReplaceBindLogForward creates a new http.Handler for the replace bind log forward operation +func NewReplaceBindLogForward(ctx *middleware.Context, handler ReplaceBindLogForwardHandler) *ReplaceBindLogForward { + return &ReplaceBindLogForward{Context: ctx, Handler: handler} +} + +/* + ReplaceBindLogForward swagger:route PUT /services/haproxy/configuration/log_forwards/{parent_name}/binds/{name} Bind replaceBindLogForward + +# Replace a bind + +Replaces a bind configuration by it's name in the specified frontend. +*/ +type ReplaceBindLogForward struct { + Context *middleware.Context + Handler ReplaceBindLogForwardHandler +} + +func (o *ReplaceBindLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceBindLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/replace_bind_log_forward_parameters.go b/operations/bind/replace_bind_log_forward_parameters.go new file mode 100644 index 00000000..1b0316bd --- /dev/null +++ b/operations/bind/replace_bind_log_forward_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceBindLogForwardParams creates a new ReplaceBindLogForwardParams object +// with the default values initialized. +func NewReplaceBindLogForwardParams() ReplaceBindLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceBindLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceBindLogForwardParams contains all the bound params for the replace bind log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceBindLogForward +type ReplaceBindLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Bind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceBindLogForwardParams() beforehand. +func (o *ReplaceBindLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Bind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceBindLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceBindLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceBindLogForwardParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceBindLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceBindLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceBindLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/replace_bind_log_forward_responses.go b/operations/bind/replace_bind_log_forward_responses.go new file mode 100644 index 00000000..d546e683 --- /dev/null +++ b/operations/bind/replace_bind_log_forward_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceBindLogForwardOKCode is the HTTP code returned for type ReplaceBindLogForwardOK +const ReplaceBindLogForwardOKCode int = 200 + +/* +ReplaceBindLogForwardOK Bind replaced + +swagger:response replaceBindLogForwardOK +*/ +type ReplaceBindLogForwardOK struct { + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewReplaceBindLogForwardOK creates ReplaceBindLogForwardOK with default headers values +func NewReplaceBindLogForwardOK() *ReplaceBindLogForwardOK { + + return &ReplaceBindLogForwardOK{} +} + +// WithPayload adds the payload to the replace bind log forward o k response +func (o *ReplaceBindLogForwardOK) WithPayload(payload *models.Bind) *ReplaceBindLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind log forward o k response +func (o *ReplaceBindLogForwardOK) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindLogForwardAcceptedCode is the HTTP code returned for type ReplaceBindLogForwardAccepted +const ReplaceBindLogForwardAcceptedCode int = 202 + +/* +ReplaceBindLogForwardAccepted Configuration change accepted and reload requested + +swagger:response replaceBindLogForwardAccepted +*/ +type ReplaceBindLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewReplaceBindLogForwardAccepted creates ReplaceBindLogForwardAccepted with default headers values +func NewReplaceBindLogForwardAccepted() *ReplaceBindLogForwardAccepted { + + return &ReplaceBindLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the replace bind log forward accepted response +func (o *ReplaceBindLogForwardAccepted) WithReloadID(reloadID string) *ReplaceBindLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace bind log forward accepted response +func (o *ReplaceBindLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace bind log forward accepted response +func (o *ReplaceBindLogForwardAccepted) WithPayload(payload *models.Bind) *ReplaceBindLogForwardAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind log forward accepted response +func (o *ReplaceBindLogForwardAccepted) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindLogForwardBadRequestCode is the HTTP code returned for type ReplaceBindLogForwardBadRequest +const ReplaceBindLogForwardBadRequestCode int = 400 + +/* +ReplaceBindLogForwardBadRequest Bad request + +swagger:response replaceBindLogForwardBadRequest +*/ +type ReplaceBindLogForwardBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindLogForwardBadRequest creates ReplaceBindLogForwardBadRequest with default headers values +func NewReplaceBindLogForwardBadRequest() *ReplaceBindLogForwardBadRequest { + + return &ReplaceBindLogForwardBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind log forward bad request response +func (o *ReplaceBindLogForwardBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceBindLogForwardBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind log forward bad request response +func (o *ReplaceBindLogForwardBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind log forward bad request response +func (o *ReplaceBindLogForwardBadRequest) WithPayload(payload *models.Error) *ReplaceBindLogForwardBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind log forward bad request response +func (o *ReplaceBindLogForwardBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindLogForwardBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindLogForwardNotFoundCode is the HTTP code returned for type ReplaceBindLogForwardNotFound +const ReplaceBindLogForwardNotFoundCode int = 404 + +/* +ReplaceBindLogForwardNotFound The specified resource was not found + +swagger:response replaceBindLogForwardNotFound +*/ +type ReplaceBindLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindLogForwardNotFound creates ReplaceBindLogForwardNotFound with default headers values +func NewReplaceBindLogForwardNotFound() *ReplaceBindLogForwardNotFound { + + return &ReplaceBindLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind log forward not found response +func (o *ReplaceBindLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceBindLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind log forward not found response +func (o *ReplaceBindLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind log forward not found response +func (o *ReplaceBindLogForwardNotFound) WithPayload(payload *models.Error) *ReplaceBindLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind log forward not found response +func (o *ReplaceBindLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceBindLogForwardDefault General Error + +swagger:response replaceBindLogForwardDefault +*/ +type ReplaceBindLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindLogForwardDefault creates ReplaceBindLogForwardDefault with default headers values +func NewReplaceBindLogForwardDefault(code int) *ReplaceBindLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceBindLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace bind log forward default response +func (o *ReplaceBindLogForwardDefault) WithStatusCode(code int) *ReplaceBindLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace bind log forward default response +func (o *ReplaceBindLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind log forward default response +func (o *ReplaceBindLogForwardDefault) WithConfigurationVersion(configurationVersion string) *ReplaceBindLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind log forward default response +func (o *ReplaceBindLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind log forward default response +func (o *ReplaceBindLogForwardDefault) WithPayload(payload *models.Error) *ReplaceBindLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind log forward default response +func (o *ReplaceBindLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/replace_bind_log_forward_urlbuilder.go b/operations/bind/replace_bind_log_forward_urlbuilder.go new file mode 100644 index 00000000..1f1b1572 --- /dev/null +++ b/operations/bind/replace_bind_log_forward_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceBindLogForwardURL generates an URL for the replace bind log forward operation +type ReplaceBindLogForwardURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBindLogForwardURL) WithBasePath(bp string) *ReplaceBindLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBindLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceBindLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceBindLogForwardURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceBindLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceBindLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceBindLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceBindLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceBindLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceBindLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceBindLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/replace_bind_parameters.go b/operations/bind/replace_bind_parameters.go deleted file mode 100644 index fdc466b6..00000000 --- a/operations/bind/replace_bind_parameters.go +++ /dev/null @@ -1,253 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceBindParams creates a new ReplaceBindParams object -// with the default values initialized. -func NewReplaceBindParams() ReplaceBindParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceBindParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceBindParams contains all the bound params for the replace bind operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceBind -type ReplaceBindParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.Bind - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent frontend name - Required: true - In: query - */ - Frontend string - /*Bind name - Required: true - In: path - */ - Name string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceBindParams() beforehand. -func (o *ReplaceBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.Bind - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qFrontend, qhkFrontend, _ := qs.GetOK("frontend") - if err := o.bindFrontend(qFrontend, qhkFrontend, route.Formats); err != nil { - res = append(res, err) - } - - rName, rhkName, _ := route.Params.GetOK("name") - if err := o.bindName(rName, rhkName, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceBindParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceBindParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindFrontend binds and validates parameter Frontend from query. -func (o *ReplaceBindParams) bindFrontend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("frontend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("frontend", "query", raw); err != nil { - return err - } - - o.Frontend = raw - - return nil -} - -// bindName binds and validates parameter Name from path. -func (o *ReplaceBindParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - o.Name = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceBindParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/bind/replace_bind_peer.go b/operations/bind/replace_bind_peer.go new file mode 100644 index 00000000..116c9bbe --- /dev/null +++ b/operations/bind/replace_bind_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceBindPeerHandlerFunc turns a function with the right signature into a replace bind peer handler +type ReplaceBindPeerHandlerFunc func(ReplaceBindPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceBindPeerHandlerFunc) Handle(params ReplaceBindPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceBindPeerHandler interface for that can handle valid replace bind peer params +type ReplaceBindPeerHandler interface { + Handle(ReplaceBindPeerParams, interface{}) middleware.Responder +} + +// NewReplaceBindPeer creates a new http.Handler for the replace bind peer operation +func NewReplaceBindPeer(ctx *middleware.Context, handler ReplaceBindPeerHandler) *ReplaceBindPeer { + return &ReplaceBindPeer{Context: ctx, Handler: handler} +} + +/* + ReplaceBindPeer swagger:route PUT /services/haproxy/configuration/peers/{parent_name}/binds/{name} Bind replaceBindPeer + +# Replace a bind + +Replaces a bind configuration by it's name in the specified frontend. +*/ +type ReplaceBindPeer struct { + Context *middleware.Context + Handler ReplaceBindPeerHandler +} + +func (o *ReplaceBindPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceBindPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/bind/replace_bind_peer_parameters.go b/operations/bind/replace_bind_peer_parameters.go new file mode 100644 index 00000000..7553bdef --- /dev/null +++ b/operations/bind/replace_bind_peer_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceBindPeerParams creates a new ReplaceBindPeerParams object +// with the default values initialized. +func NewReplaceBindPeerParams() ReplaceBindPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceBindPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceBindPeerParams contains all the bound params for the replace bind peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceBindPeer +type ReplaceBindPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Bind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceBindPeerParams() beforehand. +func (o *ReplaceBindPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Bind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceBindPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceBindPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceBindPeerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceBindPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceBindPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceBindPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/bind/replace_bind_peer_responses.go b/operations/bind/replace_bind_peer_responses.go new file mode 100644 index 00000000..28033d73 --- /dev/null +++ b/operations/bind/replace_bind_peer_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceBindPeerOKCode is the HTTP code returned for type ReplaceBindPeerOK +const ReplaceBindPeerOKCode int = 200 + +/* +ReplaceBindPeerOK Bind replaced + +swagger:response replaceBindPeerOK +*/ +type ReplaceBindPeerOK struct { + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewReplaceBindPeerOK creates ReplaceBindPeerOK with default headers values +func NewReplaceBindPeerOK() *ReplaceBindPeerOK { + + return &ReplaceBindPeerOK{} +} + +// WithPayload adds the payload to the replace bind peer o k response +func (o *ReplaceBindPeerOK) WithPayload(payload *models.Bind) *ReplaceBindPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind peer o k response +func (o *ReplaceBindPeerOK) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindPeerAcceptedCode is the HTTP code returned for type ReplaceBindPeerAccepted +const ReplaceBindPeerAcceptedCode int = 202 + +/* +ReplaceBindPeerAccepted Configuration change accepted and reload requested + +swagger:response replaceBindPeerAccepted +*/ +type ReplaceBindPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Bind `json:"body,omitempty"` +} + +// NewReplaceBindPeerAccepted creates ReplaceBindPeerAccepted with default headers values +func NewReplaceBindPeerAccepted() *ReplaceBindPeerAccepted { + + return &ReplaceBindPeerAccepted{} +} + +// WithReloadID adds the reloadId to the replace bind peer accepted response +func (o *ReplaceBindPeerAccepted) WithReloadID(reloadID string) *ReplaceBindPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace bind peer accepted response +func (o *ReplaceBindPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace bind peer accepted response +func (o *ReplaceBindPeerAccepted) WithPayload(payload *models.Bind) *ReplaceBindPeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind peer accepted response +func (o *ReplaceBindPeerAccepted) SetPayload(payload *models.Bind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindPeerBadRequestCode is the HTTP code returned for type ReplaceBindPeerBadRequest +const ReplaceBindPeerBadRequestCode int = 400 + +/* +ReplaceBindPeerBadRequest Bad request + +swagger:response replaceBindPeerBadRequest +*/ +type ReplaceBindPeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindPeerBadRequest creates ReplaceBindPeerBadRequest with default headers values +func NewReplaceBindPeerBadRequest() *ReplaceBindPeerBadRequest { + + return &ReplaceBindPeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind peer bad request response +func (o *ReplaceBindPeerBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceBindPeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind peer bad request response +func (o *ReplaceBindPeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind peer bad request response +func (o *ReplaceBindPeerBadRequest) WithPayload(payload *models.Error) *ReplaceBindPeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind peer bad request response +func (o *ReplaceBindPeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindPeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceBindPeerNotFoundCode is the HTTP code returned for type ReplaceBindPeerNotFound +const ReplaceBindPeerNotFoundCode int = 404 + +/* +ReplaceBindPeerNotFound The specified resource was not found + +swagger:response replaceBindPeerNotFound +*/ +type ReplaceBindPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindPeerNotFound creates ReplaceBindPeerNotFound with default headers values +func NewReplaceBindPeerNotFound() *ReplaceBindPeerNotFound { + + return &ReplaceBindPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind peer not found response +func (o *ReplaceBindPeerNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceBindPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind peer not found response +func (o *ReplaceBindPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind peer not found response +func (o *ReplaceBindPeerNotFound) WithPayload(payload *models.Error) *ReplaceBindPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind peer not found response +func (o *ReplaceBindPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceBindPeerDefault General Error + +swagger:response replaceBindPeerDefault +*/ +type ReplaceBindPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceBindPeerDefault creates ReplaceBindPeerDefault with default headers values +func NewReplaceBindPeerDefault(code int) *ReplaceBindPeerDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceBindPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace bind peer default response +func (o *ReplaceBindPeerDefault) WithStatusCode(code int) *ReplaceBindPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace bind peer default response +func (o *ReplaceBindPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace bind peer default response +func (o *ReplaceBindPeerDefault) WithConfigurationVersion(configurationVersion string) *ReplaceBindPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace bind peer default response +func (o *ReplaceBindPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace bind peer default response +func (o *ReplaceBindPeerDefault) WithPayload(payload *models.Error) *ReplaceBindPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace bind peer default response +func (o *ReplaceBindPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceBindPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/bind/replace_bind_peer_urlbuilder.go b/operations/bind/replace_bind_peer_urlbuilder.go new file mode 100644 index 00000000..23ada1d1 --- /dev/null +++ b/operations/bind/replace_bind_peer_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceBindPeerURL generates an URL for the replace bind peer operation +type ReplaceBindPeerURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBindPeerURL) WithBasePath(bp string) *ReplaceBindPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceBindPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceBindPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceBindPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceBindPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceBindPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceBindPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceBindPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceBindPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceBindPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceBindPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/bind/replace_bind_responses.go b/operations/bind/replace_bind_responses.go deleted file mode 100644 index 20cebcff..00000000 --- a/operations/bind/replace_bind_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceBindOKCode is the HTTP code returned for type ReplaceBindOK -const ReplaceBindOKCode int = 200 - -/*ReplaceBindOK Bind replaced - -swagger:response replaceBindOK -*/ -type ReplaceBindOK struct { - - /* - In: Body - */ - Payload *models.Bind `json:"body,omitempty"` -} - -// NewReplaceBindOK creates ReplaceBindOK with default headers values -func NewReplaceBindOK() *ReplaceBindOK { - - return &ReplaceBindOK{} -} - -// WithPayload adds the payload to the replace bind o k response -func (o *ReplaceBindOK) WithPayload(payload *models.Bind) *ReplaceBindOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace bind o k response -func (o *ReplaceBindOK) SetPayload(payload *models.Bind) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceBindOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceBindAcceptedCode is the HTTP code returned for type ReplaceBindAccepted -const ReplaceBindAcceptedCode int = 202 - -/*ReplaceBindAccepted Configuration change accepted and reload requested - -swagger:response replaceBindAccepted -*/ -type ReplaceBindAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.Bind `json:"body,omitempty"` -} - -// NewReplaceBindAccepted creates ReplaceBindAccepted with default headers values -func NewReplaceBindAccepted() *ReplaceBindAccepted { - - return &ReplaceBindAccepted{} -} - -// WithReloadID adds the reloadId to the replace bind accepted response -func (o *ReplaceBindAccepted) WithReloadID(reloadID string) *ReplaceBindAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace bind accepted response -func (o *ReplaceBindAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace bind accepted response -func (o *ReplaceBindAccepted) WithPayload(payload *models.Bind) *ReplaceBindAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace bind accepted response -func (o *ReplaceBindAccepted) SetPayload(payload *models.Bind) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceBindAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceBindBadRequestCode is the HTTP code returned for type ReplaceBindBadRequest -const ReplaceBindBadRequestCode int = 400 - -/*ReplaceBindBadRequest Bad request - -swagger:response replaceBindBadRequest -*/ -type ReplaceBindBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceBindBadRequest creates ReplaceBindBadRequest with default headers values -func NewReplaceBindBadRequest() *ReplaceBindBadRequest { - - return &ReplaceBindBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace bind bad request response -func (o *ReplaceBindBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceBindBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace bind bad request response -func (o *ReplaceBindBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace bind bad request response -func (o *ReplaceBindBadRequest) WithPayload(payload *models.Error) *ReplaceBindBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace bind bad request response -func (o *ReplaceBindBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceBindBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceBindNotFoundCode is the HTTP code returned for type ReplaceBindNotFound -const ReplaceBindNotFoundCode int = 404 - -/*ReplaceBindNotFound The specified resource was not found - -swagger:response replaceBindNotFound -*/ -type ReplaceBindNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceBindNotFound creates ReplaceBindNotFound with default headers values -func NewReplaceBindNotFound() *ReplaceBindNotFound { - - return &ReplaceBindNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace bind not found response -func (o *ReplaceBindNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceBindNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace bind not found response -func (o *ReplaceBindNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace bind not found response -func (o *ReplaceBindNotFound) WithPayload(payload *models.Error) *ReplaceBindNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace bind not found response -func (o *ReplaceBindNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceBindNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceBindDefault General Error - -swagger:response replaceBindDefault -*/ -type ReplaceBindDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceBindDefault creates ReplaceBindDefault with default headers values -func NewReplaceBindDefault(code int) *ReplaceBindDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceBindDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace bind default response -func (o *ReplaceBindDefault) WithStatusCode(code int) *ReplaceBindDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace bind default response -func (o *ReplaceBindDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace bind default response -func (o *ReplaceBindDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceBindDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace bind default response -func (o *ReplaceBindDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace bind default response -func (o *ReplaceBindDefault) WithPayload(payload *models.Error) *ReplaceBindDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace bind default response -func (o *ReplaceBindDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/bind/replace_bind_urlbuilder.go b/operations/bind/replace_bind_urlbuilder.go deleted file mode 100644 index 4b8a8aeb..00000000 --- a/operations/bind/replace_bind_urlbuilder.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package bind - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceBindURL generates an URL for the replace bind operation -type ReplaceBindURL struct { - Name string - - ForceReload *bool - Frontend string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceBindURL) WithBasePath(bp string) *ReplaceBindURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceBindURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceBindURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/binds/{name}" - - name := o.Name - if name != "" { - _path = strings.Replace(_path, "{name}", name, -1) - } else { - return nil, errors.New("name is required on ReplaceBindURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - frontend := o.Frontend - if frontend != "" { - qs.Set("frontend", frontend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceBindURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceBindURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceBindURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceBindURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceBindURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceBindURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/cache/create_cache.go b/operations/cache/create_cache.go new file mode 100644 index 00000000..41695bcd --- /dev/null +++ b/operations/cache/create_cache.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateCacheHandlerFunc turns a function with the right signature into a create cache handler +type CreateCacheHandlerFunc func(CreateCacheParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateCacheHandlerFunc) Handle(params CreateCacheParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateCacheHandler interface for that can handle valid create cache params +type CreateCacheHandler interface { + Handle(CreateCacheParams, interface{}) middleware.Responder +} + +// NewCreateCache creates a new http.Handler for the create cache operation +func NewCreateCache(ctx *middleware.Context, handler CreateCacheHandler) *CreateCache { + return &CreateCache{Context: ctx, Handler: handler} +} + +/* + CreateCache swagger:route POST /services/haproxy/configuration/caches Cache createCache + +# Add a cache + +Adds a new cache section to the configuration file. +*/ +type CreateCache struct { + Context *middleware.Context + Handler CreateCacheHandler +} + +func (o *CreateCache) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateCacheParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cache/create_cache_parameters.go b/operations/cache/create_cache_parameters.go new file mode 100644 index 00000000..3f8ea385 --- /dev/null +++ b/operations/cache/create_cache_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateCacheParams creates a new CreateCacheParams object +// with the default values initialized. +func NewCreateCacheParams() CreateCacheParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateCacheParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateCacheParams contains all the bound params for the create cache operation +// typically these are obtained from a http.Request +// +// swagger:parameters createCache +type CreateCacheParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Cache + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateCacheParams() beforehand. +func (o *CreateCacheParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Cache + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateCacheParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateCacheParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateCacheParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateCacheParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/cache/create_cache_responses.go b/operations/cache/create_cache_responses.go new file mode 100644 index 00000000..686ed55c --- /dev/null +++ b/operations/cache/create_cache_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateCacheCreatedCode is the HTTP code returned for type CreateCacheCreated +const CreateCacheCreatedCode int = 201 + +/* +CreateCacheCreated Cache created + +swagger:response createCacheCreated +*/ +type CreateCacheCreated struct { + + /* + In: Body + */ + Payload *models.Cache `json:"body,omitempty"` +} + +// NewCreateCacheCreated creates CreateCacheCreated with default headers values +func NewCreateCacheCreated() *CreateCacheCreated { + + return &CreateCacheCreated{} +} + +// WithPayload adds the payload to the create cache created response +func (o *CreateCacheCreated) WithPayload(payload *models.Cache) *CreateCacheCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cache created response +func (o *CreateCacheCreated) SetPayload(payload *models.Cache) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCacheCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCacheAcceptedCode is the HTTP code returned for type CreateCacheAccepted +const CreateCacheAcceptedCode int = 202 + +/* +CreateCacheAccepted Configuration change accepted and reload requested + +swagger:response createCacheAccepted +*/ +type CreateCacheAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Cache `json:"body,omitempty"` +} + +// NewCreateCacheAccepted creates CreateCacheAccepted with default headers values +func NewCreateCacheAccepted() *CreateCacheAccepted { + + return &CreateCacheAccepted{} +} + +// WithReloadID adds the reloadId to the create cache accepted response +func (o *CreateCacheAccepted) WithReloadID(reloadID string) *CreateCacheAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create cache accepted response +func (o *CreateCacheAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create cache accepted response +func (o *CreateCacheAccepted) WithPayload(payload *models.Cache) *CreateCacheAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cache accepted response +func (o *CreateCacheAccepted) SetPayload(payload *models.Cache) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCacheAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCacheBadRequestCode is the HTTP code returned for type CreateCacheBadRequest +const CreateCacheBadRequestCode int = 400 + +/* +CreateCacheBadRequest Bad request + +swagger:response createCacheBadRequest +*/ +type CreateCacheBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCacheBadRequest creates CreateCacheBadRequest with default headers values +func NewCreateCacheBadRequest() *CreateCacheBadRequest { + + return &CreateCacheBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create cache bad request response +func (o *CreateCacheBadRequest) WithConfigurationVersion(configurationVersion string) *CreateCacheBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create cache bad request response +func (o *CreateCacheBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create cache bad request response +func (o *CreateCacheBadRequest) WithPayload(payload *models.Error) *CreateCacheBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cache bad request response +func (o *CreateCacheBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCacheBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCacheConflictCode is the HTTP code returned for type CreateCacheConflict +const CreateCacheConflictCode int = 409 + +/* +CreateCacheConflict The specified resource already exists + +swagger:response createCacheConflict +*/ +type CreateCacheConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCacheConflict creates CreateCacheConflict with default headers values +func NewCreateCacheConflict() *CreateCacheConflict { + + return &CreateCacheConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create cache conflict response +func (o *CreateCacheConflict) WithConfigurationVersion(configurationVersion string) *CreateCacheConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create cache conflict response +func (o *CreateCacheConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create cache conflict response +func (o *CreateCacheConflict) WithPayload(payload *models.Error) *CreateCacheConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cache conflict response +func (o *CreateCacheConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCacheConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateCacheDefault General Error + +swagger:response createCacheDefault +*/ +type CreateCacheDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCacheDefault creates CreateCacheDefault with default headers values +func NewCreateCacheDefault(code int) *CreateCacheDefault { + if code <= 0 { + code = 500 + } + + return &CreateCacheDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create cache default response +func (o *CreateCacheDefault) WithStatusCode(code int) *CreateCacheDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create cache default response +func (o *CreateCacheDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create cache default response +func (o *CreateCacheDefault) WithConfigurationVersion(configurationVersion string) *CreateCacheDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create cache default response +func (o *CreateCacheDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create cache default response +func (o *CreateCacheDefault) WithPayload(payload *models.Error) *CreateCacheDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cache default response +func (o *CreateCacheDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCacheDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cache/create_cache_urlbuilder.go b/operations/cache/create_cache_urlbuilder.go new file mode 100644 index 00000000..01f68ecb --- /dev/null +++ b/operations/cache/create_cache_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateCacheURL generates an URL for the create cache operation +type CreateCacheURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCacheURL) WithBasePath(bp string) *CreateCacheURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCacheURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateCacheURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/caches" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateCacheURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateCacheURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateCacheURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateCacheURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateCacheURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateCacheURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cache/delete_cache.go b/operations/cache/delete_cache.go new file mode 100644 index 00000000..e7e20427 --- /dev/null +++ b/operations/cache/delete_cache.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCacheHandlerFunc turns a function with the right signature into a delete cache handler +type DeleteCacheHandlerFunc func(DeleteCacheParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCacheHandlerFunc) Handle(params DeleteCacheParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteCacheHandler interface for that can handle valid delete cache params +type DeleteCacheHandler interface { + Handle(DeleteCacheParams, interface{}) middleware.Responder +} + +// NewDeleteCache creates a new http.Handler for the delete cache operation +func NewDeleteCache(ctx *middleware.Context, handler DeleteCacheHandler) *DeleteCache { + return &DeleteCache{Context: ctx, Handler: handler} +} + +/* + DeleteCache swagger:route DELETE /services/haproxy/configuration/caches/{name} Cache deleteCache + +# Delete a cache + +Deletes a cache from the configuration by it's name. +*/ +type DeleteCache struct { + Context *middleware.Context + Handler DeleteCacheHandler +} + +func (o *DeleteCache) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCacheParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cache/delete_cache_parameters.go b/operations/cache/delete_cache_parameters.go new file mode 100644 index 00000000..1b2c886c --- /dev/null +++ b/operations/cache/delete_cache_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteCacheParams creates a new DeleteCacheParams object +// with the default values initialized. +func NewDeleteCacheParams() DeleteCacheParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteCacheParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteCacheParams contains all the bound params for the delete cache operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCache +type DeleteCacheParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Cache name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCacheParams() beforehand. +func (o *DeleteCacheParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteCacheParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteCacheParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteCacheParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteCacheParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteCacheParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/cache/delete_cache_responses.go b/operations/cache/delete_cache_responses.go new file mode 100644 index 00000000..77715b44 --- /dev/null +++ b/operations/cache/delete_cache_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteCacheAcceptedCode is the HTTP code returned for type DeleteCacheAccepted +const DeleteCacheAcceptedCode int = 202 + +/* +DeleteCacheAccepted Configuration change accepted and reload requested + +swagger:response deleteCacheAccepted +*/ +type DeleteCacheAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteCacheAccepted creates DeleteCacheAccepted with default headers values +func NewDeleteCacheAccepted() *DeleteCacheAccepted { + + return &DeleteCacheAccepted{} +} + +// WithReloadID adds the reloadId to the delete cache accepted response +func (o *DeleteCacheAccepted) WithReloadID(reloadID string) *DeleteCacheAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete cache accepted response +func (o *DeleteCacheAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteCacheAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteCacheNoContentCode is the HTTP code returned for type DeleteCacheNoContent +const DeleteCacheNoContentCode int = 204 + +/* +DeleteCacheNoContent Cache deleted + +swagger:response deleteCacheNoContent +*/ +type DeleteCacheNoContent struct { +} + +// NewDeleteCacheNoContent creates DeleteCacheNoContent with default headers values +func NewDeleteCacheNoContent() *DeleteCacheNoContent { + + return &DeleteCacheNoContent{} +} + +// WriteResponse to the client +func (o *DeleteCacheNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteCacheNotFoundCode is the HTTP code returned for type DeleteCacheNotFound +const DeleteCacheNotFoundCode int = 404 + +/* +DeleteCacheNotFound The specified resource was not found + +swagger:response deleteCacheNotFound +*/ +type DeleteCacheNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCacheNotFound creates DeleteCacheNotFound with default headers values +func NewDeleteCacheNotFound() *DeleteCacheNotFound { + + return &DeleteCacheNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete cache not found response +func (o *DeleteCacheNotFound) WithConfigurationVersion(configurationVersion string) *DeleteCacheNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete cache not found response +func (o *DeleteCacheNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete cache not found response +func (o *DeleteCacheNotFound) WithPayload(payload *models.Error) *DeleteCacheNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete cache not found response +func (o *DeleteCacheNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCacheNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteCacheDefault General Error + +swagger:response deleteCacheDefault +*/ +type DeleteCacheDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCacheDefault creates DeleteCacheDefault with default headers values +func NewDeleteCacheDefault(code int) *DeleteCacheDefault { + if code <= 0 { + code = 500 + } + + return &DeleteCacheDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete cache default response +func (o *DeleteCacheDefault) WithStatusCode(code int) *DeleteCacheDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete cache default response +func (o *DeleteCacheDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete cache default response +func (o *DeleteCacheDefault) WithConfigurationVersion(configurationVersion string) *DeleteCacheDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete cache default response +func (o *DeleteCacheDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete cache default response +func (o *DeleteCacheDefault) WithPayload(payload *models.Error) *DeleteCacheDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete cache default response +func (o *DeleteCacheDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCacheDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cache/delete_cache_urlbuilder.go b/operations/cache/delete_cache_urlbuilder.go new file mode 100644 index 00000000..56cd0b00 --- /dev/null +++ b/operations/cache/delete_cache_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteCacheURL generates an URL for the delete cache operation +type DeleteCacheURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCacheURL) WithBasePath(bp string) *DeleteCacheURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCacheURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCacheURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/caches/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteCacheURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCacheURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCacheURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCacheURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCacheURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCacheURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCacheURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cache/get_cache.go b/operations/cache/get_cache.go new file mode 100644 index 00000000..f346e65f --- /dev/null +++ b/operations/cache/get_cache.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCacheHandlerFunc turns a function with the right signature into a get cache handler +type GetCacheHandlerFunc func(GetCacheParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCacheHandlerFunc) Handle(params GetCacheParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCacheHandler interface for that can handle valid get cache params +type GetCacheHandler interface { + Handle(GetCacheParams, interface{}) middleware.Responder +} + +// NewGetCache creates a new http.Handler for the get cache operation +func NewGetCache(ctx *middleware.Context, handler GetCacheHandler) *GetCache { + return &GetCache{Context: ctx, Handler: handler} +} + +/* + GetCache swagger:route GET /services/haproxy/configuration/caches/{name} Cache getCache + +# Return a cache + +Returns one cache section configuration by it's name. +*/ +type GetCache struct { + Context *middleware.Context + Handler GetCacheHandler +} + +func (o *GetCache) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCacheParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cache/get_cache_parameters.go b/operations/cache/get_cache_parameters.go new file mode 100644 index 00000000..cfbc3690 --- /dev/null +++ b/operations/cache/get_cache_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetCacheParams creates a new GetCacheParams object +// +// There are no default values defined in the spec. +func NewGetCacheParams() GetCacheParams { + + return GetCacheParams{} +} + +// GetCacheParams contains all the bound params for the get cache operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCache +type GetCacheParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Cache name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCacheParams() beforehand. +func (o *GetCacheParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetCacheParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetCacheParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/cache/get_cache_responses.go b/operations/cache/get_cache_responses.go new file mode 100644 index 00000000..e9e3cd1f --- /dev/null +++ b/operations/cache/get_cache_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCacheOKCode is the HTTP code returned for type GetCacheOK +const GetCacheOKCode int = 200 + +/* +GetCacheOK Successful operation + +swagger:response getCacheOK +*/ +type GetCacheOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Cache `json:"body,omitempty"` +} + +// NewGetCacheOK creates GetCacheOK with default headers values +func NewGetCacheOK() *GetCacheOK { + + return &GetCacheOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get cache o k response +func (o *GetCacheOK) WithConfigurationVersion(configurationVersion string) *GetCacheOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get cache o k response +func (o *GetCacheOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get cache o k response +func (o *GetCacheOK) WithPayload(payload *models.Cache) *GetCacheOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cache o k response +func (o *GetCacheOK) SetPayload(payload *models.Cache) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCacheOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetCacheNotFoundCode is the HTTP code returned for type GetCacheNotFound +const GetCacheNotFoundCode int = 404 + +/* +GetCacheNotFound The specified resource was not found + +swagger:response getCacheNotFound +*/ +type GetCacheNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCacheNotFound creates GetCacheNotFound with default headers values +func NewGetCacheNotFound() *GetCacheNotFound { + + return &GetCacheNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get cache not found response +func (o *GetCacheNotFound) WithConfigurationVersion(configurationVersion string) *GetCacheNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get cache not found response +func (o *GetCacheNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get cache not found response +func (o *GetCacheNotFound) WithPayload(payload *models.Error) *GetCacheNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cache not found response +func (o *GetCacheNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCacheNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetCacheDefault General Error + +swagger:response getCacheDefault +*/ +type GetCacheDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCacheDefault creates GetCacheDefault with default headers values +func NewGetCacheDefault(code int) *GetCacheDefault { + if code <= 0 { + code = 500 + } + + return &GetCacheDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get cache default response +func (o *GetCacheDefault) WithStatusCode(code int) *GetCacheDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get cache default response +func (o *GetCacheDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get cache default response +func (o *GetCacheDefault) WithConfigurationVersion(configurationVersion string) *GetCacheDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get cache default response +func (o *GetCacheDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get cache default response +func (o *GetCacheDefault) WithPayload(payload *models.Error) *GetCacheDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cache default response +func (o *GetCacheDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCacheDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cache/get_cache_urlbuilder.go b/operations/cache/get_cache_urlbuilder.go new file mode 100644 index 00000000..17835358 --- /dev/null +++ b/operations/cache/get_cache_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetCacheURL generates an URL for the get cache operation +type GetCacheURL struct { + Name string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCacheURL) WithBasePath(bp string) *GetCacheURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCacheURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCacheURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/caches/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetCacheURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCacheURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCacheURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCacheURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCacheURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCacheURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCacheURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cache/get_caches.go b/operations/cache/get_caches.go new file mode 100644 index 00000000..26746ee7 --- /dev/null +++ b/operations/cache/get_caches.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCachesHandlerFunc turns a function with the right signature into a get caches handler +type GetCachesHandlerFunc func(GetCachesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCachesHandlerFunc) Handle(params GetCachesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCachesHandler interface for that can handle valid get caches params +type GetCachesHandler interface { + Handle(GetCachesParams, interface{}) middleware.Responder +} + +// NewGetCaches creates a new http.Handler for the get caches operation +func NewGetCaches(ctx *middleware.Context, handler GetCachesHandler) *GetCaches { + return &GetCaches{Context: ctx, Handler: handler} +} + +/* + GetCaches swagger:route GET /services/haproxy/configuration/caches Cache getCaches + +# Return an array of caches + +Returns an array of all configured caches. +*/ +type GetCaches struct { + Context *middleware.Context + Handler GetCachesHandler +} + +func (o *GetCaches) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCachesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cache/get_caches_parameters.go b/operations/cache/get_caches_parameters.go new file mode 100644 index 00000000..8c542ca6 --- /dev/null +++ b/operations/cache/get_caches_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetCachesParams creates a new GetCachesParams object +// +// There are no default values defined in the spec. +func NewGetCachesParams() GetCachesParams { + + return GetCachesParams{} +} + +// GetCachesParams contains all the bound params for the get caches operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCaches +type GetCachesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCachesParams() beforehand. +func (o *GetCachesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetCachesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/cache/get_caches_responses.go b/operations/cache/get_caches_responses.go new file mode 100644 index 00000000..5854525f --- /dev/null +++ b/operations/cache/get_caches_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCachesOKCode is the HTTP code returned for type GetCachesOK +const GetCachesOKCode int = 200 + +/* +GetCachesOK Successful operation + +swagger:response getCachesOK +*/ +type GetCachesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Caches `json:"body,omitempty"` +} + +// NewGetCachesOK creates GetCachesOK with default headers values +func NewGetCachesOK() *GetCachesOK { + + return &GetCachesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get caches o k response +func (o *GetCachesOK) WithConfigurationVersion(configurationVersion string) *GetCachesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get caches o k response +func (o *GetCachesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get caches o k response +func (o *GetCachesOK) WithPayload(payload models.Caches) *GetCachesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get caches o k response +func (o *GetCachesOK) SetPayload(payload models.Caches) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCachesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Caches{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetCachesDefault General Error + +swagger:response getCachesDefault +*/ +type GetCachesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCachesDefault creates GetCachesDefault with default headers values +func NewGetCachesDefault(code int) *GetCachesDefault { + if code <= 0 { + code = 500 + } + + return &GetCachesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get caches default response +func (o *GetCachesDefault) WithStatusCode(code int) *GetCachesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get caches default response +func (o *GetCachesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get caches default response +func (o *GetCachesDefault) WithConfigurationVersion(configurationVersion string) *GetCachesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get caches default response +func (o *GetCachesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get caches default response +func (o *GetCachesDefault) WithPayload(payload *models.Error) *GetCachesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get caches default response +func (o *GetCachesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCachesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cache/get_caches_urlbuilder.go b/operations/cache/get_caches_urlbuilder.go new file mode 100644 index 00000000..a360a024 --- /dev/null +++ b/operations/cache/get_caches_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetCachesURL generates an URL for the get caches operation +type GetCachesURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCachesURL) WithBasePath(bp string) *GetCachesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCachesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCachesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/caches" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCachesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCachesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCachesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCachesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCachesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCachesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cache/replace_cache.go b/operations/cache/replace_cache.go new file mode 100644 index 00000000..a0ecb4d2 --- /dev/null +++ b/operations/cache/replace_cache.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceCacheHandlerFunc turns a function with the right signature into a replace cache handler +type ReplaceCacheHandlerFunc func(ReplaceCacheParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceCacheHandlerFunc) Handle(params ReplaceCacheParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceCacheHandler interface for that can handle valid replace cache params +type ReplaceCacheHandler interface { + Handle(ReplaceCacheParams, interface{}) middleware.Responder +} + +// NewReplaceCache creates a new http.Handler for the replace cache operation +func NewReplaceCache(ctx *middleware.Context, handler ReplaceCacheHandler) *ReplaceCache { + return &ReplaceCache{Context: ctx, Handler: handler} +} + +/* + ReplaceCache swagger:route PUT /services/haproxy/configuration/caches/{name} Cache replaceCache + +# Replace a cache + +Replaces a cache configuration by it's name. +*/ +type ReplaceCache struct { + Context *middleware.Context + Handler ReplaceCacheHandler +} + +func (o *ReplaceCache) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceCacheParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cache/replace_cache_parameters.go b/operations/cache/replace_cache_parameters.go new file mode 100644 index 00000000..03b5ba7d --- /dev/null +++ b/operations/cache/replace_cache_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceCacheParams creates a new ReplaceCacheParams object +// with the default values initialized. +func NewReplaceCacheParams() ReplaceCacheParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceCacheParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceCacheParams contains all the bound params for the replace cache operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceCache +type ReplaceCacheParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Cache + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Cache name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceCacheParams() beforehand. +func (o *ReplaceCacheParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Cache + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceCacheParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceCacheParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceCacheParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceCacheParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceCacheParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/cache/replace_cache_responses.go b/operations/cache/replace_cache_responses.go new file mode 100644 index 00000000..1094146c --- /dev/null +++ b/operations/cache/replace_cache_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceCacheOKCode is the HTTP code returned for type ReplaceCacheOK +const ReplaceCacheOKCode int = 200 + +/* +ReplaceCacheOK Cache replaced + +swagger:response replaceCacheOK +*/ +type ReplaceCacheOK struct { + + /* + In: Body + */ + Payload *models.Cache `json:"body,omitempty"` +} + +// NewReplaceCacheOK creates ReplaceCacheOK with default headers values +func NewReplaceCacheOK() *ReplaceCacheOK { + + return &ReplaceCacheOK{} +} + +// WithPayload adds the payload to the replace cache o k response +func (o *ReplaceCacheOK) WithPayload(payload *models.Cache) *ReplaceCacheOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace cache o k response +func (o *ReplaceCacheOK) SetPayload(payload *models.Cache) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCacheOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceCacheAcceptedCode is the HTTP code returned for type ReplaceCacheAccepted +const ReplaceCacheAcceptedCode int = 202 + +/* +ReplaceCacheAccepted Configuration change accepted and reload requested + +swagger:response replaceCacheAccepted +*/ +type ReplaceCacheAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Cache `json:"body,omitempty"` +} + +// NewReplaceCacheAccepted creates ReplaceCacheAccepted with default headers values +func NewReplaceCacheAccepted() *ReplaceCacheAccepted { + + return &ReplaceCacheAccepted{} +} + +// WithReloadID adds the reloadId to the replace cache accepted response +func (o *ReplaceCacheAccepted) WithReloadID(reloadID string) *ReplaceCacheAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace cache accepted response +func (o *ReplaceCacheAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace cache accepted response +func (o *ReplaceCacheAccepted) WithPayload(payload *models.Cache) *ReplaceCacheAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace cache accepted response +func (o *ReplaceCacheAccepted) SetPayload(payload *models.Cache) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCacheAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceCacheBadRequestCode is the HTTP code returned for type ReplaceCacheBadRequest +const ReplaceCacheBadRequestCode int = 400 + +/* +ReplaceCacheBadRequest Bad request + +swagger:response replaceCacheBadRequest +*/ +type ReplaceCacheBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCacheBadRequest creates ReplaceCacheBadRequest with default headers values +func NewReplaceCacheBadRequest() *ReplaceCacheBadRequest { + + return &ReplaceCacheBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace cache bad request response +func (o *ReplaceCacheBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceCacheBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace cache bad request response +func (o *ReplaceCacheBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace cache bad request response +func (o *ReplaceCacheBadRequest) WithPayload(payload *models.Error) *ReplaceCacheBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace cache bad request response +func (o *ReplaceCacheBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCacheBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceCacheNotFoundCode is the HTTP code returned for type ReplaceCacheNotFound +const ReplaceCacheNotFoundCode int = 404 + +/* +ReplaceCacheNotFound The specified resource was not found + +swagger:response replaceCacheNotFound +*/ +type ReplaceCacheNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCacheNotFound creates ReplaceCacheNotFound with default headers values +func NewReplaceCacheNotFound() *ReplaceCacheNotFound { + + return &ReplaceCacheNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace cache not found response +func (o *ReplaceCacheNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceCacheNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace cache not found response +func (o *ReplaceCacheNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace cache not found response +func (o *ReplaceCacheNotFound) WithPayload(payload *models.Error) *ReplaceCacheNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace cache not found response +func (o *ReplaceCacheNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCacheNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceCacheDefault General Error + +swagger:response replaceCacheDefault +*/ +type ReplaceCacheDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCacheDefault creates ReplaceCacheDefault with default headers values +func NewReplaceCacheDefault(code int) *ReplaceCacheDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceCacheDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace cache default response +func (o *ReplaceCacheDefault) WithStatusCode(code int) *ReplaceCacheDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace cache default response +func (o *ReplaceCacheDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace cache default response +func (o *ReplaceCacheDefault) WithConfigurationVersion(configurationVersion string) *ReplaceCacheDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace cache default response +func (o *ReplaceCacheDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace cache default response +func (o *ReplaceCacheDefault) WithPayload(payload *models.Error) *ReplaceCacheDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace cache default response +func (o *ReplaceCacheDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCacheDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cache/replace_cache_urlbuilder.go b/operations/cache/replace_cache_urlbuilder.go new file mode 100644 index 00000000..6de5bf8a --- /dev/null +++ b/operations/cache/replace_cache_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cache + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceCacheURL generates an URL for the replace cache operation +type ReplaceCacheURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCacheURL) WithBasePath(bp string) *ReplaceCacheURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCacheURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceCacheURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/caches/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceCacheURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceCacheURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceCacheURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceCacheURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceCacheURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceCacheURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceCacheURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cluster/delete_cluster.go b/operations/cluster/delete_cluster.go new file mode 100644 index 00000000..aa3555d0 --- /dev/null +++ b/operations/cluster/delete_cluster.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteClusterHandlerFunc turns a function with the right signature into a delete cluster handler +type DeleteClusterHandlerFunc func(DeleteClusterParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteClusterHandlerFunc) Handle(params DeleteClusterParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteClusterHandler interface for that can handle valid delete cluster params +type DeleteClusterHandler interface { + Handle(DeleteClusterParams, interface{}) middleware.Responder +} + +// NewDeleteCluster creates a new http.Handler for the delete cluster operation +func NewDeleteCluster(ctx *middleware.Context, handler DeleteClusterHandler) *DeleteCluster { + return &DeleteCluster{Context: ctx, Handler: handler} +} + +/* + DeleteCluster swagger:route DELETE /cluster Cluster deleteCluster + +# Delete cluster settings + +Delete cluster settings and move the node back to single mode +*/ +type DeleteCluster struct { + Context *middleware.Context + Handler DeleteClusterHandler +} + +func (o *DeleteCluster) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteClusterParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cluster/delete_cluster_parameters.go b/operations/cluster/delete_cluster_parameters.go new file mode 100644 index 00000000..cad01e6d --- /dev/null +++ b/operations/cluster/delete_cluster_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteClusterParams creates a new DeleteClusterParams object +// +// There are no default values defined in the spec. +func NewDeleteClusterParams() DeleteClusterParams { + + return DeleteClusterParams{} +} + +// DeleteClusterParams contains all the bound params for the delete cluster operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCluster +type DeleteClusterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*In case of moving to single mode do we keep or clean configuration + In: query + */ + Configuration *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteClusterParams() beforehand. +func (o *DeleteClusterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qConfiguration, qhkConfiguration, _ := qs.GetOK("configuration") + if err := o.bindConfiguration(qConfiguration, qhkConfiguration, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindConfiguration binds and validates parameter Configuration from query. +func (o *DeleteClusterParams) bindConfiguration(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Configuration = &raw + + if err := o.validateConfiguration(formats); err != nil { + return err + } + + return nil +} + +// validateConfiguration carries on validations for parameter Configuration +func (o *DeleteClusterParams) validateConfiguration(formats strfmt.Registry) error { + + if err := validate.EnumCase("configuration", "query", *o.Configuration, []interface{}{"keep"}, true); err != nil { + return err + } + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteClusterParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/cluster/delete_cluster_responses.go b/operations/cluster/delete_cluster_responses.go new file mode 100644 index 00000000..582a1afc --- /dev/null +++ b/operations/cluster/delete_cluster_responses.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteClusterNoContentCode is the HTTP code returned for type DeleteClusterNoContent +const DeleteClusterNoContentCode int = 204 + +/* +DeleteClusterNoContent Cluster settings deleted and node moved to single mode + +swagger:response deleteClusterNoContent +*/ +type DeleteClusterNoContent struct { +} + +// NewDeleteClusterNoContent creates DeleteClusterNoContent with default headers values +func NewDeleteClusterNoContent() *DeleteClusterNoContent { + + return &DeleteClusterNoContent{} +} + +// WriteResponse to the client +func (o *DeleteClusterNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +/* +DeleteClusterDefault General Error + +swagger:response deleteClusterDefault +*/ +type DeleteClusterDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteClusterDefault creates DeleteClusterDefault with default headers values +func NewDeleteClusterDefault(code int) *DeleteClusterDefault { + if code <= 0 { + code = 500 + } + + return &DeleteClusterDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete cluster default response +func (o *DeleteClusterDefault) WithStatusCode(code int) *DeleteClusterDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete cluster default response +func (o *DeleteClusterDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete cluster default response +func (o *DeleteClusterDefault) WithConfigurationVersion(configurationVersion string) *DeleteClusterDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete cluster default response +func (o *DeleteClusterDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete cluster default response +func (o *DeleteClusterDefault) WithPayload(payload *models.Error) *DeleteClusterDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete cluster default response +func (o *DeleteClusterDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteClusterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cluster/delete_cluster_urlbuilder.go b/operations/cluster/delete_cluster_urlbuilder.go new file mode 100644 index 00000000..6294af0a --- /dev/null +++ b/operations/cluster/delete_cluster_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// DeleteClusterURL generates an URL for the delete cluster operation +type DeleteClusterURL struct { + Configuration *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteClusterURL) WithBasePath(bp string) *DeleteClusterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteClusterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteClusterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/cluster" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var configurationQ string + if o.Configuration != nil { + configurationQ = *o.Configuration + } + if configurationQ != "" { + qs.Set("configuration", configurationQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteClusterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteClusterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteClusterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteClusterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteClusterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteClusterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cluster/edit_cluster.go b/operations/cluster/edit_cluster.go new file mode 100644 index 00000000..a5a79cfa --- /dev/null +++ b/operations/cluster/edit_cluster.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// EditClusterHandlerFunc turns a function with the right signature into a edit cluster handler +type EditClusterHandlerFunc func(EditClusterParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn EditClusterHandlerFunc) Handle(params EditClusterParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// EditClusterHandler interface for that can handle valid edit cluster params +type EditClusterHandler interface { + Handle(EditClusterParams, interface{}) middleware.Responder +} + +// NewEditCluster creates a new http.Handler for the edit cluster operation +func NewEditCluster(ctx *middleware.Context, handler EditClusterHandler) *EditCluster { + return &EditCluster{Context: ctx, Handler: handler} +} + +/* + EditCluster swagger:route PUT /cluster Cluster editCluster + +# Edit cluster settings + +Edit cluster settings +*/ +type EditCluster struct { + Context *middleware.Context + Handler EditClusterHandler +} + +func (o *EditCluster) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewEditClusterParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cluster/edit_cluster_parameters.go b/operations/cluster/edit_cluster_parameters.go new file mode 100644 index 00000000..28a96c8f --- /dev/null +++ b/operations/cluster/edit_cluster_parameters.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewEditClusterParams creates a new EditClusterParams object +// +// There are no default values defined in the spec. +func NewEditClusterParams() EditClusterParams { + + return EditClusterParams{} +} + +// EditClusterParams contains all the bound params for the edit cluster operation +// typically these are obtained from a http.Request +// +// swagger:parameters editCluster +type EditClusterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ClusterSettings + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewEditClusterParams() beforehand. +func (o *EditClusterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ClusterSettings + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *EditClusterParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/cluster/edit_cluster_responses.go b/operations/cluster/edit_cluster_responses.go new file mode 100644 index 00000000..9d370c0c --- /dev/null +++ b/operations/cluster/edit_cluster_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// EditClusterOKCode is the HTTP code returned for type EditClusterOK +const EditClusterOKCode int = 200 + +/* +EditClusterOK Cluster settings changed + +swagger:response editClusterOK +*/ +type EditClusterOK struct { + + /* + In: Body + */ + Payload *models.ClusterSettings `json:"body,omitempty"` +} + +// NewEditClusterOK creates EditClusterOK with default headers values +func NewEditClusterOK() *EditClusterOK { + + return &EditClusterOK{} +} + +// WithPayload adds the payload to the edit cluster o k response +func (o *EditClusterOK) WithPayload(payload *models.ClusterSettings) *EditClusterOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit cluster o k response +func (o *EditClusterOK) SetPayload(payload *models.ClusterSettings) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditClusterBadRequestCode is the HTTP code returned for type EditClusterBadRequest +const EditClusterBadRequestCode int = 400 + +/* +EditClusterBadRequest Bad request + +swagger:response editClusterBadRequest +*/ +type EditClusterBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditClusterBadRequest creates EditClusterBadRequest with default headers values +func NewEditClusterBadRequest() *EditClusterBadRequest { + + return &EditClusterBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit cluster bad request response +func (o *EditClusterBadRequest) WithConfigurationVersion(configurationVersion string) *EditClusterBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit cluster bad request response +func (o *EditClusterBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit cluster bad request response +func (o *EditClusterBadRequest) WithPayload(payload *models.Error) *EditClusterBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit cluster bad request response +func (o *EditClusterBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditClusterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +EditClusterDefault General Error + +swagger:response editClusterDefault +*/ +type EditClusterDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditClusterDefault creates EditClusterDefault with default headers values +func NewEditClusterDefault(code int) *EditClusterDefault { + if code <= 0 { + code = 500 + } + + return &EditClusterDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the edit cluster default response +func (o *EditClusterDefault) WithStatusCode(code int) *EditClusterDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the edit cluster default response +func (o *EditClusterDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the edit cluster default response +func (o *EditClusterDefault) WithConfigurationVersion(configurationVersion string) *EditClusterDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit cluster default response +func (o *EditClusterDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit cluster default response +func (o *EditClusterDefault) WithPayload(payload *models.Error) *EditClusterDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit cluster default response +func (o *EditClusterDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditClusterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cluster/edit_cluster_urlbuilder.go b/operations/cluster/edit_cluster_urlbuilder.go new file mode 100644 index 00000000..b85f0ccd --- /dev/null +++ b/operations/cluster/edit_cluster_urlbuilder.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// EditClusterURL generates an URL for the edit cluster operation +type EditClusterURL struct { + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditClusterURL) WithBasePath(bp string) *EditClusterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditClusterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *EditClusterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/cluster" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *EditClusterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *EditClusterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *EditClusterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on EditClusterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on EditClusterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *EditClusterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cluster/get_cluster.go b/operations/cluster/get_cluster.go new file mode 100644 index 00000000..a4f492c5 --- /dev/null +++ b/operations/cluster/get_cluster.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetClusterHandlerFunc turns a function with the right signature into a get cluster handler +type GetClusterHandlerFunc func(GetClusterParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetClusterHandlerFunc) Handle(params GetClusterParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetClusterHandler interface for that can handle valid get cluster params +type GetClusterHandler interface { + Handle(GetClusterParams, interface{}) middleware.Responder +} + +// NewGetCluster creates a new http.Handler for the get cluster operation +func NewGetCluster(ctx *middleware.Context, handler GetClusterHandler) *GetCluster { + return &GetCluster{Context: ctx, Handler: handler} +} + +/* + GetCluster swagger:route GET /cluster Cluster getCluster + +# Return cluster data + +Returns cluster data +*/ +type GetCluster struct { + Context *middleware.Context + Handler GetClusterHandler +} + +func (o *GetCluster) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetClusterParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cluster/get_cluster_parameters.go b/operations/cluster/get_cluster_parameters.go new file mode 100644 index 00000000..23140d85 --- /dev/null +++ b/operations/cluster/get_cluster_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetClusterParams creates a new GetClusterParams object +// +// There are no default values defined in the spec. +func NewGetClusterParams() GetClusterParams { + + return GetClusterParams{} +} + +// GetClusterParams contains all the bound params for the get cluster operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCluster +type GetClusterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetClusterParams() beforehand. +func (o *GetClusterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/cluster/get_cluster_responses.go b/operations/cluster/get_cluster_responses.go new file mode 100644 index 00000000..53ec66e0 --- /dev/null +++ b/operations/cluster/get_cluster_responses.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetClusterOKCode is the HTTP code returned for type GetClusterOK +const GetClusterOKCode int = 200 + +/* +GetClusterOK Success + +swagger:response getClusterOK +*/ +type GetClusterOK struct { + + /* + In: Body + */ + Payload *models.ClusterSettings `json:"body,omitempty"` +} + +// NewGetClusterOK creates GetClusterOK with default headers values +func NewGetClusterOK() *GetClusterOK { + + return &GetClusterOK{} +} + +// WithPayload adds the payload to the get cluster o k response +func (o *GetClusterOK) WithPayload(payload *models.ClusterSettings) *GetClusterOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cluster o k response +func (o *GetClusterOK) SetPayload(payload *models.ClusterSettings) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetClusterDefault General Error + +swagger:response getClusterDefault +*/ +type GetClusterDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetClusterDefault creates GetClusterDefault with default headers values +func NewGetClusterDefault(code int) *GetClusterDefault { + if code <= 0 { + code = 500 + } + + return &GetClusterDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get cluster default response +func (o *GetClusterDefault) WithStatusCode(code int) *GetClusterDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get cluster default response +func (o *GetClusterDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get cluster default response +func (o *GetClusterDefault) WithConfigurationVersion(configurationVersion string) *GetClusterDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get cluster default response +func (o *GetClusterDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get cluster default response +func (o *GetClusterDefault) WithPayload(payload *models.Error) *GetClusterDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cluster default response +func (o *GetClusterDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetClusterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cluster/get_cluster_urlbuilder.go b/operations/cluster/get_cluster_urlbuilder.go new file mode 100644 index 00000000..4a708003 --- /dev/null +++ b/operations/cluster/get_cluster_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetClusterURL generates an URL for the get cluster operation +type GetClusterURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetClusterURL) WithBasePath(bp string) *GetClusterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetClusterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetClusterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/cluster" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetClusterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetClusterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetClusterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetClusterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetClusterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetClusterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cluster/initiate_certificate_refresh.go b/operations/cluster/initiate_certificate_refresh.go new file mode 100644 index 00000000..316e0385 --- /dev/null +++ b/operations/cluster/initiate_certificate_refresh.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// InitiateCertificateRefreshHandlerFunc turns a function with the right signature into a initiate certificate refresh handler +type InitiateCertificateRefreshHandlerFunc func(InitiateCertificateRefreshParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn InitiateCertificateRefreshHandlerFunc) Handle(params InitiateCertificateRefreshParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// InitiateCertificateRefreshHandler interface for that can handle valid initiate certificate refresh params +type InitiateCertificateRefreshHandler interface { + Handle(InitiateCertificateRefreshParams, interface{}) middleware.Responder +} + +// NewInitiateCertificateRefresh creates a new http.Handler for the initiate certificate refresh operation +func NewInitiateCertificateRefresh(ctx *middleware.Context, handler InitiateCertificateRefreshHandler) *InitiateCertificateRefresh { + return &InitiateCertificateRefresh{Context: ctx, Handler: handler} +} + +/* + InitiateCertificateRefresh swagger:route POST /cluster/certificate Cluster initiateCertificateRefresh + +# Initiates a certificate refresh + +Initiates a certificate refresh +*/ +type InitiateCertificateRefresh struct { + Context *middleware.Context + Handler InitiateCertificateRefreshHandler +} + +func (o *InitiateCertificateRefresh) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewInitiateCertificateRefreshParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cluster/initiate_certificate_refresh_parameters.go b/operations/cluster/initiate_certificate_refresh_parameters.go new file mode 100644 index 00000000..56ce3dfd --- /dev/null +++ b/operations/cluster/initiate_certificate_refresh_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewInitiateCertificateRefreshParams creates a new InitiateCertificateRefreshParams object +// +// There are no default values defined in the spec. +func NewInitiateCertificateRefreshParams() InitiateCertificateRefreshParams { + + return InitiateCertificateRefreshParams{} +} + +// InitiateCertificateRefreshParams contains all the bound params for the initiate certificate refresh operation +// typically these are obtained from a http.Request +// +// swagger:parameters initiateCertificateRefresh +type InitiateCertificateRefreshParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewInitiateCertificateRefreshParams() beforehand. +func (o *InitiateCertificateRefreshParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/cluster/initiate_certificate_refresh_responses.go b/operations/cluster/initiate_certificate_refresh_responses.go new file mode 100644 index 00000000..28d92fae --- /dev/null +++ b/operations/cluster/initiate_certificate_refresh_responses.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// InitiateCertificateRefreshOKCode is the HTTP code returned for type InitiateCertificateRefreshOK +const InitiateCertificateRefreshOKCode int = 200 + +/* +InitiateCertificateRefreshOK refresh activated + +swagger:response initiateCertificateRefreshOK +*/ +type InitiateCertificateRefreshOK struct { +} + +// NewInitiateCertificateRefreshOK creates InitiateCertificateRefreshOK with default headers values +func NewInitiateCertificateRefreshOK() *InitiateCertificateRefreshOK { + + return &InitiateCertificateRefreshOK{} +} + +// WriteResponse to the client +func (o *InitiateCertificateRefreshOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// InitiateCertificateRefreshForbiddenCode is the HTTP code returned for type InitiateCertificateRefreshForbidden +const InitiateCertificateRefreshForbiddenCode int = 403 + +/* +InitiateCertificateRefreshForbidden refresh not possible + +swagger:response initiateCertificateRefreshForbidden +*/ +type InitiateCertificateRefreshForbidden struct { +} + +// NewInitiateCertificateRefreshForbidden creates InitiateCertificateRefreshForbidden with default headers values +func NewInitiateCertificateRefreshForbidden() *InitiateCertificateRefreshForbidden { + + return &InitiateCertificateRefreshForbidden{} +} + +// WriteResponse to the client +func (o *InitiateCertificateRefreshForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(403) +} + +/* +InitiateCertificateRefreshDefault General Error + +swagger:response initiateCertificateRefreshDefault +*/ +type InitiateCertificateRefreshDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewInitiateCertificateRefreshDefault creates InitiateCertificateRefreshDefault with default headers values +func NewInitiateCertificateRefreshDefault(code int) *InitiateCertificateRefreshDefault { + if code <= 0 { + code = 500 + } + + return &InitiateCertificateRefreshDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the initiate certificate refresh default response +func (o *InitiateCertificateRefreshDefault) WithStatusCode(code int) *InitiateCertificateRefreshDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the initiate certificate refresh default response +func (o *InitiateCertificateRefreshDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the initiate certificate refresh default response +func (o *InitiateCertificateRefreshDefault) WithConfigurationVersion(configurationVersion string) *InitiateCertificateRefreshDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the initiate certificate refresh default response +func (o *InitiateCertificateRefreshDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the initiate certificate refresh default response +func (o *InitiateCertificateRefreshDefault) WithPayload(payload *models.Error) *InitiateCertificateRefreshDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the initiate certificate refresh default response +func (o *InitiateCertificateRefreshDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *InitiateCertificateRefreshDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cluster/initiate_certificate_refresh_urlbuilder.go b/operations/cluster/initiate_certificate_refresh_urlbuilder.go new file mode 100644 index 00000000..93abeec9 --- /dev/null +++ b/operations/cluster/initiate_certificate_refresh_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// InitiateCertificateRefreshURL generates an URL for the initiate certificate refresh operation +type InitiateCertificateRefreshURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *InitiateCertificateRefreshURL) WithBasePath(bp string) *InitiateCertificateRefreshURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *InitiateCertificateRefreshURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *InitiateCertificateRefreshURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/cluster/certificate" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *InitiateCertificateRefreshURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *InitiateCertificateRefreshURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *InitiateCertificateRefreshURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on InitiateCertificateRefreshURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on InitiateCertificateRefreshURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *InitiateCertificateRefreshURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/cluster/post_cluster.go b/operations/cluster/post_cluster.go new file mode 100644 index 00000000..0bb5ec91 --- /dev/null +++ b/operations/cluster/post_cluster.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// PostClusterHandlerFunc turns a function with the right signature into a post cluster handler +type PostClusterHandlerFunc func(PostClusterParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostClusterHandlerFunc) Handle(params PostClusterParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// PostClusterHandler interface for that can handle valid post cluster params +type PostClusterHandler interface { + Handle(PostClusterParams, interface{}) middleware.Responder +} + +// NewPostCluster creates a new http.Handler for the post cluster operation +func NewPostCluster(ctx *middleware.Context, handler PostClusterHandler) *PostCluster { + return &PostCluster{Context: ctx, Handler: handler} +} + +/* + PostCluster swagger:route POST /cluster Cluster postCluster + +# Post cluster settings + +Post cluster settings +*/ +type PostCluster struct { + Context *middleware.Context + Handler PostClusterHandler +} + +func (o *PostCluster) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostClusterParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/cluster/post_cluster_parameters.go b/operations/cluster/post_cluster_parameters.go new file mode 100644 index 00000000..c52b7c8f --- /dev/null +++ b/operations/cluster/post_cluster_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewPostClusterParams creates a new PostClusterParams object +// +// There are no default values defined in the spec. +func NewPostClusterParams() PostClusterParams { + + return PostClusterParams{} +} + +// PostClusterParams contains all the bound params for the post cluster operation +// typically these are obtained from a http.Request +// +// swagger:parameters postCluster +type PostClusterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Force the advertised address when joining a cluster + In: query + */ + AdvertisedAddress *string + /*Force the advertised port when joining a cluster + Maximum: 65535 + Minimum: 1 + In: query + */ + AdvertisedPort *int64 + /*In case of moving to single mode do we keep or clean configuration + In: query + */ + Configuration *string + /* + Required: true + In: body + */ + Data *models.ClusterSettings + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostClusterParams() beforehand. +func (o *PostClusterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qAdvertisedAddress, qhkAdvertisedAddress, _ := qs.GetOK("advertised_address") + if err := o.bindAdvertisedAddress(qAdvertisedAddress, qhkAdvertisedAddress, route.Formats); err != nil { + res = append(res, err) + } + + qAdvertisedPort, qhkAdvertisedPort, _ := qs.GetOK("advertised_port") + if err := o.bindAdvertisedPort(qAdvertisedPort, qhkAdvertisedPort, route.Formats); err != nil { + res = append(res, err) + } + + qConfiguration, qhkConfiguration, _ := qs.GetOK("configuration") + if err := o.bindConfiguration(qConfiguration, qhkConfiguration, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ClusterSettings + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindAdvertisedAddress binds and validates parameter AdvertisedAddress from query. +func (o *PostClusterParams) bindAdvertisedAddress(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.AdvertisedAddress = &raw + + return nil +} + +// bindAdvertisedPort binds and validates parameter AdvertisedPort from query. +func (o *PostClusterParams) bindAdvertisedPort(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("advertised_port", "query", "int64", raw) + } + o.AdvertisedPort = &value + + if err := o.validateAdvertisedPort(formats); err != nil { + return err + } + + return nil +} + +// validateAdvertisedPort carries on validations for parameter AdvertisedPort +func (o *PostClusterParams) validateAdvertisedPort(formats strfmt.Registry) error { + + if err := validate.MinimumInt("advertised_port", "query", *o.AdvertisedPort, 1, false); err != nil { + return err + } + + if err := validate.MaximumInt("advertised_port", "query", *o.AdvertisedPort, 65535, false); err != nil { + return err + } + + return nil +} + +// bindConfiguration binds and validates parameter Configuration from query. +func (o *PostClusterParams) bindConfiguration(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Configuration = &raw + + if err := o.validateConfiguration(formats); err != nil { + return err + } + + return nil +} + +// validateConfiguration carries on validations for parameter Configuration +func (o *PostClusterParams) validateConfiguration(formats strfmt.Registry) error { + + if err := validate.EnumCase("configuration", "query", *o.Configuration, []interface{}{"keep"}, true); err != nil { + return err + } + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *PostClusterParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/cluster/post_cluster_responses.go b/operations/cluster/post_cluster_responses.go new file mode 100644 index 00000000..0edf170e --- /dev/null +++ b/operations/cluster/post_cluster_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// PostClusterOKCode is the HTTP code returned for type PostClusterOK +const PostClusterOKCode int = 200 + +/* +PostClusterOK Cluster settings changed + +swagger:response postClusterOK +*/ +type PostClusterOK struct { + + /* + In: Body + */ + Payload *models.ClusterSettings `json:"body,omitempty"` +} + +// NewPostClusterOK creates PostClusterOK with default headers values +func NewPostClusterOK() *PostClusterOK { + + return &PostClusterOK{} +} + +// WithPayload adds the payload to the post cluster o k response +func (o *PostClusterOK) WithPayload(payload *models.ClusterSettings) *PostClusterOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post cluster o k response +func (o *PostClusterOK) SetPayload(payload *models.ClusterSettings) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostClusterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostClusterBadRequestCode is the HTTP code returned for type PostClusterBadRequest +const PostClusterBadRequestCode int = 400 + +/* +PostClusterBadRequest Bad request + +swagger:response postClusterBadRequest +*/ +type PostClusterBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostClusterBadRequest creates PostClusterBadRequest with default headers values +func NewPostClusterBadRequest() *PostClusterBadRequest { + + return &PostClusterBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the post cluster bad request response +func (o *PostClusterBadRequest) WithConfigurationVersion(configurationVersion string) *PostClusterBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the post cluster bad request response +func (o *PostClusterBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the post cluster bad request response +func (o *PostClusterBadRequest) WithPayload(payload *models.Error) *PostClusterBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post cluster bad request response +func (o *PostClusterBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostClusterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +PostClusterDefault General Error + +swagger:response postClusterDefault +*/ +type PostClusterDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostClusterDefault creates PostClusterDefault with default headers values +func NewPostClusterDefault(code int) *PostClusterDefault { + if code <= 0 { + code = 500 + } + + return &PostClusterDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the post cluster default response +func (o *PostClusterDefault) WithStatusCode(code int) *PostClusterDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the post cluster default response +func (o *PostClusterDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the post cluster default response +func (o *PostClusterDefault) WithConfigurationVersion(configurationVersion string) *PostClusterDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the post cluster default response +func (o *PostClusterDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the post cluster default response +func (o *PostClusterDefault) WithPayload(payload *models.Error) *PostClusterDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post cluster default response +func (o *PostClusterDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostClusterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/cluster/post_cluster_urlbuilder.go b/operations/cluster/post_cluster_urlbuilder.go new file mode 100644 index 00000000..004b0450 --- /dev/null +++ b/operations/cluster/post_cluster_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package cluster + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// PostClusterURL generates an URL for the post cluster operation +type PostClusterURL struct { + AdvertisedAddress *string + AdvertisedPort *int64 + Configuration *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostClusterURL) WithBasePath(bp string) *PostClusterURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostClusterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostClusterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/cluster" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var advertisedAddressQ string + if o.AdvertisedAddress != nil { + advertisedAddressQ = *o.AdvertisedAddress + } + if advertisedAddressQ != "" { + qs.Set("advertised_address", advertisedAddressQ) + } + + var advertisedPortQ string + if o.AdvertisedPort != nil { + advertisedPortQ = swag.FormatInt64(*o.AdvertisedPort) + } + if advertisedPortQ != "" { + qs.Set("advertised_port", advertisedPortQ) + } + + var configurationQ string + if o.Configuration != nil { + configurationQ = *o.Configuration + } + if configurationQ != "" { + qs.Set("configuration", configurationQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostClusterURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *PostClusterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostClusterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostClusterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostClusterURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *PostClusterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/configuration/get_configuration_version.go b/operations/configuration/get_configuration_version.go new file mode 100644 index 00000000..8b4348e8 --- /dev/null +++ b/operations/configuration/get_configuration_version.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetConfigurationVersionHandlerFunc turns a function with the right signature into a get configuration version handler +type GetConfigurationVersionHandlerFunc func(GetConfigurationVersionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetConfigurationVersionHandlerFunc) Handle(params GetConfigurationVersionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetConfigurationVersionHandler interface for that can handle valid get configuration version params +type GetConfigurationVersionHandler interface { + Handle(GetConfigurationVersionParams, interface{}) middleware.Responder +} + +// NewGetConfigurationVersion creates a new http.Handler for the get configuration version operation +func NewGetConfigurationVersion(ctx *middleware.Context, handler GetConfigurationVersionHandler) *GetConfigurationVersion { + return &GetConfigurationVersion{Context: ctx, Handler: handler} +} + +/* + GetConfigurationVersion swagger:route GET /services/haproxy/configuration/version Configuration getConfigurationVersion + +# Return a configuration version + +Returns configuration version. +*/ +type GetConfigurationVersion struct { + Context *middleware.Context + Handler GetConfigurationVersionHandler +} + +func (o *GetConfigurationVersion) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetConfigurationVersionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/configuration/get_configuration_version_parameters.go b/operations/configuration/get_configuration_version_parameters.go new file mode 100644 index 00000000..a4204ba1 --- /dev/null +++ b/operations/configuration/get_configuration_version_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetConfigurationVersionParams creates a new GetConfigurationVersionParams object +// +// There are no default values defined in the spec. +func NewGetConfigurationVersionParams() GetConfigurationVersionParams { + + return GetConfigurationVersionParams{} +} + +// GetConfigurationVersionParams contains all the bound params for the get configuration version operation +// typically these are obtained from a http.Request +// +// swagger:parameters getConfigurationVersion +type GetConfigurationVersionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetConfigurationVersionParams() beforehand. +func (o *GetConfigurationVersionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetConfigurationVersionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/configuration/get_configuration_version_responses.go b/operations/configuration/get_configuration_version_responses.go new file mode 100644 index 00000000..6e9725b7 --- /dev/null +++ b/operations/configuration/get_configuration_version_responses.go @@ -0,0 +1,220 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetConfigurationVersionOKCode is the HTTP code returned for type GetConfigurationVersionOK +const GetConfigurationVersionOKCode int = 200 + +/* +GetConfigurationVersionOK Configuration version + +swagger:response getConfigurationVersionOK +*/ +type GetConfigurationVersionOK struct { + + /* + In: Body + */ + Payload int64 `json:"body,omitempty"` +} + +// NewGetConfigurationVersionOK creates GetConfigurationVersionOK with default headers values +func NewGetConfigurationVersionOK() *GetConfigurationVersionOK { + + return &GetConfigurationVersionOK{} +} + +// WithPayload adds the payload to the get configuration version o k response +func (o *GetConfigurationVersionOK) WithPayload(payload int64) *GetConfigurationVersionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get configuration version o k response +func (o *GetConfigurationVersionOK) SetPayload(payload int64) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigurationVersionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetConfigurationVersionNotFoundCode is the HTTP code returned for type GetConfigurationVersionNotFound +const GetConfigurationVersionNotFoundCode int = 404 + +/* +GetConfigurationVersionNotFound The specified resource was not found + +swagger:response getConfigurationVersionNotFound +*/ +type GetConfigurationVersionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigurationVersionNotFound creates GetConfigurationVersionNotFound with default headers values +func NewGetConfigurationVersionNotFound() *GetConfigurationVersionNotFound { + + return &GetConfigurationVersionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get configuration version not found response +func (o *GetConfigurationVersionNotFound) WithConfigurationVersion(configurationVersion string) *GetConfigurationVersionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get configuration version not found response +func (o *GetConfigurationVersionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get configuration version not found response +func (o *GetConfigurationVersionNotFound) WithPayload(payload *models.Error) *GetConfigurationVersionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get configuration version not found response +func (o *GetConfigurationVersionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigurationVersionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetConfigurationVersionDefault General Error + +swagger:response getConfigurationVersionDefault +*/ +type GetConfigurationVersionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigurationVersionDefault creates GetConfigurationVersionDefault with default headers values +func NewGetConfigurationVersionDefault(code int) *GetConfigurationVersionDefault { + if code <= 0 { + code = 500 + } + + return &GetConfigurationVersionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get configuration version default response +func (o *GetConfigurationVersionDefault) WithStatusCode(code int) *GetConfigurationVersionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get configuration version default response +func (o *GetConfigurationVersionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get configuration version default response +func (o *GetConfigurationVersionDefault) WithConfigurationVersion(configurationVersion string) *GetConfigurationVersionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get configuration version default response +func (o *GetConfigurationVersionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get configuration version default response +func (o *GetConfigurationVersionDefault) WithPayload(payload *models.Error) *GetConfigurationVersionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get configuration version default response +func (o *GetConfigurationVersionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigurationVersionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/configuration/get_configuration_version_urlbuilder.go b/operations/configuration/get_configuration_version_urlbuilder.go new file mode 100644 index 00000000..a05251d9 --- /dev/null +++ b/operations/configuration/get_configuration_version_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package configuration + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetConfigurationVersionURL generates an URL for the get configuration version operation +type GetConfigurationVersionURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigurationVersionURL) WithBasePath(bp string) *GetConfigurationVersionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigurationVersionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetConfigurationVersionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/version" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetConfigurationVersionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetConfigurationVersionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetConfigurationVersionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetConfigurationVersionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetConfigurationVersionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetConfigurationVersionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/configuration/get_h_a_proxy_configuration.go b/operations/configuration/get_h_a_proxy_configuration.go index 5a7393a5..725e5fa1 100644 --- a/operations/configuration/get_h_a_proxy_configuration.go +++ b/operations/configuration/get_h_a_proxy_configuration.go @@ -23,11 +23,7 @@ package configuration import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" + "github.com/go-openapi/runtime/middleware" ) // GetHAProxyConfigurationHandlerFunc turns a function with the right signature into a get h a proxy configuration handler @@ -48,12 +44,12 @@ func NewGetHAProxyConfiguration(ctx *middleware.Context, handler GetHAProxyConfi return &GetHAProxyConfiguration{Context: ctx, Handler: handler} } -/*GetHAProxyConfiguration swagger:route GET /services/haproxy/configuration/raw Configuration getHAProxyConfiguration +/* + GetHAProxyConfiguration swagger:route GET /services/haproxy/configuration/raw Configuration getHAProxyConfiguration -Return HAProxy configuration +# Return HAProxy configuration Returns HAProxy configuration file in plain text - */ type GetHAProxyConfiguration struct { Context *middleware.Context @@ -63,21 +59,20 @@ type GetHAProxyConfiguration struct { func (o *GetHAProxyConfiguration) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetHAProxyConfigurationParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -86,60 +81,6 @@ func (o *GetHAProxyConfiguration) ServeHTTP(rw http.ResponseWriter, r *http.Requ } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetHAProxyConfigurationOKBody get h a proxy configuration o k body -// swagger:model GetHAProxyConfigurationOKBody -type GetHAProxyConfigurationOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data *string `json:"data"` -} - -// Validate validates this get h a proxy configuration o k body -func (o *GetHAProxyConfigurationOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetHAProxyConfigurationOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getHAProxyConfigurationOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetHAProxyConfigurationOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetHAProxyConfigurationOKBody) UnmarshalBinary(b []byte) error { - var res GetHAProxyConfigurationOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/configuration/get_h_a_proxy_configuration_parameters.go b/operations/configuration/get_h_a_proxy_configuration_parameters.go index 15a38c9c..aefe2843 100644 --- a/operations/configuration/get_h_a_proxy_configuration_parameters.go +++ b/operations/configuration/get_h_a_proxy_configuration_parameters.go @@ -26,13 +26,13 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) // NewGetHAProxyConfigurationParams creates a new GetHAProxyConfigurationParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetHAProxyConfigurationParams() GetHAProxyConfigurationParams { return GetHAProxyConfigurationParams{} @@ -77,7 +77,6 @@ func (o *GetHAProxyConfigurationParams) BindRequest(r *http.Request, route *midd if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -93,10 +92,10 @@ func (o *GetHAProxyConfigurationParams) bindTransactionID(rawData []string, hasK // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -111,6 +110,7 @@ func (o *GetHAProxyConfigurationParams) bindVersion(rawData []string, hasKey boo // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/configuration/get_h_a_proxy_configuration_responses.go b/operations/configuration/get_h_a_proxy_configuration_responses.go index 3e604f8b..afc4fad5 100644 --- a/operations/configuration/get_h_a_proxy_configuration_responses.go +++ b/operations/configuration/get_h_a_proxy_configuration_responses.go @@ -24,28 +24,34 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" ) // GetHAProxyConfigurationOKCode is the HTTP code returned for type GetHAProxyConfigurationOK const GetHAProxyConfigurationOKCode int = 200 -/*GetHAProxyConfigurationOK Operation successful +/* +GetHAProxyConfigurationOK Operation successful swagger:response getHAProxyConfigurationOK */ type GetHAProxyConfigurationOK struct { + /*Cluster configuration version + + */ + ClusterVersion string `json:"Cluster-Version"` + /*Configuration file md5 checksum + + */ + ConfigurationChecksum string `json:"Configuration-Checksum"` /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetHAProxyConfigurationOKBody `json:"body,omitempty"` + Payload string `json:"body,omitempty"` } // NewGetHAProxyConfigurationOK creates GetHAProxyConfigurationOK with default headers values @@ -54,48 +60,83 @@ func NewGetHAProxyConfigurationOK() *GetHAProxyConfigurationOK { return &GetHAProxyConfigurationOK{} } +// WithClusterVersion adds the clusterVersion to the get h a proxy configuration o k response +func (o *GetHAProxyConfigurationOK) WithClusterVersion(clusterVersion string) *GetHAProxyConfigurationOK { + o.ClusterVersion = clusterVersion + return o +} + +// SetClusterVersion sets the clusterVersion to the get h a proxy configuration o k response +func (o *GetHAProxyConfigurationOK) SetClusterVersion(clusterVersion string) { + o.ClusterVersion = clusterVersion +} + +// WithConfigurationChecksum adds the configurationChecksum to the get h a proxy configuration o k response +func (o *GetHAProxyConfigurationOK) WithConfigurationChecksum(configurationChecksum string) *GetHAProxyConfigurationOK { + o.ConfigurationChecksum = configurationChecksum + return o +} + +// SetConfigurationChecksum sets the configurationChecksum to the get h a proxy configuration o k response +func (o *GetHAProxyConfigurationOK) SetConfigurationChecksum(configurationChecksum string) { + o.ConfigurationChecksum = configurationChecksum +} + // WithConfigurationVersion adds the configurationVersion to the get h a proxy configuration o k response -func (o *GetHAProxyConfigurationOK) WithConfigurationVersion(configurationVersion int64) *GetHAProxyConfigurationOK { +func (o *GetHAProxyConfigurationOK) WithConfigurationVersion(configurationVersion string) *GetHAProxyConfigurationOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get h a proxy configuration o k response -func (o *GetHAProxyConfigurationOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetHAProxyConfigurationOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get h a proxy configuration o k response -func (o *GetHAProxyConfigurationOK) WithPayload(payload *GetHAProxyConfigurationOKBody) *GetHAProxyConfigurationOK { +func (o *GetHAProxyConfigurationOK) WithPayload(payload string) *GetHAProxyConfigurationOK { o.Payload = payload return o } // SetPayload sets the payload to the get h a proxy configuration o k response -func (o *GetHAProxyConfigurationOK) SetPayload(payload *GetHAProxyConfigurationOKBody) { +func (o *GetHAProxyConfigurationOK) SetPayload(payload string) { o.Payload = payload } // WriteResponse to the client func (o *GetHAProxyConfigurationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + // response header Cluster-Version + + clusterVersion := o.ClusterVersion + if clusterVersion != "" { + rw.Header().Set("Cluster-Version", clusterVersion) + } + + // response header Configuration-Checksum + + configurationChecksum := o.ConfigurationChecksum + if configurationChecksum != "" { + rw.Header().Set("Configuration-Checksum", configurationChecksum) + } + // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*GetHAProxyConfigurationDefault General Error +/* +GetHAProxyConfigurationDefault General Error swagger:response getHAProxyConfigurationDefault */ @@ -104,12 +145,12 @@ type GetHAProxyConfigurationDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *models.Error `json:"body,omitempty"` + Payload string `json:"body,omitempty"` } // NewGetHAProxyConfigurationDefault creates GetHAProxyConfigurationDefault with default headers values @@ -135,24 +176,24 @@ func (o *GetHAProxyConfigurationDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get h a proxy configuration default response -func (o *GetHAProxyConfigurationDefault) WithConfigurationVersion(configurationVersion int64) *GetHAProxyConfigurationDefault { +func (o *GetHAProxyConfigurationDefault) WithConfigurationVersion(configurationVersion string) *GetHAProxyConfigurationDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get h a proxy configuration default response -func (o *GetHAProxyConfigurationDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetHAProxyConfigurationDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get h a proxy configuration default response -func (o *GetHAProxyConfigurationDefault) WithPayload(payload *models.Error) *GetHAProxyConfigurationDefault { +func (o *GetHAProxyConfigurationDefault) WithPayload(payload string) *GetHAProxyConfigurationDefault { o.Payload = payload return o } // SetPayload sets the payload to the get h a proxy configuration default response -func (o *GetHAProxyConfigurationDefault) SetPayload(payload *models.Error) { +func (o *GetHAProxyConfigurationDefault) SetPayload(payload string) { o.Payload = payload } @@ -161,16 +202,14 @@ func (o *GetHAProxyConfigurationDefault) WriteResponse(rw http.ResponseWriter, p // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } diff --git a/operations/configuration/get_h_a_proxy_configuration_urlbuilder.go b/operations/configuration/get_h_a_proxy_configuration_urlbuilder.go index 94f54e35..bdb7fa95 100644 --- a/operations/configuration/get_h_a_proxy_configuration_urlbuilder.go +++ b/operations/configuration/get_h_a_proxy_configuration_urlbuilder.go @@ -61,26 +61,26 @@ func (o *GetHAProxyConfigurationURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/configuration/post_h_a_proxy_configuration.go b/operations/configuration/post_h_a_proxy_configuration.go index 7debd0a2..7e152972 100644 --- a/operations/configuration/post_h_a_proxy_configuration.go +++ b/operations/configuration/post_h_a_proxy_configuration.go @@ -23,7 +23,7 @@ package configuration import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // PostHAProxyConfigurationHandlerFunc turns a function with the right signature into a post h a proxy configuration handler @@ -44,12 +44,12 @@ func NewPostHAProxyConfiguration(ctx *middleware.Context, handler PostHAProxyCon return &PostHAProxyConfiguration{Context: ctx, Handler: handler} } -/*PostHAProxyConfiguration swagger:route POST /services/haproxy/configuration/raw Configuration postHAProxyConfiguration +/* + PostHAProxyConfiguration swagger:route POST /services/haproxy/configuration/raw Configuration postHAProxyConfiguration -Push new haproxy configuration +# Push new haproxy configuration Push a new haproxy configuration file in plain text - */ type PostHAProxyConfiguration struct { Context *middleware.Context @@ -59,21 +59,20 @@ type PostHAProxyConfiguration struct { func (o *PostHAProxyConfiguration) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewPostHAProxyConfigurationParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *PostHAProxyConfiguration) ServeHTTP(rw http.ResponseWriter, r *http.Req } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/configuration/post_h_a_proxy_configuration_parameters.go b/operations/configuration/post_h_a_proxy_configuration_parameters.go index e9085624..64eaef4b 100644 --- a/operations/configuration/post_h_a_proxy_configuration_parameters.go +++ b/operations/configuration/post_h_a_proxy_configuration_parameters.go @@ -27,9 +27,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) // NewPostHAProxyConfigurationParams creates a new PostHAProxyConfigurationParams object @@ -39,11 +38,20 @@ func NewPostHAProxyConfigurationParams() PostHAProxyConfigurationParams { var ( // initialize parameters with default values - forceReloadDefault = bool(false) + forceReloadDefault = bool(false) + onlyValidateDefault = bool(false) + skipReloadDefault = bool(false) + skipVersionDefault = bool(false) ) return PostHAProxyConfigurationParams{ ForceReload: &forceReloadDefault, + + OnlyValidate: &onlyValidateDefault, + + SkipReload: &skipReloadDefault, + + SkipVersion: &skipVersionDefault, } } @@ -56,6 +64,10 @@ type PostHAProxyConfigurationParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + /*List of Runtime API commands with parameters separated by ';' + In: header + */ + XRuntimeActions *string /* Required: true In: body @@ -66,6 +78,21 @@ type PostHAProxyConfigurationParams struct { Default: false */ ForceReload *bool + /*If set, only validates configuration, without applying it + In: query + Default: false + */ + OnlyValidate *bool + /*If set, no reload will be initiated and runtime actions from X-Runtime-Actions will be applied + In: query + Default: false + */ + SkipReload *bool + /*If set, no version check will be done and the pushed config will be enforced + In: query + Default: false + */ + SkipVersion *bool /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. In: query */ @@ -83,12 +110,16 @@ func (o *PostHAProxyConfigurationParams) BindRequest(r *http.Request, route *mid qs := runtime.Values(r.URL.Query()) + if err := o.bindXRuntimeActions(r.Header[http.CanonicalHeaderKey("X-Runtime-Actions")], true, route.Formats); err != nil { + res = append(res, err) + } + if runtime.HasBody(r) { defer r.Body.Close() var body string if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -97,24 +128,56 @@ func (o *PostHAProxyConfigurationParams) BindRequest(r *http.Request, route *mid o.Data = body } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + qOnlyValidate, qhkOnlyValidate, _ := qs.GetOK("only_validate") + if err := o.bindOnlyValidate(qOnlyValidate, qhkOnlyValidate, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + + qSkipVersion, qhkSkipVersion, _ := qs.GetOK("skip_version") + if err := o.bindSkipVersion(qSkipVersion, qhkSkipVersion, route.Formats); err != nil { + res = append(res, err) + } + qVersion, qhkVersion, _ := qs.GetOK("version") if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +// bindXRuntimeActions binds and validates parameter XRuntimeActions from header. +func (o *PostHAProxyConfigurationParams) bindXRuntimeActions(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.XRuntimeActions = &raw + + return nil +} + // bindForceReload binds and validates parameter ForceReload from query. func (o *PostHAProxyConfigurationParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -124,6 +187,7 @@ func (o *PostHAProxyConfigurationParams) bindForceReload(rawData []string, hasKe // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewPostHAProxyConfigurationParams() return nil @@ -138,6 +202,78 @@ func (o *PostHAProxyConfigurationParams) bindForceReload(rawData []string, hasKe return nil } +// bindOnlyValidate binds and validates parameter OnlyValidate from query. +func (o *PostHAProxyConfigurationParams) bindOnlyValidate(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewPostHAProxyConfigurationParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("only_validate", "query", "bool", raw) + } + o.OnlyValidate = &value + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *PostHAProxyConfigurationParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewPostHAProxyConfigurationParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} + +// bindSkipVersion binds and validates parameter SkipVersion from query. +func (o *PostHAProxyConfigurationParams) bindSkipVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewPostHAProxyConfigurationParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_version", "query", "bool", raw) + } + o.SkipVersion = &value + + return nil +} + // bindVersion binds and validates parameter Version from query. func (o *PostHAProxyConfigurationParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -147,6 +283,7 @@ func (o *PostHAProxyConfigurationParams) bindVersion(rawData []string, hasKey bo // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/configuration/post_h_a_proxy_configuration_responses.go b/operations/configuration/post_h_a_proxy_configuration_responses.go index 8cd73054..8396d193 100644 --- a/operations/configuration/post_h_a_proxy_configuration_responses.go +++ b/operations/configuration/post_h_a_proxy_configuration_responses.go @@ -24,19 +24,29 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" ) // PostHAProxyConfigurationCreatedCode is the HTTP code returned for type PostHAProxyConfigurationCreated const PostHAProxyConfigurationCreatedCode int = 201 -/*PostHAProxyConfigurationCreated New HAProxy configuration pushed +/* +PostHAProxyConfigurationCreated New HAProxy configuration pushed swagger:response postHAProxyConfigurationCreated */ type PostHAProxyConfigurationCreated struct { + /*Cluster configuration version + + */ + ClusterVersion string `json:"Cluster-Version"` + /*Configuration file md5 checksum + + */ + ConfigurationChecksum string `json:"Configuration-Checksum"` + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -50,6 +60,39 @@ func NewPostHAProxyConfigurationCreated() *PostHAProxyConfigurationCreated { return &PostHAProxyConfigurationCreated{} } +// WithClusterVersion adds the clusterVersion to the post h a proxy configuration created response +func (o *PostHAProxyConfigurationCreated) WithClusterVersion(clusterVersion string) *PostHAProxyConfigurationCreated { + o.ClusterVersion = clusterVersion + return o +} + +// SetClusterVersion sets the clusterVersion to the post h a proxy configuration created response +func (o *PostHAProxyConfigurationCreated) SetClusterVersion(clusterVersion string) { + o.ClusterVersion = clusterVersion +} + +// WithConfigurationChecksum adds the configurationChecksum to the post h a proxy configuration created response +func (o *PostHAProxyConfigurationCreated) WithConfigurationChecksum(configurationChecksum string) *PostHAProxyConfigurationCreated { + o.ConfigurationChecksum = configurationChecksum + return o +} + +// SetConfigurationChecksum sets the configurationChecksum to the post h a proxy configuration created response +func (o *PostHAProxyConfigurationCreated) SetConfigurationChecksum(configurationChecksum string) { + o.ConfigurationChecksum = configurationChecksum +} + +// WithConfigurationVersion adds the configurationVersion to the post h a proxy configuration created response +func (o *PostHAProxyConfigurationCreated) WithConfigurationVersion(configurationVersion string) *PostHAProxyConfigurationCreated { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the post h a proxy configuration created response +func (o *PostHAProxyConfigurationCreated) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + // WithPayload adds the payload to the post h a proxy configuration created response func (o *PostHAProxyConfigurationCreated) WithPayload(payload string) *PostHAProxyConfigurationCreated { o.Payload = payload @@ -64,6 +107,27 @@ func (o *PostHAProxyConfigurationCreated) SetPayload(payload string) { // WriteResponse to the client func (o *PostHAProxyConfigurationCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + // response header Cluster-Version + + clusterVersion := o.ClusterVersion + if clusterVersion != "" { + rw.Header().Set("Cluster-Version", clusterVersion) + } + + // response header Configuration-Checksum + + configurationChecksum := o.ConfigurationChecksum + if configurationChecksum != "" { + rw.Header().Set("Configuration-Checksum", configurationChecksum) + } + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + rw.WriteHeader(201) payload := o.Payload if err := producer.Produce(rw, payload); err != nil { @@ -74,11 +138,24 @@ func (o *PostHAProxyConfigurationCreated) WriteResponse(rw http.ResponseWriter, // PostHAProxyConfigurationAcceptedCode is the HTTP code returned for type PostHAProxyConfigurationAccepted const PostHAProxyConfigurationAcceptedCode int = 202 -/*PostHAProxyConfigurationAccepted Configuration change accepted and reload requested +/* +PostHAProxyConfigurationAccepted Configuration change accepted and reload requested swagger:response postHAProxyConfigurationAccepted */ type PostHAProxyConfigurationAccepted struct { + /*Cluster configuration version + + */ + ClusterVersion string `json:"Cluster-Version"` + /*Configuration file md5 checksum + + */ + ConfigurationChecksum string `json:"Configuration-Checksum"` + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` /*ID of the requested reload */ @@ -96,6 +173,39 @@ func NewPostHAProxyConfigurationAccepted() *PostHAProxyConfigurationAccepted { return &PostHAProxyConfigurationAccepted{} } +// WithClusterVersion adds the clusterVersion to the post h a proxy configuration accepted response +func (o *PostHAProxyConfigurationAccepted) WithClusterVersion(clusterVersion string) *PostHAProxyConfigurationAccepted { + o.ClusterVersion = clusterVersion + return o +} + +// SetClusterVersion sets the clusterVersion to the post h a proxy configuration accepted response +func (o *PostHAProxyConfigurationAccepted) SetClusterVersion(clusterVersion string) { + o.ClusterVersion = clusterVersion +} + +// WithConfigurationChecksum adds the configurationChecksum to the post h a proxy configuration accepted response +func (o *PostHAProxyConfigurationAccepted) WithConfigurationChecksum(configurationChecksum string) *PostHAProxyConfigurationAccepted { + o.ConfigurationChecksum = configurationChecksum + return o +} + +// SetConfigurationChecksum sets the configurationChecksum to the post h a proxy configuration accepted response +func (o *PostHAProxyConfigurationAccepted) SetConfigurationChecksum(configurationChecksum string) { + o.ConfigurationChecksum = configurationChecksum +} + +// WithConfigurationVersion adds the configurationVersion to the post h a proxy configuration accepted response +func (o *PostHAProxyConfigurationAccepted) WithConfigurationVersion(configurationVersion string) *PostHAProxyConfigurationAccepted { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the post h a proxy configuration accepted response +func (o *PostHAProxyConfigurationAccepted) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + // WithReloadID adds the reloadId to the post h a proxy configuration accepted response func (o *PostHAProxyConfigurationAccepted) WithReloadID(reloadID string) *PostHAProxyConfigurationAccepted { o.ReloadID = reloadID @@ -121,6 +231,27 @@ func (o *PostHAProxyConfigurationAccepted) SetPayload(payload string) { // WriteResponse to the client func (o *PostHAProxyConfigurationAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + // response header Cluster-Version + + clusterVersion := o.ClusterVersion + if clusterVersion != "" { + rw.Header().Set("Cluster-Version", clusterVersion) + } + + // response header Configuration-Checksum + + configurationChecksum := o.ConfigurationChecksum + if configurationChecksum != "" { + rw.Header().Set("Configuration-Checksum", configurationChecksum) + } + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + // response header Reload-ID reloadID := o.ReloadID @@ -138,7 +269,8 @@ func (o *PostHAProxyConfigurationAccepted) WriteResponse(rw http.ResponseWriter, // PostHAProxyConfigurationBadRequestCode is the HTTP code returned for type PostHAProxyConfigurationBadRequest const PostHAProxyConfigurationBadRequestCode int = 400 -/*PostHAProxyConfigurationBadRequest Bad request +/* +PostHAProxyConfigurationBadRequest Bad request swagger:response postHAProxyConfigurationBadRequest */ @@ -146,12 +278,12 @@ type PostHAProxyConfigurationBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *models.Error `json:"body,omitempty"` + Payload string `json:"body,omitempty"` } // NewPostHAProxyConfigurationBadRequest creates PostHAProxyConfigurationBadRequest with default headers values @@ -161,24 +293,24 @@ func NewPostHAProxyConfigurationBadRequest() *PostHAProxyConfigurationBadRequest } // WithConfigurationVersion adds the configurationVersion to the post h a proxy configuration bad request response -func (o *PostHAProxyConfigurationBadRequest) WithConfigurationVersion(configurationVersion int64) *PostHAProxyConfigurationBadRequest { +func (o *PostHAProxyConfigurationBadRequest) WithConfigurationVersion(configurationVersion string) *PostHAProxyConfigurationBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the post h a proxy configuration bad request response -func (o *PostHAProxyConfigurationBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *PostHAProxyConfigurationBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the post h a proxy configuration bad request response -func (o *PostHAProxyConfigurationBadRequest) WithPayload(payload *models.Error) *PostHAProxyConfigurationBadRequest { +func (o *PostHAProxyConfigurationBadRequest) WithPayload(payload string) *PostHAProxyConfigurationBadRequest { o.Payload = payload return o } // SetPayload sets the payload to the post h a proxy configuration bad request response -func (o *PostHAProxyConfigurationBadRequest) SetPayload(payload *models.Error) { +func (o *PostHAProxyConfigurationBadRequest) SetPayload(payload string) { o.Payload = payload } @@ -187,21 +319,20 @@ func (o *PostHAProxyConfigurationBadRequest) WriteResponse(rw http.ResponseWrite // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*PostHAProxyConfigurationDefault General Error +/* +PostHAProxyConfigurationDefault General Error swagger:response postHAProxyConfigurationDefault */ @@ -210,12 +341,12 @@ type PostHAProxyConfigurationDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *models.Error `json:"body,omitempty"` + Payload string `json:"body,omitempty"` } // NewPostHAProxyConfigurationDefault creates PostHAProxyConfigurationDefault with default headers values @@ -241,24 +372,24 @@ func (o *PostHAProxyConfigurationDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the post h a proxy configuration default response -func (o *PostHAProxyConfigurationDefault) WithConfigurationVersion(configurationVersion int64) *PostHAProxyConfigurationDefault { +func (o *PostHAProxyConfigurationDefault) WithConfigurationVersion(configurationVersion string) *PostHAProxyConfigurationDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the post h a proxy configuration default response -func (o *PostHAProxyConfigurationDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *PostHAProxyConfigurationDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the post h a proxy configuration default response -func (o *PostHAProxyConfigurationDefault) WithPayload(payload *models.Error) *PostHAProxyConfigurationDefault { +func (o *PostHAProxyConfigurationDefault) WithPayload(payload string) *PostHAProxyConfigurationDefault { o.Payload = payload return o } // SetPayload sets the payload to the post h a proxy configuration default response -func (o *PostHAProxyConfigurationDefault) SetPayload(payload *models.Error) { +func (o *PostHAProxyConfigurationDefault) SetPayload(payload string) { o.Payload = payload } @@ -267,16 +398,14 @@ func (o *PostHAProxyConfigurationDefault) WriteResponse(rw http.ResponseWriter, // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } diff --git a/operations/configuration/post_h_a_proxy_configuration_urlbuilder.go b/operations/configuration/post_h_a_proxy_configuration_urlbuilder.go index 1a0f1b49..9dcbbe78 100644 --- a/operations/configuration/post_h_a_proxy_configuration_urlbuilder.go +++ b/operations/configuration/post_h_a_proxy_configuration_urlbuilder.go @@ -30,8 +30,11 @@ import ( // PostHAProxyConfigurationURL generates an URL for the post h a proxy configuration operation type PostHAProxyConfigurationURL struct { - ForceReload *bool - Version *int64 + ForceReload *bool + OnlyValidate *bool + SkipReload *bool + SkipVersion *bool + Version *int64 _basePath string // avoid unkeyed usage @@ -61,26 +64,50 @@ func (o *PostHAProxyConfigurationURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var version string + var onlyValidateQ string + if o.OnlyValidate != nil { + onlyValidateQ = swag.FormatBool(*o.OnlyValidate) + } + if onlyValidateQ != "" { + qs.Set("only_validate", onlyValidateQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + var skipVersionQ string + if o.SkipVersion != nil { + skipVersionQ = swag.FormatBool(*o.SkipVersion) + } + if skipVersionQ != "" { + qs.Set("skip_version", skipVersionQ) + } + + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/crt_load/create_crt_load.go b/operations/crt_load/create_crt_load.go new file mode 100644 index 00000000..983a7b94 --- /dev/null +++ b/operations/crt_load/create_crt_load.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateCrtLoadHandlerFunc turns a function with the right signature into a create crt load handler +type CreateCrtLoadHandlerFunc func(CreateCrtLoadParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateCrtLoadHandlerFunc) Handle(params CreateCrtLoadParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateCrtLoadHandler interface for that can handle valid create crt load params +type CreateCrtLoadHandler interface { + Handle(CreateCrtLoadParams, interface{}) middleware.Responder +} + +// NewCreateCrtLoad creates a new http.Handler for the create crt load operation +func NewCreateCrtLoad(ctx *middleware.Context, handler CreateCrtLoadHandler) *CreateCrtLoad { + return &CreateCrtLoad{Context: ctx, Handler: handler} +} + +/* + CreateCrtLoad swagger:route POST /services/haproxy/configuration/crt_loads CrtLoad createCrtLoad + +# Add a new certificate to load + +Adds a new load entry to the specified crt_store section in the configuration +*/ +type CreateCrtLoad struct { + Context *middleware.Context + Handler CreateCrtLoadHandler +} + +func (o *CreateCrtLoad) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateCrtLoadParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_load/create_crt_load_parameters.go b/operations/crt_load/create_crt_load_parameters.go new file mode 100644 index 00000000..b42ab7c7 --- /dev/null +++ b/operations/crt_load/create_crt_load_parameters.go @@ -0,0 +1,229 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateCrtLoadParams creates a new CreateCrtLoadParams object +// with the default values initialized. +func NewCreateCrtLoadParams() CreateCrtLoadParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateCrtLoadParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateCrtLoadParams contains all the bound params for the create crt load operation +// typically these are obtained from a http.Request +// +// swagger:parameters createCrtLoad +type CreateCrtLoadParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent crt_store section name + Required: true + In: query + */ + CrtStore string + /* + Required: true + In: body + */ + Data *models.CrtLoad + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateCrtLoadParams() beforehand. +func (o *CreateCrtLoadParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qCrtStore, qhkCrtStore, _ := qs.GetOK("crt_store") + if err := o.bindCrtStore(qCrtStore, qhkCrtStore, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.CrtLoad + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCrtStore binds and validates parameter CrtStore from query. +func (o *CreateCrtLoadParams) bindCrtStore(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("crt_store", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("crt_store", "query", raw); err != nil { + return err + } + o.CrtStore = raw + + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateCrtLoadParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateCrtLoadParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateCrtLoadParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateCrtLoadParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/crt_load/create_crt_load_responses.go b/operations/crt_load/create_crt_load_responses.go new file mode 100644 index 00000000..9645b637 --- /dev/null +++ b/operations/crt_load/create_crt_load_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateCrtLoadCreatedCode is the HTTP code returned for type CreateCrtLoadCreated +const CreateCrtLoadCreatedCode int = 201 + +/* +CreateCrtLoadCreated Certificate load entry created + +swagger:response createCrtLoadCreated +*/ +type CreateCrtLoadCreated struct { + + /* + In: Body + */ + Payload *models.CrtLoad `json:"body,omitempty"` +} + +// NewCreateCrtLoadCreated creates CreateCrtLoadCreated with default headers values +func NewCreateCrtLoadCreated() *CreateCrtLoadCreated { + + return &CreateCrtLoadCreated{} +} + +// WithPayload adds the payload to the create crt load created response +func (o *CreateCrtLoadCreated) WithPayload(payload *models.CrtLoad) *CreateCrtLoadCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt load created response +func (o *CreateCrtLoadCreated) SetPayload(payload *models.CrtLoad) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtLoadCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCrtLoadAcceptedCode is the HTTP code returned for type CreateCrtLoadAccepted +const CreateCrtLoadAcceptedCode int = 202 + +/* +CreateCrtLoadAccepted Configuration change accepted and reload requested + +swagger:response createCrtLoadAccepted +*/ +type CreateCrtLoadAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.CrtLoad `json:"body,omitempty"` +} + +// NewCreateCrtLoadAccepted creates CreateCrtLoadAccepted with default headers values +func NewCreateCrtLoadAccepted() *CreateCrtLoadAccepted { + + return &CreateCrtLoadAccepted{} +} + +// WithReloadID adds the reloadId to the create crt load accepted response +func (o *CreateCrtLoadAccepted) WithReloadID(reloadID string) *CreateCrtLoadAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create crt load accepted response +func (o *CreateCrtLoadAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create crt load accepted response +func (o *CreateCrtLoadAccepted) WithPayload(payload *models.CrtLoad) *CreateCrtLoadAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt load accepted response +func (o *CreateCrtLoadAccepted) SetPayload(payload *models.CrtLoad) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtLoadAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCrtLoadBadRequestCode is the HTTP code returned for type CreateCrtLoadBadRequest +const CreateCrtLoadBadRequestCode int = 400 + +/* +CreateCrtLoadBadRequest Bad request + +swagger:response createCrtLoadBadRequest +*/ +type CreateCrtLoadBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrtLoadBadRequest creates CreateCrtLoadBadRequest with default headers values +func NewCreateCrtLoadBadRequest() *CreateCrtLoadBadRequest { + + return &CreateCrtLoadBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create crt load bad request response +func (o *CreateCrtLoadBadRequest) WithConfigurationVersion(configurationVersion string) *CreateCrtLoadBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crt load bad request response +func (o *CreateCrtLoadBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crt load bad request response +func (o *CreateCrtLoadBadRequest) WithPayload(payload *models.Error) *CreateCrtLoadBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt load bad request response +func (o *CreateCrtLoadBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtLoadBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCrtLoadConflictCode is the HTTP code returned for type CreateCrtLoadConflict +const CreateCrtLoadConflictCode int = 409 + +/* +CreateCrtLoadConflict The specified resource already exists + +swagger:response createCrtLoadConflict +*/ +type CreateCrtLoadConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrtLoadConflict creates CreateCrtLoadConflict with default headers values +func NewCreateCrtLoadConflict() *CreateCrtLoadConflict { + + return &CreateCrtLoadConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create crt load conflict response +func (o *CreateCrtLoadConflict) WithConfigurationVersion(configurationVersion string) *CreateCrtLoadConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crt load conflict response +func (o *CreateCrtLoadConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crt load conflict response +func (o *CreateCrtLoadConflict) WithPayload(payload *models.Error) *CreateCrtLoadConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt load conflict response +func (o *CreateCrtLoadConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtLoadConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateCrtLoadDefault General Error + +swagger:response createCrtLoadDefault +*/ +type CreateCrtLoadDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrtLoadDefault creates CreateCrtLoadDefault with default headers values +func NewCreateCrtLoadDefault(code int) *CreateCrtLoadDefault { + if code <= 0 { + code = 500 + } + + return &CreateCrtLoadDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create crt load default response +func (o *CreateCrtLoadDefault) WithStatusCode(code int) *CreateCrtLoadDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create crt load default response +func (o *CreateCrtLoadDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create crt load default response +func (o *CreateCrtLoadDefault) WithConfigurationVersion(configurationVersion string) *CreateCrtLoadDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crt load default response +func (o *CreateCrtLoadDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crt load default response +func (o *CreateCrtLoadDefault) WithPayload(payload *models.Error) *CreateCrtLoadDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt load default response +func (o *CreateCrtLoadDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtLoadDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_load/create_crt_load_urlbuilder.go b/operations/crt_load/create_crt_load_urlbuilder.go new file mode 100644 index 00000000..dd55a56d --- /dev/null +++ b/operations/crt_load/create_crt_load_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateCrtLoadURL generates an URL for the create crt load operation +type CreateCrtLoadURL struct { + CrtStore string + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCrtLoadURL) WithBasePath(bp string) *CreateCrtLoadURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCrtLoadURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateCrtLoadURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_loads" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + crtStoreQ := o.CrtStore + if crtStoreQ != "" { + qs.Set("crt_store", crtStoreQ) + } + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateCrtLoadURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateCrtLoadURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateCrtLoadURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateCrtLoadURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateCrtLoadURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateCrtLoadURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_load/delete_crt_load.go b/operations/crt_load/delete_crt_load.go new file mode 100644 index 00000000..9010ee78 --- /dev/null +++ b/operations/crt_load/delete_crt_load.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCrtLoadHandlerFunc turns a function with the right signature into a delete crt load handler +type DeleteCrtLoadHandlerFunc func(DeleteCrtLoadParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCrtLoadHandlerFunc) Handle(params DeleteCrtLoadParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteCrtLoadHandler interface for that can handle valid delete crt load params +type DeleteCrtLoadHandler interface { + Handle(DeleteCrtLoadParams, interface{}) middleware.Responder +} + +// NewDeleteCrtLoad creates a new http.Handler for the delete crt load operation +func NewDeleteCrtLoad(ctx *middleware.Context, handler DeleteCrtLoadHandler) *DeleteCrtLoad { + return &DeleteCrtLoad{Context: ctx, Handler: handler} +} + +/* + DeleteCrtLoad swagger:route DELETE /services/haproxy/configuration/crt_loads/{certificate} CrtLoad deleteCrtLoad + +# Delete a certificate load entry + +Deletes a load entry by its certificate name in the specified crt_store section +*/ +type DeleteCrtLoad struct { + Context *middleware.Context + Handler DeleteCrtLoadHandler +} + +func (o *DeleteCrtLoad) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCrtLoadParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_load/delete_crt_load_parameters.go b/operations/crt_load/delete_crt_load_parameters.go new file mode 100644 index 00000000..933bb82a --- /dev/null +++ b/operations/crt_load/delete_crt_load_parameters.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteCrtLoadParams creates a new DeleteCrtLoadParams object +// with the default values initialized. +func NewDeleteCrtLoadParams() DeleteCrtLoadParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteCrtLoadParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteCrtLoadParams contains all the bound params for the delete crt load operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCrtLoad +type DeleteCrtLoadParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Certificate filename + Required: true + In: path + */ + Certificate string + /*Parent crt_store section name + Required: true + In: query + */ + CrtStore string + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCrtLoadParams() beforehand. +func (o *DeleteCrtLoadParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rCertificate, rhkCertificate, _ := route.Params.GetOK("certificate") + if err := o.bindCertificate(rCertificate, rhkCertificate, route.Formats); err != nil { + res = append(res, err) + } + + qCrtStore, qhkCrtStore, _ := qs.GetOK("crt_store") + if err := o.bindCrtStore(qCrtStore, qhkCrtStore, route.Formats); err != nil { + res = append(res, err) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCertificate binds and validates parameter Certificate from path. +func (o *DeleteCrtLoadParams) bindCertificate(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Certificate = raw + + return nil +} + +// bindCrtStore binds and validates parameter CrtStore from query. +func (o *DeleteCrtLoadParams) bindCrtStore(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("crt_store", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("crt_store", "query", raw); err != nil { + return err + } + o.CrtStore = raw + + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteCrtLoadParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteCrtLoadParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteCrtLoadParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteCrtLoadParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/crt_load/delete_crt_load_responses.go b/operations/crt_load/delete_crt_load_responses.go new file mode 100644 index 00000000..20d62b59 --- /dev/null +++ b/operations/crt_load/delete_crt_load_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteCrtLoadAcceptedCode is the HTTP code returned for type DeleteCrtLoadAccepted +const DeleteCrtLoadAcceptedCode int = 202 + +/* +DeleteCrtLoadAccepted Configuration change accepted and reload requested + +swagger:response deleteCrtLoadAccepted +*/ +type DeleteCrtLoadAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteCrtLoadAccepted creates DeleteCrtLoadAccepted with default headers values +func NewDeleteCrtLoadAccepted() *DeleteCrtLoadAccepted { + + return &DeleteCrtLoadAccepted{} +} + +// WithReloadID adds the reloadId to the delete crt load accepted response +func (o *DeleteCrtLoadAccepted) WithReloadID(reloadID string) *DeleteCrtLoadAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete crt load accepted response +func (o *DeleteCrtLoadAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteCrtLoadAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteCrtLoadNoContentCode is the HTTP code returned for type DeleteCrtLoadNoContent +const DeleteCrtLoadNoContentCode int = 204 + +/* +DeleteCrtLoadNoContent Certificate load entry deleted + +swagger:response deleteCrtLoadNoContent +*/ +type DeleteCrtLoadNoContent struct { +} + +// NewDeleteCrtLoadNoContent creates DeleteCrtLoadNoContent with default headers values +func NewDeleteCrtLoadNoContent() *DeleteCrtLoadNoContent { + + return &DeleteCrtLoadNoContent{} +} + +// WriteResponse to the client +func (o *DeleteCrtLoadNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteCrtLoadNotFoundCode is the HTTP code returned for type DeleteCrtLoadNotFound +const DeleteCrtLoadNotFoundCode int = 404 + +/* +DeleteCrtLoadNotFound The specified resource was not found + +swagger:response deleteCrtLoadNotFound +*/ +type DeleteCrtLoadNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrtLoadNotFound creates DeleteCrtLoadNotFound with default headers values +func NewDeleteCrtLoadNotFound() *DeleteCrtLoadNotFound { + + return &DeleteCrtLoadNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete crt load not found response +func (o *DeleteCrtLoadNotFound) WithConfigurationVersion(configurationVersion string) *DeleteCrtLoadNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crt load not found response +func (o *DeleteCrtLoadNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crt load not found response +func (o *DeleteCrtLoadNotFound) WithPayload(payload *models.Error) *DeleteCrtLoadNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crt load not found response +func (o *DeleteCrtLoadNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrtLoadNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteCrtLoadDefault General Error + +swagger:response deleteCrtLoadDefault +*/ +type DeleteCrtLoadDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrtLoadDefault creates DeleteCrtLoadDefault with default headers values +func NewDeleteCrtLoadDefault(code int) *DeleteCrtLoadDefault { + if code <= 0 { + code = 500 + } + + return &DeleteCrtLoadDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete crt load default response +func (o *DeleteCrtLoadDefault) WithStatusCode(code int) *DeleteCrtLoadDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete crt load default response +func (o *DeleteCrtLoadDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete crt load default response +func (o *DeleteCrtLoadDefault) WithConfigurationVersion(configurationVersion string) *DeleteCrtLoadDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crt load default response +func (o *DeleteCrtLoadDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crt load default response +func (o *DeleteCrtLoadDefault) WithPayload(payload *models.Error) *DeleteCrtLoadDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crt load default response +func (o *DeleteCrtLoadDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrtLoadDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_load/delete_crt_load_urlbuilder.go b/operations/crt_load/delete_crt_load_urlbuilder.go new file mode 100644 index 00000000..a2f29b39 --- /dev/null +++ b/operations/crt_load/delete_crt_load_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteCrtLoadURL generates an URL for the delete crt load operation +type DeleteCrtLoadURL struct { + Certificate string + + CrtStore string + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrtLoadURL) WithBasePath(bp string) *DeleteCrtLoadURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrtLoadURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCrtLoadURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_loads/{certificate}" + + certificate := o.Certificate + if certificate != "" { + _path = strings.Replace(_path, "{certificate}", certificate, -1) + } else { + return nil, errors.New("certificate is required on DeleteCrtLoadURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + crtStoreQ := o.CrtStore + if crtStoreQ != "" { + qs.Set("crt_store", crtStoreQ) + } + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCrtLoadURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCrtLoadURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCrtLoadURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCrtLoadURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCrtLoadURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCrtLoadURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_load/get_crt_load.go b/operations/crt_load/get_crt_load.go new file mode 100644 index 00000000..8645a381 --- /dev/null +++ b/operations/crt_load/get_crt_load.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCrtLoadHandlerFunc turns a function with the right signature into a get crt load handler +type GetCrtLoadHandlerFunc func(GetCrtLoadParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCrtLoadHandlerFunc) Handle(params GetCrtLoadParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCrtLoadHandler interface for that can handle valid get crt load params +type GetCrtLoadHandler interface { + Handle(GetCrtLoadParams, interface{}) middleware.Responder +} + +// NewGetCrtLoad creates a new http.Handler for the get crt load operation +func NewGetCrtLoad(ctx *middleware.Context, handler GetCrtLoadHandler) *GetCrtLoad { + return &GetCrtLoad{Context: ctx, Handler: handler} +} + +/* + GetCrtLoad swagger:route GET /services/haproxy/configuration/crt_loads/{certificate} CrtLoad getCrtLoad + +# Return one certificate load entry + +Returns one load entry by its certificate name in the specified crt_store +*/ +type GetCrtLoad struct { + Context *middleware.Context + Handler GetCrtLoadHandler +} + +func (o *GetCrtLoad) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCrtLoadParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_load/get_crt_load_parameters.go b/operations/crt_load/get_crt_load_parameters.go new file mode 100644 index 00000000..3f1e4603 --- /dev/null +++ b/operations/crt_load/get_crt_load_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetCrtLoadParams creates a new GetCrtLoadParams object +// +// There are no default values defined in the spec. +func NewGetCrtLoadParams() GetCrtLoadParams { + + return GetCrtLoadParams{} +} + +// GetCrtLoadParams contains all the bound params for the get crt load operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCrtLoad +type GetCrtLoadParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Certificate filename + Required: true + In: path + */ + Certificate string + /*Parent crt_store name + Required: true + In: query + */ + CrtStore string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCrtLoadParams() beforehand. +func (o *GetCrtLoadParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rCertificate, rhkCertificate, _ := route.Params.GetOK("certificate") + if err := o.bindCertificate(rCertificate, rhkCertificate, route.Formats); err != nil { + res = append(res, err) + } + + qCrtStore, qhkCrtStore, _ := qs.GetOK("crt_store") + if err := o.bindCrtStore(qCrtStore, qhkCrtStore, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCertificate binds and validates parameter Certificate from path. +func (o *GetCrtLoadParams) bindCertificate(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Certificate = raw + + return nil +} + +// bindCrtStore binds and validates parameter CrtStore from query. +func (o *GetCrtLoadParams) bindCrtStore(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("crt_store", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("crt_store", "query", raw); err != nil { + return err + } + o.CrtStore = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetCrtLoadParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/crt_load/get_crt_load_responses.go b/operations/crt_load/get_crt_load_responses.go new file mode 100644 index 00000000..5132111a --- /dev/null +++ b/operations/crt_load/get_crt_load_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCrtLoadOKCode is the HTTP code returned for type GetCrtLoadOK +const GetCrtLoadOKCode int = 200 + +/* +GetCrtLoadOK Successful operation + +swagger:response getCrtLoadOK +*/ +type GetCrtLoadOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.CrtLoad `json:"body,omitempty"` +} + +// NewGetCrtLoadOK creates GetCrtLoadOK with default headers values +func NewGetCrtLoadOK() *GetCrtLoadOK { + + return &GetCrtLoadOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get crt load o k response +func (o *GetCrtLoadOK) WithConfigurationVersion(configurationVersion string) *GetCrtLoadOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt load o k response +func (o *GetCrtLoadOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt load o k response +func (o *GetCrtLoadOK) WithPayload(payload *models.CrtLoad) *GetCrtLoadOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt load o k response +func (o *GetCrtLoadOK) SetPayload(payload *models.CrtLoad) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtLoadOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetCrtLoadNotFoundCode is the HTTP code returned for type GetCrtLoadNotFound +const GetCrtLoadNotFoundCode int = 404 + +/* +GetCrtLoadNotFound The specified resource was not found + +swagger:response getCrtLoadNotFound +*/ +type GetCrtLoadNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrtLoadNotFound creates GetCrtLoadNotFound with default headers values +func NewGetCrtLoadNotFound() *GetCrtLoadNotFound { + + return &GetCrtLoadNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get crt load not found response +func (o *GetCrtLoadNotFound) WithConfigurationVersion(configurationVersion string) *GetCrtLoadNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt load not found response +func (o *GetCrtLoadNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt load not found response +func (o *GetCrtLoadNotFound) WithPayload(payload *models.Error) *GetCrtLoadNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt load not found response +func (o *GetCrtLoadNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtLoadNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetCrtLoadDefault General Error + +swagger:response getCrtLoadDefault +*/ +type GetCrtLoadDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrtLoadDefault creates GetCrtLoadDefault with default headers values +func NewGetCrtLoadDefault(code int) *GetCrtLoadDefault { + if code <= 0 { + code = 500 + } + + return &GetCrtLoadDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get crt load default response +func (o *GetCrtLoadDefault) WithStatusCode(code int) *GetCrtLoadDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get crt load default response +func (o *GetCrtLoadDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get crt load default response +func (o *GetCrtLoadDefault) WithConfigurationVersion(configurationVersion string) *GetCrtLoadDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt load default response +func (o *GetCrtLoadDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt load default response +func (o *GetCrtLoadDefault) WithPayload(payload *models.Error) *GetCrtLoadDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt load default response +func (o *GetCrtLoadDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtLoadDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_load/get_crt_load_urlbuilder.go b/operations/crt_load/get_crt_load_urlbuilder.go new file mode 100644 index 00000000..85418e77 --- /dev/null +++ b/operations/crt_load/get_crt_load_urlbuilder.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetCrtLoadURL generates an URL for the get crt load operation +type GetCrtLoadURL struct { + Certificate string + + CrtStore string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtLoadURL) WithBasePath(bp string) *GetCrtLoadURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtLoadURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCrtLoadURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_loads/{certificate}" + + certificate := o.Certificate + if certificate != "" { + _path = strings.Replace(_path, "{certificate}", certificate, -1) + } else { + return nil, errors.New("certificate is required on GetCrtLoadURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + crtStoreQ := o.CrtStore + if crtStoreQ != "" { + qs.Set("crt_store", crtStoreQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCrtLoadURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCrtLoadURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCrtLoadURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCrtLoadURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCrtLoadURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCrtLoadURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_load/get_crt_loads.go b/operations/crt_load/get_crt_loads.go new file mode 100644 index 00000000..92f750fe --- /dev/null +++ b/operations/crt_load/get_crt_loads.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCrtLoadsHandlerFunc turns a function with the right signature into a get crt loads handler +type GetCrtLoadsHandlerFunc func(GetCrtLoadsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCrtLoadsHandlerFunc) Handle(params GetCrtLoadsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCrtLoadsHandler interface for that can handle valid get crt loads params +type GetCrtLoadsHandler interface { + Handle(GetCrtLoadsParams, interface{}) middleware.Responder +} + +// NewGetCrtLoads creates a new http.Handler for the get crt loads operation +func NewGetCrtLoads(ctx *middleware.Context, handler GetCrtLoadsHandler) *GetCrtLoads { + return &GetCrtLoads{Context: ctx, Handler: handler} +} + +/* + GetCrtLoads swagger:route GET /services/haproxy/configuration/crt_loads CrtLoad getCrtLoads + +# Return an array of loaded certificates + +Returns the list of loaded certificates from the specified crt_store +*/ +type GetCrtLoads struct { + Context *middleware.Context + Handler GetCrtLoadsHandler +} + +func (o *GetCrtLoads) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCrtLoadsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_load/get_crt_loads_parameters.go b/operations/crt_load/get_crt_loads_parameters.go new file mode 100644 index 00000000..8df3b42b --- /dev/null +++ b/operations/crt_load/get_crt_loads_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetCrtLoadsParams creates a new GetCrtLoadsParams object +// +// There are no default values defined in the spec. +func NewGetCrtLoadsParams() GetCrtLoadsParams { + + return GetCrtLoadsParams{} +} + +// GetCrtLoadsParams contains all the bound params for the get crt loads operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCrtLoads +type GetCrtLoadsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent crt_store name + Required: true + In: query + */ + CrtStore string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCrtLoadsParams() beforehand. +func (o *GetCrtLoadsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qCrtStore, qhkCrtStore, _ := qs.GetOK("crt_store") + if err := o.bindCrtStore(qCrtStore, qhkCrtStore, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCrtStore binds and validates parameter CrtStore from query. +func (o *GetCrtLoadsParams) bindCrtStore(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("crt_store", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("crt_store", "query", raw); err != nil { + return err + } + o.CrtStore = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetCrtLoadsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/crt_load/get_crt_loads_responses.go b/operations/crt_load/get_crt_loads_responses.go new file mode 100644 index 00000000..6fa9cdb7 --- /dev/null +++ b/operations/crt_load/get_crt_loads_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCrtLoadsOKCode is the HTTP code returned for type GetCrtLoadsOK +const GetCrtLoadsOKCode int = 200 + +/* +GetCrtLoadsOK Successful operation + +swagger:response getCrtLoadsOK +*/ +type GetCrtLoadsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.CrtLoads `json:"body,omitempty"` +} + +// NewGetCrtLoadsOK creates GetCrtLoadsOK with default headers values +func NewGetCrtLoadsOK() *GetCrtLoadsOK { + + return &GetCrtLoadsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get crt loads o k response +func (o *GetCrtLoadsOK) WithConfigurationVersion(configurationVersion string) *GetCrtLoadsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt loads o k response +func (o *GetCrtLoadsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt loads o k response +func (o *GetCrtLoadsOK) WithPayload(payload models.CrtLoads) *GetCrtLoadsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt loads o k response +func (o *GetCrtLoadsOK) SetPayload(payload models.CrtLoads) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtLoadsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.CrtLoads{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetCrtLoadsDefault General Error + +swagger:response getCrtLoadsDefault +*/ +type GetCrtLoadsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrtLoadsDefault creates GetCrtLoadsDefault with default headers values +func NewGetCrtLoadsDefault(code int) *GetCrtLoadsDefault { + if code <= 0 { + code = 500 + } + + return &GetCrtLoadsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get crt loads default response +func (o *GetCrtLoadsDefault) WithStatusCode(code int) *GetCrtLoadsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get crt loads default response +func (o *GetCrtLoadsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get crt loads default response +func (o *GetCrtLoadsDefault) WithConfigurationVersion(configurationVersion string) *GetCrtLoadsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt loads default response +func (o *GetCrtLoadsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt loads default response +func (o *GetCrtLoadsDefault) WithPayload(payload *models.Error) *GetCrtLoadsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt loads default response +func (o *GetCrtLoadsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtLoadsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_load/get_crt_loads_urlbuilder.go b/operations/crt_load/get_crt_loads_urlbuilder.go new file mode 100644 index 00000000..d7d9dc24 --- /dev/null +++ b/operations/crt_load/get_crt_loads_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetCrtLoadsURL generates an URL for the get crt loads operation +type GetCrtLoadsURL struct { + CrtStore string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtLoadsURL) WithBasePath(bp string) *GetCrtLoadsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtLoadsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCrtLoadsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_loads" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + crtStoreQ := o.CrtStore + if crtStoreQ != "" { + qs.Set("crt_store", crtStoreQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCrtLoadsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCrtLoadsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCrtLoadsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCrtLoadsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCrtLoadsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCrtLoadsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_load/replace_crt_load.go b/operations/crt_load/replace_crt_load.go new file mode 100644 index 00000000..3947740f --- /dev/null +++ b/operations/crt_load/replace_crt_load.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceCrtLoadHandlerFunc turns a function with the right signature into a replace crt load handler +type ReplaceCrtLoadHandlerFunc func(ReplaceCrtLoadParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceCrtLoadHandlerFunc) Handle(params ReplaceCrtLoadParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceCrtLoadHandler interface for that can handle valid replace crt load params +type ReplaceCrtLoadHandler interface { + Handle(ReplaceCrtLoadParams, interface{}) middleware.Responder +} + +// NewReplaceCrtLoad creates a new http.Handler for the replace crt load operation +func NewReplaceCrtLoad(ctx *middleware.Context, handler ReplaceCrtLoadHandler) *ReplaceCrtLoad { + return &ReplaceCrtLoad{Context: ctx, Handler: handler} +} + +/* + ReplaceCrtLoad swagger:route PUT /services/haproxy/configuration/crt_loads/{certificate} CrtLoad replaceCrtLoad + +# Replace a certificate load entry + +Replaces a load entry by its certificate name in the specified crt_store section +*/ +type ReplaceCrtLoad struct { + Context *middleware.Context + Handler ReplaceCrtLoadHandler +} + +func (o *ReplaceCrtLoad) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceCrtLoadParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_load/replace_crt_load_parameters.go b/operations/crt_load/replace_crt_load_parameters.go new file mode 100644 index 00000000..a02980b1 --- /dev/null +++ b/operations/crt_load/replace_crt_load_parameters.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceCrtLoadParams creates a new ReplaceCrtLoadParams object +// with the default values initialized. +func NewReplaceCrtLoadParams() ReplaceCrtLoadParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceCrtLoadParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceCrtLoadParams contains all the bound params for the replace crt load operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceCrtLoad +type ReplaceCrtLoadParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Certificate filename + Required: true + In: path + */ + Certificate string + /*Parent crt_store section name + Required: true + In: query + */ + CrtStore string + /* + Required: true + In: body + */ + Data *models.CrtLoad + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceCrtLoadParams() beforehand. +func (o *ReplaceCrtLoadParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rCertificate, rhkCertificate, _ := route.Params.GetOK("certificate") + if err := o.bindCertificate(rCertificate, rhkCertificate, route.Formats); err != nil { + res = append(res, err) + } + + qCrtStore, qhkCrtStore, _ := qs.GetOK("crt_store") + if err := o.bindCrtStore(qCrtStore, qhkCrtStore, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.CrtLoad + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCertificate binds and validates parameter Certificate from path. +func (o *ReplaceCrtLoadParams) bindCertificate(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Certificate = raw + + return nil +} + +// bindCrtStore binds and validates parameter CrtStore from query. +func (o *ReplaceCrtLoadParams) bindCrtStore(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("crt_store", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("crt_store", "query", raw); err != nil { + return err + } + o.CrtStore = raw + + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceCrtLoadParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceCrtLoadParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceCrtLoadParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceCrtLoadParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/crt_load/replace_crt_load_responses.go b/operations/crt_load/replace_crt_load_responses.go new file mode 100644 index 00000000..4c2674d2 --- /dev/null +++ b/operations/crt_load/replace_crt_load_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceCrtLoadOKCode is the HTTP code returned for type ReplaceCrtLoadOK +const ReplaceCrtLoadOKCode int = 200 + +/* +ReplaceCrtLoadOK Certificate load entry replaced + +swagger:response replaceCrtLoadOK +*/ +type ReplaceCrtLoadOK struct { + + /* + In: Body + */ + Payload *models.CrtLoad `json:"body,omitempty"` +} + +// NewReplaceCrtLoadOK creates ReplaceCrtLoadOK with default headers values +func NewReplaceCrtLoadOK() *ReplaceCrtLoadOK { + + return &ReplaceCrtLoadOK{} +} + +// WithPayload adds the payload to the replace crt load o k response +func (o *ReplaceCrtLoadOK) WithPayload(payload *models.CrtLoad) *ReplaceCrtLoadOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace crt load o k response +func (o *ReplaceCrtLoadOK) SetPayload(payload *models.CrtLoad) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCrtLoadOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceCrtLoadAcceptedCode is the HTTP code returned for type ReplaceCrtLoadAccepted +const ReplaceCrtLoadAcceptedCode int = 202 + +/* +ReplaceCrtLoadAccepted Configuration change accepted and reload requested + +swagger:response replaceCrtLoadAccepted +*/ +type ReplaceCrtLoadAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.CrtLoad `json:"body,omitempty"` +} + +// NewReplaceCrtLoadAccepted creates ReplaceCrtLoadAccepted with default headers values +func NewReplaceCrtLoadAccepted() *ReplaceCrtLoadAccepted { + + return &ReplaceCrtLoadAccepted{} +} + +// WithReloadID adds the reloadId to the replace crt load accepted response +func (o *ReplaceCrtLoadAccepted) WithReloadID(reloadID string) *ReplaceCrtLoadAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace crt load accepted response +func (o *ReplaceCrtLoadAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace crt load accepted response +func (o *ReplaceCrtLoadAccepted) WithPayload(payload *models.CrtLoad) *ReplaceCrtLoadAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace crt load accepted response +func (o *ReplaceCrtLoadAccepted) SetPayload(payload *models.CrtLoad) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCrtLoadAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceCrtLoadBadRequestCode is the HTTP code returned for type ReplaceCrtLoadBadRequest +const ReplaceCrtLoadBadRequestCode int = 400 + +/* +ReplaceCrtLoadBadRequest Bad request + +swagger:response replaceCrtLoadBadRequest +*/ +type ReplaceCrtLoadBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCrtLoadBadRequest creates ReplaceCrtLoadBadRequest with default headers values +func NewReplaceCrtLoadBadRequest() *ReplaceCrtLoadBadRequest { + + return &ReplaceCrtLoadBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace crt load bad request response +func (o *ReplaceCrtLoadBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceCrtLoadBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace crt load bad request response +func (o *ReplaceCrtLoadBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace crt load bad request response +func (o *ReplaceCrtLoadBadRequest) WithPayload(payload *models.Error) *ReplaceCrtLoadBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace crt load bad request response +func (o *ReplaceCrtLoadBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCrtLoadBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceCrtLoadNotFoundCode is the HTTP code returned for type ReplaceCrtLoadNotFound +const ReplaceCrtLoadNotFoundCode int = 404 + +/* +ReplaceCrtLoadNotFound The specified resource was not found + +swagger:response replaceCrtLoadNotFound +*/ +type ReplaceCrtLoadNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCrtLoadNotFound creates ReplaceCrtLoadNotFound with default headers values +func NewReplaceCrtLoadNotFound() *ReplaceCrtLoadNotFound { + + return &ReplaceCrtLoadNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace crt load not found response +func (o *ReplaceCrtLoadNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceCrtLoadNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace crt load not found response +func (o *ReplaceCrtLoadNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace crt load not found response +func (o *ReplaceCrtLoadNotFound) WithPayload(payload *models.Error) *ReplaceCrtLoadNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace crt load not found response +func (o *ReplaceCrtLoadNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCrtLoadNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceCrtLoadDefault General Error + +swagger:response replaceCrtLoadDefault +*/ +type ReplaceCrtLoadDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCrtLoadDefault creates ReplaceCrtLoadDefault with default headers values +func NewReplaceCrtLoadDefault(code int) *ReplaceCrtLoadDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceCrtLoadDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace crt load default response +func (o *ReplaceCrtLoadDefault) WithStatusCode(code int) *ReplaceCrtLoadDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace crt load default response +func (o *ReplaceCrtLoadDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace crt load default response +func (o *ReplaceCrtLoadDefault) WithConfigurationVersion(configurationVersion string) *ReplaceCrtLoadDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace crt load default response +func (o *ReplaceCrtLoadDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace crt load default response +func (o *ReplaceCrtLoadDefault) WithPayload(payload *models.Error) *ReplaceCrtLoadDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace crt load default response +func (o *ReplaceCrtLoadDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCrtLoadDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_load/replace_crt_load_urlbuilder.go b/operations/crt_load/replace_crt_load_urlbuilder.go new file mode 100644 index 00000000..8fbfad4b --- /dev/null +++ b/operations/crt_load/replace_crt_load_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_load + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceCrtLoadURL generates an URL for the replace crt load operation +type ReplaceCrtLoadURL struct { + Certificate string + + CrtStore string + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCrtLoadURL) WithBasePath(bp string) *ReplaceCrtLoadURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCrtLoadURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceCrtLoadURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_loads/{certificate}" + + certificate := o.Certificate + if certificate != "" { + _path = strings.Replace(_path, "{certificate}", certificate, -1) + } else { + return nil, errors.New("certificate is required on ReplaceCrtLoadURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + crtStoreQ := o.CrtStore + if crtStoreQ != "" { + qs.Set("crt_store", crtStoreQ) + } + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceCrtLoadURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceCrtLoadURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceCrtLoadURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceCrtLoadURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceCrtLoadURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceCrtLoadURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_store/create_crt_store.go b/operations/crt_store/create_crt_store.go new file mode 100644 index 00000000..f82d739c --- /dev/null +++ b/operations/crt_store/create_crt_store.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateCrtStoreHandlerFunc turns a function with the right signature into a create crt store handler +type CreateCrtStoreHandlerFunc func(CreateCrtStoreParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateCrtStoreHandlerFunc) Handle(params CreateCrtStoreParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateCrtStoreHandler interface for that can handle valid create crt store params +type CreateCrtStoreHandler interface { + Handle(CreateCrtStoreParams, interface{}) middleware.Responder +} + +// NewCreateCrtStore creates a new http.Handler for the create crt store operation +func NewCreateCrtStore(ctx *middleware.Context, handler CreateCrtStoreHandler) *CreateCrtStore { + return &CreateCrtStore{Context: ctx, Handler: handler} +} + +/* + CreateCrtStore swagger:route POST /services/haproxy/configuration/crt_stores CrtStore createCrtStore + +# Add a new Certificate Store + +Creates a new crt_store section +*/ +type CreateCrtStore struct { + Context *middleware.Context + Handler CreateCrtStoreHandler +} + +func (o *CreateCrtStore) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateCrtStoreParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_store/create_crt_store_parameters.go b/operations/crt_store/create_crt_store_parameters.go new file mode 100644 index 00000000..74f66a48 --- /dev/null +++ b/operations/crt_store/create_crt_store_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateCrtStoreParams creates a new CreateCrtStoreParams object +// with the default values initialized. +func NewCreateCrtStoreParams() CreateCrtStoreParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateCrtStoreParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateCrtStoreParams contains all the bound params for the create crt store operation +// typically these are obtained from a http.Request +// +// swagger:parameters createCrtStore +type CreateCrtStoreParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.CrtStore + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateCrtStoreParams() beforehand. +func (o *CreateCrtStoreParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.CrtStore + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateCrtStoreParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateCrtStoreParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateCrtStoreParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateCrtStoreParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/crt_store/create_crt_store_responses.go b/operations/crt_store/create_crt_store_responses.go new file mode 100644 index 00000000..e24ec350 --- /dev/null +++ b/operations/crt_store/create_crt_store_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateCrtStoreCreatedCode is the HTTP code returned for type CreateCrtStoreCreated +const CreateCrtStoreCreatedCode int = 201 + +/* +CreateCrtStoreCreated Certificate Store created + +swagger:response createCrtStoreCreated +*/ +type CreateCrtStoreCreated struct { + + /* + In: Body + */ + Payload *models.CrtStore `json:"body,omitempty"` +} + +// NewCreateCrtStoreCreated creates CreateCrtStoreCreated with default headers values +func NewCreateCrtStoreCreated() *CreateCrtStoreCreated { + + return &CreateCrtStoreCreated{} +} + +// WithPayload adds the payload to the create crt store created response +func (o *CreateCrtStoreCreated) WithPayload(payload *models.CrtStore) *CreateCrtStoreCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt store created response +func (o *CreateCrtStoreCreated) SetPayload(payload *models.CrtStore) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtStoreCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCrtStoreAcceptedCode is the HTTP code returned for type CreateCrtStoreAccepted +const CreateCrtStoreAcceptedCode int = 202 + +/* +CreateCrtStoreAccepted Configuration change accepted and reload requested + +swagger:response createCrtStoreAccepted +*/ +type CreateCrtStoreAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.CrtStore `json:"body,omitempty"` +} + +// NewCreateCrtStoreAccepted creates CreateCrtStoreAccepted with default headers values +func NewCreateCrtStoreAccepted() *CreateCrtStoreAccepted { + + return &CreateCrtStoreAccepted{} +} + +// WithReloadID adds the reloadId to the create crt store accepted response +func (o *CreateCrtStoreAccepted) WithReloadID(reloadID string) *CreateCrtStoreAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create crt store accepted response +func (o *CreateCrtStoreAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create crt store accepted response +func (o *CreateCrtStoreAccepted) WithPayload(payload *models.CrtStore) *CreateCrtStoreAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt store accepted response +func (o *CreateCrtStoreAccepted) SetPayload(payload *models.CrtStore) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtStoreAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCrtStoreBadRequestCode is the HTTP code returned for type CreateCrtStoreBadRequest +const CreateCrtStoreBadRequestCode int = 400 + +/* +CreateCrtStoreBadRequest Bad request + +swagger:response createCrtStoreBadRequest +*/ +type CreateCrtStoreBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrtStoreBadRequest creates CreateCrtStoreBadRequest with default headers values +func NewCreateCrtStoreBadRequest() *CreateCrtStoreBadRequest { + + return &CreateCrtStoreBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create crt store bad request response +func (o *CreateCrtStoreBadRequest) WithConfigurationVersion(configurationVersion string) *CreateCrtStoreBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crt store bad request response +func (o *CreateCrtStoreBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crt store bad request response +func (o *CreateCrtStoreBadRequest) WithPayload(payload *models.Error) *CreateCrtStoreBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt store bad request response +func (o *CreateCrtStoreBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtStoreBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCrtStoreConflictCode is the HTTP code returned for type CreateCrtStoreConflict +const CreateCrtStoreConflictCode int = 409 + +/* +CreateCrtStoreConflict The specified resource already exists + +swagger:response createCrtStoreConflict +*/ +type CreateCrtStoreConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrtStoreConflict creates CreateCrtStoreConflict with default headers values +func NewCreateCrtStoreConflict() *CreateCrtStoreConflict { + + return &CreateCrtStoreConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create crt store conflict response +func (o *CreateCrtStoreConflict) WithConfigurationVersion(configurationVersion string) *CreateCrtStoreConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crt store conflict response +func (o *CreateCrtStoreConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crt store conflict response +func (o *CreateCrtStoreConflict) WithPayload(payload *models.Error) *CreateCrtStoreConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt store conflict response +func (o *CreateCrtStoreConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtStoreConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateCrtStoreDefault General Error + +swagger:response createCrtStoreDefault +*/ +type CreateCrtStoreDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrtStoreDefault creates CreateCrtStoreDefault with default headers values +func NewCreateCrtStoreDefault(code int) *CreateCrtStoreDefault { + if code <= 0 { + code = 500 + } + + return &CreateCrtStoreDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create crt store default response +func (o *CreateCrtStoreDefault) WithStatusCode(code int) *CreateCrtStoreDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create crt store default response +func (o *CreateCrtStoreDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create crt store default response +func (o *CreateCrtStoreDefault) WithConfigurationVersion(configurationVersion string) *CreateCrtStoreDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crt store default response +func (o *CreateCrtStoreDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crt store default response +func (o *CreateCrtStoreDefault) WithPayload(payload *models.Error) *CreateCrtStoreDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crt store default response +func (o *CreateCrtStoreDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrtStoreDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_store/create_crt_store_urlbuilder.go b/operations/crt_store/create_crt_store_urlbuilder.go new file mode 100644 index 00000000..1701a055 --- /dev/null +++ b/operations/crt_store/create_crt_store_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateCrtStoreURL generates an URL for the create crt store operation +type CreateCrtStoreURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCrtStoreURL) WithBasePath(bp string) *CreateCrtStoreURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCrtStoreURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateCrtStoreURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_stores" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateCrtStoreURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateCrtStoreURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateCrtStoreURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateCrtStoreURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateCrtStoreURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateCrtStoreURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_store/delete_crt_store.go b/operations/crt_store/delete_crt_store.go new file mode 100644 index 00000000..b2ce927a --- /dev/null +++ b/operations/crt_store/delete_crt_store.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCrtStoreHandlerFunc turns a function with the right signature into a delete crt store handler +type DeleteCrtStoreHandlerFunc func(DeleteCrtStoreParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCrtStoreHandlerFunc) Handle(params DeleteCrtStoreParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteCrtStoreHandler interface for that can handle valid delete crt store params +type DeleteCrtStoreHandler interface { + Handle(DeleteCrtStoreParams, interface{}) middleware.Responder +} + +// NewDeleteCrtStore creates a new http.Handler for the delete crt store operation +func NewDeleteCrtStore(ctx *middleware.Context, handler DeleteCrtStoreHandler) *DeleteCrtStore { + return &DeleteCrtStore{Context: ctx, Handler: handler} +} + +/* + DeleteCrtStore swagger:route DELETE /services/haproxy/configuration/crt_stores/{name} CrtStore deleteCrtStore + +# Delete a Certificate Store + +Deletes a crt_store section from the configuration +*/ +type DeleteCrtStore struct { + Context *middleware.Context + Handler DeleteCrtStoreHandler +} + +func (o *DeleteCrtStore) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCrtStoreParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_store/delete_crt_store_parameters.go b/operations/crt_store/delete_crt_store_parameters.go new file mode 100644 index 00000000..4d40a3a9 --- /dev/null +++ b/operations/crt_store/delete_crt_store_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteCrtStoreParams creates a new DeleteCrtStoreParams object +// with the default values initialized. +func NewDeleteCrtStoreParams() DeleteCrtStoreParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteCrtStoreParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteCrtStoreParams contains all the bound params for the delete crt store operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCrtStore +type DeleteCrtStoreParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*crt_store name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCrtStoreParams() beforehand. +func (o *DeleteCrtStoreParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteCrtStoreParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteCrtStoreParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteCrtStoreParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteCrtStoreParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteCrtStoreParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/crt_store/delete_crt_store_responses.go b/operations/crt_store/delete_crt_store_responses.go new file mode 100644 index 00000000..8e70603f --- /dev/null +++ b/operations/crt_store/delete_crt_store_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteCrtStoreAcceptedCode is the HTTP code returned for type DeleteCrtStoreAccepted +const DeleteCrtStoreAcceptedCode int = 202 + +/* +DeleteCrtStoreAccepted Configuration change accepted and reload requested + +swagger:response deleteCrtStoreAccepted +*/ +type DeleteCrtStoreAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteCrtStoreAccepted creates DeleteCrtStoreAccepted with default headers values +func NewDeleteCrtStoreAccepted() *DeleteCrtStoreAccepted { + + return &DeleteCrtStoreAccepted{} +} + +// WithReloadID adds the reloadId to the delete crt store accepted response +func (o *DeleteCrtStoreAccepted) WithReloadID(reloadID string) *DeleteCrtStoreAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete crt store accepted response +func (o *DeleteCrtStoreAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteCrtStoreAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteCrtStoreNoContentCode is the HTTP code returned for type DeleteCrtStoreNoContent +const DeleteCrtStoreNoContentCode int = 204 + +/* +DeleteCrtStoreNoContent crt_store deleted + +swagger:response deleteCrtStoreNoContent +*/ +type DeleteCrtStoreNoContent struct { +} + +// NewDeleteCrtStoreNoContent creates DeleteCrtStoreNoContent with default headers values +func NewDeleteCrtStoreNoContent() *DeleteCrtStoreNoContent { + + return &DeleteCrtStoreNoContent{} +} + +// WriteResponse to the client +func (o *DeleteCrtStoreNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteCrtStoreNotFoundCode is the HTTP code returned for type DeleteCrtStoreNotFound +const DeleteCrtStoreNotFoundCode int = 404 + +/* +DeleteCrtStoreNotFound The specified resource was not found + +swagger:response deleteCrtStoreNotFound +*/ +type DeleteCrtStoreNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrtStoreNotFound creates DeleteCrtStoreNotFound with default headers values +func NewDeleteCrtStoreNotFound() *DeleteCrtStoreNotFound { + + return &DeleteCrtStoreNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete crt store not found response +func (o *DeleteCrtStoreNotFound) WithConfigurationVersion(configurationVersion string) *DeleteCrtStoreNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crt store not found response +func (o *DeleteCrtStoreNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crt store not found response +func (o *DeleteCrtStoreNotFound) WithPayload(payload *models.Error) *DeleteCrtStoreNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crt store not found response +func (o *DeleteCrtStoreNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrtStoreNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteCrtStoreDefault General Error + +swagger:response deleteCrtStoreDefault +*/ +type DeleteCrtStoreDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrtStoreDefault creates DeleteCrtStoreDefault with default headers values +func NewDeleteCrtStoreDefault(code int) *DeleteCrtStoreDefault { + if code <= 0 { + code = 500 + } + + return &DeleteCrtStoreDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete crt store default response +func (o *DeleteCrtStoreDefault) WithStatusCode(code int) *DeleteCrtStoreDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete crt store default response +func (o *DeleteCrtStoreDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete crt store default response +func (o *DeleteCrtStoreDefault) WithConfigurationVersion(configurationVersion string) *DeleteCrtStoreDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crt store default response +func (o *DeleteCrtStoreDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crt store default response +func (o *DeleteCrtStoreDefault) WithPayload(payload *models.Error) *DeleteCrtStoreDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crt store default response +func (o *DeleteCrtStoreDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrtStoreDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_store/delete_crt_store_urlbuilder.go b/operations/crt_store/delete_crt_store_urlbuilder.go new file mode 100644 index 00000000..907ce75d --- /dev/null +++ b/operations/crt_store/delete_crt_store_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteCrtStoreURL generates an URL for the delete crt store operation +type DeleteCrtStoreURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrtStoreURL) WithBasePath(bp string) *DeleteCrtStoreURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrtStoreURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCrtStoreURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_stores/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteCrtStoreURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCrtStoreURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCrtStoreURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCrtStoreURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCrtStoreURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCrtStoreURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCrtStoreURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_store/edit_crt_store.go b/operations/crt_store/edit_crt_store.go new file mode 100644 index 00000000..13b0ca40 --- /dev/null +++ b/operations/crt_store/edit_crt_store.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// EditCrtStoreHandlerFunc turns a function with the right signature into a edit crt store handler +type EditCrtStoreHandlerFunc func(EditCrtStoreParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn EditCrtStoreHandlerFunc) Handle(params EditCrtStoreParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// EditCrtStoreHandler interface for that can handle valid edit crt store params +type EditCrtStoreHandler interface { + Handle(EditCrtStoreParams, interface{}) middleware.Responder +} + +// NewEditCrtStore creates a new http.Handler for the edit crt store operation +func NewEditCrtStore(ctx *middleware.Context, handler EditCrtStoreHandler) *EditCrtStore { + return &EditCrtStore{Context: ctx, Handler: handler} +} + +/* + EditCrtStore swagger:route PUT /services/haproxy/configuration/crt_stores/{name} CrtStore editCrtStore + +# Modify a Certificate Store + +Modifies a crt_store's configuration by its name +*/ +type EditCrtStore struct { + Context *middleware.Context + Handler EditCrtStoreHandler +} + +func (o *EditCrtStore) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewEditCrtStoreParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_store/edit_crt_store_parameters.go b/operations/crt_store/edit_crt_store_parameters.go new file mode 100644 index 00000000..e1a6c098 --- /dev/null +++ b/operations/crt_store/edit_crt_store_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewEditCrtStoreParams creates a new EditCrtStoreParams object +// with the default values initialized. +func NewEditCrtStoreParams() EditCrtStoreParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return EditCrtStoreParams{ + ForceReload: &forceReloadDefault, + } +} + +// EditCrtStoreParams contains all the bound params for the edit crt store operation +// typically these are obtained from a http.Request +// +// swagger:parameters editCrtStore +type EditCrtStoreParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.CrtStore + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*crt_store name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewEditCrtStoreParams() beforehand. +func (o *EditCrtStoreParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.CrtStore + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *EditCrtStoreParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewEditCrtStoreParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *EditCrtStoreParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *EditCrtStoreParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *EditCrtStoreParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/crt_store/edit_crt_store_responses.go b/operations/crt_store/edit_crt_store_responses.go new file mode 100644 index 00000000..65c094c2 --- /dev/null +++ b/operations/crt_store/edit_crt_store_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// EditCrtStoreOKCode is the HTTP code returned for type EditCrtStoreOK +const EditCrtStoreOKCode int = 200 + +/* +EditCrtStoreOK crt_store configuration updated + +swagger:response editCrtStoreOK +*/ +type EditCrtStoreOK struct { + + /* + In: Body + */ + Payload *models.CrtStore `json:"body,omitempty"` +} + +// NewEditCrtStoreOK creates EditCrtStoreOK with default headers values +func NewEditCrtStoreOK() *EditCrtStoreOK { + + return &EditCrtStoreOK{} +} + +// WithPayload adds the payload to the edit crt store o k response +func (o *EditCrtStoreOK) WithPayload(payload *models.CrtStore) *EditCrtStoreOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit crt store o k response +func (o *EditCrtStoreOK) SetPayload(payload *models.CrtStore) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditCrtStoreOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditCrtStoreAcceptedCode is the HTTP code returned for type EditCrtStoreAccepted +const EditCrtStoreAcceptedCode int = 202 + +/* +EditCrtStoreAccepted Configuration change accepted and reload requested + +swagger:response editCrtStoreAccepted +*/ +type EditCrtStoreAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.CrtStore `json:"body,omitempty"` +} + +// NewEditCrtStoreAccepted creates EditCrtStoreAccepted with default headers values +func NewEditCrtStoreAccepted() *EditCrtStoreAccepted { + + return &EditCrtStoreAccepted{} +} + +// WithReloadID adds the reloadId to the edit crt store accepted response +func (o *EditCrtStoreAccepted) WithReloadID(reloadID string) *EditCrtStoreAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the edit crt store accepted response +func (o *EditCrtStoreAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the edit crt store accepted response +func (o *EditCrtStoreAccepted) WithPayload(payload *models.CrtStore) *EditCrtStoreAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit crt store accepted response +func (o *EditCrtStoreAccepted) SetPayload(payload *models.CrtStore) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditCrtStoreAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditCrtStoreBadRequestCode is the HTTP code returned for type EditCrtStoreBadRequest +const EditCrtStoreBadRequestCode int = 400 + +/* +EditCrtStoreBadRequest Bad request + +swagger:response editCrtStoreBadRequest +*/ +type EditCrtStoreBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditCrtStoreBadRequest creates EditCrtStoreBadRequest with default headers values +func NewEditCrtStoreBadRequest() *EditCrtStoreBadRequest { + + return &EditCrtStoreBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit crt store bad request response +func (o *EditCrtStoreBadRequest) WithConfigurationVersion(configurationVersion string) *EditCrtStoreBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit crt store bad request response +func (o *EditCrtStoreBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit crt store bad request response +func (o *EditCrtStoreBadRequest) WithPayload(payload *models.Error) *EditCrtStoreBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit crt store bad request response +func (o *EditCrtStoreBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditCrtStoreBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditCrtStoreNotFoundCode is the HTTP code returned for type EditCrtStoreNotFound +const EditCrtStoreNotFoundCode int = 404 + +/* +EditCrtStoreNotFound The specified resource was not found + +swagger:response editCrtStoreNotFound +*/ +type EditCrtStoreNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditCrtStoreNotFound creates EditCrtStoreNotFound with default headers values +func NewEditCrtStoreNotFound() *EditCrtStoreNotFound { + + return &EditCrtStoreNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit crt store not found response +func (o *EditCrtStoreNotFound) WithConfigurationVersion(configurationVersion string) *EditCrtStoreNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit crt store not found response +func (o *EditCrtStoreNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit crt store not found response +func (o *EditCrtStoreNotFound) WithPayload(payload *models.Error) *EditCrtStoreNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit crt store not found response +func (o *EditCrtStoreNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditCrtStoreNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +EditCrtStoreDefault General Error + +swagger:response editCrtStoreDefault +*/ +type EditCrtStoreDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditCrtStoreDefault creates EditCrtStoreDefault with default headers values +func NewEditCrtStoreDefault(code int) *EditCrtStoreDefault { + if code <= 0 { + code = 500 + } + + return &EditCrtStoreDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the edit crt store default response +func (o *EditCrtStoreDefault) WithStatusCode(code int) *EditCrtStoreDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the edit crt store default response +func (o *EditCrtStoreDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the edit crt store default response +func (o *EditCrtStoreDefault) WithConfigurationVersion(configurationVersion string) *EditCrtStoreDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit crt store default response +func (o *EditCrtStoreDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit crt store default response +func (o *EditCrtStoreDefault) WithPayload(payload *models.Error) *EditCrtStoreDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit crt store default response +func (o *EditCrtStoreDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditCrtStoreDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_store/edit_crt_store_urlbuilder.go b/operations/crt_store/edit_crt_store_urlbuilder.go new file mode 100644 index 00000000..bd409ac0 --- /dev/null +++ b/operations/crt_store/edit_crt_store_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// EditCrtStoreURL generates an URL for the edit crt store operation +type EditCrtStoreURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditCrtStoreURL) WithBasePath(bp string) *EditCrtStoreURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditCrtStoreURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *EditCrtStoreURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_stores/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on EditCrtStoreURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *EditCrtStoreURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *EditCrtStoreURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *EditCrtStoreURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on EditCrtStoreURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on EditCrtStoreURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *EditCrtStoreURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_store/get_crt_store.go b/operations/crt_store/get_crt_store.go new file mode 100644 index 00000000..fb4dfc78 --- /dev/null +++ b/operations/crt_store/get_crt_store.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCrtStoreHandlerFunc turns a function with the right signature into a get crt store handler +type GetCrtStoreHandlerFunc func(GetCrtStoreParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCrtStoreHandlerFunc) Handle(params GetCrtStoreParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCrtStoreHandler interface for that can handle valid get crt store params +type GetCrtStoreHandler interface { + Handle(GetCrtStoreParams, interface{}) middleware.Responder +} + +// NewGetCrtStore creates a new http.Handler for the get crt store operation +func NewGetCrtStore(ctx *middleware.Context, handler GetCrtStoreHandler) *GetCrtStore { + return &GetCrtStore{Context: ctx, Handler: handler} +} + +/* + GetCrtStore swagger:route GET /services/haproxy/configuration/crt_stores/{name} CrtStore getCrtStore + +# Return a Certificate Store + +Returns crt_store section by its name +*/ +type GetCrtStore struct { + Context *middleware.Context + Handler GetCrtStoreHandler +} + +func (o *GetCrtStore) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCrtStoreParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_store/get_crt_store_parameters.go b/operations/crt_store/get_crt_store_parameters.go new file mode 100644 index 00000000..e24fe0b8 --- /dev/null +++ b/operations/crt_store/get_crt_store_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetCrtStoreParams creates a new GetCrtStoreParams object +// +// There are no default values defined in the spec. +func NewGetCrtStoreParams() GetCrtStoreParams { + + return GetCrtStoreParams{} +} + +// GetCrtStoreParams contains all the bound params for the get crt store operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCrtStore +type GetCrtStoreParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*crt_store name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCrtStoreParams() beforehand. +func (o *GetCrtStoreParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetCrtStoreParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetCrtStoreParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/crt_store/get_crt_store_responses.go b/operations/crt_store/get_crt_store_responses.go new file mode 100644 index 00000000..12d0d7fc --- /dev/null +++ b/operations/crt_store/get_crt_store_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCrtStoreOKCode is the HTTP code returned for type GetCrtStoreOK +const GetCrtStoreOKCode int = 200 + +/* +GetCrtStoreOK Successful operation + +swagger:response getCrtStoreOK +*/ +type GetCrtStoreOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.CrtStore `json:"body,omitempty"` +} + +// NewGetCrtStoreOK creates GetCrtStoreOK with default headers values +func NewGetCrtStoreOK() *GetCrtStoreOK { + + return &GetCrtStoreOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get crt store o k response +func (o *GetCrtStoreOK) WithConfigurationVersion(configurationVersion string) *GetCrtStoreOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt store o k response +func (o *GetCrtStoreOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt store o k response +func (o *GetCrtStoreOK) WithPayload(payload *models.CrtStore) *GetCrtStoreOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt store o k response +func (o *GetCrtStoreOK) SetPayload(payload *models.CrtStore) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtStoreOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetCrtStoreNotFoundCode is the HTTP code returned for type GetCrtStoreNotFound +const GetCrtStoreNotFoundCode int = 404 + +/* +GetCrtStoreNotFound The specified resource was not found + +swagger:response getCrtStoreNotFound +*/ +type GetCrtStoreNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrtStoreNotFound creates GetCrtStoreNotFound with default headers values +func NewGetCrtStoreNotFound() *GetCrtStoreNotFound { + + return &GetCrtStoreNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get crt store not found response +func (o *GetCrtStoreNotFound) WithConfigurationVersion(configurationVersion string) *GetCrtStoreNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt store not found response +func (o *GetCrtStoreNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt store not found response +func (o *GetCrtStoreNotFound) WithPayload(payload *models.Error) *GetCrtStoreNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt store not found response +func (o *GetCrtStoreNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtStoreNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetCrtStoreDefault General Error + +swagger:response getCrtStoreDefault +*/ +type GetCrtStoreDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrtStoreDefault creates GetCrtStoreDefault with default headers values +func NewGetCrtStoreDefault(code int) *GetCrtStoreDefault { + if code <= 0 { + code = 500 + } + + return &GetCrtStoreDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get crt store default response +func (o *GetCrtStoreDefault) WithStatusCode(code int) *GetCrtStoreDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get crt store default response +func (o *GetCrtStoreDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get crt store default response +func (o *GetCrtStoreDefault) WithConfigurationVersion(configurationVersion string) *GetCrtStoreDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt store default response +func (o *GetCrtStoreDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt store default response +func (o *GetCrtStoreDefault) WithPayload(payload *models.Error) *GetCrtStoreDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt store default response +func (o *GetCrtStoreDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtStoreDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_store/get_crt_store_urlbuilder.go b/operations/crt_store/get_crt_store_urlbuilder.go new file mode 100644 index 00000000..cbafc2db --- /dev/null +++ b/operations/crt_store/get_crt_store_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetCrtStoreURL generates an URL for the get crt store operation +type GetCrtStoreURL struct { + Name string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtStoreURL) WithBasePath(bp string) *GetCrtStoreURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtStoreURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCrtStoreURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_stores/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetCrtStoreURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCrtStoreURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCrtStoreURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCrtStoreURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCrtStoreURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCrtStoreURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCrtStoreURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/crt_store/get_crt_stores.go b/operations/crt_store/get_crt_stores.go new file mode 100644 index 00000000..f6b4a47e --- /dev/null +++ b/operations/crt_store/get_crt_stores.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCrtStoresHandlerFunc turns a function with the right signature into a get crt stores handler +type GetCrtStoresHandlerFunc func(GetCrtStoresParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCrtStoresHandlerFunc) Handle(params GetCrtStoresParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCrtStoresHandler interface for that can handle valid get crt stores params +type GetCrtStoresHandler interface { + Handle(GetCrtStoresParams, interface{}) middleware.Responder +} + +// NewGetCrtStores creates a new http.Handler for the get crt stores operation +func NewGetCrtStores(ctx *middleware.Context, handler GetCrtStoresHandler) *GetCrtStores { + return &GetCrtStores{Context: ctx, Handler: handler} +} + +/* + GetCrtStores swagger:route GET /services/haproxy/configuration/crt_stores CrtStore getCrtStores + +# Return all the Certificate Stores + +Returns an array of all the configured crt_store sections in HAProxy +*/ +type GetCrtStores struct { + Context *middleware.Context + Handler GetCrtStoresHandler +} + +func (o *GetCrtStores) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCrtStoresParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/crt_store/get_crt_stores_parameters.go b/operations/crt_store/get_crt_stores_parameters.go new file mode 100644 index 00000000..7a9fe822 --- /dev/null +++ b/operations/crt_store/get_crt_stores_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetCrtStoresParams creates a new GetCrtStoresParams object +// +// There are no default values defined in the spec. +func NewGetCrtStoresParams() GetCrtStoresParams { + + return GetCrtStoresParams{} +} + +// GetCrtStoresParams contains all the bound params for the get crt stores operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCrtStores +type GetCrtStoresParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCrtStoresParams() beforehand. +func (o *GetCrtStoresParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetCrtStoresParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/crt_store/get_crt_stores_responses.go b/operations/crt_store/get_crt_stores_responses.go new file mode 100644 index 00000000..159f1bc8 --- /dev/null +++ b/operations/crt_store/get_crt_stores_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCrtStoresOKCode is the HTTP code returned for type GetCrtStoresOK +const GetCrtStoresOKCode int = 200 + +/* +GetCrtStoresOK Successful operation + +swagger:response getCrtStoresOK +*/ +type GetCrtStoresOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.CrtStores `json:"body,omitempty"` +} + +// NewGetCrtStoresOK creates GetCrtStoresOK with default headers values +func NewGetCrtStoresOK() *GetCrtStoresOK { + + return &GetCrtStoresOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get crt stores o k response +func (o *GetCrtStoresOK) WithConfigurationVersion(configurationVersion string) *GetCrtStoresOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt stores o k response +func (o *GetCrtStoresOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt stores o k response +func (o *GetCrtStoresOK) WithPayload(payload models.CrtStores) *GetCrtStoresOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt stores o k response +func (o *GetCrtStoresOK) SetPayload(payload models.CrtStores) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtStoresOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.CrtStores{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetCrtStoresDefault General Error + +swagger:response getCrtStoresDefault +*/ +type GetCrtStoresDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrtStoresDefault creates GetCrtStoresDefault with default headers values +func NewGetCrtStoresDefault(code int) *GetCrtStoresDefault { + if code <= 0 { + code = 500 + } + + return &GetCrtStoresDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get crt stores default response +func (o *GetCrtStoresDefault) WithStatusCode(code int) *GetCrtStoresDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get crt stores default response +func (o *GetCrtStoresDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get crt stores default response +func (o *GetCrtStoresDefault) WithConfigurationVersion(configurationVersion string) *GetCrtStoresDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crt stores default response +func (o *GetCrtStoresDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crt stores default response +func (o *GetCrtStoresDefault) WithPayload(payload *models.Error) *GetCrtStoresDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crt stores default response +func (o *GetCrtStoresDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrtStoresDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/crt_store/get_crt_stores_urlbuilder.go b/operations/crt_store/get_crt_stores_urlbuilder.go new file mode 100644 index 00000000..ab7c0f86 --- /dev/null +++ b/operations/crt_store/get_crt_stores_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package crt_store + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetCrtStoresURL generates an URL for the get crt stores operation +type GetCrtStoresURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtStoresURL) WithBasePath(bp string) *GetCrtStoresURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrtStoresURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCrtStoresURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/crt_stores" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCrtStoresURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCrtStoresURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCrtStoresURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCrtStoresURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCrtStoresURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCrtStoresURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/data_plane_api.go b/operations/data_plane_api.go index 54690802..ab8ede94 100644 --- a/operations/data_plane_api.go +++ b/operations/data_plane_api.go @@ -25,39 +25,81 @@ import ( "net/http" "strings" - errors "github.com/go-openapi/errors" - loads "github.com/go-openapi/loads" - runtime "github.com/go-openapi/runtime" - middleware "github.com/go-openapi/runtime/middleware" - security "github.com/go-openapi/runtime/security" - spec "github.com/go-openapi/spec" - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/haproxytech/dataplaneapi/operations/acl" + "github.com/haproxytech/dataplaneapi/operations/acl_runtime" + "github.com/haproxytech/dataplaneapi/operations/acme" + "github.com/haproxytech/dataplaneapi/operations/acme_runtime" "github.com/haproxytech/dataplaneapi/operations/backend" "github.com/haproxytech/dataplaneapi/operations/backend_switching_rule" "github.com/haproxytech/dataplaneapi/operations/bind" + "github.com/haproxytech/dataplaneapi/operations/cache" + "github.com/haproxytech/dataplaneapi/operations/cluster" "github.com/haproxytech/dataplaneapi/operations/configuration" + "github.com/haproxytech/dataplaneapi/operations/crt_load" + "github.com/haproxytech/dataplaneapi/operations/crt_store" + "github.com/haproxytech/dataplaneapi/operations/declare_capture" "github.com/haproxytech/dataplaneapi/operations/defaults" + "github.com/haproxytech/dataplaneapi/operations/dgram_bind" "github.com/haproxytech/dataplaneapi/operations/discovery" + "github.com/haproxytech/dataplaneapi/operations/fcgi_app" "github.com/haproxytech/dataplaneapi/operations/filter" "github.com/haproxytech/dataplaneapi/operations/frontend" "github.com/haproxytech/dataplaneapi/operations/global" + "github.com/haproxytech/dataplaneapi/operations/group" + "github.com/haproxytech/dataplaneapi/operations/health" + "github.com/haproxytech/dataplaneapi/operations/http_after_response_rule" + "github.com/haproxytech/dataplaneapi/operations/http_check" + "github.com/haproxytech/dataplaneapi/operations/http_error_rule" + "github.com/haproxytech/dataplaneapi/operations/http_errors" "github.com/haproxytech/dataplaneapi/operations/http_request_rule" "github.com/haproxytech/dataplaneapi/operations/http_response_rule" "github.com/haproxytech/dataplaneapi/operations/information" + "github.com/haproxytech/dataplaneapi/operations/log_forward" + "github.com/haproxytech/dataplaneapi/operations/log_profile" "github.com/haproxytech/dataplaneapi/operations/log_target" + "github.com/haproxytech/dataplaneapi/operations/mailer_entry" + "github.com/haproxytech/dataplaneapi/operations/mailers" + "github.com/haproxytech/dataplaneapi/operations/maps" + "github.com/haproxytech/dataplaneapi/operations/nameserver" + "github.com/haproxytech/dataplaneapi/operations/peer" + "github.com/haproxytech/dataplaneapi/operations/peer_entry" + "github.com/haproxytech/dataplaneapi/operations/process_manager" + "github.com/haproxytech/dataplaneapi/operations/quic_initial_rule" "github.com/haproxytech/dataplaneapi/operations/reloads" - "github.com/haproxytech/dataplaneapi/operations/server" + "github.com/haproxytech/dataplaneapi/operations/resolver" + "github.com/haproxytech/dataplaneapi/operations/ring" + "github.com/haproxytech/dataplaneapi/operations/s_s_l_front_use" + "github.com/haproxytech/dataplaneapi/operations/s_s_l_runtime" + serverops "github.com/haproxytech/dataplaneapi/operations/server" "github.com/haproxytech/dataplaneapi/operations/server_switching_rule" + "github.com/haproxytech/dataplaneapi/operations/server_template" + "github.com/haproxytech/dataplaneapi/operations/service_discovery" "github.com/haproxytech/dataplaneapi/operations/sites" "github.com/haproxytech/dataplaneapi/operations/specification" + "github.com/haproxytech/dataplaneapi/operations/specification_openapiv3" + "github.com/haproxytech/dataplaneapi/operations/spoe" + "github.com/haproxytech/dataplaneapi/operations/spoe_transactions" "github.com/haproxytech/dataplaneapi/operations/stats" "github.com/haproxytech/dataplaneapi/operations/stick_rule" + "github.com/haproxytech/dataplaneapi/operations/stick_table" + "github.com/haproxytech/dataplaneapi/operations/storage" + "github.com/haproxytech/dataplaneapi/operations/table" + "github.com/haproxytech/dataplaneapi/operations/tcp_check" "github.com/haproxytech/dataplaneapi/operations/tcp_request_rule" "github.com/haproxytech/dataplaneapi/operations/tcp_response_rule" + "github.com/haproxytech/dataplaneapi/operations/traces" "github.com/haproxytech/dataplaneapi/operations/transactions" + "github.com/haproxytech/dataplaneapi/operations/user" + "github.com/haproxytech/dataplaneapi/operations/userlist" ) // NewDataPlaneAPI creates a new DataPlane instance @@ -69,1615 +111,6825 @@ func NewDataPlaneAPI(spec *loads.Document) *DataPlaneAPI { defaultProduces: "application/json", customConsumers: make(map[string]runtime.Consumer), customProducers: make(map[string]runtime.Producer), + PreServerShutdown: func() {}, ServerShutdown: func() {}, spec: spec, + useSwaggerUI: false, ServeError: errors.ServeError, BasicAuthenticator: security.BasicAuth, APIKeyAuthenticator: security.APIKeyAuth, BearerAuthenticator: security.BearerAuth, - JSONConsumer: runtime.JSONConsumer(), - TxtConsumer: runtime.TextConsumer(), - JSONProducer: runtime.JSONProducer(), - TxtProducer: runtime.TextProducer(), + + JSONConsumer: runtime.JSONConsumer(), + MultipartformConsumer: runtime.DiscardConsumer, + TxtConsumer: runtime.TextConsumer(), + + BinProducer: runtime.ByteStreamProducer(), + JSONProducer: runtime.JSONProducer(), + TxtProducer: runtime.TextProducer(), + + StorageCreateStorageSSLCrtListEntryHandler: storage.CreateStorageSSLCrtListEntryHandlerFunc(func(params storage.CreateStorageSSLCrtListEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.CreateStorageSSLCrtListEntry has not yet been implemented") + }), + ACLRuntimeDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler: acl_runtime.DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc(func(params acl_runtime.DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl_runtime.DeleteServicesHaproxyRuntimeAclsParentNameEntriesID has not yet been implemented") + }), + StorageDeleteStorageSSLCrtListEntryHandler: storage.DeleteStorageSSLCrtListEntryHandlerFunc(func(params storage.DeleteStorageSSLCrtListEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.DeleteStorageSSLCrtListEntry has not yet been implemented") + }), + ACLRuntimeGetServicesHaproxyRuntimeAclsHandler: acl_runtime.GetServicesHaproxyRuntimeAclsHandlerFunc(func(params acl_runtime.GetServicesHaproxyRuntimeAclsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl_runtime.GetServicesHaproxyRuntimeAcls has not yet been implemented") + }), + ACLRuntimeGetServicesHaproxyRuntimeAclsIDHandler: acl_runtime.GetServicesHaproxyRuntimeAclsIDHandlerFunc(func(params acl_runtime.GetServicesHaproxyRuntimeAclsIDParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl_runtime.GetServicesHaproxyRuntimeAclsID has not yet been implemented") + }), + ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesHandler: acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc(func(params acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntries has not yet been implemented") + }), + ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler: acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandlerFunc(func(params acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesIDParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesID has not yet been implemented") + }), + StorageGetStorageSSLCrtListEntriesHandler: storage.GetStorageSSLCrtListEntriesHandlerFunc(func(params storage.GetStorageSSLCrtListEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetStorageSSLCrtListEntries has not yet been implemented") + }), + ACLRuntimePostServicesHaproxyRuntimeAclsParentNameEntriesHandler: acl_runtime.PostServicesHaproxyRuntimeAclsParentNameEntriesHandlerFunc(func(params acl_runtime.PostServicesHaproxyRuntimeAclsParentNameEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl_runtime.PostServicesHaproxyRuntimeAclsParentNameEntries has not yet been implemented") + }), + SslRuntimeAddCaEntryHandler: s_s_l_runtime.AddCaEntryHandlerFunc(func(params s_s_l_runtime.AddCaEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.AddCaEntry has not yet been implemented") + }), + SslRuntimeAddCrtListEntryHandler: s_s_l_runtime.AddCrtListEntryHandlerFunc(func(params s_s_l_runtime.AddCrtListEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.AddCrtListEntry has not yet been implemented") + }), + DefaultsAddDefaultsSectionHandler: defaults.AddDefaultsSectionHandlerFunc(func(params defaults.AddDefaultsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation defaults.AddDefaultsSection has not yet been implemented") + }), + MapsAddMapEntryHandler: maps.AddMapEntryHandlerFunc(func(params maps.AddMapEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.AddMapEntry has not yet been implemented") + }), + ACLRuntimeAddPayloadRuntimeACLHandler: acl_runtime.AddPayloadRuntimeACLHandlerFunc(func(params acl_runtime.AddPayloadRuntimeACLParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl_runtime.AddPayloadRuntimeACL has not yet been implemented") + }), + MapsAddPayloadRuntimeMapHandler: maps.AddPayloadRuntimeMapHandlerFunc(func(params maps.AddPayloadRuntimeMapParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.AddPayloadRuntimeMap has not yet been implemented") + }), + ServerAddRuntimeServerHandler: serverops.AddRuntimeServerHandlerFunc(func(params serverops.AddRuntimeServerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.AddRuntimeServer has not yet been implemented") + }), + MapsClearRuntimeMapHandler: maps.ClearRuntimeMapHandlerFunc(func(params maps.ClearRuntimeMapParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.ClearRuntimeMap has not yet been implemented") + }), + SpoeTransactionsCommitSpoeTransactionHandler: spoe_transactions.CommitSpoeTransactionHandlerFunc(func(params spoe_transactions.CommitSpoeTransactionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe_transactions.CommitSpoeTransaction has not yet been implemented") + }), TransactionsCommitTransactionHandler: transactions.CommitTransactionHandlerFunc(func(params transactions.CommitTransactionParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TransactionsCommitTransaction has not yet been implemented") + return middleware.NotImplemented("operation transactions.CommitTransaction has not yet been implemented") + }), + ServiceDiscoveryCreateAWSRegionHandler: service_discovery.CreateAWSRegionHandlerFunc(func(params service_discovery.CreateAWSRegionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.CreateAWSRegion has not yet been implemented") + }), + ACLCreateACLBackendHandler: acl.CreateACLBackendHandlerFunc(func(params acl.CreateACLBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.CreateACLBackend has not yet been implemented") + }), + ACLCreateACLDefaultsHandler: acl.CreateACLDefaultsHandlerFunc(func(params acl.CreateACLDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.CreateACLDefaults has not yet been implemented") }), - ACLCreateACLHandler: acl.CreateACLHandlerFunc(func(params acl.CreateACLParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ACLCreateACL has not yet been implemented") + ACLCreateACLFCGIAppHandler: acl.CreateACLFCGIAppHandlerFunc(func(params acl.CreateACLFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.CreateACLFCGIApp has not yet been implemented") + }), + ACLCreateACLFrontendHandler: acl.CreateACLFrontendHandlerFunc(func(params acl.CreateACLFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.CreateACLFrontend has not yet been implemented") + }), + AcmeCreateAcmeProviderHandler: acme.CreateAcmeProviderHandlerFunc(func(params acme.CreateAcmeProviderParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acme.CreateAcmeProvider has not yet been implemented") }), BackendCreateBackendHandler: backend.CreateBackendHandlerFunc(func(params backend.CreateBackendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendCreateBackend has not yet been implemented") + return middleware.NotImplemented("operation backend.CreateBackend has not yet been implemented") }), BackendSwitchingRuleCreateBackendSwitchingRuleHandler: backend_switching_rule.CreateBackendSwitchingRuleHandlerFunc(func(params backend_switching_rule.CreateBackendSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendSwitchingRuleCreateBackendSwitchingRule has not yet been implemented") + return middleware.NotImplemented("operation backend_switching_rule.CreateBackendSwitchingRule has not yet been implemented") + }), + BindCreateBindFrontendHandler: bind.CreateBindFrontendHandlerFunc(func(params bind.CreateBindFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.CreateBindFrontend has not yet been implemented") + }), + BindCreateBindLogForwardHandler: bind.CreateBindLogForwardHandlerFunc(func(params bind.CreateBindLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.CreateBindLogForward has not yet been implemented") + }), + BindCreateBindPeerHandler: bind.CreateBindPeerHandlerFunc(func(params bind.CreateBindPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.CreateBindPeer has not yet been implemented") + }), + SslRuntimeCreateCaFileHandler: s_s_l_runtime.CreateCaFileHandlerFunc(func(params s_s_l_runtime.CreateCaFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.CreateCaFile has not yet been implemented") + }), + CacheCreateCacheHandler: cache.CreateCacheHandlerFunc(func(params cache.CreateCacheParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cache.CreateCache has not yet been implemented") + }), + SslRuntimeCreateCertHandler: s_s_l_runtime.CreateCertHandlerFunc(func(params s_s_l_runtime.CreateCertParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.CreateCert has not yet been implemented") }), - BindCreateBindHandler: bind.CreateBindHandlerFunc(func(params bind.CreateBindParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BindCreateBind has not yet been implemented") + ServiceDiscoveryCreateConsulHandler: service_discovery.CreateConsulHandlerFunc(func(params service_discovery.CreateConsulParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.CreateConsul has not yet been implemented") }), - FilterCreateFilterHandler: filter.CreateFilterHandlerFunc(func(params filter.CreateFilterParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FilterCreateFilter has not yet been implemented") + SslRuntimeCreateCrlHandler: s_s_l_runtime.CreateCrlHandlerFunc(func(params s_s_l_runtime.CreateCrlParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.CreateCrl has not yet been implemented") + }), + CrtLoadCreateCrtLoadHandler: crt_load.CreateCrtLoadHandlerFunc(func(params crt_load.CreateCrtLoadParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_load.CreateCrtLoad has not yet been implemented") + }), + CrtStoreCreateCrtStoreHandler: crt_store.CreateCrtStoreHandlerFunc(func(params crt_store.CreateCrtStoreParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_store.CreateCrtStore has not yet been implemented") + }), + DeclareCaptureCreateDeclareCaptureHandler: declare_capture.CreateDeclareCaptureHandlerFunc(func(params declare_capture.CreateDeclareCaptureParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation declare_capture.CreateDeclareCapture has not yet been implemented") + }), + DefaultsCreateDefaultsSectionHandler: defaults.CreateDefaultsSectionHandlerFunc(func(params defaults.CreateDefaultsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation defaults.CreateDefaultsSection has not yet been implemented") + }), + DgramBindCreateDgramBindHandler: dgram_bind.CreateDgramBindHandlerFunc(func(params dgram_bind.CreateDgramBindParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation dgram_bind.CreateDgramBind has not yet been implemented") + }), + FCGIAppCreateFCGIAppHandler: fcgi_app.CreateFCGIAppHandlerFunc(func(params fcgi_app.CreateFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation fcgi_app.CreateFCGIApp has not yet been implemented") + }), + FilterCreateFilterBackendHandler: filter.CreateFilterBackendHandlerFunc(func(params filter.CreateFilterBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.CreateFilterBackend has not yet been implemented") + }), + FilterCreateFilterFrontendHandler: filter.CreateFilterFrontendHandlerFunc(func(params filter.CreateFilterFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.CreateFilterFrontend has not yet been implemented") }), FrontendCreateFrontendHandler: frontend.CreateFrontendHandlerFunc(func(params frontend.CreateFrontendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FrontendCreateFrontend has not yet been implemented") + return middleware.NotImplemented("operation frontend.CreateFrontend has not yet been implemented") + }), + GroupCreateGroupHandler: group.CreateGroupHandlerFunc(func(params group.CreateGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation group.CreateGroup has not yet been implemented") + }), + HTTPAfterResponseRuleCreateHTTPAfterResponseRuleBackendHandler: http_after_response_rule.CreateHTTPAfterResponseRuleBackendHandlerFunc(func(params http_after_response_rule.CreateHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.CreateHTTPAfterResponseRuleBackend has not yet been implemented") + }), + HTTPAfterResponseRuleCreateHTTPAfterResponseRuleDefaultsHandler: http_after_response_rule.CreateHTTPAfterResponseRuleDefaultsHandlerFunc(func(params http_after_response_rule.CreateHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.CreateHTTPAfterResponseRuleDefaults has not yet been implemented") + }), + HTTPAfterResponseRuleCreateHTTPAfterResponseRuleFrontendHandler: http_after_response_rule.CreateHTTPAfterResponseRuleFrontendHandlerFunc(func(params http_after_response_rule.CreateHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.CreateHTTPAfterResponseRuleFrontend has not yet been implemented") + }), + HTTPCheckCreateHTTPCheckBackendHandler: http_check.CreateHTTPCheckBackendHandlerFunc(func(params http_check.CreateHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.CreateHTTPCheckBackend has not yet been implemented") + }), + HTTPCheckCreateHTTPCheckDefaultsHandler: http_check.CreateHTTPCheckDefaultsHandlerFunc(func(params http_check.CreateHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.CreateHTTPCheckDefaults has not yet been implemented") + }), + HTTPErrorRuleCreateHTTPErrorRuleBackendHandler: http_error_rule.CreateHTTPErrorRuleBackendHandlerFunc(func(params http_error_rule.CreateHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.CreateHTTPErrorRuleBackend has not yet been implemented") + }), + HTTPErrorRuleCreateHTTPErrorRuleDefaultsHandler: http_error_rule.CreateHTTPErrorRuleDefaultsHandlerFunc(func(params http_error_rule.CreateHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.CreateHTTPErrorRuleDefaults has not yet been implemented") + }), + HTTPErrorRuleCreateHTTPErrorRuleFrontendHandler: http_error_rule.CreateHTTPErrorRuleFrontendHandlerFunc(func(params http_error_rule.CreateHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.CreateHTTPErrorRuleFrontend has not yet been implemented") + }), + HTTPErrorsCreateHTTPErrorsSectionHandler: http_errors.CreateHTTPErrorsSectionHandlerFunc(func(params http_errors.CreateHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_errors.CreateHTTPErrorsSection has not yet been implemented") + }), + HTTPRequestRuleCreateHTTPRequestRuleBackendHandler: http_request_rule.CreateHTTPRequestRuleBackendHandlerFunc(func(params http_request_rule.CreateHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.CreateHTTPRequestRuleBackend has not yet been implemented") + }), + HTTPRequestRuleCreateHTTPRequestRuleDefaultsHandler: http_request_rule.CreateHTTPRequestRuleDefaultsHandlerFunc(func(params http_request_rule.CreateHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.CreateHTTPRequestRuleDefaults has not yet been implemented") + }), + HTTPRequestRuleCreateHTTPRequestRuleFrontendHandler: http_request_rule.CreateHTTPRequestRuleFrontendHandlerFunc(func(params http_request_rule.CreateHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.CreateHTTPRequestRuleFrontend has not yet been implemented") + }), + HTTPResponseRuleCreateHTTPResponseRuleBackendHandler: http_response_rule.CreateHTTPResponseRuleBackendHandlerFunc(func(params http_response_rule.CreateHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.CreateHTTPResponseRuleBackend has not yet been implemented") + }), + HTTPResponseRuleCreateHTTPResponseRuleDefaultsHandler: http_response_rule.CreateHTTPResponseRuleDefaultsHandlerFunc(func(params http_response_rule.CreateHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.CreateHTTPResponseRuleDefaults has not yet been implemented") + }), + HTTPResponseRuleCreateHTTPResponseRuleFrontendHandler: http_response_rule.CreateHTTPResponseRuleFrontendHandlerFunc(func(params http_response_rule.CreateHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.CreateHTTPResponseRuleFrontend has not yet been implemented") + }), + LogForwardCreateLogForwardHandler: log_forward.CreateLogForwardHandlerFunc(func(params log_forward.CreateLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_forward.CreateLogForward has not yet been implemented") + }), + LogProfileCreateLogProfileHandler: log_profile.CreateLogProfileHandlerFunc(func(params log_profile.CreateLogProfileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_profile.CreateLogProfile has not yet been implemented") + }), + LogTargetCreateLogTargetBackendHandler: log_target.CreateLogTargetBackendHandlerFunc(func(params log_target.CreateLogTargetBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.CreateLogTargetBackend has not yet been implemented") + }), + LogTargetCreateLogTargetDefaultsHandler: log_target.CreateLogTargetDefaultsHandlerFunc(func(params log_target.CreateLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.CreateLogTargetDefaults has not yet been implemented") + }), + LogTargetCreateLogTargetFrontendHandler: log_target.CreateLogTargetFrontendHandlerFunc(func(params log_target.CreateLogTargetFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.CreateLogTargetFrontend has not yet been implemented") + }), + LogTargetCreateLogTargetGlobalHandler: log_target.CreateLogTargetGlobalHandlerFunc(func(params log_target.CreateLogTargetGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.CreateLogTargetGlobal has not yet been implemented") + }), + LogTargetCreateLogTargetLogForwardHandler: log_target.CreateLogTargetLogForwardHandlerFunc(func(params log_target.CreateLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.CreateLogTargetLogForward has not yet been implemented") + }), + LogTargetCreateLogTargetPeerHandler: log_target.CreateLogTargetPeerHandlerFunc(func(params log_target.CreateLogTargetPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.CreateLogTargetPeer has not yet been implemented") }), - HTTPRequestRuleCreateHTTPRequestRuleHandler: http_request_rule.CreateHTTPRequestRuleHandlerFunc(func(params http_request_rule.CreateHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPRequestRuleCreateHTTPRequestRule has not yet been implemented") + MailerEntryCreateMailerEntryHandler: mailer_entry.CreateMailerEntryHandlerFunc(func(params mailer_entry.CreateMailerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailer_entry.CreateMailerEntry has not yet been implemented") }), - HTTPResponseRuleCreateHTTPResponseRuleHandler: http_response_rule.CreateHTTPResponseRuleHandlerFunc(func(params http_response_rule.CreateHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPResponseRuleCreateHTTPResponseRule has not yet been implemented") + MailersCreateMailersSectionHandler: mailers.CreateMailersSectionHandlerFunc(func(params mailers.CreateMailersSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailers.CreateMailersSection has not yet been implemented") }), - LogTargetCreateLogTargetHandler: log_target.CreateLogTargetHandlerFunc(func(params log_target.CreateLogTargetParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation LogTargetCreateLogTarget has not yet been implemented") + NameserverCreateNameserverHandler: nameserver.CreateNameserverHandlerFunc(func(params nameserver.CreateNameserverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation nameserver.CreateNameserver has not yet been implemented") }), - ServerCreateServerHandler: server.CreateServerHandlerFunc(func(params server.CreateServerParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerCreateServer has not yet been implemented") + PeerCreatePeerHandler: peer.CreatePeerHandlerFunc(func(params peer.CreatePeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer.CreatePeer has not yet been implemented") + }), + PeerEntryCreatePeerEntryHandler: peer_entry.CreatePeerEntryHandlerFunc(func(params peer_entry.CreatePeerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer_entry.CreatePeerEntry has not yet been implemented") + }), + ProcessManagerCreateProgramHandler: process_manager.CreateProgramHandlerFunc(func(params process_manager.CreateProgramParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation process_manager.CreateProgram has not yet been implemented") + }), + QUICInitialRuleCreateQUICInitialRuleDefaultsHandler: quic_initial_rule.CreateQUICInitialRuleDefaultsHandlerFunc(func(params quic_initial_rule.CreateQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.CreateQUICInitialRuleDefaults has not yet been implemented") + }), + QUICInitialRuleCreateQUICInitialRuleFrontendHandler: quic_initial_rule.CreateQUICInitialRuleFrontendHandlerFunc(func(params quic_initial_rule.CreateQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.CreateQUICInitialRuleFrontend has not yet been implemented") + }), + ResolverCreateResolverHandler: resolver.CreateResolverHandlerFunc(func(params resolver.CreateResolverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation resolver.CreateResolver has not yet been implemented") + }), + RingCreateRingHandler: ring.CreateRingHandlerFunc(func(params ring.CreateRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ring.CreateRing has not yet been implemented") + }), + SslFrontUseCreateSSLFrontUseHandler: s_s_l_front_use.CreateSSLFrontUseHandlerFunc(func(params s_s_l_front_use.CreateSSLFrontUseParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_front_use.CreateSSLFrontUse has not yet been implemented") + }), + ServerCreateServerBackendHandler: serverops.CreateServerBackendHandlerFunc(func(params serverops.CreateServerBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.CreateServerBackend has not yet been implemented") + }), + ServerCreateServerPeerHandler: serverops.CreateServerPeerHandlerFunc(func(params serverops.CreateServerPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.CreateServerPeer has not yet been implemented") + }), + ServerCreateServerRingHandler: serverops.CreateServerRingHandlerFunc(func(params serverops.CreateServerRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.CreateServerRing has not yet been implemented") }), ServerSwitchingRuleCreateServerSwitchingRuleHandler: server_switching_rule.CreateServerSwitchingRuleHandlerFunc(func(params server_switching_rule.CreateServerSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerSwitchingRuleCreateServerSwitchingRule has not yet been implemented") + return middleware.NotImplemented("operation server_switching_rule.CreateServerSwitchingRule has not yet been implemented") + }), + ServerTemplateCreateServerTemplateHandler: server_template.CreateServerTemplateHandlerFunc(func(params server_template.CreateServerTemplateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_template.CreateServerTemplate has not yet been implemented") }), SitesCreateSiteHandler: sites.CreateSiteHandlerFunc(func(params sites.CreateSiteParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation SitesCreateSite has not yet been implemented") + return middleware.NotImplemented("operation sites.CreateSite has not yet been implemented") + }), + SpoeCreateSpoeHandler: spoe.CreateSpoeHandlerFunc(func(params spoe.CreateSpoeParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.CreateSpoe has not yet been implemented") + }), + SpoeCreateSpoeAgentHandler: spoe.CreateSpoeAgentHandlerFunc(func(params spoe.CreateSpoeAgentParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.CreateSpoeAgent has not yet been implemented") + }), + SpoeCreateSpoeGroupHandler: spoe.CreateSpoeGroupHandlerFunc(func(params spoe.CreateSpoeGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.CreateSpoeGroup has not yet been implemented") + }), + SpoeCreateSpoeMessageHandler: spoe.CreateSpoeMessageHandlerFunc(func(params spoe.CreateSpoeMessageParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.CreateSpoeMessage has not yet been implemented") + }), + SpoeCreateSpoeScopeHandler: spoe.CreateSpoeScopeHandlerFunc(func(params spoe.CreateSpoeScopeParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.CreateSpoeScope has not yet been implemented") }), StickRuleCreateStickRuleHandler: stick_rule.CreateStickRuleHandlerFunc(func(params stick_rule.CreateStickRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation StickRuleCreateStickRule has not yet been implemented") + return middleware.NotImplemented("operation stick_rule.CreateStickRule has not yet been implemented") + }), + StorageCreateStorageGeneralFileHandler: storage.CreateStorageGeneralFileHandlerFunc(func(params storage.CreateStorageGeneralFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.CreateStorageGeneralFile has not yet been implemented") + }), + StorageCreateStorageMapFileHandler: storage.CreateStorageMapFileHandlerFunc(func(params storage.CreateStorageMapFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.CreateStorageMapFile has not yet been implemented") + }), + StorageCreateStorageSSLCertificateHandler: storage.CreateStorageSSLCertificateHandlerFunc(func(params storage.CreateStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.CreateStorageSSLCertificate has not yet been implemented") + }), + StorageCreateStorageSSLCrtListFileHandler: storage.CreateStorageSSLCrtListFileHandlerFunc(func(params storage.CreateStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.CreateStorageSSLCrtListFile has not yet been implemented") + }), + TCPCheckCreateTCPCheckBackendHandler: tcp_check.CreateTCPCheckBackendHandlerFunc(func(params tcp_check.CreateTCPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.CreateTCPCheckBackend has not yet been implemented") + }), + TCPCheckCreateTCPCheckDefaultsHandler: tcp_check.CreateTCPCheckDefaultsHandlerFunc(func(params tcp_check.CreateTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.CreateTCPCheckDefaults has not yet been implemented") + }), + TCPRequestRuleCreateTCPRequestRuleBackendHandler: tcp_request_rule.CreateTCPRequestRuleBackendHandlerFunc(func(params tcp_request_rule.CreateTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.CreateTCPRequestRuleBackend has not yet been implemented") + }), + TCPRequestRuleCreateTCPRequestRuleDefaultsHandler: tcp_request_rule.CreateTCPRequestRuleDefaultsHandlerFunc(func(params tcp_request_rule.CreateTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.CreateTCPRequestRuleDefaults has not yet been implemented") + }), + TCPRequestRuleCreateTCPRequestRuleFrontendHandler: tcp_request_rule.CreateTCPRequestRuleFrontendHandlerFunc(func(params tcp_request_rule.CreateTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.CreateTCPRequestRuleFrontend has not yet been implemented") + }), + TCPResponseRuleCreateTCPResponseRuleBackendHandler: tcp_response_rule.CreateTCPResponseRuleBackendHandlerFunc(func(params tcp_response_rule.CreateTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.CreateTCPResponseRuleBackend has not yet been implemented") + }), + TCPResponseRuleCreateTCPResponseRuleDefaultsHandler: tcp_response_rule.CreateTCPResponseRuleDefaultsHandlerFunc(func(params tcp_response_rule.CreateTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.CreateTCPResponseRuleDefaults has not yet been implemented") + }), + TableCreateTableHandler: table.CreateTableHandlerFunc(func(params table.CreateTableParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation table.CreateTable has not yet been implemented") + }), + TracesCreateTraceEntryHandler: traces.CreateTraceEntryHandlerFunc(func(params traces.CreateTraceEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation traces.CreateTraceEntry has not yet been implemented") + }), + TracesCreateTracesHandler: traces.CreateTracesHandlerFunc(func(params traces.CreateTracesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation traces.CreateTraces has not yet been implemented") + }), + UserCreateUserHandler: user.CreateUserHandlerFunc(func(params user.CreateUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.CreateUser has not yet been implemented") + }), + UserlistCreateUserlistHandler: userlist.CreateUserlistHandlerFunc(func(params userlist.CreateUserlistParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation userlist.CreateUserlist has not yet been implemented") }), - TCPRequestRuleCreateTCPRequestRuleHandler: tcp_request_rule.CreateTCPRequestRuleHandlerFunc(func(params tcp_request_rule.CreateTCPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPRequestRuleCreateTCPRequestRule has not yet been implemented") + ServiceDiscoveryDeleteAWSRegionHandler: service_discovery.DeleteAWSRegionHandlerFunc(func(params service_discovery.DeleteAWSRegionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.DeleteAWSRegion has not yet been implemented") }), - TCPResponseRuleCreateTCPResponseRuleHandler: tcp_response_rule.CreateTCPResponseRuleHandlerFunc(func(params tcp_response_rule.CreateTCPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPResponseRuleCreateTCPResponseRule has not yet been implemented") + ACLDeleteACLBackendHandler: acl.DeleteACLBackendHandlerFunc(func(params acl.DeleteACLBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.DeleteACLBackend has not yet been implemented") }), - ACLDeleteACLHandler: acl.DeleteACLHandlerFunc(func(params acl.DeleteACLParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ACLDeleteACL has not yet been implemented") + ACLDeleteACLDefaultsHandler: acl.DeleteACLDefaultsHandlerFunc(func(params acl.DeleteACLDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.DeleteACLDefaults has not yet been implemented") + }), + ACLDeleteACLFCGIAppHandler: acl.DeleteACLFCGIAppHandlerFunc(func(params acl.DeleteACLFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.DeleteACLFCGIApp has not yet been implemented") + }), + ACLDeleteACLFrontendHandler: acl.DeleteACLFrontendHandlerFunc(func(params acl.DeleteACLFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.DeleteACLFrontend has not yet been implemented") + }), + AcmeDeleteAcmeProviderHandler: acme.DeleteAcmeProviderHandlerFunc(func(params acme.DeleteAcmeProviderParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acme.DeleteAcmeProvider has not yet been implemented") }), BackendDeleteBackendHandler: backend.DeleteBackendHandlerFunc(func(params backend.DeleteBackendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendDeleteBackend has not yet been implemented") + return middleware.NotImplemented("operation backend.DeleteBackend has not yet been implemented") }), BackendSwitchingRuleDeleteBackendSwitchingRuleHandler: backend_switching_rule.DeleteBackendSwitchingRuleHandlerFunc(func(params backend_switching_rule.DeleteBackendSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendSwitchingRuleDeleteBackendSwitchingRule has not yet been implemented") + return middleware.NotImplemented("operation backend_switching_rule.DeleteBackendSwitchingRule has not yet been implemented") + }), + BindDeleteBindFrontendHandler: bind.DeleteBindFrontendHandlerFunc(func(params bind.DeleteBindFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.DeleteBindFrontend has not yet been implemented") + }), + BindDeleteBindLogForwardHandler: bind.DeleteBindLogForwardHandlerFunc(func(params bind.DeleteBindLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.DeleteBindLogForward has not yet been implemented") + }), + BindDeleteBindPeerHandler: bind.DeleteBindPeerHandlerFunc(func(params bind.DeleteBindPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.DeleteBindPeer has not yet been implemented") + }), + SslRuntimeDeleteCaFileHandler: s_s_l_runtime.DeleteCaFileHandlerFunc(func(params s_s_l_runtime.DeleteCaFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.DeleteCaFile has not yet been implemented") + }), + CacheDeleteCacheHandler: cache.DeleteCacheHandlerFunc(func(params cache.DeleteCacheParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cache.DeleteCache has not yet been implemented") + }), + SslRuntimeDeleteCertHandler: s_s_l_runtime.DeleteCertHandlerFunc(func(params s_s_l_runtime.DeleteCertParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.DeleteCert has not yet been implemented") + }), + ClusterDeleteClusterHandler: cluster.DeleteClusterHandlerFunc(func(params cluster.DeleteClusterParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cluster.DeleteCluster has not yet been implemented") + }), + ServiceDiscoveryDeleteConsulHandler: service_discovery.DeleteConsulHandlerFunc(func(params service_discovery.DeleteConsulParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.DeleteConsul has not yet been implemented") + }), + SslRuntimeDeleteCrlHandler: s_s_l_runtime.DeleteCrlHandlerFunc(func(params s_s_l_runtime.DeleteCrlParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.DeleteCrl has not yet been implemented") + }), + SslRuntimeDeleteCrtListEntryHandler: s_s_l_runtime.DeleteCrtListEntryHandlerFunc(func(params s_s_l_runtime.DeleteCrtListEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.DeleteCrtListEntry has not yet been implemented") + }), + CrtLoadDeleteCrtLoadHandler: crt_load.DeleteCrtLoadHandlerFunc(func(params crt_load.DeleteCrtLoadParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_load.DeleteCrtLoad has not yet been implemented") + }), + CrtStoreDeleteCrtStoreHandler: crt_store.DeleteCrtStoreHandlerFunc(func(params crt_store.DeleteCrtStoreParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_store.DeleteCrtStore has not yet been implemented") + }), + DeclareCaptureDeleteDeclareCaptureHandler: declare_capture.DeleteDeclareCaptureHandlerFunc(func(params declare_capture.DeleteDeclareCaptureParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation declare_capture.DeleteDeclareCapture has not yet been implemented") }), - BindDeleteBindHandler: bind.DeleteBindHandlerFunc(func(params bind.DeleteBindParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BindDeleteBind has not yet been implemented") + DefaultsDeleteDefaultsSectionHandler: defaults.DeleteDefaultsSectionHandlerFunc(func(params defaults.DeleteDefaultsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation defaults.DeleteDefaultsSection has not yet been implemented") }), - FilterDeleteFilterHandler: filter.DeleteFilterHandlerFunc(func(params filter.DeleteFilterParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FilterDeleteFilter has not yet been implemented") + DgramBindDeleteDgramBindHandler: dgram_bind.DeleteDgramBindHandlerFunc(func(params dgram_bind.DeleteDgramBindParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation dgram_bind.DeleteDgramBind has not yet been implemented") + }), + FCGIAppDeleteFCGIAppHandler: fcgi_app.DeleteFCGIAppHandlerFunc(func(params fcgi_app.DeleteFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation fcgi_app.DeleteFCGIApp has not yet been implemented") + }), + FilterDeleteFilterBackendHandler: filter.DeleteFilterBackendHandlerFunc(func(params filter.DeleteFilterBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.DeleteFilterBackend has not yet been implemented") + }), + FilterDeleteFilterFrontendHandler: filter.DeleteFilterFrontendHandlerFunc(func(params filter.DeleteFilterFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.DeleteFilterFrontend has not yet been implemented") }), FrontendDeleteFrontendHandler: frontend.DeleteFrontendHandlerFunc(func(params frontend.DeleteFrontendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FrontendDeleteFrontend has not yet been implemented") + return middleware.NotImplemented("operation frontend.DeleteFrontend has not yet been implemented") + }), + GroupDeleteGroupHandler: group.DeleteGroupHandlerFunc(func(params group.DeleteGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation group.DeleteGroup has not yet been implemented") + }), + HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleBackendHandler: http_after_response_rule.DeleteHTTPAfterResponseRuleBackendHandlerFunc(func(params http_after_response_rule.DeleteHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.DeleteHTTPAfterResponseRuleBackend has not yet been implemented") + }), + HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleDefaultsHandler: http_after_response_rule.DeleteHTTPAfterResponseRuleDefaultsHandlerFunc(func(params http_after_response_rule.DeleteHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.DeleteHTTPAfterResponseRuleDefaults has not yet been implemented") + }), + HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleFrontendHandler: http_after_response_rule.DeleteHTTPAfterResponseRuleFrontendHandlerFunc(func(params http_after_response_rule.DeleteHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.DeleteHTTPAfterResponseRuleFrontend has not yet been implemented") + }), + HTTPCheckDeleteHTTPCheckBackendHandler: http_check.DeleteHTTPCheckBackendHandlerFunc(func(params http_check.DeleteHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.DeleteHTTPCheckBackend has not yet been implemented") + }), + HTTPCheckDeleteHTTPCheckDefaultsHandler: http_check.DeleteHTTPCheckDefaultsHandlerFunc(func(params http_check.DeleteHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.DeleteHTTPCheckDefaults has not yet been implemented") + }), + HTTPErrorRuleDeleteHTTPErrorRuleBackendHandler: http_error_rule.DeleteHTTPErrorRuleBackendHandlerFunc(func(params http_error_rule.DeleteHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.DeleteHTTPErrorRuleBackend has not yet been implemented") + }), + HTTPErrorRuleDeleteHTTPErrorRuleDefaultsHandler: http_error_rule.DeleteHTTPErrorRuleDefaultsHandlerFunc(func(params http_error_rule.DeleteHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.DeleteHTTPErrorRuleDefaults has not yet been implemented") + }), + HTTPErrorRuleDeleteHTTPErrorRuleFrontendHandler: http_error_rule.DeleteHTTPErrorRuleFrontendHandlerFunc(func(params http_error_rule.DeleteHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.DeleteHTTPErrorRuleFrontend has not yet been implemented") + }), + HTTPErrorsDeleteHTTPErrorsSectionHandler: http_errors.DeleteHTTPErrorsSectionHandlerFunc(func(params http_errors.DeleteHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_errors.DeleteHTTPErrorsSection has not yet been implemented") + }), + HTTPRequestRuleDeleteHTTPRequestRuleBackendHandler: http_request_rule.DeleteHTTPRequestRuleBackendHandlerFunc(func(params http_request_rule.DeleteHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.DeleteHTTPRequestRuleBackend has not yet been implemented") + }), + HTTPRequestRuleDeleteHTTPRequestRuleDefaultsHandler: http_request_rule.DeleteHTTPRequestRuleDefaultsHandlerFunc(func(params http_request_rule.DeleteHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.DeleteHTTPRequestRuleDefaults has not yet been implemented") + }), + HTTPRequestRuleDeleteHTTPRequestRuleFrontendHandler: http_request_rule.DeleteHTTPRequestRuleFrontendHandlerFunc(func(params http_request_rule.DeleteHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.DeleteHTTPRequestRuleFrontend has not yet been implemented") }), - HTTPRequestRuleDeleteHTTPRequestRuleHandler: http_request_rule.DeleteHTTPRequestRuleHandlerFunc(func(params http_request_rule.DeleteHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPRequestRuleDeleteHTTPRequestRule has not yet been implemented") + HTTPResponseRuleDeleteHTTPResponseRuleBackendHandler: http_response_rule.DeleteHTTPResponseRuleBackendHandlerFunc(func(params http_response_rule.DeleteHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.DeleteHTTPResponseRuleBackend has not yet been implemented") }), - HTTPResponseRuleDeleteHTTPResponseRuleHandler: http_response_rule.DeleteHTTPResponseRuleHandlerFunc(func(params http_response_rule.DeleteHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPResponseRuleDeleteHTTPResponseRule has not yet been implemented") + HTTPResponseRuleDeleteHTTPResponseRuleDefaultsHandler: http_response_rule.DeleteHTTPResponseRuleDefaultsHandlerFunc(func(params http_response_rule.DeleteHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.DeleteHTTPResponseRuleDefaults has not yet been implemented") }), - LogTargetDeleteLogTargetHandler: log_target.DeleteLogTargetHandlerFunc(func(params log_target.DeleteLogTargetParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation LogTargetDeleteLogTarget has not yet been implemented") + HTTPResponseRuleDeleteHTTPResponseRuleFrontendHandler: http_response_rule.DeleteHTTPResponseRuleFrontendHandlerFunc(func(params http_response_rule.DeleteHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.DeleteHTTPResponseRuleFrontend has not yet been implemented") }), - ServerDeleteServerHandler: server.DeleteServerHandlerFunc(func(params server.DeleteServerParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerDeleteServer has not yet been implemented") + LogForwardDeleteLogForwardHandler: log_forward.DeleteLogForwardHandlerFunc(func(params log_forward.DeleteLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_forward.DeleteLogForward has not yet been implemented") + }), + LogProfileDeleteLogProfileHandler: log_profile.DeleteLogProfileHandlerFunc(func(params log_profile.DeleteLogProfileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_profile.DeleteLogProfile has not yet been implemented") + }), + LogTargetDeleteLogTargetBackendHandler: log_target.DeleteLogTargetBackendHandlerFunc(func(params log_target.DeleteLogTargetBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.DeleteLogTargetBackend has not yet been implemented") + }), + LogTargetDeleteLogTargetDefaultsHandler: log_target.DeleteLogTargetDefaultsHandlerFunc(func(params log_target.DeleteLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.DeleteLogTargetDefaults has not yet been implemented") + }), + LogTargetDeleteLogTargetFrontendHandler: log_target.DeleteLogTargetFrontendHandlerFunc(func(params log_target.DeleteLogTargetFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.DeleteLogTargetFrontend has not yet been implemented") + }), + LogTargetDeleteLogTargetGlobalHandler: log_target.DeleteLogTargetGlobalHandlerFunc(func(params log_target.DeleteLogTargetGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.DeleteLogTargetGlobal has not yet been implemented") + }), + LogTargetDeleteLogTargetLogForwardHandler: log_target.DeleteLogTargetLogForwardHandlerFunc(func(params log_target.DeleteLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.DeleteLogTargetLogForward has not yet been implemented") + }), + LogTargetDeleteLogTargetPeerHandler: log_target.DeleteLogTargetPeerHandlerFunc(func(params log_target.DeleteLogTargetPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.DeleteLogTargetPeer has not yet been implemented") + }), + MailerEntryDeleteMailerEntryHandler: mailer_entry.DeleteMailerEntryHandlerFunc(func(params mailer_entry.DeleteMailerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailer_entry.DeleteMailerEntry has not yet been implemented") + }), + MailersDeleteMailersSectionHandler: mailers.DeleteMailersSectionHandlerFunc(func(params mailers.DeleteMailersSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailers.DeleteMailersSection has not yet been implemented") + }), + NameserverDeleteNameserverHandler: nameserver.DeleteNameserverHandlerFunc(func(params nameserver.DeleteNameserverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation nameserver.DeleteNameserver has not yet been implemented") + }), + PeerDeletePeerHandler: peer.DeletePeerHandlerFunc(func(params peer.DeletePeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer.DeletePeer has not yet been implemented") + }), + PeerEntryDeletePeerEntryHandler: peer_entry.DeletePeerEntryHandlerFunc(func(params peer_entry.DeletePeerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer_entry.DeletePeerEntry has not yet been implemented") + }), + ProcessManagerDeleteProgramHandler: process_manager.DeleteProgramHandlerFunc(func(params process_manager.DeleteProgramParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation process_manager.DeleteProgram has not yet been implemented") + }), + QUICInitialRuleDeleteQUICInitialRuleDefaultsHandler: quic_initial_rule.DeleteQUICInitialRuleDefaultsHandlerFunc(func(params quic_initial_rule.DeleteQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.DeleteQUICInitialRuleDefaults has not yet been implemented") + }), + QUICInitialRuleDeleteQUICInitialRuleFrontendHandler: quic_initial_rule.DeleteQUICInitialRuleFrontendHandlerFunc(func(params quic_initial_rule.DeleteQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.DeleteQUICInitialRuleFrontend has not yet been implemented") + }), + ResolverDeleteResolverHandler: resolver.DeleteResolverHandlerFunc(func(params resolver.DeleteResolverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation resolver.DeleteResolver has not yet been implemented") + }), + RingDeleteRingHandler: ring.DeleteRingHandlerFunc(func(params ring.DeleteRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ring.DeleteRing has not yet been implemented") + }), + MapsDeleteRuntimeMapEntryHandler: maps.DeleteRuntimeMapEntryHandlerFunc(func(params maps.DeleteRuntimeMapEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.DeleteRuntimeMapEntry has not yet been implemented") + }), + ServerDeleteRuntimeServerHandler: serverops.DeleteRuntimeServerHandlerFunc(func(params serverops.DeleteRuntimeServerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.DeleteRuntimeServer has not yet been implemented") + }), + SslFrontUseDeleteSSLFrontUseHandler: s_s_l_front_use.DeleteSSLFrontUseHandlerFunc(func(params s_s_l_front_use.DeleteSSLFrontUseParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_front_use.DeleteSSLFrontUse has not yet been implemented") + }), + ServerDeleteServerBackendHandler: serverops.DeleteServerBackendHandlerFunc(func(params serverops.DeleteServerBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.DeleteServerBackend has not yet been implemented") + }), + ServerDeleteServerPeerHandler: serverops.DeleteServerPeerHandlerFunc(func(params serverops.DeleteServerPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.DeleteServerPeer has not yet been implemented") + }), + ServerDeleteServerRingHandler: serverops.DeleteServerRingHandlerFunc(func(params serverops.DeleteServerRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.DeleteServerRing has not yet been implemented") }), ServerSwitchingRuleDeleteServerSwitchingRuleHandler: server_switching_rule.DeleteServerSwitchingRuleHandlerFunc(func(params server_switching_rule.DeleteServerSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerSwitchingRuleDeleteServerSwitchingRule has not yet been implemented") + return middleware.NotImplemented("operation server_switching_rule.DeleteServerSwitchingRule has not yet been implemented") + }), + ServerTemplateDeleteServerTemplateHandler: server_template.DeleteServerTemplateHandlerFunc(func(params server_template.DeleteServerTemplateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_template.DeleteServerTemplate has not yet been implemented") }), SitesDeleteSiteHandler: sites.DeleteSiteHandlerFunc(func(params sites.DeleteSiteParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation SitesDeleteSite has not yet been implemented") + return middleware.NotImplemented("operation sites.DeleteSite has not yet been implemented") + }), + SpoeDeleteSpoeAgentHandler: spoe.DeleteSpoeAgentHandlerFunc(func(params spoe.DeleteSpoeAgentParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.DeleteSpoeAgent has not yet been implemented") + }), + SpoeDeleteSpoeFileHandler: spoe.DeleteSpoeFileHandlerFunc(func(params spoe.DeleteSpoeFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.DeleteSpoeFile has not yet been implemented") + }), + SpoeDeleteSpoeGroupHandler: spoe.DeleteSpoeGroupHandlerFunc(func(params spoe.DeleteSpoeGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.DeleteSpoeGroup has not yet been implemented") + }), + SpoeDeleteSpoeMessageHandler: spoe.DeleteSpoeMessageHandlerFunc(func(params spoe.DeleteSpoeMessageParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.DeleteSpoeMessage has not yet been implemented") + }), + SpoeDeleteSpoeScopeHandler: spoe.DeleteSpoeScopeHandlerFunc(func(params spoe.DeleteSpoeScopeParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.DeleteSpoeScope has not yet been implemented") + }), + SpoeTransactionsDeleteSpoeTransactionHandler: spoe_transactions.DeleteSpoeTransactionHandlerFunc(func(params spoe_transactions.DeleteSpoeTransactionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe_transactions.DeleteSpoeTransaction has not yet been implemented") }), StickRuleDeleteStickRuleHandler: stick_rule.DeleteStickRuleHandlerFunc(func(params stick_rule.DeleteStickRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation StickRuleDeleteStickRule has not yet been implemented") + return middleware.NotImplemented("operation stick_rule.DeleteStickRule has not yet been implemented") + }), + StorageDeleteStorageGeneralFileHandler: storage.DeleteStorageGeneralFileHandlerFunc(func(params storage.DeleteStorageGeneralFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.DeleteStorageGeneralFile has not yet been implemented") + }), + StorageDeleteStorageMapHandler: storage.DeleteStorageMapHandlerFunc(func(params storage.DeleteStorageMapParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.DeleteStorageMap has not yet been implemented") }), - TCPRequestRuleDeleteTCPRequestRuleHandler: tcp_request_rule.DeleteTCPRequestRuleHandlerFunc(func(params tcp_request_rule.DeleteTCPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPRequestRuleDeleteTCPRequestRule has not yet been implemented") + StorageDeleteStorageSSLCertificateHandler: storage.DeleteStorageSSLCertificateHandlerFunc(func(params storage.DeleteStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.DeleteStorageSSLCertificate has not yet been implemented") }), - TCPResponseRuleDeleteTCPResponseRuleHandler: tcp_response_rule.DeleteTCPResponseRuleHandlerFunc(func(params tcp_response_rule.DeleteTCPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPResponseRuleDeleteTCPResponseRule has not yet been implemented") + StorageDeleteStorageSSLCrtListFileHandler: storage.DeleteStorageSSLCrtListFileHandlerFunc(func(params storage.DeleteStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.DeleteStorageSSLCrtListFile has not yet been implemented") + }), + TCPCheckDeleteTCPCheckBackendHandler: tcp_check.DeleteTCPCheckBackendHandlerFunc(func(params tcp_check.DeleteTCPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.DeleteTCPCheckBackend has not yet been implemented") + }), + TCPCheckDeleteTCPCheckDefaultsHandler: tcp_check.DeleteTCPCheckDefaultsHandlerFunc(func(params tcp_check.DeleteTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.DeleteTCPCheckDefaults has not yet been implemented") + }), + TCPRequestRuleDeleteTCPRequestRuleBackendHandler: tcp_request_rule.DeleteTCPRequestRuleBackendHandlerFunc(func(params tcp_request_rule.DeleteTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.DeleteTCPRequestRuleBackend has not yet been implemented") + }), + TCPRequestRuleDeleteTCPRequestRuleDefaultsHandler: tcp_request_rule.DeleteTCPRequestRuleDefaultsHandlerFunc(func(params tcp_request_rule.DeleteTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.DeleteTCPRequestRuleDefaults has not yet been implemented") + }), + TCPRequestRuleDeleteTCPRequestRuleFrontendHandler: tcp_request_rule.DeleteTCPRequestRuleFrontendHandlerFunc(func(params tcp_request_rule.DeleteTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.DeleteTCPRequestRuleFrontend has not yet been implemented") + }), + TCPResponseRuleDeleteTCPResponseRuleBackendHandler: tcp_response_rule.DeleteTCPResponseRuleBackendHandlerFunc(func(params tcp_response_rule.DeleteTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.DeleteTCPResponseRuleBackend has not yet been implemented") + }), + TCPResponseRuleDeleteTCPResponseRuleDefaultsHandler: tcp_response_rule.DeleteTCPResponseRuleDefaultsHandlerFunc(func(params tcp_response_rule.DeleteTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.DeleteTCPResponseRuleDefaults has not yet been implemented") + }), + TableDeleteTableHandler: table.DeleteTableHandlerFunc(func(params table.DeleteTableParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation table.DeleteTable has not yet been implemented") + }), + TracesDeleteTraceEntryHandler: traces.DeleteTraceEntryHandlerFunc(func(params traces.DeleteTraceEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation traces.DeleteTraceEntry has not yet been implemented") + }), + TracesDeleteTracesHandler: traces.DeleteTracesHandlerFunc(func(params traces.DeleteTracesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation traces.DeleteTraces has not yet been implemented") }), TransactionsDeleteTransactionHandler: transactions.DeleteTransactionHandlerFunc(func(params transactions.DeleteTransactionParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TransactionsDeleteTransaction has not yet been implemented") + return middleware.NotImplemented("operation transactions.DeleteTransaction has not yet been implemented") + }), + UserDeleteUserHandler: user.DeleteUserHandlerFunc(func(params user.DeleteUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.DeleteUser has not yet been implemented") + }), + UserlistDeleteUserlistHandler: userlist.DeleteUserlistHandlerFunc(func(params userlist.DeleteUserlistParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation userlist.DeleteUserlist has not yet been implemented") + }), + AcmeEditAcmeProviderHandler: acme.EditAcmeProviderHandlerFunc(func(params acme.EditAcmeProviderParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acme.EditAcmeProvider has not yet been implemented") + }), + ClusterEditClusterHandler: cluster.EditClusterHandlerFunc(func(params cluster.EditClusterParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cluster.EditCluster has not yet been implemented") + }), + CrtStoreEditCrtStoreHandler: crt_store.EditCrtStoreHandlerFunc(func(params crt_store.EditCrtStoreParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_store.EditCrtStore has not yet been implemented") + }), + LogProfileEditLogProfileHandler: log_profile.EditLogProfileHandlerFunc(func(params log_profile.EditLogProfileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_profile.EditLogProfile has not yet been implemented") + }), + MailersEditMailersSectionHandler: mailers.EditMailersSectionHandlerFunc(func(params mailers.EditMailersSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailers.EditMailersSection has not yet been implemented") }), DiscoveryGetAPIEndpointsHandler: discovery.GetAPIEndpointsHandlerFunc(func(params discovery.GetAPIEndpointsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation DiscoveryGetAPIEndpoints has not yet been implemented") + return middleware.NotImplemented("operation discovery.GetAPIEndpoints has not yet been implemented") }), - ACLGetACLHandler: acl.GetACLHandlerFunc(func(params acl.GetACLParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ACLGetACL has not yet been implemented") + ServiceDiscoveryGetAWSRegionHandler: service_discovery.GetAWSRegionHandlerFunc(func(params service_discovery.GetAWSRegionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.GetAWSRegion has not yet been implemented") }), - ACLGetAclsHandler: acl.GetAclsHandlerFunc(func(params acl.GetAclsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ACLGetAcls has not yet been implemented") + ServiceDiscoveryGetAWSRegionsHandler: service_discovery.GetAWSRegionsHandlerFunc(func(params service_discovery.GetAWSRegionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.GetAWSRegions has not yet been implemented") }), - BackendGetBackendHandler: backend.GetBackendHandlerFunc(func(params backend.GetBackendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendGetBackend has not yet been implemented") + ACLGetACLBackendHandler: acl.GetACLBackendHandlerFunc(func(params acl.GetACLBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetACLBackend has not yet been implemented") }), - BackendSwitchingRuleGetBackendSwitchingRuleHandler: backend_switching_rule.GetBackendSwitchingRuleHandlerFunc(func(params backend_switching_rule.GetBackendSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendSwitchingRuleGetBackendSwitchingRule has not yet been implemented") + ACLGetACLDefaultsHandler: acl.GetACLDefaultsHandlerFunc(func(params acl.GetACLDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetACLDefaults has not yet been implemented") }), - BackendSwitchingRuleGetBackendSwitchingRulesHandler: backend_switching_rule.GetBackendSwitchingRulesHandlerFunc(func(params backend_switching_rule.GetBackendSwitchingRulesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendSwitchingRuleGetBackendSwitchingRules has not yet been implemented") + ACLGetACLFCGIAppHandler: acl.GetACLFCGIAppHandlerFunc(func(params acl.GetACLFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetACLFCGIApp has not yet been implemented") }), - BackendGetBackendsHandler: backend.GetBackendsHandlerFunc(func(params backend.GetBackendsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendGetBackends has not yet been implemented") + ACLGetACLFrontendHandler: acl.GetACLFrontendHandlerFunc(func(params acl.GetACLFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetACLFrontend has not yet been implemented") }), - BindGetBindHandler: bind.GetBindHandlerFunc(func(params bind.GetBindParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BindGetBind has not yet been implemented") + AcmeGetAcmeProviderHandler: acme.GetAcmeProviderHandlerFunc(func(params acme.GetAcmeProviderParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acme.GetAcmeProvider has not yet been implemented") }), - BindGetBindsHandler: bind.GetBindsHandlerFunc(func(params bind.GetBindsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BindGetBinds has not yet been implemented") + AcmeGetAcmeProvidersHandler: acme.GetAcmeProvidersHandlerFunc(func(params acme.GetAcmeProvidersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acme.GetAcmeProviders has not yet been implemented") }), - DiscoveryGetConfigurationEndpointsHandler: discovery.GetConfigurationEndpointsHandlerFunc(func(params discovery.GetConfigurationEndpointsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation DiscoveryGetConfigurationEndpoints has not yet been implemented") + AcmeRuntimeGetAcmeStatusHandler: acme_runtime.GetAcmeStatusHandlerFunc(func(params acme_runtime.GetAcmeStatusParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acme_runtime.GetAcmeStatus has not yet been implemented") }), - DefaultsGetDefaultsHandler: defaults.GetDefaultsHandlerFunc(func(params defaults.GetDefaultsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation DefaultsGetDefaults has not yet been implemented") + ACLGetAllACLBackendHandler: acl.GetAllACLBackendHandlerFunc(func(params acl.GetAllACLBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetAllACLBackend has not yet been implemented") }), - FilterGetFilterHandler: filter.GetFilterHandlerFunc(func(params filter.GetFilterParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FilterGetFilter has not yet been implemented") + ACLGetAllACLDefaultsHandler: acl.GetAllACLDefaultsHandlerFunc(func(params acl.GetAllACLDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetAllACLDefaults has not yet been implemented") }), - FilterGetFiltersHandler: filter.GetFiltersHandlerFunc(func(params filter.GetFiltersParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FilterGetFilters has not yet been implemented") + ACLGetAllACLFCGIAppHandler: acl.GetAllACLFCGIAppHandlerFunc(func(params acl.GetAllACLFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetAllACLFCGIApp has not yet been implemented") }), - FrontendGetFrontendHandler: frontend.GetFrontendHandlerFunc(func(params frontend.GetFrontendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FrontendGetFrontend has not yet been implemented") + ACLGetAllACLFrontendHandler: acl.GetAllACLFrontendHandlerFunc(func(params acl.GetAllACLFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.GetAllACLFrontend has not yet been implemented") }), - FrontendGetFrontendsHandler: frontend.GetFrontendsHandlerFunc(func(params frontend.GetFrontendsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FrontendGetFrontends has not yet been implemented") + BindGetAllBindFrontendHandler: bind.GetAllBindFrontendHandlerFunc(func(params bind.GetAllBindFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.GetAllBindFrontend has not yet been implemented") }), - GlobalGetGlobalHandler: global.GetGlobalHandlerFunc(func(params global.GetGlobalParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation GlobalGetGlobal has not yet been implemented") + BindGetAllBindLogForwardHandler: bind.GetAllBindLogForwardHandlerFunc(func(params bind.GetAllBindLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.GetAllBindLogForward has not yet been implemented") }), - ConfigurationGetHAProxyConfigurationHandler: configuration.GetHAProxyConfigurationHandlerFunc(func(params configuration.GetHAProxyConfigurationParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ConfigurationGetHAProxyConfiguration has not yet been implemented") + BindGetAllBindPeerHandler: bind.GetAllBindPeerHandlerFunc(func(params bind.GetAllBindPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.GetAllBindPeer has not yet been implemented") }), - HTTPRequestRuleGetHTTPRequestRuleHandler: http_request_rule.GetHTTPRequestRuleHandlerFunc(func(params http_request_rule.GetHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPRequestRuleGetHTTPRequestRule has not yet been implemented") + SslRuntimeGetAllCaFilesHandler: s_s_l_runtime.GetAllCaFilesHandlerFunc(func(params s_s_l_runtime.GetAllCaFilesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetAllCaFiles has not yet been implemented") }), - HTTPRequestRuleGetHTTPRequestRulesHandler: http_request_rule.GetHTTPRequestRulesHandlerFunc(func(params http_request_rule.GetHTTPRequestRulesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPRequestRuleGetHTTPRequestRules has not yet been implemented") + SslRuntimeGetAllCertsHandler: s_s_l_runtime.GetAllCertsHandlerFunc(func(params s_s_l_runtime.GetAllCertsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetAllCerts has not yet been implemented") }), - HTTPResponseRuleGetHTTPResponseRuleHandler: http_response_rule.GetHTTPResponseRuleHandlerFunc(func(params http_response_rule.GetHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPResponseRuleGetHTTPResponseRule has not yet been implemented") + SslRuntimeGetAllCrlHandler: s_s_l_runtime.GetAllCrlHandlerFunc(func(params s_s_l_runtime.GetAllCrlParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetAllCrl has not yet been implemented") }), - HTTPResponseRuleGetHTTPResponseRulesHandler: http_response_rule.GetHTTPResponseRulesHandlerFunc(func(params http_response_rule.GetHTTPResponseRulesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPResponseRuleGetHTTPResponseRules has not yet been implemented") + SslRuntimeGetAllCrtListEntriesHandler: s_s_l_runtime.GetAllCrtListEntriesHandlerFunc(func(params s_s_l_runtime.GetAllCrtListEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetAllCrtListEntries has not yet been implemented") }), - DiscoveryGetHaproxyEndpointsHandler: discovery.GetHaproxyEndpointsHandlerFunc(func(params discovery.GetHaproxyEndpointsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation DiscoveryGetHaproxyEndpoints has not yet been implemented") + SslRuntimeGetAllCrtListsHandler: s_s_l_runtime.GetAllCrtListsHandlerFunc(func(params s_s_l_runtime.GetAllCrtListsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetAllCrtLists has not yet been implemented") }), - InformationGetHaproxyProcessInfoHandler: information.GetHaproxyProcessInfoHandlerFunc(func(params information.GetHaproxyProcessInfoParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation InformationGetHaproxyProcessInfo has not yet been implemented") + FilterGetAllFilterBackendHandler: filter.GetAllFilterBackendHandlerFunc(func(params filter.GetAllFilterBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.GetAllFilterBackend has not yet been implemented") }), - InformationGetInfoHandler: information.GetInfoHandlerFunc(func(params information.GetInfoParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation InformationGetInfo has not yet been implemented") + FilterGetAllFilterFrontendHandler: filter.GetAllFilterFrontendHandlerFunc(func(params filter.GetAllFilterFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.GetAllFilterFrontend has not yet been implemented") }), - LogTargetGetLogTargetHandler: log_target.GetLogTargetHandlerFunc(func(params log_target.GetLogTargetParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation LogTargetGetLogTarget has not yet been implemented") + HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleBackendHandler: http_after_response_rule.GetAllHTTPAfterResponseRuleBackendHandlerFunc(func(params http_after_response_rule.GetAllHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.GetAllHTTPAfterResponseRuleBackend has not yet been implemented") }), - LogTargetGetLogTargetsHandler: log_target.GetLogTargetsHandlerFunc(func(params log_target.GetLogTargetsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation LogTargetGetLogTargets has not yet been implemented") + HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleDefaultsHandler: http_after_response_rule.GetAllHTTPAfterResponseRuleDefaultsHandlerFunc(func(params http_after_response_rule.GetAllHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.GetAllHTTPAfterResponseRuleDefaults has not yet been implemented") }), - ReloadsGetReloadHandler: reloads.GetReloadHandlerFunc(func(params reloads.GetReloadParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ReloadsGetReload has not yet been implemented") + HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleFrontendHandler: http_after_response_rule.GetAllHTTPAfterResponseRuleFrontendHandlerFunc(func(params http_after_response_rule.GetAllHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.GetAllHTTPAfterResponseRuleFrontend has not yet been implemented") }), - ReloadsGetReloadsHandler: reloads.GetReloadsHandlerFunc(func(params reloads.GetReloadsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ReloadsGetReloads has not yet been implemented") + HTTPCheckGetAllHTTPCheckBackendHandler: http_check.GetAllHTTPCheckBackendHandlerFunc(func(params http_check.GetAllHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.GetAllHTTPCheckBackend has not yet been implemented") }), - ServerGetServerHandler: server.GetServerHandlerFunc(func(params server.GetServerParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerGetServer has not yet been implemented") + HTTPCheckGetAllHTTPCheckDefaultsHandler: http_check.GetAllHTTPCheckDefaultsHandlerFunc(func(params http_check.GetAllHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.GetAllHTTPCheckDefaults has not yet been implemented") }), - ServerSwitchingRuleGetServerSwitchingRuleHandler: server_switching_rule.GetServerSwitchingRuleHandlerFunc(func(params server_switching_rule.GetServerSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerSwitchingRuleGetServerSwitchingRule has not yet been implemented") + HTTPErrorRuleGetAllHTTPErrorRuleBackendHandler: http_error_rule.GetAllHTTPErrorRuleBackendHandlerFunc(func(params http_error_rule.GetAllHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.GetAllHTTPErrorRuleBackend has not yet been implemented") }), - ServerSwitchingRuleGetServerSwitchingRulesHandler: server_switching_rule.GetServerSwitchingRulesHandlerFunc(func(params server_switching_rule.GetServerSwitchingRulesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerSwitchingRuleGetServerSwitchingRules has not yet been implemented") + HTTPErrorRuleGetAllHTTPErrorRuleDefaultsHandler: http_error_rule.GetAllHTTPErrorRuleDefaultsHandlerFunc(func(params http_error_rule.GetAllHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.GetAllHTTPErrorRuleDefaults has not yet been implemented") }), - ServerGetServersHandler: server.GetServersHandlerFunc(func(params server.GetServersParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerGetServers has not yet been implemented") + HTTPErrorRuleGetAllHTTPErrorRuleFrontendHandler: http_error_rule.GetAllHTTPErrorRuleFrontendHandlerFunc(func(params http_error_rule.GetAllHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.GetAllHTTPErrorRuleFrontend has not yet been implemented") }), - DiscoveryGetServicesEndpointsHandler: discovery.GetServicesEndpointsHandlerFunc(func(params discovery.GetServicesEndpointsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation DiscoveryGetServicesEndpoints has not yet been implemented") + HTTPRequestRuleGetAllHTTPRequestRuleBackendHandler: http_request_rule.GetAllHTTPRequestRuleBackendHandlerFunc(func(params http_request_rule.GetAllHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.GetAllHTTPRequestRuleBackend has not yet been implemented") }), - SitesGetSiteHandler: sites.GetSiteHandlerFunc(func(params sites.GetSiteParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation SitesGetSite has not yet been implemented") + HTTPRequestRuleGetAllHTTPRequestRuleDefaultsHandler: http_request_rule.GetAllHTTPRequestRuleDefaultsHandlerFunc(func(params http_request_rule.GetAllHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.GetAllHTTPRequestRuleDefaults has not yet been implemented") }), - SitesGetSitesHandler: sites.GetSitesHandlerFunc(func(params sites.GetSitesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation SitesGetSites has not yet been implemented") + HTTPRequestRuleGetAllHTTPRequestRuleFrontendHandler: http_request_rule.GetAllHTTPRequestRuleFrontendHandlerFunc(func(params http_request_rule.GetAllHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.GetAllHTTPRequestRuleFrontend has not yet been implemented") }), - SpecificationGetSpecificationHandler: specification.GetSpecificationHandlerFunc(func(params specification.GetSpecificationParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation SpecificationGetSpecification has not yet been implemented") + HTTPResponseRuleGetAllHTTPResponseRuleBackendHandler: http_response_rule.GetAllHTTPResponseRuleBackendHandlerFunc(func(params http_response_rule.GetAllHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.GetAllHTTPResponseRuleBackend has not yet been implemented") }), - StatsGetStatsHandler: stats.GetStatsHandlerFunc(func(params stats.GetStatsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation StatsGetStats has not yet been implemented") + HTTPResponseRuleGetAllHTTPResponseRuleDefaultsHandler: http_response_rule.GetAllHTTPResponseRuleDefaultsHandlerFunc(func(params http_response_rule.GetAllHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.GetAllHTTPResponseRuleDefaults has not yet been implemented") }), - DiscoveryGetStatsEndpointsHandler: discovery.GetStatsEndpointsHandlerFunc(func(params discovery.GetStatsEndpointsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation DiscoveryGetStatsEndpoints has not yet been implemented") + HTTPResponseRuleGetAllHTTPResponseRuleFrontendHandler: http_response_rule.GetAllHTTPResponseRuleFrontendHandlerFunc(func(params http_response_rule.GetAllHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.GetAllHTTPResponseRuleFrontend has not yet been implemented") }), - StickRuleGetStickRuleHandler: stick_rule.GetStickRuleHandlerFunc(func(params stick_rule.GetStickRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation StickRuleGetStickRule has not yet been implemented") + LogTargetGetAllLogTargetBackendHandler: log_target.GetAllLogTargetBackendHandlerFunc(func(params log_target.GetAllLogTargetBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetAllLogTargetBackend has not yet been implemented") }), - StickRuleGetStickRulesHandler: stick_rule.GetStickRulesHandlerFunc(func(params stick_rule.GetStickRulesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation StickRuleGetStickRules has not yet been implemented") + LogTargetGetAllLogTargetDefaultsHandler: log_target.GetAllLogTargetDefaultsHandlerFunc(func(params log_target.GetAllLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetAllLogTargetDefaults has not yet been implemented") }), - TCPRequestRuleGetTCPRequestRuleHandler: tcp_request_rule.GetTCPRequestRuleHandlerFunc(func(params tcp_request_rule.GetTCPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPRequestRuleGetTCPRequestRule has not yet been implemented") + LogTargetGetAllLogTargetFrontendHandler: log_target.GetAllLogTargetFrontendHandlerFunc(func(params log_target.GetAllLogTargetFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetAllLogTargetFrontend has not yet been implemented") }), - TCPRequestRuleGetTCPRequestRulesHandler: tcp_request_rule.GetTCPRequestRulesHandlerFunc(func(params tcp_request_rule.GetTCPRequestRulesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPRequestRuleGetTCPRequestRules has not yet been implemented") + LogTargetGetAllLogTargetGlobalHandler: log_target.GetAllLogTargetGlobalHandlerFunc(func(params log_target.GetAllLogTargetGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetAllLogTargetGlobal has not yet been implemented") }), - TCPResponseRuleGetTCPResponseRuleHandler: tcp_response_rule.GetTCPResponseRuleHandlerFunc(func(params tcp_response_rule.GetTCPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPResponseRuleGetTCPResponseRule has not yet been implemented") + LogTargetGetAllLogTargetLogForwardHandler: log_target.GetAllLogTargetLogForwardHandlerFunc(func(params log_target.GetAllLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetAllLogTargetLogForward has not yet been implemented") }), - TCPResponseRuleGetTCPResponseRulesHandler: tcp_response_rule.GetTCPResponseRulesHandlerFunc(func(params tcp_response_rule.GetTCPResponseRulesParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPResponseRuleGetTCPResponseRules has not yet been implemented") + LogTargetGetAllLogTargetPeerHandler: log_target.GetAllLogTargetPeerHandlerFunc(func(params log_target.GetAllLogTargetPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetAllLogTargetPeer has not yet been implemented") }), - TransactionsGetTransactionHandler: transactions.GetTransactionHandlerFunc(func(params transactions.GetTransactionParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TransactionsGetTransaction has not yet been implemented") + QUICInitialRuleGetAllQUICInitialRuleDefaultsHandler: quic_initial_rule.GetAllQUICInitialRuleDefaultsHandlerFunc(func(params quic_initial_rule.GetAllQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.GetAllQUICInitialRuleDefaults has not yet been implemented") }), - TransactionsGetTransactionsHandler: transactions.GetTransactionsHandlerFunc(func(params transactions.GetTransactionsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TransactionsGetTransactions has not yet been implemented") + QUICInitialRuleGetAllQUICInitialRuleFrontendHandler: quic_initial_rule.GetAllQUICInitialRuleFrontendHandlerFunc(func(params quic_initial_rule.GetAllQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.GetAllQUICInitialRuleFrontend has not yet been implemented") }), - ConfigurationPostHAProxyConfigurationHandler: configuration.PostHAProxyConfigurationHandlerFunc(func(params configuration.PostHAProxyConfigurationParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ConfigurationPostHAProxyConfiguration has not yet been implemented") + MapsGetAllRuntimeMapFilesHandler: maps.GetAllRuntimeMapFilesHandlerFunc(func(params maps.GetAllRuntimeMapFilesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.GetAllRuntimeMapFiles has not yet been implemented") }), - ACLReplaceACLHandler: acl.ReplaceACLHandlerFunc(func(params acl.ReplaceACLParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ACLReplaceACL has not yet been implemented") + ServerGetAllRuntimeServerHandler: serverops.GetAllRuntimeServerHandlerFunc(func(params serverops.GetAllRuntimeServerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetAllRuntimeServer has not yet been implemented") }), - BackendReplaceBackendHandler: backend.ReplaceBackendHandlerFunc(func(params backend.ReplaceBackendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendReplaceBackend has not yet been implemented") + SslFrontUseGetAllSSLFrontUsesHandler: s_s_l_front_use.GetAllSSLFrontUsesHandlerFunc(func(params s_s_l_front_use.GetAllSSLFrontUsesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_front_use.GetAllSSLFrontUses has not yet been implemented") }), - BackendSwitchingRuleReplaceBackendSwitchingRuleHandler: backend_switching_rule.ReplaceBackendSwitchingRuleHandlerFunc(func(params backend_switching_rule.ReplaceBackendSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BackendSwitchingRuleReplaceBackendSwitchingRule has not yet been implemented") + ServerGetAllServerBackendHandler: serverops.GetAllServerBackendHandlerFunc(func(params serverops.GetAllServerBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetAllServerBackend has not yet been implemented") }), - BindReplaceBindHandler: bind.ReplaceBindHandlerFunc(func(params bind.ReplaceBindParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation BindReplaceBind has not yet been implemented") + ServerGetAllServerPeerHandler: serverops.GetAllServerPeerHandlerFunc(func(params serverops.GetAllServerPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetAllServerPeer has not yet been implemented") }), - DefaultsReplaceDefaultsHandler: defaults.ReplaceDefaultsHandlerFunc(func(params defaults.ReplaceDefaultsParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation DefaultsReplaceDefaults has not yet been implemented") + ServerGetAllServerRingHandler: serverops.GetAllServerRingHandlerFunc(func(params serverops.GetAllServerRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetAllServerRing has not yet been implemented") }), - FilterReplaceFilterHandler: filter.ReplaceFilterHandlerFunc(func(params filter.ReplaceFilterParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FilterReplaceFilter has not yet been implemented") + SpoeGetAllSpoeAgentHandler: spoe.GetAllSpoeAgentHandlerFunc(func(params spoe.GetAllSpoeAgentParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetAllSpoeAgent has not yet been implemented") }), - FrontendReplaceFrontendHandler: frontend.ReplaceFrontendHandlerFunc(func(params frontend.ReplaceFrontendParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation FrontendReplaceFrontend has not yet been implemented") + SpoeGetAllSpoeFilesHandler: spoe.GetAllSpoeFilesHandlerFunc(func(params spoe.GetAllSpoeFilesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetAllSpoeFiles has not yet been implemented") }), - GlobalReplaceGlobalHandler: global.ReplaceGlobalHandlerFunc(func(params global.ReplaceGlobalParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation GlobalReplaceGlobal has not yet been implemented") + SpoeGetAllSpoeGroupHandler: spoe.GetAllSpoeGroupHandlerFunc(func(params spoe.GetAllSpoeGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetAllSpoeGroup has not yet been implemented") }), - HTTPRequestRuleReplaceHTTPRequestRuleHandler: http_request_rule.ReplaceHTTPRequestRuleHandlerFunc(func(params http_request_rule.ReplaceHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPRequestRuleReplaceHTTPRequestRule has not yet been implemented") + SpoeGetAllSpoeMessageHandler: spoe.GetAllSpoeMessageHandlerFunc(func(params spoe.GetAllSpoeMessageParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetAllSpoeMessage has not yet been implemented") }), - HTTPResponseRuleReplaceHTTPResponseRuleHandler: http_response_rule.ReplaceHTTPResponseRuleHandlerFunc(func(params http_response_rule.ReplaceHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation HTTPResponseRuleReplaceHTTPResponseRule has not yet been implemented") + SpoeGetAllSpoeScopeHandler: spoe.GetAllSpoeScopeHandlerFunc(func(params spoe.GetAllSpoeScopeParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetAllSpoeScope has not yet been implemented") }), - LogTargetReplaceLogTargetHandler: log_target.ReplaceLogTargetHandlerFunc(func(params log_target.ReplaceLogTargetParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation LogTargetReplaceLogTarget has not yet been implemented") + SpoeTransactionsGetAllSpoeTransactionHandler: spoe_transactions.GetAllSpoeTransactionHandlerFunc(func(params spoe_transactions.GetAllSpoeTransactionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe_transactions.GetAllSpoeTransaction has not yet been implemented") }), - ServerReplaceServerHandler: server.ReplaceServerHandlerFunc(func(params server.ReplaceServerParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerReplaceServer has not yet been implemented") + StorageGetAllStorageGeneralFilesHandler: storage.GetAllStorageGeneralFilesHandlerFunc(func(params storage.GetAllStorageGeneralFilesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetAllStorageGeneralFiles has not yet been implemented") }), - ServerSwitchingRuleReplaceServerSwitchingRuleHandler: server_switching_rule.ReplaceServerSwitchingRuleHandlerFunc(func(params server_switching_rule.ReplaceServerSwitchingRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation ServerSwitchingRuleReplaceServerSwitchingRule has not yet been implemented") + StorageGetAllStorageMapFilesHandler: storage.GetAllStorageMapFilesHandlerFunc(func(params storage.GetAllStorageMapFilesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetAllStorageMapFiles has not yet been implemented") }), - SitesReplaceSiteHandler: sites.ReplaceSiteHandlerFunc(func(params sites.ReplaceSiteParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation SitesReplaceSite has not yet been implemented") + StorageGetAllStorageSSLCertificatesHandler: storage.GetAllStorageSSLCertificatesHandlerFunc(func(params storage.GetAllStorageSSLCertificatesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetAllStorageSSLCertificates has not yet been implemented") }), - StickRuleReplaceStickRuleHandler: stick_rule.ReplaceStickRuleHandlerFunc(func(params stick_rule.ReplaceStickRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation StickRuleReplaceStickRule has not yet been implemented") + StorageGetAllStorageSSLCrtListFilesHandler: storage.GetAllStorageSSLCrtListFilesHandlerFunc(func(params storage.GetAllStorageSSLCrtListFilesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetAllStorageSSLCrtListFiles has not yet been implemented") }), - TCPRequestRuleReplaceTCPRequestRuleHandler: tcp_request_rule.ReplaceTCPRequestRuleHandlerFunc(func(params tcp_request_rule.ReplaceTCPRequestRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPRequestRuleReplaceTCPRequestRule has not yet been implemented") + TCPCheckGetAllTCPCheckBackendHandler: tcp_check.GetAllTCPCheckBackendHandlerFunc(func(params tcp_check.GetAllTCPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.GetAllTCPCheckBackend has not yet been implemented") }), - TCPResponseRuleReplaceTCPResponseRuleHandler: tcp_response_rule.ReplaceTCPResponseRuleHandlerFunc(func(params tcp_response_rule.ReplaceTCPResponseRuleParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TCPResponseRuleReplaceTCPResponseRule has not yet been implemented") + TCPCheckGetAllTCPCheckDefaultsHandler: tcp_check.GetAllTCPCheckDefaultsHandlerFunc(func(params tcp_check.GetAllTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.GetAllTCPCheckDefaults has not yet been implemented") }), - TransactionsStartTransactionHandler: transactions.StartTransactionHandlerFunc(func(params transactions.StartTransactionParams, principal interface{}) middleware.Responder { - return middleware.NotImplemented("operation TransactionsStartTransaction has not yet been implemented") + TCPRequestRuleGetAllTCPRequestRuleBackendHandler: tcp_request_rule.GetAllTCPRequestRuleBackendHandlerFunc(func(params tcp_request_rule.GetAllTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.GetAllTCPRequestRuleBackend has not yet been implemented") }), - - // Applies when the Authorization header is set with the Basic scheme - BasicAuthAuth: func(user string, pass string) (interface{}, error) { - return nil, errors.NotImplemented("basic auth (basic_auth) has not yet been implemented") - }, - - // default authorizer is authorized meaning no requests are blocked - APIAuthorizer: security.Authorized(), - } -} - -/*DataPlaneAPI API for editing and managing haproxy instances. Provides process information, configuration management, -haproxy stats and logs. -*/ -type DataPlaneAPI struct { - spec *loads.Document - context *middleware.Context - handlers map[string]map[string]http.Handler - formats strfmt.Registry - customConsumers map[string]runtime.Consumer - customProducers map[string]runtime.Producer - defaultConsumes string - defaultProduces string - Middleware func(middleware.Builder) http.Handler - - // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. - // It has a default implementation in the security package, however you can replace it for your particular usage. - BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator - // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. - // It has a default implementation in the security package, however you can replace it for your particular usage. - APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator - // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. - // It has a default implementation in the security package, however you can replace it for your particular usage. - BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator - - // JSONConsumer registers a consumer for a "application/json" mime type - JSONConsumer runtime.Consumer - // TxtConsumer registers a consumer for a "text/plain" mime type - TxtConsumer runtime.Consumer - - // JSONProducer registers a producer for a "application/json" mime type - JSONProducer runtime.Producer - // TxtProducer registers a producer for a "text/plain" mime type - TxtProducer runtime.Producer - - // BasicAuthAuth registers a function that takes username and password and returns a principal - // it performs authentication with basic auth - BasicAuthAuth func(string, string) (interface{}, error) - + TCPRequestRuleGetAllTCPRequestRuleDefaultsHandler: tcp_request_rule.GetAllTCPRequestRuleDefaultsHandlerFunc(func(params tcp_request_rule.GetAllTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.GetAllTCPRequestRuleDefaults has not yet been implemented") + }), + TCPRequestRuleGetAllTCPRequestRuleFrontendHandler: tcp_request_rule.GetAllTCPRequestRuleFrontendHandlerFunc(func(params tcp_request_rule.GetAllTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.GetAllTCPRequestRuleFrontend has not yet been implemented") + }), + TCPResponseRuleGetAllTCPResponseRuleBackendHandler: tcp_response_rule.GetAllTCPResponseRuleBackendHandlerFunc(func(params tcp_response_rule.GetAllTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.GetAllTCPResponseRuleBackend has not yet been implemented") + }), + TCPResponseRuleGetAllTCPResponseRuleDefaultsHandler: tcp_response_rule.GetAllTCPResponseRuleDefaultsHandlerFunc(func(params tcp_response_rule.GetAllTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.GetAllTCPResponseRuleDefaults has not yet been implemented") + }), + BackendGetBackendHandler: backend.GetBackendHandlerFunc(func(params backend.GetBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation backend.GetBackend has not yet been implemented") + }), + BackendSwitchingRuleGetBackendSwitchingRuleHandler: backend_switching_rule.GetBackendSwitchingRuleHandlerFunc(func(params backend_switching_rule.GetBackendSwitchingRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation backend_switching_rule.GetBackendSwitchingRule has not yet been implemented") + }), + BackendSwitchingRuleGetBackendSwitchingRulesHandler: backend_switching_rule.GetBackendSwitchingRulesHandlerFunc(func(params backend_switching_rule.GetBackendSwitchingRulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation backend_switching_rule.GetBackendSwitchingRules has not yet been implemented") + }), + BackendGetBackendsHandler: backend.GetBackendsHandlerFunc(func(params backend.GetBackendsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation backend.GetBackends has not yet been implemented") + }), + BindGetBindFrontendHandler: bind.GetBindFrontendHandlerFunc(func(params bind.GetBindFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.GetBindFrontend has not yet been implemented") + }), + BindGetBindLogForwardHandler: bind.GetBindLogForwardHandlerFunc(func(params bind.GetBindLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.GetBindLogForward has not yet been implemented") + }), + BindGetBindPeerHandler: bind.GetBindPeerHandlerFunc(func(params bind.GetBindPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.GetBindPeer has not yet been implemented") + }), + SslRuntimeGetCaEntryHandler: s_s_l_runtime.GetCaEntryHandlerFunc(func(params s_s_l_runtime.GetCaEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetCaEntry has not yet been implemented") + }), + SslRuntimeGetCaFileHandler: s_s_l_runtime.GetCaFileHandlerFunc(func(params s_s_l_runtime.GetCaFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetCaFile has not yet been implemented") + }), + CacheGetCacheHandler: cache.GetCacheHandlerFunc(func(params cache.GetCacheParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cache.GetCache has not yet been implemented") + }), + CacheGetCachesHandler: cache.GetCachesHandlerFunc(func(params cache.GetCachesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cache.GetCaches has not yet been implemented") + }), + SslRuntimeGetCertHandler: s_s_l_runtime.GetCertHandlerFunc(func(params s_s_l_runtime.GetCertParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetCert has not yet been implemented") + }), + ClusterGetClusterHandler: cluster.GetClusterHandlerFunc(func(params cluster.GetClusterParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cluster.GetCluster has not yet been implemented") + }), + DiscoveryGetConfigurationEndpointsHandler: discovery.GetConfigurationEndpointsHandlerFunc(func(params discovery.GetConfigurationEndpointsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation discovery.GetConfigurationEndpoints has not yet been implemented") + }), + ConfigurationGetConfigurationVersionHandler: configuration.GetConfigurationVersionHandlerFunc(func(params configuration.GetConfigurationVersionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation configuration.GetConfigurationVersion has not yet been implemented") + }), + ServiceDiscoveryGetConsulHandler: service_discovery.GetConsulHandlerFunc(func(params service_discovery.GetConsulParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.GetConsul has not yet been implemented") + }), + ServiceDiscoveryGetConsulsHandler: service_discovery.GetConsulsHandlerFunc(func(params service_discovery.GetConsulsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.GetConsuls has not yet been implemented") + }), + SslRuntimeGetCrlHandler: s_s_l_runtime.GetCrlHandlerFunc(func(params s_s_l_runtime.GetCrlParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.GetCrl has not yet been implemented") + }), + CrtLoadGetCrtLoadHandler: crt_load.GetCrtLoadHandlerFunc(func(params crt_load.GetCrtLoadParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_load.GetCrtLoad has not yet been implemented") + }), + CrtLoadGetCrtLoadsHandler: crt_load.GetCrtLoadsHandlerFunc(func(params crt_load.GetCrtLoadsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_load.GetCrtLoads has not yet been implemented") + }), + CrtStoreGetCrtStoreHandler: crt_store.GetCrtStoreHandlerFunc(func(params crt_store.GetCrtStoreParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_store.GetCrtStore has not yet been implemented") + }), + CrtStoreGetCrtStoresHandler: crt_store.GetCrtStoresHandlerFunc(func(params crt_store.GetCrtStoresParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_store.GetCrtStores has not yet been implemented") + }), + DeclareCaptureGetDeclareCaptureHandler: declare_capture.GetDeclareCaptureHandlerFunc(func(params declare_capture.GetDeclareCaptureParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation declare_capture.GetDeclareCapture has not yet been implemented") + }), + DeclareCaptureGetDeclareCapturesHandler: declare_capture.GetDeclareCapturesHandlerFunc(func(params declare_capture.GetDeclareCapturesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation declare_capture.GetDeclareCaptures has not yet been implemented") + }), + DefaultsGetDefaultsSectionHandler: defaults.GetDefaultsSectionHandlerFunc(func(params defaults.GetDefaultsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation defaults.GetDefaultsSection has not yet been implemented") + }), + DefaultsGetDefaultsSectionsHandler: defaults.GetDefaultsSectionsHandlerFunc(func(params defaults.GetDefaultsSectionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation defaults.GetDefaultsSections has not yet been implemented") + }), + DgramBindGetDgramBindHandler: dgram_bind.GetDgramBindHandlerFunc(func(params dgram_bind.GetDgramBindParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation dgram_bind.GetDgramBind has not yet been implemented") + }), + DgramBindGetDgramBindsHandler: dgram_bind.GetDgramBindsHandlerFunc(func(params dgram_bind.GetDgramBindsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation dgram_bind.GetDgramBinds has not yet been implemented") + }), + FCGIAppGetFCGIAppHandler: fcgi_app.GetFCGIAppHandlerFunc(func(params fcgi_app.GetFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation fcgi_app.GetFCGIApp has not yet been implemented") + }), + FCGIAppGetFCGIAppsHandler: fcgi_app.GetFCGIAppsHandlerFunc(func(params fcgi_app.GetFCGIAppsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation fcgi_app.GetFCGIApps has not yet been implemented") + }), + FilterGetFilterBackendHandler: filter.GetFilterBackendHandlerFunc(func(params filter.GetFilterBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.GetFilterBackend has not yet been implemented") + }), + FilterGetFilterFrontendHandler: filter.GetFilterFrontendHandlerFunc(func(params filter.GetFilterFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.GetFilterFrontend has not yet been implemented") + }), + FrontendGetFrontendHandler: frontend.GetFrontendHandlerFunc(func(params frontend.GetFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation frontend.GetFrontend has not yet been implemented") + }), + FrontendGetFrontendsHandler: frontend.GetFrontendsHandlerFunc(func(params frontend.GetFrontendsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation frontend.GetFrontends has not yet been implemented") + }), + GlobalGetGlobalHandler: global.GetGlobalHandlerFunc(func(params global.GetGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation global.GetGlobal has not yet been implemented") + }), + GroupGetGroupHandler: group.GetGroupHandlerFunc(func(params group.GetGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation group.GetGroup has not yet been implemented") + }), + GroupGetGroupsHandler: group.GetGroupsHandlerFunc(func(params group.GetGroupsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation group.GetGroups has not yet been implemented") + }), + ConfigurationGetHAProxyConfigurationHandler: configuration.GetHAProxyConfigurationHandlerFunc(func(params configuration.GetHAProxyConfigurationParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation configuration.GetHAProxyConfiguration has not yet been implemented") + }), + HTTPAfterResponseRuleGetHTTPAfterResponseRuleBackendHandler: http_after_response_rule.GetHTTPAfterResponseRuleBackendHandlerFunc(func(params http_after_response_rule.GetHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.GetHTTPAfterResponseRuleBackend has not yet been implemented") + }), + HTTPAfterResponseRuleGetHTTPAfterResponseRuleDefaultsHandler: http_after_response_rule.GetHTTPAfterResponseRuleDefaultsHandlerFunc(func(params http_after_response_rule.GetHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.GetHTTPAfterResponseRuleDefaults has not yet been implemented") + }), + HTTPAfterResponseRuleGetHTTPAfterResponseRuleFrontendHandler: http_after_response_rule.GetHTTPAfterResponseRuleFrontendHandlerFunc(func(params http_after_response_rule.GetHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.GetHTTPAfterResponseRuleFrontend has not yet been implemented") + }), + HTTPCheckGetHTTPCheckBackendHandler: http_check.GetHTTPCheckBackendHandlerFunc(func(params http_check.GetHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.GetHTTPCheckBackend has not yet been implemented") + }), + HTTPCheckGetHTTPCheckDefaultsHandler: http_check.GetHTTPCheckDefaultsHandlerFunc(func(params http_check.GetHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.GetHTTPCheckDefaults has not yet been implemented") + }), + HTTPErrorRuleGetHTTPErrorRuleBackendHandler: http_error_rule.GetHTTPErrorRuleBackendHandlerFunc(func(params http_error_rule.GetHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.GetHTTPErrorRuleBackend has not yet been implemented") + }), + HTTPErrorRuleGetHTTPErrorRuleDefaultsHandler: http_error_rule.GetHTTPErrorRuleDefaultsHandlerFunc(func(params http_error_rule.GetHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.GetHTTPErrorRuleDefaults has not yet been implemented") + }), + HTTPErrorRuleGetHTTPErrorRuleFrontendHandler: http_error_rule.GetHTTPErrorRuleFrontendHandlerFunc(func(params http_error_rule.GetHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.GetHTTPErrorRuleFrontend has not yet been implemented") + }), + HTTPErrorsGetHTTPErrorsSectionHandler: http_errors.GetHTTPErrorsSectionHandlerFunc(func(params http_errors.GetHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_errors.GetHTTPErrorsSection has not yet been implemented") + }), + HTTPErrorsGetHTTPErrorsSectionsHandler: http_errors.GetHTTPErrorsSectionsHandlerFunc(func(params http_errors.GetHTTPErrorsSectionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_errors.GetHTTPErrorsSections has not yet been implemented") + }), + HTTPRequestRuleGetHTTPRequestRuleBackendHandler: http_request_rule.GetHTTPRequestRuleBackendHandlerFunc(func(params http_request_rule.GetHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.GetHTTPRequestRuleBackend has not yet been implemented") + }), + HTTPRequestRuleGetHTTPRequestRuleDefaultsHandler: http_request_rule.GetHTTPRequestRuleDefaultsHandlerFunc(func(params http_request_rule.GetHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.GetHTTPRequestRuleDefaults has not yet been implemented") + }), + HTTPRequestRuleGetHTTPRequestRuleFrontendHandler: http_request_rule.GetHTTPRequestRuleFrontendHandlerFunc(func(params http_request_rule.GetHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.GetHTTPRequestRuleFrontend has not yet been implemented") + }), + HTTPResponseRuleGetHTTPResponseRuleBackendHandler: http_response_rule.GetHTTPResponseRuleBackendHandlerFunc(func(params http_response_rule.GetHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.GetHTTPResponseRuleBackend has not yet been implemented") + }), + HTTPResponseRuleGetHTTPResponseRuleDefaultsHandler: http_response_rule.GetHTTPResponseRuleDefaultsHandlerFunc(func(params http_response_rule.GetHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.GetHTTPResponseRuleDefaults has not yet been implemented") + }), + HTTPResponseRuleGetHTTPResponseRuleFrontendHandler: http_response_rule.GetHTTPResponseRuleFrontendHandlerFunc(func(params http_response_rule.GetHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.GetHTTPResponseRuleFrontend has not yet been implemented") + }), + DiscoveryGetHaproxyEndpointsHandler: discovery.GetHaproxyEndpointsHandlerFunc(func(params discovery.GetHaproxyEndpointsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation discovery.GetHaproxyEndpoints has not yet been implemented") + }), + InformationGetHaproxyProcessInfoHandler: information.GetHaproxyProcessInfoHandlerFunc(func(params information.GetHaproxyProcessInfoParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation information.GetHaproxyProcessInfo has not yet been implemented") + }), + HealthGetHealthHandler: health.GetHealthHandlerFunc(func(params health.GetHealthParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation health.GetHealth has not yet been implemented") + }), + InformationGetInfoHandler: information.GetInfoHandlerFunc(func(params information.GetInfoParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation information.GetInfo has not yet been implemented") + }), + LogForwardGetLogForwardHandler: log_forward.GetLogForwardHandlerFunc(func(params log_forward.GetLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_forward.GetLogForward has not yet been implemented") + }), + LogForwardGetLogForwardsHandler: log_forward.GetLogForwardsHandlerFunc(func(params log_forward.GetLogForwardsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_forward.GetLogForwards has not yet been implemented") + }), + LogProfileGetLogProfileHandler: log_profile.GetLogProfileHandlerFunc(func(params log_profile.GetLogProfileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_profile.GetLogProfile has not yet been implemented") + }), + LogProfileGetLogProfilesHandler: log_profile.GetLogProfilesHandlerFunc(func(params log_profile.GetLogProfilesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_profile.GetLogProfiles has not yet been implemented") + }), + LogTargetGetLogTargetBackendHandler: log_target.GetLogTargetBackendHandlerFunc(func(params log_target.GetLogTargetBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetLogTargetBackend has not yet been implemented") + }), + LogTargetGetLogTargetDefaultsHandler: log_target.GetLogTargetDefaultsHandlerFunc(func(params log_target.GetLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetLogTargetDefaults has not yet been implemented") + }), + LogTargetGetLogTargetFrontendHandler: log_target.GetLogTargetFrontendHandlerFunc(func(params log_target.GetLogTargetFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetLogTargetFrontend has not yet been implemented") + }), + LogTargetGetLogTargetGlobalHandler: log_target.GetLogTargetGlobalHandlerFunc(func(params log_target.GetLogTargetGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetLogTargetGlobal has not yet been implemented") + }), + LogTargetGetLogTargetLogForwardHandler: log_target.GetLogTargetLogForwardHandlerFunc(func(params log_target.GetLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetLogTargetLogForward has not yet been implemented") + }), + LogTargetGetLogTargetPeerHandler: log_target.GetLogTargetPeerHandlerFunc(func(params log_target.GetLogTargetPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.GetLogTargetPeer has not yet been implemented") + }), + MailerEntryGetMailerEntriesHandler: mailer_entry.GetMailerEntriesHandlerFunc(func(params mailer_entry.GetMailerEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailer_entry.GetMailerEntries has not yet been implemented") + }), + MailerEntryGetMailerEntryHandler: mailer_entry.GetMailerEntryHandlerFunc(func(params mailer_entry.GetMailerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailer_entry.GetMailerEntry has not yet been implemented") + }), + MailersGetMailersSectionHandler: mailers.GetMailersSectionHandlerFunc(func(params mailers.GetMailersSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailers.GetMailersSection has not yet been implemented") + }), + MailersGetMailersSectionsHandler: mailers.GetMailersSectionsHandlerFunc(func(params mailers.GetMailersSectionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailers.GetMailersSections has not yet been implemented") + }), + NameserverGetNameserverHandler: nameserver.GetNameserverHandlerFunc(func(params nameserver.GetNameserverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation nameserver.GetNameserver has not yet been implemented") + }), + NameserverGetNameserversHandler: nameserver.GetNameserversHandlerFunc(func(params nameserver.GetNameserversParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation nameserver.GetNameservers has not yet been implemented") + }), + MapsGetOneRuntimeMapHandler: maps.GetOneRuntimeMapHandlerFunc(func(params maps.GetOneRuntimeMapParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.GetOneRuntimeMap has not yet been implemented") + }), + SpoeGetOneSpoeFileHandler: spoe.GetOneSpoeFileHandlerFunc(func(params spoe.GetOneSpoeFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetOneSpoeFile has not yet been implemented") + }), + StorageGetOneStorageGeneralFileHandler: storage.GetOneStorageGeneralFileHandlerFunc(func(params storage.GetOneStorageGeneralFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetOneStorageGeneralFile has not yet been implemented") + }), + StorageGetOneStorageMapHandler: storage.GetOneStorageMapHandlerFunc(func(params storage.GetOneStorageMapParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetOneStorageMap has not yet been implemented") + }), + StorageGetOneStorageSSLCertificateHandler: storage.GetOneStorageSSLCertificateHandlerFunc(func(params storage.GetOneStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetOneStorageSSLCertificate has not yet been implemented") + }), + StorageGetOneStorageSSLCrtListFileHandler: storage.GetOneStorageSSLCrtListFileHandlerFunc(func(params storage.GetOneStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.GetOneStorageSSLCrtListFile has not yet been implemented") + }), + SpecificationOpenapiv3GetOpenapiv3SpecificationHandler: specification_openapiv3.GetOpenapiv3SpecificationHandlerFunc(func(params specification_openapiv3.GetOpenapiv3SpecificationParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation specification_openapiv3.GetOpenapiv3Specification has not yet been implemented") + }), + PeerEntryGetPeerEntriesHandler: peer_entry.GetPeerEntriesHandlerFunc(func(params peer_entry.GetPeerEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer_entry.GetPeerEntries has not yet been implemented") + }), + PeerEntryGetPeerEntryHandler: peer_entry.GetPeerEntryHandlerFunc(func(params peer_entry.GetPeerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer_entry.GetPeerEntry has not yet been implemented") + }), + PeerGetPeerSectionHandler: peer.GetPeerSectionHandlerFunc(func(params peer.GetPeerSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer.GetPeerSection has not yet been implemented") + }), + PeerGetPeerSectionsHandler: peer.GetPeerSectionsHandlerFunc(func(params peer.GetPeerSectionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer.GetPeerSections has not yet been implemented") + }), + ProcessManagerGetProgramHandler: process_manager.GetProgramHandlerFunc(func(params process_manager.GetProgramParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation process_manager.GetProgram has not yet been implemented") + }), + ProcessManagerGetProgramsHandler: process_manager.GetProgramsHandlerFunc(func(params process_manager.GetProgramsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation process_manager.GetPrograms has not yet been implemented") + }), + QUICInitialRuleGetQUICInitialRuleDefaultsHandler: quic_initial_rule.GetQUICInitialRuleDefaultsHandlerFunc(func(params quic_initial_rule.GetQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.GetQUICInitialRuleDefaults has not yet been implemented") + }), + QUICInitialRuleGetQUICInitialRuleFrontendHandler: quic_initial_rule.GetQUICInitialRuleFrontendHandlerFunc(func(params quic_initial_rule.GetQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.GetQUICInitialRuleFrontend has not yet been implemented") + }), + ReloadsGetReloadHandler: reloads.GetReloadHandlerFunc(func(params reloads.GetReloadParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation reloads.GetReload has not yet been implemented") + }), + ReloadsGetReloadsHandler: reloads.GetReloadsHandlerFunc(func(params reloads.GetReloadsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation reloads.GetReloads has not yet been implemented") + }), + ResolverGetResolverHandler: resolver.GetResolverHandlerFunc(func(params resolver.GetResolverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation resolver.GetResolver has not yet been implemented") + }), + ResolverGetResolversHandler: resolver.GetResolversHandlerFunc(func(params resolver.GetResolversParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation resolver.GetResolvers has not yet been implemented") + }), + RingGetRingHandler: ring.GetRingHandlerFunc(func(params ring.GetRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ring.GetRing has not yet been implemented") + }), + RingGetRingsHandler: ring.GetRingsHandlerFunc(func(params ring.GetRingsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ring.GetRings has not yet been implemented") + }), + DiscoveryGetRuntimeEndpointsHandler: discovery.GetRuntimeEndpointsHandlerFunc(func(params discovery.GetRuntimeEndpointsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation discovery.GetRuntimeEndpoints has not yet been implemented") + }), + MapsGetRuntimeMapEntryHandler: maps.GetRuntimeMapEntryHandlerFunc(func(params maps.GetRuntimeMapEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.GetRuntimeMapEntry has not yet been implemented") + }), + ServerGetRuntimeServerHandler: serverops.GetRuntimeServerHandlerFunc(func(params serverops.GetRuntimeServerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetRuntimeServer has not yet been implemented") + }), + SslFrontUseGetSSLFrontUseHandler: s_s_l_front_use.GetSSLFrontUseHandlerFunc(func(params s_s_l_front_use.GetSSLFrontUseParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_front_use.GetSSLFrontUse has not yet been implemented") + }), + ServerGetServerBackendHandler: serverops.GetServerBackendHandlerFunc(func(params serverops.GetServerBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetServerBackend has not yet been implemented") + }), + ServerGetServerPeerHandler: serverops.GetServerPeerHandlerFunc(func(params serverops.GetServerPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetServerPeer has not yet been implemented") + }), + ServerGetServerRingHandler: serverops.GetServerRingHandlerFunc(func(params serverops.GetServerRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.GetServerRing has not yet been implemented") + }), + ServerSwitchingRuleGetServerSwitchingRuleHandler: server_switching_rule.GetServerSwitchingRuleHandlerFunc(func(params server_switching_rule.GetServerSwitchingRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_switching_rule.GetServerSwitchingRule has not yet been implemented") + }), + ServerSwitchingRuleGetServerSwitchingRulesHandler: server_switching_rule.GetServerSwitchingRulesHandlerFunc(func(params server_switching_rule.GetServerSwitchingRulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_switching_rule.GetServerSwitchingRules has not yet been implemented") + }), + ServerTemplateGetServerTemplateHandler: server_template.GetServerTemplateHandlerFunc(func(params server_template.GetServerTemplateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_template.GetServerTemplate has not yet been implemented") + }), + ServerTemplateGetServerTemplatesHandler: server_template.GetServerTemplatesHandlerFunc(func(params server_template.GetServerTemplatesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_template.GetServerTemplates has not yet been implemented") + }), + DiscoveryGetServicesEndpointsHandler: discovery.GetServicesEndpointsHandlerFunc(func(params discovery.GetServicesEndpointsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation discovery.GetServicesEndpoints has not yet been implemented") + }), + SitesGetSiteHandler: sites.GetSiteHandlerFunc(func(params sites.GetSiteParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation sites.GetSite has not yet been implemented") + }), + SitesGetSitesHandler: sites.GetSitesHandlerFunc(func(params sites.GetSitesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation sites.GetSites has not yet been implemented") + }), + SpecificationGetSpecificationHandler: specification.GetSpecificationHandlerFunc(func(params specification.GetSpecificationParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation specification.GetSpecification has not yet been implemented") + }), + SpoeGetSpoeAgentHandler: spoe.GetSpoeAgentHandlerFunc(func(params spoe.GetSpoeAgentParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetSpoeAgent has not yet been implemented") + }), + SpoeGetSpoeConfigurationVersionHandler: spoe.GetSpoeConfigurationVersionHandlerFunc(func(params spoe.GetSpoeConfigurationVersionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetSpoeConfigurationVersion has not yet been implemented") + }), + DiscoveryGetSpoeEndpointsHandler: discovery.GetSpoeEndpointsHandlerFunc(func(params discovery.GetSpoeEndpointsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation discovery.GetSpoeEndpoints has not yet been implemented") + }), + SpoeGetSpoeGroupHandler: spoe.GetSpoeGroupHandlerFunc(func(params spoe.GetSpoeGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetSpoeGroup has not yet been implemented") + }), + SpoeGetSpoeMessageHandler: spoe.GetSpoeMessageHandlerFunc(func(params spoe.GetSpoeMessageParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetSpoeMessage has not yet been implemented") + }), + SpoeGetSpoeScopeHandler: spoe.GetSpoeScopeHandlerFunc(func(params spoe.GetSpoeScopeParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.GetSpoeScope has not yet been implemented") + }), + SpoeTransactionsGetSpoeTransactionHandler: spoe_transactions.GetSpoeTransactionHandlerFunc(func(params spoe_transactions.GetSpoeTransactionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe_transactions.GetSpoeTransaction has not yet been implemented") + }), + StatsGetStatsHandler: stats.GetStatsHandlerFunc(func(params stats.GetStatsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stats.GetStats has not yet been implemented") + }), + DiscoveryGetStatsEndpointsHandler: discovery.GetStatsEndpointsHandlerFunc(func(params discovery.GetStatsEndpointsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation discovery.GetStatsEndpoints has not yet been implemented") + }), + StickRuleGetStickRuleHandler: stick_rule.GetStickRuleHandlerFunc(func(params stick_rule.GetStickRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_rule.GetStickRule has not yet been implemented") + }), + StickRuleGetStickRulesHandler: stick_rule.GetStickRulesHandlerFunc(func(params stick_rule.GetStickRulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_rule.GetStickRules has not yet been implemented") + }), + StickTableGetStickTableHandler: stick_table.GetStickTableHandlerFunc(func(params stick_table.GetStickTableParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_table.GetStickTable has not yet been implemented") + }), + StickTableGetStickTableEntriesHandler: stick_table.GetStickTableEntriesHandlerFunc(func(params stick_table.GetStickTableEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_table.GetStickTableEntries has not yet been implemented") + }), + StickTableGetStickTablesHandler: stick_table.GetStickTablesHandlerFunc(func(params stick_table.GetStickTablesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_table.GetStickTables has not yet been implemented") + }), + DiscoveryGetStorageEndpointsHandler: discovery.GetStorageEndpointsHandlerFunc(func(params discovery.GetStorageEndpointsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation discovery.GetStorageEndpoints has not yet been implemented") + }), + TCPCheckGetTCPCheckBackendHandler: tcp_check.GetTCPCheckBackendHandlerFunc(func(params tcp_check.GetTCPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.GetTCPCheckBackend has not yet been implemented") + }), + TCPCheckGetTCPCheckDefaultsHandler: tcp_check.GetTCPCheckDefaultsHandlerFunc(func(params tcp_check.GetTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.GetTCPCheckDefaults has not yet been implemented") + }), + TCPRequestRuleGetTCPRequestRuleBackendHandler: tcp_request_rule.GetTCPRequestRuleBackendHandlerFunc(func(params tcp_request_rule.GetTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.GetTCPRequestRuleBackend has not yet been implemented") + }), + TCPRequestRuleGetTCPRequestRuleDefaultsHandler: tcp_request_rule.GetTCPRequestRuleDefaultsHandlerFunc(func(params tcp_request_rule.GetTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.GetTCPRequestRuleDefaults has not yet been implemented") + }), + TCPRequestRuleGetTCPRequestRuleFrontendHandler: tcp_request_rule.GetTCPRequestRuleFrontendHandlerFunc(func(params tcp_request_rule.GetTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.GetTCPRequestRuleFrontend has not yet been implemented") + }), + TCPResponseRuleGetTCPResponseRuleBackendHandler: tcp_response_rule.GetTCPResponseRuleBackendHandlerFunc(func(params tcp_response_rule.GetTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.GetTCPResponseRuleBackend has not yet been implemented") + }), + TCPResponseRuleGetTCPResponseRuleDefaultsHandler: tcp_response_rule.GetTCPResponseRuleDefaultsHandlerFunc(func(params tcp_response_rule.GetTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.GetTCPResponseRuleDefaults has not yet been implemented") + }), + TableGetTableHandler: table.GetTableHandlerFunc(func(params table.GetTableParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation table.GetTable has not yet been implemented") + }), + TableGetTablesHandler: table.GetTablesHandlerFunc(func(params table.GetTablesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation table.GetTables has not yet been implemented") + }), + TracesGetTracesHandler: traces.GetTracesHandlerFunc(func(params traces.GetTracesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation traces.GetTraces has not yet been implemented") + }), + TransactionsGetTransactionHandler: transactions.GetTransactionHandlerFunc(func(params transactions.GetTransactionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation transactions.GetTransaction has not yet been implemented") + }), + TransactionsGetTransactionsHandler: transactions.GetTransactionsHandlerFunc(func(params transactions.GetTransactionsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation transactions.GetTransactions has not yet been implemented") + }), + UserGetUserHandler: user.GetUserHandlerFunc(func(params user.GetUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.GetUser has not yet been implemented") + }), + UserlistGetUserlistHandler: userlist.GetUserlistHandlerFunc(func(params userlist.GetUserlistParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation userlist.GetUserlist has not yet been implemented") + }), + UserlistGetUserlistsHandler: userlist.GetUserlistsHandlerFunc(func(params userlist.GetUserlistsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation userlist.GetUserlists has not yet been implemented") + }), + UserGetUsersHandler: user.GetUsersHandlerFunc(func(params user.GetUsersParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.GetUsers has not yet been implemented") + }), + ClusterInitiateCertificateRefreshHandler: cluster.InitiateCertificateRefreshHandlerFunc(func(params cluster.InitiateCertificateRefreshParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cluster.InitiateCertificateRefresh has not yet been implemented") + }), + ClusterPostClusterHandler: cluster.PostClusterHandlerFunc(func(params cluster.PostClusterParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cluster.PostCluster has not yet been implemented") + }), + ConfigurationPostHAProxyConfigurationHandler: configuration.PostHAProxyConfigurationHandlerFunc(func(params configuration.PostHAProxyConfigurationParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation configuration.PostHAProxyConfiguration has not yet been implemented") + }), + AcmeRuntimeRenewAcmeCertificateHandler: acme_runtime.RenewAcmeCertificateHandlerFunc(func(params acme_runtime.RenewAcmeCertificateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acme_runtime.RenewAcmeCertificate has not yet been implemented") + }), + ServiceDiscoveryReplaceAWSRegionHandler: service_discovery.ReplaceAWSRegionHandlerFunc(func(params service_discovery.ReplaceAWSRegionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.ReplaceAWSRegion has not yet been implemented") + }), + ACLReplaceACLBackendHandler: acl.ReplaceACLBackendHandlerFunc(func(params acl.ReplaceACLBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceACLBackend has not yet been implemented") + }), + ACLReplaceACLDefaultsHandler: acl.ReplaceACLDefaultsHandlerFunc(func(params acl.ReplaceACLDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceACLDefaults has not yet been implemented") + }), + ACLReplaceACLFCGIAppHandler: acl.ReplaceACLFCGIAppHandlerFunc(func(params acl.ReplaceACLFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceACLFCGIApp has not yet been implemented") + }), + ACLReplaceACLFrontendHandler: acl.ReplaceACLFrontendHandlerFunc(func(params acl.ReplaceACLFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceACLFrontend has not yet been implemented") + }), + ACLReplaceAllACLBackendHandler: acl.ReplaceAllACLBackendHandlerFunc(func(params acl.ReplaceAllACLBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceAllACLBackend has not yet been implemented") + }), + ACLReplaceAllACLDefaultsHandler: acl.ReplaceAllACLDefaultsHandlerFunc(func(params acl.ReplaceAllACLDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceAllACLDefaults has not yet been implemented") + }), + ACLReplaceAllACLFCGIAppHandler: acl.ReplaceAllACLFCGIAppHandlerFunc(func(params acl.ReplaceAllACLFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceAllACLFCGIApp has not yet been implemented") + }), + ACLReplaceAllACLFrontendHandler: acl.ReplaceAllACLFrontendHandlerFunc(func(params acl.ReplaceAllACLFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation acl.ReplaceAllACLFrontend has not yet been implemented") + }), + FilterReplaceAllFilterBackendHandler: filter.ReplaceAllFilterBackendHandlerFunc(func(params filter.ReplaceAllFilterBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.ReplaceAllFilterBackend has not yet been implemented") + }), + FilterReplaceAllFilterFrontendHandler: filter.ReplaceAllFilterFrontendHandlerFunc(func(params filter.ReplaceAllFilterFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.ReplaceAllFilterFrontend has not yet been implemented") + }), + HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleBackendHandler: http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendHandlerFunc(func(params http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackend has not yet been implemented") + }), + HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleDefaultsHandler: http_after_response_rule.ReplaceAllHTTPAfterResponseRuleDefaultsHandlerFunc(func(params http_after_response_rule.ReplaceAllHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.ReplaceAllHTTPAfterResponseRuleDefaults has not yet been implemented") + }), + HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleFrontendHandler: http_after_response_rule.ReplaceAllHTTPAfterResponseRuleFrontendHandlerFunc(func(params http_after_response_rule.ReplaceAllHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.ReplaceAllHTTPAfterResponseRuleFrontend has not yet been implemented") + }), + HTTPCheckReplaceAllHTTPCheckBackendHandler: http_check.ReplaceAllHTTPCheckBackendHandlerFunc(func(params http_check.ReplaceAllHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.ReplaceAllHTTPCheckBackend has not yet been implemented") + }), + HTTPCheckReplaceAllHTTPCheckDefaultsHandler: http_check.ReplaceAllHTTPCheckDefaultsHandlerFunc(func(params http_check.ReplaceAllHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.ReplaceAllHTTPCheckDefaults has not yet been implemented") + }), + HTTPErrorRuleReplaceAllHTTPErrorRuleBackendHandler: http_error_rule.ReplaceAllHTTPErrorRuleBackendHandlerFunc(func(params http_error_rule.ReplaceAllHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.ReplaceAllHTTPErrorRuleBackend has not yet been implemented") + }), + HTTPErrorRuleReplaceAllHTTPErrorRuleDefaultsHandler: http_error_rule.ReplaceAllHTTPErrorRuleDefaultsHandlerFunc(func(params http_error_rule.ReplaceAllHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.ReplaceAllHTTPErrorRuleDefaults has not yet been implemented") + }), + HTTPErrorRuleReplaceAllHTTPErrorRuleFrontendHandler: http_error_rule.ReplaceAllHTTPErrorRuleFrontendHandlerFunc(func(params http_error_rule.ReplaceAllHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.ReplaceAllHTTPErrorRuleFrontend has not yet been implemented") + }), + HTTPRequestRuleReplaceAllHTTPRequestRuleBackendHandler: http_request_rule.ReplaceAllHTTPRequestRuleBackendHandlerFunc(func(params http_request_rule.ReplaceAllHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.ReplaceAllHTTPRequestRuleBackend has not yet been implemented") + }), + HTTPRequestRuleReplaceAllHTTPRequestRuleDefaultsHandler: http_request_rule.ReplaceAllHTTPRequestRuleDefaultsHandlerFunc(func(params http_request_rule.ReplaceAllHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.ReplaceAllHTTPRequestRuleDefaults has not yet been implemented") + }), + HTTPRequestRuleReplaceAllHTTPRequestRuleFrontendHandler: http_request_rule.ReplaceAllHTTPRequestRuleFrontendHandlerFunc(func(params http_request_rule.ReplaceAllHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.ReplaceAllHTTPRequestRuleFrontend has not yet been implemented") + }), + HTTPResponseRuleReplaceAllHTTPResponseRuleBackendHandler: http_response_rule.ReplaceAllHTTPResponseRuleBackendHandlerFunc(func(params http_response_rule.ReplaceAllHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.ReplaceAllHTTPResponseRuleBackend has not yet been implemented") + }), + HTTPResponseRuleReplaceAllHTTPResponseRuleDefaultsHandler: http_response_rule.ReplaceAllHTTPResponseRuleDefaultsHandlerFunc(func(params http_response_rule.ReplaceAllHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.ReplaceAllHTTPResponseRuleDefaults has not yet been implemented") + }), + HTTPResponseRuleReplaceAllHTTPResponseRuleFrontendHandler: http_response_rule.ReplaceAllHTTPResponseRuleFrontendHandlerFunc(func(params http_response_rule.ReplaceAllHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.ReplaceAllHTTPResponseRuleFrontend has not yet been implemented") + }), + LogTargetReplaceAllLogTargetBackendHandler: log_target.ReplaceAllLogTargetBackendHandlerFunc(func(params log_target.ReplaceAllLogTargetBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceAllLogTargetBackend has not yet been implemented") + }), + LogTargetReplaceAllLogTargetDefaultsHandler: log_target.ReplaceAllLogTargetDefaultsHandlerFunc(func(params log_target.ReplaceAllLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceAllLogTargetDefaults has not yet been implemented") + }), + LogTargetReplaceAllLogTargetFrontendHandler: log_target.ReplaceAllLogTargetFrontendHandlerFunc(func(params log_target.ReplaceAllLogTargetFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceAllLogTargetFrontend has not yet been implemented") + }), + LogTargetReplaceAllLogTargetGlobalHandler: log_target.ReplaceAllLogTargetGlobalHandlerFunc(func(params log_target.ReplaceAllLogTargetGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceAllLogTargetGlobal has not yet been implemented") + }), + LogTargetReplaceAllLogTargetLogForwardHandler: log_target.ReplaceAllLogTargetLogForwardHandlerFunc(func(params log_target.ReplaceAllLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceAllLogTargetLogForward has not yet been implemented") + }), + LogTargetReplaceAllLogTargetPeerHandler: log_target.ReplaceAllLogTargetPeerHandlerFunc(func(params log_target.ReplaceAllLogTargetPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceAllLogTargetPeer has not yet been implemented") + }), + QUICInitialRuleReplaceAllQUICInitialRuleDefaultsHandler: quic_initial_rule.ReplaceAllQUICInitialRuleDefaultsHandlerFunc(func(params quic_initial_rule.ReplaceAllQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.ReplaceAllQUICInitialRuleDefaults has not yet been implemented") + }), + QUICInitialRuleReplaceAllQUICInitialRuleFrontendHandler: quic_initial_rule.ReplaceAllQUICInitialRuleFrontendHandlerFunc(func(params quic_initial_rule.ReplaceAllQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.ReplaceAllQUICInitialRuleFrontend has not yet been implemented") + }), + TCPCheckReplaceAllTCPCheckBackendHandler: tcp_check.ReplaceAllTCPCheckBackendHandlerFunc(func(params tcp_check.ReplaceAllTCPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.ReplaceAllTCPCheckBackend has not yet been implemented") + }), + TCPCheckReplaceAllTCPCheckDefaultsHandler: tcp_check.ReplaceAllTCPCheckDefaultsHandlerFunc(func(params tcp_check.ReplaceAllTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.ReplaceAllTCPCheckDefaults has not yet been implemented") + }), + TCPRequestRuleReplaceAllTCPRequestRuleBackendHandler: tcp_request_rule.ReplaceAllTCPRequestRuleBackendHandlerFunc(func(params tcp_request_rule.ReplaceAllTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.ReplaceAllTCPRequestRuleBackend has not yet been implemented") + }), + TCPRequestRuleReplaceAllTCPRequestRuleDefaultsHandler: tcp_request_rule.ReplaceAllTCPRequestRuleDefaultsHandlerFunc(func(params tcp_request_rule.ReplaceAllTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.ReplaceAllTCPRequestRuleDefaults has not yet been implemented") + }), + TCPRequestRuleReplaceAllTCPRequestRuleFrontendHandler: tcp_request_rule.ReplaceAllTCPRequestRuleFrontendHandlerFunc(func(params tcp_request_rule.ReplaceAllTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.ReplaceAllTCPRequestRuleFrontend has not yet been implemented") + }), + TCPResponseRuleReplaceAllTCPResponseRuleBackendHandler: tcp_response_rule.ReplaceAllTCPResponseRuleBackendHandlerFunc(func(params tcp_response_rule.ReplaceAllTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.ReplaceAllTCPResponseRuleBackend has not yet been implemented") + }), + TCPResponseRuleReplaceAllTCPResponseRuleDefaultsHandler: tcp_response_rule.ReplaceAllTCPResponseRuleDefaultsHandlerFunc(func(params tcp_response_rule.ReplaceAllTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.ReplaceAllTCPResponseRuleDefaults has not yet been implemented") + }), + BackendReplaceBackendHandler: backend.ReplaceBackendHandlerFunc(func(params backend.ReplaceBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation backend.ReplaceBackend has not yet been implemented") + }), + BackendSwitchingRuleReplaceBackendSwitchingRuleHandler: backend_switching_rule.ReplaceBackendSwitchingRuleHandlerFunc(func(params backend_switching_rule.ReplaceBackendSwitchingRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation backend_switching_rule.ReplaceBackendSwitchingRule has not yet been implemented") + }), + BackendSwitchingRuleReplaceBackendSwitchingRulesHandler: backend_switching_rule.ReplaceBackendSwitchingRulesHandlerFunc(func(params backend_switching_rule.ReplaceBackendSwitchingRulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation backend_switching_rule.ReplaceBackendSwitchingRules has not yet been implemented") + }), + BindReplaceBindFrontendHandler: bind.ReplaceBindFrontendHandlerFunc(func(params bind.ReplaceBindFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.ReplaceBindFrontend has not yet been implemented") + }), + BindReplaceBindLogForwardHandler: bind.ReplaceBindLogForwardHandlerFunc(func(params bind.ReplaceBindLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.ReplaceBindLogForward has not yet been implemented") + }), + BindReplaceBindPeerHandler: bind.ReplaceBindPeerHandlerFunc(func(params bind.ReplaceBindPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation bind.ReplaceBindPeer has not yet been implemented") + }), + CacheReplaceCacheHandler: cache.ReplaceCacheHandlerFunc(func(params cache.ReplaceCacheParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation cache.ReplaceCache has not yet been implemented") + }), + SslRuntimeReplaceCertHandler: s_s_l_runtime.ReplaceCertHandlerFunc(func(params s_s_l_runtime.ReplaceCertParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.ReplaceCert has not yet been implemented") + }), + ServiceDiscoveryReplaceConsulHandler: service_discovery.ReplaceConsulHandlerFunc(func(params service_discovery.ReplaceConsulParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation service_discovery.ReplaceConsul has not yet been implemented") + }), + SslRuntimeReplaceCrlHandler: s_s_l_runtime.ReplaceCrlHandlerFunc(func(params s_s_l_runtime.ReplaceCrlParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.ReplaceCrl has not yet been implemented") + }), + CrtLoadReplaceCrtLoadHandler: crt_load.ReplaceCrtLoadHandlerFunc(func(params crt_load.ReplaceCrtLoadParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation crt_load.ReplaceCrtLoad has not yet been implemented") + }), + DeclareCaptureReplaceDeclareCaptureHandler: declare_capture.ReplaceDeclareCaptureHandlerFunc(func(params declare_capture.ReplaceDeclareCaptureParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation declare_capture.ReplaceDeclareCapture has not yet been implemented") + }), + DeclareCaptureReplaceDeclareCapturesHandler: declare_capture.ReplaceDeclareCapturesHandlerFunc(func(params declare_capture.ReplaceDeclareCapturesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation declare_capture.ReplaceDeclareCaptures has not yet been implemented") + }), + DefaultsReplaceDefaultsSectionHandler: defaults.ReplaceDefaultsSectionHandlerFunc(func(params defaults.ReplaceDefaultsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation defaults.ReplaceDefaultsSection has not yet been implemented") + }), + DgramBindReplaceDgramBindHandler: dgram_bind.ReplaceDgramBindHandlerFunc(func(params dgram_bind.ReplaceDgramBindParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation dgram_bind.ReplaceDgramBind has not yet been implemented") + }), + FCGIAppReplaceFCGIAppHandler: fcgi_app.ReplaceFCGIAppHandlerFunc(func(params fcgi_app.ReplaceFCGIAppParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation fcgi_app.ReplaceFCGIApp has not yet been implemented") + }), + FilterReplaceFilterBackendHandler: filter.ReplaceFilterBackendHandlerFunc(func(params filter.ReplaceFilterBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.ReplaceFilterBackend has not yet been implemented") + }), + FilterReplaceFilterFrontendHandler: filter.ReplaceFilterFrontendHandlerFunc(func(params filter.ReplaceFilterFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation filter.ReplaceFilterFrontend has not yet been implemented") + }), + FrontendReplaceFrontendHandler: frontend.ReplaceFrontendHandlerFunc(func(params frontend.ReplaceFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation frontend.ReplaceFrontend has not yet been implemented") + }), + GlobalReplaceGlobalHandler: global.ReplaceGlobalHandlerFunc(func(params global.ReplaceGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation global.ReplaceGlobal has not yet been implemented") + }), + GroupReplaceGroupHandler: group.ReplaceGroupHandlerFunc(func(params group.ReplaceGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation group.ReplaceGroup has not yet been implemented") + }), + HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleBackendHandler: http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendHandlerFunc(func(params http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.ReplaceHTTPAfterResponseRuleBackend has not yet been implemented") + }), + HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleDefaultsHandler: http_after_response_rule.ReplaceHTTPAfterResponseRuleDefaultsHandlerFunc(func(params http_after_response_rule.ReplaceHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.ReplaceHTTPAfterResponseRuleDefaults has not yet been implemented") + }), + HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleFrontendHandler: http_after_response_rule.ReplaceHTTPAfterResponseRuleFrontendHandlerFunc(func(params http_after_response_rule.ReplaceHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_after_response_rule.ReplaceHTTPAfterResponseRuleFrontend has not yet been implemented") + }), + HTTPCheckReplaceHTTPCheckBackendHandler: http_check.ReplaceHTTPCheckBackendHandlerFunc(func(params http_check.ReplaceHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.ReplaceHTTPCheckBackend has not yet been implemented") + }), + HTTPCheckReplaceHTTPCheckDefaultsHandler: http_check.ReplaceHTTPCheckDefaultsHandlerFunc(func(params http_check.ReplaceHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_check.ReplaceHTTPCheckDefaults has not yet been implemented") + }), + HTTPErrorRuleReplaceHTTPErrorRuleBackendHandler: http_error_rule.ReplaceHTTPErrorRuleBackendHandlerFunc(func(params http_error_rule.ReplaceHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.ReplaceHTTPErrorRuleBackend has not yet been implemented") + }), + HTTPErrorRuleReplaceHTTPErrorRuleDefaultsHandler: http_error_rule.ReplaceHTTPErrorRuleDefaultsHandlerFunc(func(params http_error_rule.ReplaceHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.ReplaceHTTPErrorRuleDefaults has not yet been implemented") + }), + HTTPErrorRuleReplaceHTTPErrorRuleFrontendHandler: http_error_rule.ReplaceHTTPErrorRuleFrontendHandlerFunc(func(params http_error_rule.ReplaceHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_error_rule.ReplaceHTTPErrorRuleFrontend has not yet been implemented") + }), + HTTPErrorsReplaceHTTPErrorsSectionHandler: http_errors.ReplaceHTTPErrorsSectionHandlerFunc(func(params http_errors.ReplaceHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_errors.ReplaceHTTPErrorsSection has not yet been implemented") + }), + HTTPRequestRuleReplaceHTTPRequestRuleBackendHandler: http_request_rule.ReplaceHTTPRequestRuleBackendHandlerFunc(func(params http_request_rule.ReplaceHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.ReplaceHTTPRequestRuleBackend has not yet been implemented") + }), + HTTPRequestRuleReplaceHTTPRequestRuleDefaultsHandler: http_request_rule.ReplaceHTTPRequestRuleDefaultsHandlerFunc(func(params http_request_rule.ReplaceHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.ReplaceHTTPRequestRuleDefaults has not yet been implemented") + }), + HTTPRequestRuleReplaceHTTPRequestRuleFrontendHandler: http_request_rule.ReplaceHTTPRequestRuleFrontendHandlerFunc(func(params http_request_rule.ReplaceHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_request_rule.ReplaceHTTPRequestRuleFrontend has not yet been implemented") + }), + HTTPResponseRuleReplaceHTTPResponseRuleBackendHandler: http_response_rule.ReplaceHTTPResponseRuleBackendHandlerFunc(func(params http_response_rule.ReplaceHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.ReplaceHTTPResponseRuleBackend has not yet been implemented") + }), + HTTPResponseRuleReplaceHTTPResponseRuleDefaultsHandler: http_response_rule.ReplaceHTTPResponseRuleDefaultsHandlerFunc(func(params http_response_rule.ReplaceHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.ReplaceHTTPResponseRuleDefaults has not yet been implemented") + }), + HTTPResponseRuleReplaceHTTPResponseRuleFrontendHandler: http_response_rule.ReplaceHTTPResponseRuleFrontendHandlerFunc(func(params http_response_rule.ReplaceHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation http_response_rule.ReplaceHTTPResponseRuleFrontend has not yet been implemented") + }), + LogForwardReplaceLogForwardHandler: log_forward.ReplaceLogForwardHandlerFunc(func(params log_forward.ReplaceLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_forward.ReplaceLogForward has not yet been implemented") + }), + LogTargetReplaceLogTargetBackendHandler: log_target.ReplaceLogTargetBackendHandlerFunc(func(params log_target.ReplaceLogTargetBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceLogTargetBackend has not yet been implemented") + }), + LogTargetReplaceLogTargetDefaultsHandler: log_target.ReplaceLogTargetDefaultsHandlerFunc(func(params log_target.ReplaceLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceLogTargetDefaults has not yet been implemented") + }), + LogTargetReplaceLogTargetFrontendHandler: log_target.ReplaceLogTargetFrontendHandlerFunc(func(params log_target.ReplaceLogTargetFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceLogTargetFrontend has not yet been implemented") + }), + LogTargetReplaceLogTargetGlobalHandler: log_target.ReplaceLogTargetGlobalHandlerFunc(func(params log_target.ReplaceLogTargetGlobalParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceLogTargetGlobal has not yet been implemented") + }), + LogTargetReplaceLogTargetLogForwardHandler: log_target.ReplaceLogTargetLogForwardHandlerFunc(func(params log_target.ReplaceLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceLogTargetLogForward has not yet been implemented") + }), + LogTargetReplaceLogTargetPeerHandler: log_target.ReplaceLogTargetPeerHandlerFunc(func(params log_target.ReplaceLogTargetPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation log_target.ReplaceLogTargetPeer has not yet been implemented") + }), + MailerEntryReplaceMailerEntryHandler: mailer_entry.ReplaceMailerEntryHandlerFunc(func(params mailer_entry.ReplaceMailerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation mailer_entry.ReplaceMailerEntry has not yet been implemented") + }), + NameserverReplaceNameserverHandler: nameserver.ReplaceNameserverHandlerFunc(func(params nameserver.ReplaceNameserverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation nameserver.ReplaceNameserver has not yet been implemented") + }), + PeerEntryReplacePeerEntryHandler: peer_entry.ReplacePeerEntryHandlerFunc(func(params peer_entry.ReplacePeerEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation peer_entry.ReplacePeerEntry has not yet been implemented") + }), + ProcessManagerReplaceProgramHandler: process_manager.ReplaceProgramHandlerFunc(func(params process_manager.ReplaceProgramParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation process_manager.ReplaceProgram has not yet been implemented") + }), + QUICInitialRuleReplaceQUICInitialRuleDefaultsHandler: quic_initial_rule.ReplaceQUICInitialRuleDefaultsHandlerFunc(func(params quic_initial_rule.ReplaceQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.ReplaceQUICInitialRuleDefaults has not yet been implemented") + }), + QUICInitialRuleReplaceQUICInitialRuleFrontendHandler: quic_initial_rule.ReplaceQUICInitialRuleFrontendHandlerFunc(func(params quic_initial_rule.ReplaceQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation quic_initial_rule.ReplaceQUICInitialRuleFrontend has not yet been implemented") + }), + ResolverReplaceResolverHandler: resolver.ReplaceResolverHandlerFunc(func(params resolver.ReplaceResolverParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation resolver.ReplaceResolver has not yet been implemented") + }), + RingReplaceRingHandler: ring.ReplaceRingHandlerFunc(func(params ring.ReplaceRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation ring.ReplaceRing has not yet been implemented") + }), + MapsReplaceRuntimeMapEntryHandler: maps.ReplaceRuntimeMapEntryHandlerFunc(func(params maps.ReplaceRuntimeMapEntryParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.ReplaceRuntimeMapEntry has not yet been implemented") + }), + ServerReplaceRuntimeServerHandler: serverops.ReplaceRuntimeServerHandlerFunc(func(params serverops.ReplaceRuntimeServerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.ReplaceRuntimeServer has not yet been implemented") + }), + SslFrontUseReplaceSSLFrontUseHandler: s_s_l_front_use.ReplaceSSLFrontUseHandlerFunc(func(params s_s_l_front_use.ReplaceSSLFrontUseParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_front_use.ReplaceSSLFrontUse has not yet been implemented") + }), + ServerReplaceServerBackendHandler: serverops.ReplaceServerBackendHandlerFunc(func(params serverops.ReplaceServerBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.ReplaceServerBackend has not yet been implemented") + }), + ServerReplaceServerPeerHandler: serverops.ReplaceServerPeerHandlerFunc(func(params serverops.ReplaceServerPeerParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.ReplaceServerPeer has not yet been implemented") + }), + ServerReplaceServerRingHandler: serverops.ReplaceServerRingHandlerFunc(func(params serverops.ReplaceServerRingParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server.ReplaceServerRing has not yet been implemented") + }), + ServerSwitchingRuleReplaceServerSwitchingRuleHandler: server_switching_rule.ReplaceServerSwitchingRuleHandlerFunc(func(params server_switching_rule.ReplaceServerSwitchingRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_switching_rule.ReplaceServerSwitchingRule has not yet been implemented") + }), + ServerSwitchingRuleReplaceServerSwitchingRulesHandler: server_switching_rule.ReplaceServerSwitchingRulesHandlerFunc(func(params server_switching_rule.ReplaceServerSwitchingRulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_switching_rule.ReplaceServerSwitchingRules has not yet been implemented") + }), + ServerTemplateReplaceServerTemplateHandler: server_template.ReplaceServerTemplateHandlerFunc(func(params server_template.ReplaceServerTemplateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation server_template.ReplaceServerTemplate has not yet been implemented") + }), + SitesReplaceSiteHandler: sites.ReplaceSiteHandlerFunc(func(params sites.ReplaceSiteParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation sites.ReplaceSite has not yet been implemented") + }), + SpoeReplaceSpoeAgentHandler: spoe.ReplaceSpoeAgentHandlerFunc(func(params spoe.ReplaceSpoeAgentParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.ReplaceSpoeAgent has not yet been implemented") + }), + SpoeReplaceSpoeGroupHandler: spoe.ReplaceSpoeGroupHandlerFunc(func(params spoe.ReplaceSpoeGroupParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.ReplaceSpoeGroup has not yet been implemented") + }), + SpoeReplaceSpoeMessageHandler: spoe.ReplaceSpoeMessageHandlerFunc(func(params spoe.ReplaceSpoeMessageParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe.ReplaceSpoeMessage has not yet been implemented") + }), + StickRuleReplaceStickRuleHandler: stick_rule.ReplaceStickRuleHandlerFunc(func(params stick_rule.ReplaceStickRuleParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_rule.ReplaceStickRule has not yet been implemented") + }), + StickRuleReplaceStickRulesHandler: stick_rule.ReplaceStickRulesHandlerFunc(func(params stick_rule.ReplaceStickRulesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_rule.ReplaceStickRules has not yet been implemented") + }), + StorageReplaceStorageGeneralFileHandler: storage.ReplaceStorageGeneralFileHandlerFunc(func(params storage.ReplaceStorageGeneralFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.ReplaceStorageGeneralFile has not yet been implemented") + }), + StorageReplaceStorageMapFileHandler: storage.ReplaceStorageMapFileHandlerFunc(func(params storage.ReplaceStorageMapFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.ReplaceStorageMapFile has not yet been implemented") + }), + StorageReplaceStorageSSLCertificateHandler: storage.ReplaceStorageSSLCertificateHandlerFunc(func(params storage.ReplaceStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.ReplaceStorageSSLCertificate has not yet been implemented") + }), + StorageReplaceStorageSSLCrtListFileHandler: storage.ReplaceStorageSSLCrtListFileHandlerFunc(func(params storage.ReplaceStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation storage.ReplaceStorageSSLCrtListFile has not yet been implemented") + }), + TCPCheckReplaceTCPCheckBackendHandler: tcp_check.ReplaceTCPCheckBackendHandlerFunc(func(params tcp_check.ReplaceTCPCheckBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.ReplaceTCPCheckBackend has not yet been implemented") + }), + TCPCheckReplaceTCPCheckDefaultsHandler: tcp_check.ReplaceTCPCheckDefaultsHandlerFunc(func(params tcp_check.ReplaceTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_check.ReplaceTCPCheckDefaults has not yet been implemented") + }), + TCPRequestRuleReplaceTCPRequestRuleBackendHandler: tcp_request_rule.ReplaceTCPRequestRuleBackendHandlerFunc(func(params tcp_request_rule.ReplaceTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.ReplaceTCPRequestRuleBackend has not yet been implemented") + }), + TCPRequestRuleReplaceTCPRequestRuleDefaultsHandler: tcp_request_rule.ReplaceTCPRequestRuleDefaultsHandlerFunc(func(params tcp_request_rule.ReplaceTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.ReplaceTCPRequestRuleDefaults has not yet been implemented") + }), + TCPRequestRuleReplaceTCPRequestRuleFrontendHandler: tcp_request_rule.ReplaceTCPRequestRuleFrontendHandlerFunc(func(params tcp_request_rule.ReplaceTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_request_rule.ReplaceTCPRequestRuleFrontend has not yet been implemented") + }), + TCPResponseRuleReplaceTCPResponseRuleBackendHandler: tcp_response_rule.ReplaceTCPResponseRuleBackendHandlerFunc(func(params tcp_response_rule.ReplaceTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.ReplaceTCPResponseRuleBackend has not yet been implemented") + }), + TCPResponseRuleReplaceTCPResponseRuleDefaultsHandler: tcp_response_rule.ReplaceTCPResponseRuleDefaultsHandlerFunc(func(params tcp_response_rule.ReplaceTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation tcp_response_rule.ReplaceTCPResponseRuleDefaults has not yet been implemented") + }), + TableReplaceTableHandler: table.ReplaceTableHandlerFunc(func(params table.ReplaceTableParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation table.ReplaceTable has not yet been implemented") + }), + TracesReplaceTracesHandler: traces.ReplaceTracesHandlerFunc(func(params traces.ReplaceTracesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation traces.ReplaceTraces has not yet been implemented") + }), + UserReplaceUserHandler: user.ReplaceUserHandlerFunc(func(params user.ReplaceUserParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation user.ReplaceUser has not yet been implemented") + }), + SslRuntimeSetCaFileHandler: s_s_l_runtime.SetCaFileHandlerFunc(func(params s_s_l_runtime.SetCaFileParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation s_s_l_runtime.SetCaFile has not yet been implemented") + }), + StickTableSetStickTableEntriesHandler: stick_table.SetStickTableEntriesHandlerFunc(func(params stick_table.SetStickTableEntriesParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation stick_table.SetStickTableEntries has not yet been implemented") + }), + MapsShowRuntimeMapHandler: maps.ShowRuntimeMapHandlerFunc(func(params maps.ShowRuntimeMapParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation maps.ShowRuntimeMap has not yet been implemented") + }), + SpoeTransactionsStartSpoeTransactionHandler: spoe_transactions.StartSpoeTransactionHandlerFunc(func(params spoe_transactions.StartSpoeTransactionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation spoe_transactions.StartSpoeTransaction has not yet been implemented") + }), + TransactionsStartTransactionHandler: transactions.StartTransactionHandlerFunc(func(params transactions.StartTransactionParams, principal interface{}) middleware.Responder { + return middleware.NotImplemented("operation transactions.StartTransaction has not yet been implemented") + }), + + // Applies when the Authorization header is set with the Basic scheme + BasicAuthAuth: func(user string, pass string) (interface{}, error) { + return nil, errors.NotImplemented("basic auth (basic_auth) has not yet been implemented") + }, + // default authorizer is authorized meaning no requests are blocked + APIAuthorizer: security.Authorized(), + } +} + +/* +DataPlaneAPI API for editing and managing haproxy instances. Provides process information, configuration management, +haproxy stats and logs. +*/ +type DataPlaneAPI struct { + spec *loads.Document + context *middleware.Context + handlers map[string]map[string]http.Handler + formats strfmt.Registry + customConsumers map[string]runtime.Consumer + customProducers map[string]runtime.Producer + defaultConsumes string + defaultProduces string + Middleware func(middleware.Builder) http.Handler + useSwaggerUI bool + + // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator + + // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator + + // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator + + // JSONConsumer registers a consumer for the following mime types: + // - application/json + JSONConsumer runtime.Consumer + // MultipartformConsumer registers a consumer for the following mime types: + // - multipart/form-data + MultipartformConsumer runtime.Consumer + // TxtConsumer registers a consumer for the following mime types: + // - text/plain + TxtConsumer runtime.Consumer + + // BinProducer registers a producer for the following mime types: + // - application/octet-stream + BinProducer runtime.Producer + // JSONProducer registers a producer for the following mime types: + // - application/json + JSONProducer runtime.Producer + // TxtProducer registers a producer for the following mime types: + // - text/plain + TxtProducer runtime.Producer + + // BasicAuthAuth registers a function that takes username and password and returns a principal + // it performs authentication with basic auth + BasicAuthAuth func(string, string) (interface{}, error) + // APIAuthorizer provides access control (ACL/RBAC/ABAC) by providing access to the request and authenticated principal APIAuthorizer runtime.Authorizer - // TransactionsCommitTransactionHandler sets the operation handler for the commit transaction operation - TransactionsCommitTransactionHandler transactions.CommitTransactionHandler - // ACLCreateACLHandler sets the operation handler for the create Acl operation - ACLCreateACLHandler acl.CreateACLHandler - // BackendCreateBackendHandler sets the operation handler for the create backend operation - BackendCreateBackendHandler backend.CreateBackendHandler - // BackendSwitchingRuleCreateBackendSwitchingRuleHandler sets the operation handler for the create backend switching rule operation - BackendSwitchingRuleCreateBackendSwitchingRuleHandler backend_switching_rule.CreateBackendSwitchingRuleHandler - // BindCreateBindHandler sets the operation handler for the create bind operation - BindCreateBindHandler bind.CreateBindHandler - // FilterCreateFilterHandler sets the operation handler for the create filter operation - FilterCreateFilterHandler filter.CreateFilterHandler - // FrontendCreateFrontendHandler sets the operation handler for the create frontend operation - FrontendCreateFrontendHandler frontend.CreateFrontendHandler - // HTTPRequestRuleCreateHTTPRequestRuleHandler sets the operation handler for the create HTTP request rule operation - HTTPRequestRuleCreateHTTPRequestRuleHandler http_request_rule.CreateHTTPRequestRuleHandler - // HTTPResponseRuleCreateHTTPResponseRuleHandler sets the operation handler for the create HTTP response rule operation - HTTPResponseRuleCreateHTTPResponseRuleHandler http_response_rule.CreateHTTPResponseRuleHandler - // LogTargetCreateLogTargetHandler sets the operation handler for the create log target operation - LogTargetCreateLogTargetHandler log_target.CreateLogTargetHandler - // ServerCreateServerHandler sets the operation handler for the create server operation - ServerCreateServerHandler server.CreateServerHandler - // ServerSwitchingRuleCreateServerSwitchingRuleHandler sets the operation handler for the create server switching rule operation - ServerSwitchingRuleCreateServerSwitchingRuleHandler server_switching_rule.CreateServerSwitchingRuleHandler - // SitesCreateSiteHandler sets the operation handler for the create site operation - SitesCreateSiteHandler sites.CreateSiteHandler - // StickRuleCreateStickRuleHandler sets the operation handler for the create stick rule operation - StickRuleCreateStickRuleHandler stick_rule.CreateStickRuleHandler - // TCPRequestRuleCreateTCPRequestRuleHandler sets the operation handler for the create TCP request rule operation - TCPRequestRuleCreateTCPRequestRuleHandler tcp_request_rule.CreateTCPRequestRuleHandler - // TCPResponseRuleCreateTCPResponseRuleHandler sets the operation handler for the create TCP response rule operation - TCPResponseRuleCreateTCPResponseRuleHandler tcp_response_rule.CreateTCPResponseRuleHandler - // ACLDeleteACLHandler sets the operation handler for the delete Acl operation - ACLDeleteACLHandler acl.DeleteACLHandler - // BackendDeleteBackendHandler sets the operation handler for the delete backend operation - BackendDeleteBackendHandler backend.DeleteBackendHandler - // BackendSwitchingRuleDeleteBackendSwitchingRuleHandler sets the operation handler for the delete backend switching rule operation - BackendSwitchingRuleDeleteBackendSwitchingRuleHandler backend_switching_rule.DeleteBackendSwitchingRuleHandler - // BindDeleteBindHandler sets the operation handler for the delete bind operation - BindDeleteBindHandler bind.DeleteBindHandler - // FilterDeleteFilterHandler sets the operation handler for the delete filter operation - FilterDeleteFilterHandler filter.DeleteFilterHandler - // FrontendDeleteFrontendHandler sets the operation handler for the delete frontend operation - FrontendDeleteFrontendHandler frontend.DeleteFrontendHandler - // HTTPRequestRuleDeleteHTTPRequestRuleHandler sets the operation handler for the delete HTTP request rule operation - HTTPRequestRuleDeleteHTTPRequestRuleHandler http_request_rule.DeleteHTTPRequestRuleHandler - // HTTPResponseRuleDeleteHTTPResponseRuleHandler sets the operation handler for the delete HTTP response rule operation - HTTPResponseRuleDeleteHTTPResponseRuleHandler http_response_rule.DeleteHTTPResponseRuleHandler - // LogTargetDeleteLogTargetHandler sets the operation handler for the delete log target operation - LogTargetDeleteLogTargetHandler log_target.DeleteLogTargetHandler - // ServerDeleteServerHandler sets the operation handler for the delete server operation - ServerDeleteServerHandler server.DeleteServerHandler - // ServerSwitchingRuleDeleteServerSwitchingRuleHandler sets the operation handler for the delete server switching rule operation - ServerSwitchingRuleDeleteServerSwitchingRuleHandler server_switching_rule.DeleteServerSwitchingRuleHandler - // SitesDeleteSiteHandler sets the operation handler for the delete site operation - SitesDeleteSiteHandler sites.DeleteSiteHandler - // StickRuleDeleteStickRuleHandler sets the operation handler for the delete stick rule operation - StickRuleDeleteStickRuleHandler stick_rule.DeleteStickRuleHandler - // TCPRequestRuleDeleteTCPRequestRuleHandler sets the operation handler for the delete TCP request rule operation - TCPRequestRuleDeleteTCPRequestRuleHandler tcp_request_rule.DeleteTCPRequestRuleHandler - // TCPResponseRuleDeleteTCPResponseRuleHandler sets the operation handler for the delete TCP response rule operation - TCPResponseRuleDeleteTCPResponseRuleHandler tcp_response_rule.DeleteTCPResponseRuleHandler - // TransactionsDeleteTransactionHandler sets the operation handler for the delete transaction operation - TransactionsDeleteTransactionHandler transactions.DeleteTransactionHandler - // DiscoveryGetAPIEndpointsHandler sets the operation handler for the get API endpoints operation - DiscoveryGetAPIEndpointsHandler discovery.GetAPIEndpointsHandler - // ACLGetACLHandler sets the operation handler for the get Acl operation - ACLGetACLHandler acl.GetACLHandler - // ACLGetAclsHandler sets the operation handler for the get acls operation - ACLGetAclsHandler acl.GetAclsHandler - // BackendGetBackendHandler sets the operation handler for the get backend operation - BackendGetBackendHandler backend.GetBackendHandler - // BackendSwitchingRuleGetBackendSwitchingRuleHandler sets the operation handler for the get backend switching rule operation - BackendSwitchingRuleGetBackendSwitchingRuleHandler backend_switching_rule.GetBackendSwitchingRuleHandler - // BackendSwitchingRuleGetBackendSwitchingRulesHandler sets the operation handler for the get backend switching rules operation - BackendSwitchingRuleGetBackendSwitchingRulesHandler backend_switching_rule.GetBackendSwitchingRulesHandler - // BackendGetBackendsHandler sets the operation handler for the get backends operation - BackendGetBackendsHandler backend.GetBackendsHandler - // BindGetBindHandler sets the operation handler for the get bind operation - BindGetBindHandler bind.GetBindHandler - // BindGetBindsHandler sets the operation handler for the get binds operation - BindGetBindsHandler bind.GetBindsHandler - // DiscoveryGetConfigurationEndpointsHandler sets the operation handler for the get configuration endpoints operation - DiscoveryGetConfigurationEndpointsHandler discovery.GetConfigurationEndpointsHandler - // DefaultsGetDefaultsHandler sets the operation handler for the get defaults operation - DefaultsGetDefaultsHandler defaults.GetDefaultsHandler - // FilterGetFilterHandler sets the operation handler for the get filter operation - FilterGetFilterHandler filter.GetFilterHandler - // FilterGetFiltersHandler sets the operation handler for the get filters operation - FilterGetFiltersHandler filter.GetFiltersHandler - // FrontendGetFrontendHandler sets the operation handler for the get frontend operation - FrontendGetFrontendHandler frontend.GetFrontendHandler - // FrontendGetFrontendsHandler sets the operation handler for the get frontends operation - FrontendGetFrontendsHandler frontend.GetFrontendsHandler - // GlobalGetGlobalHandler sets the operation handler for the get global operation - GlobalGetGlobalHandler global.GetGlobalHandler - // ConfigurationGetHAProxyConfigurationHandler sets the operation handler for the get h a proxy configuration operation - ConfigurationGetHAProxyConfigurationHandler configuration.GetHAProxyConfigurationHandler - // HTTPRequestRuleGetHTTPRequestRuleHandler sets the operation handler for the get HTTP request rule operation - HTTPRequestRuleGetHTTPRequestRuleHandler http_request_rule.GetHTTPRequestRuleHandler - // HTTPRequestRuleGetHTTPRequestRulesHandler sets the operation handler for the get HTTP request rules operation - HTTPRequestRuleGetHTTPRequestRulesHandler http_request_rule.GetHTTPRequestRulesHandler - // HTTPResponseRuleGetHTTPResponseRuleHandler sets the operation handler for the get HTTP response rule operation - HTTPResponseRuleGetHTTPResponseRuleHandler http_response_rule.GetHTTPResponseRuleHandler - // HTTPResponseRuleGetHTTPResponseRulesHandler sets the operation handler for the get HTTP response rules operation - HTTPResponseRuleGetHTTPResponseRulesHandler http_response_rule.GetHTTPResponseRulesHandler - // DiscoveryGetHaproxyEndpointsHandler sets the operation handler for the get haproxy endpoints operation - DiscoveryGetHaproxyEndpointsHandler discovery.GetHaproxyEndpointsHandler - // InformationGetHaproxyProcessInfoHandler sets the operation handler for the get haproxy process info operation - InformationGetHaproxyProcessInfoHandler information.GetHaproxyProcessInfoHandler - // InformationGetInfoHandler sets the operation handler for the get info operation - InformationGetInfoHandler information.GetInfoHandler - // LogTargetGetLogTargetHandler sets the operation handler for the get log target operation - LogTargetGetLogTargetHandler log_target.GetLogTargetHandler - // LogTargetGetLogTargetsHandler sets the operation handler for the get log targets operation - LogTargetGetLogTargetsHandler log_target.GetLogTargetsHandler - // ReloadsGetReloadHandler sets the operation handler for the get reload operation - ReloadsGetReloadHandler reloads.GetReloadHandler - // ReloadsGetReloadsHandler sets the operation handler for the get reloads operation - ReloadsGetReloadsHandler reloads.GetReloadsHandler - // ServerGetServerHandler sets the operation handler for the get server operation - ServerGetServerHandler server.GetServerHandler - // ServerSwitchingRuleGetServerSwitchingRuleHandler sets the operation handler for the get server switching rule operation - ServerSwitchingRuleGetServerSwitchingRuleHandler server_switching_rule.GetServerSwitchingRuleHandler - // ServerSwitchingRuleGetServerSwitchingRulesHandler sets the operation handler for the get server switching rules operation - ServerSwitchingRuleGetServerSwitchingRulesHandler server_switching_rule.GetServerSwitchingRulesHandler - // ServerGetServersHandler sets the operation handler for the get servers operation - ServerGetServersHandler server.GetServersHandler - // DiscoveryGetServicesEndpointsHandler sets the operation handler for the get services endpoints operation - DiscoveryGetServicesEndpointsHandler discovery.GetServicesEndpointsHandler - // SitesGetSiteHandler sets the operation handler for the get site operation - SitesGetSiteHandler sites.GetSiteHandler - // SitesGetSitesHandler sets the operation handler for the get sites operation - SitesGetSitesHandler sites.GetSitesHandler - // SpecificationGetSpecificationHandler sets the operation handler for the get specification operation - SpecificationGetSpecificationHandler specification.GetSpecificationHandler - // StatsGetStatsHandler sets the operation handler for the get stats operation - StatsGetStatsHandler stats.GetStatsHandler - // DiscoveryGetStatsEndpointsHandler sets the operation handler for the get stats endpoints operation - DiscoveryGetStatsEndpointsHandler discovery.GetStatsEndpointsHandler - // StickRuleGetStickRuleHandler sets the operation handler for the get stick rule operation - StickRuleGetStickRuleHandler stick_rule.GetStickRuleHandler - // StickRuleGetStickRulesHandler sets the operation handler for the get stick rules operation - StickRuleGetStickRulesHandler stick_rule.GetStickRulesHandler - // TCPRequestRuleGetTCPRequestRuleHandler sets the operation handler for the get TCP request rule operation - TCPRequestRuleGetTCPRequestRuleHandler tcp_request_rule.GetTCPRequestRuleHandler - // TCPRequestRuleGetTCPRequestRulesHandler sets the operation handler for the get TCP request rules operation - TCPRequestRuleGetTCPRequestRulesHandler tcp_request_rule.GetTCPRequestRulesHandler - // TCPResponseRuleGetTCPResponseRuleHandler sets the operation handler for the get TCP response rule operation - TCPResponseRuleGetTCPResponseRuleHandler tcp_response_rule.GetTCPResponseRuleHandler - // TCPResponseRuleGetTCPResponseRulesHandler sets the operation handler for the get TCP response rules operation - TCPResponseRuleGetTCPResponseRulesHandler tcp_response_rule.GetTCPResponseRulesHandler - // TransactionsGetTransactionHandler sets the operation handler for the get transaction operation - TransactionsGetTransactionHandler transactions.GetTransactionHandler - // TransactionsGetTransactionsHandler sets the operation handler for the get transactions operation - TransactionsGetTransactionsHandler transactions.GetTransactionsHandler - // ConfigurationPostHAProxyConfigurationHandler sets the operation handler for the post h a proxy configuration operation - ConfigurationPostHAProxyConfigurationHandler configuration.PostHAProxyConfigurationHandler - // ACLReplaceACLHandler sets the operation handler for the replace Acl operation - ACLReplaceACLHandler acl.ReplaceACLHandler - // BackendReplaceBackendHandler sets the operation handler for the replace backend operation - BackendReplaceBackendHandler backend.ReplaceBackendHandler - // BackendSwitchingRuleReplaceBackendSwitchingRuleHandler sets the operation handler for the replace backend switching rule operation - BackendSwitchingRuleReplaceBackendSwitchingRuleHandler backend_switching_rule.ReplaceBackendSwitchingRuleHandler - // BindReplaceBindHandler sets the operation handler for the replace bind operation - BindReplaceBindHandler bind.ReplaceBindHandler - // DefaultsReplaceDefaultsHandler sets the operation handler for the replace defaults operation - DefaultsReplaceDefaultsHandler defaults.ReplaceDefaultsHandler - // FilterReplaceFilterHandler sets the operation handler for the replace filter operation - FilterReplaceFilterHandler filter.ReplaceFilterHandler - // FrontendReplaceFrontendHandler sets the operation handler for the replace frontend operation - FrontendReplaceFrontendHandler frontend.ReplaceFrontendHandler - // GlobalReplaceGlobalHandler sets the operation handler for the replace global operation - GlobalReplaceGlobalHandler global.ReplaceGlobalHandler - // HTTPRequestRuleReplaceHTTPRequestRuleHandler sets the operation handler for the replace HTTP request rule operation - HTTPRequestRuleReplaceHTTPRequestRuleHandler http_request_rule.ReplaceHTTPRequestRuleHandler - // HTTPResponseRuleReplaceHTTPResponseRuleHandler sets the operation handler for the replace HTTP response rule operation - HTTPResponseRuleReplaceHTTPResponseRuleHandler http_response_rule.ReplaceHTTPResponseRuleHandler - // LogTargetReplaceLogTargetHandler sets the operation handler for the replace log target operation - LogTargetReplaceLogTargetHandler log_target.ReplaceLogTargetHandler - // ServerReplaceServerHandler sets the operation handler for the replace server operation - ServerReplaceServerHandler server.ReplaceServerHandler - // ServerSwitchingRuleReplaceServerSwitchingRuleHandler sets the operation handler for the replace server switching rule operation - ServerSwitchingRuleReplaceServerSwitchingRuleHandler server_switching_rule.ReplaceServerSwitchingRuleHandler - // SitesReplaceSiteHandler sets the operation handler for the replace site operation - SitesReplaceSiteHandler sites.ReplaceSiteHandler - // StickRuleReplaceStickRuleHandler sets the operation handler for the replace stick rule operation - StickRuleReplaceStickRuleHandler stick_rule.ReplaceStickRuleHandler - // TCPRequestRuleReplaceTCPRequestRuleHandler sets the operation handler for the replace TCP request rule operation - TCPRequestRuleReplaceTCPRequestRuleHandler tcp_request_rule.ReplaceTCPRequestRuleHandler - // TCPResponseRuleReplaceTCPResponseRuleHandler sets the operation handler for the replace TCP response rule operation - TCPResponseRuleReplaceTCPResponseRuleHandler tcp_response_rule.ReplaceTCPResponseRuleHandler - // TransactionsStartTransactionHandler sets the operation handler for the start transaction operation - TransactionsStartTransactionHandler transactions.StartTransactionHandler + // StorageCreateStorageSSLCrtListEntryHandler sets the operation handler for the create storage s s l crt list entry operation + StorageCreateStorageSSLCrtListEntryHandler storage.CreateStorageSSLCrtListEntryHandler + // ACLRuntimeDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler sets the operation handler for the delete services haproxy runtime acls parent name entries ID operation + ACLRuntimeDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler acl_runtime.DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler + // StorageDeleteStorageSSLCrtListEntryHandler sets the operation handler for the delete storage s s l crt list entry operation + StorageDeleteStorageSSLCrtListEntryHandler storage.DeleteStorageSSLCrtListEntryHandler + // ACLRuntimeGetServicesHaproxyRuntimeAclsHandler sets the operation handler for the get services haproxy runtime acls operation + ACLRuntimeGetServicesHaproxyRuntimeAclsHandler acl_runtime.GetServicesHaproxyRuntimeAclsHandler + // ACLRuntimeGetServicesHaproxyRuntimeAclsIDHandler sets the operation handler for the get services haproxy runtime acls ID operation + ACLRuntimeGetServicesHaproxyRuntimeAclsIDHandler acl_runtime.GetServicesHaproxyRuntimeAclsIDHandler + // ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesHandler sets the operation handler for the get services haproxy runtime acls parent name entries operation + ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesHandler acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesHandler + // ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler sets the operation handler for the get services haproxy runtime acls parent name entries ID operation + ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler + // StorageGetStorageSSLCrtListEntriesHandler sets the operation handler for the get storage s s l crt list entries operation + StorageGetStorageSSLCrtListEntriesHandler storage.GetStorageSSLCrtListEntriesHandler + // ACLRuntimePostServicesHaproxyRuntimeAclsParentNameEntriesHandler sets the operation handler for the post services haproxy runtime acls parent name entries operation + ACLRuntimePostServicesHaproxyRuntimeAclsParentNameEntriesHandler acl_runtime.PostServicesHaproxyRuntimeAclsParentNameEntriesHandler + // SslRuntimeAddCaEntryHandler sets the operation handler for the add ca entry operation + SslRuntimeAddCaEntryHandler s_s_l_runtime.AddCaEntryHandler + // SslRuntimeAddCrtListEntryHandler sets the operation handler for the add crt list entry operation + SslRuntimeAddCrtListEntryHandler s_s_l_runtime.AddCrtListEntryHandler + // DefaultsAddDefaultsSectionHandler sets the operation handler for the add defaults section operation + DefaultsAddDefaultsSectionHandler defaults.AddDefaultsSectionHandler + // MapsAddMapEntryHandler sets the operation handler for the add map entry operation + MapsAddMapEntryHandler maps.AddMapEntryHandler + // ACLRuntimeAddPayloadRuntimeACLHandler sets the operation handler for the add payload runtime ACL operation + ACLRuntimeAddPayloadRuntimeACLHandler acl_runtime.AddPayloadRuntimeACLHandler + // MapsAddPayloadRuntimeMapHandler sets the operation handler for the add payload runtime map operation + MapsAddPayloadRuntimeMapHandler maps.AddPayloadRuntimeMapHandler + // ServerAddRuntimeServerHandler sets the operation handler for the add runtime server operation + ServerAddRuntimeServerHandler serverops.AddRuntimeServerHandler + // MapsClearRuntimeMapHandler sets the operation handler for the clear runtime map operation + MapsClearRuntimeMapHandler maps.ClearRuntimeMapHandler + // SpoeTransactionsCommitSpoeTransactionHandler sets the operation handler for the commit spoe transaction operation + SpoeTransactionsCommitSpoeTransactionHandler spoe_transactions.CommitSpoeTransactionHandler + // TransactionsCommitTransactionHandler sets the operation handler for the commit transaction operation + TransactionsCommitTransactionHandler transactions.CommitTransactionHandler + // ServiceDiscoveryCreateAWSRegionHandler sets the operation handler for the create a w s region operation + ServiceDiscoveryCreateAWSRegionHandler service_discovery.CreateAWSRegionHandler + // ACLCreateACLBackendHandler sets the operation handler for the create Acl backend operation + ACLCreateACLBackendHandler acl.CreateACLBackendHandler + // ACLCreateACLDefaultsHandler sets the operation handler for the create Acl defaults operation + ACLCreateACLDefaultsHandler acl.CreateACLDefaultsHandler + // ACLCreateACLFCGIAppHandler sets the operation handler for the create Acl FCGI app operation + ACLCreateACLFCGIAppHandler acl.CreateACLFCGIAppHandler + // ACLCreateACLFrontendHandler sets the operation handler for the create Acl frontend operation + ACLCreateACLFrontendHandler acl.CreateACLFrontendHandler + // AcmeCreateAcmeProviderHandler sets the operation handler for the create acme provider operation + AcmeCreateAcmeProviderHandler acme.CreateAcmeProviderHandler + // BackendCreateBackendHandler sets the operation handler for the create backend operation + BackendCreateBackendHandler backend.CreateBackendHandler + // BackendSwitchingRuleCreateBackendSwitchingRuleHandler sets the operation handler for the create backend switching rule operation + BackendSwitchingRuleCreateBackendSwitchingRuleHandler backend_switching_rule.CreateBackendSwitchingRuleHandler + // BindCreateBindFrontendHandler sets the operation handler for the create bind frontend operation + BindCreateBindFrontendHandler bind.CreateBindFrontendHandler + // BindCreateBindLogForwardHandler sets the operation handler for the create bind log forward operation + BindCreateBindLogForwardHandler bind.CreateBindLogForwardHandler + // BindCreateBindPeerHandler sets the operation handler for the create bind peer operation + BindCreateBindPeerHandler bind.CreateBindPeerHandler + // SslRuntimeCreateCaFileHandler sets the operation handler for the create ca file operation + SslRuntimeCreateCaFileHandler s_s_l_runtime.CreateCaFileHandler + // CacheCreateCacheHandler sets the operation handler for the create cache operation + CacheCreateCacheHandler cache.CreateCacheHandler + // SslRuntimeCreateCertHandler sets the operation handler for the create cert operation + SslRuntimeCreateCertHandler s_s_l_runtime.CreateCertHandler + // ServiceDiscoveryCreateConsulHandler sets the operation handler for the create consul operation + ServiceDiscoveryCreateConsulHandler service_discovery.CreateConsulHandler + // SslRuntimeCreateCrlHandler sets the operation handler for the create crl operation + SslRuntimeCreateCrlHandler s_s_l_runtime.CreateCrlHandler + // CrtLoadCreateCrtLoadHandler sets the operation handler for the create crt load operation + CrtLoadCreateCrtLoadHandler crt_load.CreateCrtLoadHandler + // CrtStoreCreateCrtStoreHandler sets the operation handler for the create crt store operation + CrtStoreCreateCrtStoreHandler crt_store.CreateCrtStoreHandler + // DeclareCaptureCreateDeclareCaptureHandler sets the operation handler for the create declare capture operation + DeclareCaptureCreateDeclareCaptureHandler declare_capture.CreateDeclareCaptureHandler + // DefaultsCreateDefaultsSectionHandler sets the operation handler for the create defaults section operation + DefaultsCreateDefaultsSectionHandler defaults.CreateDefaultsSectionHandler + // DgramBindCreateDgramBindHandler sets the operation handler for the create dgram bind operation + DgramBindCreateDgramBindHandler dgram_bind.CreateDgramBindHandler + // FCGIAppCreateFCGIAppHandler sets the operation handler for the create FCGI app operation + FCGIAppCreateFCGIAppHandler fcgi_app.CreateFCGIAppHandler + // FilterCreateFilterBackendHandler sets the operation handler for the create filter backend operation + FilterCreateFilterBackendHandler filter.CreateFilterBackendHandler + // FilterCreateFilterFrontendHandler sets the operation handler for the create filter frontend operation + FilterCreateFilterFrontendHandler filter.CreateFilterFrontendHandler + // FrontendCreateFrontendHandler sets the operation handler for the create frontend operation + FrontendCreateFrontendHandler frontend.CreateFrontendHandler + // GroupCreateGroupHandler sets the operation handler for the create group operation + GroupCreateGroupHandler group.CreateGroupHandler + // HTTPAfterResponseRuleCreateHTTPAfterResponseRuleBackendHandler sets the operation handler for the create HTTP after response rule backend operation + HTTPAfterResponseRuleCreateHTTPAfterResponseRuleBackendHandler http_after_response_rule.CreateHTTPAfterResponseRuleBackendHandler + // HTTPAfterResponseRuleCreateHTTPAfterResponseRuleDefaultsHandler sets the operation handler for the create HTTP after response rule defaults operation + HTTPAfterResponseRuleCreateHTTPAfterResponseRuleDefaultsHandler http_after_response_rule.CreateHTTPAfterResponseRuleDefaultsHandler + // HTTPAfterResponseRuleCreateHTTPAfterResponseRuleFrontendHandler sets the operation handler for the create HTTP after response rule frontend operation + HTTPAfterResponseRuleCreateHTTPAfterResponseRuleFrontendHandler http_after_response_rule.CreateHTTPAfterResponseRuleFrontendHandler + // HTTPCheckCreateHTTPCheckBackendHandler sets the operation handler for the create HTTP check backend operation + HTTPCheckCreateHTTPCheckBackendHandler http_check.CreateHTTPCheckBackendHandler + // HTTPCheckCreateHTTPCheckDefaultsHandler sets the operation handler for the create HTTP check defaults operation + HTTPCheckCreateHTTPCheckDefaultsHandler http_check.CreateHTTPCheckDefaultsHandler + // HTTPErrorRuleCreateHTTPErrorRuleBackendHandler sets the operation handler for the create HTTP error rule backend operation + HTTPErrorRuleCreateHTTPErrorRuleBackendHandler http_error_rule.CreateHTTPErrorRuleBackendHandler + // HTTPErrorRuleCreateHTTPErrorRuleDefaultsHandler sets the operation handler for the create HTTP error rule defaults operation + HTTPErrorRuleCreateHTTPErrorRuleDefaultsHandler http_error_rule.CreateHTTPErrorRuleDefaultsHandler + // HTTPErrorRuleCreateHTTPErrorRuleFrontendHandler sets the operation handler for the create HTTP error rule frontend operation + HTTPErrorRuleCreateHTTPErrorRuleFrontendHandler http_error_rule.CreateHTTPErrorRuleFrontendHandler + // HTTPErrorsCreateHTTPErrorsSectionHandler sets the operation handler for the create HTTP errors section operation + HTTPErrorsCreateHTTPErrorsSectionHandler http_errors.CreateHTTPErrorsSectionHandler + // HTTPRequestRuleCreateHTTPRequestRuleBackendHandler sets the operation handler for the create HTTP request rule backend operation + HTTPRequestRuleCreateHTTPRequestRuleBackendHandler http_request_rule.CreateHTTPRequestRuleBackendHandler + // HTTPRequestRuleCreateHTTPRequestRuleDefaultsHandler sets the operation handler for the create HTTP request rule defaults operation + HTTPRequestRuleCreateHTTPRequestRuleDefaultsHandler http_request_rule.CreateHTTPRequestRuleDefaultsHandler + // HTTPRequestRuleCreateHTTPRequestRuleFrontendHandler sets the operation handler for the create HTTP request rule frontend operation + HTTPRequestRuleCreateHTTPRequestRuleFrontendHandler http_request_rule.CreateHTTPRequestRuleFrontendHandler + // HTTPResponseRuleCreateHTTPResponseRuleBackendHandler sets the operation handler for the create HTTP response rule backend operation + HTTPResponseRuleCreateHTTPResponseRuleBackendHandler http_response_rule.CreateHTTPResponseRuleBackendHandler + // HTTPResponseRuleCreateHTTPResponseRuleDefaultsHandler sets the operation handler for the create HTTP response rule defaults operation + HTTPResponseRuleCreateHTTPResponseRuleDefaultsHandler http_response_rule.CreateHTTPResponseRuleDefaultsHandler + // HTTPResponseRuleCreateHTTPResponseRuleFrontendHandler sets the operation handler for the create HTTP response rule frontend operation + HTTPResponseRuleCreateHTTPResponseRuleFrontendHandler http_response_rule.CreateHTTPResponseRuleFrontendHandler + // LogForwardCreateLogForwardHandler sets the operation handler for the create log forward operation + LogForwardCreateLogForwardHandler log_forward.CreateLogForwardHandler + // LogProfileCreateLogProfileHandler sets the operation handler for the create log profile operation + LogProfileCreateLogProfileHandler log_profile.CreateLogProfileHandler + // LogTargetCreateLogTargetBackendHandler sets the operation handler for the create log target backend operation + LogTargetCreateLogTargetBackendHandler log_target.CreateLogTargetBackendHandler + // LogTargetCreateLogTargetDefaultsHandler sets the operation handler for the create log target defaults operation + LogTargetCreateLogTargetDefaultsHandler log_target.CreateLogTargetDefaultsHandler + // LogTargetCreateLogTargetFrontendHandler sets the operation handler for the create log target frontend operation + LogTargetCreateLogTargetFrontendHandler log_target.CreateLogTargetFrontendHandler + // LogTargetCreateLogTargetGlobalHandler sets the operation handler for the create log target global operation + LogTargetCreateLogTargetGlobalHandler log_target.CreateLogTargetGlobalHandler + // LogTargetCreateLogTargetLogForwardHandler sets the operation handler for the create log target log forward operation + LogTargetCreateLogTargetLogForwardHandler log_target.CreateLogTargetLogForwardHandler + // LogTargetCreateLogTargetPeerHandler sets the operation handler for the create log target peer operation + LogTargetCreateLogTargetPeerHandler log_target.CreateLogTargetPeerHandler + // MailerEntryCreateMailerEntryHandler sets the operation handler for the create mailer entry operation + MailerEntryCreateMailerEntryHandler mailer_entry.CreateMailerEntryHandler + // MailersCreateMailersSectionHandler sets the operation handler for the create mailers section operation + MailersCreateMailersSectionHandler mailers.CreateMailersSectionHandler + // NameserverCreateNameserverHandler sets the operation handler for the create nameserver operation + NameserverCreateNameserverHandler nameserver.CreateNameserverHandler + // PeerCreatePeerHandler sets the operation handler for the create peer operation + PeerCreatePeerHandler peer.CreatePeerHandler + // PeerEntryCreatePeerEntryHandler sets the operation handler for the create peer entry operation + PeerEntryCreatePeerEntryHandler peer_entry.CreatePeerEntryHandler + // ProcessManagerCreateProgramHandler sets the operation handler for the create program operation + ProcessManagerCreateProgramHandler process_manager.CreateProgramHandler + // QUICInitialRuleCreateQUICInitialRuleDefaultsHandler sets the operation handler for the create QUIC initial rule defaults operation + QUICInitialRuleCreateQUICInitialRuleDefaultsHandler quic_initial_rule.CreateQUICInitialRuleDefaultsHandler + // QUICInitialRuleCreateQUICInitialRuleFrontendHandler sets the operation handler for the create QUIC initial rule frontend operation + QUICInitialRuleCreateQUICInitialRuleFrontendHandler quic_initial_rule.CreateQUICInitialRuleFrontendHandler + // ResolverCreateResolverHandler sets the operation handler for the create resolver operation + ResolverCreateResolverHandler resolver.CreateResolverHandler + // RingCreateRingHandler sets the operation handler for the create ring operation + RingCreateRingHandler ring.CreateRingHandler + // SslFrontUseCreateSSLFrontUseHandler sets the operation handler for the create s s l front use operation + SslFrontUseCreateSSLFrontUseHandler s_s_l_front_use.CreateSSLFrontUseHandler + // ServerCreateServerBackendHandler sets the operation handler for the create server backend operation + ServerCreateServerBackendHandler serverops.CreateServerBackendHandler + // ServerCreateServerPeerHandler sets the operation handler for the create server peer operation + ServerCreateServerPeerHandler serverops.CreateServerPeerHandler + // ServerCreateServerRingHandler sets the operation handler for the create server ring operation + ServerCreateServerRingHandler serverops.CreateServerRingHandler + // ServerSwitchingRuleCreateServerSwitchingRuleHandler sets the operation handler for the create server switching rule operation + ServerSwitchingRuleCreateServerSwitchingRuleHandler server_switching_rule.CreateServerSwitchingRuleHandler + // ServerTemplateCreateServerTemplateHandler sets the operation handler for the create server template operation + ServerTemplateCreateServerTemplateHandler server_template.CreateServerTemplateHandler + // SitesCreateSiteHandler sets the operation handler for the create site operation + SitesCreateSiteHandler sites.CreateSiteHandler + // SpoeCreateSpoeHandler sets the operation handler for the create spoe operation + SpoeCreateSpoeHandler spoe.CreateSpoeHandler + // SpoeCreateSpoeAgentHandler sets the operation handler for the create spoe agent operation + SpoeCreateSpoeAgentHandler spoe.CreateSpoeAgentHandler + // SpoeCreateSpoeGroupHandler sets the operation handler for the create spoe group operation + SpoeCreateSpoeGroupHandler spoe.CreateSpoeGroupHandler + // SpoeCreateSpoeMessageHandler sets the operation handler for the create spoe message operation + SpoeCreateSpoeMessageHandler spoe.CreateSpoeMessageHandler + // SpoeCreateSpoeScopeHandler sets the operation handler for the create spoe scope operation + SpoeCreateSpoeScopeHandler spoe.CreateSpoeScopeHandler + // StickRuleCreateStickRuleHandler sets the operation handler for the create stick rule operation + StickRuleCreateStickRuleHandler stick_rule.CreateStickRuleHandler + // StorageCreateStorageGeneralFileHandler sets the operation handler for the create storage general file operation + StorageCreateStorageGeneralFileHandler storage.CreateStorageGeneralFileHandler + // StorageCreateStorageMapFileHandler sets the operation handler for the create storage map file operation + StorageCreateStorageMapFileHandler storage.CreateStorageMapFileHandler + // StorageCreateStorageSSLCertificateHandler sets the operation handler for the create storage s s l certificate operation + StorageCreateStorageSSLCertificateHandler storage.CreateStorageSSLCertificateHandler + // StorageCreateStorageSSLCrtListFileHandler sets the operation handler for the create storage s s l crt list file operation + StorageCreateStorageSSLCrtListFileHandler storage.CreateStorageSSLCrtListFileHandler + // TCPCheckCreateTCPCheckBackendHandler sets the operation handler for the create TCP check backend operation + TCPCheckCreateTCPCheckBackendHandler tcp_check.CreateTCPCheckBackendHandler + // TCPCheckCreateTCPCheckDefaultsHandler sets the operation handler for the create TCP check defaults operation + TCPCheckCreateTCPCheckDefaultsHandler tcp_check.CreateTCPCheckDefaultsHandler + // TCPRequestRuleCreateTCPRequestRuleBackendHandler sets the operation handler for the create TCP request rule backend operation + TCPRequestRuleCreateTCPRequestRuleBackendHandler tcp_request_rule.CreateTCPRequestRuleBackendHandler + // TCPRequestRuleCreateTCPRequestRuleDefaultsHandler sets the operation handler for the create TCP request rule defaults operation + TCPRequestRuleCreateTCPRequestRuleDefaultsHandler tcp_request_rule.CreateTCPRequestRuleDefaultsHandler + // TCPRequestRuleCreateTCPRequestRuleFrontendHandler sets the operation handler for the create TCP request rule frontend operation + TCPRequestRuleCreateTCPRequestRuleFrontendHandler tcp_request_rule.CreateTCPRequestRuleFrontendHandler + // TCPResponseRuleCreateTCPResponseRuleBackendHandler sets the operation handler for the create TCP response rule backend operation + TCPResponseRuleCreateTCPResponseRuleBackendHandler tcp_response_rule.CreateTCPResponseRuleBackendHandler + // TCPResponseRuleCreateTCPResponseRuleDefaultsHandler sets the operation handler for the create TCP response rule defaults operation + TCPResponseRuleCreateTCPResponseRuleDefaultsHandler tcp_response_rule.CreateTCPResponseRuleDefaultsHandler + // TableCreateTableHandler sets the operation handler for the create table operation + TableCreateTableHandler table.CreateTableHandler + // TracesCreateTraceEntryHandler sets the operation handler for the create trace entry operation + TracesCreateTraceEntryHandler traces.CreateTraceEntryHandler + // TracesCreateTracesHandler sets the operation handler for the create traces operation + TracesCreateTracesHandler traces.CreateTracesHandler + // UserCreateUserHandler sets the operation handler for the create user operation + UserCreateUserHandler user.CreateUserHandler + // UserlistCreateUserlistHandler sets the operation handler for the create userlist operation + UserlistCreateUserlistHandler userlist.CreateUserlistHandler + // ServiceDiscoveryDeleteAWSRegionHandler sets the operation handler for the delete a w s region operation + ServiceDiscoveryDeleteAWSRegionHandler service_discovery.DeleteAWSRegionHandler + // ACLDeleteACLBackendHandler sets the operation handler for the delete Acl backend operation + ACLDeleteACLBackendHandler acl.DeleteACLBackendHandler + // ACLDeleteACLDefaultsHandler sets the operation handler for the delete Acl defaults operation + ACLDeleteACLDefaultsHandler acl.DeleteACLDefaultsHandler + // ACLDeleteACLFCGIAppHandler sets the operation handler for the delete Acl FCGI app operation + ACLDeleteACLFCGIAppHandler acl.DeleteACLFCGIAppHandler + // ACLDeleteACLFrontendHandler sets the operation handler for the delete Acl frontend operation + ACLDeleteACLFrontendHandler acl.DeleteACLFrontendHandler + // AcmeDeleteAcmeProviderHandler sets the operation handler for the delete acme provider operation + AcmeDeleteAcmeProviderHandler acme.DeleteAcmeProviderHandler + // BackendDeleteBackendHandler sets the operation handler for the delete backend operation + BackendDeleteBackendHandler backend.DeleteBackendHandler + // BackendSwitchingRuleDeleteBackendSwitchingRuleHandler sets the operation handler for the delete backend switching rule operation + BackendSwitchingRuleDeleteBackendSwitchingRuleHandler backend_switching_rule.DeleteBackendSwitchingRuleHandler + // BindDeleteBindFrontendHandler sets the operation handler for the delete bind frontend operation + BindDeleteBindFrontendHandler bind.DeleteBindFrontendHandler + // BindDeleteBindLogForwardHandler sets the operation handler for the delete bind log forward operation + BindDeleteBindLogForwardHandler bind.DeleteBindLogForwardHandler + // BindDeleteBindPeerHandler sets the operation handler for the delete bind peer operation + BindDeleteBindPeerHandler bind.DeleteBindPeerHandler + // SslRuntimeDeleteCaFileHandler sets the operation handler for the delete ca file operation + SslRuntimeDeleteCaFileHandler s_s_l_runtime.DeleteCaFileHandler + // CacheDeleteCacheHandler sets the operation handler for the delete cache operation + CacheDeleteCacheHandler cache.DeleteCacheHandler + // SslRuntimeDeleteCertHandler sets the operation handler for the delete cert operation + SslRuntimeDeleteCertHandler s_s_l_runtime.DeleteCertHandler + // ClusterDeleteClusterHandler sets the operation handler for the delete cluster operation + ClusterDeleteClusterHandler cluster.DeleteClusterHandler + // ServiceDiscoveryDeleteConsulHandler sets the operation handler for the delete consul operation + ServiceDiscoveryDeleteConsulHandler service_discovery.DeleteConsulHandler + // SslRuntimeDeleteCrlHandler sets the operation handler for the delete crl operation + SslRuntimeDeleteCrlHandler s_s_l_runtime.DeleteCrlHandler + // SslRuntimeDeleteCrtListEntryHandler sets the operation handler for the delete crt list entry operation + SslRuntimeDeleteCrtListEntryHandler s_s_l_runtime.DeleteCrtListEntryHandler + // CrtLoadDeleteCrtLoadHandler sets the operation handler for the delete crt load operation + CrtLoadDeleteCrtLoadHandler crt_load.DeleteCrtLoadHandler + // CrtStoreDeleteCrtStoreHandler sets the operation handler for the delete crt store operation + CrtStoreDeleteCrtStoreHandler crt_store.DeleteCrtStoreHandler + // DeclareCaptureDeleteDeclareCaptureHandler sets the operation handler for the delete declare capture operation + DeclareCaptureDeleteDeclareCaptureHandler declare_capture.DeleteDeclareCaptureHandler + // DefaultsDeleteDefaultsSectionHandler sets the operation handler for the delete defaults section operation + DefaultsDeleteDefaultsSectionHandler defaults.DeleteDefaultsSectionHandler + // DgramBindDeleteDgramBindHandler sets the operation handler for the delete dgram bind operation + DgramBindDeleteDgramBindHandler dgram_bind.DeleteDgramBindHandler + // FCGIAppDeleteFCGIAppHandler sets the operation handler for the delete FCGI app operation + FCGIAppDeleteFCGIAppHandler fcgi_app.DeleteFCGIAppHandler + // FilterDeleteFilterBackendHandler sets the operation handler for the delete filter backend operation + FilterDeleteFilterBackendHandler filter.DeleteFilterBackendHandler + // FilterDeleteFilterFrontendHandler sets the operation handler for the delete filter frontend operation + FilterDeleteFilterFrontendHandler filter.DeleteFilterFrontendHandler + // FrontendDeleteFrontendHandler sets the operation handler for the delete frontend operation + FrontendDeleteFrontendHandler frontend.DeleteFrontendHandler + // GroupDeleteGroupHandler sets the operation handler for the delete group operation + GroupDeleteGroupHandler group.DeleteGroupHandler + // HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleBackendHandler sets the operation handler for the delete HTTP after response rule backend operation + HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleBackendHandler http_after_response_rule.DeleteHTTPAfterResponseRuleBackendHandler + // HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleDefaultsHandler sets the operation handler for the delete HTTP after response rule defaults operation + HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleDefaultsHandler http_after_response_rule.DeleteHTTPAfterResponseRuleDefaultsHandler + // HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleFrontendHandler sets the operation handler for the delete HTTP after response rule frontend operation + HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleFrontendHandler http_after_response_rule.DeleteHTTPAfterResponseRuleFrontendHandler + // HTTPCheckDeleteHTTPCheckBackendHandler sets the operation handler for the delete HTTP check backend operation + HTTPCheckDeleteHTTPCheckBackendHandler http_check.DeleteHTTPCheckBackendHandler + // HTTPCheckDeleteHTTPCheckDefaultsHandler sets the operation handler for the delete HTTP check defaults operation + HTTPCheckDeleteHTTPCheckDefaultsHandler http_check.DeleteHTTPCheckDefaultsHandler + // HTTPErrorRuleDeleteHTTPErrorRuleBackendHandler sets the operation handler for the delete HTTP error rule backend operation + HTTPErrorRuleDeleteHTTPErrorRuleBackendHandler http_error_rule.DeleteHTTPErrorRuleBackendHandler + // HTTPErrorRuleDeleteHTTPErrorRuleDefaultsHandler sets the operation handler for the delete HTTP error rule defaults operation + HTTPErrorRuleDeleteHTTPErrorRuleDefaultsHandler http_error_rule.DeleteHTTPErrorRuleDefaultsHandler + // HTTPErrorRuleDeleteHTTPErrorRuleFrontendHandler sets the operation handler for the delete HTTP error rule frontend operation + HTTPErrorRuleDeleteHTTPErrorRuleFrontendHandler http_error_rule.DeleteHTTPErrorRuleFrontendHandler + // HTTPErrorsDeleteHTTPErrorsSectionHandler sets the operation handler for the delete HTTP errors section operation + HTTPErrorsDeleteHTTPErrorsSectionHandler http_errors.DeleteHTTPErrorsSectionHandler + // HTTPRequestRuleDeleteHTTPRequestRuleBackendHandler sets the operation handler for the delete HTTP request rule backend operation + HTTPRequestRuleDeleteHTTPRequestRuleBackendHandler http_request_rule.DeleteHTTPRequestRuleBackendHandler + // HTTPRequestRuleDeleteHTTPRequestRuleDefaultsHandler sets the operation handler for the delete HTTP request rule defaults operation + HTTPRequestRuleDeleteHTTPRequestRuleDefaultsHandler http_request_rule.DeleteHTTPRequestRuleDefaultsHandler + // HTTPRequestRuleDeleteHTTPRequestRuleFrontendHandler sets the operation handler for the delete HTTP request rule frontend operation + HTTPRequestRuleDeleteHTTPRequestRuleFrontendHandler http_request_rule.DeleteHTTPRequestRuleFrontendHandler + // HTTPResponseRuleDeleteHTTPResponseRuleBackendHandler sets the operation handler for the delete HTTP response rule backend operation + HTTPResponseRuleDeleteHTTPResponseRuleBackendHandler http_response_rule.DeleteHTTPResponseRuleBackendHandler + // HTTPResponseRuleDeleteHTTPResponseRuleDefaultsHandler sets the operation handler for the delete HTTP response rule defaults operation + HTTPResponseRuleDeleteHTTPResponseRuleDefaultsHandler http_response_rule.DeleteHTTPResponseRuleDefaultsHandler + // HTTPResponseRuleDeleteHTTPResponseRuleFrontendHandler sets the operation handler for the delete HTTP response rule frontend operation + HTTPResponseRuleDeleteHTTPResponseRuleFrontendHandler http_response_rule.DeleteHTTPResponseRuleFrontendHandler + // LogForwardDeleteLogForwardHandler sets the operation handler for the delete log forward operation + LogForwardDeleteLogForwardHandler log_forward.DeleteLogForwardHandler + // LogProfileDeleteLogProfileHandler sets the operation handler for the delete log profile operation + LogProfileDeleteLogProfileHandler log_profile.DeleteLogProfileHandler + // LogTargetDeleteLogTargetBackendHandler sets the operation handler for the delete log target backend operation + LogTargetDeleteLogTargetBackendHandler log_target.DeleteLogTargetBackendHandler + // LogTargetDeleteLogTargetDefaultsHandler sets the operation handler for the delete log target defaults operation + LogTargetDeleteLogTargetDefaultsHandler log_target.DeleteLogTargetDefaultsHandler + // LogTargetDeleteLogTargetFrontendHandler sets the operation handler for the delete log target frontend operation + LogTargetDeleteLogTargetFrontendHandler log_target.DeleteLogTargetFrontendHandler + // LogTargetDeleteLogTargetGlobalHandler sets the operation handler for the delete log target global operation + LogTargetDeleteLogTargetGlobalHandler log_target.DeleteLogTargetGlobalHandler + // LogTargetDeleteLogTargetLogForwardHandler sets the operation handler for the delete log target log forward operation + LogTargetDeleteLogTargetLogForwardHandler log_target.DeleteLogTargetLogForwardHandler + // LogTargetDeleteLogTargetPeerHandler sets the operation handler for the delete log target peer operation + LogTargetDeleteLogTargetPeerHandler log_target.DeleteLogTargetPeerHandler + // MailerEntryDeleteMailerEntryHandler sets the operation handler for the delete mailer entry operation + MailerEntryDeleteMailerEntryHandler mailer_entry.DeleteMailerEntryHandler + // MailersDeleteMailersSectionHandler sets the operation handler for the delete mailers section operation + MailersDeleteMailersSectionHandler mailers.DeleteMailersSectionHandler + // NameserverDeleteNameserverHandler sets the operation handler for the delete nameserver operation + NameserverDeleteNameserverHandler nameserver.DeleteNameserverHandler + // PeerDeletePeerHandler sets the operation handler for the delete peer operation + PeerDeletePeerHandler peer.DeletePeerHandler + // PeerEntryDeletePeerEntryHandler sets the operation handler for the delete peer entry operation + PeerEntryDeletePeerEntryHandler peer_entry.DeletePeerEntryHandler + // ProcessManagerDeleteProgramHandler sets the operation handler for the delete program operation + ProcessManagerDeleteProgramHandler process_manager.DeleteProgramHandler + // QUICInitialRuleDeleteQUICInitialRuleDefaultsHandler sets the operation handler for the delete QUIC initial rule defaults operation + QUICInitialRuleDeleteQUICInitialRuleDefaultsHandler quic_initial_rule.DeleteQUICInitialRuleDefaultsHandler + // QUICInitialRuleDeleteQUICInitialRuleFrontendHandler sets the operation handler for the delete QUIC initial rule frontend operation + QUICInitialRuleDeleteQUICInitialRuleFrontendHandler quic_initial_rule.DeleteQUICInitialRuleFrontendHandler + // ResolverDeleteResolverHandler sets the operation handler for the delete resolver operation + ResolverDeleteResolverHandler resolver.DeleteResolverHandler + // RingDeleteRingHandler sets the operation handler for the delete ring operation + RingDeleteRingHandler ring.DeleteRingHandler + // MapsDeleteRuntimeMapEntryHandler sets the operation handler for the delete runtime map entry operation + MapsDeleteRuntimeMapEntryHandler maps.DeleteRuntimeMapEntryHandler + // ServerDeleteRuntimeServerHandler sets the operation handler for the delete runtime server operation + ServerDeleteRuntimeServerHandler serverops.DeleteRuntimeServerHandler + // SslFrontUseDeleteSSLFrontUseHandler sets the operation handler for the delete s s l front use operation + SslFrontUseDeleteSSLFrontUseHandler s_s_l_front_use.DeleteSSLFrontUseHandler + // ServerDeleteServerBackendHandler sets the operation handler for the delete server backend operation + ServerDeleteServerBackendHandler serverops.DeleteServerBackendHandler + // ServerDeleteServerPeerHandler sets the operation handler for the delete server peer operation + ServerDeleteServerPeerHandler serverops.DeleteServerPeerHandler + // ServerDeleteServerRingHandler sets the operation handler for the delete server ring operation + ServerDeleteServerRingHandler serverops.DeleteServerRingHandler + // ServerSwitchingRuleDeleteServerSwitchingRuleHandler sets the operation handler for the delete server switching rule operation + ServerSwitchingRuleDeleteServerSwitchingRuleHandler server_switching_rule.DeleteServerSwitchingRuleHandler + // ServerTemplateDeleteServerTemplateHandler sets the operation handler for the delete server template operation + ServerTemplateDeleteServerTemplateHandler server_template.DeleteServerTemplateHandler + // SitesDeleteSiteHandler sets the operation handler for the delete site operation + SitesDeleteSiteHandler sites.DeleteSiteHandler + // SpoeDeleteSpoeAgentHandler sets the operation handler for the delete spoe agent operation + SpoeDeleteSpoeAgentHandler spoe.DeleteSpoeAgentHandler + // SpoeDeleteSpoeFileHandler sets the operation handler for the delete spoe file operation + SpoeDeleteSpoeFileHandler spoe.DeleteSpoeFileHandler + // SpoeDeleteSpoeGroupHandler sets the operation handler for the delete spoe group operation + SpoeDeleteSpoeGroupHandler spoe.DeleteSpoeGroupHandler + // SpoeDeleteSpoeMessageHandler sets the operation handler for the delete spoe message operation + SpoeDeleteSpoeMessageHandler spoe.DeleteSpoeMessageHandler + // SpoeDeleteSpoeScopeHandler sets the operation handler for the delete spoe scope operation + SpoeDeleteSpoeScopeHandler spoe.DeleteSpoeScopeHandler + // SpoeTransactionsDeleteSpoeTransactionHandler sets the operation handler for the delete spoe transaction operation + SpoeTransactionsDeleteSpoeTransactionHandler spoe_transactions.DeleteSpoeTransactionHandler + // StickRuleDeleteStickRuleHandler sets the operation handler for the delete stick rule operation + StickRuleDeleteStickRuleHandler stick_rule.DeleteStickRuleHandler + // StorageDeleteStorageGeneralFileHandler sets the operation handler for the delete storage general file operation + StorageDeleteStorageGeneralFileHandler storage.DeleteStorageGeneralFileHandler + // StorageDeleteStorageMapHandler sets the operation handler for the delete storage map operation + StorageDeleteStorageMapHandler storage.DeleteStorageMapHandler + // StorageDeleteStorageSSLCertificateHandler sets the operation handler for the delete storage s s l certificate operation + StorageDeleteStorageSSLCertificateHandler storage.DeleteStorageSSLCertificateHandler + // StorageDeleteStorageSSLCrtListFileHandler sets the operation handler for the delete storage s s l crt list file operation + StorageDeleteStorageSSLCrtListFileHandler storage.DeleteStorageSSLCrtListFileHandler + // TCPCheckDeleteTCPCheckBackendHandler sets the operation handler for the delete TCP check backend operation + TCPCheckDeleteTCPCheckBackendHandler tcp_check.DeleteTCPCheckBackendHandler + // TCPCheckDeleteTCPCheckDefaultsHandler sets the operation handler for the delete TCP check defaults operation + TCPCheckDeleteTCPCheckDefaultsHandler tcp_check.DeleteTCPCheckDefaultsHandler + // TCPRequestRuleDeleteTCPRequestRuleBackendHandler sets the operation handler for the delete TCP request rule backend operation + TCPRequestRuleDeleteTCPRequestRuleBackendHandler tcp_request_rule.DeleteTCPRequestRuleBackendHandler + // TCPRequestRuleDeleteTCPRequestRuleDefaultsHandler sets the operation handler for the delete TCP request rule defaults operation + TCPRequestRuleDeleteTCPRequestRuleDefaultsHandler tcp_request_rule.DeleteTCPRequestRuleDefaultsHandler + // TCPRequestRuleDeleteTCPRequestRuleFrontendHandler sets the operation handler for the delete TCP request rule frontend operation + TCPRequestRuleDeleteTCPRequestRuleFrontendHandler tcp_request_rule.DeleteTCPRequestRuleFrontendHandler + // TCPResponseRuleDeleteTCPResponseRuleBackendHandler sets the operation handler for the delete TCP response rule backend operation + TCPResponseRuleDeleteTCPResponseRuleBackendHandler tcp_response_rule.DeleteTCPResponseRuleBackendHandler + // TCPResponseRuleDeleteTCPResponseRuleDefaultsHandler sets the operation handler for the delete TCP response rule defaults operation + TCPResponseRuleDeleteTCPResponseRuleDefaultsHandler tcp_response_rule.DeleteTCPResponseRuleDefaultsHandler + // TableDeleteTableHandler sets the operation handler for the delete table operation + TableDeleteTableHandler table.DeleteTableHandler + // TracesDeleteTraceEntryHandler sets the operation handler for the delete trace entry operation + TracesDeleteTraceEntryHandler traces.DeleteTraceEntryHandler + // TracesDeleteTracesHandler sets the operation handler for the delete traces operation + TracesDeleteTracesHandler traces.DeleteTracesHandler + // TransactionsDeleteTransactionHandler sets the operation handler for the delete transaction operation + TransactionsDeleteTransactionHandler transactions.DeleteTransactionHandler + // UserDeleteUserHandler sets the operation handler for the delete user operation + UserDeleteUserHandler user.DeleteUserHandler + // UserlistDeleteUserlistHandler sets the operation handler for the delete userlist operation + UserlistDeleteUserlistHandler userlist.DeleteUserlistHandler + // AcmeEditAcmeProviderHandler sets the operation handler for the edit acme provider operation + AcmeEditAcmeProviderHandler acme.EditAcmeProviderHandler + // ClusterEditClusterHandler sets the operation handler for the edit cluster operation + ClusterEditClusterHandler cluster.EditClusterHandler + // CrtStoreEditCrtStoreHandler sets the operation handler for the edit crt store operation + CrtStoreEditCrtStoreHandler crt_store.EditCrtStoreHandler + // LogProfileEditLogProfileHandler sets the operation handler for the edit log profile operation + LogProfileEditLogProfileHandler log_profile.EditLogProfileHandler + // MailersEditMailersSectionHandler sets the operation handler for the edit mailers section operation + MailersEditMailersSectionHandler mailers.EditMailersSectionHandler + // DiscoveryGetAPIEndpointsHandler sets the operation handler for the get API endpoints operation + DiscoveryGetAPIEndpointsHandler discovery.GetAPIEndpointsHandler + // ServiceDiscoveryGetAWSRegionHandler sets the operation handler for the get a w s region operation + ServiceDiscoveryGetAWSRegionHandler service_discovery.GetAWSRegionHandler + // ServiceDiscoveryGetAWSRegionsHandler sets the operation handler for the get a w s regions operation + ServiceDiscoveryGetAWSRegionsHandler service_discovery.GetAWSRegionsHandler + // ACLGetACLBackendHandler sets the operation handler for the get Acl backend operation + ACLGetACLBackendHandler acl.GetACLBackendHandler + // ACLGetACLDefaultsHandler sets the operation handler for the get Acl defaults operation + ACLGetACLDefaultsHandler acl.GetACLDefaultsHandler + // ACLGetACLFCGIAppHandler sets the operation handler for the get Acl FCGI app operation + ACLGetACLFCGIAppHandler acl.GetACLFCGIAppHandler + // ACLGetACLFrontendHandler sets the operation handler for the get Acl frontend operation + ACLGetACLFrontendHandler acl.GetACLFrontendHandler + // AcmeGetAcmeProviderHandler sets the operation handler for the get acme provider operation + AcmeGetAcmeProviderHandler acme.GetAcmeProviderHandler + // AcmeGetAcmeProvidersHandler sets the operation handler for the get acme providers operation + AcmeGetAcmeProvidersHandler acme.GetAcmeProvidersHandler + // AcmeRuntimeGetAcmeStatusHandler sets the operation handler for the get acme status operation + AcmeRuntimeGetAcmeStatusHandler acme_runtime.GetAcmeStatusHandler + // ACLGetAllACLBackendHandler sets the operation handler for the get all Acl backend operation + ACLGetAllACLBackendHandler acl.GetAllACLBackendHandler + // ACLGetAllACLDefaultsHandler sets the operation handler for the get all Acl defaults operation + ACLGetAllACLDefaultsHandler acl.GetAllACLDefaultsHandler + // ACLGetAllACLFCGIAppHandler sets the operation handler for the get all Acl FCGI app operation + ACLGetAllACLFCGIAppHandler acl.GetAllACLFCGIAppHandler + // ACLGetAllACLFrontendHandler sets the operation handler for the get all Acl frontend operation + ACLGetAllACLFrontendHandler acl.GetAllACLFrontendHandler + // BindGetAllBindFrontendHandler sets the operation handler for the get all bind frontend operation + BindGetAllBindFrontendHandler bind.GetAllBindFrontendHandler + // BindGetAllBindLogForwardHandler sets the operation handler for the get all bind log forward operation + BindGetAllBindLogForwardHandler bind.GetAllBindLogForwardHandler + // BindGetAllBindPeerHandler sets the operation handler for the get all bind peer operation + BindGetAllBindPeerHandler bind.GetAllBindPeerHandler + // SslRuntimeGetAllCaFilesHandler sets the operation handler for the get all ca files operation + SslRuntimeGetAllCaFilesHandler s_s_l_runtime.GetAllCaFilesHandler + // SslRuntimeGetAllCertsHandler sets the operation handler for the get all certs operation + SslRuntimeGetAllCertsHandler s_s_l_runtime.GetAllCertsHandler + // SslRuntimeGetAllCrlHandler sets the operation handler for the get all crl operation + SslRuntimeGetAllCrlHandler s_s_l_runtime.GetAllCrlHandler + // SslRuntimeGetAllCrtListEntriesHandler sets the operation handler for the get all crt list entries operation + SslRuntimeGetAllCrtListEntriesHandler s_s_l_runtime.GetAllCrtListEntriesHandler + // SslRuntimeGetAllCrtListsHandler sets the operation handler for the get all crt lists operation + SslRuntimeGetAllCrtListsHandler s_s_l_runtime.GetAllCrtListsHandler + // FilterGetAllFilterBackendHandler sets the operation handler for the get all filter backend operation + FilterGetAllFilterBackendHandler filter.GetAllFilterBackendHandler + // FilterGetAllFilterFrontendHandler sets the operation handler for the get all filter frontend operation + FilterGetAllFilterFrontendHandler filter.GetAllFilterFrontendHandler + // HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleBackendHandler sets the operation handler for the get all HTTP after response rule backend operation + HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleBackendHandler http_after_response_rule.GetAllHTTPAfterResponseRuleBackendHandler + // HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleDefaultsHandler sets the operation handler for the get all HTTP after response rule defaults operation + HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleDefaultsHandler http_after_response_rule.GetAllHTTPAfterResponseRuleDefaultsHandler + // HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleFrontendHandler sets the operation handler for the get all HTTP after response rule frontend operation + HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleFrontendHandler http_after_response_rule.GetAllHTTPAfterResponseRuleFrontendHandler + // HTTPCheckGetAllHTTPCheckBackendHandler sets the operation handler for the get all HTTP check backend operation + HTTPCheckGetAllHTTPCheckBackendHandler http_check.GetAllHTTPCheckBackendHandler + // HTTPCheckGetAllHTTPCheckDefaultsHandler sets the operation handler for the get all HTTP check defaults operation + HTTPCheckGetAllHTTPCheckDefaultsHandler http_check.GetAllHTTPCheckDefaultsHandler + // HTTPErrorRuleGetAllHTTPErrorRuleBackendHandler sets the operation handler for the get all HTTP error rule backend operation + HTTPErrorRuleGetAllHTTPErrorRuleBackendHandler http_error_rule.GetAllHTTPErrorRuleBackendHandler + // HTTPErrorRuleGetAllHTTPErrorRuleDefaultsHandler sets the operation handler for the get all HTTP error rule defaults operation + HTTPErrorRuleGetAllHTTPErrorRuleDefaultsHandler http_error_rule.GetAllHTTPErrorRuleDefaultsHandler + // HTTPErrorRuleGetAllHTTPErrorRuleFrontendHandler sets the operation handler for the get all HTTP error rule frontend operation + HTTPErrorRuleGetAllHTTPErrorRuleFrontendHandler http_error_rule.GetAllHTTPErrorRuleFrontendHandler + // HTTPRequestRuleGetAllHTTPRequestRuleBackendHandler sets the operation handler for the get all HTTP request rule backend operation + HTTPRequestRuleGetAllHTTPRequestRuleBackendHandler http_request_rule.GetAllHTTPRequestRuleBackendHandler + // HTTPRequestRuleGetAllHTTPRequestRuleDefaultsHandler sets the operation handler for the get all HTTP request rule defaults operation + HTTPRequestRuleGetAllHTTPRequestRuleDefaultsHandler http_request_rule.GetAllHTTPRequestRuleDefaultsHandler + // HTTPRequestRuleGetAllHTTPRequestRuleFrontendHandler sets the operation handler for the get all HTTP request rule frontend operation + HTTPRequestRuleGetAllHTTPRequestRuleFrontendHandler http_request_rule.GetAllHTTPRequestRuleFrontendHandler + // HTTPResponseRuleGetAllHTTPResponseRuleBackendHandler sets the operation handler for the get all HTTP response rule backend operation + HTTPResponseRuleGetAllHTTPResponseRuleBackendHandler http_response_rule.GetAllHTTPResponseRuleBackendHandler + // HTTPResponseRuleGetAllHTTPResponseRuleDefaultsHandler sets the operation handler for the get all HTTP response rule defaults operation + HTTPResponseRuleGetAllHTTPResponseRuleDefaultsHandler http_response_rule.GetAllHTTPResponseRuleDefaultsHandler + // HTTPResponseRuleGetAllHTTPResponseRuleFrontendHandler sets the operation handler for the get all HTTP response rule frontend operation + HTTPResponseRuleGetAllHTTPResponseRuleFrontendHandler http_response_rule.GetAllHTTPResponseRuleFrontendHandler + // LogTargetGetAllLogTargetBackendHandler sets the operation handler for the get all log target backend operation + LogTargetGetAllLogTargetBackendHandler log_target.GetAllLogTargetBackendHandler + // LogTargetGetAllLogTargetDefaultsHandler sets the operation handler for the get all log target defaults operation + LogTargetGetAllLogTargetDefaultsHandler log_target.GetAllLogTargetDefaultsHandler + // LogTargetGetAllLogTargetFrontendHandler sets the operation handler for the get all log target frontend operation + LogTargetGetAllLogTargetFrontendHandler log_target.GetAllLogTargetFrontendHandler + // LogTargetGetAllLogTargetGlobalHandler sets the operation handler for the get all log target global operation + LogTargetGetAllLogTargetGlobalHandler log_target.GetAllLogTargetGlobalHandler + // LogTargetGetAllLogTargetLogForwardHandler sets the operation handler for the get all log target log forward operation + LogTargetGetAllLogTargetLogForwardHandler log_target.GetAllLogTargetLogForwardHandler + // LogTargetGetAllLogTargetPeerHandler sets the operation handler for the get all log target peer operation + LogTargetGetAllLogTargetPeerHandler log_target.GetAllLogTargetPeerHandler + // QUICInitialRuleGetAllQUICInitialRuleDefaultsHandler sets the operation handler for the get all QUIC initial rule defaults operation + QUICInitialRuleGetAllQUICInitialRuleDefaultsHandler quic_initial_rule.GetAllQUICInitialRuleDefaultsHandler + // QUICInitialRuleGetAllQUICInitialRuleFrontendHandler sets the operation handler for the get all QUIC initial rule frontend operation + QUICInitialRuleGetAllQUICInitialRuleFrontendHandler quic_initial_rule.GetAllQUICInitialRuleFrontendHandler + // MapsGetAllRuntimeMapFilesHandler sets the operation handler for the get all runtime map files operation + MapsGetAllRuntimeMapFilesHandler maps.GetAllRuntimeMapFilesHandler + // ServerGetAllRuntimeServerHandler sets the operation handler for the get all runtime server operation + ServerGetAllRuntimeServerHandler serverops.GetAllRuntimeServerHandler + // SslFrontUseGetAllSSLFrontUsesHandler sets the operation handler for the get all s s l front uses operation + SslFrontUseGetAllSSLFrontUsesHandler s_s_l_front_use.GetAllSSLFrontUsesHandler + // ServerGetAllServerBackendHandler sets the operation handler for the get all server backend operation + ServerGetAllServerBackendHandler serverops.GetAllServerBackendHandler + // ServerGetAllServerPeerHandler sets the operation handler for the get all server peer operation + ServerGetAllServerPeerHandler serverops.GetAllServerPeerHandler + // ServerGetAllServerRingHandler sets the operation handler for the get all server ring operation + ServerGetAllServerRingHandler serverops.GetAllServerRingHandler + // SpoeGetAllSpoeAgentHandler sets the operation handler for the get all spoe agent operation + SpoeGetAllSpoeAgentHandler spoe.GetAllSpoeAgentHandler + // SpoeGetAllSpoeFilesHandler sets the operation handler for the get all spoe files operation + SpoeGetAllSpoeFilesHandler spoe.GetAllSpoeFilesHandler + // SpoeGetAllSpoeGroupHandler sets the operation handler for the get all spoe group operation + SpoeGetAllSpoeGroupHandler spoe.GetAllSpoeGroupHandler + // SpoeGetAllSpoeMessageHandler sets the operation handler for the get all spoe message operation + SpoeGetAllSpoeMessageHandler spoe.GetAllSpoeMessageHandler + // SpoeGetAllSpoeScopeHandler sets the operation handler for the get all spoe scope operation + SpoeGetAllSpoeScopeHandler spoe.GetAllSpoeScopeHandler + // SpoeTransactionsGetAllSpoeTransactionHandler sets the operation handler for the get all spoe transaction operation + SpoeTransactionsGetAllSpoeTransactionHandler spoe_transactions.GetAllSpoeTransactionHandler + // StorageGetAllStorageGeneralFilesHandler sets the operation handler for the get all storage general files operation + StorageGetAllStorageGeneralFilesHandler storage.GetAllStorageGeneralFilesHandler + // StorageGetAllStorageMapFilesHandler sets the operation handler for the get all storage map files operation + StorageGetAllStorageMapFilesHandler storage.GetAllStorageMapFilesHandler + // StorageGetAllStorageSSLCertificatesHandler sets the operation handler for the get all storage s s l certificates operation + StorageGetAllStorageSSLCertificatesHandler storage.GetAllStorageSSLCertificatesHandler + // StorageGetAllStorageSSLCrtListFilesHandler sets the operation handler for the get all storage s s l crt list files operation + StorageGetAllStorageSSLCrtListFilesHandler storage.GetAllStorageSSLCrtListFilesHandler + // TCPCheckGetAllTCPCheckBackendHandler sets the operation handler for the get all TCP check backend operation + TCPCheckGetAllTCPCheckBackendHandler tcp_check.GetAllTCPCheckBackendHandler + // TCPCheckGetAllTCPCheckDefaultsHandler sets the operation handler for the get all TCP check defaults operation + TCPCheckGetAllTCPCheckDefaultsHandler tcp_check.GetAllTCPCheckDefaultsHandler + // TCPRequestRuleGetAllTCPRequestRuleBackendHandler sets the operation handler for the get all TCP request rule backend operation + TCPRequestRuleGetAllTCPRequestRuleBackendHandler tcp_request_rule.GetAllTCPRequestRuleBackendHandler + // TCPRequestRuleGetAllTCPRequestRuleDefaultsHandler sets the operation handler for the get all TCP request rule defaults operation + TCPRequestRuleGetAllTCPRequestRuleDefaultsHandler tcp_request_rule.GetAllTCPRequestRuleDefaultsHandler + // TCPRequestRuleGetAllTCPRequestRuleFrontendHandler sets the operation handler for the get all TCP request rule frontend operation + TCPRequestRuleGetAllTCPRequestRuleFrontendHandler tcp_request_rule.GetAllTCPRequestRuleFrontendHandler + // TCPResponseRuleGetAllTCPResponseRuleBackendHandler sets the operation handler for the get all TCP response rule backend operation + TCPResponseRuleGetAllTCPResponseRuleBackendHandler tcp_response_rule.GetAllTCPResponseRuleBackendHandler + // TCPResponseRuleGetAllTCPResponseRuleDefaultsHandler sets the operation handler for the get all TCP response rule defaults operation + TCPResponseRuleGetAllTCPResponseRuleDefaultsHandler tcp_response_rule.GetAllTCPResponseRuleDefaultsHandler + // BackendGetBackendHandler sets the operation handler for the get backend operation + BackendGetBackendHandler backend.GetBackendHandler + // BackendSwitchingRuleGetBackendSwitchingRuleHandler sets the operation handler for the get backend switching rule operation + BackendSwitchingRuleGetBackendSwitchingRuleHandler backend_switching_rule.GetBackendSwitchingRuleHandler + // BackendSwitchingRuleGetBackendSwitchingRulesHandler sets the operation handler for the get backend switching rules operation + BackendSwitchingRuleGetBackendSwitchingRulesHandler backend_switching_rule.GetBackendSwitchingRulesHandler + // BackendGetBackendsHandler sets the operation handler for the get backends operation + BackendGetBackendsHandler backend.GetBackendsHandler + // BindGetBindFrontendHandler sets the operation handler for the get bind frontend operation + BindGetBindFrontendHandler bind.GetBindFrontendHandler + // BindGetBindLogForwardHandler sets the operation handler for the get bind log forward operation + BindGetBindLogForwardHandler bind.GetBindLogForwardHandler + // BindGetBindPeerHandler sets the operation handler for the get bind peer operation + BindGetBindPeerHandler bind.GetBindPeerHandler + // SslRuntimeGetCaEntryHandler sets the operation handler for the get ca entry operation + SslRuntimeGetCaEntryHandler s_s_l_runtime.GetCaEntryHandler + // SslRuntimeGetCaFileHandler sets the operation handler for the get ca file operation + SslRuntimeGetCaFileHandler s_s_l_runtime.GetCaFileHandler + // CacheGetCacheHandler sets the operation handler for the get cache operation + CacheGetCacheHandler cache.GetCacheHandler + // CacheGetCachesHandler sets the operation handler for the get caches operation + CacheGetCachesHandler cache.GetCachesHandler + // SslRuntimeGetCertHandler sets the operation handler for the get cert operation + SslRuntimeGetCertHandler s_s_l_runtime.GetCertHandler + // ClusterGetClusterHandler sets the operation handler for the get cluster operation + ClusterGetClusterHandler cluster.GetClusterHandler + // DiscoveryGetConfigurationEndpointsHandler sets the operation handler for the get configuration endpoints operation + DiscoveryGetConfigurationEndpointsHandler discovery.GetConfigurationEndpointsHandler + // ConfigurationGetConfigurationVersionHandler sets the operation handler for the get configuration version operation + ConfigurationGetConfigurationVersionHandler configuration.GetConfigurationVersionHandler + // ServiceDiscoveryGetConsulHandler sets the operation handler for the get consul operation + ServiceDiscoveryGetConsulHandler service_discovery.GetConsulHandler + // ServiceDiscoveryGetConsulsHandler sets the operation handler for the get consuls operation + ServiceDiscoveryGetConsulsHandler service_discovery.GetConsulsHandler + // SslRuntimeGetCrlHandler sets the operation handler for the get crl operation + SslRuntimeGetCrlHandler s_s_l_runtime.GetCrlHandler + // CrtLoadGetCrtLoadHandler sets the operation handler for the get crt load operation + CrtLoadGetCrtLoadHandler crt_load.GetCrtLoadHandler + // CrtLoadGetCrtLoadsHandler sets the operation handler for the get crt loads operation + CrtLoadGetCrtLoadsHandler crt_load.GetCrtLoadsHandler + // CrtStoreGetCrtStoreHandler sets the operation handler for the get crt store operation + CrtStoreGetCrtStoreHandler crt_store.GetCrtStoreHandler + // CrtStoreGetCrtStoresHandler sets the operation handler for the get crt stores operation + CrtStoreGetCrtStoresHandler crt_store.GetCrtStoresHandler + // DeclareCaptureGetDeclareCaptureHandler sets the operation handler for the get declare capture operation + DeclareCaptureGetDeclareCaptureHandler declare_capture.GetDeclareCaptureHandler + // DeclareCaptureGetDeclareCapturesHandler sets the operation handler for the get declare captures operation + DeclareCaptureGetDeclareCapturesHandler declare_capture.GetDeclareCapturesHandler + // DefaultsGetDefaultsSectionHandler sets the operation handler for the get defaults section operation + DefaultsGetDefaultsSectionHandler defaults.GetDefaultsSectionHandler + // DefaultsGetDefaultsSectionsHandler sets the operation handler for the get defaults sections operation + DefaultsGetDefaultsSectionsHandler defaults.GetDefaultsSectionsHandler + // DgramBindGetDgramBindHandler sets the operation handler for the get dgram bind operation + DgramBindGetDgramBindHandler dgram_bind.GetDgramBindHandler + // DgramBindGetDgramBindsHandler sets the operation handler for the get dgram binds operation + DgramBindGetDgramBindsHandler dgram_bind.GetDgramBindsHandler + // FCGIAppGetFCGIAppHandler sets the operation handler for the get FCGI app operation + FCGIAppGetFCGIAppHandler fcgi_app.GetFCGIAppHandler + // FCGIAppGetFCGIAppsHandler sets the operation handler for the get FCGI apps operation + FCGIAppGetFCGIAppsHandler fcgi_app.GetFCGIAppsHandler + // FilterGetFilterBackendHandler sets the operation handler for the get filter backend operation + FilterGetFilterBackendHandler filter.GetFilterBackendHandler + // FilterGetFilterFrontendHandler sets the operation handler for the get filter frontend operation + FilterGetFilterFrontendHandler filter.GetFilterFrontendHandler + // FrontendGetFrontendHandler sets the operation handler for the get frontend operation + FrontendGetFrontendHandler frontend.GetFrontendHandler + // FrontendGetFrontendsHandler sets the operation handler for the get frontends operation + FrontendGetFrontendsHandler frontend.GetFrontendsHandler + // GlobalGetGlobalHandler sets the operation handler for the get global operation + GlobalGetGlobalHandler global.GetGlobalHandler + // GroupGetGroupHandler sets the operation handler for the get group operation + GroupGetGroupHandler group.GetGroupHandler + // GroupGetGroupsHandler sets the operation handler for the get groups operation + GroupGetGroupsHandler group.GetGroupsHandler + // ConfigurationGetHAProxyConfigurationHandler sets the operation handler for the get h a proxy configuration operation + ConfigurationGetHAProxyConfigurationHandler configuration.GetHAProxyConfigurationHandler + // HTTPAfterResponseRuleGetHTTPAfterResponseRuleBackendHandler sets the operation handler for the get HTTP after response rule backend operation + HTTPAfterResponseRuleGetHTTPAfterResponseRuleBackendHandler http_after_response_rule.GetHTTPAfterResponseRuleBackendHandler + // HTTPAfterResponseRuleGetHTTPAfterResponseRuleDefaultsHandler sets the operation handler for the get HTTP after response rule defaults operation + HTTPAfterResponseRuleGetHTTPAfterResponseRuleDefaultsHandler http_after_response_rule.GetHTTPAfterResponseRuleDefaultsHandler + // HTTPAfterResponseRuleGetHTTPAfterResponseRuleFrontendHandler sets the operation handler for the get HTTP after response rule frontend operation + HTTPAfterResponseRuleGetHTTPAfterResponseRuleFrontendHandler http_after_response_rule.GetHTTPAfterResponseRuleFrontendHandler + // HTTPCheckGetHTTPCheckBackendHandler sets the operation handler for the get HTTP check backend operation + HTTPCheckGetHTTPCheckBackendHandler http_check.GetHTTPCheckBackendHandler + // HTTPCheckGetHTTPCheckDefaultsHandler sets the operation handler for the get HTTP check defaults operation + HTTPCheckGetHTTPCheckDefaultsHandler http_check.GetHTTPCheckDefaultsHandler + // HTTPErrorRuleGetHTTPErrorRuleBackendHandler sets the operation handler for the get HTTP error rule backend operation + HTTPErrorRuleGetHTTPErrorRuleBackendHandler http_error_rule.GetHTTPErrorRuleBackendHandler + // HTTPErrorRuleGetHTTPErrorRuleDefaultsHandler sets the operation handler for the get HTTP error rule defaults operation + HTTPErrorRuleGetHTTPErrorRuleDefaultsHandler http_error_rule.GetHTTPErrorRuleDefaultsHandler + // HTTPErrorRuleGetHTTPErrorRuleFrontendHandler sets the operation handler for the get HTTP error rule frontend operation + HTTPErrorRuleGetHTTPErrorRuleFrontendHandler http_error_rule.GetHTTPErrorRuleFrontendHandler + // HTTPErrorsGetHTTPErrorsSectionHandler sets the operation handler for the get HTTP errors section operation + HTTPErrorsGetHTTPErrorsSectionHandler http_errors.GetHTTPErrorsSectionHandler + // HTTPErrorsGetHTTPErrorsSectionsHandler sets the operation handler for the get HTTP errors sections operation + HTTPErrorsGetHTTPErrorsSectionsHandler http_errors.GetHTTPErrorsSectionsHandler + // HTTPRequestRuleGetHTTPRequestRuleBackendHandler sets the operation handler for the get HTTP request rule backend operation + HTTPRequestRuleGetHTTPRequestRuleBackendHandler http_request_rule.GetHTTPRequestRuleBackendHandler + // HTTPRequestRuleGetHTTPRequestRuleDefaultsHandler sets the operation handler for the get HTTP request rule defaults operation + HTTPRequestRuleGetHTTPRequestRuleDefaultsHandler http_request_rule.GetHTTPRequestRuleDefaultsHandler + // HTTPRequestRuleGetHTTPRequestRuleFrontendHandler sets the operation handler for the get HTTP request rule frontend operation + HTTPRequestRuleGetHTTPRequestRuleFrontendHandler http_request_rule.GetHTTPRequestRuleFrontendHandler + // HTTPResponseRuleGetHTTPResponseRuleBackendHandler sets the operation handler for the get HTTP response rule backend operation + HTTPResponseRuleGetHTTPResponseRuleBackendHandler http_response_rule.GetHTTPResponseRuleBackendHandler + // HTTPResponseRuleGetHTTPResponseRuleDefaultsHandler sets the operation handler for the get HTTP response rule defaults operation + HTTPResponseRuleGetHTTPResponseRuleDefaultsHandler http_response_rule.GetHTTPResponseRuleDefaultsHandler + // HTTPResponseRuleGetHTTPResponseRuleFrontendHandler sets the operation handler for the get HTTP response rule frontend operation + HTTPResponseRuleGetHTTPResponseRuleFrontendHandler http_response_rule.GetHTTPResponseRuleFrontendHandler + // DiscoveryGetHaproxyEndpointsHandler sets the operation handler for the get haproxy endpoints operation + DiscoveryGetHaproxyEndpointsHandler discovery.GetHaproxyEndpointsHandler + // InformationGetHaproxyProcessInfoHandler sets the operation handler for the get haproxy process info operation + InformationGetHaproxyProcessInfoHandler information.GetHaproxyProcessInfoHandler + // HealthGetHealthHandler sets the operation handler for the get health operation + HealthGetHealthHandler health.GetHealthHandler + // InformationGetInfoHandler sets the operation handler for the get info operation + InformationGetInfoHandler information.GetInfoHandler + // LogForwardGetLogForwardHandler sets the operation handler for the get log forward operation + LogForwardGetLogForwardHandler log_forward.GetLogForwardHandler + // LogForwardGetLogForwardsHandler sets the operation handler for the get log forwards operation + LogForwardGetLogForwardsHandler log_forward.GetLogForwardsHandler + // LogProfileGetLogProfileHandler sets the operation handler for the get log profile operation + LogProfileGetLogProfileHandler log_profile.GetLogProfileHandler + // LogProfileGetLogProfilesHandler sets the operation handler for the get log profiles operation + LogProfileGetLogProfilesHandler log_profile.GetLogProfilesHandler + // LogTargetGetLogTargetBackendHandler sets the operation handler for the get log target backend operation + LogTargetGetLogTargetBackendHandler log_target.GetLogTargetBackendHandler + // LogTargetGetLogTargetDefaultsHandler sets the operation handler for the get log target defaults operation + LogTargetGetLogTargetDefaultsHandler log_target.GetLogTargetDefaultsHandler + // LogTargetGetLogTargetFrontendHandler sets the operation handler for the get log target frontend operation + LogTargetGetLogTargetFrontendHandler log_target.GetLogTargetFrontendHandler + // LogTargetGetLogTargetGlobalHandler sets the operation handler for the get log target global operation + LogTargetGetLogTargetGlobalHandler log_target.GetLogTargetGlobalHandler + // LogTargetGetLogTargetLogForwardHandler sets the operation handler for the get log target log forward operation + LogTargetGetLogTargetLogForwardHandler log_target.GetLogTargetLogForwardHandler + // LogTargetGetLogTargetPeerHandler sets the operation handler for the get log target peer operation + LogTargetGetLogTargetPeerHandler log_target.GetLogTargetPeerHandler + // MailerEntryGetMailerEntriesHandler sets the operation handler for the get mailer entries operation + MailerEntryGetMailerEntriesHandler mailer_entry.GetMailerEntriesHandler + // MailerEntryGetMailerEntryHandler sets the operation handler for the get mailer entry operation + MailerEntryGetMailerEntryHandler mailer_entry.GetMailerEntryHandler + // MailersGetMailersSectionHandler sets the operation handler for the get mailers section operation + MailersGetMailersSectionHandler mailers.GetMailersSectionHandler + // MailersGetMailersSectionsHandler sets the operation handler for the get mailers sections operation + MailersGetMailersSectionsHandler mailers.GetMailersSectionsHandler + // NameserverGetNameserverHandler sets the operation handler for the get nameserver operation + NameserverGetNameserverHandler nameserver.GetNameserverHandler + // NameserverGetNameserversHandler sets the operation handler for the get nameservers operation + NameserverGetNameserversHandler nameserver.GetNameserversHandler + // MapsGetOneRuntimeMapHandler sets the operation handler for the get one runtime map operation + MapsGetOneRuntimeMapHandler maps.GetOneRuntimeMapHandler + // SpoeGetOneSpoeFileHandler sets the operation handler for the get one spoe file operation + SpoeGetOneSpoeFileHandler spoe.GetOneSpoeFileHandler + // StorageGetOneStorageGeneralFileHandler sets the operation handler for the get one storage general file operation + StorageGetOneStorageGeneralFileHandler storage.GetOneStorageGeneralFileHandler + // StorageGetOneStorageMapHandler sets the operation handler for the get one storage map operation + StorageGetOneStorageMapHandler storage.GetOneStorageMapHandler + // StorageGetOneStorageSSLCertificateHandler sets the operation handler for the get one storage s s l certificate operation + StorageGetOneStorageSSLCertificateHandler storage.GetOneStorageSSLCertificateHandler + // StorageGetOneStorageSSLCrtListFileHandler sets the operation handler for the get one storage s s l crt list file operation + StorageGetOneStorageSSLCrtListFileHandler storage.GetOneStorageSSLCrtListFileHandler + // SpecificationOpenapiv3GetOpenapiv3SpecificationHandler sets the operation handler for the get openapiv3 specification operation + SpecificationOpenapiv3GetOpenapiv3SpecificationHandler specification_openapiv3.GetOpenapiv3SpecificationHandler + // PeerEntryGetPeerEntriesHandler sets the operation handler for the get peer entries operation + PeerEntryGetPeerEntriesHandler peer_entry.GetPeerEntriesHandler + // PeerEntryGetPeerEntryHandler sets the operation handler for the get peer entry operation + PeerEntryGetPeerEntryHandler peer_entry.GetPeerEntryHandler + // PeerGetPeerSectionHandler sets the operation handler for the get peer section operation + PeerGetPeerSectionHandler peer.GetPeerSectionHandler + // PeerGetPeerSectionsHandler sets the operation handler for the get peer sections operation + PeerGetPeerSectionsHandler peer.GetPeerSectionsHandler + // ProcessManagerGetProgramHandler sets the operation handler for the get program operation + ProcessManagerGetProgramHandler process_manager.GetProgramHandler + // ProcessManagerGetProgramsHandler sets the operation handler for the get programs operation + ProcessManagerGetProgramsHandler process_manager.GetProgramsHandler + // QUICInitialRuleGetQUICInitialRuleDefaultsHandler sets the operation handler for the get QUIC initial rule defaults operation + QUICInitialRuleGetQUICInitialRuleDefaultsHandler quic_initial_rule.GetQUICInitialRuleDefaultsHandler + // QUICInitialRuleGetQUICInitialRuleFrontendHandler sets the operation handler for the get QUIC initial rule frontend operation + QUICInitialRuleGetQUICInitialRuleFrontendHandler quic_initial_rule.GetQUICInitialRuleFrontendHandler + // ReloadsGetReloadHandler sets the operation handler for the get reload operation + ReloadsGetReloadHandler reloads.GetReloadHandler + // ReloadsGetReloadsHandler sets the operation handler for the get reloads operation + ReloadsGetReloadsHandler reloads.GetReloadsHandler + // ResolverGetResolverHandler sets the operation handler for the get resolver operation + ResolverGetResolverHandler resolver.GetResolverHandler + // ResolverGetResolversHandler sets the operation handler for the get resolvers operation + ResolverGetResolversHandler resolver.GetResolversHandler + // RingGetRingHandler sets the operation handler for the get ring operation + RingGetRingHandler ring.GetRingHandler + // RingGetRingsHandler sets the operation handler for the get rings operation + RingGetRingsHandler ring.GetRingsHandler + // DiscoveryGetRuntimeEndpointsHandler sets the operation handler for the get runtime endpoints operation + DiscoveryGetRuntimeEndpointsHandler discovery.GetRuntimeEndpointsHandler + // MapsGetRuntimeMapEntryHandler sets the operation handler for the get runtime map entry operation + MapsGetRuntimeMapEntryHandler maps.GetRuntimeMapEntryHandler + // ServerGetRuntimeServerHandler sets the operation handler for the get runtime server operation + ServerGetRuntimeServerHandler serverops.GetRuntimeServerHandler + // SslFrontUseGetSSLFrontUseHandler sets the operation handler for the get s s l front use operation + SslFrontUseGetSSLFrontUseHandler s_s_l_front_use.GetSSLFrontUseHandler + // ServerGetServerBackendHandler sets the operation handler for the get server backend operation + ServerGetServerBackendHandler serverops.GetServerBackendHandler + // ServerGetServerPeerHandler sets the operation handler for the get server peer operation + ServerGetServerPeerHandler serverops.GetServerPeerHandler + // ServerGetServerRingHandler sets the operation handler for the get server ring operation + ServerGetServerRingHandler serverops.GetServerRingHandler + // ServerSwitchingRuleGetServerSwitchingRuleHandler sets the operation handler for the get server switching rule operation + ServerSwitchingRuleGetServerSwitchingRuleHandler server_switching_rule.GetServerSwitchingRuleHandler + // ServerSwitchingRuleGetServerSwitchingRulesHandler sets the operation handler for the get server switching rules operation + ServerSwitchingRuleGetServerSwitchingRulesHandler server_switching_rule.GetServerSwitchingRulesHandler + // ServerTemplateGetServerTemplateHandler sets the operation handler for the get server template operation + ServerTemplateGetServerTemplateHandler server_template.GetServerTemplateHandler + // ServerTemplateGetServerTemplatesHandler sets the operation handler for the get server templates operation + ServerTemplateGetServerTemplatesHandler server_template.GetServerTemplatesHandler + // DiscoveryGetServicesEndpointsHandler sets the operation handler for the get services endpoints operation + DiscoveryGetServicesEndpointsHandler discovery.GetServicesEndpointsHandler + // SitesGetSiteHandler sets the operation handler for the get site operation + SitesGetSiteHandler sites.GetSiteHandler + // SitesGetSitesHandler sets the operation handler for the get sites operation + SitesGetSitesHandler sites.GetSitesHandler + // SpecificationGetSpecificationHandler sets the operation handler for the get specification operation + SpecificationGetSpecificationHandler specification.GetSpecificationHandler + // SpoeGetSpoeAgentHandler sets the operation handler for the get spoe agent operation + SpoeGetSpoeAgentHandler spoe.GetSpoeAgentHandler + // SpoeGetSpoeConfigurationVersionHandler sets the operation handler for the get spoe configuration version operation + SpoeGetSpoeConfigurationVersionHandler spoe.GetSpoeConfigurationVersionHandler + // DiscoveryGetSpoeEndpointsHandler sets the operation handler for the get spoe endpoints operation + DiscoveryGetSpoeEndpointsHandler discovery.GetSpoeEndpointsHandler + // SpoeGetSpoeGroupHandler sets the operation handler for the get spoe group operation + SpoeGetSpoeGroupHandler spoe.GetSpoeGroupHandler + // SpoeGetSpoeMessageHandler sets the operation handler for the get spoe message operation + SpoeGetSpoeMessageHandler spoe.GetSpoeMessageHandler + // SpoeGetSpoeScopeHandler sets the operation handler for the get spoe scope operation + SpoeGetSpoeScopeHandler spoe.GetSpoeScopeHandler + // SpoeTransactionsGetSpoeTransactionHandler sets the operation handler for the get spoe transaction operation + SpoeTransactionsGetSpoeTransactionHandler spoe_transactions.GetSpoeTransactionHandler + // StatsGetStatsHandler sets the operation handler for the get stats operation + StatsGetStatsHandler stats.GetStatsHandler + // DiscoveryGetStatsEndpointsHandler sets the operation handler for the get stats endpoints operation + DiscoveryGetStatsEndpointsHandler discovery.GetStatsEndpointsHandler + // StickRuleGetStickRuleHandler sets the operation handler for the get stick rule operation + StickRuleGetStickRuleHandler stick_rule.GetStickRuleHandler + // StickRuleGetStickRulesHandler sets the operation handler for the get stick rules operation + StickRuleGetStickRulesHandler stick_rule.GetStickRulesHandler + // StickTableGetStickTableHandler sets the operation handler for the get stick table operation + StickTableGetStickTableHandler stick_table.GetStickTableHandler + // StickTableGetStickTableEntriesHandler sets the operation handler for the get stick table entries operation + StickTableGetStickTableEntriesHandler stick_table.GetStickTableEntriesHandler + // StickTableGetStickTablesHandler sets the operation handler for the get stick tables operation + StickTableGetStickTablesHandler stick_table.GetStickTablesHandler + // DiscoveryGetStorageEndpointsHandler sets the operation handler for the get storage endpoints operation + DiscoveryGetStorageEndpointsHandler discovery.GetStorageEndpointsHandler + // TCPCheckGetTCPCheckBackendHandler sets the operation handler for the get TCP check backend operation + TCPCheckGetTCPCheckBackendHandler tcp_check.GetTCPCheckBackendHandler + // TCPCheckGetTCPCheckDefaultsHandler sets the operation handler for the get TCP check defaults operation + TCPCheckGetTCPCheckDefaultsHandler tcp_check.GetTCPCheckDefaultsHandler + // TCPRequestRuleGetTCPRequestRuleBackendHandler sets the operation handler for the get TCP request rule backend operation + TCPRequestRuleGetTCPRequestRuleBackendHandler tcp_request_rule.GetTCPRequestRuleBackendHandler + // TCPRequestRuleGetTCPRequestRuleDefaultsHandler sets the operation handler for the get TCP request rule defaults operation + TCPRequestRuleGetTCPRequestRuleDefaultsHandler tcp_request_rule.GetTCPRequestRuleDefaultsHandler + // TCPRequestRuleGetTCPRequestRuleFrontendHandler sets the operation handler for the get TCP request rule frontend operation + TCPRequestRuleGetTCPRequestRuleFrontendHandler tcp_request_rule.GetTCPRequestRuleFrontendHandler + // TCPResponseRuleGetTCPResponseRuleBackendHandler sets the operation handler for the get TCP response rule backend operation + TCPResponseRuleGetTCPResponseRuleBackendHandler tcp_response_rule.GetTCPResponseRuleBackendHandler + // TCPResponseRuleGetTCPResponseRuleDefaultsHandler sets the operation handler for the get TCP response rule defaults operation + TCPResponseRuleGetTCPResponseRuleDefaultsHandler tcp_response_rule.GetTCPResponseRuleDefaultsHandler + // TableGetTableHandler sets the operation handler for the get table operation + TableGetTableHandler table.GetTableHandler + // TableGetTablesHandler sets the operation handler for the get tables operation + TableGetTablesHandler table.GetTablesHandler + // TracesGetTracesHandler sets the operation handler for the get traces operation + TracesGetTracesHandler traces.GetTracesHandler + // TransactionsGetTransactionHandler sets the operation handler for the get transaction operation + TransactionsGetTransactionHandler transactions.GetTransactionHandler + // TransactionsGetTransactionsHandler sets the operation handler for the get transactions operation + TransactionsGetTransactionsHandler transactions.GetTransactionsHandler + // UserGetUserHandler sets the operation handler for the get user operation + UserGetUserHandler user.GetUserHandler + // UserlistGetUserlistHandler sets the operation handler for the get userlist operation + UserlistGetUserlistHandler userlist.GetUserlistHandler + // UserlistGetUserlistsHandler sets the operation handler for the get userlists operation + UserlistGetUserlistsHandler userlist.GetUserlistsHandler + // UserGetUsersHandler sets the operation handler for the get users operation + UserGetUsersHandler user.GetUsersHandler + // ClusterInitiateCertificateRefreshHandler sets the operation handler for the initiate certificate refresh operation + ClusterInitiateCertificateRefreshHandler cluster.InitiateCertificateRefreshHandler + // ClusterPostClusterHandler sets the operation handler for the post cluster operation + ClusterPostClusterHandler cluster.PostClusterHandler + // ConfigurationPostHAProxyConfigurationHandler sets the operation handler for the post h a proxy configuration operation + ConfigurationPostHAProxyConfigurationHandler configuration.PostHAProxyConfigurationHandler + // AcmeRuntimeRenewAcmeCertificateHandler sets the operation handler for the renew acme certificate operation + AcmeRuntimeRenewAcmeCertificateHandler acme_runtime.RenewAcmeCertificateHandler + // ServiceDiscoveryReplaceAWSRegionHandler sets the operation handler for the replace a w s region operation + ServiceDiscoveryReplaceAWSRegionHandler service_discovery.ReplaceAWSRegionHandler + // ACLReplaceACLBackendHandler sets the operation handler for the replace Acl backend operation + ACLReplaceACLBackendHandler acl.ReplaceACLBackendHandler + // ACLReplaceACLDefaultsHandler sets the operation handler for the replace Acl defaults operation + ACLReplaceACLDefaultsHandler acl.ReplaceACLDefaultsHandler + // ACLReplaceACLFCGIAppHandler sets the operation handler for the replace Acl FCGI app operation + ACLReplaceACLFCGIAppHandler acl.ReplaceACLFCGIAppHandler + // ACLReplaceACLFrontendHandler sets the operation handler for the replace Acl frontend operation + ACLReplaceACLFrontendHandler acl.ReplaceACLFrontendHandler + // ACLReplaceAllACLBackendHandler sets the operation handler for the replace all Acl backend operation + ACLReplaceAllACLBackendHandler acl.ReplaceAllACLBackendHandler + // ACLReplaceAllACLDefaultsHandler sets the operation handler for the replace all Acl defaults operation + ACLReplaceAllACLDefaultsHandler acl.ReplaceAllACLDefaultsHandler + // ACLReplaceAllACLFCGIAppHandler sets the operation handler for the replace all Acl FCGI app operation + ACLReplaceAllACLFCGIAppHandler acl.ReplaceAllACLFCGIAppHandler + // ACLReplaceAllACLFrontendHandler sets the operation handler for the replace all Acl frontend operation + ACLReplaceAllACLFrontendHandler acl.ReplaceAllACLFrontendHandler + // FilterReplaceAllFilterBackendHandler sets the operation handler for the replace all filter backend operation + FilterReplaceAllFilterBackendHandler filter.ReplaceAllFilterBackendHandler + // FilterReplaceAllFilterFrontendHandler sets the operation handler for the replace all filter frontend operation + FilterReplaceAllFilterFrontendHandler filter.ReplaceAllFilterFrontendHandler + // HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleBackendHandler sets the operation handler for the replace all HTTP after response rule backend operation + HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleBackendHandler http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendHandler + // HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleDefaultsHandler sets the operation handler for the replace all HTTP after response rule defaults operation + HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleDefaultsHandler http_after_response_rule.ReplaceAllHTTPAfterResponseRuleDefaultsHandler + // HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleFrontendHandler sets the operation handler for the replace all HTTP after response rule frontend operation + HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleFrontendHandler http_after_response_rule.ReplaceAllHTTPAfterResponseRuleFrontendHandler + // HTTPCheckReplaceAllHTTPCheckBackendHandler sets the operation handler for the replace all HTTP check backend operation + HTTPCheckReplaceAllHTTPCheckBackendHandler http_check.ReplaceAllHTTPCheckBackendHandler + // HTTPCheckReplaceAllHTTPCheckDefaultsHandler sets the operation handler for the replace all HTTP check defaults operation + HTTPCheckReplaceAllHTTPCheckDefaultsHandler http_check.ReplaceAllHTTPCheckDefaultsHandler + // HTTPErrorRuleReplaceAllHTTPErrorRuleBackendHandler sets the operation handler for the replace all HTTP error rule backend operation + HTTPErrorRuleReplaceAllHTTPErrorRuleBackendHandler http_error_rule.ReplaceAllHTTPErrorRuleBackendHandler + // HTTPErrorRuleReplaceAllHTTPErrorRuleDefaultsHandler sets the operation handler for the replace all HTTP error rule defaults operation + HTTPErrorRuleReplaceAllHTTPErrorRuleDefaultsHandler http_error_rule.ReplaceAllHTTPErrorRuleDefaultsHandler + // HTTPErrorRuleReplaceAllHTTPErrorRuleFrontendHandler sets the operation handler for the replace all HTTP error rule frontend operation + HTTPErrorRuleReplaceAllHTTPErrorRuleFrontendHandler http_error_rule.ReplaceAllHTTPErrorRuleFrontendHandler + // HTTPRequestRuleReplaceAllHTTPRequestRuleBackendHandler sets the operation handler for the replace all HTTP request rule backend operation + HTTPRequestRuleReplaceAllHTTPRequestRuleBackendHandler http_request_rule.ReplaceAllHTTPRequestRuleBackendHandler + // HTTPRequestRuleReplaceAllHTTPRequestRuleDefaultsHandler sets the operation handler for the replace all HTTP request rule defaults operation + HTTPRequestRuleReplaceAllHTTPRequestRuleDefaultsHandler http_request_rule.ReplaceAllHTTPRequestRuleDefaultsHandler + // HTTPRequestRuleReplaceAllHTTPRequestRuleFrontendHandler sets the operation handler for the replace all HTTP request rule frontend operation + HTTPRequestRuleReplaceAllHTTPRequestRuleFrontendHandler http_request_rule.ReplaceAllHTTPRequestRuleFrontendHandler + // HTTPResponseRuleReplaceAllHTTPResponseRuleBackendHandler sets the operation handler for the replace all HTTP response rule backend operation + HTTPResponseRuleReplaceAllHTTPResponseRuleBackendHandler http_response_rule.ReplaceAllHTTPResponseRuleBackendHandler + // HTTPResponseRuleReplaceAllHTTPResponseRuleDefaultsHandler sets the operation handler for the replace all HTTP response rule defaults operation + HTTPResponseRuleReplaceAllHTTPResponseRuleDefaultsHandler http_response_rule.ReplaceAllHTTPResponseRuleDefaultsHandler + // HTTPResponseRuleReplaceAllHTTPResponseRuleFrontendHandler sets the operation handler for the replace all HTTP response rule frontend operation + HTTPResponseRuleReplaceAllHTTPResponseRuleFrontendHandler http_response_rule.ReplaceAllHTTPResponseRuleFrontendHandler + // LogTargetReplaceAllLogTargetBackendHandler sets the operation handler for the replace all log target backend operation + LogTargetReplaceAllLogTargetBackendHandler log_target.ReplaceAllLogTargetBackendHandler + // LogTargetReplaceAllLogTargetDefaultsHandler sets the operation handler for the replace all log target defaults operation + LogTargetReplaceAllLogTargetDefaultsHandler log_target.ReplaceAllLogTargetDefaultsHandler + // LogTargetReplaceAllLogTargetFrontendHandler sets the operation handler for the replace all log target frontend operation + LogTargetReplaceAllLogTargetFrontendHandler log_target.ReplaceAllLogTargetFrontendHandler + // LogTargetReplaceAllLogTargetGlobalHandler sets the operation handler for the replace all log target global operation + LogTargetReplaceAllLogTargetGlobalHandler log_target.ReplaceAllLogTargetGlobalHandler + // LogTargetReplaceAllLogTargetLogForwardHandler sets the operation handler for the replace all log target log forward operation + LogTargetReplaceAllLogTargetLogForwardHandler log_target.ReplaceAllLogTargetLogForwardHandler + // LogTargetReplaceAllLogTargetPeerHandler sets the operation handler for the replace all log target peer operation + LogTargetReplaceAllLogTargetPeerHandler log_target.ReplaceAllLogTargetPeerHandler + // QUICInitialRuleReplaceAllQUICInitialRuleDefaultsHandler sets the operation handler for the replace all QUIC initial rule defaults operation + QUICInitialRuleReplaceAllQUICInitialRuleDefaultsHandler quic_initial_rule.ReplaceAllQUICInitialRuleDefaultsHandler + // QUICInitialRuleReplaceAllQUICInitialRuleFrontendHandler sets the operation handler for the replace all QUIC initial rule frontend operation + QUICInitialRuleReplaceAllQUICInitialRuleFrontendHandler quic_initial_rule.ReplaceAllQUICInitialRuleFrontendHandler + // TCPCheckReplaceAllTCPCheckBackendHandler sets the operation handler for the replace all TCP check backend operation + TCPCheckReplaceAllTCPCheckBackendHandler tcp_check.ReplaceAllTCPCheckBackendHandler + // TCPCheckReplaceAllTCPCheckDefaultsHandler sets the operation handler for the replace all TCP check defaults operation + TCPCheckReplaceAllTCPCheckDefaultsHandler tcp_check.ReplaceAllTCPCheckDefaultsHandler + // TCPRequestRuleReplaceAllTCPRequestRuleBackendHandler sets the operation handler for the replace all TCP request rule backend operation + TCPRequestRuleReplaceAllTCPRequestRuleBackendHandler tcp_request_rule.ReplaceAllTCPRequestRuleBackendHandler + // TCPRequestRuleReplaceAllTCPRequestRuleDefaultsHandler sets the operation handler for the replace all TCP request rule defaults operation + TCPRequestRuleReplaceAllTCPRequestRuleDefaultsHandler tcp_request_rule.ReplaceAllTCPRequestRuleDefaultsHandler + // TCPRequestRuleReplaceAllTCPRequestRuleFrontendHandler sets the operation handler for the replace all TCP request rule frontend operation + TCPRequestRuleReplaceAllTCPRequestRuleFrontendHandler tcp_request_rule.ReplaceAllTCPRequestRuleFrontendHandler + // TCPResponseRuleReplaceAllTCPResponseRuleBackendHandler sets the operation handler for the replace all TCP response rule backend operation + TCPResponseRuleReplaceAllTCPResponseRuleBackendHandler tcp_response_rule.ReplaceAllTCPResponseRuleBackendHandler + // TCPResponseRuleReplaceAllTCPResponseRuleDefaultsHandler sets the operation handler for the replace all TCP response rule defaults operation + TCPResponseRuleReplaceAllTCPResponseRuleDefaultsHandler tcp_response_rule.ReplaceAllTCPResponseRuleDefaultsHandler + // BackendReplaceBackendHandler sets the operation handler for the replace backend operation + BackendReplaceBackendHandler backend.ReplaceBackendHandler + // BackendSwitchingRuleReplaceBackendSwitchingRuleHandler sets the operation handler for the replace backend switching rule operation + BackendSwitchingRuleReplaceBackendSwitchingRuleHandler backend_switching_rule.ReplaceBackendSwitchingRuleHandler + // BackendSwitchingRuleReplaceBackendSwitchingRulesHandler sets the operation handler for the replace backend switching rules operation + BackendSwitchingRuleReplaceBackendSwitchingRulesHandler backend_switching_rule.ReplaceBackendSwitchingRulesHandler + // BindReplaceBindFrontendHandler sets the operation handler for the replace bind frontend operation + BindReplaceBindFrontendHandler bind.ReplaceBindFrontendHandler + // BindReplaceBindLogForwardHandler sets the operation handler for the replace bind log forward operation + BindReplaceBindLogForwardHandler bind.ReplaceBindLogForwardHandler + // BindReplaceBindPeerHandler sets the operation handler for the replace bind peer operation + BindReplaceBindPeerHandler bind.ReplaceBindPeerHandler + // CacheReplaceCacheHandler sets the operation handler for the replace cache operation + CacheReplaceCacheHandler cache.ReplaceCacheHandler + // SslRuntimeReplaceCertHandler sets the operation handler for the replace cert operation + SslRuntimeReplaceCertHandler s_s_l_runtime.ReplaceCertHandler + // ServiceDiscoveryReplaceConsulHandler sets the operation handler for the replace consul operation + ServiceDiscoveryReplaceConsulHandler service_discovery.ReplaceConsulHandler + // SslRuntimeReplaceCrlHandler sets the operation handler for the replace crl operation + SslRuntimeReplaceCrlHandler s_s_l_runtime.ReplaceCrlHandler + // CrtLoadReplaceCrtLoadHandler sets the operation handler for the replace crt load operation + CrtLoadReplaceCrtLoadHandler crt_load.ReplaceCrtLoadHandler + // DeclareCaptureReplaceDeclareCaptureHandler sets the operation handler for the replace declare capture operation + DeclareCaptureReplaceDeclareCaptureHandler declare_capture.ReplaceDeclareCaptureHandler + // DeclareCaptureReplaceDeclareCapturesHandler sets the operation handler for the replace declare captures operation + DeclareCaptureReplaceDeclareCapturesHandler declare_capture.ReplaceDeclareCapturesHandler + // DefaultsReplaceDefaultsSectionHandler sets the operation handler for the replace defaults section operation + DefaultsReplaceDefaultsSectionHandler defaults.ReplaceDefaultsSectionHandler + // DgramBindReplaceDgramBindHandler sets the operation handler for the replace dgram bind operation + DgramBindReplaceDgramBindHandler dgram_bind.ReplaceDgramBindHandler + // FCGIAppReplaceFCGIAppHandler sets the operation handler for the replace FCGI app operation + FCGIAppReplaceFCGIAppHandler fcgi_app.ReplaceFCGIAppHandler + // FilterReplaceFilterBackendHandler sets the operation handler for the replace filter backend operation + FilterReplaceFilterBackendHandler filter.ReplaceFilterBackendHandler + // FilterReplaceFilterFrontendHandler sets the operation handler for the replace filter frontend operation + FilterReplaceFilterFrontendHandler filter.ReplaceFilterFrontendHandler + // FrontendReplaceFrontendHandler sets the operation handler for the replace frontend operation + FrontendReplaceFrontendHandler frontend.ReplaceFrontendHandler + // GlobalReplaceGlobalHandler sets the operation handler for the replace global operation + GlobalReplaceGlobalHandler global.ReplaceGlobalHandler + // GroupReplaceGroupHandler sets the operation handler for the replace group operation + GroupReplaceGroupHandler group.ReplaceGroupHandler + // HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleBackendHandler sets the operation handler for the replace HTTP after response rule backend operation + HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleBackendHandler http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendHandler + // HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleDefaultsHandler sets the operation handler for the replace HTTP after response rule defaults operation + HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleDefaultsHandler http_after_response_rule.ReplaceHTTPAfterResponseRuleDefaultsHandler + // HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleFrontendHandler sets the operation handler for the replace HTTP after response rule frontend operation + HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleFrontendHandler http_after_response_rule.ReplaceHTTPAfterResponseRuleFrontendHandler + // HTTPCheckReplaceHTTPCheckBackendHandler sets the operation handler for the replace HTTP check backend operation + HTTPCheckReplaceHTTPCheckBackendHandler http_check.ReplaceHTTPCheckBackendHandler + // HTTPCheckReplaceHTTPCheckDefaultsHandler sets the operation handler for the replace HTTP check defaults operation + HTTPCheckReplaceHTTPCheckDefaultsHandler http_check.ReplaceHTTPCheckDefaultsHandler + // HTTPErrorRuleReplaceHTTPErrorRuleBackendHandler sets the operation handler for the replace HTTP error rule backend operation + HTTPErrorRuleReplaceHTTPErrorRuleBackendHandler http_error_rule.ReplaceHTTPErrorRuleBackendHandler + // HTTPErrorRuleReplaceHTTPErrorRuleDefaultsHandler sets the operation handler for the replace HTTP error rule defaults operation + HTTPErrorRuleReplaceHTTPErrorRuleDefaultsHandler http_error_rule.ReplaceHTTPErrorRuleDefaultsHandler + // HTTPErrorRuleReplaceHTTPErrorRuleFrontendHandler sets the operation handler for the replace HTTP error rule frontend operation + HTTPErrorRuleReplaceHTTPErrorRuleFrontendHandler http_error_rule.ReplaceHTTPErrorRuleFrontendHandler + // HTTPErrorsReplaceHTTPErrorsSectionHandler sets the operation handler for the replace HTTP errors section operation + HTTPErrorsReplaceHTTPErrorsSectionHandler http_errors.ReplaceHTTPErrorsSectionHandler + // HTTPRequestRuleReplaceHTTPRequestRuleBackendHandler sets the operation handler for the replace HTTP request rule backend operation + HTTPRequestRuleReplaceHTTPRequestRuleBackendHandler http_request_rule.ReplaceHTTPRequestRuleBackendHandler + // HTTPRequestRuleReplaceHTTPRequestRuleDefaultsHandler sets the operation handler for the replace HTTP request rule defaults operation + HTTPRequestRuleReplaceHTTPRequestRuleDefaultsHandler http_request_rule.ReplaceHTTPRequestRuleDefaultsHandler + // HTTPRequestRuleReplaceHTTPRequestRuleFrontendHandler sets the operation handler for the replace HTTP request rule frontend operation + HTTPRequestRuleReplaceHTTPRequestRuleFrontendHandler http_request_rule.ReplaceHTTPRequestRuleFrontendHandler + // HTTPResponseRuleReplaceHTTPResponseRuleBackendHandler sets the operation handler for the replace HTTP response rule backend operation + HTTPResponseRuleReplaceHTTPResponseRuleBackendHandler http_response_rule.ReplaceHTTPResponseRuleBackendHandler + // HTTPResponseRuleReplaceHTTPResponseRuleDefaultsHandler sets the operation handler for the replace HTTP response rule defaults operation + HTTPResponseRuleReplaceHTTPResponseRuleDefaultsHandler http_response_rule.ReplaceHTTPResponseRuleDefaultsHandler + // HTTPResponseRuleReplaceHTTPResponseRuleFrontendHandler sets the operation handler for the replace HTTP response rule frontend operation + HTTPResponseRuleReplaceHTTPResponseRuleFrontendHandler http_response_rule.ReplaceHTTPResponseRuleFrontendHandler + // LogForwardReplaceLogForwardHandler sets the operation handler for the replace log forward operation + LogForwardReplaceLogForwardHandler log_forward.ReplaceLogForwardHandler + // LogTargetReplaceLogTargetBackendHandler sets the operation handler for the replace log target backend operation + LogTargetReplaceLogTargetBackendHandler log_target.ReplaceLogTargetBackendHandler + // LogTargetReplaceLogTargetDefaultsHandler sets the operation handler for the replace log target defaults operation + LogTargetReplaceLogTargetDefaultsHandler log_target.ReplaceLogTargetDefaultsHandler + // LogTargetReplaceLogTargetFrontendHandler sets the operation handler for the replace log target frontend operation + LogTargetReplaceLogTargetFrontendHandler log_target.ReplaceLogTargetFrontendHandler + // LogTargetReplaceLogTargetGlobalHandler sets the operation handler for the replace log target global operation + LogTargetReplaceLogTargetGlobalHandler log_target.ReplaceLogTargetGlobalHandler + // LogTargetReplaceLogTargetLogForwardHandler sets the operation handler for the replace log target log forward operation + LogTargetReplaceLogTargetLogForwardHandler log_target.ReplaceLogTargetLogForwardHandler + // LogTargetReplaceLogTargetPeerHandler sets the operation handler for the replace log target peer operation + LogTargetReplaceLogTargetPeerHandler log_target.ReplaceLogTargetPeerHandler + // MailerEntryReplaceMailerEntryHandler sets the operation handler for the replace mailer entry operation + MailerEntryReplaceMailerEntryHandler mailer_entry.ReplaceMailerEntryHandler + // NameserverReplaceNameserverHandler sets the operation handler for the replace nameserver operation + NameserverReplaceNameserverHandler nameserver.ReplaceNameserverHandler + // PeerEntryReplacePeerEntryHandler sets the operation handler for the replace peer entry operation + PeerEntryReplacePeerEntryHandler peer_entry.ReplacePeerEntryHandler + // ProcessManagerReplaceProgramHandler sets the operation handler for the replace program operation + ProcessManagerReplaceProgramHandler process_manager.ReplaceProgramHandler + // QUICInitialRuleReplaceQUICInitialRuleDefaultsHandler sets the operation handler for the replace QUIC initial rule defaults operation + QUICInitialRuleReplaceQUICInitialRuleDefaultsHandler quic_initial_rule.ReplaceQUICInitialRuleDefaultsHandler + // QUICInitialRuleReplaceQUICInitialRuleFrontendHandler sets the operation handler for the replace QUIC initial rule frontend operation + QUICInitialRuleReplaceQUICInitialRuleFrontendHandler quic_initial_rule.ReplaceQUICInitialRuleFrontendHandler + // ResolverReplaceResolverHandler sets the operation handler for the replace resolver operation + ResolverReplaceResolverHandler resolver.ReplaceResolverHandler + // RingReplaceRingHandler sets the operation handler for the replace ring operation + RingReplaceRingHandler ring.ReplaceRingHandler + // MapsReplaceRuntimeMapEntryHandler sets the operation handler for the replace runtime map entry operation + MapsReplaceRuntimeMapEntryHandler maps.ReplaceRuntimeMapEntryHandler + // ServerReplaceRuntimeServerHandler sets the operation handler for the replace runtime server operation + ServerReplaceRuntimeServerHandler serverops.ReplaceRuntimeServerHandler + // SslFrontUseReplaceSSLFrontUseHandler sets the operation handler for the replace s s l front use operation + SslFrontUseReplaceSSLFrontUseHandler s_s_l_front_use.ReplaceSSLFrontUseHandler + // ServerReplaceServerBackendHandler sets the operation handler for the replace server backend operation + ServerReplaceServerBackendHandler serverops.ReplaceServerBackendHandler + // ServerReplaceServerPeerHandler sets the operation handler for the replace server peer operation + ServerReplaceServerPeerHandler serverops.ReplaceServerPeerHandler + // ServerReplaceServerRingHandler sets the operation handler for the replace server ring operation + ServerReplaceServerRingHandler serverops.ReplaceServerRingHandler + // ServerSwitchingRuleReplaceServerSwitchingRuleHandler sets the operation handler for the replace server switching rule operation + ServerSwitchingRuleReplaceServerSwitchingRuleHandler server_switching_rule.ReplaceServerSwitchingRuleHandler + // ServerSwitchingRuleReplaceServerSwitchingRulesHandler sets the operation handler for the replace server switching rules operation + ServerSwitchingRuleReplaceServerSwitchingRulesHandler server_switching_rule.ReplaceServerSwitchingRulesHandler + // ServerTemplateReplaceServerTemplateHandler sets the operation handler for the replace server template operation + ServerTemplateReplaceServerTemplateHandler server_template.ReplaceServerTemplateHandler + // SitesReplaceSiteHandler sets the operation handler for the replace site operation + SitesReplaceSiteHandler sites.ReplaceSiteHandler + // SpoeReplaceSpoeAgentHandler sets the operation handler for the replace spoe agent operation + SpoeReplaceSpoeAgentHandler spoe.ReplaceSpoeAgentHandler + // SpoeReplaceSpoeGroupHandler sets the operation handler for the replace spoe group operation + SpoeReplaceSpoeGroupHandler spoe.ReplaceSpoeGroupHandler + // SpoeReplaceSpoeMessageHandler sets the operation handler for the replace spoe message operation + SpoeReplaceSpoeMessageHandler spoe.ReplaceSpoeMessageHandler + // StickRuleReplaceStickRuleHandler sets the operation handler for the replace stick rule operation + StickRuleReplaceStickRuleHandler stick_rule.ReplaceStickRuleHandler + // StickRuleReplaceStickRulesHandler sets the operation handler for the replace stick rules operation + StickRuleReplaceStickRulesHandler stick_rule.ReplaceStickRulesHandler + // StorageReplaceStorageGeneralFileHandler sets the operation handler for the replace storage general file operation + StorageReplaceStorageGeneralFileHandler storage.ReplaceStorageGeneralFileHandler + // StorageReplaceStorageMapFileHandler sets the operation handler for the replace storage map file operation + StorageReplaceStorageMapFileHandler storage.ReplaceStorageMapFileHandler + // StorageReplaceStorageSSLCertificateHandler sets the operation handler for the replace storage s s l certificate operation + StorageReplaceStorageSSLCertificateHandler storage.ReplaceStorageSSLCertificateHandler + // StorageReplaceStorageSSLCrtListFileHandler sets the operation handler for the replace storage s s l crt list file operation + StorageReplaceStorageSSLCrtListFileHandler storage.ReplaceStorageSSLCrtListFileHandler + // TCPCheckReplaceTCPCheckBackendHandler sets the operation handler for the replace TCP check backend operation + TCPCheckReplaceTCPCheckBackendHandler tcp_check.ReplaceTCPCheckBackendHandler + // TCPCheckReplaceTCPCheckDefaultsHandler sets the operation handler for the replace TCP check defaults operation + TCPCheckReplaceTCPCheckDefaultsHandler tcp_check.ReplaceTCPCheckDefaultsHandler + // TCPRequestRuleReplaceTCPRequestRuleBackendHandler sets the operation handler for the replace TCP request rule backend operation + TCPRequestRuleReplaceTCPRequestRuleBackendHandler tcp_request_rule.ReplaceTCPRequestRuleBackendHandler + // TCPRequestRuleReplaceTCPRequestRuleDefaultsHandler sets the operation handler for the replace TCP request rule defaults operation + TCPRequestRuleReplaceTCPRequestRuleDefaultsHandler tcp_request_rule.ReplaceTCPRequestRuleDefaultsHandler + // TCPRequestRuleReplaceTCPRequestRuleFrontendHandler sets the operation handler for the replace TCP request rule frontend operation + TCPRequestRuleReplaceTCPRequestRuleFrontendHandler tcp_request_rule.ReplaceTCPRequestRuleFrontendHandler + // TCPResponseRuleReplaceTCPResponseRuleBackendHandler sets the operation handler for the replace TCP response rule backend operation + TCPResponseRuleReplaceTCPResponseRuleBackendHandler tcp_response_rule.ReplaceTCPResponseRuleBackendHandler + // TCPResponseRuleReplaceTCPResponseRuleDefaultsHandler sets the operation handler for the replace TCP response rule defaults operation + TCPResponseRuleReplaceTCPResponseRuleDefaultsHandler tcp_response_rule.ReplaceTCPResponseRuleDefaultsHandler + // TableReplaceTableHandler sets the operation handler for the replace table operation + TableReplaceTableHandler table.ReplaceTableHandler + // TracesReplaceTracesHandler sets the operation handler for the replace traces operation + TracesReplaceTracesHandler traces.ReplaceTracesHandler + // UserReplaceUserHandler sets the operation handler for the replace user operation + UserReplaceUserHandler user.ReplaceUserHandler + // SslRuntimeSetCaFileHandler sets the operation handler for the set ca file operation + SslRuntimeSetCaFileHandler s_s_l_runtime.SetCaFileHandler + // StickTableSetStickTableEntriesHandler sets the operation handler for the set stick table entries operation + StickTableSetStickTableEntriesHandler stick_table.SetStickTableEntriesHandler + // MapsShowRuntimeMapHandler sets the operation handler for the show runtime map operation + MapsShowRuntimeMapHandler maps.ShowRuntimeMapHandler + // SpoeTransactionsStartSpoeTransactionHandler sets the operation handler for the start spoe transaction operation + SpoeTransactionsStartSpoeTransactionHandler spoe_transactions.StartSpoeTransactionHandler + // TransactionsStartTransactionHandler sets the operation handler for the start transaction operation + TransactionsStartTransactionHandler transactions.StartTransactionHandler + + // ServeError is called when an error is received, there is a default handler + // but you can set your own with this + ServeError func(http.ResponseWriter, *http.Request, error) + + // PreServerShutdown is called before the HTTP(S) server is shutdown + // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic + PreServerShutdown func() + + // ServerShutdown is called when the HTTP(S) server is shut down and done + // handling all active connections and does not accept connections any more + ServerShutdown func() + + // Custom command line argument groups with their descriptions + CommandLineOptionsGroups []swag.CommandLineOptionsGroup + + // User defined logger function. + Logger func(string, ...interface{}) +} + +// UseRedoc for documentation at /docs +func (o *DataPlaneAPI) UseRedoc() { + o.useSwaggerUI = false +} + +// UseSwaggerUI for documentation at /docs +func (o *DataPlaneAPI) UseSwaggerUI() { + o.useSwaggerUI = true +} + +// SetDefaultProduces sets the default produces media type +func (o *DataPlaneAPI) SetDefaultProduces(mediaType string) { + o.defaultProduces = mediaType +} + +// SetDefaultConsumes returns the default consumes media type +func (o *DataPlaneAPI) SetDefaultConsumes(mediaType string) { + o.defaultConsumes = mediaType +} + +// SetSpec sets a spec that will be served for the clients. +func (o *DataPlaneAPI) SetSpec(spec *loads.Document) { + o.spec = spec +} + +// DefaultProduces returns the default produces media type +func (o *DataPlaneAPI) DefaultProduces() string { + return o.defaultProduces +} + +// DefaultConsumes returns the default consumes media type +func (o *DataPlaneAPI) DefaultConsumes() string { + return o.defaultConsumes +} + +// Formats returns the registered string formats +func (o *DataPlaneAPI) Formats() strfmt.Registry { + return o.formats +} + +// RegisterFormat registers a custom format validator +func (o *DataPlaneAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + o.formats.Add(name, format, validator) +} + +// Validate validates the registrations in the DataPlaneAPI +func (o *DataPlaneAPI) Validate() error { + var unregistered []string + + if o.JSONConsumer == nil { + unregistered = append(unregistered, "JSONConsumer") + } + if o.MultipartformConsumer == nil { + unregistered = append(unregistered, "MultipartformConsumer") + } + if o.TxtConsumer == nil { + unregistered = append(unregistered, "TxtConsumer") + } + + if o.BinProducer == nil { + unregistered = append(unregistered, "BinProducer") + } + if o.JSONProducer == nil { + unregistered = append(unregistered, "JSONProducer") + } + if o.TxtProducer == nil { + unregistered = append(unregistered, "TxtProducer") + } + + if o.BasicAuthAuth == nil { + unregistered = append(unregistered, "BasicAuthAuth") + } + + if o.StorageCreateStorageSSLCrtListEntryHandler == nil { + unregistered = append(unregistered, "storage.CreateStorageSSLCrtListEntryHandler") + } + if o.ACLRuntimeDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler == nil { + unregistered = append(unregistered, "acl_runtime.DeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler") + } + if o.StorageDeleteStorageSSLCrtListEntryHandler == nil { + unregistered = append(unregistered, "storage.DeleteStorageSSLCrtListEntryHandler") + } + if o.ACLRuntimeGetServicesHaproxyRuntimeAclsHandler == nil { + unregistered = append(unregistered, "acl_runtime.GetServicesHaproxyRuntimeAclsHandler") + } + if o.ACLRuntimeGetServicesHaproxyRuntimeAclsIDHandler == nil { + unregistered = append(unregistered, "acl_runtime.GetServicesHaproxyRuntimeAclsIDHandler") + } + if o.ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesHandler == nil { + unregistered = append(unregistered, "acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesHandler") + } + if o.ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler == nil { + unregistered = append(unregistered, "acl_runtime.GetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler") + } + if o.StorageGetStorageSSLCrtListEntriesHandler == nil { + unregistered = append(unregistered, "storage.GetStorageSSLCrtListEntriesHandler") + } + if o.ACLRuntimePostServicesHaproxyRuntimeAclsParentNameEntriesHandler == nil { + unregistered = append(unregistered, "acl_runtime.PostServicesHaproxyRuntimeAclsParentNameEntriesHandler") + } + if o.SslRuntimeAddCaEntryHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.AddCaEntryHandler") + } + if o.SslRuntimeAddCrtListEntryHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.AddCrtListEntryHandler") + } + if o.DefaultsAddDefaultsSectionHandler == nil { + unregistered = append(unregistered, "defaults.AddDefaultsSectionHandler") + } + if o.MapsAddMapEntryHandler == nil { + unregistered = append(unregistered, "maps.AddMapEntryHandler") + } + if o.ACLRuntimeAddPayloadRuntimeACLHandler == nil { + unregistered = append(unregistered, "acl_runtime.AddPayloadRuntimeACLHandler") + } + if o.MapsAddPayloadRuntimeMapHandler == nil { + unregistered = append(unregistered, "maps.AddPayloadRuntimeMapHandler") + } + if o.ServerAddRuntimeServerHandler == nil { + unregistered = append(unregistered, "server.AddRuntimeServerHandler") + } + if o.MapsClearRuntimeMapHandler == nil { + unregistered = append(unregistered, "maps.ClearRuntimeMapHandler") + } + if o.SpoeTransactionsCommitSpoeTransactionHandler == nil { + unregistered = append(unregistered, "spoe_transactions.CommitSpoeTransactionHandler") + } + if o.TransactionsCommitTransactionHandler == nil { + unregistered = append(unregistered, "transactions.CommitTransactionHandler") + } + if o.ServiceDiscoveryCreateAWSRegionHandler == nil { + unregistered = append(unregistered, "service_discovery.CreateAWSRegionHandler") + } + if o.ACLCreateACLBackendHandler == nil { + unregistered = append(unregistered, "acl.CreateACLBackendHandler") + } + if o.ACLCreateACLDefaultsHandler == nil { + unregistered = append(unregistered, "acl.CreateACLDefaultsHandler") + } + if o.ACLCreateACLFCGIAppHandler == nil { + unregistered = append(unregistered, "acl.CreateACLFCGIAppHandler") + } + if o.ACLCreateACLFrontendHandler == nil { + unregistered = append(unregistered, "acl.CreateACLFrontendHandler") + } + if o.AcmeCreateAcmeProviderHandler == nil { + unregistered = append(unregistered, "acme.CreateAcmeProviderHandler") + } + if o.BackendCreateBackendHandler == nil { + unregistered = append(unregistered, "backend.CreateBackendHandler") + } + if o.BackendSwitchingRuleCreateBackendSwitchingRuleHandler == nil { + unregistered = append(unregistered, "backend_switching_rule.CreateBackendSwitchingRuleHandler") + } + if o.BindCreateBindFrontendHandler == nil { + unregistered = append(unregistered, "bind.CreateBindFrontendHandler") + } + if o.BindCreateBindLogForwardHandler == nil { + unregistered = append(unregistered, "bind.CreateBindLogForwardHandler") + } + if o.BindCreateBindPeerHandler == nil { + unregistered = append(unregistered, "bind.CreateBindPeerHandler") + } + if o.SslRuntimeCreateCaFileHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.CreateCaFileHandler") + } + if o.CacheCreateCacheHandler == nil { + unregistered = append(unregistered, "cache.CreateCacheHandler") + } + if o.SslRuntimeCreateCertHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.CreateCertHandler") + } + if o.ServiceDiscoveryCreateConsulHandler == nil { + unregistered = append(unregistered, "service_discovery.CreateConsulHandler") + } + if o.SslRuntimeCreateCrlHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.CreateCrlHandler") + } + if o.CrtLoadCreateCrtLoadHandler == nil { + unregistered = append(unregistered, "crt_load.CreateCrtLoadHandler") + } + if o.CrtStoreCreateCrtStoreHandler == nil { + unregistered = append(unregistered, "crt_store.CreateCrtStoreHandler") + } + if o.DeclareCaptureCreateDeclareCaptureHandler == nil { + unregistered = append(unregistered, "declare_capture.CreateDeclareCaptureHandler") + } + if o.DefaultsCreateDefaultsSectionHandler == nil { + unregistered = append(unregistered, "defaults.CreateDefaultsSectionHandler") + } + if o.DgramBindCreateDgramBindHandler == nil { + unregistered = append(unregistered, "dgram_bind.CreateDgramBindHandler") + } + if o.FCGIAppCreateFCGIAppHandler == nil { + unregistered = append(unregistered, "fcgi_app.CreateFCGIAppHandler") + } + if o.FilterCreateFilterBackendHandler == nil { + unregistered = append(unregistered, "filter.CreateFilterBackendHandler") + } + if o.FilterCreateFilterFrontendHandler == nil { + unregistered = append(unregistered, "filter.CreateFilterFrontendHandler") + } + if o.FrontendCreateFrontendHandler == nil { + unregistered = append(unregistered, "frontend.CreateFrontendHandler") + } + if o.GroupCreateGroupHandler == nil { + unregistered = append(unregistered, "group.CreateGroupHandler") + } + if o.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.CreateHTTPAfterResponseRuleBackendHandler") + } + if o.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.CreateHTTPAfterResponseRuleDefaultsHandler") + } + if o.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.CreateHTTPAfterResponseRuleFrontendHandler") + } + if o.HTTPCheckCreateHTTPCheckBackendHandler == nil { + unregistered = append(unregistered, "http_check.CreateHTTPCheckBackendHandler") + } + if o.HTTPCheckCreateHTTPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "http_check.CreateHTTPCheckDefaultsHandler") + } + if o.HTTPErrorRuleCreateHTTPErrorRuleBackendHandler == nil { + unregistered = append(unregistered, "http_error_rule.CreateHTTPErrorRuleBackendHandler") + } + if o.HTTPErrorRuleCreateHTTPErrorRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_error_rule.CreateHTTPErrorRuleDefaultsHandler") + } + if o.HTTPErrorRuleCreateHTTPErrorRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_error_rule.CreateHTTPErrorRuleFrontendHandler") + } + if o.HTTPErrorsCreateHTTPErrorsSectionHandler == nil { + unregistered = append(unregistered, "http_errors.CreateHTTPErrorsSectionHandler") + } + if o.HTTPRequestRuleCreateHTTPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "http_request_rule.CreateHTTPRequestRuleBackendHandler") + } + if o.HTTPRequestRuleCreateHTTPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_request_rule.CreateHTTPRequestRuleDefaultsHandler") + } + if o.HTTPRequestRuleCreateHTTPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_request_rule.CreateHTTPRequestRuleFrontendHandler") + } + if o.HTTPResponseRuleCreateHTTPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_response_rule.CreateHTTPResponseRuleBackendHandler") + } + if o.HTTPResponseRuleCreateHTTPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_response_rule.CreateHTTPResponseRuleDefaultsHandler") + } + if o.HTTPResponseRuleCreateHTTPResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_response_rule.CreateHTTPResponseRuleFrontendHandler") + } + if o.LogForwardCreateLogForwardHandler == nil { + unregistered = append(unregistered, "log_forward.CreateLogForwardHandler") + } + if o.LogProfileCreateLogProfileHandler == nil { + unregistered = append(unregistered, "log_profile.CreateLogProfileHandler") + } + if o.LogTargetCreateLogTargetBackendHandler == nil { + unregistered = append(unregistered, "log_target.CreateLogTargetBackendHandler") + } + if o.LogTargetCreateLogTargetDefaultsHandler == nil { + unregistered = append(unregistered, "log_target.CreateLogTargetDefaultsHandler") + } + if o.LogTargetCreateLogTargetFrontendHandler == nil { + unregistered = append(unregistered, "log_target.CreateLogTargetFrontendHandler") + } + if o.LogTargetCreateLogTargetGlobalHandler == nil { + unregistered = append(unregistered, "log_target.CreateLogTargetGlobalHandler") + } + if o.LogTargetCreateLogTargetLogForwardHandler == nil { + unregistered = append(unregistered, "log_target.CreateLogTargetLogForwardHandler") + } + if o.LogTargetCreateLogTargetPeerHandler == nil { + unregistered = append(unregistered, "log_target.CreateLogTargetPeerHandler") + } + if o.MailerEntryCreateMailerEntryHandler == nil { + unregistered = append(unregistered, "mailer_entry.CreateMailerEntryHandler") + } + if o.MailersCreateMailersSectionHandler == nil { + unregistered = append(unregistered, "mailers.CreateMailersSectionHandler") + } + if o.NameserverCreateNameserverHandler == nil { + unregistered = append(unregistered, "nameserver.CreateNameserverHandler") + } + if o.PeerCreatePeerHandler == nil { + unregistered = append(unregistered, "peer.CreatePeerHandler") + } + if o.PeerEntryCreatePeerEntryHandler == nil { + unregistered = append(unregistered, "peer_entry.CreatePeerEntryHandler") + } + if o.ProcessManagerCreateProgramHandler == nil { + unregistered = append(unregistered, "process_manager.CreateProgramHandler") + } + if o.QUICInitialRuleCreateQUICInitialRuleDefaultsHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.CreateQUICInitialRuleDefaultsHandler") + } + if o.QUICInitialRuleCreateQUICInitialRuleFrontendHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.CreateQUICInitialRuleFrontendHandler") + } + if o.ResolverCreateResolverHandler == nil { + unregistered = append(unregistered, "resolver.CreateResolverHandler") + } + if o.RingCreateRingHandler == nil { + unregistered = append(unregistered, "ring.CreateRingHandler") + } + if o.SslFrontUseCreateSSLFrontUseHandler == nil { + unregistered = append(unregistered, "s_s_l_front_use.CreateSSLFrontUseHandler") + } + if o.ServerCreateServerBackendHandler == nil { + unregistered = append(unregistered, "server.CreateServerBackendHandler") + } + if o.ServerCreateServerPeerHandler == nil { + unregistered = append(unregistered, "server.CreateServerPeerHandler") + } + if o.ServerCreateServerRingHandler == nil { + unregistered = append(unregistered, "server.CreateServerRingHandler") + } + if o.ServerSwitchingRuleCreateServerSwitchingRuleHandler == nil { + unregistered = append(unregistered, "server_switching_rule.CreateServerSwitchingRuleHandler") + } + if o.ServerTemplateCreateServerTemplateHandler == nil { + unregistered = append(unregistered, "server_template.CreateServerTemplateHandler") + } + if o.SitesCreateSiteHandler == nil { + unregistered = append(unregistered, "sites.CreateSiteHandler") + } + if o.SpoeCreateSpoeHandler == nil { + unregistered = append(unregistered, "spoe.CreateSpoeHandler") + } + if o.SpoeCreateSpoeAgentHandler == nil { + unregistered = append(unregistered, "spoe.CreateSpoeAgentHandler") + } + if o.SpoeCreateSpoeGroupHandler == nil { + unregistered = append(unregistered, "spoe.CreateSpoeGroupHandler") + } + if o.SpoeCreateSpoeMessageHandler == nil { + unregistered = append(unregistered, "spoe.CreateSpoeMessageHandler") + } + if o.SpoeCreateSpoeScopeHandler == nil { + unregistered = append(unregistered, "spoe.CreateSpoeScopeHandler") + } + if o.StickRuleCreateStickRuleHandler == nil { + unregistered = append(unregistered, "stick_rule.CreateStickRuleHandler") + } + if o.StorageCreateStorageGeneralFileHandler == nil { + unregistered = append(unregistered, "storage.CreateStorageGeneralFileHandler") + } + if o.StorageCreateStorageMapFileHandler == nil { + unregistered = append(unregistered, "storage.CreateStorageMapFileHandler") + } + if o.StorageCreateStorageSSLCertificateHandler == nil { + unregistered = append(unregistered, "storage.CreateStorageSSLCertificateHandler") + } + if o.StorageCreateStorageSSLCrtListFileHandler == nil { + unregistered = append(unregistered, "storage.CreateStorageSSLCrtListFileHandler") + } + if o.TCPCheckCreateTCPCheckBackendHandler == nil { + unregistered = append(unregistered, "tcp_check.CreateTCPCheckBackendHandler") + } + if o.TCPCheckCreateTCPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_check.CreateTCPCheckDefaultsHandler") + } + if o.TCPRequestRuleCreateTCPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.CreateTCPRequestRuleBackendHandler") + } + if o.TCPRequestRuleCreateTCPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.CreateTCPRequestRuleDefaultsHandler") + } + if o.TCPRequestRuleCreateTCPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.CreateTCPRequestRuleFrontendHandler") + } + if o.TCPResponseRuleCreateTCPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.CreateTCPResponseRuleBackendHandler") + } + if o.TCPResponseRuleCreateTCPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.CreateTCPResponseRuleDefaultsHandler") + } + if o.TableCreateTableHandler == nil { + unregistered = append(unregistered, "table.CreateTableHandler") + } + if o.TracesCreateTraceEntryHandler == nil { + unregistered = append(unregistered, "traces.CreateTraceEntryHandler") + } + if o.TracesCreateTracesHandler == nil { + unregistered = append(unregistered, "traces.CreateTracesHandler") + } + if o.UserCreateUserHandler == nil { + unregistered = append(unregistered, "user.CreateUserHandler") + } + if o.UserlistCreateUserlistHandler == nil { + unregistered = append(unregistered, "userlist.CreateUserlistHandler") + } + if o.ServiceDiscoveryDeleteAWSRegionHandler == nil { + unregistered = append(unregistered, "service_discovery.DeleteAWSRegionHandler") + } + if o.ACLDeleteACLBackendHandler == nil { + unregistered = append(unregistered, "acl.DeleteACLBackendHandler") + } + if o.ACLDeleteACLDefaultsHandler == nil { + unregistered = append(unregistered, "acl.DeleteACLDefaultsHandler") + } + if o.ACLDeleteACLFCGIAppHandler == nil { + unregistered = append(unregistered, "acl.DeleteACLFCGIAppHandler") + } + if o.ACLDeleteACLFrontendHandler == nil { + unregistered = append(unregistered, "acl.DeleteACLFrontendHandler") + } + if o.AcmeDeleteAcmeProviderHandler == nil { + unregistered = append(unregistered, "acme.DeleteAcmeProviderHandler") + } + if o.BackendDeleteBackendHandler == nil { + unregistered = append(unregistered, "backend.DeleteBackendHandler") + } + if o.BackendSwitchingRuleDeleteBackendSwitchingRuleHandler == nil { + unregistered = append(unregistered, "backend_switching_rule.DeleteBackendSwitchingRuleHandler") + } + if o.BindDeleteBindFrontendHandler == nil { + unregistered = append(unregistered, "bind.DeleteBindFrontendHandler") + } + if o.BindDeleteBindLogForwardHandler == nil { + unregistered = append(unregistered, "bind.DeleteBindLogForwardHandler") + } + if o.BindDeleteBindPeerHandler == nil { + unregistered = append(unregistered, "bind.DeleteBindPeerHandler") + } + if o.SslRuntimeDeleteCaFileHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.DeleteCaFileHandler") + } + if o.CacheDeleteCacheHandler == nil { + unregistered = append(unregistered, "cache.DeleteCacheHandler") + } + if o.SslRuntimeDeleteCertHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.DeleteCertHandler") + } + if o.ClusterDeleteClusterHandler == nil { + unregistered = append(unregistered, "cluster.DeleteClusterHandler") + } + if o.ServiceDiscoveryDeleteConsulHandler == nil { + unregistered = append(unregistered, "service_discovery.DeleteConsulHandler") + } + if o.SslRuntimeDeleteCrlHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.DeleteCrlHandler") + } + if o.SslRuntimeDeleteCrtListEntryHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.DeleteCrtListEntryHandler") + } + if o.CrtLoadDeleteCrtLoadHandler == nil { + unregistered = append(unregistered, "crt_load.DeleteCrtLoadHandler") + } + if o.CrtStoreDeleteCrtStoreHandler == nil { + unregistered = append(unregistered, "crt_store.DeleteCrtStoreHandler") + } + if o.DeclareCaptureDeleteDeclareCaptureHandler == nil { + unregistered = append(unregistered, "declare_capture.DeleteDeclareCaptureHandler") + } + if o.DefaultsDeleteDefaultsSectionHandler == nil { + unregistered = append(unregistered, "defaults.DeleteDefaultsSectionHandler") + } + if o.DgramBindDeleteDgramBindHandler == nil { + unregistered = append(unregistered, "dgram_bind.DeleteDgramBindHandler") + } + if o.FCGIAppDeleteFCGIAppHandler == nil { + unregistered = append(unregistered, "fcgi_app.DeleteFCGIAppHandler") + } + if o.FilterDeleteFilterBackendHandler == nil { + unregistered = append(unregistered, "filter.DeleteFilterBackendHandler") + } + if o.FilterDeleteFilterFrontendHandler == nil { + unregistered = append(unregistered, "filter.DeleteFilterFrontendHandler") + } + if o.FrontendDeleteFrontendHandler == nil { + unregistered = append(unregistered, "frontend.DeleteFrontendHandler") + } + if o.GroupDeleteGroupHandler == nil { + unregistered = append(unregistered, "group.DeleteGroupHandler") + } + if o.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.DeleteHTTPAfterResponseRuleBackendHandler") + } + if o.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.DeleteHTTPAfterResponseRuleDefaultsHandler") + } + if o.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.DeleteHTTPAfterResponseRuleFrontendHandler") + } + if o.HTTPCheckDeleteHTTPCheckBackendHandler == nil { + unregistered = append(unregistered, "http_check.DeleteHTTPCheckBackendHandler") + } + if o.HTTPCheckDeleteHTTPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "http_check.DeleteHTTPCheckDefaultsHandler") + } + if o.HTTPErrorRuleDeleteHTTPErrorRuleBackendHandler == nil { + unregistered = append(unregistered, "http_error_rule.DeleteHTTPErrorRuleBackendHandler") + } + if o.HTTPErrorRuleDeleteHTTPErrorRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_error_rule.DeleteHTTPErrorRuleDefaultsHandler") + } + if o.HTTPErrorRuleDeleteHTTPErrorRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_error_rule.DeleteHTTPErrorRuleFrontendHandler") + } + if o.HTTPErrorsDeleteHTTPErrorsSectionHandler == nil { + unregistered = append(unregistered, "http_errors.DeleteHTTPErrorsSectionHandler") + } + if o.HTTPRequestRuleDeleteHTTPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "http_request_rule.DeleteHTTPRequestRuleBackendHandler") + } + if o.HTTPRequestRuleDeleteHTTPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_request_rule.DeleteHTTPRequestRuleDefaultsHandler") + } + if o.HTTPRequestRuleDeleteHTTPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_request_rule.DeleteHTTPRequestRuleFrontendHandler") + } + if o.HTTPResponseRuleDeleteHTTPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_response_rule.DeleteHTTPResponseRuleBackendHandler") + } + if o.HTTPResponseRuleDeleteHTTPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_response_rule.DeleteHTTPResponseRuleDefaultsHandler") + } + if o.HTTPResponseRuleDeleteHTTPResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_response_rule.DeleteHTTPResponseRuleFrontendHandler") + } + if o.LogForwardDeleteLogForwardHandler == nil { + unregistered = append(unregistered, "log_forward.DeleteLogForwardHandler") + } + if o.LogProfileDeleteLogProfileHandler == nil { + unregistered = append(unregistered, "log_profile.DeleteLogProfileHandler") + } + if o.LogTargetDeleteLogTargetBackendHandler == nil { + unregistered = append(unregistered, "log_target.DeleteLogTargetBackendHandler") + } + if o.LogTargetDeleteLogTargetDefaultsHandler == nil { + unregistered = append(unregistered, "log_target.DeleteLogTargetDefaultsHandler") + } + if o.LogTargetDeleteLogTargetFrontendHandler == nil { + unregistered = append(unregistered, "log_target.DeleteLogTargetFrontendHandler") + } + if o.LogTargetDeleteLogTargetGlobalHandler == nil { + unregistered = append(unregistered, "log_target.DeleteLogTargetGlobalHandler") + } + if o.LogTargetDeleteLogTargetLogForwardHandler == nil { + unregistered = append(unregistered, "log_target.DeleteLogTargetLogForwardHandler") + } + if o.LogTargetDeleteLogTargetPeerHandler == nil { + unregistered = append(unregistered, "log_target.DeleteLogTargetPeerHandler") + } + if o.MailerEntryDeleteMailerEntryHandler == nil { + unregistered = append(unregistered, "mailer_entry.DeleteMailerEntryHandler") + } + if o.MailersDeleteMailersSectionHandler == nil { + unregistered = append(unregistered, "mailers.DeleteMailersSectionHandler") + } + if o.NameserverDeleteNameserverHandler == nil { + unregistered = append(unregistered, "nameserver.DeleteNameserverHandler") + } + if o.PeerDeletePeerHandler == nil { + unregistered = append(unregistered, "peer.DeletePeerHandler") + } + if o.PeerEntryDeletePeerEntryHandler == nil { + unregistered = append(unregistered, "peer_entry.DeletePeerEntryHandler") + } + if o.ProcessManagerDeleteProgramHandler == nil { + unregistered = append(unregistered, "process_manager.DeleteProgramHandler") + } + if o.QUICInitialRuleDeleteQUICInitialRuleDefaultsHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.DeleteQUICInitialRuleDefaultsHandler") + } + if o.QUICInitialRuleDeleteQUICInitialRuleFrontendHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.DeleteQUICInitialRuleFrontendHandler") + } + if o.ResolverDeleteResolverHandler == nil { + unregistered = append(unregistered, "resolver.DeleteResolverHandler") + } + if o.RingDeleteRingHandler == nil { + unregistered = append(unregistered, "ring.DeleteRingHandler") + } + if o.MapsDeleteRuntimeMapEntryHandler == nil { + unregistered = append(unregistered, "maps.DeleteRuntimeMapEntryHandler") + } + if o.ServerDeleteRuntimeServerHandler == nil { + unregistered = append(unregistered, "server.DeleteRuntimeServerHandler") + } + if o.SslFrontUseDeleteSSLFrontUseHandler == nil { + unregistered = append(unregistered, "s_s_l_front_use.DeleteSSLFrontUseHandler") + } + if o.ServerDeleteServerBackendHandler == nil { + unregistered = append(unregistered, "server.DeleteServerBackendHandler") + } + if o.ServerDeleteServerPeerHandler == nil { + unregistered = append(unregistered, "server.DeleteServerPeerHandler") + } + if o.ServerDeleteServerRingHandler == nil { + unregistered = append(unregistered, "server.DeleteServerRingHandler") + } + if o.ServerSwitchingRuleDeleteServerSwitchingRuleHandler == nil { + unregistered = append(unregistered, "server_switching_rule.DeleteServerSwitchingRuleHandler") + } + if o.ServerTemplateDeleteServerTemplateHandler == nil { + unregistered = append(unregistered, "server_template.DeleteServerTemplateHandler") + } + if o.SitesDeleteSiteHandler == nil { + unregistered = append(unregistered, "sites.DeleteSiteHandler") + } + if o.SpoeDeleteSpoeAgentHandler == nil { + unregistered = append(unregistered, "spoe.DeleteSpoeAgentHandler") + } + if o.SpoeDeleteSpoeFileHandler == nil { + unregistered = append(unregistered, "spoe.DeleteSpoeFileHandler") + } + if o.SpoeDeleteSpoeGroupHandler == nil { + unregistered = append(unregistered, "spoe.DeleteSpoeGroupHandler") + } + if o.SpoeDeleteSpoeMessageHandler == nil { + unregistered = append(unregistered, "spoe.DeleteSpoeMessageHandler") + } + if o.SpoeDeleteSpoeScopeHandler == nil { + unregistered = append(unregistered, "spoe.DeleteSpoeScopeHandler") + } + if o.SpoeTransactionsDeleteSpoeTransactionHandler == nil { + unregistered = append(unregistered, "spoe_transactions.DeleteSpoeTransactionHandler") + } + if o.StickRuleDeleteStickRuleHandler == nil { + unregistered = append(unregistered, "stick_rule.DeleteStickRuleHandler") + } + if o.StorageDeleteStorageGeneralFileHandler == nil { + unregistered = append(unregistered, "storage.DeleteStorageGeneralFileHandler") + } + if o.StorageDeleteStorageMapHandler == nil { + unregistered = append(unregistered, "storage.DeleteStorageMapHandler") + } + if o.StorageDeleteStorageSSLCertificateHandler == nil { + unregistered = append(unregistered, "storage.DeleteStorageSSLCertificateHandler") + } + if o.StorageDeleteStorageSSLCrtListFileHandler == nil { + unregistered = append(unregistered, "storage.DeleteStorageSSLCrtListFileHandler") + } + if o.TCPCheckDeleteTCPCheckBackendHandler == nil { + unregistered = append(unregistered, "tcp_check.DeleteTCPCheckBackendHandler") + } + if o.TCPCheckDeleteTCPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_check.DeleteTCPCheckDefaultsHandler") + } + if o.TCPRequestRuleDeleteTCPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.DeleteTCPRequestRuleBackendHandler") + } + if o.TCPRequestRuleDeleteTCPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.DeleteTCPRequestRuleDefaultsHandler") + } + if o.TCPRequestRuleDeleteTCPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.DeleteTCPRequestRuleFrontendHandler") + } + if o.TCPResponseRuleDeleteTCPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.DeleteTCPResponseRuleBackendHandler") + } + if o.TCPResponseRuleDeleteTCPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.DeleteTCPResponseRuleDefaultsHandler") + } + if o.TableDeleteTableHandler == nil { + unregistered = append(unregistered, "table.DeleteTableHandler") + } + if o.TracesDeleteTraceEntryHandler == nil { + unregistered = append(unregistered, "traces.DeleteTraceEntryHandler") + } + if o.TracesDeleteTracesHandler == nil { + unregistered = append(unregistered, "traces.DeleteTracesHandler") + } + if o.TransactionsDeleteTransactionHandler == nil { + unregistered = append(unregistered, "transactions.DeleteTransactionHandler") + } + if o.UserDeleteUserHandler == nil { + unregistered = append(unregistered, "user.DeleteUserHandler") + } + if o.UserlistDeleteUserlistHandler == nil { + unregistered = append(unregistered, "userlist.DeleteUserlistHandler") + } + if o.AcmeEditAcmeProviderHandler == nil { + unregistered = append(unregistered, "acme.EditAcmeProviderHandler") + } + if o.ClusterEditClusterHandler == nil { + unregistered = append(unregistered, "cluster.EditClusterHandler") + } + if o.CrtStoreEditCrtStoreHandler == nil { + unregistered = append(unregistered, "crt_store.EditCrtStoreHandler") + } + if o.LogProfileEditLogProfileHandler == nil { + unregistered = append(unregistered, "log_profile.EditLogProfileHandler") + } + if o.MailersEditMailersSectionHandler == nil { + unregistered = append(unregistered, "mailers.EditMailersSectionHandler") + } + if o.DiscoveryGetAPIEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetAPIEndpointsHandler") + } + if o.ServiceDiscoveryGetAWSRegionHandler == nil { + unregistered = append(unregistered, "service_discovery.GetAWSRegionHandler") + } + if o.ServiceDiscoveryGetAWSRegionsHandler == nil { + unregistered = append(unregistered, "service_discovery.GetAWSRegionsHandler") + } + if o.ACLGetACLBackendHandler == nil { + unregistered = append(unregistered, "acl.GetACLBackendHandler") + } + if o.ACLGetACLDefaultsHandler == nil { + unregistered = append(unregistered, "acl.GetACLDefaultsHandler") + } + if o.ACLGetACLFCGIAppHandler == nil { + unregistered = append(unregistered, "acl.GetACLFCGIAppHandler") + } + if o.ACLGetACLFrontendHandler == nil { + unregistered = append(unregistered, "acl.GetACLFrontendHandler") + } + if o.AcmeGetAcmeProviderHandler == nil { + unregistered = append(unregistered, "acme.GetAcmeProviderHandler") + } + if o.AcmeGetAcmeProvidersHandler == nil { + unregistered = append(unregistered, "acme.GetAcmeProvidersHandler") + } + if o.AcmeRuntimeGetAcmeStatusHandler == nil { + unregistered = append(unregistered, "acme_runtime.GetAcmeStatusHandler") + } + if o.ACLGetAllACLBackendHandler == nil { + unregistered = append(unregistered, "acl.GetAllACLBackendHandler") + } + if o.ACLGetAllACLDefaultsHandler == nil { + unregistered = append(unregistered, "acl.GetAllACLDefaultsHandler") + } + if o.ACLGetAllACLFCGIAppHandler == nil { + unregistered = append(unregistered, "acl.GetAllACLFCGIAppHandler") + } + if o.ACLGetAllACLFrontendHandler == nil { + unregistered = append(unregistered, "acl.GetAllACLFrontendHandler") + } + if o.BindGetAllBindFrontendHandler == nil { + unregistered = append(unregistered, "bind.GetAllBindFrontendHandler") + } + if o.BindGetAllBindLogForwardHandler == nil { + unregistered = append(unregistered, "bind.GetAllBindLogForwardHandler") + } + if o.BindGetAllBindPeerHandler == nil { + unregistered = append(unregistered, "bind.GetAllBindPeerHandler") + } + if o.SslRuntimeGetAllCaFilesHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetAllCaFilesHandler") + } + if o.SslRuntimeGetAllCertsHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetAllCertsHandler") + } + if o.SslRuntimeGetAllCrlHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetAllCrlHandler") + } + if o.SslRuntimeGetAllCrtListEntriesHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetAllCrtListEntriesHandler") + } + if o.SslRuntimeGetAllCrtListsHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetAllCrtListsHandler") + } + if o.FilterGetAllFilterBackendHandler == nil { + unregistered = append(unregistered, "filter.GetAllFilterBackendHandler") + } + if o.FilterGetAllFilterFrontendHandler == nil { + unregistered = append(unregistered, "filter.GetAllFilterFrontendHandler") + } + if o.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.GetAllHTTPAfterResponseRuleBackendHandler") + } + if o.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.GetAllHTTPAfterResponseRuleDefaultsHandler") + } + if o.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.GetAllHTTPAfterResponseRuleFrontendHandler") + } + if o.HTTPCheckGetAllHTTPCheckBackendHandler == nil { + unregistered = append(unregistered, "http_check.GetAllHTTPCheckBackendHandler") + } + if o.HTTPCheckGetAllHTTPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "http_check.GetAllHTTPCheckDefaultsHandler") + } + if o.HTTPErrorRuleGetAllHTTPErrorRuleBackendHandler == nil { + unregistered = append(unregistered, "http_error_rule.GetAllHTTPErrorRuleBackendHandler") + } + if o.HTTPErrorRuleGetAllHTTPErrorRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_error_rule.GetAllHTTPErrorRuleDefaultsHandler") + } + if o.HTTPErrorRuleGetAllHTTPErrorRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_error_rule.GetAllHTTPErrorRuleFrontendHandler") + } + if o.HTTPRequestRuleGetAllHTTPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "http_request_rule.GetAllHTTPRequestRuleBackendHandler") + } + if o.HTTPRequestRuleGetAllHTTPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_request_rule.GetAllHTTPRequestRuleDefaultsHandler") + } + if o.HTTPRequestRuleGetAllHTTPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_request_rule.GetAllHTTPRequestRuleFrontendHandler") + } + if o.HTTPResponseRuleGetAllHTTPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_response_rule.GetAllHTTPResponseRuleBackendHandler") + } + if o.HTTPResponseRuleGetAllHTTPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_response_rule.GetAllHTTPResponseRuleDefaultsHandler") + } + if o.HTTPResponseRuleGetAllHTTPResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_response_rule.GetAllHTTPResponseRuleFrontendHandler") + } + if o.LogTargetGetAllLogTargetBackendHandler == nil { + unregistered = append(unregistered, "log_target.GetAllLogTargetBackendHandler") + } + if o.LogTargetGetAllLogTargetDefaultsHandler == nil { + unregistered = append(unregistered, "log_target.GetAllLogTargetDefaultsHandler") + } + if o.LogTargetGetAllLogTargetFrontendHandler == nil { + unregistered = append(unregistered, "log_target.GetAllLogTargetFrontendHandler") + } + if o.LogTargetGetAllLogTargetGlobalHandler == nil { + unregistered = append(unregistered, "log_target.GetAllLogTargetGlobalHandler") + } + if o.LogTargetGetAllLogTargetLogForwardHandler == nil { + unregistered = append(unregistered, "log_target.GetAllLogTargetLogForwardHandler") + } + if o.LogTargetGetAllLogTargetPeerHandler == nil { + unregistered = append(unregistered, "log_target.GetAllLogTargetPeerHandler") + } + if o.QUICInitialRuleGetAllQUICInitialRuleDefaultsHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.GetAllQUICInitialRuleDefaultsHandler") + } + if o.QUICInitialRuleGetAllQUICInitialRuleFrontendHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.GetAllQUICInitialRuleFrontendHandler") + } + if o.MapsGetAllRuntimeMapFilesHandler == nil { + unregistered = append(unregistered, "maps.GetAllRuntimeMapFilesHandler") + } + if o.ServerGetAllRuntimeServerHandler == nil { + unregistered = append(unregistered, "server.GetAllRuntimeServerHandler") + } + if o.SslFrontUseGetAllSSLFrontUsesHandler == nil { + unregistered = append(unregistered, "s_s_l_front_use.GetAllSSLFrontUsesHandler") + } + if o.ServerGetAllServerBackendHandler == nil { + unregistered = append(unregistered, "server.GetAllServerBackendHandler") + } + if o.ServerGetAllServerPeerHandler == nil { + unregistered = append(unregistered, "server.GetAllServerPeerHandler") + } + if o.ServerGetAllServerRingHandler == nil { + unregistered = append(unregistered, "server.GetAllServerRingHandler") + } + if o.SpoeGetAllSpoeAgentHandler == nil { + unregistered = append(unregistered, "spoe.GetAllSpoeAgentHandler") + } + if o.SpoeGetAllSpoeFilesHandler == nil { + unregistered = append(unregistered, "spoe.GetAllSpoeFilesHandler") + } + if o.SpoeGetAllSpoeGroupHandler == nil { + unregistered = append(unregistered, "spoe.GetAllSpoeGroupHandler") + } + if o.SpoeGetAllSpoeMessageHandler == nil { + unregistered = append(unregistered, "spoe.GetAllSpoeMessageHandler") + } + if o.SpoeGetAllSpoeScopeHandler == nil { + unregistered = append(unregistered, "spoe.GetAllSpoeScopeHandler") + } + if o.SpoeTransactionsGetAllSpoeTransactionHandler == nil { + unregistered = append(unregistered, "spoe_transactions.GetAllSpoeTransactionHandler") + } + if o.StorageGetAllStorageGeneralFilesHandler == nil { + unregistered = append(unregistered, "storage.GetAllStorageGeneralFilesHandler") + } + if o.StorageGetAllStorageMapFilesHandler == nil { + unregistered = append(unregistered, "storage.GetAllStorageMapFilesHandler") + } + if o.StorageGetAllStorageSSLCertificatesHandler == nil { + unregistered = append(unregistered, "storage.GetAllStorageSSLCertificatesHandler") + } + if o.StorageGetAllStorageSSLCrtListFilesHandler == nil { + unregistered = append(unregistered, "storage.GetAllStorageSSLCrtListFilesHandler") + } + if o.TCPCheckGetAllTCPCheckBackendHandler == nil { + unregistered = append(unregistered, "tcp_check.GetAllTCPCheckBackendHandler") + } + if o.TCPCheckGetAllTCPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_check.GetAllTCPCheckDefaultsHandler") + } + if o.TCPRequestRuleGetAllTCPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.GetAllTCPRequestRuleBackendHandler") + } + if o.TCPRequestRuleGetAllTCPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.GetAllTCPRequestRuleDefaultsHandler") + } + if o.TCPRequestRuleGetAllTCPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.GetAllTCPRequestRuleFrontendHandler") + } + if o.TCPResponseRuleGetAllTCPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.GetAllTCPResponseRuleBackendHandler") + } + if o.TCPResponseRuleGetAllTCPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.GetAllTCPResponseRuleDefaultsHandler") + } + if o.BackendGetBackendHandler == nil { + unregistered = append(unregistered, "backend.GetBackendHandler") + } + if o.BackendSwitchingRuleGetBackendSwitchingRuleHandler == nil { + unregistered = append(unregistered, "backend_switching_rule.GetBackendSwitchingRuleHandler") + } + if o.BackendSwitchingRuleGetBackendSwitchingRulesHandler == nil { + unregistered = append(unregistered, "backend_switching_rule.GetBackendSwitchingRulesHandler") + } + if o.BackendGetBackendsHandler == nil { + unregistered = append(unregistered, "backend.GetBackendsHandler") + } + if o.BindGetBindFrontendHandler == nil { + unregistered = append(unregistered, "bind.GetBindFrontendHandler") + } + if o.BindGetBindLogForwardHandler == nil { + unregistered = append(unregistered, "bind.GetBindLogForwardHandler") + } + if o.BindGetBindPeerHandler == nil { + unregistered = append(unregistered, "bind.GetBindPeerHandler") + } + if o.SslRuntimeGetCaEntryHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetCaEntryHandler") + } + if o.SslRuntimeGetCaFileHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetCaFileHandler") + } + if o.CacheGetCacheHandler == nil { + unregistered = append(unregistered, "cache.GetCacheHandler") + } + if o.CacheGetCachesHandler == nil { + unregistered = append(unregistered, "cache.GetCachesHandler") + } + if o.SslRuntimeGetCertHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetCertHandler") + } + if o.ClusterGetClusterHandler == nil { + unregistered = append(unregistered, "cluster.GetClusterHandler") + } + if o.DiscoveryGetConfigurationEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetConfigurationEndpointsHandler") + } + if o.ConfigurationGetConfigurationVersionHandler == nil { + unregistered = append(unregistered, "configuration.GetConfigurationVersionHandler") + } + if o.ServiceDiscoveryGetConsulHandler == nil { + unregistered = append(unregistered, "service_discovery.GetConsulHandler") + } + if o.ServiceDiscoveryGetConsulsHandler == nil { + unregistered = append(unregistered, "service_discovery.GetConsulsHandler") + } + if o.SslRuntimeGetCrlHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.GetCrlHandler") + } + if o.CrtLoadGetCrtLoadHandler == nil { + unregistered = append(unregistered, "crt_load.GetCrtLoadHandler") + } + if o.CrtLoadGetCrtLoadsHandler == nil { + unregistered = append(unregistered, "crt_load.GetCrtLoadsHandler") + } + if o.CrtStoreGetCrtStoreHandler == nil { + unregistered = append(unregistered, "crt_store.GetCrtStoreHandler") + } + if o.CrtStoreGetCrtStoresHandler == nil { + unregistered = append(unregistered, "crt_store.GetCrtStoresHandler") + } + if o.DeclareCaptureGetDeclareCaptureHandler == nil { + unregistered = append(unregistered, "declare_capture.GetDeclareCaptureHandler") + } + if o.DeclareCaptureGetDeclareCapturesHandler == nil { + unregistered = append(unregistered, "declare_capture.GetDeclareCapturesHandler") + } + if o.DefaultsGetDefaultsSectionHandler == nil { + unregistered = append(unregistered, "defaults.GetDefaultsSectionHandler") + } + if o.DefaultsGetDefaultsSectionsHandler == nil { + unregistered = append(unregistered, "defaults.GetDefaultsSectionsHandler") + } + if o.DgramBindGetDgramBindHandler == nil { + unregistered = append(unregistered, "dgram_bind.GetDgramBindHandler") + } + if o.DgramBindGetDgramBindsHandler == nil { + unregistered = append(unregistered, "dgram_bind.GetDgramBindsHandler") + } + if o.FCGIAppGetFCGIAppHandler == nil { + unregistered = append(unregistered, "fcgi_app.GetFCGIAppHandler") + } + if o.FCGIAppGetFCGIAppsHandler == nil { + unregistered = append(unregistered, "fcgi_app.GetFCGIAppsHandler") + } + if o.FilterGetFilterBackendHandler == nil { + unregistered = append(unregistered, "filter.GetFilterBackendHandler") + } + if o.FilterGetFilterFrontendHandler == nil { + unregistered = append(unregistered, "filter.GetFilterFrontendHandler") + } + if o.FrontendGetFrontendHandler == nil { + unregistered = append(unregistered, "frontend.GetFrontendHandler") + } + if o.FrontendGetFrontendsHandler == nil { + unregistered = append(unregistered, "frontend.GetFrontendsHandler") + } + if o.GlobalGetGlobalHandler == nil { + unregistered = append(unregistered, "global.GetGlobalHandler") + } + if o.GroupGetGroupHandler == nil { + unregistered = append(unregistered, "group.GetGroupHandler") + } + if o.GroupGetGroupsHandler == nil { + unregistered = append(unregistered, "group.GetGroupsHandler") + } + if o.ConfigurationGetHAProxyConfigurationHandler == nil { + unregistered = append(unregistered, "configuration.GetHAProxyConfigurationHandler") + } + if o.HTTPAfterResponseRuleGetHTTPAfterResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.GetHTTPAfterResponseRuleBackendHandler") + } + if o.HTTPAfterResponseRuleGetHTTPAfterResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.GetHTTPAfterResponseRuleDefaultsHandler") + } + if o.HTTPAfterResponseRuleGetHTTPAfterResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.GetHTTPAfterResponseRuleFrontendHandler") + } + if o.HTTPCheckGetHTTPCheckBackendHandler == nil { + unregistered = append(unregistered, "http_check.GetHTTPCheckBackendHandler") + } + if o.HTTPCheckGetHTTPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "http_check.GetHTTPCheckDefaultsHandler") + } + if o.HTTPErrorRuleGetHTTPErrorRuleBackendHandler == nil { + unregistered = append(unregistered, "http_error_rule.GetHTTPErrorRuleBackendHandler") + } + if o.HTTPErrorRuleGetHTTPErrorRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_error_rule.GetHTTPErrorRuleDefaultsHandler") + } + if o.HTTPErrorRuleGetHTTPErrorRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_error_rule.GetHTTPErrorRuleFrontendHandler") + } + if o.HTTPErrorsGetHTTPErrorsSectionHandler == nil { + unregistered = append(unregistered, "http_errors.GetHTTPErrorsSectionHandler") + } + if o.HTTPErrorsGetHTTPErrorsSectionsHandler == nil { + unregistered = append(unregistered, "http_errors.GetHTTPErrorsSectionsHandler") + } + if o.HTTPRequestRuleGetHTTPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "http_request_rule.GetHTTPRequestRuleBackendHandler") + } + if o.HTTPRequestRuleGetHTTPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_request_rule.GetHTTPRequestRuleDefaultsHandler") + } + if o.HTTPRequestRuleGetHTTPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_request_rule.GetHTTPRequestRuleFrontendHandler") + } + if o.HTTPResponseRuleGetHTTPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_response_rule.GetHTTPResponseRuleBackendHandler") + } + if o.HTTPResponseRuleGetHTTPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_response_rule.GetHTTPResponseRuleDefaultsHandler") + } + if o.HTTPResponseRuleGetHTTPResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_response_rule.GetHTTPResponseRuleFrontendHandler") + } + if o.DiscoveryGetHaproxyEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetHaproxyEndpointsHandler") + } + if o.InformationGetHaproxyProcessInfoHandler == nil { + unregistered = append(unregistered, "information.GetHaproxyProcessInfoHandler") + } + if o.HealthGetHealthHandler == nil { + unregistered = append(unregistered, "health.GetHealthHandler") + } + if o.InformationGetInfoHandler == nil { + unregistered = append(unregistered, "information.GetInfoHandler") + } + if o.LogForwardGetLogForwardHandler == nil { + unregistered = append(unregistered, "log_forward.GetLogForwardHandler") + } + if o.LogForwardGetLogForwardsHandler == nil { + unregistered = append(unregistered, "log_forward.GetLogForwardsHandler") + } + if o.LogProfileGetLogProfileHandler == nil { + unregistered = append(unregistered, "log_profile.GetLogProfileHandler") + } + if o.LogProfileGetLogProfilesHandler == nil { + unregistered = append(unregistered, "log_profile.GetLogProfilesHandler") + } + if o.LogTargetGetLogTargetBackendHandler == nil { + unregistered = append(unregistered, "log_target.GetLogTargetBackendHandler") + } + if o.LogTargetGetLogTargetDefaultsHandler == nil { + unregistered = append(unregistered, "log_target.GetLogTargetDefaultsHandler") + } + if o.LogTargetGetLogTargetFrontendHandler == nil { + unregistered = append(unregistered, "log_target.GetLogTargetFrontendHandler") + } + if o.LogTargetGetLogTargetGlobalHandler == nil { + unregistered = append(unregistered, "log_target.GetLogTargetGlobalHandler") + } + if o.LogTargetGetLogTargetLogForwardHandler == nil { + unregistered = append(unregistered, "log_target.GetLogTargetLogForwardHandler") + } + if o.LogTargetGetLogTargetPeerHandler == nil { + unregistered = append(unregistered, "log_target.GetLogTargetPeerHandler") + } + if o.MailerEntryGetMailerEntriesHandler == nil { + unregistered = append(unregistered, "mailer_entry.GetMailerEntriesHandler") + } + if o.MailerEntryGetMailerEntryHandler == nil { + unregistered = append(unregistered, "mailer_entry.GetMailerEntryHandler") + } + if o.MailersGetMailersSectionHandler == nil { + unregistered = append(unregistered, "mailers.GetMailersSectionHandler") + } + if o.MailersGetMailersSectionsHandler == nil { + unregistered = append(unregistered, "mailers.GetMailersSectionsHandler") + } + if o.NameserverGetNameserverHandler == nil { + unregistered = append(unregistered, "nameserver.GetNameserverHandler") + } + if o.NameserverGetNameserversHandler == nil { + unregistered = append(unregistered, "nameserver.GetNameserversHandler") + } + if o.MapsGetOneRuntimeMapHandler == nil { + unregistered = append(unregistered, "maps.GetOneRuntimeMapHandler") + } + if o.SpoeGetOneSpoeFileHandler == nil { + unregistered = append(unregistered, "spoe.GetOneSpoeFileHandler") + } + if o.StorageGetOneStorageGeneralFileHandler == nil { + unregistered = append(unregistered, "storage.GetOneStorageGeneralFileHandler") + } + if o.StorageGetOneStorageMapHandler == nil { + unregistered = append(unregistered, "storage.GetOneStorageMapHandler") + } + if o.StorageGetOneStorageSSLCertificateHandler == nil { + unregistered = append(unregistered, "storage.GetOneStorageSSLCertificateHandler") + } + if o.StorageGetOneStorageSSLCrtListFileHandler == nil { + unregistered = append(unregistered, "storage.GetOneStorageSSLCrtListFileHandler") + } + if o.SpecificationOpenapiv3GetOpenapiv3SpecificationHandler == nil { + unregistered = append(unregistered, "specification_openapiv3.GetOpenapiv3SpecificationHandler") + } + if o.PeerEntryGetPeerEntriesHandler == nil { + unregistered = append(unregistered, "peer_entry.GetPeerEntriesHandler") + } + if o.PeerEntryGetPeerEntryHandler == nil { + unregistered = append(unregistered, "peer_entry.GetPeerEntryHandler") + } + if o.PeerGetPeerSectionHandler == nil { + unregistered = append(unregistered, "peer.GetPeerSectionHandler") + } + if o.PeerGetPeerSectionsHandler == nil { + unregistered = append(unregistered, "peer.GetPeerSectionsHandler") + } + if o.ProcessManagerGetProgramHandler == nil { + unregistered = append(unregistered, "process_manager.GetProgramHandler") + } + if o.ProcessManagerGetProgramsHandler == nil { + unregistered = append(unregistered, "process_manager.GetProgramsHandler") + } + if o.QUICInitialRuleGetQUICInitialRuleDefaultsHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.GetQUICInitialRuleDefaultsHandler") + } + if o.QUICInitialRuleGetQUICInitialRuleFrontendHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.GetQUICInitialRuleFrontendHandler") + } + if o.ReloadsGetReloadHandler == nil { + unregistered = append(unregistered, "reloads.GetReloadHandler") + } + if o.ReloadsGetReloadsHandler == nil { + unregistered = append(unregistered, "reloads.GetReloadsHandler") + } + if o.ResolverGetResolverHandler == nil { + unregistered = append(unregistered, "resolver.GetResolverHandler") + } + if o.ResolverGetResolversHandler == nil { + unregistered = append(unregistered, "resolver.GetResolversHandler") + } + if o.RingGetRingHandler == nil { + unregistered = append(unregistered, "ring.GetRingHandler") + } + if o.RingGetRingsHandler == nil { + unregistered = append(unregistered, "ring.GetRingsHandler") + } + if o.DiscoveryGetRuntimeEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetRuntimeEndpointsHandler") + } + if o.MapsGetRuntimeMapEntryHandler == nil { + unregistered = append(unregistered, "maps.GetRuntimeMapEntryHandler") + } + if o.ServerGetRuntimeServerHandler == nil { + unregistered = append(unregistered, "server.GetRuntimeServerHandler") + } + if o.SslFrontUseGetSSLFrontUseHandler == nil { + unregistered = append(unregistered, "s_s_l_front_use.GetSSLFrontUseHandler") + } + if o.ServerGetServerBackendHandler == nil { + unregistered = append(unregistered, "server.GetServerBackendHandler") + } + if o.ServerGetServerPeerHandler == nil { + unregistered = append(unregistered, "server.GetServerPeerHandler") + } + if o.ServerGetServerRingHandler == nil { + unregistered = append(unregistered, "server.GetServerRingHandler") + } + if o.ServerSwitchingRuleGetServerSwitchingRuleHandler == nil { + unregistered = append(unregistered, "server_switching_rule.GetServerSwitchingRuleHandler") + } + if o.ServerSwitchingRuleGetServerSwitchingRulesHandler == nil { + unregistered = append(unregistered, "server_switching_rule.GetServerSwitchingRulesHandler") + } + if o.ServerTemplateGetServerTemplateHandler == nil { + unregistered = append(unregistered, "server_template.GetServerTemplateHandler") + } + if o.ServerTemplateGetServerTemplatesHandler == nil { + unregistered = append(unregistered, "server_template.GetServerTemplatesHandler") + } + if o.DiscoveryGetServicesEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetServicesEndpointsHandler") + } + if o.SitesGetSiteHandler == nil { + unregistered = append(unregistered, "sites.GetSiteHandler") + } + if o.SitesGetSitesHandler == nil { + unregistered = append(unregistered, "sites.GetSitesHandler") + } + if o.SpecificationGetSpecificationHandler == nil { + unregistered = append(unregistered, "specification.GetSpecificationHandler") + } + if o.SpoeGetSpoeAgentHandler == nil { + unregistered = append(unregistered, "spoe.GetSpoeAgentHandler") + } + if o.SpoeGetSpoeConfigurationVersionHandler == nil { + unregistered = append(unregistered, "spoe.GetSpoeConfigurationVersionHandler") + } + if o.DiscoveryGetSpoeEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetSpoeEndpointsHandler") + } + if o.SpoeGetSpoeGroupHandler == nil { + unregistered = append(unregistered, "spoe.GetSpoeGroupHandler") + } + if o.SpoeGetSpoeMessageHandler == nil { + unregistered = append(unregistered, "spoe.GetSpoeMessageHandler") + } + if o.SpoeGetSpoeScopeHandler == nil { + unregistered = append(unregistered, "spoe.GetSpoeScopeHandler") + } + if o.SpoeTransactionsGetSpoeTransactionHandler == nil { + unregistered = append(unregistered, "spoe_transactions.GetSpoeTransactionHandler") + } + if o.StatsGetStatsHandler == nil { + unregistered = append(unregistered, "stats.GetStatsHandler") + } + if o.DiscoveryGetStatsEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetStatsEndpointsHandler") + } + if o.StickRuleGetStickRuleHandler == nil { + unregistered = append(unregistered, "stick_rule.GetStickRuleHandler") + } + if o.StickRuleGetStickRulesHandler == nil { + unregistered = append(unregistered, "stick_rule.GetStickRulesHandler") + } + if o.StickTableGetStickTableHandler == nil { + unregistered = append(unregistered, "stick_table.GetStickTableHandler") + } + if o.StickTableGetStickTableEntriesHandler == nil { + unregistered = append(unregistered, "stick_table.GetStickTableEntriesHandler") + } + if o.StickTableGetStickTablesHandler == nil { + unregistered = append(unregistered, "stick_table.GetStickTablesHandler") + } + if o.DiscoveryGetStorageEndpointsHandler == nil { + unregistered = append(unregistered, "discovery.GetStorageEndpointsHandler") + } + if o.TCPCheckGetTCPCheckBackendHandler == nil { + unregistered = append(unregistered, "tcp_check.GetTCPCheckBackendHandler") + } + if o.TCPCheckGetTCPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_check.GetTCPCheckDefaultsHandler") + } + if o.TCPRequestRuleGetTCPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.GetTCPRequestRuleBackendHandler") + } + if o.TCPRequestRuleGetTCPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.GetTCPRequestRuleDefaultsHandler") + } + if o.TCPRequestRuleGetTCPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.GetTCPRequestRuleFrontendHandler") + } + if o.TCPResponseRuleGetTCPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.GetTCPResponseRuleBackendHandler") + } + if o.TCPResponseRuleGetTCPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.GetTCPResponseRuleDefaultsHandler") + } + if o.TableGetTableHandler == nil { + unregistered = append(unregistered, "table.GetTableHandler") + } + if o.TableGetTablesHandler == nil { + unregistered = append(unregistered, "table.GetTablesHandler") + } + if o.TracesGetTracesHandler == nil { + unregistered = append(unregistered, "traces.GetTracesHandler") + } + if o.TransactionsGetTransactionHandler == nil { + unregistered = append(unregistered, "transactions.GetTransactionHandler") + } + if o.TransactionsGetTransactionsHandler == nil { + unregistered = append(unregistered, "transactions.GetTransactionsHandler") + } + if o.UserGetUserHandler == nil { + unregistered = append(unregistered, "user.GetUserHandler") + } + if o.UserlistGetUserlistHandler == nil { + unregistered = append(unregistered, "userlist.GetUserlistHandler") + } + if o.UserlistGetUserlistsHandler == nil { + unregistered = append(unregistered, "userlist.GetUserlistsHandler") + } + if o.UserGetUsersHandler == nil { + unregistered = append(unregistered, "user.GetUsersHandler") + } + if o.ClusterInitiateCertificateRefreshHandler == nil { + unregistered = append(unregistered, "cluster.InitiateCertificateRefreshHandler") + } + if o.ClusterPostClusterHandler == nil { + unregistered = append(unregistered, "cluster.PostClusterHandler") + } + if o.ConfigurationPostHAProxyConfigurationHandler == nil { + unregistered = append(unregistered, "configuration.PostHAProxyConfigurationHandler") + } + if o.AcmeRuntimeRenewAcmeCertificateHandler == nil { + unregistered = append(unregistered, "acme_runtime.RenewAcmeCertificateHandler") + } + if o.ServiceDiscoveryReplaceAWSRegionHandler == nil { + unregistered = append(unregistered, "service_discovery.ReplaceAWSRegionHandler") + } + if o.ACLReplaceACLBackendHandler == nil { + unregistered = append(unregistered, "acl.ReplaceACLBackendHandler") + } + if o.ACLReplaceACLDefaultsHandler == nil { + unregistered = append(unregistered, "acl.ReplaceACLDefaultsHandler") + } + if o.ACLReplaceACLFCGIAppHandler == nil { + unregistered = append(unregistered, "acl.ReplaceACLFCGIAppHandler") + } + if o.ACLReplaceACLFrontendHandler == nil { + unregistered = append(unregistered, "acl.ReplaceACLFrontendHandler") + } + if o.ACLReplaceAllACLBackendHandler == nil { + unregistered = append(unregistered, "acl.ReplaceAllACLBackendHandler") + } + if o.ACLReplaceAllACLDefaultsHandler == nil { + unregistered = append(unregistered, "acl.ReplaceAllACLDefaultsHandler") + } + if o.ACLReplaceAllACLFCGIAppHandler == nil { + unregistered = append(unregistered, "acl.ReplaceAllACLFCGIAppHandler") + } + if o.ACLReplaceAllACLFrontendHandler == nil { + unregistered = append(unregistered, "acl.ReplaceAllACLFrontendHandler") + } + if o.FilterReplaceAllFilterBackendHandler == nil { + unregistered = append(unregistered, "filter.ReplaceAllFilterBackendHandler") + } + if o.FilterReplaceAllFilterFrontendHandler == nil { + unregistered = append(unregistered, "filter.ReplaceAllFilterFrontendHandler") + } + if o.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.ReplaceAllHTTPAfterResponseRuleBackendHandler") + } + if o.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.ReplaceAllHTTPAfterResponseRuleDefaultsHandler") + } + if o.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.ReplaceAllHTTPAfterResponseRuleFrontendHandler") + } + if o.HTTPCheckReplaceAllHTTPCheckBackendHandler == nil { + unregistered = append(unregistered, "http_check.ReplaceAllHTTPCheckBackendHandler") + } + if o.HTTPCheckReplaceAllHTTPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "http_check.ReplaceAllHTTPCheckDefaultsHandler") + } + if o.HTTPErrorRuleReplaceAllHTTPErrorRuleBackendHandler == nil { + unregistered = append(unregistered, "http_error_rule.ReplaceAllHTTPErrorRuleBackendHandler") + } + if o.HTTPErrorRuleReplaceAllHTTPErrorRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_error_rule.ReplaceAllHTTPErrorRuleDefaultsHandler") + } + if o.HTTPErrorRuleReplaceAllHTTPErrorRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_error_rule.ReplaceAllHTTPErrorRuleFrontendHandler") + } + if o.HTTPRequestRuleReplaceAllHTTPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "http_request_rule.ReplaceAllHTTPRequestRuleBackendHandler") + } + if o.HTTPRequestRuleReplaceAllHTTPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_request_rule.ReplaceAllHTTPRequestRuleDefaultsHandler") + } + if o.HTTPRequestRuleReplaceAllHTTPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_request_rule.ReplaceAllHTTPRequestRuleFrontendHandler") + } + if o.HTTPResponseRuleReplaceAllHTTPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_response_rule.ReplaceAllHTTPResponseRuleBackendHandler") + } + if o.HTTPResponseRuleReplaceAllHTTPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_response_rule.ReplaceAllHTTPResponseRuleDefaultsHandler") + } + if o.HTTPResponseRuleReplaceAllHTTPResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_response_rule.ReplaceAllHTTPResponseRuleFrontendHandler") + } + if o.LogTargetReplaceAllLogTargetBackendHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceAllLogTargetBackendHandler") + } + if o.LogTargetReplaceAllLogTargetDefaultsHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceAllLogTargetDefaultsHandler") + } + if o.LogTargetReplaceAllLogTargetFrontendHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceAllLogTargetFrontendHandler") + } + if o.LogTargetReplaceAllLogTargetGlobalHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceAllLogTargetGlobalHandler") + } + if o.LogTargetReplaceAllLogTargetLogForwardHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceAllLogTargetLogForwardHandler") + } + if o.LogTargetReplaceAllLogTargetPeerHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceAllLogTargetPeerHandler") + } + if o.QUICInitialRuleReplaceAllQUICInitialRuleDefaultsHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.ReplaceAllQUICInitialRuleDefaultsHandler") + } + if o.QUICInitialRuleReplaceAllQUICInitialRuleFrontendHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.ReplaceAllQUICInitialRuleFrontendHandler") + } + if o.TCPCheckReplaceAllTCPCheckBackendHandler == nil { + unregistered = append(unregistered, "tcp_check.ReplaceAllTCPCheckBackendHandler") + } + if o.TCPCheckReplaceAllTCPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_check.ReplaceAllTCPCheckDefaultsHandler") + } + if o.TCPRequestRuleReplaceAllTCPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.ReplaceAllTCPRequestRuleBackendHandler") + } + if o.TCPRequestRuleReplaceAllTCPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.ReplaceAllTCPRequestRuleDefaultsHandler") + } + if o.TCPRequestRuleReplaceAllTCPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.ReplaceAllTCPRequestRuleFrontendHandler") + } + if o.TCPResponseRuleReplaceAllTCPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.ReplaceAllTCPResponseRuleBackendHandler") + } + if o.TCPResponseRuleReplaceAllTCPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.ReplaceAllTCPResponseRuleDefaultsHandler") + } + if o.BackendReplaceBackendHandler == nil { + unregistered = append(unregistered, "backend.ReplaceBackendHandler") + } + if o.BackendSwitchingRuleReplaceBackendSwitchingRuleHandler == nil { + unregistered = append(unregistered, "backend_switching_rule.ReplaceBackendSwitchingRuleHandler") + } + if o.BackendSwitchingRuleReplaceBackendSwitchingRulesHandler == nil { + unregistered = append(unregistered, "backend_switching_rule.ReplaceBackendSwitchingRulesHandler") + } + if o.BindReplaceBindFrontendHandler == nil { + unregistered = append(unregistered, "bind.ReplaceBindFrontendHandler") + } + if o.BindReplaceBindLogForwardHandler == nil { + unregistered = append(unregistered, "bind.ReplaceBindLogForwardHandler") + } + if o.BindReplaceBindPeerHandler == nil { + unregistered = append(unregistered, "bind.ReplaceBindPeerHandler") + } + if o.CacheReplaceCacheHandler == nil { + unregistered = append(unregistered, "cache.ReplaceCacheHandler") + } + if o.SslRuntimeReplaceCertHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.ReplaceCertHandler") + } + if o.ServiceDiscoveryReplaceConsulHandler == nil { + unregistered = append(unregistered, "service_discovery.ReplaceConsulHandler") + } + if o.SslRuntimeReplaceCrlHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.ReplaceCrlHandler") + } + if o.CrtLoadReplaceCrtLoadHandler == nil { + unregistered = append(unregistered, "crt_load.ReplaceCrtLoadHandler") + } + if o.DeclareCaptureReplaceDeclareCaptureHandler == nil { + unregistered = append(unregistered, "declare_capture.ReplaceDeclareCaptureHandler") + } + if o.DeclareCaptureReplaceDeclareCapturesHandler == nil { + unregistered = append(unregistered, "declare_capture.ReplaceDeclareCapturesHandler") + } + if o.DefaultsReplaceDefaultsSectionHandler == nil { + unregistered = append(unregistered, "defaults.ReplaceDefaultsSectionHandler") + } + if o.DgramBindReplaceDgramBindHandler == nil { + unregistered = append(unregistered, "dgram_bind.ReplaceDgramBindHandler") + } + if o.FCGIAppReplaceFCGIAppHandler == nil { + unregistered = append(unregistered, "fcgi_app.ReplaceFCGIAppHandler") + } + if o.FilterReplaceFilterBackendHandler == nil { + unregistered = append(unregistered, "filter.ReplaceFilterBackendHandler") + } + if o.FilterReplaceFilterFrontendHandler == nil { + unregistered = append(unregistered, "filter.ReplaceFilterFrontendHandler") + } + if o.FrontendReplaceFrontendHandler == nil { + unregistered = append(unregistered, "frontend.ReplaceFrontendHandler") + } + if o.GlobalReplaceGlobalHandler == nil { + unregistered = append(unregistered, "global.ReplaceGlobalHandler") + } + if o.GroupReplaceGroupHandler == nil { + unregistered = append(unregistered, "group.ReplaceGroupHandler") + } + if o.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.ReplaceHTTPAfterResponseRuleBackendHandler") + } + if o.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.ReplaceHTTPAfterResponseRuleDefaultsHandler") + } + if o.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_after_response_rule.ReplaceHTTPAfterResponseRuleFrontendHandler") + } + if o.HTTPCheckReplaceHTTPCheckBackendHandler == nil { + unregistered = append(unregistered, "http_check.ReplaceHTTPCheckBackendHandler") + } + if o.HTTPCheckReplaceHTTPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "http_check.ReplaceHTTPCheckDefaultsHandler") + } + if o.HTTPErrorRuleReplaceHTTPErrorRuleBackendHandler == nil { + unregistered = append(unregistered, "http_error_rule.ReplaceHTTPErrorRuleBackendHandler") + } + if o.HTTPErrorRuleReplaceHTTPErrorRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_error_rule.ReplaceHTTPErrorRuleDefaultsHandler") + } + if o.HTTPErrorRuleReplaceHTTPErrorRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_error_rule.ReplaceHTTPErrorRuleFrontendHandler") + } + if o.HTTPErrorsReplaceHTTPErrorsSectionHandler == nil { + unregistered = append(unregistered, "http_errors.ReplaceHTTPErrorsSectionHandler") + } + if o.HTTPRequestRuleReplaceHTTPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "http_request_rule.ReplaceHTTPRequestRuleBackendHandler") + } + if o.HTTPRequestRuleReplaceHTTPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_request_rule.ReplaceHTTPRequestRuleDefaultsHandler") + } + if o.HTTPRequestRuleReplaceHTTPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_request_rule.ReplaceHTTPRequestRuleFrontendHandler") + } + if o.HTTPResponseRuleReplaceHTTPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "http_response_rule.ReplaceHTTPResponseRuleBackendHandler") + } + if o.HTTPResponseRuleReplaceHTTPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "http_response_rule.ReplaceHTTPResponseRuleDefaultsHandler") + } + if o.HTTPResponseRuleReplaceHTTPResponseRuleFrontendHandler == nil { + unregistered = append(unregistered, "http_response_rule.ReplaceHTTPResponseRuleFrontendHandler") + } + if o.LogForwardReplaceLogForwardHandler == nil { + unregistered = append(unregistered, "log_forward.ReplaceLogForwardHandler") + } + if o.LogTargetReplaceLogTargetBackendHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceLogTargetBackendHandler") + } + if o.LogTargetReplaceLogTargetDefaultsHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceLogTargetDefaultsHandler") + } + if o.LogTargetReplaceLogTargetFrontendHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceLogTargetFrontendHandler") + } + if o.LogTargetReplaceLogTargetGlobalHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceLogTargetGlobalHandler") + } + if o.LogTargetReplaceLogTargetLogForwardHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceLogTargetLogForwardHandler") + } + if o.LogTargetReplaceLogTargetPeerHandler == nil { + unregistered = append(unregistered, "log_target.ReplaceLogTargetPeerHandler") + } + if o.MailerEntryReplaceMailerEntryHandler == nil { + unregistered = append(unregistered, "mailer_entry.ReplaceMailerEntryHandler") + } + if o.NameserverReplaceNameserverHandler == nil { + unregistered = append(unregistered, "nameserver.ReplaceNameserverHandler") + } + if o.PeerEntryReplacePeerEntryHandler == nil { + unregistered = append(unregistered, "peer_entry.ReplacePeerEntryHandler") + } + if o.ProcessManagerReplaceProgramHandler == nil { + unregistered = append(unregistered, "process_manager.ReplaceProgramHandler") + } + if o.QUICInitialRuleReplaceQUICInitialRuleDefaultsHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.ReplaceQUICInitialRuleDefaultsHandler") + } + if o.QUICInitialRuleReplaceQUICInitialRuleFrontendHandler == nil { + unregistered = append(unregistered, "quic_initial_rule.ReplaceQUICInitialRuleFrontendHandler") + } + if o.ResolverReplaceResolverHandler == nil { + unregistered = append(unregistered, "resolver.ReplaceResolverHandler") + } + if o.RingReplaceRingHandler == nil { + unregistered = append(unregistered, "ring.ReplaceRingHandler") + } + if o.MapsReplaceRuntimeMapEntryHandler == nil { + unregistered = append(unregistered, "maps.ReplaceRuntimeMapEntryHandler") + } + if o.ServerReplaceRuntimeServerHandler == nil { + unregistered = append(unregistered, "server.ReplaceRuntimeServerHandler") + } + if o.SslFrontUseReplaceSSLFrontUseHandler == nil { + unregistered = append(unregistered, "s_s_l_front_use.ReplaceSSLFrontUseHandler") + } + if o.ServerReplaceServerBackendHandler == nil { + unregistered = append(unregistered, "server.ReplaceServerBackendHandler") + } + if o.ServerReplaceServerPeerHandler == nil { + unregistered = append(unregistered, "server.ReplaceServerPeerHandler") + } + if o.ServerReplaceServerRingHandler == nil { + unregistered = append(unregistered, "server.ReplaceServerRingHandler") + } + if o.ServerSwitchingRuleReplaceServerSwitchingRuleHandler == nil { + unregistered = append(unregistered, "server_switching_rule.ReplaceServerSwitchingRuleHandler") + } + if o.ServerSwitchingRuleReplaceServerSwitchingRulesHandler == nil { + unregistered = append(unregistered, "server_switching_rule.ReplaceServerSwitchingRulesHandler") + } + if o.ServerTemplateReplaceServerTemplateHandler == nil { + unregistered = append(unregistered, "server_template.ReplaceServerTemplateHandler") + } + if o.SitesReplaceSiteHandler == nil { + unregistered = append(unregistered, "sites.ReplaceSiteHandler") + } + if o.SpoeReplaceSpoeAgentHandler == nil { + unregistered = append(unregistered, "spoe.ReplaceSpoeAgentHandler") + } + if o.SpoeReplaceSpoeGroupHandler == nil { + unregistered = append(unregistered, "spoe.ReplaceSpoeGroupHandler") + } + if o.SpoeReplaceSpoeMessageHandler == nil { + unregistered = append(unregistered, "spoe.ReplaceSpoeMessageHandler") + } + if o.StickRuleReplaceStickRuleHandler == nil { + unregistered = append(unregistered, "stick_rule.ReplaceStickRuleHandler") + } + if o.StickRuleReplaceStickRulesHandler == nil { + unregistered = append(unregistered, "stick_rule.ReplaceStickRulesHandler") + } + if o.StorageReplaceStorageGeneralFileHandler == nil { + unregistered = append(unregistered, "storage.ReplaceStorageGeneralFileHandler") + } + if o.StorageReplaceStorageMapFileHandler == nil { + unregistered = append(unregistered, "storage.ReplaceStorageMapFileHandler") + } + if o.StorageReplaceStorageSSLCertificateHandler == nil { + unregistered = append(unregistered, "storage.ReplaceStorageSSLCertificateHandler") + } + if o.StorageReplaceStorageSSLCrtListFileHandler == nil { + unregistered = append(unregistered, "storage.ReplaceStorageSSLCrtListFileHandler") + } + if o.TCPCheckReplaceTCPCheckBackendHandler == nil { + unregistered = append(unregistered, "tcp_check.ReplaceTCPCheckBackendHandler") + } + if o.TCPCheckReplaceTCPCheckDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_check.ReplaceTCPCheckDefaultsHandler") + } + if o.TCPRequestRuleReplaceTCPRequestRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.ReplaceTCPRequestRuleBackendHandler") + } + if o.TCPRequestRuleReplaceTCPRequestRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.ReplaceTCPRequestRuleDefaultsHandler") + } + if o.TCPRequestRuleReplaceTCPRequestRuleFrontendHandler == nil { + unregistered = append(unregistered, "tcp_request_rule.ReplaceTCPRequestRuleFrontendHandler") + } + if o.TCPResponseRuleReplaceTCPResponseRuleBackendHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.ReplaceTCPResponseRuleBackendHandler") + } + if o.TCPResponseRuleReplaceTCPResponseRuleDefaultsHandler == nil { + unregistered = append(unregistered, "tcp_response_rule.ReplaceTCPResponseRuleDefaultsHandler") + } + if o.TableReplaceTableHandler == nil { + unregistered = append(unregistered, "table.ReplaceTableHandler") + } + if o.TracesReplaceTracesHandler == nil { + unregistered = append(unregistered, "traces.ReplaceTracesHandler") + } + if o.UserReplaceUserHandler == nil { + unregistered = append(unregistered, "user.ReplaceUserHandler") + } + if o.SslRuntimeSetCaFileHandler == nil { + unregistered = append(unregistered, "s_s_l_runtime.SetCaFileHandler") + } + if o.StickTableSetStickTableEntriesHandler == nil { + unregistered = append(unregistered, "stick_table.SetStickTableEntriesHandler") + } + if o.MapsShowRuntimeMapHandler == nil { + unregistered = append(unregistered, "maps.ShowRuntimeMapHandler") + } + if o.SpoeTransactionsStartSpoeTransactionHandler == nil { + unregistered = append(unregistered, "spoe_transactions.StartSpoeTransactionHandler") + } + if o.TransactionsStartTransactionHandler == nil { + unregistered = append(unregistered, "transactions.StartTransactionHandler") + } + + if len(unregistered) > 0 { + return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) + } - // ServeError is called when an error is received, there is a default handler - // but you can set your own with this - ServeError func(http.ResponseWriter, *http.Request, error) + return nil +} - // ServerShutdown is called when the HTTP(S) server is shut down and done - // handling all active connections and does not accept connections any more - ServerShutdown func() +// ServeErrorFor gets a error handler for a given operation id +func (o *DataPlaneAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return o.ServeError +} - // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (o *DataPlaneAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + result := make(map[string]runtime.Authenticator) + for name := range schemes { + switch name { + case "basic_auth": + result[name] = o.BasicAuthenticator(o.BasicAuthAuth) - // User defined logger function. - Logger func(string, ...interface{}) + } + } + return result } -// SetDefaultProduces sets the default produces media type -func (o *DataPlaneAPI) SetDefaultProduces(mediaType string) { - o.defaultProduces = mediaType +// Authorizer returns the registered authorizer +func (o *DataPlaneAPI) Authorizer() runtime.Authorizer { + return o.APIAuthorizer } -// SetDefaultConsumes returns the default consumes media type -func (o *DataPlaneAPI) SetDefaultConsumes(mediaType string) { - o.defaultConsumes = mediaType -} +// ConsumersFor gets the consumers for the specified media types. +// MIME type parameters are ignored here. +func (o *DataPlaneAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { + result := make(map[string]runtime.Consumer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONConsumer + case "multipart/form-data": + result["multipart/form-data"] = o.MultipartformConsumer + case "text/plain": + result["text/plain"] = o.TxtConsumer + } -// SetSpec sets a spec that will be served for the clients. -func (o *DataPlaneAPI) SetSpec(spec *loads.Document) { - o.spec = spec + if c, ok := o.customConsumers[mt]; ok { + result[mt] = c + } + } + return result } -// DefaultProduces returns the default produces media type -func (o *DataPlaneAPI) DefaultProduces() string { - return o.defaultProduces -} +// ProducersFor gets the producers for the specified media types. +// MIME type parameters are ignored here. +func (o *DataPlaneAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { + result := make(map[string]runtime.Producer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/octet-stream": + result["application/octet-stream"] = o.BinProducer + case "application/json": + result["application/json"] = o.JSONProducer + case "text/plain": + result["text/plain"] = o.TxtProducer + } -// DefaultConsumes returns the default consumes media type -func (o *DataPlaneAPI) DefaultConsumes() string { - return o.defaultConsumes + if p, ok := o.customProducers[mt]; ok { + result[mt] = p + } + } + return result } -// Formats returns the registered string formats -func (o *DataPlaneAPI) Formats() strfmt.Registry { - return o.formats +// HandlerFor gets a http.Handler for the provided operation method and path +func (o *DataPlaneAPI) HandlerFor(method, path string) (http.Handler, bool) { + if o.handlers == nil { + return nil, false + } + um := strings.ToUpper(method) + if _, ok := o.handlers[um]; !ok { + return nil, false + } + if path == "/" { + path = "" + } + h, ok := o.handlers[um][path] + return h, ok } -// RegisterFormat registers a custom format validator -func (o *DataPlaneAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { - o.formats.Add(name, format, validator) +// Context returns the middleware context for the data plane API +func (o *DataPlaneAPI) Context() *middleware.Context { + if o.context == nil { + o.context = middleware.NewRoutableContext(o.spec, o, nil) + } + + return o.context } -// Validate validates the registrations in the DataPlaneAPI -func (o *DataPlaneAPI) Validate() error { - var unregistered []string +func (o *DataPlaneAPI) initHandlerCache() { + o.Context() // don't care about the result, just that the initialization happened + if o.handlers == nil { + o.handlers = make(map[string]map[string]http.Handler) + } - if o.JSONConsumer == nil { - unregistered = append(unregistered, "JSONConsumer") + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/storage/ssl_crt_lists/{name}/entries"] = storage.NewCreateStorageSSLCrtListEntry(o.context, o.StorageCreateStorageSSLCrtListEntryHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/acls/{parent_name}/entries/{id}"] = acl_runtime.NewDeleteServicesHaproxyRuntimeAclsParentNameEntriesID(o.context, o.ACLRuntimeDeleteServicesHaproxyRuntimeAclsParentNameEntriesIDHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/storage/ssl_crt_lists/{name}/entries"] = storage.NewDeleteStorageSSLCrtListEntry(o.context, o.StorageDeleteStorageSSLCrtListEntryHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/acls"] = acl_runtime.NewGetServicesHaproxyRuntimeAcls(o.context, o.ACLRuntimeGetServicesHaproxyRuntimeAclsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/acls/{id}"] = acl_runtime.NewGetServicesHaproxyRuntimeAclsID(o.context, o.ACLRuntimeGetServicesHaproxyRuntimeAclsIDHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/acls/{parent_name}/entries"] = acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntries(o.context, o.ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/acls/{parent_name}/entries/{id}"] = acl_runtime.NewGetServicesHaproxyRuntimeAclsParentNameEntriesID(o.context, o.ACLRuntimeGetServicesHaproxyRuntimeAclsParentNameEntriesIDHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/storage/ssl_crt_lists/{name}/entries"] = storage.NewGetStorageSSLCrtListEntries(o.context, o.StorageGetStorageSSLCrtListEntriesHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/acls/{parent_name}/entries"] = acl_runtime.NewPostServicesHaproxyRuntimeAclsParentNameEntries(o.context, o.ACLRuntimePostServicesHaproxyRuntimeAclsParentNameEntriesHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/ssl_ca_files/{name}/entries"] = s_s_l_runtime.NewAddCaEntry(o.context, o.SslRuntimeAddCaEntryHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/ssl_crt_lists/entries"] = s_s_l_runtime.NewAddCrtListEntry(o.context, o.SslRuntimeAddCrtListEntryHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults"] = defaults.NewAddDefaultsSection(o.context, o.DefaultsAddDefaultsSectionHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/maps/{parent_name}/entries"] = maps.NewAddMapEntry(o.context, o.MapsAddMapEntryHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/runtime/acls/{parent_name}/entries"] = acl_runtime.NewAddPayloadRuntimeACL(o.context, o.ACLRuntimeAddPayloadRuntimeACLHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/runtime/maps/{name}"] = maps.NewAddPayloadRuntimeMap(o.context, o.MapsAddPayloadRuntimeMapHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/backends/{parent_name}/servers"] = serverops.NewAddRuntimeServer(o.context, o.ServerAddRuntimeServerHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/maps/{name}"] = maps.NewClearRuntimeMap(o.context, o.MapsClearRuntimeMapHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}"] = spoe_transactions.NewCommitSpoeTransaction(o.context, o.SpoeTransactionsCommitSpoeTransactionHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/transactions/{id}"] = transactions.NewCommitTransaction(o.context, o.TransactionsCommitTransactionHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/service_discovery/aws"] = service_discovery.NewCreateAWSRegion(o.context, o.ServiceDiscoveryCreateAWSRegionHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/acls/{index}"] = acl.NewCreateACLBackend(o.context, o.ACLCreateACLBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/acls/{index}"] = acl.NewCreateACLDefaults(o.context, o.ACLCreateACLDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}"] = acl.NewCreateACLFCGIApp(o.context, o.ACLCreateACLFCGIAppHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/acls/{index}"] = acl.NewCreateACLFrontend(o.context, o.ACLCreateACLFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/acme"] = acme.NewCreateAcmeProvider(o.context, o.AcmeCreateAcmeProviderHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends"] = backend.NewCreateBackend(o.context, o.BackendCreateBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}"] = backend_switching_rule.NewCreateBackendSwitchingRule(o.context, o.BackendSwitchingRuleCreateBackendSwitchingRuleHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/binds"] = bind.NewCreateBindFrontend(o.context, o.BindCreateBindFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/log_forwards/{parent_name}/binds"] = bind.NewCreateBindLogForward(o.context, o.BindCreateBindLogForwardHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/peers/{parent_name}/binds"] = bind.NewCreateBindPeer(o.context, o.BindCreateBindPeerHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/ssl_ca_files"] = s_s_l_runtime.NewCreateCaFile(o.context, o.SslRuntimeCreateCaFileHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/caches"] = cache.NewCreateCache(o.context, o.CacheCreateCacheHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/ssl_certs"] = s_s_l_runtime.NewCreateCert(o.context, o.SslRuntimeCreateCertHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/service_discovery/consul"] = service_discovery.NewCreateConsul(o.context, o.ServiceDiscoveryCreateConsulHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/ssl_crl_files"] = s_s_l_runtime.NewCreateCrl(o.context, o.SslRuntimeCreateCrlHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/crt_loads"] = crt_load.NewCreateCrtLoad(o.context, o.CrtLoadCreateCrtLoadHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/crt_stores"] = crt_store.NewCreateCrtStore(o.context, o.CrtStoreCreateCrtStoreHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/captures/{index}"] = declare_capture.NewCreateDeclareCapture(o.context, o.DeclareCaptureCreateDeclareCaptureHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/configuration/defaults"] = defaults.NewCreateDefaultsSection(o.context, o.DefaultsCreateDefaultsSectionHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds"] = dgram_bind.NewCreateDgramBind(o.context, o.DgramBindCreateDgramBindHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/fcgi_apps"] = fcgi_app.NewCreateFCGIApp(o.context, o.FCGIAppCreateFCGIAppHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/filters/{index}"] = filter.NewCreateFilterBackend(o.context, o.FilterCreateFilterBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/filters/{index}"] = filter.NewCreateFilterFrontend(o.context, o.FilterCreateFilterFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends"] = frontend.NewCreateFrontend(o.context, o.FrontendCreateFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/groups"] = group.NewCreateGroup(o.context, o.GroupCreateGroupHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewCreateHTTPAfterResponseRuleBackend(o.context, o.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewCreateHTTPAfterResponseRuleDefaults(o.context, o.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewCreateHTTPAfterResponseRuleFrontend(o.context, o.HTTPAfterResponseRuleCreateHTTPAfterResponseRuleFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}"] = http_check.NewCreateHTTPCheckBackend(o.context, o.HTTPCheckCreateHTTPCheckBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}"] = http_check.NewCreateHTTPCheckDefaults(o.context, o.HTTPCheckCreateHTTPCheckDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewCreateHTTPErrorRuleBackend(o.context, o.HTTPErrorRuleCreateHTTPErrorRuleBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewCreateHTTPErrorRuleDefaults(o.context, o.HTTPErrorRuleCreateHTTPErrorRuleDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewCreateHTTPErrorRuleFrontend(o.context, o.HTTPErrorRuleCreateHTTPErrorRuleFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/http_errors_sections"] = http_errors.NewCreateHTTPErrorsSection(o.context, o.HTTPErrorsCreateHTTPErrorsSectionHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewCreateHTTPRequestRuleBackend(o.context, o.HTTPRequestRuleCreateHTTPRequestRuleBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewCreateHTTPRequestRuleDefaults(o.context, o.HTTPRequestRuleCreateHTTPRequestRuleDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewCreateHTTPRequestRuleFrontend(o.context, o.HTTPRequestRuleCreateHTTPRequestRuleFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewCreateHTTPResponseRuleBackend(o.context, o.HTTPResponseRuleCreateHTTPResponseRuleBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewCreateHTTPResponseRuleDefaults(o.context, o.HTTPResponseRuleCreateHTTPResponseRuleDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewCreateHTTPResponseRuleFrontend(o.context, o.HTTPResponseRuleCreateHTTPResponseRuleFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/log_forwards"] = log_forward.NewCreateLogForward(o.context, o.LogForwardCreateLogForwardHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/log_profiles"] = log_profile.NewCreateLogProfile(o.context, o.LogProfileCreateLogProfileHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}"] = log_target.NewCreateLogTargetBackend(o.context, o.LogTargetCreateLogTargetBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}"] = log_target.NewCreateLogTargetDefaults(o.context, o.LogTargetCreateLogTargetDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}"] = log_target.NewCreateLogTargetFrontend(o.context, o.LogTargetCreateLogTargetFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/global/log_targets/{index}"] = log_target.NewCreateLogTargetGlobal(o.context, o.LogTargetCreateLogTargetGlobalHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}"] = log_target.NewCreateLogTargetLogForward(o.context, o.LogTargetCreateLogTargetLogForwardHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}"] = log_target.NewCreateLogTargetPeer(o.context, o.LogTargetCreateLogTargetPeerHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/mailer_entries"] = mailer_entry.NewCreateMailerEntry(o.context, o.MailerEntryCreateMailerEntryHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/mailers_section"] = mailers.NewCreateMailersSection(o.context, o.MailersCreateMailersSectionHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/nameservers"] = nameserver.NewCreateNameserver(o.context, o.NameserverCreateNameserverHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/peer_section"] = peer.NewCreatePeer(o.context, o.PeerCreatePeerHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/peer_entries"] = peer_entry.NewCreatePeerEntry(o.context, o.PeerEntryCreatePeerEntryHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/programs"] = process_manager.NewCreateProgram(o.context, o.ProcessManagerCreateProgramHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewCreateQUICInitialRuleDefaults(o.context, o.QUICInitialRuleCreateQUICInitialRuleDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewCreateQUICInitialRuleFrontend(o.context, o.QUICInitialRuleCreateQUICInitialRuleFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/resolvers"] = resolver.NewCreateResolver(o.context, o.ResolverCreateResolverHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/rings"] = ring.NewCreateRing(o.context, o.RingCreateRingHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses"] = s_s_l_front_use.NewCreateSSLFrontUse(o.context, o.SslFrontUseCreateSSLFrontUseHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/servers"] = serverops.NewCreateServerBackend(o.context, o.ServerCreateServerBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/peers/{parent_name}/servers"] = serverops.NewCreateServerPeer(o.context, o.ServerCreateServerPeerHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/rings/{parent_name}/servers"] = serverops.NewCreateServerRing(o.context, o.ServerCreateServerRingHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}"] = server_switching_rule.NewCreateServerSwitchingRule(o.context, o.ServerSwitchingRuleCreateServerSwitchingRuleHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/server_templates"] = server_template.NewCreateServerTemplate(o.context, o.ServerTemplateCreateServerTemplateHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/sites"] = sites.NewCreateSite(o.context, o.SitesCreateSiteHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/spoe/spoe_files"] = spoe.NewCreateSpoe(o.context, o.SpoeCreateSpoeHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents"] = spoe.NewCreateSpoeAgent(o.context, o.SpoeCreateSpoeAgentHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups"] = spoe.NewCreateSpoeGroup(o.context, o.SpoeCreateSpoeGroupHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages"] = spoe.NewCreateSpoeMessage(o.context, o.SpoeCreateSpoeMessageHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes"] = spoe.NewCreateSpoeScope(o.context, o.SpoeCreateSpoeScopeHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}"] = stick_rule.NewCreateStickRule(o.context, o.StickRuleCreateStickRuleHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/storage/general"] = storage.NewCreateStorageGeneralFile(o.context, o.StorageCreateStorageGeneralFileHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/storage/maps"] = storage.NewCreateStorageMapFile(o.context, o.StorageCreateStorageMapFileHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/storage/ssl_certificates"] = storage.NewCreateStorageSSLCertificate(o.context, o.StorageCreateStorageSSLCertificateHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/storage/ssl_crt_lists"] = storage.NewCreateStorageSSLCrtListFile(o.context, o.StorageCreateStorageSSLCrtListFileHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}"] = tcp_check.NewCreateTCPCheckBackend(o.context, o.TCPCheckCreateTCPCheckBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}"] = tcp_check.NewCreateTCPCheckDefaults(o.context, o.TCPCheckCreateTCPCheckDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewCreateTCPRequestRuleBackend(o.context, o.TCPRequestRuleCreateTCPRequestRuleBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewCreateTCPRequestRuleDefaults(o.context, o.TCPRequestRuleCreateTCPRequestRuleDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewCreateTCPRequestRuleFrontend(o.context, o.TCPRequestRuleCreateTCPRequestRuleFrontendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewCreateTCPResponseRuleBackend(o.context, o.TCPResponseRuleCreateTCPResponseRuleBackendHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewCreateTCPResponseRuleDefaults(o.context, o.TCPResponseRuleCreateTCPResponseRuleDefaultsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/peers/{parent_name}/tables"] = table.NewCreateTable(o.context, o.TableCreateTableHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/traces/entries"] = traces.NewCreateTraceEntry(o.context, o.TracesCreateTraceEntryHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/traces"] = traces.NewCreateTraces(o.context, o.TracesCreateTracesHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/users"] = user.NewCreateUser(o.context, o.UserCreateUserHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/configuration/userlists"] = userlist.NewCreateUserlist(o.context, o.UserlistCreateUserlistHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/service_discovery/aws/{id}"] = service_discovery.NewDeleteAWSRegion(o.context, o.ServiceDiscoveryDeleteAWSRegionHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/acls/{index}"] = acl.NewDeleteACLBackend(o.context, o.ACLDeleteACLBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/acls/{index}"] = acl.NewDeleteACLDefaults(o.context, o.ACLDeleteACLDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}"] = acl.NewDeleteACLFCGIApp(o.context, o.ACLDeleteACLFCGIAppHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/acls/{index}"] = acl.NewDeleteACLFrontend(o.context, o.ACLDeleteACLFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/acme/{name}"] = acme.NewDeleteAcmeProvider(o.context, o.AcmeDeleteAcmeProviderHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{name}"] = backend.NewDeleteBackend(o.context, o.BackendDeleteBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}"] = backend_switching_rule.NewDeleteBackendSwitchingRule(o.context, o.BackendSwitchingRuleDeleteBackendSwitchingRuleHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/binds/{name}"] = bind.NewDeleteBindFrontend(o.context, o.BindDeleteBindFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}"] = bind.NewDeleteBindLogForward(o.context, o.BindDeleteBindLogForwardHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/peers/{parent_name}/binds/{name}"] = bind.NewDeleteBindPeer(o.context, o.BindDeleteBindPeerHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/ssl_ca_files/{name}"] = s_s_l_runtime.NewDeleteCaFile(o.context, o.SslRuntimeDeleteCaFileHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/caches/{name}"] = cache.NewDeleteCache(o.context, o.CacheDeleteCacheHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/ssl_certs/{name}"] = s_s_l_runtime.NewDeleteCert(o.context, o.SslRuntimeDeleteCertHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/cluster"] = cluster.NewDeleteCluster(o.context, o.ClusterDeleteClusterHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/service_discovery/consul/{id}"] = service_discovery.NewDeleteConsul(o.context, o.ServiceDiscoveryDeleteConsulHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/ssl_crl_files/{name}"] = s_s_l_runtime.NewDeleteCrl(o.context, o.SslRuntimeDeleteCrlHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/ssl_crt_lists/entries"] = s_s_l_runtime.NewDeleteCrtListEntry(o.context, o.SslRuntimeDeleteCrtListEntryHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/crt_loads/{certificate}"] = crt_load.NewDeleteCrtLoad(o.context, o.CrtLoadDeleteCrtLoadHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/crt_stores/{name}"] = crt_store.NewDeleteCrtStore(o.context, o.CrtStoreDeleteCrtStoreHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/captures/{index}"] = declare_capture.NewDeleteDeclareCapture(o.context, o.DeclareCaptureDeleteDeclareCaptureHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{name}"] = defaults.NewDeleteDefaultsSection(o.context, o.DefaultsDeleteDefaultsSectionHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}"] = dgram_bind.NewDeleteDgramBind(o.context, o.DgramBindDeleteDgramBindHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/fcgi_apps/{name}"] = fcgi_app.NewDeleteFCGIApp(o.context, o.FCGIAppDeleteFCGIAppHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/filters/{index}"] = filter.NewDeleteFilterBackend(o.context, o.FilterDeleteFilterBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/filters/{index}"] = filter.NewDeleteFilterFrontend(o.context, o.FilterDeleteFilterFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{name}"] = frontend.NewDeleteFrontend(o.context, o.FrontendDeleteFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/groups/{name}"] = group.NewDeleteGroup(o.context, o.GroupDeleteGroupHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewDeleteHTTPAfterResponseRuleBackend(o.context, o.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewDeleteHTTPAfterResponseRuleDefaults(o.context, o.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewDeleteHTTPAfterResponseRuleFrontend(o.context, o.HTTPAfterResponseRuleDeleteHTTPAfterResponseRuleFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}"] = http_check.NewDeleteHTTPCheckBackend(o.context, o.HTTPCheckDeleteHTTPCheckBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}"] = http_check.NewDeleteHTTPCheckDefaults(o.context, o.HTTPCheckDeleteHTTPCheckDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewDeleteHTTPErrorRuleBackend(o.context, o.HTTPErrorRuleDeleteHTTPErrorRuleBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewDeleteHTTPErrorRuleDefaults(o.context, o.HTTPErrorRuleDeleteHTTPErrorRuleDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewDeleteHTTPErrorRuleFrontend(o.context, o.HTTPErrorRuleDeleteHTTPErrorRuleFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/http_errors_sections/{name}"] = http_errors.NewDeleteHTTPErrorsSection(o.context, o.HTTPErrorsDeleteHTTPErrorsSectionHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewDeleteHTTPRequestRuleBackend(o.context, o.HTTPRequestRuleDeleteHTTPRequestRuleBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewDeleteHTTPRequestRuleDefaults(o.context, o.HTTPRequestRuleDeleteHTTPRequestRuleDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewDeleteHTTPRequestRuleFrontend(o.context, o.HTTPRequestRuleDeleteHTTPRequestRuleFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewDeleteHTTPResponseRuleBackend(o.context, o.HTTPResponseRuleDeleteHTTPResponseRuleBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewDeleteHTTPResponseRuleDefaults(o.context, o.HTTPResponseRuleDeleteHTTPResponseRuleDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewDeleteHTTPResponseRuleFrontend(o.context, o.HTTPResponseRuleDeleteHTTPResponseRuleFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/log_forwards/{name}"] = log_forward.NewDeleteLogForward(o.context, o.LogForwardDeleteLogForwardHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/log_profiles/{name}"] = log_profile.NewDeleteLogProfile(o.context, o.LogProfileDeleteLogProfileHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}"] = log_target.NewDeleteLogTargetBackend(o.context, o.LogTargetDeleteLogTargetBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}"] = log_target.NewDeleteLogTargetDefaults(o.context, o.LogTargetDeleteLogTargetDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}"] = log_target.NewDeleteLogTargetFrontend(o.context, o.LogTargetDeleteLogTargetFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/global/log_targets/{index}"] = log_target.NewDeleteLogTargetGlobal(o.context, o.LogTargetDeleteLogTargetGlobalHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}"] = log_target.NewDeleteLogTargetLogForward(o.context, o.LogTargetDeleteLogTargetLogForwardHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}"] = log_target.NewDeleteLogTargetPeer(o.context, o.LogTargetDeleteLogTargetPeerHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/mailer_entries/{name}"] = mailer_entry.NewDeleteMailerEntry(o.context, o.MailerEntryDeleteMailerEntryHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/mailers_section/{name}"] = mailers.NewDeleteMailersSection(o.context, o.MailersDeleteMailersSectionHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/nameservers/{name}"] = nameserver.NewDeleteNameserver(o.context, o.NameserverDeleteNameserverHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/peer_section/{name}"] = peer.NewDeletePeer(o.context, o.PeerDeletePeerHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/peer_entries/{name}"] = peer_entry.NewDeletePeerEntry(o.context, o.PeerEntryDeletePeerEntryHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/programs/{name}"] = process_manager.NewDeleteProgram(o.context, o.ProcessManagerDeleteProgramHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewDeleteQUICInitialRuleDefaults(o.context, o.QUICInitialRuleDeleteQUICInitialRuleDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewDeleteQUICInitialRuleFrontend(o.context, o.QUICInitialRuleDeleteQUICInitialRuleFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/resolvers/{name}"] = resolver.NewDeleteResolver(o.context, o.ResolverDeleteResolverHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/rings/{name}"] = ring.NewDeleteRing(o.context, o.RingDeleteRingHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/maps/{parent_name}/entries/{id}"] = maps.NewDeleteRuntimeMapEntry(o.context, o.MapsDeleteRuntimeMapEntryHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/runtime/backends/{parent_name}/servers/{name}"] = serverops.NewDeleteRuntimeServer(o.context, o.ServerDeleteRuntimeServerHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}"] = s_s_l_front_use.NewDeleteSSLFrontUse(o.context, o.SslFrontUseDeleteSSLFrontUseHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/servers/{name}"] = serverops.NewDeleteServerBackend(o.context, o.ServerDeleteServerBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/peers/{parent_name}/servers/{name}"] = serverops.NewDeleteServerPeer(o.context, o.ServerDeleteServerPeerHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/rings/{parent_name}/servers/{name}"] = serverops.NewDeleteServerRing(o.context, o.ServerDeleteServerRingHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}"] = server_switching_rule.NewDeleteServerSwitchingRule(o.context, o.ServerSwitchingRuleDeleteServerSwitchingRuleHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}"] = server_template.NewDeleteServerTemplate(o.context, o.ServerTemplateDeleteServerTemplateHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/sites/{name}"] = sites.NewDeleteSite(o.context, o.SitesDeleteSiteHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}"] = spoe.NewDeleteSpoeAgent(o.context, o.SpoeDeleteSpoeAgentHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/spoe/spoe_files/{name}"] = spoe.NewDeleteSpoeFile(o.context, o.SpoeDeleteSpoeFileHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}"] = spoe.NewDeleteSpoeGroup(o.context, o.SpoeDeleteSpoeGroupHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}"] = spoe.NewDeleteSpoeMessage(o.context, o.SpoeDeleteSpoeMessageHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name}"] = spoe.NewDeleteSpoeScope(o.context, o.SpoeDeleteSpoeScopeHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}"] = spoe_transactions.NewDeleteSpoeTransaction(o.context, o.SpoeTransactionsDeleteSpoeTransactionHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}"] = stick_rule.NewDeleteStickRule(o.context, o.StickRuleDeleteStickRuleHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/storage/general/{name}"] = storage.NewDeleteStorageGeneralFile(o.context, o.StorageDeleteStorageGeneralFileHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/storage/maps/{name}"] = storage.NewDeleteStorageMap(o.context, o.StorageDeleteStorageMapHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/storage/ssl_certificates/{name}"] = storage.NewDeleteStorageSSLCertificate(o.context, o.StorageDeleteStorageSSLCertificateHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/storage/ssl_crt_lists/{name}"] = storage.NewDeleteStorageSSLCrtListFile(o.context, o.StorageDeleteStorageSSLCrtListFileHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}"] = tcp_check.NewDeleteTCPCheckBackend(o.context, o.TCPCheckDeleteTCPCheckBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}"] = tcp_check.NewDeleteTCPCheckDefaults(o.context, o.TCPCheckDeleteTCPCheckDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewDeleteTCPRequestRuleBackend(o.context, o.TCPRequestRuleDeleteTCPRequestRuleBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewDeleteTCPRequestRuleDefaults(o.context, o.TCPRequestRuleDeleteTCPRequestRuleDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewDeleteTCPRequestRuleFrontend(o.context, o.TCPRequestRuleDeleteTCPRequestRuleFrontendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewDeleteTCPResponseRuleBackend(o.context, o.TCPResponseRuleDeleteTCPResponseRuleBackendHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewDeleteTCPResponseRuleDefaults(o.context, o.TCPResponseRuleDeleteTCPResponseRuleDefaultsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/peers/{parent_name}/tables/{name}"] = table.NewDeleteTable(o.context, o.TableDeleteTableHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/traces/entries"] = traces.NewDeleteTraceEntry(o.context, o.TracesDeleteTraceEntryHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/traces"] = traces.NewDeleteTraces(o.context, o.TracesDeleteTracesHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/transactions/{id}"] = transactions.NewDeleteTransaction(o.context, o.TransactionsDeleteTransactionHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/users/{username}"] = user.NewDeleteUser(o.context, o.UserDeleteUserHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/services/haproxy/configuration/userlists/{name}"] = userlist.NewDeleteUserlist(o.context, o.UserlistDeleteUserlistHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/configuration/acme/{name}"] = acme.NewEditAcmeProvider(o.context, o.AcmeEditAcmeProviderHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/cluster"] = cluster.NewEditCluster(o.context, o.ClusterEditClusterHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/configuration/crt_stores/{name}"] = crt_store.NewEditCrtStore(o.context, o.CrtStoreEditCrtStoreHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/configuration/log_profiles/{name}"] = log_profile.NewEditLogProfile(o.context, o.LogProfileEditLogProfileHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/configuration/mailers_section/{name}"] = mailers.NewEditMailersSection(o.context, o.MailersEditMailersSectionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"][""] = discovery.NewGetAPIEndpoints(o.context, o.DiscoveryGetAPIEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/service_discovery/aws/{id}"] = service_discovery.NewGetAWSRegion(o.context, o.ServiceDiscoveryGetAWSRegionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/service_discovery/aws"] = service_discovery.NewGetAWSRegions(o.context, o.ServiceDiscoveryGetAWSRegionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/acls/{index}"] = acl.NewGetACLBackend(o.context, o.ACLGetACLBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/acls/{index}"] = acl.NewGetACLDefaults(o.context, o.ACLGetACLDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}"] = acl.NewGetACLFCGIApp(o.context, o.ACLGetACLFCGIAppHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/acls/{index}"] = acl.NewGetACLFrontend(o.context, o.ACLGetACLFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/acme/{name}"] = acme.NewGetAcmeProvider(o.context, o.AcmeGetAcmeProviderHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/acme"] = acme.NewGetAcmeProviders(o.context, o.AcmeGetAcmeProvidersHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/acme"] = acme_runtime.NewGetAcmeStatus(o.context, o.AcmeRuntimeGetAcmeStatusHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/acls"] = acl.NewGetAllACLBackend(o.context, o.ACLGetAllACLBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/acls"] = acl.NewGetAllACLDefaults(o.context, o.ACLGetAllACLDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/fcgi_apps/{parent_name}/acls"] = acl.NewGetAllACLFCGIApp(o.context, o.ACLGetAllACLFCGIAppHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/acls"] = acl.NewGetAllACLFrontend(o.context, o.ACLGetAllACLFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/binds"] = bind.NewGetAllBindFrontend(o.context, o.BindGetAllBindFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/log_forwards/{parent_name}/binds"] = bind.NewGetAllBindLogForward(o.context, o.BindGetAllBindLogForwardHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/binds"] = bind.NewGetAllBindPeer(o.context, o.BindGetAllBindPeerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_ca_files"] = s_s_l_runtime.NewGetAllCaFiles(o.context, o.SslRuntimeGetAllCaFilesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_certs"] = s_s_l_runtime.NewGetAllCerts(o.context, o.SslRuntimeGetAllCertsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_crl_files"] = s_s_l_runtime.NewGetAllCrl(o.context, o.SslRuntimeGetAllCrlHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_crt_lists/entries"] = s_s_l_runtime.NewGetAllCrtListEntries(o.context, o.SslRuntimeGetAllCrtListEntriesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_crt_lists"] = s_s_l_runtime.NewGetAllCrtLists(o.context, o.SslRuntimeGetAllCrtListsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/filters"] = filter.NewGetAllFilterBackend(o.context, o.FilterGetAllFilterBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/filters"] = filter.NewGetAllFilterFrontend(o.context, o.FilterGetAllFilterFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules"] = http_after_response_rule.NewGetAllHTTPAfterResponseRuleBackend(o.context, o.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules"] = http_after_response_rule.NewGetAllHTTPAfterResponseRuleDefaults(o.context, o.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules"] = http_after_response_rule.NewGetAllHTTPAfterResponseRuleFrontend(o.context, o.HTTPAfterResponseRuleGetAllHTTPAfterResponseRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_checks"] = http_check.NewGetAllHTTPCheckBackend(o.context, o.HTTPCheckGetAllHTTPCheckBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_checks"] = http_check.NewGetAllHTTPCheckDefaults(o.context, o.HTTPCheckGetAllHTTPCheckDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_error_rules"] = http_error_rule.NewGetAllHTTPErrorRuleBackend(o.context, o.HTTPErrorRuleGetAllHTTPErrorRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_error_rules"] = http_error_rule.NewGetAllHTTPErrorRuleDefaults(o.context, o.HTTPErrorRuleGetAllHTTPErrorRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_error_rules"] = http_error_rule.NewGetAllHTTPErrorRuleFrontend(o.context, o.HTTPErrorRuleGetAllHTTPErrorRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_request_rules"] = http_request_rule.NewGetAllHTTPRequestRuleBackend(o.context, o.HTTPRequestRuleGetAllHTTPRequestRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_request_rules"] = http_request_rule.NewGetAllHTTPRequestRuleDefaults(o.context, o.HTTPRequestRuleGetAllHTTPRequestRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_request_rules"] = http_request_rule.NewGetAllHTTPRequestRuleFrontend(o.context, o.HTTPRequestRuleGetAllHTTPRequestRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_response_rules"] = http_response_rule.NewGetAllHTTPResponseRuleBackend(o.context, o.HTTPResponseRuleGetAllHTTPResponseRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_response_rules"] = http_response_rule.NewGetAllHTTPResponseRuleDefaults(o.context, o.HTTPResponseRuleGetAllHTTPResponseRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_response_rules"] = http_response_rule.NewGetAllHTTPResponseRuleFrontend(o.context, o.HTTPResponseRuleGetAllHTTPResponseRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/log_targets"] = log_target.NewGetAllLogTargetBackend(o.context, o.LogTargetGetAllLogTargetBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/log_targets"] = log_target.NewGetAllLogTargetDefaults(o.context, o.LogTargetGetAllLogTargetDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/log_targets"] = log_target.NewGetAllLogTargetFrontend(o.context, o.LogTargetGetAllLogTargetFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/global/log_targets"] = log_target.NewGetAllLogTargetGlobal(o.context, o.LogTargetGetAllLogTargetGlobalHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/log_forwards/{parent_name}/log_targets"] = log_target.NewGetAllLogTargetLogForward(o.context, o.LogTargetGetAllLogTargetLogForwardHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/log_targets"] = log_target.NewGetAllLogTargetPeer(o.context, o.LogTargetGetAllLogTargetPeerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules"] = quic_initial_rule.NewGetAllQUICInitialRuleDefaults(o.context, o.QUICInitialRuleGetAllQUICInitialRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules"] = quic_initial_rule.NewGetAllQUICInitialRuleFrontend(o.context, o.QUICInitialRuleGetAllQUICInitialRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/maps"] = maps.NewGetAllRuntimeMapFiles(o.context, o.MapsGetAllRuntimeMapFilesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/backends/{parent_name}/servers"] = serverops.NewGetAllRuntimeServer(o.context, o.ServerGetAllRuntimeServerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses"] = s_s_l_front_use.NewGetAllSSLFrontUses(o.context, o.SslFrontUseGetAllSSLFrontUsesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/servers"] = serverops.NewGetAllServerBackend(o.context, o.ServerGetAllServerBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/servers"] = serverops.NewGetAllServerPeer(o.context, o.ServerGetAllServerPeerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/rings/{parent_name}/servers"] = serverops.NewGetAllServerRing(o.context, o.ServerGetAllServerRingHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents"] = spoe.NewGetAllSpoeAgent(o.context, o.SpoeGetAllSpoeAgentHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files"] = spoe.NewGetAllSpoeFiles(o.context, o.SpoeGetAllSpoeFilesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups"] = spoe.NewGetAllSpoeGroup(o.context, o.SpoeGetAllSpoeGroupHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages"] = spoe.NewGetAllSpoeMessage(o.context, o.SpoeGetAllSpoeMessageHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes"] = spoe.NewGetAllSpoeScope(o.context, o.SpoeGetAllSpoeScopeHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/transactions"] = spoe_transactions.NewGetAllSpoeTransaction(o.context, o.SpoeTransactionsGetAllSpoeTransactionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/storage/general"] = storage.NewGetAllStorageGeneralFiles(o.context, o.StorageGetAllStorageGeneralFilesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/storage/maps"] = storage.NewGetAllStorageMapFiles(o.context, o.StorageGetAllStorageMapFilesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/storage/ssl_certificates"] = storage.NewGetAllStorageSSLCertificates(o.context, o.StorageGetAllStorageSSLCertificatesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/storage/ssl_crt_lists"] = storage.NewGetAllStorageSSLCrtListFiles(o.context, o.StorageGetAllStorageSSLCrtListFilesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/tcp_checks"] = tcp_check.NewGetAllTCPCheckBackend(o.context, o.TCPCheckGetAllTCPCheckBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_checks"] = tcp_check.NewGetAllTCPCheckDefaults(o.context, o.TCPCheckGetAllTCPCheckDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules"] = tcp_request_rule.NewGetAllTCPRequestRuleBackend(o.context, o.TCPRequestRuleGetAllTCPRequestRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules"] = tcp_request_rule.NewGetAllTCPRequestRuleDefaults(o.context, o.TCPRequestRuleGetAllTCPRequestRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules"] = tcp_request_rule.NewGetAllTCPRequestRuleFrontend(o.context, o.TCPRequestRuleGetAllTCPRequestRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules"] = tcp_response_rule.NewGetAllTCPResponseRuleBackend(o.context, o.TCPResponseRuleGetAllTCPResponseRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules"] = tcp_response_rule.NewGetAllTCPResponseRuleDefaults(o.context, o.TCPResponseRuleGetAllTCPResponseRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{name}"] = backend.NewGetBackend(o.context, o.BackendGetBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}"] = backend_switching_rule.NewGetBackendSwitchingRule(o.context, o.BackendSwitchingRuleGetBackendSwitchingRuleHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules"] = backend_switching_rule.NewGetBackendSwitchingRules(o.context, o.BackendSwitchingRuleGetBackendSwitchingRulesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends"] = backend.NewGetBackends(o.context, o.BackendGetBackendsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/binds/{name}"] = bind.NewGetBindFrontend(o.context, o.BindGetBindFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}"] = bind.NewGetBindLogForward(o.context, o.BindGetBindLogForwardHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/binds/{name}"] = bind.NewGetBindPeer(o.context, o.BindGetBindPeerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_ca_files/{name}/entries/{index}"] = s_s_l_runtime.NewGetCaEntry(o.context, o.SslRuntimeGetCaEntryHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_ca_files/{name}"] = s_s_l_runtime.NewGetCaFile(o.context, o.SslRuntimeGetCaFileHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/caches/{name}"] = cache.NewGetCache(o.context, o.CacheGetCacheHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/caches"] = cache.NewGetCaches(o.context, o.CacheGetCachesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_certs/{name}"] = s_s_l_runtime.NewGetCert(o.context, o.SslRuntimeGetCertHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/cluster"] = cluster.NewGetCluster(o.context, o.ClusterGetClusterHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration"] = discovery.NewGetConfigurationEndpoints(o.context, o.DiscoveryGetConfigurationEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/version"] = configuration.NewGetConfigurationVersion(o.context, o.ConfigurationGetConfigurationVersionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/service_discovery/consul/{id}"] = service_discovery.NewGetConsul(o.context, o.ServiceDiscoveryGetConsulHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/service_discovery/consul"] = service_discovery.NewGetConsuls(o.context, o.ServiceDiscoveryGetConsulsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/ssl_crl_files/{name}"] = s_s_l_runtime.NewGetCrl(o.context, o.SslRuntimeGetCrlHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/crt_loads/{certificate}"] = crt_load.NewGetCrtLoad(o.context, o.CrtLoadGetCrtLoadHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/crt_loads"] = crt_load.NewGetCrtLoads(o.context, o.CrtLoadGetCrtLoadsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/crt_stores/{name}"] = crt_store.NewGetCrtStore(o.context, o.CrtStoreGetCrtStoreHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/crt_stores"] = crt_store.NewGetCrtStores(o.context, o.CrtStoreGetCrtStoresHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/captures/{index}"] = declare_capture.NewGetDeclareCapture(o.context, o.DeclareCaptureGetDeclareCaptureHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/captures"] = declare_capture.NewGetDeclareCaptures(o.context, o.DeclareCaptureGetDeclareCapturesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{name}"] = defaults.NewGetDefaultsSection(o.context, o.DefaultsGetDefaultsSectionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults"] = defaults.NewGetDefaultsSections(o.context, o.DefaultsGetDefaultsSectionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}"] = dgram_bind.NewGetDgramBind(o.context, o.DgramBindGetDgramBindHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds"] = dgram_bind.NewGetDgramBinds(o.context, o.DgramBindGetDgramBindsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/fcgi_apps/{name}"] = fcgi_app.NewGetFCGIApp(o.context, o.FCGIAppGetFCGIAppHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/fcgi_apps"] = fcgi_app.NewGetFCGIApps(o.context, o.FCGIAppGetFCGIAppsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/filters/{index}"] = filter.NewGetFilterBackend(o.context, o.FilterGetFilterBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/filters/{index}"] = filter.NewGetFilterFrontend(o.context, o.FilterGetFilterFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{name}"] = frontend.NewGetFrontend(o.context, o.FrontendGetFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends"] = frontend.NewGetFrontends(o.context, o.FrontendGetFrontendsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/global"] = global.NewGetGlobal(o.context, o.GlobalGetGlobalHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/groups/{name}"] = group.NewGetGroup(o.context, o.GroupGetGroupHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/groups"] = group.NewGetGroups(o.context, o.GroupGetGroupsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/raw"] = configuration.NewGetHAProxyConfiguration(o.context, o.ConfigurationGetHAProxyConfigurationHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewGetHTTPAfterResponseRuleBackend(o.context, o.HTTPAfterResponseRuleGetHTTPAfterResponseRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewGetHTTPAfterResponseRuleDefaults(o.context, o.HTTPAfterResponseRuleGetHTTPAfterResponseRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewGetHTTPAfterResponseRuleFrontend(o.context, o.HTTPAfterResponseRuleGetHTTPAfterResponseRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}"] = http_check.NewGetHTTPCheckBackend(o.context, o.HTTPCheckGetHTTPCheckBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}"] = http_check.NewGetHTTPCheckDefaults(o.context, o.HTTPCheckGetHTTPCheckDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewGetHTTPErrorRuleBackend(o.context, o.HTTPErrorRuleGetHTTPErrorRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewGetHTTPErrorRuleDefaults(o.context, o.HTTPErrorRuleGetHTTPErrorRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewGetHTTPErrorRuleFrontend(o.context, o.HTTPErrorRuleGetHTTPErrorRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/http_errors_sections/{name}"] = http_errors.NewGetHTTPErrorsSection(o.context, o.HTTPErrorsGetHTTPErrorsSectionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/http_errors_sections"] = http_errors.NewGetHTTPErrorsSections(o.context, o.HTTPErrorsGetHTTPErrorsSectionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewGetHTTPRequestRuleBackend(o.context, o.HTTPRequestRuleGetHTTPRequestRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewGetHTTPRequestRuleDefaults(o.context, o.HTTPRequestRuleGetHTTPRequestRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewGetHTTPRequestRuleFrontend(o.context, o.HTTPRequestRuleGetHTTPRequestRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewGetHTTPResponseRuleBackend(o.context, o.HTTPResponseRuleGetHTTPResponseRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewGetHTTPResponseRuleDefaults(o.context, o.HTTPResponseRuleGetHTTPResponseRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TxtConsumer == nil { - unregistered = append(unregistered, "TxtConsumer") + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewGetHTTPResponseRuleFrontend(o.context, o.HTTPResponseRuleGetHTTPResponseRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.JSONProducer == nil { - unregistered = append(unregistered, "JSONProducer") + o.handlers["GET"]["/services/haproxy"] = discovery.NewGetHaproxyEndpoints(o.context, o.DiscoveryGetHaproxyEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TxtProducer == nil { - unregistered = append(unregistered, "TxtProducer") + o.handlers["GET"]["/services/haproxy/runtime/info"] = information.NewGetHaproxyProcessInfo(o.context, o.InformationGetHaproxyProcessInfoHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BasicAuthAuth == nil { - unregistered = append(unregistered, "BasicAuthAuth") + o.handlers["GET"]["/health"] = health.NewGetHealth(o.context, o.HealthGetHealthHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TransactionsCommitTransactionHandler == nil { - unregistered = append(unregistered, "transactions.CommitTransactionHandler") + o.handlers["GET"]["/info"] = information.NewGetInfo(o.context, o.InformationGetInfoHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ACLCreateACLHandler == nil { - unregistered = append(unregistered, "acl.CreateACLHandler") + o.handlers["GET"]["/services/haproxy/configuration/log_forwards/{name}"] = log_forward.NewGetLogForward(o.context, o.LogForwardGetLogForwardHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendCreateBackendHandler == nil { - unregistered = append(unregistered, "backend.CreateBackendHandler") + o.handlers["GET"]["/services/haproxy/configuration/log_forwards"] = log_forward.NewGetLogForwards(o.context, o.LogForwardGetLogForwardsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendSwitchingRuleCreateBackendSwitchingRuleHandler == nil { - unregistered = append(unregistered, "backend_switching_rule.CreateBackendSwitchingRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/log_profiles/{name}"] = log_profile.NewGetLogProfile(o.context, o.LogProfileGetLogProfileHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BindCreateBindHandler == nil { - unregistered = append(unregistered, "bind.CreateBindHandler") + o.handlers["GET"]["/services/haproxy/configuration/log_profiles"] = log_profile.NewGetLogProfiles(o.context, o.LogProfileGetLogProfilesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FilterCreateFilterHandler == nil { - unregistered = append(unregistered, "filter.CreateFilterHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}"] = log_target.NewGetLogTargetBackend(o.context, o.LogTargetGetLogTargetBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FrontendCreateFrontendHandler == nil { - unregistered = append(unregistered, "frontend.CreateFrontendHandler") + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}"] = log_target.NewGetLogTargetDefaults(o.context, o.LogTargetGetLogTargetDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPRequestRuleCreateHTTPRequestRuleHandler == nil { - unregistered = append(unregistered, "http_request_rule.CreateHTTPRequestRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}"] = log_target.NewGetLogTargetFrontend(o.context, o.LogTargetGetLogTargetFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPResponseRuleCreateHTTPResponseRuleHandler == nil { - unregistered = append(unregistered, "http_response_rule.CreateHTTPResponseRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/global/log_targets/{index}"] = log_target.NewGetLogTargetGlobal(o.context, o.LogTargetGetLogTargetGlobalHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.LogTargetCreateLogTargetHandler == nil { - unregistered = append(unregistered, "log_target.CreateLogTargetHandler") + o.handlers["GET"]["/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}"] = log_target.NewGetLogTargetLogForward(o.context, o.LogTargetGetLogTargetLogForwardHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerCreateServerHandler == nil { - unregistered = append(unregistered, "server.CreateServerHandler") + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}"] = log_target.NewGetLogTargetPeer(o.context, o.LogTargetGetLogTargetPeerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerSwitchingRuleCreateServerSwitchingRuleHandler == nil { - unregistered = append(unregistered, "server_switching_rule.CreateServerSwitchingRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/mailer_entries"] = mailer_entry.NewGetMailerEntries(o.context, o.MailerEntryGetMailerEntriesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.SitesCreateSiteHandler == nil { - unregistered = append(unregistered, "sites.CreateSiteHandler") + o.handlers["GET"]["/services/haproxy/configuration/mailer_entries/{name}"] = mailer_entry.NewGetMailerEntry(o.context, o.MailerEntryGetMailerEntryHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.StickRuleCreateStickRuleHandler == nil { - unregistered = append(unregistered, "stick_rule.CreateStickRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/mailers_section/{name}"] = mailers.NewGetMailersSection(o.context, o.MailersGetMailersSectionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPRequestRuleCreateTCPRequestRuleHandler == nil { - unregistered = append(unregistered, "tcp_request_rule.CreateTCPRequestRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/mailers_section"] = mailers.NewGetMailersSections(o.context, o.MailersGetMailersSectionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPResponseRuleCreateTCPResponseRuleHandler == nil { - unregistered = append(unregistered, "tcp_response_rule.CreateTCPResponseRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/nameservers/{name}"] = nameserver.NewGetNameserver(o.context, o.NameserverGetNameserverHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ACLDeleteACLHandler == nil { - unregistered = append(unregistered, "acl.DeleteACLHandler") + o.handlers["GET"]["/services/haproxy/configuration/nameservers"] = nameserver.NewGetNameservers(o.context, o.NameserverGetNameserversHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendDeleteBackendHandler == nil { - unregistered = append(unregistered, "backend.DeleteBackendHandler") + o.handlers["GET"]["/services/haproxy/runtime/maps/{name}"] = maps.NewGetOneRuntimeMap(o.context, o.MapsGetOneRuntimeMapHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendSwitchingRuleDeleteBackendSwitchingRuleHandler == nil { - unregistered = append(unregistered, "backend_switching_rule.DeleteBackendSwitchingRuleHandler") + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{name}"] = spoe.NewGetOneSpoeFile(o.context, o.SpoeGetOneSpoeFileHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BindDeleteBindHandler == nil { - unregistered = append(unregistered, "bind.DeleteBindHandler") + o.handlers["GET"]["/services/haproxy/storage/general/{name}"] = storage.NewGetOneStorageGeneralFile(o.context, o.StorageGetOneStorageGeneralFileHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FilterDeleteFilterHandler == nil { - unregistered = append(unregistered, "filter.DeleteFilterHandler") + o.handlers["GET"]["/services/haproxy/storage/maps/{name}"] = storage.NewGetOneStorageMap(o.context, o.StorageGetOneStorageMapHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FrontendDeleteFrontendHandler == nil { - unregistered = append(unregistered, "frontend.DeleteFrontendHandler") + o.handlers["GET"]["/services/haproxy/storage/ssl_certificates/{name}"] = storage.NewGetOneStorageSSLCertificate(o.context, o.StorageGetOneStorageSSLCertificateHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPRequestRuleDeleteHTTPRequestRuleHandler == nil { - unregistered = append(unregistered, "http_request_rule.DeleteHTTPRequestRuleHandler") + o.handlers["GET"]["/services/haproxy/storage/ssl_crt_lists/{name}"] = storage.NewGetOneStorageSSLCrtListFile(o.context, o.StorageGetOneStorageSSLCrtListFileHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPResponseRuleDeleteHTTPResponseRuleHandler == nil { - unregistered = append(unregistered, "http_response_rule.DeleteHTTPResponseRuleHandler") + o.handlers["GET"]["/specification_openapiv3"] = specification_openapiv3.NewGetOpenapiv3Specification(o.context, o.SpecificationOpenapiv3GetOpenapiv3SpecificationHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.LogTargetDeleteLogTargetHandler == nil { - unregistered = append(unregistered, "log_target.DeleteLogTargetHandler") + o.handlers["GET"]["/services/haproxy/configuration/peer_entries"] = peer_entry.NewGetPeerEntries(o.context, o.PeerEntryGetPeerEntriesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerDeleteServerHandler == nil { - unregistered = append(unregistered, "server.DeleteServerHandler") + o.handlers["GET"]["/services/haproxy/configuration/peer_entries/{name}"] = peer_entry.NewGetPeerEntry(o.context, o.PeerEntryGetPeerEntryHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerSwitchingRuleDeleteServerSwitchingRuleHandler == nil { - unregistered = append(unregistered, "server_switching_rule.DeleteServerSwitchingRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/peer_section/{name}"] = peer.NewGetPeerSection(o.context, o.PeerGetPeerSectionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.SitesDeleteSiteHandler == nil { - unregistered = append(unregistered, "sites.DeleteSiteHandler") + o.handlers["GET"]["/services/haproxy/configuration/peer_section"] = peer.NewGetPeerSections(o.context, o.PeerGetPeerSectionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.StickRuleDeleteStickRuleHandler == nil { - unregistered = append(unregistered, "stick_rule.DeleteStickRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/programs/{name}"] = process_manager.NewGetProgram(o.context, o.ProcessManagerGetProgramHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPRequestRuleDeleteTCPRequestRuleHandler == nil { - unregistered = append(unregistered, "tcp_request_rule.DeleteTCPRequestRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/programs"] = process_manager.NewGetPrograms(o.context, o.ProcessManagerGetProgramsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPResponseRuleDeleteTCPResponseRuleHandler == nil { - unregistered = append(unregistered, "tcp_response_rule.DeleteTCPResponseRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewGetQUICInitialRuleDefaults(o.context, o.QUICInitialRuleGetQUICInitialRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TransactionsDeleteTransactionHandler == nil { - unregistered = append(unregistered, "transactions.DeleteTransactionHandler") + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewGetQUICInitialRuleFrontend(o.context, o.QUICInitialRuleGetQUICInitialRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.DiscoveryGetAPIEndpointsHandler == nil { - unregistered = append(unregistered, "discovery.GetAPIEndpointsHandler") + o.handlers["GET"]["/services/haproxy/reloads/{id}"] = reloads.NewGetReload(o.context, o.ReloadsGetReloadHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ACLGetACLHandler == nil { - unregistered = append(unregistered, "acl.GetACLHandler") + o.handlers["GET"]["/services/haproxy/reloads"] = reloads.NewGetReloads(o.context, o.ReloadsGetReloadsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ACLGetAclsHandler == nil { - unregistered = append(unregistered, "acl.GetAclsHandler") + o.handlers["GET"]["/services/haproxy/configuration/resolvers/{name}"] = resolver.NewGetResolver(o.context, o.ResolverGetResolverHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendGetBackendHandler == nil { - unregistered = append(unregistered, "backend.GetBackendHandler") + o.handlers["GET"]["/services/haproxy/configuration/resolvers"] = resolver.NewGetResolvers(o.context, o.ResolverGetResolversHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendSwitchingRuleGetBackendSwitchingRuleHandler == nil { - unregistered = append(unregistered, "backend_switching_rule.GetBackendSwitchingRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/rings/{name}"] = ring.NewGetRing(o.context, o.RingGetRingHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendSwitchingRuleGetBackendSwitchingRulesHandler == nil { - unregistered = append(unregistered, "backend_switching_rule.GetBackendSwitchingRulesHandler") + o.handlers["GET"]["/services/haproxy/configuration/rings"] = ring.NewGetRings(o.context, o.RingGetRingsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BackendGetBackendsHandler == nil { - unregistered = append(unregistered, "backend.GetBackendsHandler") + o.handlers["GET"]["/services/haproxy/runtime"] = discovery.NewGetRuntimeEndpoints(o.context, o.DiscoveryGetRuntimeEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BindGetBindHandler == nil { - unregistered = append(unregistered, "bind.GetBindHandler") + o.handlers["GET"]["/services/haproxy/runtime/maps/{parent_name}/entries/{id}"] = maps.NewGetRuntimeMapEntry(o.context, o.MapsGetRuntimeMapEntryHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.BindGetBindsHandler == nil { - unregistered = append(unregistered, "bind.GetBindsHandler") + o.handlers["GET"]["/services/haproxy/runtime/backends/{parent_name}/servers/{name}"] = serverops.NewGetRuntimeServer(o.context, o.ServerGetRuntimeServerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.DiscoveryGetConfigurationEndpointsHandler == nil { - unregistered = append(unregistered, "discovery.GetConfigurationEndpointsHandler") + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}"] = s_s_l_front_use.NewGetSSLFrontUse(o.context, o.SslFrontUseGetSSLFrontUseHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.DefaultsGetDefaultsHandler == nil { - unregistered = append(unregistered, "defaults.GetDefaultsHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/servers/{name}"] = serverops.NewGetServerBackend(o.context, o.ServerGetServerBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FilterGetFilterHandler == nil { - unregistered = append(unregistered, "filter.GetFilterHandler") + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/servers/{name}"] = serverops.NewGetServerPeer(o.context, o.ServerGetServerPeerHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FilterGetFiltersHandler == nil { - unregistered = append(unregistered, "filter.GetFiltersHandler") + o.handlers["GET"]["/services/haproxy/configuration/rings/{parent_name}/servers/{name}"] = serverops.NewGetServerRing(o.context, o.ServerGetServerRingHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FrontendGetFrontendHandler == nil { - unregistered = append(unregistered, "frontend.GetFrontendHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}"] = server_switching_rule.NewGetServerSwitchingRule(o.context, o.ServerSwitchingRuleGetServerSwitchingRuleHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.FrontendGetFrontendsHandler == nil { - unregistered = append(unregistered, "frontend.GetFrontendsHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/server_switching_rules"] = server_switching_rule.NewGetServerSwitchingRules(o.context, o.ServerSwitchingRuleGetServerSwitchingRulesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.GlobalGetGlobalHandler == nil { - unregistered = append(unregistered, "global.GetGlobalHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}"] = server_template.NewGetServerTemplate(o.context, o.ServerTemplateGetServerTemplateHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ConfigurationGetHAProxyConfigurationHandler == nil { - unregistered = append(unregistered, "configuration.GetHAProxyConfigurationHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/server_templates"] = server_template.NewGetServerTemplates(o.context, o.ServerTemplateGetServerTemplatesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPRequestRuleGetHTTPRequestRuleHandler == nil { - unregistered = append(unregistered, "http_request_rule.GetHTTPRequestRuleHandler") + o.handlers["GET"]["/services"] = discovery.NewGetServicesEndpoints(o.context, o.DiscoveryGetServicesEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPRequestRuleGetHTTPRequestRulesHandler == nil { - unregistered = append(unregistered, "http_request_rule.GetHTTPRequestRulesHandler") + o.handlers["GET"]["/services/haproxy/sites/{name}"] = sites.NewGetSite(o.context, o.SitesGetSiteHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPResponseRuleGetHTTPResponseRuleHandler == nil { - unregistered = append(unregistered, "http_response_rule.GetHTTPResponseRuleHandler") + o.handlers["GET"]["/services/haproxy/sites"] = sites.NewGetSites(o.context, o.SitesGetSitesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.HTTPResponseRuleGetHTTPResponseRulesHandler == nil { - unregistered = append(unregistered, "http_response_rule.GetHTTPResponseRulesHandler") + o.handlers["GET"]["/specification"] = specification.NewGetSpecification(o.context, o.SpecificationGetSpecificationHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.DiscoveryGetHaproxyEndpointsHandler == nil { - unregistered = append(unregistered, "discovery.GetHaproxyEndpointsHandler") + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}"] = spoe.NewGetSpoeAgent(o.context, o.SpoeGetSpoeAgentHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.InformationGetHaproxyProcessInfoHandler == nil { - unregistered = append(unregistered, "information.GetHaproxyProcessInfoHandler") + o.handlers["GET"]["/services/haproxy/spoe/{parent_name}/version"] = spoe.NewGetSpoeConfigurationVersion(o.context, o.SpoeGetSpoeConfigurationVersionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe"] = discovery.NewGetSpoeEndpoints(o.context, o.DiscoveryGetSpoeEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}"] = spoe.NewGetSpoeGroup(o.context, o.SpoeGetSpoeGroupHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}"] = spoe.NewGetSpoeMessage(o.context, o.SpoeGetSpoeMessageHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name}"] = spoe.NewGetSpoeScope(o.context, o.SpoeGetSpoeScopeHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.InformationGetInfoHandler == nil { - unregistered = append(unregistered, "information.GetInfoHandler") + o.handlers["GET"]["/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}"] = spoe_transactions.NewGetSpoeTransaction(o.context, o.SpoeTransactionsGetSpoeTransactionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.LogTargetGetLogTargetHandler == nil { - unregistered = append(unregistered, "log_target.GetLogTargetHandler") + o.handlers["GET"]["/services/haproxy/stats/native"] = stats.NewGetStats(o.context, o.StatsGetStatsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.LogTargetGetLogTargetsHandler == nil { - unregistered = append(unregistered, "log_target.GetLogTargetsHandler") + o.handlers["GET"]["/services/haproxy/stats"] = discovery.NewGetStatsEndpoints(o.context, o.DiscoveryGetStatsEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ReloadsGetReloadHandler == nil { - unregistered = append(unregistered, "reloads.GetReloadHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}"] = stick_rule.NewGetStickRule(o.context, o.StickRuleGetStickRuleHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ReloadsGetReloadsHandler == nil { - unregistered = append(unregistered, "reloads.GetReloadsHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/stick_rules"] = stick_rule.NewGetStickRules(o.context, o.StickRuleGetStickRulesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerGetServerHandler == nil { - unregistered = append(unregistered, "server.GetServerHandler") + o.handlers["GET"]["/services/haproxy/runtime/stick_tables/{name}"] = stick_table.NewGetStickTable(o.context, o.StickTableGetStickTableHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerSwitchingRuleGetServerSwitchingRuleHandler == nil { - unregistered = append(unregistered, "server_switching_rule.GetServerSwitchingRuleHandler") + o.handlers["GET"]["/services/haproxy/runtime/stick_tables/{parent_name}/entries"] = stick_table.NewGetStickTableEntries(o.context, o.StickTableGetStickTableEntriesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerSwitchingRuleGetServerSwitchingRulesHandler == nil { - unregistered = append(unregistered, "server_switching_rule.GetServerSwitchingRulesHandler") + o.handlers["GET"]["/services/haproxy/runtime/stick_tables"] = stick_table.NewGetStickTables(o.context, o.StickTableGetStickTablesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ServerGetServersHandler == nil { - unregistered = append(unregistered, "server.GetServersHandler") + o.handlers["GET"]["/services/haproxy/storage"] = discovery.NewGetStorageEndpoints(o.context, o.DiscoveryGetStorageEndpointsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.DiscoveryGetServicesEndpointsHandler == nil { - unregistered = append(unregistered, "discovery.GetServicesEndpointsHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}"] = tcp_check.NewGetTCPCheckBackend(o.context, o.TCPCheckGetTCPCheckBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.SitesGetSiteHandler == nil { - unregistered = append(unregistered, "sites.GetSiteHandler") + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}"] = tcp_check.NewGetTCPCheckDefaults(o.context, o.TCPCheckGetTCPCheckDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.SitesGetSitesHandler == nil { - unregistered = append(unregistered, "sites.GetSitesHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewGetTCPRequestRuleBackend(o.context, o.TCPRequestRuleGetTCPRequestRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.SpecificationGetSpecificationHandler == nil { - unregistered = append(unregistered, "specification.GetSpecificationHandler") + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewGetTCPRequestRuleDefaults(o.context, o.TCPRequestRuleGetTCPRequestRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.StatsGetStatsHandler == nil { - unregistered = append(unregistered, "stats.GetStatsHandler") + o.handlers["GET"]["/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewGetTCPRequestRuleFrontend(o.context, o.TCPRequestRuleGetTCPRequestRuleFrontendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.DiscoveryGetStatsEndpointsHandler == nil { - unregistered = append(unregistered, "discovery.GetStatsEndpointsHandler") + o.handlers["GET"]["/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewGetTCPResponseRuleBackend(o.context, o.TCPResponseRuleGetTCPResponseRuleBackendHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.StickRuleGetStickRuleHandler == nil { - unregistered = append(unregistered, "stick_rule.GetStickRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewGetTCPResponseRuleDefaults(o.context, o.TCPResponseRuleGetTCPResponseRuleDefaultsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.StickRuleGetStickRulesHandler == nil { - unregistered = append(unregistered, "stick_rule.GetStickRulesHandler") + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/tables/{name}"] = table.NewGetTable(o.context, o.TableGetTableHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPRequestRuleGetTCPRequestRuleHandler == nil { - unregistered = append(unregistered, "tcp_request_rule.GetTCPRequestRuleHandler") + o.handlers["GET"]["/services/haproxy/configuration/peers/{parent_name}/tables"] = table.NewGetTables(o.context, o.TableGetTablesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPRequestRuleGetTCPRequestRulesHandler == nil { - unregistered = append(unregistered, "tcp_request_rule.GetTCPRequestRulesHandler") + o.handlers["GET"]["/services/haproxy/configuration/traces"] = traces.NewGetTraces(o.context, o.TracesGetTracesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPResponseRuleGetTCPResponseRuleHandler == nil { - unregistered = append(unregistered, "tcp_response_rule.GetTCPResponseRuleHandler") + o.handlers["GET"]["/services/haproxy/transactions/{id}"] = transactions.NewGetTransaction(o.context, o.TransactionsGetTransactionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TCPResponseRuleGetTCPResponseRulesHandler == nil { - unregistered = append(unregistered, "tcp_response_rule.GetTCPResponseRulesHandler") + o.handlers["GET"]["/services/haproxy/transactions"] = transactions.NewGetTransactions(o.context, o.TransactionsGetTransactionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TransactionsGetTransactionHandler == nil { - unregistered = append(unregistered, "transactions.GetTransactionHandler") + o.handlers["GET"]["/services/haproxy/configuration/users/{username}"] = user.NewGetUser(o.context, o.UserGetUserHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.TransactionsGetTransactionsHandler == nil { - unregistered = append(unregistered, "transactions.GetTransactionsHandler") + o.handlers["GET"]["/services/haproxy/configuration/userlists/{name}"] = userlist.NewGetUserlist(o.context, o.UserlistGetUserlistHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ConfigurationPostHAProxyConfigurationHandler == nil { - unregistered = append(unregistered, "configuration.PostHAProxyConfigurationHandler") + o.handlers["GET"]["/services/haproxy/configuration/userlists"] = userlist.NewGetUserlists(o.context, o.UserlistGetUserlistsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) } - - if o.ACLReplaceACLHandler == nil { - unregistered = append(unregistered, "acl.ReplaceACLHandler") + o.handlers["GET"]["/services/haproxy/configuration/users"] = user.NewGetUsers(o.context, o.UserGetUsersHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) } - - if o.BackendReplaceBackendHandler == nil { - unregistered = append(unregistered, "backend.ReplaceBackendHandler") + o.handlers["POST"]["/cluster/certificate"] = cluster.NewInitiateCertificateRefresh(o.context, o.ClusterInitiateCertificateRefreshHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) } - - if o.BackendSwitchingRuleReplaceBackendSwitchingRuleHandler == nil { - unregistered = append(unregistered, "backend_switching_rule.ReplaceBackendSwitchingRuleHandler") + o.handlers["POST"]["/cluster"] = cluster.NewPostCluster(o.context, o.ClusterPostClusterHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) } - - if o.BindReplaceBindHandler == nil { - unregistered = append(unregistered, "bind.ReplaceBindHandler") + o.handlers["POST"]["/services/haproxy/configuration/raw"] = configuration.NewPostHAProxyConfiguration(o.context, o.ConfigurationPostHAProxyConfigurationHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.DefaultsReplaceDefaultsHandler == nil { - unregistered = append(unregistered, "defaults.ReplaceDefaultsHandler") + o.handlers["PUT"]["/services/haproxy/runtime/acme"] = acme_runtime.NewRenewAcmeCertificate(o.context, o.AcmeRuntimeRenewAcmeCertificateHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.FilterReplaceFilterHandler == nil { - unregistered = append(unregistered, "filter.ReplaceFilterHandler") + o.handlers["PUT"]["/service_discovery/aws/{id}"] = service_discovery.NewReplaceAWSRegion(o.context, o.ServiceDiscoveryReplaceAWSRegionHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.FrontendReplaceFrontendHandler == nil { - unregistered = append(unregistered, "frontend.ReplaceFrontendHandler") + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/acls/{index}"] = acl.NewReplaceACLBackend(o.context, o.ACLReplaceACLBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.GlobalReplaceGlobalHandler == nil { - unregistered = append(unregistered, "global.ReplaceGlobalHandler") + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/acls/{index}"] = acl.NewReplaceACLDefaults(o.context, o.ACLReplaceACLDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.HTTPRequestRuleReplaceHTTPRequestRuleHandler == nil { - unregistered = append(unregistered, "http_request_rule.ReplaceHTTPRequestRuleHandler") + o.handlers["PUT"]["/services/haproxy/configuration/fcgi_apps/{parent_name}/acls/{index}"] = acl.NewReplaceACLFCGIApp(o.context, o.ACLReplaceACLFCGIAppHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.HTTPResponseRuleReplaceHTTPResponseRuleHandler == nil { - unregistered = append(unregistered, "http_response_rule.ReplaceHTTPResponseRuleHandler") + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/acls/{index}"] = acl.NewReplaceACLFrontend(o.context, o.ACLReplaceACLFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.LogTargetReplaceLogTargetHandler == nil { - unregistered = append(unregistered, "log_target.ReplaceLogTargetHandler") + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/acls"] = acl.NewReplaceAllACLBackend(o.context, o.ACLReplaceAllACLBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.ServerReplaceServerHandler == nil { - unregistered = append(unregistered, "server.ReplaceServerHandler") + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/acls"] = acl.NewReplaceAllACLDefaults(o.context, o.ACLReplaceAllACLDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.ServerSwitchingRuleReplaceServerSwitchingRuleHandler == nil { - unregistered = append(unregistered, "server_switching_rule.ReplaceServerSwitchingRuleHandler") + o.handlers["PUT"]["/services/haproxy/configuration/fcgi_apps/{parent_name}/acls"] = acl.NewReplaceAllACLFCGIApp(o.context, o.ACLReplaceAllACLFCGIAppHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.SitesReplaceSiteHandler == nil { - unregistered = append(unregistered, "sites.ReplaceSiteHandler") + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/acls"] = acl.NewReplaceAllACLFrontend(o.context, o.ACLReplaceAllACLFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.StickRuleReplaceStickRuleHandler == nil { - unregistered = append(unregistered, "stick_rule.ReplaceStickRuleHandler") + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/filters"] = filter.NewReplaceAllFilterBackend(o.context, o.FilterReplaceAllFilterBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.TCPRequestRuleReplaceTCPRequestRuleHandler == nil { - unregistered = append(unregistered, "tcp_request_rule.ReplaceTCPRequestRuleHandler") + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/filters"] = filter.NewReplaceAllFilterFrontend(o.context, o.FilterReplaceAllFilterFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.TCPResponseRuleReplaceTCPResponseRuleHandler == nil { - unregistered = append(unregistered, "tcp_response_rule.ReplaceTCPResponseRuleHandler") + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules"] = http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleBackend(o.context, o.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if o.TransactionsStartTransactionHandler == nil { - unregistered = append(unregistered, "transactions.StartTransactionHandler") + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules"] = http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleDefaults(o.context, o.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - if len(unregistered) > 0 { - return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules"] = http_after_response_rule.NewReplaceAllHTTPAfterResponseRuleFrontend(o.context, o.HTTPAfterResponseRuleReplaceAllHTTPAfterResponseRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - return nil -} - -// ServeErrorFor gets a error handler for a given operation id -func (o *DataPlaneAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { - return o.ServeError -} - -// AuthenticatorsFor gets the authenticators for the specified security schemes -func (o *DataPlaneAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { - - result := make(map[string]runtime.Authenticator) - for name, scheme := range schemes { - switch name { - - case "basic_auth": - _ = scheme - result[name] = o.BasicAuthenticator(o.BasicAuthAuth) - - } + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_checks"] = http_check.NewReplaceAllHTTPCheckBackend(o.context, o.HTTPCheckReplaceAllHTTPCheckBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - return result - -} - -// Authorizer returns the registered authorizer -func (o *DataPlaneAPI) Authorizer() runtime.Authorizer { - - return o.APIAuthorizer - -} - -// ConsumersFor gets the consumers for the specified media types -func (o *DataPlaneAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { - - result := make(map[string]runtime.Consumer) - for _, mt := range mediaTypes { - switch mt { - - case "application/json": - result["application/json"] = o.JSONConsumer - - case "text/plain": - result["text/plain"] = o.TxtConsumer - - } - - if c, ok := o.customConsumers[mt]; ok { - result[mt] = c - } + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_checks"] = http_check.NewReplaceAllHTTPCheckDefaults(o.context, o.HTTPCheckReplaceAllHTTPCheckDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - return result - -} - -// ProducersFor gets the producers for the specified media types -func (o *DataPlaneAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { - - result := make(map[string]runtime.Producer) - for _, mt := range mediaTypes { - switch mt { - - case "application/json": - result["application/json"] = o.JSONProducer - - case "text/plain": - result["text/plain"] = o.TxtProducer - - } - - if p, ok := o.customProducers[mt]; ok { - result[mt] = p - } + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_error_rules"] = http_error_rule.NewReplaceAllHTTPErrorRuleBackend(o.context, o.HTTPErrorRuleReplaceAllHTTPErrorRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - return result - -} - -// HandlerFor gets a http.Handler for the provided operation method and path -func (o *DataPlaneAPI) HandlerFor(method, path string) (http.Handler, bool) { - if o.handlers == nil { - return nil, false + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_error_rules"] = http_error_rule.NewReplaceAllHTTPErrorRuleDefaults(o.context, o.HTTPErrorRuleReplaceAllHTTPErrorRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - um := strings.ToUpper(method) - if _, ok := o.handlers[um]; !ok { - return nil, false + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_error_rules"] = http_error_rule.NewReplaceAllHTTPErrorRuleFrontend(o.context, o.HTTPErrorRuleReplaceAllHTTPErrorRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - if path == "/" { - path = "" + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_request_rules"] = http_request_rule.NewReplaceAllHTTPRequestRuleBackend(o.context, o.HTTPRequestRuleReplaceAllHTTPRequestRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - h, ok := o.handlers[um][path] - return h, ok -} - -// Context returns the middleware context for the data plane API -func (o *DataPlaneAPI) Context() *middleware.Context { - if o.context == nil { - o.context = middleware.NewRoutableContext(o.spec, o, nil) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_request_rules"] = http_request_rule.NewReplaceAllHTTPRequestRuleDefaults(o.context, o.HTTPRequestRuleReplaceAllHTTPRequestRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - - return o.context -} - -func (o *DataPlaneAPI) initHandlerCache() { - o.Context() // don't care about the result, just that the initialization happened - - if o.handlers == nil { - o.handlers = make(map[string]map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_request_rules"] = http_request_rule.NewReplaceAllHTTPRequestRuleFrontend(o.context, o.HTTPRequestRuleReplaceAllHTTPRequestRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_response_rules"] = http_response_rule.NewReplaceAllHTTPResponseRuleBackend(o.context, o.HTTPResponseRuleReplaceAllHTTPResponseRuleBackendHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/transactions/{id}"] = transactions.NewCommitTransaction(o.context, o.TransactionsCommitTransactionHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_response_rules"] = http_response_rule.NewReplaceAllHTTPResponseRuleDefaults(o.context, o.HTTPResponseRuleReplaceAllHTTPResponseRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/acls"] = acl.NewCreateACL(o.context, o.ACLCreateACLHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_response_rules"] = http_response_rule.NewReplaceAllHTTPResponseRuleFrontend(o.context, o.HTTPResponseRuleReplaceAllHTTPResponseRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/backends"] = backend.NewCreateBackend(o.context, o.BackendCreateBackendHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/log_targets"] = log_target.NewReplaceAllLogTargetBackend(o.context, o.LogTargetReplaceAllLogTargetBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/backend_switching_rules"] = backend_switching_rule.NewCreateBackendSwitchingRule(o.context, o.BackendSwitchingRuleCreateBackendSwitchingRuleHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/log_targets"] = log_target.NewReplaceAllLogTargetDefaults(o.context, o.LogTargetReplaceAllLogTargetDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/binds"] = bind.NewCreateBind(o.context, o.BindCreateBindHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/log_targets"] = log_target.NewReplaceAllLogTargetFrontend(o.context, o.LogTargetReplaceAllLogTargetFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/filters"] = filter.NewCreateFilter(o.context, o.FilterCreateFilterHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/global/log_targets"] = log_target.NewReplaceAllLogTargetGlobal(o.context, o.LogTargetReplaceAllLogTargetGlobalHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/frontends"] = frontend.NewCreateFrontend(o.context, o.FrontendCreateFrontendHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/log_forwards/{parent_name}/log_targets"] = log_target.NewReplaceAllLogTargetLogForward(o.context, o.LogTargetReplaceAllLogTargetLogForwardHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/http_request_rules"] = http_request_rule.NewCreateHTTPRequestRule(o.context, o.HTTPRequestRuleCreateHTTPRequestRuleHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/peers/{parent_name}/log_targets"] = log_target.NewReplaceAllLogTargetPeer(o.context, o.LogTargetReplaceAllLogTargetPeerHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/http_response_rules"] = http_response_rule.NewCreateHTTPResponseRule(o.context, o.HTTPResponseRuleCreateHTTPResponseRuleHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules"] = quic_initial_rule.NewReplaceAllQUICInitialRuleDefaults(o.context, o.QUICInitialRuleReplaceAllQUICInitialRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/log_targets"] = log_target.NewCreateLogTarget(o.context, o.LogTargetCreateLogTargetHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules"] = quic_initial_rule.NewReplaceAllQUICInitialRuleFrontend(o.context, o.QUICInitialRuleReplaceAllQUICInitialRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/servers"] = server.NewCreateServer(o.context, o.ServerCreateServerHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/tcp_checks"] = tcp_check.NewReplaceAllTCPCheckBackend(o.context, o.TCPCheckReplaceAllTCPCheckBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/server_switching_rules"] = server_switching_rule.NewCreateServerSwitchingRule(o.context, o.ServerSwitchingRuleCreateServerSwitchingRuleHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_checks"] = tcp_check.NewReplaceAllTCPCheckDefaults(o.context, o.TCPCheckReplaceAllTCPCheckDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/sites"] = sites.NewCreateSite(o.context, o.SitesCreateSiteHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules"] = tcp_request_rule.NewReplaceAllTCPRequestRuleBackend(o.context, o.TCPRequestRuleReplaceAllTCPRequestRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/stick_rules"] = stick_rule.NewCreateStickRule(o.context, o.StickRuleCreateStickRuleHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules"] = tcp_request_rule.NewReplaceAllTCPRequestRuleDefaults(o.context, o.TCPRequestRuleReplaceAllTCPRequestRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/tcp_request_rules"] = tcp_request_rule.NewCreateTCPRequestRule(o.context, o.TCPRequestRuleCreateTCPRequestRuleHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules"] = tcp_request_rule.NewReplaceAllTCPRequestRuleFrontend(o.context, o.TCPRequestRuleReplaceAllTCPRequestRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/tcp_response_rules"] = tcp_response_rule.NewCreateTCPResponseRule(o.context, o.TCPResponseRuleCreateTCPResponseRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules"] = tcp_response_rule.NewReplaceAllTCPResponseRuleBackend(o.context, o.TCPResponseRuleReplaceAllTCPResponseRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/acls/{id}"] = acl.NewDeleteACL(o.context, o.ACLDeleteACLHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules"] = tcp_response_rule.NewReplaceAllTCPResponseRuleDefaults(o.context, o.TCPResponseRuleReplaceAllTCPResponseRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/backends/{name}"] = backend.NewDeleteBackend(o.context, o.BackendDeleteBackendHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{name}"] = backend.NewReplaceBackend(o.context, o.BackendReplaceBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/backend_switching_rules/{id}"] = backend_switching_rule.NewDeleteBackendSwitchingRule(o.context, o.BackendSwitchingRuleDeleteBackendSwitchingRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules/{index}"] = backend_switching_rule.NewReplaceBackendSwitchingRule(o.context, o.BackendSwitchingRuleReplaceBackendSwitchingRuleHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/binds/{name}"] = bind.NewDeleteBind(o.context, o.BindDeleteBindHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/backend_switching_rules"] = backend_switching_rule.NewReplaceBackendSwitchingRules(o.context, o.BackendSwitchingRuleReplaceBackendSwitchingRulesHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/filters/{id}"] = filter.NewDeleteFilter(o.context, o.FilterDeleteFilterHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/binds/{name}"] = bind.NewReplaceBindFrontend(o.context, o.BindReplaceBindFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/frontends/{name}"] = frontend.NewDeleteFrontend(o.context, o.FrontendDeleteFrontendHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/log_forwards/{parent_name}/binds/{name}"] = bind.NewReplaceBindLogForward(o.context, o.BindReplaceBindLogForwardHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/http_request_rules/{id}"] = http_request_rule.NewDeleteHTTPRequestRule(o.context, o.HTTPRequestRuleDeleteHTTPRequestRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/peers/{parent_name}/binds/{name}"] = bind.NewReplaceBindPeer(o.context, o.BindReplaceBindPeerHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/http_response_rules/{id}"] = http_response_rule.NewDeleteHTTPResponseRule(o.context, o.HTTPResponseRuleDeleteHTTPResponseRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/caches/{name}"] = cache.NewReplaceCache(o.context, o.CacheReplaceCacheHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/log_targets/{id}"] = log_target.NewDeleteLogTarget(o.context, o.LogTargetDeleteLogTargetHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/runtime/ssl_certs/{name}"] = s_s_l_runtime.NewReplaceCert(o.context, o.SslRuntimeReplaceCertHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/servers/{name}"] = server.NewDeleteServer(o.context, o.ServerDeleteServerHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/service_discovery/consul/{id}"] = service_discovery.NewReplaceConsul(o.context, o.ServiceDiscoveryReplaceConsulHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/server_switching_rules/{id}"] = server_switching_rule.NewDeleteServerSwitchingRule(o.context, o.ServerSwitchingRuleDeleteServerSwitchingRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/runtime/ssl_crl_files/{name}"] = s_s_l_runtime.NewReplaceCrl(o.context, o.SslRuntimeReplaceCrlHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/sites/{name}"] = sites.NewDeleteSite(o.context, o.SitesDeleteSiteHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/crt_loads/{certificate}"] = crt_load.NewReplaceCrtLoad(o.context, o.CrtLoadReplaceCrtLoadHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/stick_rules/{id}"] = stick_rule.NewDeleteStickRule(o.context, o.StickRuleDeleteStickRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/captures/{index}"] = declare_capture.NewReplaceDeclareCapture(o.context, o.DeclareCaptureReplaceDeclareCaptureHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/tcp_request_rules/{id}"] = tcp_request_rule.NewDeleteTCPRequestRule(o.context, o.TCPRequestRuleDeleteTCPRequestRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/captures"] = declare_capture.NewReplaceDeclareCaptures(o.context, o.DeclareCaptureReplaceDeclareCapturesHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/configuration/tcp_response_rules/{id}"] = tcp_response_rule.NewDeleteTCPResponseRule(o.context, o.TCPResponseRuleDeleteTCPResponseRuleHandler) - - if o.handlers["DELETE"] == nil { - o.handlers["DELETE"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{name}"] = defaults.NewReplaceDefaultsSection(o.context, o.DefaultsReplaceDefaultsSectionHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["DELETE"]["/services/haproxy/transactions/{id}"] = transactions.NewDeleteTransaction(o.context, o.TransactionsDeleteTransactionHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}"] = dgram_bind.NewReplaceDgramBind(o.context, o.DgramBindReplaceDgramBindHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"][""] = discovery.NewGetAPIEndpoints(o.context, o.DiscoveryGetAPIEndpointsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/fcgi_apps/{name}"] = fcgi_app.NewReplaceFCGIApp(o.context, o.FCGIAppReplaceFCGIAppHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/acls/{id}"] = acl.NewGetACL(o.context, o.ACLGetACLHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/filters/{index}"] = filter.NewReplaceFilterBackend(o.context, o.FilterReplaceFilterBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/acls"] = acl.NewGetAcls(o.context, o.ACLGetAclsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/filters/{index}"] = filter.NewReplaceFilterFrontend(o.context, o.FilterReplaceFilterFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/backends/{name}"] = backend.NewGetBackend(o.context, o.BackendGetBackendHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{name}"] = frontend.NewReplaceFrontend(o.context, o.FrontendReplaceFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/backend_switching_rules/{id}"] = backend_switching_rule.NewGetBackendSwitchingRule(o.context, o.BackendSwitchingRuleGetBackendSwitchingRuleHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/global"] = global.NewReplaceGlobal(o.context, o.GlobalReplaceGlobalHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/backend_switching_rules"] = backend_switching_rule.NewGetBackendSwitchingRules(o.context, o.BackendSwitchingRuleGetBackendSwitchingRulesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/groups/{name}"] = group.NewReplaceGroup(o.context, o.GroupReplaceGroupHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/backends"] = backend.NewGetBackends(o.context, o.BackendGetBackendsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewReplaceHTTPAfterResponseRuleBackend(o.context, o.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewReplaceHTTPAfterResponseRuleDefaults(o.context, o.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}"] = http_after_response_rule.NewReplaceHTTPAfterResponseRuleFrontend(o.context, o.HTTPAfterResponseRuleReplaceHTTPAfterResponseRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/binds/{name}"] = bind.NewGetBind(o.context, o.BindGetBindHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}"] = http_check.NewReplaceHTTPCheckBackend(o.context, o.HTTPCheckReplaceHTTPCheckBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/binds"] = bind.NewGetBinds(o.context, o.BindGetBindsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}"] = http_check.NewReplaceHTTPCheckDefaults(o.context, o.HTTPCheckReplaceHTTPCheckDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration"] = discovery.NewGetConfigurationEndpoints(o.context, o.DiscoveryGetConfigurationEndpointsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewReplaceHTTPErrorRuleBackend(o.context, o.HTTPErrorRuleReplaceHTTPErrorRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/defaults"] = defaults.NewGetDefaults(o.context, o.DefaultsGetDefaultsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewReplaceHTTPErrorRuleDefaults(o.context, o.HTTPErrorRuleReplaceHTTPErrorRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/filters/{id}"] = filter.NewGetFilter(o.context, o.FilterGetFilterHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}"] = http_error_rule.NewReplaceHTTPErrorRuleFrontend(o.context, o.HTTPErrorRuleReplaceHTTPErrorRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/filters"] = filter.NewGetFilters(o.context, o.FilterGetFiltersHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/http_errors_sections/{name}"] = http_errors.NewReplaceHTTPErrorsSection(o.context, o.HTTPErrorsReplaceHTTPErrorsSectionHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/frontends/{name}"] = frontend.NewGetFrontend(o.context, o.FrontendGetFrontendHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewReplaceHTTPRequestRuleBackend(o.context, o.HTTPRequestRuleReplaceHTTPRequestRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/frontends"] = frontend.NewGetFrontends(o.context, o.FrontendGetFrontendsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewReplaceHTTPRequestRuleDefaults(o.context, o.HTTPRequestRuleReplaceHTTPRequestRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/global"] = global.NewGetGlobal(o.context, o.GlobalGetGlobalHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}"] = http_request_rule.NewReplaceHTTPRequestRuleFrontend(o.context, o.HTTPRequestRuleReplaceHTTPRequestRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/raw"] = configuration.NewGetHAProxyConfiguration(o.context, o.ConfigurationGetHAProxyConfigurationHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewReplaceHTTPResponseRuleBackend(o.context, o.HTTPResponseRuleReplaceHTTPResponseRuleBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/http_request_rules/{id}"] = http_request_rule.NewGetHTTPRequestRule(o.context, o.HTTPRequestRuleGetHTTPRequestRuleHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewReplaceHTTPResponseRuleDefaults(o.context, o.HTTPResponseRuleReplaceHTTPResponseRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/http_request_rules"] = http_request_rule.NewGetHTTPRequestRules(o.context, o.HTTPRequestRuleGetHTTPRequestRulesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}"] = http_response_rule.NewReplaceHTTPResponseRuleFrontend(o.context, o.HTTPResponseRuleReplaceHTTPResponseRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/http_response_rules/{id}"] = http_response_rule.NewGetHTTPResponseRule(o.context, o.HTTPResponseRuleGetHTTPResponseRuleHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/log_forwards/{name}"] = log_forward.NewReplaceLogForward(o.context, o.LogForwardReplaceLogForwardHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/http_response_rules"] = http_response_rule.NewGetHTTPResponseRules(o.context, o.HTTPResponseRuleGetHTTPResponseRulesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}"] = log_target.NewReplaceLogTargetBackend(o.context, o.LogTargetReplaceLogTargetBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy"] = discovery.NewGetHaproxyEndpoints(o.context, o.DiscoveryGetHaproxyEndpointsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}"] = log_target.NewReplaceLogTargetDefaults(o.context, o.LogTargetReplaceLogTargetDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/info"] = information.NewGetHaproxyProcessInfo(o.context, o.InformationGetHaproxyProcessInfoHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}"] = log_target.NewReplaceLogTargetFrontend(o.context, o.LogTargetReplaceLogTargetFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/info"] = information.NewGetInfo(o.context, o.InformationGetInfoHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/global/log_targets/{index}"] = log_target.NewReplaceLogTargetGlobal(o.context, o.LogTargetReplaceLogTargetGlobalHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/log_targets/{id}"] = log_target.NewGetLogTarget(o.context, o.LogTargetGetLogTargetHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}"] = log_target.NewReplaceLogTargetLogForward(o.context, o.LogTargetReplaceLogTargetLogForwardHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/log_targets"] = log_target.NewGetLogTargets(o.context, o.LogTargetGetLogTargetsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}"] = log_target.NewReplaceLogTargetPeer(o.context, o.LogTargetReplaceLogTargetPeerHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/reloads/{id}"] = reloads.NewGetReload(o.context, o.ReloadsGetReloadHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/mailer_entries/{name}"] = mailer_entry.NewReplaceMailerEntry(o.context, o.MailerEntryReplaceMailerEntryHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/reloads"] = reloads.NewGetReloads(o.context, o.ReloadsGetReloadsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/nameservers/{name}"] = nameserver.NewReplaceNameserver(o.context, o.NameserverReplaceNameserverHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/servers/{name}"] = server.NewGetServer(o.context, o.ServerGetServerHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/peer_entries/{name}"] = peer_entry.NewReplacePeerEntry(o.context, o.PeerEntryReplacePeerEntryHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/server_switching_rules/{id}"] = server_switching_rule.NewGetServerSwitchingRule(o.context, o.ServerSwitchingRuleGetServerSwitchingRuleHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/programs/{name}"] = process_manager.NewReplaceProgram(o.context, o.ProcessManagerReplaceProgramHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/server_switching_rules"] = server_switching_rule.NewGetServerSwitchingRules(o.context, o.ServerSwitchingRuleGetServerSwitchingRulesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewReplaceQUICInitialRuleDefaults(o.context, o.QUICInitialRuleReplaceQUICInitialRuleDefaultsHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/servers"] = server.NewGetServers(o.context, o.ServerGetServersHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}"] = quic_initial_rule.NewReplaceQUICInitialRuleFrontend(o.context, o.QUICInitialRuleReplaceQUICInitialRuleFrontendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services"] = discovery.NewGetServicesEndpoints(o.context, o.DiscoveryGetServicesEndpointsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/resolvers/{name}"] = resolver.NewReplaceResolver(o.context, o.ResolverReplaceResolverHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/sites/{name}"] = sites.NewGetSite(o.context, o.SitesGetSiteHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/rings/{name}"] = ring.NewReplaceRing(o.context, o.RingReplaceRingHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/sites"] = sites.NewGetSites(o.context, o.SitesGetSitesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/runtime/maps/{parent_name}/entries/{id}"] = maps.NewReplaceRuntimeMapEntry(o.context, o.MapsReplaceRuntimeMapEntryHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/specification"] = specification.NewGetSpecification(o.context, o.SpecificationGetSpecificationHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/runtime/backends/{parent_name}/servers/{name}"] = serverops.NewReplaceRuntimeServer(o.context, o.ServerReplaceRuntimeServerHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/stats/native"] = stats.NewGetStats(o.context, o.StatsGetStatsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}"] = s_s_l_front_use.NewReplaceSSLFrontUse(o.context, o.SslFrontUseReplaceSSLFrontUseHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/stats"] = discovery.NewGetStatsEndpoints(o.context, o.DiscoveryGetStatsEndpointsHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/servers/{name}"] = serverops.NewReplaceServerBackend(o.context, o.ServerReplaceServerBackendHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/stick_rules/{id}"] = stick_rule.NewGetStickRule(o.context, o.StickRuleGetStickRuleHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/peers/{parent_name}/servers/{name}"] = serverops.NewReplaceServerPeer(o.context, o.ServerReplaceServerPeerHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/stick_rules"] = stick_rule.NewGetStickRules(o.context, o.StickRuleGetStickRulesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/rings/{parent_name}/servers/{name}"] = serverops.NewReplaceServerRing(o.context, o.ServerReplaceServerRingHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/tcp_request_rules/{id}"] = tcp_request_rule.NewGetTCPRequestRule(o.context, o.TCPRequestRuleGetTCPRequestRuleHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}"] = server_switching_rule.NewReplaceServerSwitchingRule(o.context, o.ServerSwitchingRuleReplaceServerSwitchingRuleHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/tcp_request_rules"] = tcp_request_rule.NewGetTCPRequestRules(o.context, o.TCPRequestRuleGetTCPRequestRulesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/server_switching_rules"] = server_switching_rule.NewReplaceServerSwitchingRules(o.context, o.ServerSwitchingRuleReplaceServerSwitchingRulesHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/tcp_response_rules/{id}"] = tcp_response_rule.NewGetTCPResponseRule(o.context, o.TCPResponseRuleGetTCPResponseRuleHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}"] = server_template.NewReplaceServerTemplate(o.context, o.ServerTemplateReplaceServerTemplateHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/configuration/tcp_response_rules"] = tcp_response_rule.NewGetTCPResponseRules(o.context, o.TCPResponseRuleGetTCPResponseRulesHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/sites/{name}"] = sites.NewReplaceSite(o.context, o.SitesReplaceSiteHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/transactions/{id}"] = transactions.NewGetTransaction(o.context, o.TransactionsGetTransactionHandler) - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}"] = spoe.NewReplaceSpoeAgent(o.context, o.SpoeReplaceSpoeAgentHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["GET"]["/services/haproxy/transactions"] = transactions.NewGetTransactions(o.context, o.TransactionsGetTransactionsHandler) - - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) + o.handlers["PUT"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}"] = spoe.NewReplaceSpoeGroup(o.context, o.SpoeReplaceSpoeGroupHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["POST"]["/services/haproxy/configuration/raw"] = configuration.NewPostHAProxyConfiguration(o.context, o.ConfigurationPostHAProxyConfigurationHandler) - + o.handlers["PUT"]["/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}"] = spoe.NewReplaceSpoeMessage(o.context, o.SpoeReplaceSpoeMessageHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/acls/{id}"] = acl.NewReplaceACL(o.context, o.ACLReplaceACLHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}"] = stick_rule.NewReplaceStickRule(o.context, o.StickRuleReplaceStickRuleHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/backends/{name}"] = backend.NewReplaceBackend(o.context, o.BackendReplaceBackendHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/stick_rules"] = stick_rule.NewReplaceStickRules(o.context, o.StickRuleReplaceStickRulesHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/backend_switching_rules/{id}"] = backend_switching_rule.NewReplaceBackendSwitchingRule(o.context, o.BackendSwitchingRuleReplaceBackendSwitchingRuleHandler) - + o.handlers["PUT"]["/services/haproxy/storage/general/{name}"] = storage.NewReplaceStorageGeneralFile(o.context, o.StorageReplaceStorageGeneralFileHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/binds/{name}"] = bind.NewReplaceBind(o.context, o.BindReplaceBindHandler) - + o.handlers["PUT"]["/services/haproxy/storage/maps/{name}"] = storage.NewReplaceStorageMapFile(o.context, o.StorageReplaceStorageMapFileHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/defaults"] = defaults.NewReplaceDefaults(o.context, o.DefaultsReplaceDefaultsHandler) - + o.handlers["PUT"]["/services/haproxy/storage/ssl_certificates/{name}"] = storage.NewReplaceStorageSSLCertificate(o.context, o.StorageReplaceStorageSSLCertificateHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/filters/{id}"] = filter.NewReplaceFilter(o.context, o.FilterReplaceFilterHandler) - + o.handlers["PUT"]["/services/haproxy/storage/ssl_crt_lists/{name}"] = storage.NewReplaceStorageSSLCrtListFile(o.context, o.StorageReplaceStorageSSLCrtListFileHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/frontends/{name}"] = frontend.NewReplaceFrontend(o.context, o.FrontendReplaceFrontendHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}"] = tcp_check.NewReplaceTCPCheckBackend(o.context, o.TCPCheckReplaceTCPCheckBackendHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/global"] = global.NewReplaceGlobal(o.context, o.GlobalReplaceGlobalHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}"] = tcp_check.NewReplaceTCPCheckDefaults(o.context, o.TCPCheckReplaceTCPCheckDefaultsHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/http_request_rules/{id}"] = http_request_rule.NewReplaceHTTPRequestRule(o.context, o.HTTPRequestRuleReplaceHTTPRequestRuleHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewReplaceTCPRequestRuleBackend(o.context, o.TCPRequestRuleReplaceTCPRequestRuleBackendHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/http_response_rules/{id}"] = http_response_rule.NewReplaceHTTPResponseRule(o.context, o.HTTPResponseRuleReplaceHTTPResponseRuleHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewReplaceTCPRequestRuleDefaults(o.context, o.TCPRequestRuleReplaceTCPRequestRuleDefaultsHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/log_targets/{id}"] = log_target.NewReplaceLogTarget(o.context, o.LogTargetReplaceLogTargetHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}"] = tcp_request_rule.NewReplaceTCPRequestRuleFrontend(o.context, o.TCPRequestRuleReplaceTCPRequestRuleFrontendHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/servers/{name}"] = server.NewReplaceServer(o.context, o.ServerReplaceServerHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewReplaceTCPResponseRuleBackend(o.context, o.TCPResponseRuleReplaceTCPResponseRuleBackendHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/server_switching_rules/{id}"] = server_switching_rule.NewReplaceServerSwitchingRule(o.context, o.ServerSwitchingRuleReplaceServerSwitchingRuleHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}"] = tcp_response_rule.NewReplaceTCPResponseRuleDefaults(o.context, o.TCPResponseRuleReplaceTCPResponseRuleDefaultsHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/sites/{name}"] = sites.NewReplaceSite(o.context, o.SitesReplaceSiteHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/peers/{parent_name}/tables/{name}"] = table.NewReplaceTable(o.context, o.TableReplaceTableHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/stick_rules/{id}"] = stick_rule.NewReplaceStickRule(o.context, o.StickRuleReplaceStickRuleHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/traces"] = traces.NewReplaceTraces(o.context, o.TracesReplaceTracesHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/tcp_request_rules/{id}"] = tcp_request_rule.NewReplaceTCPRequestRule(o.context, o.TCPRequestRuleReplaceTCPRequestRuleHandler) - + o.handlers["PUT"]["/services/haproxy/configuration/users/{username}"] = user.NewReplaceUser(o.context, o.UserReplaceUserHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/services/haproxy/configuration/tcp_response_rules/{id}"] = tcp_response_rule.NewReplaceTCPResponseRule(o.context, o.TCPResponseRuleReplaceTCPResponseRuleHandler) - + o.handlers["PUT"]["/services/haproxy/runtime/ssl_ca_files/{name}"] = s_s_l_runtime.NewSetCaFile(o.context, o.SslRuntimeSetCaFileHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/runtime/stick_tables/{parent_name}/entries"] = stick_table.NewSetStickTableEntries(o.context, o.StickTableSetStickTableEntriesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/services/haproxy/runtime/maps/{parent_name}/entries"] = maps.NewShowRuntimeMap(o.context, o.MapsShowRuntimeMapHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/services/haproxy/spoe/spoe_files/{parent_name}/transactions"] = spoe_transactions.NewStartSpoeTransaction(o.context, o.SpoeTransactionsStartSpoeTransactionHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } o.handlers["POST"]["/services/haproxy/transactions"] = transactions.NewStartTransaction(o.context, o.TransactionsStartTransactionHandler) - } // Serve creates a http handler to serve the API over HTTP @@ -1688,6 +6940,9 @@ func (o *DataPlaneAPI) Serve(builder middleware.Builder) http.Handler { if o.Middleware != nil { return o.Middleware(builder) } + if o.useSwaggerUI { + return o.context.APIHandlerSwaggerUI(builder) + } return o.context.APIHandler(builder) } @@ -1707,3 +6962,15 @@ func (o *DataPlaneAPI) RegisterConsumer(mediaType string, consumer runtime.Consu func (o *DataPlaneAPI) RegisterProducer(mediaType string, producer runtime.Producer) { o.customProducers[mediaType] = producer } + +// AddMiddlewareFor adds a http middleware to existing handler +func (o *DataPlaneAPI) AddMiddlewareFor(method, path string, builder middleware.Builder) { + um := strings.ToUpper(method) + if path == "/" { + path = "" + } + o.Init() + if h, ok := o.handlers[um][path]; ok { + o.handlers[um][path] = builder(h) + } +} diff --git a/operations/declare_capture/create_declare_capture.go b/operations/declare_capture/create_declare_capture.go new file mode 100644 index 00000000..a3bd8724 --- /dev/null +++ b/operations/declare_capture/create_declare_capture.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateDeclareCaptureHandlerFunc turns a function with the right signature into a create declare capture handler +type CreateDeclareCaptureHandlerFunc func(CreateDeclareCaptureParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateDeclareCaptureHandlerFunc) Handle(params CreateDeclareCaptureParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateDeclareCaptureHandler interface for that can handle valid create declare capture params +type CreateDeclareCaptureHandler interface { + Handle(CreateDeclareCaptureParams, interface{}) middleware.Responder +} + +// NewCreateDeclareCapture creates a new http.Handler for the create declare capture operation +func NewCreateDeclareCapture(ctx *middleware.Context, handler CreateDeclareCaptureHandler) *CreateDeclareCapture { + return &CreateDeclareCapture{Context: ctx, Handler: handler} +} + +/* + CreateDeclareCapture swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/captures/{index} DeclareCapture createDeclareCapture + +# Add a new declare capture + +Adds a new declare capture in the specified frontend in the configuration file. +*/ +type CreateDeclareCapture struct { + Context *middleware.Context + Handler CreateDeclareCaptureHandler +} + +func (o *CreateDeclareCapture) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateDeclareCaptureParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/declare_capture/create_declare_capture_parameters.go b/operations/declare_capture/create_declare_capture_parameters.go new file mode 100644 index 00000000..b0a4af84 --- /dev/null +++ b/operations/declare_capture/create_declare_capture_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateDeclareCaptureParams creates a new CreateDeclareCaptureParams object +// with the default values initialized. +func NewCreateDeclareCaptureParams() CreateDeclareCaptureParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateDeclareCaptureParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateDeclareCaptureParams contains all the bound params for the create declare capture operation +// typically these are obtained from a http.Request +// +// swagger:parameters createDeclareCapture +type CreateDeclareCaptureParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Capture + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Declare Capture Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateDeclareCaptureParams() beforehand. +func (o *CreateDeclareCaptureParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Capture + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateDeclareCaptureParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateDeclareCaptureParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateDeclareCaptureParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateDeclareCaptureParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateDeclareCaptureParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateDeclareCaptureParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/declare_capture/create_declare_capture_responses.go b/operations/declare_capture/create_declare_capture_responses.go new file mode 100644 index 00000000..841fc063 --- /dev/null +++ b/operations/declare_capture/create_declare_capture_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateDeclareCaptureCreatedCode is the HTTP code returned for type CreateDeclareCaptureCreated +const CreateDeclareCaptureCreatedCode int = 201 + +/* +CreateDeclareCaptureCreated Declare capture created + +swagger:response createDeclareCaptureCreated +*/ +type CreateDeclareCaptureCreated struct { + + /* + In: Body + */ + Payload *models.Capture `json:"body,omitempty"` +} + +// NewCreateDeclareCaptureCreated creates CreateDeclareCaptureCreated with default headers values +func NewCreateDeclareCaptureCreated() *CreateDeclareCaptureCreated { + + return &CreateDeclareCaptureCreated{} +} + +// WithPayload adds the payload to the create declare capture created response +func (o *CreateDeclareCaptureCreated) WithPayload(payload *models.Capture) *CreateDeclareCaptureCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create declare capture created response +func (o *CreateDeclareCaptureCreated) SetPayload(payload *models.Capture) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDeclareCaptureCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDeclareCaptureAcceptedCode is the HTTP code returned for type CreateDeclareCaptureAccepted +const CreateDeclareCaptureAcceptedCode int = 202 + +/* +CreateDeclareCaptureAccepted Configuration change accepted and reload requested + +swagger:response createDeclareCaptureAccepted +*/ +type CreateDeclareCaptureAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Capture `json:"body,omitempty"` +} + +// NewCreateDeclareCaptureAccepted creates CreateDeclareCaptureAccepted with default headers values +func NewCreateDeclareCaptureAccepted() *CreateDeclareCaptureAccepted { + + return &CreateDeclareCaptureAccepted{} +} + +// WithReloadID adds the reloadId to the create declare capture accepted response +func (o *CreateDeclareCaptureAccepted) WithReloadID(reloadID string) *CreateDeclareCaptureAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create declare capture accepted response +func (o *CreateDeclareCaptureAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create declare capture accepted response +func (o *CreateDeclareCaptureAccepted) WithPayload(payload *models.Capture) *CreateDeclareCaptureAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create declare capture accepted response +func (o *CreateDeclareCaptureAccepted) SetPayload(payload *models.Capture) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDeclareCaptureAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDeclareCaptureBadRequestCode is the HTTP code returned for type CreateDeclareCaptureBadRequest +const CreateDeclareCaptureBadRequestCode int = 400 + +/* +CreateDeclareCaptureBadRequest Bad request + +swagger:response createDeclareCaptureBadRequest +*/ +type CreateDeclareCaptureBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDeclareCaptureBadRequest creates CreateDeclareCaptureBadRequest with default headers values +func NewCreateDeclareCaptureBadRequest() *CreateDeclareCaptureBadRequest { + + return &CreateDeclareCaptureBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create declare capture bad request response +func (o *CreateDeclareCaptureBadRequest) WithConfigurationVersion(configurationVersion string) *CreateDeclareCaptureBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create declare capture bad request response +func (o *CreateDeclareCaptureBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create declare capture bad request response +func (o *CreateDeclareCaptureBadRequest) WithPayload(payload *models.Error) *CreateDeclareCaptureBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create declare capture bad request response +func (o *CreateDeclareCaptureBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDeclareCaptureBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDeclareCaptureConflictCode is the HTTP code returned for type CreateDeclareCaptureConflict +const CreateDeclareCaptureConflictCode int = 409 + +/* +CreateDeclareCaptureConflict The specified resource already exists + +swagger:response createDeclareCaptureConflict +*/ +type CreateDeclareCaptureConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDeclareCaptureConflict creates CreateDeclareCaptureConflict with default headers values +func NewCreateDeclareCaptureConflict() *CreateDeclareCaptureConflict { + + return &CreateDeclareCaptureConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create declare capture conflict response +func (o *CreateDeclareCaptureConflict) WithConfigurationVersion(configurationVersion string) *CreateDeclareCaptureConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create declare capture conflict response +func (o *CreateDeclareCaptureConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create declare capture conflict response +func (o *CreateDeclareCaptureConflict) WithPayload(payload *models.Error) *CreateDeclareCaptureConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create declare capture conflict response +func (o *CreateDeclareCaptureConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDeclareCaptureConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateDeclareCaptureDefault General Error + +swagger:response createDeclareCaptureDefault +*/ +type CreateDeclareCaptureDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDeclareCaptureDefault creates CreateDeclareCaptureDefault with default headers values +func NewCreateDeclareCaptureDefault(code int) *CreateDeclareCaptureDefault { + if code <= 0 { + code = 500 + } + + return &CreateDeclareCaptureDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create declare capture default response +func (o *CreateDeclareCaptureDefault) WithStatusCode(code int) *CreateDeclareCaptureDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create declare capture default response +func (o *CreateDeclareCaptureDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create declare capture default response +func (o *CreateDeclareCaptureDefault) WithConfigurationVersion(configurationVersion string) *CreateDeclareCaptureDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create declare capture default response +func (o *CreateDeclareCaptureDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create declare capture default response +func (o *CreateDeclareCaptureDefault) WithPayload(payload *models.Error) *CreateDeclareCaptureDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create declare capture default response +func (o *CreateDeclareCaptureDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDeclareCaptureDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/declare_capture/create_declare_capture_urlbuilder.go b/operations/declare_capture/create_declare_capture_urlbuilder.go new file mode 100644 index 00000000..175519d4 --- /dev/null +++ b/operations/declare_capture/create_declare_capture_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateDeclareCaptureURL generates an URL for the create declare capture operation +type CreateDeclareCaptureURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateDeclareCaptureURL) WithBasePath(bp string) *CreateDeclareCaptureURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateDeclareCaptureURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateDeclareCaptureURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/captures/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateDeclareCaptureURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateDeclareCaptureURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateDeclareCaptureURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateDeclareCaptureURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateDeclareCaptureURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateDeclareCaptureURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateDeclareCaptureURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateDeclareCaptureURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/declare_capture/delete_declare_capture.go b/operations/declare_capture/delete_declare_capture.go new file mode 100644 index 00000000..027c2950 --- /dev/null +++ b/operations/declare_capture/delete_declare_capture.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteDeclareCaptureHandlerFunc turns a function with the right signature into a delete declare capture handler +type DeleteDeclareCaptureHandlerFunc func(DeleteDeclareCaptureParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteDeclareCaptureHandlerFunc) Handle(params DeleteDeclareCaptureParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteDeclareCaptureHandler interface for that can handle valid delete declare capture params +type DeleteDeclareCaptureHandler interface { + Handle(DeleteDeclareCaptureParams, interface{}) middleware.Responder +} + +// NewDeleteDeclareCapture creates a new http.Handler for the delete declare capture operation +func NewDeleteDeclareCapture(ctx *middleware.Context, handler DeleteDeclareCaptureHandler) *DeleteDeclareCapture { + return &DeleteDeclareCapture{Context: ctx, Handler: handler} +} + +/* + DeleteDeclareCapture swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/captures/{index} DeclareCapture deleteDeclareCapture + +# Delete a declare capture + +Deletes a declare capture configuration by it's index in the specified frontend. +*/ +type DeleteDeclareCapture struct { + Context *middleware.Context + Handler DeleteDeclareCaptureHandler +} + +func (o *DeleteDeclareCapture) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteDeclareCaptureParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/declare_capture/delete_declare_capture_parameters.go b/operations/declare_capture/delete_declare_capture_parameters.go new file mode 100644 index 00000000..979440dc --- /dev/null +++ b/operations/declare_capture/delete_declare_capture_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteDeclareCaptureParams creates a new DeleteDeclareCaptureParams object +// with the default values initialized. +func NewDeleteDeclareCaptureParams() DeleteDeclareCaptureParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteDeclareCaptureParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteDeclareCaptureParams contains all the bound params for the delete declare capture operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteDeclareCapture +type DeleteDeclareCaptureParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Declare Capture Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteDeclareCaptureParams() beforehand. +func (o *DeleteDeclareCaptureParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteDeclareCaptureParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteDeclareCaptureParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteDeclareCaptureParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteDeclareCaptureParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteDeclareCaptureParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteDeclareCaptureParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/declare_capture/delete_declare_capture_responses.go b/operations/declare_capture/delete_declare_capture_responses.go new file mode 100644 index 00000000..4a152d6f --- /dev/null +++ b/operations/declare_capture/delete_declare_capture_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteDeclareCaptureAcceptedCode is the HTTP code returned for type DeleteDeclareCaptureAccepted +const DeleteDeclareCaptureAcceptedCode int = 202 + +/* +DeleteDeclareCaptureAccepted Configuration change accepted and reload requested + +swagger:response deleteDeclareCaptureAccepted +*/ +type DeleteDeclareCaptureAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteDeclareCaptureAccepted creates DeleteDeclareCaptureAccepted with default headers values +func NewDeleteDeclareCaptureAccepted() *DeleteDeclareCaptureAccepted { + + return &DeleteDeclareCaptureAccepted{} +} + +// WithReloadID adds the reloadId to the delete declare capture accepted response +func (o *DeleteDeclareCaptureAccepted) WithReloadID(reloadID string) *DeleteDeclareCaptureAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete declare capture accepted response +func (o *DeleteDeclareCaptureAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteDeclareCaptureAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteDeclareCaptureNoContentCode is the HTTP code returned for type DeleteDeclareCaptureNoContent +const DeleteDeclareCaptureNoContentCode int = 204 + +/* +DeleteDeclareCaptureNoContent Declare Capture deleted + +swagger:response deleteDeclareCaptureNoContent +*/ +type DeleteDeclareCaptureNoContent struct { +} + +// NewDeleteDeclareCaptureNoContent creates DeleteDeclareCaptureNoContent with default headers values +func NewDeleteDeclareCaptureNoContent() *DeleteDeclareCaptureNoContent { + + return &DeleteDeclareCaptureNoContent{} +} + +// WriteResponse to the client +func (o *DeleteDeclareCaptureNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteDeclareCaptureNotFoundCode is the HTTP code returned for type DeleteDeclareCaptureNotFound +const DeleteDeclareCaptureNotFoundCode int = 404 + +/* +DeleteDeclareCaptureNotFound The specified resource was not found + +swagger:response deleteDeclareCaptureNotFound +*/ +type DeleteDeclareCaptureNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteDeclareCaptureNotFound creates DeleteDeclareCaptureNotFound with default headers values +func NewDeleteDeclareCaptureNotFound() *DeleteDeclareCaptureNotFound { + + return &DeleteDeclareCaptureNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete declare capture not found response +func (o *DeleteDeclareCaptureNotFound) WithConfigurationVersion(configurationVersion string) *DeleteDeclareCaptureNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete declare capture not found response +func (o *DeleteDeclareCaptureNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete declare capture not found response +func (o *DeleteDeclareCaptureNotFound) WithPayload(payload *models.Error) *DeleteDeclareCaptureNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete declare capture not found response +func (o *DeleteDeclareCaptureNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteDeclareCaptureNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteDeclareCaptureDefault General Error + +swagger:response deleteDeclareCaptureDefault +*/ +type DeleteDeclareCaptureDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteDeclareCaptureDefault creates DeleteDeclareCaptureDefault with default headers values +func NewDeleteDeclareCaptureDefault(code int) *DeleteDeclareCaptureDefault { + if code <= 0 { + code = 500 + } + + return &DeleteDeclareCaptureDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete declare capture default response +func (o *DeleteDeclareCaptureDefault) WithStatusCode(code int) *DeleteDeclareCaptureDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete declare capture default response +func (o *DeleteDeclareCaptureDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete declare capture default response +func (o *DeleteDeclareCaptureDefault) WithConfigurationVersion(configurationVersion string) *DeleteDeclareCaptureDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete declare capture default response +func (o *DeleteDeclareCaptureDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete declare capture default response +func (o *DeleteDeclareCaptureDefault) WithPayload(payload *models.Error) *DeleteDeclareCaptureDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete declare capture default response +func (o *DeleteDeclareCaptureDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteDeclareCaptureDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/declare_capture/delete_declare_capture_urlbuilder.go b/operations/declare_capture/delete_declare_capture_urlbuilder.go new file mode 100644 index 00000000..d5b5f04b --- /dev/null +++ b/operations/declare_capture/delete_declare_capture_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteDeclareCaptureURL generates an URL for the delete declare capture operation +type DeleteDeclareCaptureURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteDeclareCaptureURL) WithBasePath(bp string) *DeleteDeclareCaptureURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteDeclareCaptureURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteDeclareCaptureURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/captures/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteDeclareCaptureURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteDeclareCaptureURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteDeclareCaptureURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteDeclareCaptureURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteDeclareCaptureURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteDeclareCaptureURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteDeclareCaptureURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteDeclareCaptureURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/declare_capture/get_declare_capture.go b/operations/declare_capture/get_declare_capture.go new file mode 100644 index 00000000..48e28980 --- /dev/null +++ b/operations/declare_capture/get_declare_capture.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetDeclareCaptureHandlerFunc turns a function with the right signature into a get declare capture handler +type GetDeclareCaptureHandlerFunc func(GetDeclareCaptureParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetDeclareCaptureHandlerFunc) Handle(params GetDeclareCaptureParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetDeclareCaptureHandler interface for that can handle valid get declare capture params +type GetDeclareCaptureHandler interface { + Handle(GetDeclareCaptureParams, interface{}) middleware.Responder +} + +// NewGetDeclareCapture creates a new http.Handler for the get declare capture operation +func NewGetDeclareCapture(ctx *middleware.Context, handler GetDeclareCaptureHandler) *GetDeclareCapture { + return &GetDeclareCapture{Context: ctx, Handler: handler} +} + +/* + GetDeclareCapture swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/captures/{index} DeclareCapture getDeclareCapture + +# Return one declare capture + +Returns one declare capture configuration by it's index in the specified frontend. +*/ +type GetDeclareCapture struct { + Context *middleware.Context + Handler GetDeclareCaptureHandler +} + +func (o *GetDeclareCapture) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetDeclareCaptureParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/declare_capture/get_declare_capture_parameters.go b/operations/declare_capture/get_declare_capture_parameters.go new file mode 100644 index 00000000..02c47cc4 --- /dev/null +++ b/operations/declare_capture/get_declare_capture_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetDeclareCaptureParams creates a new GetDeclareCaptureParams object +// +// There are no default values defined in the spec. +func NewGetDeclareCaptureParams() GetDeclareCaptureParams { + + return GetDeclareCaptureParams{} +} + +// GetDeclareCaptureParams contains all the bound params for the get declare capture operation +// typically these are obtained from a http.Request +// +// swagger:parameters getDeclareCapture +type GetDeclareCaptureParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Declare Capture Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetDeclareCaptureParams() beforehand. +func (o *GetDeclareCaptureParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetDeclareCaptureParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetDeclareCaptureParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetDeclareCaptureParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/declare_capture/get_declare_capture_responses.go b/operations/declare_capture/get_declare_capture_responses.go new file mode 100644 index 00000000..c9b61754 --- /dev/null +++ b/operations/declare_capture/get_declare_capture_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetDeclareCaptureOKCode is the HTTP code returned for type GetDeclareCaptureOK +const GetDeclareCaptureOKCode int = 200 + +/* +GetDeclareCaptureOK Successful operation + +swagger:response getDeclareCaptureOK +*/ +type GetDeclareCaptureOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Capture `json:"body,omitempty"` +} + +// NewGetDeclareCaptureOK creates GetDeclareCaptureOK with default headers values +func NewGetDeclareCaptureOK() *GetDeclareCaptureOK { + + return &GetDeclareCaptureOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get declare capture o k response +func (o *GetDeclareCaptureOK) WithConfigurationVersion(configurationVersion string) *GetDeclareCaptureOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get declare capture o k response +func (o *GetDeclareCaptureOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get declare capture o k response +func (o *GetDeclareCaptureOK) WithPayload(payload *models.Capture) *GetDeclareCaptureOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get declare capture o k response +func (o *GetDeclareCaptureOK) SetPayload(payload *models.Capture) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDeclareCaptureOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetDeclareCaptureNotFoundCode is the HTTP code returned for type GetDeclareCaptureNotFound +const GetDeclareCaptureNotFoundCode int = 404 + +/* +GetDeclareCaptureNotFound The specified resource already exists + +swagger:response getDeclareCaptureNotFound +*/ +type GetDeclareCaptureNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDeclareCaptureNotFound creates GetDeclareCaptureNotFound with default headers values +func NewGetDeclareCaptureNotFound() *GetDeclareCaptureNotFound { + + return &GetDeclareCaptureNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get declare capture not found response +func (o *GetDeclareCaptureNotFound) WithConfigurationVersion(configurationVersion string) *GetDeclareCaptureNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get declare capture not found response +func (o *GetDeclareCaptureNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get declare capture not found response +func (o *GetDeclareCaptureNotFound) WithPayload(payload *models.Error) *GetDeclareCaptureNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get declare capture not found response +func (o *GetDeclareCaptureNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDeclareCaptureNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetDeclareCaptureDefault General Error + +swagger:response getDeclareCaptureDefault +*/ +type GetDeclareCaptureDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDeclareCaptureDefault creates GetDeclareCaptureDefault with default headers values +func NewGetDeclareCaptureDefault(code int) *GetDeclareCaptureDefault { + if code <= 0 { + code = 500 + } + + return &GetDeclareCaptureDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get declare capture default response +func (o *GetDeclareCaptureDefault) WithStatusCode(code int) *GetDeclareCaptureDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get declare capture default response +func (o *GetDeclareCaptureDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get declare capture default response +func (o *GetDeclareCaptureDefault) WithConfigurationVersion(configurationVersion string) *GetDeclareCaptureDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get declare capture default response +func (o *GetDeclareCaptureDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get declare capture default response +func (o *GetDeclareCaptureDefault) WithPayload(payload *models.Error) *GetDeclareCaptureDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get declare capture default response +func (o *GetDeclareCaptureDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDeclareCaptureDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/declare_capture/get_declare_capture_urlbuilder.go b/operations/declare_capture/get_declare_capture_urlbuilder.go new file mode 100644 index 00000000..85686ae1 --- /dev/null +++ b/operations/declare_capture/get_declare_capture_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetDeclareCaptureURL generates an URL for the get declare capture operation +type GetDeclareCaptureURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDeclareCaptureURL) WithBasePath(bp string) *GetDeclareCaptureURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDeclareCaptureURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetDeclareCaptureURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/captures/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetDeclareCaptureURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetDeclareCaptureURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetDeclareCaptureURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetDeclareCaptureURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetDeclareCaptureURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetDeclareCaptureURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetDeclareCaptureURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetDeclareCaptureURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/declare_capture/get_declare_captures.go b/operations/declare_capture/get_declare_captures.go new file mode 100644 index 00000000..ebf64077 --- /dev/null +++ b/operations/declare_capture/get_declare_captures.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetDeclareCapturesHandlerFunc turns a function with the right signature into a get declare captures handler +type GetDeclareCapturesHandlerFunc func(GetDeclareCapturesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetDeclareCapturesHandlerFunc) Handle(params GetDeclareCapturesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetDeclareCapturesHandler interface for that can handle valid get declare captures params +type GetDeclareCapturesHandler interface { + Handle(GetDeclareCapturesParams, interface{}) middleware.Responder +} + +// NewGetDeclareCaptures creates a new http.Handler for the get declare captures operation +func NewGetDeclareCaptures(ctx *middleware.Context, handler GetDeclareCapturesHandler) *GetDeclareCaptures { + return &GetDeclareCaptures{Context: ctx, Handler: handler} +} + +/* + GetDeclareCaptures swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/captures DeclareCapture getDeclareCaptures + +# Return an array of declare captures + +Returns an array of all declare capture records that are configured in specified frontend. +*/ +type GetDeclareCaptures struct { + Context *middleware.Context + Handler GetDeclareCapturesHandler +} + +func (o *GetDeclareCaptures) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetDeclareCapturesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/declare_capture/get_declare_captures_parameters.go b/operations/declare_capture/get_declare_captures_parameters.go new file mode 100644 index 00000000..dbc989fe --- /dev/null +++ b/operations/declare_capture/get_declare_captures_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetDeclareCapturesParams creates a new GetDeclareCapturesParams object +// +// There are no default values defined in the spec. +func NewGetDeclareCapturesParams() GetDeclareCapturesParams { + + return GetDeclareCapturesParams{} +} + +// GetDeclareCapturesParams contains all the bound params for the get declare captures operation +// typically these are obtained from a http.Request +// +// swagger:parameters getDeclareCaptures +type GetDeclareCapturesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetDeclareCapturesParams() beforehand. +func (o *GetDeclareCapturesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetDeclareCapturesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetDeclareCapturesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/declare_capture/get_declare_captures_responses.go b/operations/declare_capture/get_declare_captures_responses.go new file mode 100644 index 00000000..a0c364fb --- /dev/null +++ b/operations/declare_capture/get_declare_captures_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetDeclareCapturesOKCode is the HTTP code returned for type GetDeclareCapturesOK +const GetDeclareCapturesOKCode int = 200 + +/* +GetDeclareCapturesOK Successful operation + +swagger:response getDeclareCapturesOK +*/ +type GetDeclareCapturesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Captures `json:"body,omitempty"` +} + +// NewGetDeclareCapturesOK creates GetDeclareCapturesOK with default headers values +func NewGetDeclareCapturesOK() *GetDeclareCapturesOK { + + return &GetDeclareCapturesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get declare captures o k response +func (o *GetDeclareCapturesOK) WithConfigurationVersion(configurationVersion string) *GetDeclareCapturesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get declare captures o k response +func (o *GetDeclareCapturesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get declare captures o k response +func (o *GetDeclareCapturesOK) WithPayload(payload models.Captures) *GetDeclareCapturesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get declare captures o k response +func (o *GetDeclareCapturesOK) SetPayload(payload models.Captures) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDeclareCapturesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Captures{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetDeclareCapturesDefault General Error + +swagger:response getDeclareCapturesDefault +*/ +type GetDeclareCapturesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDeclareCapturesDefault creates GetDeclareCapturesDefault with default headers values +func NewGetDeclareCapturesDefault(code int) *GetDeclareCapturesDefault { + if code <= 0 { + code = 500 + } + + return &GetDeclareCapturesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get declare captures default response +func (o *GetDeclareCapturesDefault) WithStatusCode(code int) *GetDeclareCapturesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get declare captures default response +func (o *GetDeclareCapturesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get declare captures default response +func (o *GetDeclareCapturesDefault) WithConfigurationVersion(configurationVersion string) *GetDeclareCapturesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get declare captures default response +func (o *GetDeclareCapturesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get declare captures default response +func (o *GetDeclareCapturesDefault) WithPayload(payload *models.Error) *GetDeclareCapturesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get declare captures default response +func (o *GetDeclareCapturesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDeclareCapturesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/declare_capture/get_declare_captures_urlbuilder.go b/operations/declare_capture/get_declare_captures_urlbuilder.go new file mode 100644 index 00000000..c624130c --- /dev/null +++ b/operations/declare_capture/get_declare_captures_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetDeclareCapturesURL generates an URL for the get declare captures operation +type GetDeclareCapturesURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDeclareCapturesURL) WithBasePath(bp string) *GetDeclareCapturesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDeclareCapturesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetDeclareCapturesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/captures" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetDeclareCapturesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetDeclareCapturesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetDeclareCapturesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetDeclareCapturesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetDeclareCapturesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetDeclareCapturesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetDeclareCapturesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/declare_capture/replace_declare_capture.go b/operations/declare_capture/replace_declare_capture.go new file mode 100644 index 00000000..b62cc249 --- /dev/null +++ b/operations/declare_capture/replace_declare_capture.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceDeclareCaptureHandlerFunc turns a function with the right signature into a replace declare capture handler +type ReplaceDeclareCaptureHandlerFunc func(ReplaceDeclareCaptureParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceDeclareCaptureHandlerFunc) Handle(params ReplaceDeclareCaptureParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceDeclareCaptureHandler interface for that can handle valid replace declare capture params +type ReplaceDeclareCaptureHandler interface { + Handle(ReplaceDeclareCaptureParams, interface{}) middleware.Responder +} + +// NewReplaceDeclareCapture creates a new http.Handler for the replace declare capture operation +func NewReplaceDeclareCapture(ctx *middleware.Context, handler ReplaceDeclareCaptureHandler) *ReplaceDeclareCapture { + return &ReplaceDeclareCapture{Context: ctx, Handler: handler} +} + +/* + ReplaceDeclareCapture swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/captures/{index} DeclareCapture replaceDeclareCapture + +# Replace a declare capture + +Replaces a declare capture configuration by it's index in the specified frontend. +*/ +type ReplaceDeclareCapture struct { + Context *middleware.Context + Handler ReplaceDeclareCaptureHandler +} + +func (o *ReplaceDeclareCapture) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceDeclareCaptureParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/declare_capture/replace_declare_capture_parameters.go b/operations/declare_capture/replace_declare_capture_parameters.go new file mode 100644 index 00000000..604e683c --- /dev/null +++ b/operations/declare_capture/replace_declare_capture_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceDeclareCaptureParams creates a new ReplaceDeclareCaptureParams object +// with the default values initialized. +func NewReplaceDeclareCaptureParams() ReplaceDeclareCaptureParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceDeclareCaptureParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceDeclareCaptureParams contains all the bound params for the replace declare capture operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceDeclareCapture +type ReplaceDeclareCaptureParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Capture + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Declare Capture Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceDeclareCaptureParams() beforehand. +func (o *ReplaceDeclareCaptureParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Capture + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceDeclareCaptureParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceDeclareCaptureParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceDeclareCaptureParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceDeclareCaptureParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceDeclareCaptureParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceDeclareCaptureParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/declare_capture/replace_declare_capture_responses.go b/operations/declare_capture/replace_declare_capture_responses.go new file mode 100644 index 00000000..d1ac1438 --- /dev/null +++ b/operations/declare_capture/replace_declare_capture_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceDeclareCaptureOKCode is the HTTP code returned for type ReplaceDeclareCaptureOK +const ReplaceDeclareCaptureOKCode int = 200 + +/* +ReplaceDeclareCaptureOK Declare Capture replaced + +swagger:response replaceDeclareCaptureOK +*/ +type ReplaceDeclareCaptureOK struct { + + /* + In: Body + */ + Payload *models.Capture `json:"body,omitempty"` +} + +// NewReplaceDeclareCaptureOK creates ReplaceDeclareCaptureOK with default headers values +func NewReplaceDeclareCaptureOK() *ReplaceDeclareCaptureOK { + + return &ReplaceDeclareCaptureOK{} +} + +// WithPayload adds the payload to the replace declare capture o k response +func (o *ReplaceDeclareCaptureOK) WithPayload(payload *models.Capture) *ReplaceDeclareCaptureOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare capture o k response +func (o *ReplaceDeclareCaptureOK) SetPayload(payload *models.Capture) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCaptureOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDeclareCaptureAcceptedCode is the HTTP code returned for type ReplaceDeclareCaptureAccepted +const ReplaceDeclareCaptureAcceptedCode int = 202 + +/* +ReplaceDeclareCaptureAccepted Configuration change accepted and reload requested + +swagger:response replaceDeclareCaptureAccepted +*/ +type ReplaceDeclareCaptureAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Capture `json:"body,omitempty"` +} + +// NewReplaceDeclareCaptureAccepted creates ReplaceDeclareCaptureAccepted with default headers values +func NewReplaceDeclareCaptureAccepted() *ReplaceDeclareCaptureAccepted { + + return &ReplaceDeclareCaptureAccepted{} +} + +// WithReloadID adds the reloadId to the replace declare capture accepted response +func (o *ReplaceDeclareCaptureAccepted) WithReloadID(reloadID string) *ReplaceDeclareCaptureAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace declare capture accepted response +func (o *ReplaceDeclareCaptureAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace declare capture accepted response +func (o *ReplaceDeclareCaptureAccepted) WithPayload(payload *models.Capture) *ReplaceDeclareCaptureAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare capture accepted response +func (o *ReplaceDeclareCaptureAccepted) SetPayload(payload *models.Capture) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCaptureAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDeclareCaptureBadRequestCode is the HTTP code returned for type ReplaceDeclareCaptureBadRequest +const ReplaceDeclareCaptureBadRequestCode int = 400 + +/* +ReplaceDeclareCaptureBadRequest Bad request + +swagger:response replaceDeclareCaptureBadRequest +*/ +type ReplaceDeclareCaptureBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDeclareCaptureBadRequest creates ReplaceDeclareCaptureBadRequest with default headers values +func NewReplaceDeclareCaptureBadRequest() *ReplaceDeclareCaptureBadRequest { + + return &ReplaceDeclareCaptureBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace declare capture bad request response +func (o *ReplaceDeclareCaptureBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceDeclareCaptureBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace declare capture bad request response +func (o *ReplaceDeclareCaptureBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace declare capture bad request response +func (o *ReplaceDeclareCaptureBadRequest) WithPayload(payload *models.Error) *ReplaceDeclareCaptureBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare capture bad request response +func (o *ReplaceDeclareCaptureBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCaptureBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDeclareCaptureNotFoundCode is the HTTP code returned for type ReplaceDeclareCaptureNotFound +const ReplaceDeclareCaptureNotFoundCode int = 404 + +/* +ReplaceDeclareCaptureNotFound The specified resource was not found + +swagger:response replaceDeclareCaptureNotFound +*/ +type ReplaceDeclareCaptureNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDeclareCaptureNotFound creates ReplaceDeclareCaptureNotFound with default headers values +func NewReplaceDeclareCaptureNotFound() *ReplaceDeclareCaptureNotFound { + + return &ReplaceDeclareCaptureNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace declare capture not found response +func (o *ReplaceDeclareCaptureNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceDeclareCaptureNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace declare capture not found response +func (o *ReplaceDeclareCaptureNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace declare capture not found response +func (o *ReplaceDeclareCaptureNotFound) WithPayload(payload *models.Error) *ReplaceDeclareCaptureNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare capture not found response +func (o *ReplaceDeclareCaptureNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCaptureNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceDeclareCaptureDefault General Error + +swagger:response replaceDeclareCaptureDefault +*/ +type ReplaceDeclareCaptureDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDeclareCaptureDefault creates ReplaceDeclareCaptureDefault with default headers values +func NewReplaceDeclareCaptureDefault(code int) *ReplaceDeclareCaptureDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceDeclareCaptureDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace declare capture default response +func (o *ReplaceDeclareCaptureDefault) WithStatusCode(code int) *ReplaceDeclareCaptureDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace declare capture default response +func (o *ReplaceDeclareCaptureDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace declare capture default response +func (o *ReplaceDeclareCaptureDefault) WithConfigurationVersion(configurationVersion string) *ReplaceDeclareCaptureDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace declare capture default response +func (o *ReplaceDeclareCaptureDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace declare capture default response +func (o *ReplaceDeclareCaptureDefault) WithPayload(payload *models.Error) *ReplaceDeclareCaptureDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare capture default response +func (o *ReplaceDeclareCaptureDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCaptureDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/declare_capture/replace_declare_capture_urlbuilder.go b/operations/declare_capture/replace_declare_capture_urlbuilder.go new file mode 100644 index 00000000..cca389da --- /dev/null +++ b/operations/declare_capture/replace_declare_capture_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceDeclareCaptureURL generates an URL for the replace declare capture operation +type ReplaceDeclareCaptureURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDeclareCaptureURL) WithBasePath(bp string) *ReplaceDeclareCaptureURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDeclareCaptureURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceDeclareCaptureURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/captures/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceDeclareCaptureURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceDeclareCaptureURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceDeclareCaptureURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceDeclareCaptureURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceDeclareCaptureURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceDeclareCaptureURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceDeclareCaptureURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceDeclareCaptureURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/declare_capture/replace_declare_captures.go b/operations/declare_capture/replace_declare_captures.go new file mode 100644 index 00000000..2d9d4240 --- /dev/null +++ b/operations/declare_capture/replace_declare_captures.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceDeclareCapturesHandlerFunc turns a function with the right signature into a replace declare captures handler +type ReplaceDeclareCapturesHandlerFunc func(ReplaceDeclareCapturesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceDeclareCapturesHandlerFunc) Handle(params ReplaceDeclareCapturesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceDeclareCapturesHandler interface for that can handle valid replace declare captures params +type ReplaceDeclareCapturesHandler interface { + Handle(ReplaceDeclareCapturesParams, interface{}) middleware.Responder +} + +// NewReplaceDeclareCaptures creates a new http.Handler for the replace declare captures operation +func NewReplaceDeclareCaptures(ctx *middleware.Context, handler ReplaceDeclareCapturesHandler) *ReplaceDeclareCaptures { + return &ReplaceDeclareCaptures{Context: ctx, Handler: handler} +} + +/* + ReplaceDeclareCaptures swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/captures DeclareCapture replaceDeclareCaptures + +# Replace a declare capture list + +Replaces a whole list of declare capture with the list given in parameter +*/ +type ReplaceDeclareCaptures struct { + Context *middleware.Context + Handler ReplaceDeclareCapturesHandler +} + +func (o *ReplaceDeclareCaptures) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceDeclareCapturesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/declare_capture/replace_declare_captures_parameters.go b/operations/declare_capture/replace_declare_captures_parameters.go new file mode 100644 index 00000000..2db19806 --- /dev/null +++ b/operations/declare_capture/replace_declare_captures_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceDeclareCapturesParams creates a new ReplaceDeclareCapturesParams object +// with the default values initialized. +func NewReplaceDeclareCapturesParams() ReplaceDeclareCapturesParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceDeclareCapturesParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceDeclareCapturesParams contains all the bound params for the replace declare captures operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceDeclareCaptures +type ReplaceDeclareCapturesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.Captures + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceDeclareCapturesParams() beforehand. +func (o *ReplaceDeclareCapturesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Captures + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceDeclareCapturesParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceDeclareCapturesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceDeclareCapturesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceDeclareCapturesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceDeclareCapturesParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/declare_capture/replace_declare_captures_responses.go b/operations/declare_capture/replace_declare_captures_responses.go new file mode 100644 index 00000000..fd1a58ba --- /dev/null +++ b/operations/declare_capture/replace_declare_captures_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceDeclareCapturesOKCode is the HTTP code returned for type ReplaceDeclareCapturesOK +const ReplaceDeclareCapturesOKCode int = 200 + +/* +ReplaceDeclareCapturesOK All Declare capture lines replaced + +swagger:response replaceDeclareCapturesOK +*/ +type ReplaceDeclareCapturesOK struct { + + /* + In: Body + */ + Payload models.Captures `json:"body,omitempty"` +} + +// NewReplaceDeclareCapturesOK creates ReplaceDeclareCapturesOK with default headers values +func NewReplaceDeclareCapturesOK() *ReplaceDeclareCapturesOK { + + return &ReplaceDeclareCapturesOK{} +} + +// WithPayload adds the payload to the replace declare captures o k response +func (o *ReplaceDeclareCapturesOK) WithPayload(payload models.Captures) *ReplaceDeclareCapturesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare captures o k response +func (o *ReplaceDeclareCapturesOK) SetPayload(payload models.Captures) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCapturesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Captures{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceDeclareCapturesAcceptedCode is the HTTP code returned for type ReplaceDeclareCapturesAccepted +const ReplaceDeclareCapturesAcceptedCode int = 202 + +/* +ReplaceDeclareCapturesAccepted Configuration change accepted and reload requested + +swagger:response replaceDeclareCapturesAccepted +*/ +type ReplaceDeclareCapturesAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.Captures `json:"body,omitempty"` +} + +// NewReplaceDeclareCapturesAccepted creates ReplaceDeclareCapturesAccepted with default headers values +func NewReplaceDeclareCapturesAccepted() *ReplaceDeclareCapturesAccepted { + + return &ReplaceDeclareCapturesAccepted{} +} + +// WithReloadID adds the reloadId to the replace declare captures accepted response +func (o *ReplaceDeclareCapturesAccepted) WithReloadID(reloadID string) *ReplaceDeclareCapturesAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace declare captures accepted response +func (o *ReplaceDeclareCapturesAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace declare captures accepted response +func (o *ReplaceDeclareCapturesAccepted) WithPayload(payload models.Captures) *ReplaceDeclareCapturesAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare captures accepted response +func (o *ReplaceDeclareCapturesAccepted) SetPayload(payload models.Captures) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCapturesAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Captures{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceDeclareCapturesBadRequestCode is the HTTP code returned for type ReplaceDeclareCapturesBadRequest +const ReplaceDeclareCapturesBadRequestCode int = 400 + +/* +ReplaceDeclareCapturesBadRequest Bad request + +swagger:response replaceDeclareCapturesBadRequest +*/ +type ReplaceDeclareCapturesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDeclareCapturesBadRequest creates ReplaceDeclareCapturesBadRequest with default headers values +func NewReplaceDeclareCapturesBadRequest() *ReplaceDeclareCapturesBadRequest { + + return &ReplaceDeclareCapturesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace declare captures bad request response +func (o *ReplaceDeclareCapturesBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceDeclareCapturesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace declare captures bad request response +func (o *ReplaceDeclareCapturesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace declare captures bad request response +func (o *ReplaceDeclareCapturesBadRequest) WithPayload(payload *models.Error) *ReplaceDeclareCapturesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare captures bad request response +func (o *ReplaceDeclareCapturesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCapturesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceDeclareCapturesDefault General Error + +swagger:response replaceDeclareCapturesDefault +*/ +type ReplaceDeclareCapturesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDeclareCapturesDefault creates ReplaceDeclareCapturesDefault with default headers values +func NewReplaceDeclareCapturesDefault(code int) *ReplaceDeclareCapturesDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceDeclareCapturesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace declare captures default response +func (o *ReplaceDeclareCapturesDefault) WithStatusCode(code int) *ReplaceDeclareCapturesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace declare captures default response +func (o *ReplaceDeclareCapturesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace declare captures default response +func (o *ReplaceDeclareCapturesDefault) WithConfigurationVersion(configurationVersion string) *ReplaceDeclareCapturesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace declare captures default response +func (o *ReplaceDeclareCapturesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace declare captures default response +func (o *ReplaceDeclareCapturesDefault) WithPayload(payload *models.Error) *ReplaceDeclareCapturesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace declare captures default response +func (o *ReplaceDeclareCapturesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDeclareCapturesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/declare_capture/replace_declare_captures_urlbuilder.go b/operations/declare_capture/replace_declare_captures_urlbuilder.go new file mode 100644 index 00000000..06df03ee --- /dev/null +++ b/operations/declare_capture/replace_declare_captures_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package declare_capture + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceDeclareCapturesURL generates an URL for the replace declare captures operation +type ReplaceDeclareCapturesURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDeclareCapturesURL) WithBasePath(bp string) *ReplaceDeclareCapturesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDeclareCapturesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceDeclareCapturesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/captures" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceDeclareCapturesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceDeclareCapturesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceDeclareCapturesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceDeclareCapturesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceDeclareCapturesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceDeclareCapturesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceDeclareCapturesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/defaults/add_defaults_section.go b/operations/defaults/add_defaults_section.go new file mode 100644 index 00000000..702bb888 --- /dev/null +++ b/operations/defaults/add_defaults_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddDefaultsSectionHandlerFunc turns a function with the right signature into a add defaults section handler +type AddDefaultsSectionHandlerFunc func(AddDefaultsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddDefaultsSectionHandlerFunc) Handle(params AddDefaultsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddDefaultsSectionHandler interface for that can handle valid add defaults section params +type AddDefaultsSectionHandler interface { + Handle(AddDefaultsSectionParams, interface{}) middleware.Responder +} + +// NewAddDefaultsSection creates a new http.Handler for the add defaults section operation +func NewAddDefaultsSection(ctx *middleware.Context, handler AddDefaultsSectionHandler) *AddDefaultsSection { + return &AddDefaultsSection{Context: ctx, Handler: handler} +} + +/* + AddDefaultsSection swagger:route POST /services/haproxy/configuration/defaults Defaults addDefaultsSection + +# Add a defaults section + +Adds a new defaults section to the configuration file. +*/ +type AddDefaultsSection struct { + Context *middleware.Context + Handler AddDefaultsSectionHandler +} + +func (o *AddDefaultsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewAddDefaultsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/defaults/add_defaults_section_parameters.go b/operations/defaults/add_defaults_section_parameters.go new file mode 100644 index 00000000..a3f83bab --- /dev/null +++ b/operations/defaults/add_defaults_section_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewAddDefaultsSectionParams creates a new AddDefaultsSectionParams object +// with the default values initialized. +func NewAddDefaultsSectionParams() AddDefaultsSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return AddDefaultsSectionParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// AddDefaultsSectionParams contains all the bound params for the add defaults section operation +// typically these are obtained from a http.Request +// +// swagger:parameters addDefaultsSection +type AddDefaultsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Defaults + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddDefaultsSectionParams() beforehand. +func (o *AddDefaultsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Defaults + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *AddDefaultsSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewAddDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *AddDefaultsSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewAddDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *AddDefaultsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *AddDefaultsSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/defaults/add_defaults_section_responses.go b/operations/defaults/add_defaults_section_responses.go new file mode 100644 index 00000000..bd305e43 --- /dev/null +++ b/operations/defaults/add_defaults_section_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// AddDefaultsSectionCreatedCode is the HTTP code returned for type AddDefaultsSectionCreated +const AddDefaultsSectionCreatedCode int = 201 + +/* +AddDefaultsSectionCreated Defaults created + +swagger:response addDefaultsSectionCreated +*/ +type AddDefaultsSectionCreated struct { + + /* + In: Body + */ + Payload *models.Defaults `json:"body,omitempty"` +} + +// NewAddDefaultsSectionCreated creates AddDefaultsSectionCreated with default headers values +func NewAddDefaultsSectionCreated() *AddDefaultsSectionCreated { + + return &AddDefaultsSectionCreated{} +} + +// WithPayload adds the payload to the add defaults section created response +func (o *AddDefaultsSectionCreated) WithPayload(payload *models.Defaults) *AddDefaultsSectionCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add defaults section created response +func (o *AddDefaultsSectionCreated) SetPayload(payload *models.Defaults) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddDefaultsSectionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddDefaultsSectionAcceptedCode is the HTTP code returned for type AddDefaultsSectionAccepted +const AddDefaultsSectionAcceptedCode int = 202 + +/* +AddDefaultsSectionAccepted Configuration change accepted and reload requested + +swagger:response addDefaultsSectionAccepted +*/ +type AddDefaultsSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Defaults `json:"body,omitempty"` +} + +// NewAddDefaultsSectionAccepted creates AddDefaultsSectionAccepted with default headers values +func NewAddDefaultsSectionAccepted() *AddDefaultsSectionAccepted { + + return &AddDefaultsSectionAccepted{} +} + +// WithReloadID adds the reloadId to the add defaults section accepted response +func (o *AddDefaultsSectionAccepted) WithReloadID(reloadID string) *AddDefaultsSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the add defaults section accepted response +func (o *AddDefaultsSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the add defaults section accepted response +func (o *AddDefaultsSectionAccepted) WithPayload(payload *models.Defaults) *AddDefaultsSectionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add defaults section accepted response +func (o *AddDefaultsSectionAccepted) SetPayload(payload *models.Defaults) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddDefaultsSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddDefaultsSectionBadRequestCode is the HTTP code returned for type AddDefaultsSectionBadRequest +const AddDefaultsSectionBadRequestCode int = 400 + +/* +AddDefaultsSectionBadRequest Bad request + +swagger:response addDefaultsSectionBadRequest +*/ +type AddDefaultsSectionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddDefaultsSectionBadRequest creates AddDefaultsSectionBadRequest with default headers values +func NewAddDefaultsSectionBadRequest() *AddDefaultsSectionBadRequest { + + return &AddDefaultsSectionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the add defaults section bad request response +func (o *AddDefaultsSectionBadRequest) WithConfigurationVersion(configurationVersion string) *AddDefaultsSectionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add defaults section bad request response +func (o *AddDefaultsSectionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add defaults section bad request response +func (o *AddDefaultsSectionBadRequest) WithPayload(payload *models.Error) *AddDefaultsSectionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add defaults section bad request response +func (o *AddDefaultsSectionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddDefaultsSectionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddDefaultsSectionConflictCode is the HTTP code returned for type AddDefaultsSectionConflict +const AddDefaultsSectionConflictCode int = 409 + +/* +AddDefaultsSectionConflict The specified resource already exists + +swagger:response addDefaultsSectionConflict +*/ +type AddDefaultsSectionConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddDefaultsSectionConflict creates AddDefaultsSectionConflict with default headers values +func NewAddDefaultsSectionConflict() *AddDefaultsSectionConflict { + + return &AddDefaultsSectionConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the add defaults section conflict response +func (o *AddDefaultsSectionConflict) WithConfigurationVersion(configurationVersion string) *AddDefaultsSectionConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add defaults section conflict response +func (o *AddDefaultsSectionConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add defaults section conflict response +func (o *AddDefaultsSectionConflict) WithPayload(payload *models.Error) *AddDefaultsSectionConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add defaults section conflict response +func (o *AddDefaultsSectionConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddDefaultsSectionConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +AddDefaultsSectionDefault General Error + +swagger:response addDefaultsSectionDefault +*/ +type AddDefaultsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddDefaultsSectionDefault creates AddDefaultsSectionDefault with default headers values +func NewAddDefaultsSectionDefault(code int) *AddDefaultsSectionDefault { + if code <= 0 { + code = 500 + } + + return &AddDefaultsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the add defaults section default response +func (o *AddDefaultsSectionDefault) WithStatusCode(code int) *AddDefaultsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the add defaults section default response +func (o *AddDefaultsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the add defaults section default response +func (o *AddDefaultsSectionDefault) WithConfigurationVersion(configurationVersion string) *AddDefaultsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add defaults section default response +func (o *AddDefaultsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add defaults section default response +func (o *AddDefaultsSectionDefault) WithPayload(payload *models.Error) *AddDefaultsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add defaults section default response +func (o *AddDefaultsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddDefaultsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/defaults/add_defaults_section_urlbuilder.go b/operations/defaults/add_defaults_section_urlbuilder.go new file mode 100644 index 00000000..a009af3f --- /dev/null +++ b/operations/defaults/add_defaults_section_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// AddDefaultsSectionURL generates an URL for the add defaults section operation +type AddDefaultsSectionURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddDefaultsSectionURL) WithBasePath(bp string) *AddDefaultsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddDefaultsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddDefaultsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddDefaultsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddDefaultsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddDefaultsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddDefaultsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddDefaultsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddDefaultsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/defaults/create_defaults_section.go b/operations/defaults/create_defaults_section.go new file mode 100644 index 00000000..0d5e7d2c --- /dev/null +++ b/operations/defaults/create_defaults_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateDefaultsSectionHandlerFunc turns a function with the right signature into a create defaults section handler +type CreateDefaultsSectionHandlerFunc func(CreateDefaultsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateDefaultsSectionHandlerFunc) Handle(params CreateDefaultsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateDefaultsSectionHandler interface for that can handle valid create defaults section params +type CreateDefaultsSectionHandler interface { + Handle(CreateDefaultsSectionParams, interface{}) middleware.Responder +} + +// NewCreateDefaultsSection creates a new http.Handler for the create defaults section operation +func NewCreateDefaultsSection(ctx *middleware.Context, handler CreateDefaultsSectionHandler) *CreateDefaultsSection { + return &CreateDefaultsSection{Context: ctx, Handler: handler} +} + +/* + CreateDefaultsSection swagger:route PUT /services/haproxy/configuration/defaults Defaults createDefaultsSection + +# Add a defaults section + +Adds a new defaults section to the configuration file. +*/ +type CreateDefaultsSection struct { + Context *middleware.Context + Handler CreateDefaultsSectionHandler +} + +func (o *CreateDefaultsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateDefaultsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/defaults/create_defaults_section_parameters.go b/operations/defaults/create_defaults_section_parameters.go new file mode 100644 index 00000000..05718477 --- /dev/null +++ b/operations/defaults/create_defaults_section_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateDefaultsSectionParams creates a new CreateDefaultsSectionParams object +// with the default values initialized. +func NewCreateDefaultsSectionParams() CreateDefaultsSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreateDefaultsSectionParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreateDefaultsSectionParams contains all the bound params for the create defaults section operation +// typically these are obtained from a http.Request +// +// swagger:parameters createDefaultsSection +type CreateDefaultsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Defaults + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateDefaultsSectionParams() beforehand. +func (o *CreateDefaultsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Defaults + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateDefaultsSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateDefaultsSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateDefaultsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateDefaultsSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/defaults/create_defaults_section_responses.go b/operations/defaults/create_defaults_section_responses.go new file mode 100644 index 00000000..f85a5208 --- /dev/null +++ b/operations/defaults/create_defaults_section_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateDefaultsSectionCreatedCode is the HTTP code returned for type CreateDefaultsSectionCreated +const CreateDefaultsSectionCreatedCode int = 201 + +/* +CreateDefaultsSectionCreated Defaults created + +swagger:response createDefaultsSectionCreated +*/ +type CreateDefaultsSectionCreated struct { + + /* + In: Body + */ + Payload *models.Defaults `json:"body,omitempty"` +} + +// NewCreateDefaultsSectionCreated creates CreateDefaultsSectionCreated with default headers values +func NewCreateDefaultsSectionCreated() *CreateDefaultsSectionCreated { + + return &CreateDefaultsSectionCreated{} +} + +// WithPayload adds the payload to the create defaults section created response +func (o *CreateDefaultsSectionCreated) WithPayload(payload *models.Defaults) *CreateDefaultsSectionCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create defaults section created response +func (o *CreateDefaultsSectionCreated) SetPayload(payload *models.Defaults) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDefaultsSectionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDefaultsSectionAcceptedCode is the HTTP code returned for type CreateDefaultsSectionAccepted +const CreateDefaultsSectionAcceptedCode int = 202 + +/* +CreateDefaultsSectionAccepted Configuration change accepted and reload requested + +swagger:response createDefaultsSectionAccepted +*/ +type CreateDefaultsSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Defaults `json:"body,omitempty"` +} + +// NewCreateDefaultsSectionAccepted creates CreateDefaultsSectionAccepted with default headers values +func NewCreateDefaultsSectionAccepted() *CreateDefaultsSectionAccepted { + + return &CreateDefaultsSectionAccepted{} +} + +// WithReloadID adds the reloadId to the create defaults section accepted response +func (o *CreateDefaultsSectionAccepted) WithReloadID(reloadID string) *CreateDefaultsSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create defaults section accepted response +func (o *CreateDefaultsSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create defaults section accepted response +func (o *CreateDefaultsSectionAccepted) WithPayload(payload *models.Defaults) *CreateDefaultsSectionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create defaults section accepted response +func (o *CreateDefaultsSectionAccepted) SetPayload(payload *models.Defaults) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDefaultsSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDefaultsSectionBadRequestCode is the HTTP code returned for type CreateDefaultsSectionBadRequest +const CreateDefaultsSectionBadRequestCode int = 400 + +/* +CreateDefaultsSectionBadRequest Bad request + +swagger:response createDefaultsSectionBadRequest +*/ +type CreateDefaultsSectionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDefaultsSectionBadRequest creates CreateDefaultsSectionBadRequest with default headers values +func NewCreateDefaultsSectionBadRequest() *CreateDefaultsSectionBadRequest { + + return &CreateDefaultsSectionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create defaults section bad request response +func (o *CreateDefaultsSectionBadRequest) WithConfigurationVersion(configurationVersion string) *CreateDefaultsSectionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create defaults section bad request response +func (o *CreateDefaultsSectionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create defaults section bad request response +func (o *CreateDefaultsSectionBadRequest) WithPayload(payload *models.Error) *CreateDefaultsSectionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create defaults section bad request response +func (o *CreateDefaultsSectionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDefaultsSectionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDefaultsSectionConflictCode is the HTTP code returned for type CreateDefaultsSectionConflict +const CreateDefaultsSectionConflictCode int = 409 + +/* +CreateDefaultsSectionConflict The specified resource already exists + +swagger:response createDefaultsSectionConflict +*/ +type CreateDefaultsSectionConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDefaultsSectionConflict creates CreateDefaultsSectionConflict with default headers values +func NewCreateDefaultsSectionConflict() *CreateDefaultsSectionConflict { + + return &CreateDefaultsSectionConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create defaults section conflict response +func (o *CreateDefaultsSectionConflict) WithConfigurationVersion(configurationVersion string) *CreateDefaultsSectionConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create defaults section conflict response +func (o *CreateDefaultsSectionConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create defaults section conflict response +func (o *CreateDefaultsSectionConflict) WithPayload(payload *models.Error) *CreateDefaultsSectionConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create defaults section conflict response +func (o *CreateDefaultsSectionConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDefaultsSectionConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateDefaultsSectionDefault General Error + +swagger:response createDefaultsSectionDefault +*/ +type CreateDefaultsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDefaultsSectionDefault creates CreateDefaultsSectionDefault with default headers values +func NewCreateDefaultsSectionDefault(code int) *CreateDefaultsSectionDefault { + if code <= 0 { + code = 500 + } + + return &CreateDefaultsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create defaults section default response +func (o *CreateDefaultsSectionDefault) WithStatusCode(code int) *CreateDefaultsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create defaults section default response +func (o *CreateDefaultsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create defaults section default response +func (o *CreateDefaultsSectionDefault) WithConfigurationVersion(configurationVersion string) *CreateDefaultsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create defaults section default response +func (o *CreateDefaultsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create defaults section default response +func (o *CreateDefaultsSectionDefault) WithPayload(payload *models.Error) *CreateDefaultsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create defaults section default response +func (o *CreateDefaultsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDefaultsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/defaults/create_defaults_section_urlbuilder.go b/operations/defaults/create_defaults_section_urlbuilder.go new file mode 100644 index 00000000..99035a38 --- /dev/null +++ b/operations/defaults/create_defaults_section_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateDefaultsSectionURL generates an URL for the create defaults section operation +type CreateDefaultsSectionURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateDefaultsSectionURL) WithBasePath(bp string) *CreateDefaultsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateDefaultsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateDefaultsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateDefaultsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateDefaultsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateDefaultsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateDefaultsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateDefaultsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateDefaultsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/defaults/delete_defaults_section.go b/operations/defaults/delete_defaults_section.go new file mode 100644 index 00000000..f1485974 --- /dev/null +++ b/operations/defaults/delete_defaults_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteDefaultsSectionHandlerFunc turns a function with the right signature into a delete defaults section handler +type DeleteDefaultsSectionHandlerFunc func(DeleteDefaultsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteDefaultsSectionHandlerFunc) Handle(params DeleteDefaultsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteDefaultsSectionHandler interface for that can handle valid delete defaults section params +type DeleteDefaultsSectionHandler interface { + Handle(DeleteDefaultsSectionParams, interface{}) middleware.Responder +} + +// NewDeleteDefaultsSection creates a new http.Handler for the delete defaults section operation +func NewDeleteDefaultsSection(ctx *middleware.Context, handler DeleteDefaultsSectionHandler) *DeleteDefaultsSection { + return &DeleteDefaultsSection{Context: ctx, Handler: handler} +} + +/* + DeleteDefaultsSection swagger:route DELETE /services/haproxy/configuration/defaults/{name} Defaults deleteDefaultsSection + +# Delete a defaults section + +Deletes a defaults section from the configuration by it's name. +*/ +type DeleteDefaultsSection struct { + Context *middleware.Context + Handler DeleteDefaultsSectionHandler +} + +func (o *DeleteDefaultsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteDefaultsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/defaults/delete_defaults_section_parameters.go b/operations/defaults/delete_defaults_section_parameters.go new file mode 100644 index 00000000..31ea92e1 --- /dev/null +++ b/operations/defaults/delete_defaults_section_parameters.go @@ -0,0 +1,227 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteDefaultsSectionParams creates a new DeleteDefaultsSectionParams object +// with the default values initialized. +func NewDeleteDefaultsSectionParams() DeleteDefaultsSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return DeleteDefaultsSectionParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// DeleteDefaultsSectionParams contains all the bound params for the delete defaults section operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteDefaultsSection +type DeleteDefaultsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Defaults name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteDefaultsSectionParams() beforehand. +func (o *DeleteDefaultsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteDefaultsSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *DeleteDefaultsSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteDefaultsSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteDefaultsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteDefaultsSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/defaults/delete_defaults_section_responses.go b/operations/defaults/delete_defaults_section_responses.go new file mode 100644 index 00000000..21ca320f --- /dev/null +++ b/operations/defaults/delete_defaults_section_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteDefaultsSectionAcceptedCode is the HTTP code returned for type DeleteDefaultsSectionAccepted +const DeleteDefaultsSectionAcceptedCode int = 202 + +/* +DeleteDefaultsSectionAccepted Configuration change accepted and reload requested + +swagger:response deleteDefaultsSectionAccepted +*/ +type DeleteDefaultsSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteDefaultsSectionAccepted creates DeleteDefaultsSectionAccepted with default headers values +func NewDeleteDefaultsSectionAccepted() *DeleteDefaultsSectionAccepted { + + return &DeleteDefaultsSectionAccepted{} +} + +// WithReloadID adds the reloadId to the delete defaults section accepted response +func (o *DeleteDefaultsSectionAccepted) WithReloadID(reloadID string) *DeleteDefaultsSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete defaults section accepted response +func (o *DeleteDefaultsSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteDefaultsSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteDefaultsSectionNoContentCode is the HTTP code returned for type DeleteDefaultsSectionNoContent +const DeleteDefaultsSectionNoContentCode int = 204 + +/* +DeleteDefaultsSectionNoContent Defaults section deleted + +swagger:response deleteDefaultsSectionNoContent +*/ +type DeleteDefaultsSectionNoContent struct { +} + +// NewDeleteDefaultsSectionNoContent creates DeleteDefaultsSectionNoContent with default headers values +func NewDeleteDefaultsSectionNoContent() *DeleteDefaultsSectionNoContent { + + return &DeleteDefaultsSectionNoContent{} +} + +// WriteResponse to the client +func (o *DeleteDefaultsSectionNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteDefaultsSectionNotFoundCode is the HTTP code returned for type DeleteDefaultsSectionNotFound +const DeleteDefaultsSectionNotFoundCode int = 404 + +/* +DeleteDefaultsSectionNotFound The specified resource was not found + +swagger:response deleteDefaultsSectionNotFound +*/ +type DeleteDefaultsSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteDefaultsSectionNotFound creates DeleteDefaultsSectionNotFound with default headers values +func NewDeleteDefaultsSectionNotFound() *DeleteDefaultsSectionNotFound { + + return &DeleteDefaultsSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete defaults section not found response +func (o *DeleteDefaultsSectionNotFound) WithConfigurationVersion(configurationVersion string) *DeleteDefaultsSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete defaults section not found response +func (o *DeleteDefaultsSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete defaults section not found response +func (o *DeleteDefaultsSectionNotFound) WithPayload(payload *models.Error) *DeleteDefaultsSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete defaults section not found response +func (o *DeleteDefaultsSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteDefaultsSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteDefaultsSectionDefault General Error + +swagger:response deleteDefaultsSectionDefault +*/ +type DeleteDefaultsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteDefaultsSectionDefault creates DeleteDefaultsSectionDefault with default headers values +func NewDeleteDefaultsSectionDefault(code int) *DeleteDefaultsSectionDefault { + if code <= 0 { + code = 500 + } + + return &DeleteDefaultsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete defaults section default response +func (o *DeleteDefaultsSectionDefault) WithStatusCode(code int) *DeleteDefaultsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete defaults section default response +func (o *DeleteDefaultsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete defaults section default response +func (o *DeleteDefaultsSectionDefault) WithConfigurationVersion(configurationVersion string) *DeleteDefaultsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete defaults section default response +func (o *DeleteDefaultsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete defaults section default response +func (o *DeleteDefaultsSectionDefault) WithPayload(payload *models.Error) *DeleteDefaultsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete defaults section default response +func (o *DeleteDefaultsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteDefaultsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/defaults/delete_defaults_section_urlbuilder.go b/operations/defaults/delete_defaults_section_urlbuilder.go new file mode 100644 index 00000000..c2752125 --- /dev/null +++ b/operations/defaults/delete_defaults_section_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteDefaultsSectionURL generates an URL for the delete defaults section operation +type DeleteDefaultsSectionURL struct { + Name string + + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteDefaultsSectionURL) WithBasePath(bp string) *DeleteDefaultsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteDefaultsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteDefaultsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteDefaultsSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteDefaultsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteDefaultsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteDefaultsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteDefaultsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteDefaultsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteDefaultsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/defaults/get_defaults.go b/operations/defaults/get_defaults.go deleted file mode 100644 index bb26be43..00000000 --- a/operations/defaults/get_defaults.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetDefaultsHandlerFunc turns a function with the right signature into a get defaults handler -type GetDefaultsHandlerFunc func(GetDefaultsParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetDefaultsHandlerFunc) Handle(params GetDefaultsParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetDefaultsHandler interface for that can handle valid get defaults params -type GetDefaultsHandler interface { - Handle(GetDefaultsParams, interface{}) middleware.Responder -} - -// NewGetDefaults creates a new http.Handler for the get defaults operation -func NewGetDefaults(ctx *middleware.Context, handler GetDefaultsHandler) *GetDefaults { - return &GetDefaults{Context: ctx, Handler: handler} -} - -/*GetDefaults swagger:route GET /services/haproxy/configuration/defaults Defaults getDefaults - -Return defaults part of configuration - -Returns defaults part of configuration. - -*/ -type GetDefaults struct { - Context *middleware.Context - Handler GetDefaultsHandler -} - -func (o *GetDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetDefaultsParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetDefaultsOKBody get defaults o k body -// swagger:model GetDefaultsOKBody -type GetDefaultsOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Defaults `json:"data,omitempty"` -} - -// Validate validates this get defaults o k body -func (o *GetDefaultsOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetDefaultsOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getDefaultsOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetDefaultsOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetDefaultsOKBody) UnmarshalBinary(b []byte) error { - var res GetDefaultsOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/defaults/get_defaults_parameters.go b/operations/defaults/get_defaults_parameters.go deleted file mode 100644 index 33541991..00000000 --- a/operations/defaults/get_defaults_parameters.go +++ /dev/null @@ -1,93 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetDefaultsParams creates a new GetDefaultsParams object -// no default values defined in spec. -func NewGetDefaultsParams() GetDefaultsParams { - - return GetDefaultsParams{} -} - -// GetDefaultsParams contains all the bound params for the get defaults operation -// typically these are obtained from a http.Request -// -// swagger:parameters getDefaults -type GetDefaultsParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetDefaultsParams() beforehand. -func (o *GetDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/defaults/get_defaults_responses.go b/operations/defaults/get_defaults_responses.go deleted file mode 100644 index ef31c148..00000000 --- a/operations/defaults/get_defaults_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetDefaultsOKCode is the HTTP code returned for type GetDefaultsOK -const GetDefaultsOKCode int = 200 - -/*GetDefaultsOK Successful operation - -swagger:response getDefaultsOK -*/ -type GetDefaultsOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetDefaultsOKBody `json:"body,omitempty"` -} - -// NewGetDefaultsOK creates GetDefaultsOK with default headers values -func NewGetDefaultsOK() *GetDefaultsOK { - - return &GetDefaultsOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get defaults o k response -func (o *GetDefaultsOK) WithConfigurationVersion(configurationVersion int64) *GetDefaultsOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get defaults o k response -func (o *GetDefaultsOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get defaults o k response -func (o *GetDefaultsOK) WithPayload(payload *GetDefaultsOKBody) *GetDefaultsOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get defaults o k response -func (o *GetDefaultsOK) SetPayload(payload *GetDefaultsOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetDefaultsDefault General Error - -swagger:response getDefaultsDefault -*/ -type GetDefaultsDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetDefaultsDefault creates GetDefaultsDefault with default headers values -func NewGetDefaultsDefault(code int) *GetDefaultsDefault { - if code <= 0 { - code = 500 - } - - return &GetDefaultsDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get defaults default response -func (o *GetDefaultsDefault) WithStatusCode(code int) *GetDefaultsDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get defaults default response -func (o *GetDefaultsDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get defaults default response -func (o *GetDefaultsDefault) WithConfigurationVersion(configurationVersion int64) *GetDefaultsDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get defaults default response -func (o *GetDefaultsDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get defaults default response -func (o *GetDefaultsDefault) WithPayload(payload *models.Error) *GetDefaultsDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get defaults default response -func (o *GetDefaultsDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/defaults/get_defaults_section.go b/operations/defaults/get_defaults_section.go new file mode 100644 index 00000000..aa1776c9 --- /dev/null +++ b/operations/defaults/get_defaults_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetDefaultsSectionHandlerFunc turns a function with the right signature into a get defaults section handler +type GetDefaultsSectionHandlerFunc func(GetDefaultsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetDefaultsSectionHandlerFunc) Handle(params GetDefaultsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetDefaultsSectionHandler interface for that can handle valid get defaults section params +type GetDefaultsSectionHandler interface { + Handle(GetDefaultsSectionParams, interface{}) middleware.Responder +} + +// NewGetDefaultsSection creates a new http.Handler for the get defaults section operation +func NewGetDefaultsSection(ctx *middleware.Context, handler GetDefaultsSectionHandler) *GetDefaultsSection { + return &GetDefaultsSection{Context: ctx, Handler: handler} +} + +/* + GetDefaultsSection swagger:route GET /services/haproxy/configuration/defaults/{name} Defaults getDefaultsSection + +# Return a defaults section + +Returns one defaults section configuration by it's name. +*/ +type GetDefaultsSection struct { + Context *middleware.Context + Handler GetDefaultsSectionHandler +} + +func (o *GetDefaultsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetDefaultsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/defaults/get_defaults_section_parameters.go b/operations/defaults/get_defaults_section_parameters.go new file mode 100644 index 00000000..558d776b --- /dev/null +++ b/operations/defaults/get_defaults_section_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetDefaultsSectionParams creates a new GetDefaultsSectionParams object +// with the default values initialized. +func NewGetDefaultsSectionParams() GetDefaultsSectionParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetDefaultsSectionParams{ + FullSection: &fullSectionDefault, + } +} + +// GetDefaultsSectionParams contains all the bound params for the get defaults section operation +// typically these are obtained from a http.Request +// +// swagger:parameters getDefaultsSection +type GetDefaultsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Defaults name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetDefaultsSectionParams() beforehand. +func (o *GetDefaultsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetDefaultsSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetDefaultsSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetDefaultsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/defaults/get_defaults_section_responses.go b/operations/defaults/get_defaults_section_responses.go new file mode 100644 index 00000000..2a17f2de --- /dev/null +++ b/operations/defaults/get_defaults_section_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetDefaultsSectionOKCode is the HTTP code returned for type GetDefaultsSectionOK +const GetDefaultsSectionOKCode int = 200 + +/* +GetDefaultsSectionOK Successful operation + +swagger:response getDefaultsSectionOK +*/ +type GetDefaultsSectionOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Defaults `json:"body,omitempty"` +} + +// NewGetDefaultsSectionOK creates GetDefaultsSectionOK with default headers values +func NewGetDefaultsSectionOK() *GetDefaultsSectionOK { + + return &GetDefaultsSectionOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get defaults section o k response +func (o *GetDefaultsSectionOK) WithConfigurationVersion(configurationVersion string) *GetDefaultsSectionOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get defaults section o k response +func (o *GetDefaultsSectionOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get defaults section o k response +func (o *GetDefaultsSectionOK) WithPayload(payload *models.Defaults) *GetDefaultsSectionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get defaults section o k response +func (o *GetDefaultsSectionOK) SetPayload(payload *models.Defaults) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDefaultsSectionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetDefaultsSectionNotFoundCode is the HTTP code returned for type GetDefaultsSectionNotFound +const GetDefaultsSectionNotFoundCode int = 404 + +/* +GetDefaultsSectionNotFound The specified resource was not found + +swagger:response getDefaultsSectionNotFound +*/ +type GetDefaultsSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDefaultsSectionNotFound creates GetDefaultsSectionNotFound with default headers values +func NewGetDefaultsSectionNotFound() *GetDefaultsSectionNotFound { + + return &GetDefaultsSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get defaults section not found response +func (o *GetDefaultsSectionNotFound) WithConfigurationVersion(configurationVersion string) *GetDefaultsSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get defaults section not found response +func (o *GetDefaultsSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get defaults section not found response +func (o *GetDefaultsSectionNotFound) WithPayload(payload *models.Error) *GetDefaultsSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get defaults section not found response +func (o *GetDefaultsSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDefaultsSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetDefaultsSectionDefault General Error + +swagger:response getDefaultsSectionDefault +*/ +type GetDefaultsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDefaultsSectionDefault creates GetDefaultsSectionDefault with default headers values +func NewGetDefaultsSectionDefault(code int) *GetDefaultsSectionDefault { + if code <= 0 { + code = 500 + } + + return &GetDefaultsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get defaults section default response +func (o *GetDefaultsSectionDefault) WithStatusCode(code int) *GetDefaultsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get defaults section default response +func (o *GetDefaultsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get defaults section default response +func (o *GetDefaultsSectionDefault) WithConfigurationVersion(configurationVersion string) *GetDefaultsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get defaults section default response +func (o *GetDefaultsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get defaults section default response +func (o *GetDefaultsSectionDefault) WithPayload(payload *models.Error) *GetDefaultsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get defaults section default response +func (o *GetDefaultsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDefaultsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/defaults/get_defaults_section_urlbuilder.go b/operations/defaults/get_defaults_section_urlbuilder.go new file mode 100644 index 00000000..dc1c8061 --- /dev/null +++ b/operations/defaults/get_defaults_section_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetDefaultsSectionURL generates an URL for the get defaults section operation +type GetDefaultsSectionURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDefaultsSectionURL) WithBasePath(bp string) *GetDefaultsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDefaultsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetDefaultsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetDefaultsSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetDefaultsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetDefaultsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetDefaultsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetDefaultsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetDefaultsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetDefaultsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/defaults/get_defaults_sections.go b/operations/defaults/get_defaults_sections.go new file mode 100644 index 00000000..d95270f7 --- /dev/null +++ b/operations/defaults/get_defaults_sections.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetDefaultsSectionsHandlerFunc turns a function with the right signature into a get defaults sections handler +type GetDefaultsSectionsHandlerFunc func(GetDefaultsSectionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetDefaultsSectionsHandlerFunc) Handle(params GetDefaultsSectionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetDefaultsSectionsHandler interface for that can handle valid get defaults sections params +type GetDefaultsSectionsHandler interface { + Handle(GetDefaultsSectionsParams, interface{}) middleware.Responder +} + +// NewGetDefaultsSections creates a new http.Handler for the get defaults sections operation +func NewGetDefaultsSections(ctx *middleware.Context, handler GetDefaultsSectionsHandler) *GetDefaultsSections { + return &GetDefaultsSections{Context: ctx, Handler: handler} +} + +/* + GetDefaultsSections swagger:route GET /services/haproxy/configuration/defaults Defaults getDefaultsSections + +# Return an array of defaults + +Returns an array of all configured defaults. +*/ +type GetDefaultsSections struct { + Context *middleware.Context + Handler GetDefaultsSectionsHandler +} + +func (o *GetDefaultsSections) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetDefaultsSectionsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/defaults/get_defaults_sections_parameters.go b/operations/defaults/get_defaults_sections_parameters.go new file mode 100644 index 00000000..b585c236 --- /dev/null +++ b/operations/defaults/get_defaults_sections_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetDefaultsSectionsParams creates a new GetDefaultsSectionsParams object +// with the default values initialized. +func NewGetDefaultsSectionsParams() GetDefaultsSectionsParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetDefaultsSectionsParams{ + FullSection: &fullSectionDefault, + } +} + +// GetDefaultsSectionsParams contains all the bound params for the get defaults sections operation +// typically these are obtained from a http.Request +// +// swagger:parameters getDefaultsSections +type GetDefaultsSectionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetDefaultsSectionsParams() beforehand. +func (o *GetDefaultsSectionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetDefaultsSectionsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetDefaultsSectionsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetDefaultsSectionsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/defaults/get_defaults_sections_responses.go b/operations/defaults/get_defaults_sections_responses.go new file mode 100644 index 00000000..c245db02 --- /dev/null +++ b/operations/defaults/get_defaults_sections_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetDefaultsSectionsOKCode is the HTTP code returned for type GetDefaultsSectionsOK +const GetDefaultsSectionsOKCode int = 200 + +/* +GetDefaultsSectionsOK Successful operation + +swagger:response getDefaultsSectionsOK +*/ +type GetDefaultsSectionsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.DefaultsSections `json:"body,omitempty"` +} + +// NewGetDefaultsSectionsOK creates GetDefaultsSectionsOK with default headers values +func NewGetDefaultsSectionsOK() *GetDefaultsSectionsOK { + + return &GetDefaultsSectionsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get defaults sections o k response +func (o *GetDefaultsSectionsOK) WithConfigurationVersion(configurationVersion string) *GetDefaultsSectionsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get defaults sections o k response +func (o *GetDefaultsSectionsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get defaults sections o k response +func (o *GetDefaultsSectionsOK) WithPayload(payload models.DefaultsSections) *GetDefaultsSectionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get defaults sections o k response +func (o *GetDefaultsSectionsOK) SetPayload(payload models.DefaultsSections) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDefaultsSectionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.DefaultsSections{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetDefaultsSectionsDefault General Error + +swagger:response getDefaultsSectionsDefault +*/ +type GetDefaultsSectionsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDefaultsSectionsDefault creates GetDefaultsSectionsDefault with default headers values +func NewGetDefaultsSectionsDefault(code int) *GetDefaultsSectionsDefault { + if code <= 0 { + code = 500 + } + + return &GetDefaultsSectionsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get defaults sections default response +func (o *GetDefaultsSectionsDefault) WithStatusCode(code int) *GetDefaultsSectionsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get defaults sections default response +func (o *GetDefaultsSectionsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get defaults sections default response +func (o *GetDefaultsSectionsDefault) WithConfigurationVersion(configurationVersion string) *GetDefaultsSectionsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get defaults sections default response +func (o *GetDefaultsSectionsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get defaults sections default response +func (o *GetDefaultsSectionsDefault) WithPayload(payload *models.Error) *GetDefaultsSectionsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get defaults sections default response +func (o *GetDefaultsSectionsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDefaultsSectionsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/defaults/get_defaults_sections_urlbuilder.go b/operations/defaults/get_defaults_sections_urlbuilder.go new file mode 100644 index 00000000..702a1dbf --- /dev/null +++ b/operations/defaults/get_defaults_sections_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetDefaultsSectionsURL generates an URL for the get defaults sections operation +type GetDefaultsSectionsURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDefaultsSectionsURL) WithBasePath(bp string) *GetDefaultsSectionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDefaultsSectionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetDefaultsSectionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetDefaultsSectionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetDefaultsSectionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetDefaultsSectionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetDefaultsSectionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetDefaultsSectionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetDefaultsSectionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/defaults/get_defaults_urlbuilder.go b/operations/defaults/get_defaults_urlbuilder.go deleted file mode 100644 index b3806b4b..00000000 --- a/operations/defaults/get_defaults_urlbuilder.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetDefaultsURL generates an URL for the get defaults operation -type GetDefaultsURL struct { - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetDefaultsURL) WithBasePath(bp string) *GetDefaultsURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetDefaultsURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetDefaultsURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/defaults" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetDefaultsURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetDefaultsURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetDefaultsURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetDefaultsURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetDefaultsURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/defaults/replace_defaults.go b/operations/defaults/replace_defaults.go deleted file mode 100644 index 9d1227d8..00000000 --- a/operations/defaults/replace_defaults.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceDefaultsHandlerFunc turns a function with the right signature into a replace defaults handler -type ReplaceDefaultsHandlerFunc func(ReplaceDefaultsParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceDefaultsHandlerFunc) Handle(params ReplaceDefaultsParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceDefaultsHandler interface for that can handle valid replace defaults params -type ReplaceDefaultsHandler interface { - Handle(ReplaceDefaultsParams, interface{}) middleware.Responder -} - -// NewReplaceDefaults creates a new http.Handler for the replace defaults operation -func NewReplaceDefaults(ctx *middleware.Context, handler ReplaceDefaultsHandler) *ReplaceDefaults { - return &ReplaceDefaults{Context: ctx, Handler: handler} -} - -/*ReplaceDefaults swagger:route PUT /services/haproxy/configuration/defaults Defaults replaceDefaults - -Replace defaults - -Replace defaults part of config - -*/ -type ReplaceDefaults struct { - Context *middleware.Context - Handler ReplaceDefaultsHandler -} - -func (o *ReplaceDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceDefaultsParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/defaults/replace_defaults_parameters.go b/operations/defaults/replace_defaults_parameters.go deleted file mode 100644 index 90e5eb99..00000000 --- a/operations/defaults/replace_defaults_parameters.go +++ /dev/null @@ -1,196 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceDefaultsParams creates a new ReplaceDefaultsParams object -// with the default values initialized. -func NewReplaceDefaultsParams() ReplaceDefaultsParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceDefaultsParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceDefaultsParams contains all the bound params for the replace defaults operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceDefaults -type ReplaceDefaultsParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.Defaults - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceDefaultsParams() beforehand. -func (o *ReplaceDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.Defaults - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceDefaultsParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/defaults/replace_defaults_responses.go b/operations/defaults/replace_defaults_responses.go deleted file mode 100644 index aa53e626..00000000 --- a/operations/defaults/replace_defaults_responses.go +++ /dev/null @@ -1,286 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceDefaultsOKCode is the HTTP code returned for type ReplaceDefaultsOK -const ReplaceDefaultsOKCode int = 200 - -/*ReplaceDefaultsOK Defaults replaced - -swagger:response replaceDefaultsOK -*/ -type ReplaceDefaultsOK struct { - - /* - In: Body - */ - Payload *models.Defaults `json:"body,omitempty"` -} - -// NewReplaceDefaultsOK creates ReplaceDefaultsOK with default headers values -func NewReplaceDefaultsOK() *ReplaceDefaultsOK { - - return &ReplaceDefaultsOK{} -} - -// WithPayload adds the payload to the replace defaults o k response -func (o *ReplaceDefaultsOK) WithPayload(payload *models.Defaults) *ReplaceDefaultsOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace defaults o k response -func (o *ReplaceDefaultsOK) SetPayload(payload *models.Defaults) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceDefaultsAcceptedCode is the HTTP code returned for type ReplaceDefaultsAccepted -const ReplaceDefaultsAcceptedCode int = 202 - -/*ReplaceDefaultsAccepted Configuration change accepted and reload requested - -swagger:response replaceDefaultsAccepted -*/ -type ReplaceDefaultsAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.Defaults `json:"body,omitempty"` -} - -// NewReplaceDefaultsAccepted creates ReplaceDefaultsAccepted with default headers values -func NewReplaceDefaultsAccepted() *ReplaceDefaultsAccepted { - - return &ReplaceDefaultsAccepted{} -} - -// WithReloadID adds the reloadId to the replace defaults accepted response -func (o *ReplaceDefaultsAccepted) WithReloadID(reloadID string) *ReplaceDefaultsAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace defaults accepted response -func (o *ReplaceDefaultsAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace defaults accepted response -func (o *ReplaceDefaultsAccepted) WithPayload(payload *models.Defaults) *ReplaceDefaultsAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace defaults accepted response -func (o *ReplaceDefaultsAccepted) SetPayload(payload *models.Defaults) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceDefaultsBadRequestCode is the HTTP code returned for type ReplaceDefaultsBadRequest -const ReplaceDefaultsBadRequestCode int = 400 - -/*ReplaceDefaultsBadRequest Bad request - -swagger:response replaceDefaultsBadRequest -*/ -type ReplaceDefaultsBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceDefaultsBadRequest creates ReplaceDefaultsBadRequest with default headers values -func NewReplaceDefaultsBadRequest() *ReplaceDefaultsBadRequest { - - return &ReplaceDefaultsBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace defaults bad request response -func (o *ReplaceDefaultsBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceDefaultsBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace defaults bad request response -func (o *ReplaceDefaultsBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace defaults bad request response -func (o *ReplaceDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceDefaultsBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace defaults bad request response -func (o *ReplaceDefaultsBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceDefaultsDefault General Error - -swagger:response replaceDefaultsDefault -*/ -type ReplaceDefaultsDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceDefaultsDefault creates ReplaceDefaultsDefault with default headers values -func NewReplaceDefaultsDefault(code int) *ReplaceDefaultsDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceDefaultsDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace defaults default response -func (o *ReplaceDefaultsDefault) WithStatusCode(code int) *ReplaceDefaultsDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace defaults default response -func (o *ReplaceDefaultsDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace defaults default response -func (o *ReplaceDefaultsDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceDefaultsDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace defaults default response -func (o *ReplaceDefaultsDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace defaults default response -func (o *ReplaceDefaultsDefault) WithPayload(payload *models.Error) *ReplaceDefaultsDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace defaults default response -func (o *ReplaceDefaultsDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/defaults/replace_defaults_section.go b/operations/defaults/replace_defaults_section.go new file mode 100644 index 00000000..ec7746d2 --- /dev/null +++ b/operations/defaults/replace_defaults_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceDefaultsSectionHandlerFunc turns a function with the right signature into a replace defaults section handler +type ReplaceDefaultsSectionHandlerFunc func(ReplaceDefaultsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceDefaultsSectionHandlerFunc) Handle(params ReplaceDefaultsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceDefaultsSectionHandler interface for that can handle valid replace defaults section params +type ReplaceDefaultsSectionHandler interface { + Handle(ReplaceDefaultsSectionParams, interface{}) middleware.Responder +} + +// NewReplaceDefaultsSection creates a new http.Handler for the replace defaults section operation +func NewReplaceDefaultsSection(ctx *middleware.Context, handler ReplaceDefaultsSectionHandler) *ReplaceDefaultsSection { + return &ReplaceDefaultsSection{Context: ctx, Handler: handler} +} + +/* + ReplaceDefaultsSection swagger:route PUT /services/haproxy/configuration/defaults/{name} Defaults replaceDefaultsSection + +# Replace a defatults section + +Replaces a defatults section configuration by it's name. +*/ +type ReplaceDefaultsSection struct { + Context *middleware.Context + Handler ReplaceDefaultsSectionHandler +} + +func (o *ReplaceDefaultsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceDefaultsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/defaults/replace_defaults_section_parameters.go b/operations/defaults/replace_defaults_section_parameters.go new file mode 100644 index 00000000..3f94df48 --- /dev/null +++ b/operations/defaults/replace_defaults_section_parameters.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceDefaultsSectionParams creates a new ReplaceDefaultsSectionParams object +// with the default values initialized. +func NewReplaceDefaultsSectionParams() ReplaceDefaultsSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return ReplaceDefaultsSectionParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// ReplaceDefaultsSectionParams contains all the bound params for the replace defaults section operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceDefaultsSection +type ReplaceDefaultsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Defaults + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Defaults name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceDefaultsSectionParams() beforehand. +func (o *ReplaceDefaultsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Defaults + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceDefaultsSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceDefaultsSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceDefaultsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceDefaultsSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceDefaultsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceDefaultsSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/defaults/replace_defaults_section_responses.go b/operations/defaults/replace_defaults_section_responses.go new file mode 100644 index 00000000..7a9538a5 --- /dev/null +++ b/operations/defaults/replace_defaults_section_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceDefaultsSectionOKCode is the HTTP code returned for type ReplaceDefaultsSectionOK +const ReplaceDefaultsSectionOKCode int = 200 + +/* +ReplaceDefaultsSectionOK Defaults section replaced + +swagger:response replaceDefaultsSectionOK +*/ +type ReplaceDefaultsSectionOK struct { + + /* + In: Body + */ + Payload *models.Defaults `json:"body,omitempty"` +} + +// NewReplaceDefaultsSectionOK creates ReplaceDefaultsSectionOK with default headers values +func NewReplaceDefaultsSectionOK() *ReplaceDefaultsSectionOK { + + return &ReplaceDefaultsSectionOK{} +} + +// WithPayload adds the payload to the replace defaults section o k response +func (o *ReplaceDefaultsSectionOK) WithPayload(payload *models.Defaults) *ReplaceDefaultsSectionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace defaults section o k response +func (o *ReplaceDefaultsSectionOK) SetPayload(payload *models.Defaults) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDefaultsSectionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDefaultsSectionAcceptedCode is the HTTP code returned for type ReplaceDefaultsSectionAccepted +const ReplaceDefaultsSectionAcceptedCode int = 202 + +/* +ReplaceDefaultsSectionAccepted Configuration change accepted and reload requested + +swagger:response replaceDefaultsSectionAccepted +*/ +type ReplaceDefaultsSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Defaults `json:"body,omitempty"` +} + +// NewReplaceDefaultsSectionAccepted creates ReplaceDefaultsSectionAccepted with default headers values +func NewReplaceDefaultsSectionAccepted() *ReplaceDefaultsSectionAccepted { + + return &ReplaceDefaultsSectionAccepted{} +} + +// WithReloadID adds the reloadId to the replace defaults section accepted response +func (o *ReplaceDefaultsSectionAccepted) WithReloadID(reloadID string) *ReplaceDefaultsSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace defaults section accepted response +func (o *ReplaceDefaultsSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace defaults section accepted response +func (o *ReplaceDefaultsSectionAccepted) WithPayload(payload *models.Defaults) *ReplaceDefaultsSectionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace defaults section accepted response +func (o *ReplaceDefaultsSectionAccepted) SetPayload(payload *models.Defaults) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDefaultsSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDefaultsSectionBadRequestCode is the HTTP code returned for type ReplaceDefaultsSectionBadRequest +const ReplaceDefaultsSectionBadRequestCode int = 400 + +/* +ReplaceDefaultsSectionBadRequest Bad request + +swagger:response replaceDefaultsSectionBadRequest +*/ +type ReplaceDefaultsSectionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDefaultsSectionBadRequest creates ReplaceDefaultsSectionBadRequest with default headers values +func NewReplaceDefaultsSectionBadRequest() *ReplaceDefaultsSectionBadRequest { + + return &ReplaceDefaultsSectionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace defaults section bad request response +func (o *ReplaceDefaultsSectionBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceDefaultsSectionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace defaults section bad request response +func (o *ReplaceDefaultsSectionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace defaults section bad request response +func (o *ReplaceDefaultsSectionBadRequest) WithPayload(payload *models.Error) *ReplaceDefaultsSectionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace defaults section bad request response +func (o *ReplaceDefaultsSectionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDefaultsSectionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDefaultsSectionNotFoundCode is the HTTP code returned for type ReplaceDefaultsSectionNotFound +const ReplaceDefaultsSectionNotFoundCode int = 404 + +/* +ReplaceDefaultsSectionNotFound The specified resource was not found + +swagger:response replaceDefaultsSectionNotFound +*/ +type ReplaceDefaultsSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDefaultsSectionNotFound creates ReplaceDefaultsSectionNotFound with default headers values +func NewReplaceDefaultsSectionNotFound() *ReplaceDefaultsSectionNotFound { + + return &ReplaceDefaultsSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace defaults section not found response +func (o *ReplaceDefaultsSectionNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceDefaultsSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace defaults section not found response +func (o *ReplaceDefaultsSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace defaults section not found response +func (o *ReplaceDefaultsSectionNotFound) WithPayload(payload *models.Error) *ReplaceDefaultsSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace defaults section not found response +func (o *ReplaceDefaultsSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDefaultsSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceDefaultsSectionDefault General Error + +swagger:response replaceDefaultsSectionDefault +*/ +type ReplaceDefaultsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDefaultsSectionDefault creates ReplaceDefaultsSectionDefault with default headers values +func NewReplaceDefaultsSectionDefault(code int) *ReplaceDefaultsSectionDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceDefaultsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace defaults section default response +func (o *ReplaceDefaultsSectionDefault) WithStatusCode(code int) *ReplaceDefaultsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace defaults section default response +func (o *ReplaceDefaultsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace defaults section default response +func (o *ReplaceDefaultsSectionDefault) WithConfigurationVersion(configurationVersion string) *ReplaceDefaultsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace defaults section default response +func (o *ReplaceDefaultsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace defaults section default response +func (o *ReplaceDefaultsSectionDefault) WithPayload(payload *models.Error) *ReplaceDefaultsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace defaults section default response +func (o *ReplaceDefaultsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDefaultsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/defaults/replace_defaults_section_urlbuilder.go b/operations/defaults/replace_defaults_section_urlbuilder.go new file mode 100644 index 00000000..4ab7eada --- /dev/null +++ b/operations/defaults/replace_defaults_section_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package defaults + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceDefaultsSectionURL generates an URL for the replace defaults section operation +type ReplaceDefaultsSectionURL struct { + Name string + + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDefaultsSectionURL) WithBasePath(bp string) *ReplaceDefaultsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDefaultsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceDefaultsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceDefaultsSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceDefaultsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceDefaultsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceDefaultsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceDefaultsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceDefaultsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceDefaultsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/defaults/replace_defaults_urlbuilder.go b/operations/defaults/replace_defaults_urlbuilder.go deleted file mode 100644 index fea12211..00000000 --- a/operations/defaults/replace_defaults_urlbuilder.go +++ /dev/null @@ -1,138 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package defaults - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// ReplaceDefaultsURL generates an URL for the replace defaults operation -type ReplaceDefaultsURL struct { - ForceReload *bool - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceDefaultsURL) WithBasePath(bp string) *ReplaceDefaultsURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceDefaultsURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceDefaultsURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/defaults" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceDefaultsURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceDefaultsURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceDefaultsURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceDefaultsURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceDefaultsURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/dgram_bind/create_dgram_bind.go b/operations/dgram_bind/create_dgram_bind.go new file mode 100644 index 00000000..fec65b11 --- /dev/null +++ b/operations/dgram_bind/create_dgram_bind.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateDgramBindHandlerFunc turns a function with the right signature into a create dgram bind handler +type CreateDgramBindHandlerFunc func(CreateDgramBindParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateDgramBindHandlerFunc) Handle(params CreateDgramBindParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateDgramBindHandler interface for that can handle valid create dgram bind params +type CreateDgramBindHandler interface { + Handle(CreateDgramBindParams, interface{}) middleware.Responder +} + +// NewCreateDgramBind creates a new http.Handler for the create dgram bind operation +func NewCreateDgramBind(ctx *middleware.Context, handler CreateDgramBindHandler) *CreateDgramBind { + return &CreateDgramBind{Context: ctx, Handler: handler} +} + +/* + CreateDgramBind swagger:route POST /services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds DgramBind createDgramBind + +# Add a new dgram bind + +Adds a new dgram bind in the specified log forward in the configuration file. +*/ +type CreateDgramBind struct { + Context *middleware.Context + Handler CreateDgramBindHandler +} + +func (o *CreateDgramBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateDgramBindParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/dgram_bind/create_dgram_bind_parameters.go b/operations/dgram_bind/create_dgram_bind_parameters.go new file mode 100644 index 00000000..2678b1e1 --- /dev/null +++ b/operations/dgram_bind/create_dgram_bind_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateDgramBindParams creates a new CreateDgramBindParams object +// with the default values initialized. +func NewCreateDgramBindParams() CreateDgramBindParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateDgramBindParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateDgramBindParams contains all the bound params for the create dgram bind operation +// typically these are obtained from a http.Request +// +// swagger:parameters createDgramBind +type CreateDgramBindParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.DgramBind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateDgramBindParams() beforehand. +func (o *CreateDgramBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.DgramBind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateDgramBindParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateDgramBindParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateDgramBindParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateDgramBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateDgramBindParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/dgram_bind/create_dgram_bind_responses.go b/operations/dgram_bind/create_dgram_bind_responses.go new file mode 100644 index 00000000..b6940f41 --- /dev/null +++ b/operations/dgram_bind/create_dgram_bind_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateDgramBindCreatedCode is the HTTP code returned for type CreateDgramBindCreated +const CreateDgramBindCreatedCode int = 201 + +/* +CreateDgramBindCreated Bind created + +swagger:response createDgramBindCreated +*/ +type CreateDgramBindCreated struct { + + /* + In: Body + */ + Payload *models.DgramBind `json:"body,omitempty"` +} + +// NewCreateDgramBindCreated creates CreateDgramBindCreated with default headers values +func NewCreateDgramBindCreated() *CreateDgramBindCreated { + + return &CreateDgramBindCreated{} +} + +// WithPayload adds the payload to the create dgram bind created response +func (o *CreateDgramBindCreated) WithPayload(payload *models.DgramBind) *CreateDgramBindCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create dgram bind created response +func (o *CreateDgramBindCreated) SetPayload(payload *models.DgramBind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDgramBindCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDgramBindAcceptedCode is the HTTP code returned for type CreateDgramBindAccepted +const CreateDgramBindAcceptedCode int = 202 + +/* +CreateDgramBindAccepted Configuration change accepted and reload requested + +swagger:response createDgramBindAccepted +*/ +type CreateDgramBindAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.DgramBind `json:"body,omitempty"` +} + +// NewCreateDgramBindAccepted creates CreateDgramBindAccepted with default headers values +func NewCreateDgramBindAccepted() *CreateDgramBindAccepted { + + return &CreateDgramBindAccepted{} +} + +// WithReloadID adds the reloadId to the create dgram bind accepted response +func (o *CreateDgramBindAccepted) WithReloadID(reloadID string) *CreateDgramBindAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create dgram bind accepted response +func (o *CreateDgramBindAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create dgram bind accepted response +func (o *CreateDgramBindAccepted) WithPayload(payload *models.DgramBind) *CreateDgramBindAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create dgram bind accepted response +func (o *CreateDgramBindAccepted) SetPayload(payload *models.DgramBind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDgramBindAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDgramBindBadRequestCode is the HTTP code returned for type CreateDgramBindBadRequest +const CreateDgramBindBadRequestCode int = 400 + +/* +CreateDgramBindBadRequest Bad request + +swagger:response createDgramBindBadRequest +*/ +type CreateDgramBindBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDgramBindBadRequest creates CreateDgramBindBadRequest with default headers values +func NewCreateDgramBindBadRequest() *CreateDgramBindBadRequest { + + return &CreateDgramBindBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create dgram bind bad request response +func (o *CreateDgramBindBadRequest) WithConfigurationVersion(configurationVersion string) *CreateDgramBindBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create dgram bind bad request response +func (o *CreateDgramBindBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create dgram bind bad request response +func (o *CreateDgramBindBadRequest) WithPayload(payload *models.Error) *CreateDgramBindBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create dgram bind bad request response +func (o *CreateDgramBindBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDgramBindBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateDgramBindConflictCode is the HTTP code returned for type CreateDgramBindConflict +const CreateDgramBindConflictCode int = 409 + +/* +CreateDgramBindConflict The specified resource already exists + +swagger:response createDgramBindConflict +*/ +type CreateDgramBindConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDgramBindConflict creates CreateDgramBindConflict with default headers values +func NewCreateDgramBindConflict() *CreateDgramBindConflict { + + return &CreateDgramBindConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create dgram bind conflict response +func (o *CreateDgramBindConflict) WithConfigurationVersion(configurationVersion string) *CreateDgramBindConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create dgram bind conflict response +func (o *CreateDgramBindConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create dgram bind conflict response +func (o *CreateDgramBindConflict) WithPayload(payload *models.Error) *CreateDgramBindConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create dgram bind conflict response +func (o *CreateDgramBindConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDgramBindConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateDgramBindDefault General Error + +swagger:response createDgramBindDefault +*/ +type CreateDgramBindDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateDgramBindDefault creates CreateDgramBindDefault with default headers values +func NewCreateDgramBindDefault(code int) *CreateDgramBindDefault { + if code <= 0 { + code = 500 + } + + return &CreateDgramBindDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create dgram bind default response +func (o *CreateDgramBindDefault) WithStatusCode(code int) *CreateDgramBindDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create dgram bind default response +func (o *CreateDgramBindDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create dgram bind default response +func (o *CreateDgramBindDefault) WithConfigurationVersion(configurationVersion string) *CreateDgramBindDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create dgram bind default response +func (o *CreateDgramBindDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create dgram bind default response +func (o *CreateDgramBindDefault) WithPayload(payload *models.Error) *CreateDgramBindDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create dgram bind default response +func (o *CreateDgramBindDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateDgramBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/dgram_bind/create_dgram_bind_urlbuilder.go b/operations/dgram_bind/create_dgram_bind_urlbuilder.go new file mode 100644 index 00000000..3a37b653 --- /dev/null +++ b/operations/dgram_bind/create_dgram_bind_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateDgramBindURL generates an URL for the create dgram bind operation +type CreateDgramBindURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateDgramBindURL) WithBasePath(bp string) *CreateDgramBindURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateDgramBindURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateDgramBindURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateDgramBindURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateDgramBindURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateDgramBindURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateDgramBindURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateDgramBindURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateDgramBindURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateDgramBindURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/dgram_bind/delete_dgram_bind.go b/operations/dgram_bind/delete_dgram_bind.go new file mode 100644 index 00000000..fa96f4cb --- /dev/null +++ b/operations/dgram_bind/delete_dgram_bind.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteDgramBindHandlerFunc turns a function with the right signature into a delete dgram bind handler +type DeleteDgramBindHandlerFunc func(DeleteDgramBindParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteDgramBindHandlerFunc) Handle(params DeleteDgramBindParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteDgramBindHandler interface for that can handle valid delete dgram bind params +type DeleteDgramBindHandler interface { + Handle(DeleteDgramBindParams, interface{}) middleware.Responder +} + +// NewDeleteDgramBind creates a new http.Handler for the delete dgram bind operation +func NewDeleteDgramBind(ctx *middleware.Context, handler DeleteDgramBindHandler) *DeleteDgramBind { + return &DeleteDgramBind{Context: ctx, Handler: handler} +} + +/* + DeleteDgramBind swagger:route DELETE /services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name} DgramBind deleteDgramBind + +# Delete a dgram bind + +Deletes a dgram bind configuration by it's name in the specified log forward. +*/ +type DeleteDgramBind struct { + Context *middleware.Context + Handler DeleteDgramBindHandler +} + +func (o *DeleteDgramBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteDgramBindParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/dgram_bind/delete_dgram_bind_parameters.go b/operations/dgram_bind/delete_dgram_bind_parameters.go new file mode 100644 index 00000000..b3995061 --- /dev/null +++ b/operations/dgram_bind/delete_dgram_bind_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteDgramBindParams creates a new DeleteDgramBindParams object +// with the default values initialized. +func NewDeleteDgramBindParams() DeleteDgramBindParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteDgramBindParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteDgramBindParams contains all the bound params for the delete dgram bind operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteDgramBind +type DeleteDgramBindParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteDgramBindParams() beforehand. +func (o *DeleteDgramBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteDgramBindParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteDgramBindParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteDgramBindParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteDgramBindParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteDgramBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteDgramBindParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/dgram_bind/delete_dgram_bind_responses.go b/operations/dgram_bind/delete_dgram_bind_responses.go new file mode 100644 index 00000000..5ae6f89f --- /dev/null +++ b/operations/dgram_bind/delete_dgram_bind_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteDgramBindAcceptedCode is the HTTP code returned for type DeleteDgramBindAccepted +const DeleteDgramBindAcceptedCode int = 202 + +/* +DeleteDgramBindAccepted Configuration change accepted and reload requested + +swagger:response deleteDgramBindAccepted +*/ +type DeleteDgramBindAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteDgramBindAccepted creates DeleteDgramBindAccepted with default headers values +func NewDeleteDgramBindAccepted() *DeleteDgramBindAccepted { + + return &DeleteDgramBindAccepted{} +} + +// WithReloadID adds the reloadId to the delete dgram bind accepted response +func (o *DeleteDgramBindAccepted) WithReloadID(reloadID string) *DeleteDgramBindAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete dgram bind accepted response +func (o *DeleteDgramBindAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteDgramBindAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteDgramBindNoContentCode is the HTTP code returned for type DeleteDgramBindNoContent +const DeleteDgramBindNoContentCode int = 204 + +/* +DeleteDgramBindNoContent Bind deleted + +swagger:response deleteDgramBindNoContent +*/ +type DeleteDgramBindNoContent struct { +} + +// NewDeleteDgramBindNoContent creates DeleteDgramBindNoContent with default headers values +func NewDeleteDgramBindNoContent() *DeleteDgramBindNoContent { + + return &DeleteDgramBindNoContent{} +} + +// WriteResponse to the client +func (o *DeleteDgramBindNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteDgramBindNotFoundCode is the HTTP code returned for type DeleteDgramBindNotFound +const DeleteDgramBindNotFoundCode int = 404 + +/* +DeleteDgramBindNotFound The specified resource was not found + +swagger:response deleteDgramBindNotFound +*/ +type DeleteDgramBindNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteDgramBindNotFound creates DeleteDgramBindNotFound with default headers values +func NewDeleteDgramBindNotFound() *DeleteDgramBindNotFound { + + return &DeleteDgramBindNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete dgram bind not found response +func (o *DeleteDgramBindNotFound) WithConfigurationVersion(configurationVersion string) *DeleteDgramBindNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete dgram bind not found response +func (o *DeleteDgramBindNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete dgram bind not found response +func (o *DeleteDgramBindNotFound) WithPayload(payload *models.Error) *DeleteDgramBindNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete dgram bind not found response +func (o *DeleteDgramBindNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteDgramBindNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteDgramBindDefault General Error + +swagger:response deleteDgramBindDefault +*/ +type DeleteDgramBindDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteDgramBindDefault creates DeleteDgramBindDefault with default headers values +func NewDeleteDgramBindDefault(code int) *DeleteDgramBindDefault { + if code <= 0 { + code = 500 + } + + return &DeleteDgramBindDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete dgram bind default response +func (o *DeleteDgramBindDefault) WithStatusCode(code int) *DeleteDgramBindDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete dgram bind default response +func (o *DeleteDgramBindDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete dgram bind default response +func (o *DeleteDgramBindDefault) WithConfigurationVersion(configurationVersion string) *DeleteDgramBindDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete dgram bind default response +func (o *DeleteDgramBindDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete dgram bind default response +func (o *DeleteDgramBindDefault) WithPayload(payload *models.Error) *DeleteDgramBindDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete dgram bind default response +func (o *DeleteDgramBindDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteDgramBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/dgram_bind/delete_dgram_bind_urlbuilder.go b/operations/dgram_bind/delete_dgram_bind_urlbuilder.go new file mode 100644 index 00000000..564e18bd --- /dev/null +++ b/operations/dgram_bind/delete_dgram_bind_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteDgramBindURL generates an URL for the delete dgram bind operation +type DeleteDgramBindURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteDgramBindURL) WithBasePath(bp string) *DeleteDgramBindURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteDgramBindURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteDgramBindURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteDgramBindURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteDgramBindURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteDgramBindURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteDgramBindURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteDgramBindURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteDgramBindURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteDgramBindURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteDgramBindURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/dgram_bind/get_dgram_bind.go b/operations/dgram_bind/get_dgram_bind.go new file mode 100644 index 00000000..deabe3c3 --- /dev/null +++ b/operations/dgram_bind/get_dgram_bind.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetDgramBindHandlerFunc turns a function with the right signature into a get dgram bind handler +type GetDgramBindHandlerFunc func(GetDgramBindParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetDgramBindHandlerFunc) Handle(params GetDgramBindParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetDgramBindHandler interface for that can handle valid get dgram bind params +type GetDgramBindHandler interface { + Handle(GetDgramBindParams, interface{}) middleware.Responder +} + +// NewGetDgramBind creates a new http.Handler for the get dgram bind operation +func NewGetDgramBind(ctx *middleware.Context, handler GetDgramBindHandler) *GetDgramBind { + return &GetDgramBind{Context: ctx, Handler: handler} +} + +/* + GetDgramBind swagger:route GET /services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name} DgramBind getDgramBind + +# Return one dgram bind + +Returns one dgram bind configuration by it's name in the specified log forward. +*/ +type GetDgramBind struct { + Context *middleware.Context + Handler GetDgramBindHandler +} + +func (o *GetDgramBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetDgramBindParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/dgram_bind/get_dgram_bind_parameters.go b/operations/dgram_bind/get_dgram_bind_parameters.go new file mode 100644 index 00000000..4355ac22 --- /dev/null +++ b/operations/dgram_bind/get_dgram_bind_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetDgramBindParams creates a new GetDgramBindParams object +// +// There are no default values defined in the spec. +func NewGetDgramBindParams() GetDgramBindParams { + + return GetDgramBindParams{} +} + +// GetDgramBindParams contains all the bound params for the get dgram bind operation +// typically these are obtained from a http.Request +// +// swagger:parameters getDgramBind +type GetDgramBindParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetDgramBindParams() beforehand. +func (o *GetDgramBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetDgramBindParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetDgramBindParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetDgramBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/dgram_bind/get_dgram_bind_responses.go b/operations/dgram_bind/get_dgram_bind_responses.go new file mode 100644 index 00000000..054a8b97 --- /dev/null +++ b/operations/dgram_bind/get_dgram_bind_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetDgramBindOKCode is the HTTP code returned for type GetDgramBindOK +const GetDgramBindOKCode int = 200 + +/* +GetDgramBindOK Successful operation + +swagger:response getDgramBindOK +*/ +type GetDgramBindOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.DgramBind `json:"body,omitempty"` +} + +// NewGetDgramBindOK creates GetDgramBindOK with default headers values +func NewGetDgramBindOK() *GetDgramBindOK { + + return &GetDgramBindOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get dgram bind o k response +func (o *GetDgramBindOK) WithConfigurationVersion(configurationVersion string) *GetDgramBindOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get dgram bind o k response +func (o *GetDgramBindOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get dgram bind o k response +func (o *GetDgramBindOK) WithPayload(payload *models.DgramBind) *GetDgramBindOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get dgram bind o k response +func (o *GetDgramBindOK) SetPayload(payload *models.DgramBind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDgramBindOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetDgramBindNotFoundCode is the HTTP code returned for type GetDgramBindNotFound +const GetDgramBindNotFoundCode int = 404 + +/* +GetDgramBindNotFound The specified resource already exists + +swagger:response getDgramBindNotFound +*/ +type GetDgramBindNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDgramBindNotFound creates GetDgramBindNotFound with default headers values +func NewGetDgramBindNotFound() *GetDgramBindNotFound { + + return &GetDgramBindNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get dgram bind not found response +func (o *GetDgramBindNotFound) WithConfigurationVersion(configurationVersion string) *GetDgramBindNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get dgram bind not found response +func (o *GetDgramBindNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get dgram bind not found response +func (o *GetDgramBindNotFound) WithPayload(payload *models.Error) *GetDgramBindNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get dgram bind not found response +func (o *GetDgramBindNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDgramBindNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetDgramBindDefault General Error + +swagger:response getDgramBindDefault +*/ +type GetDgramBindDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDgramBindDefault creates GetDgramBindDefault with default headers values +func NewGetDgramBindDefault(code int) *GetDgramBindDefault { + if code <= 0 { + code = 500 + } + + return &GetDgramBindDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get dgram bind default response +func (o *GetDgramBindDefault) WithStatusCode(code int) *GetDgramBindDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get dgram bind default response +func (o *GetDgramBindDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get dgram bind default response +func (o *GetDgramBindDefault) WithConfigurationVersion(configurationVersion string) *GetDgramBindDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get dgram bind default response +func (o *GetDgramBindDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get dgram bind default response +func (o *GetDgramBindDefault) WithPayload(payload *models.Error) *GetDgramBindDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get dgram bind default response +func (o *GetDgramBindDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDgramBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/dgram_bind/get_dgram_bind_urlbuilder.go b/operations/dgram_bind/get_dgram_bind_urlbuilder.go new file mode 100644 index 00000000..a252994c --- /dev/null +++ b/operations/dgram_bind/get_dgram_bind_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetDgramBindURL generates an URL for the get dgram bind operation +type GetDgramBindURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDgramBindURL) WithBasePath(bp string) *GetDgramBindURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDgramBindURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetDgramBindURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetDgramBindURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetDgramBindURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetDgramBindURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetDgramBindURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetDgramBindURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetDgramBindURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetDgramBindURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetDgramBindURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/dgram_bind/get_dgram_binds.go b/operations/dgram_bind/get_dgram_binds.go new file mode 100644 index 00000000..ada78ead --- /dev/null +++ b/operations/dgram_bind/get_dgram_binds.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetDgramBindsHandlerFunc turns a function with the right signature into a get dgram binds handler +type GetDgramBindsHandlerFunc func(GetDgramBindsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetDgramBindsHandlerFunc) Handle(params GetDgramBindsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetDgramBindsHandler interface for that can handle valid get dgram binds params +type GetDgramBindsHandler interface { + Handle(GetDgramBindsParams, interface{}) middleware.Responder +} + +// NewGetDgramBinds creates a new http.Handler for the get dgram binds operation +func NewGetDgramBinds(ctx *middleware.Context, handler GetDgramBindsHandler) *GetDgramBinds { + return &GetDgramBinds{Context: ctx, Handler: handler} +} + +/* + GetDgramBinds swagger:route GET /services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds DgramBind getDgramBinds + +# Return an array of dgram binds + +Returns an array of all dgram binds that are configured in specified log forward. +*/ +type GetDgramBinds struct { + Context *middleware.Context + Handler GetDgramBindsHandler +} + +func (o *GetDgramBinds) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetDgramBindsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/dgram_bind/get_dgram_binds_parameters.go b/operations/dgram_bind/get_dgram_binds_parameters.go new file mode 100644 index 00000000..c37006e9 --- /dev/null +++ b/operations/dgram_bind/get_dgram_binds_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetDgramBindsParams creates a new GetDgramBindsParams object +// +// There are no default values defined in the spec. +func NewGetDgramBindsParams() GetDgramBindsParams { + + return GetDgramBindsParams{} +} + +// GetDgramBindsParams contains all the bound params for the get dgram binds operation +// typically these are obtained from a http.Request +// +// swagger:parameters getDgramBinds +type GetDgramBindsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetDgramBindsParams() beforehand. +func (o *GetDgramBindsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetDgramBindsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetDgramBindsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/dgram_bind/get_dgram_binds_responses.go b/operations/dgram_bind/get_dgram_binds_responses.go new file mode 100644 index 00000000..093978b7 --- /dev/null +++ b/operations/dgram_bind/get_dgram_binds_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetDgramBindsOKCode is the HTTP code returned for type GetDgramBindsOK +const GetDgramBindsOKCode int = 200 + +/* +GetDgramBindsOK Successful operation + +swagger:response getDgramBindsOK +*/ +type GetDgramBindsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.DgramBinds `json:"body,omitempty"` +} + +// NewGetDgramBindsOK creates GetDgramBindsOK with default headers values +func NewGetDgramBindsOK() *GetDgramBindsOK { + + return &GetDgramBindsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get dgram binds o k response +func (o *GetDgramBindsOK) WithConfigurationVersion(configurationVersion string) *GetDgramBindsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get dgram binds o k response +func (o *GetDgramBindsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get dgram binds o k response +func (o *GetDgramBindsOK) WithPayload(payload models.DgramBinds) *GetDgramBindsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get dgram binds o k response +func (o *GetDgramBindsOK) SetPayload(payload models.DgramBinds) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDgramBindsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.DgramBinds{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetDgramBindsDefault General Error + +swagger:response getDgramBindsDefault +*/ +type GetDgramBindsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDgramBindsDefault creates GetDgramBindsDefault with default headers values +func NewGetDgramBindsDefault(code int) *GetDgramBindsDefault { + if code <= 0 { + code = 500 + } + + return &GetDgramBindsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get dgram binds default response +func (o *GetDgramBindsDefault) WithStatusCode(code int) *GetDgramBindsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get dgram binds default response +func (o *GetDgramBindsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get dgram binds default response +func (o *GetDgramBindsDefault) WithConfigurationVersion(configurationVersion string) *GetDgramBindsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get dgram binds default response +func (o *GetDgramBindsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get dgram binds default response +func (o *GetDgramBindsDefault) WithPayload(payload *models.Error) *GetDgramBindsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get dgram binds default response +func (o *GetDgramBindsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDgramBindsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/dgram_bind/get_dgram_binds_urlbuilder.go b/operations/dgram_bind/get_dgram_binds_urlbuilder.go new file mode 100644 index 00000000..755add34 --- /dev/null +++ b/operations/dgram_bind/get_dgram_binds_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetDgramBindsURL generates an URL for the get dgram binds operation +type GetDgramBindsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDgramBindsURL) WithBasePath(bp string) *GetDgramBindsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetDgramBindsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetDgramBindsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetDgramBindsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetDgramBindsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetDgramBindsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetDgramBindsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetDgramBindsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetDgramBindsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetDgramBindsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/dgram_bind/replace_dgram_bind.go b/operations/dgram_bind/replace_dgram_bind.go new file mode 100644 index 00000000..1a5f14ad --- /dev/null +++ b/operations/dgram_bind/replace_dgram_bind.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceDgramBindHandlerFunc turns a function with the right signature into a replace dgram bind handler +type ReplaceDgramBindHandlerFunc func(ReplaceDgramBindParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceDgramBindHandlerFunc) Handle(params ReplaceDgramBindParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceDgramBindHandler interface for that can handle valid replace dgram bind params +type ReplaceDgramBindHandler interface { + Handle(ReplaceDgramBindParams, interface{}) middleware.Responder +} + +// NewReplaceDgramBind creates a new http.Handler for the replace dgram bind operation +func NewReplaceDgramBind(ctx *middleware.Context, handler ReplaceDgramBindHandler) *ReplaceDgramBind { + return &ReplaceDgramBind{Context: ctx, Handler: handler} +} + +/* + ReplaceDgramBind swagger:route PUT /services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name} DgramBind replaceDgramBind + +# Replace a dgram bind + +Replaces a dgram bind configuration by it's name in the specified log forward. +*/ +type ReplaceDgramBind struct { + Context *middleware.Context + Handler ReplaceDgramBindHandler +} + +func (o *ReplaceDgramBind) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceDgramBindParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/dgram_bind/replace_dgram_bind_parameters.go b/operations/dgram_bind/replace_dgram_bind_parameters.go new file mode 100644 index 00000000..3f05f62b --- /dev/null +++ b/operations/dgram_bind/replace_dgram_bind_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceDgramBindParams creates a new ReplaceDgramBindParams object +// with the default values initialized. +func NewReplaceDgramBindParams() ReplaceDgramBindParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceDgramBindParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceDgramBindParams contains all the bound params for the replace dgram bind operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceDgramBind +type ReplaceDgramBindParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.DgramBind + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Bind name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceDgramBindParams() beforehand. +func (o *ReplaceDgramBindParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.DgramBind + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceDgramBindParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceDgramBindParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceDgramBindParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceDgramBindParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceDgramBindParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceDgramBindParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/dgram_bind/replace_dgram_bind_responses.go b/operations/dgram_bind/replace_dgram_bind_responses.go new file mode 100644 index 00000000..ecef4fe6 --- /dev/null +++ b/operations/dgram_bind/replace_dgram_bind_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceDgramBindOKCode is the HTTP code returned for type ReplaceDgramBindOK +const ReplaceDgramBindOKCode int = 200 + +/* +ReplaceDgramBindOK Bind replaced + +swagger:response replaceDgramBindOK +*/ +type ReplaceDgramBindOK struct { + + /* + In: Body + */ + Payload *models.DgramBind `json:"body,omitempty"` +} + +// NewReplaceDgramBindOK creates ReplaceDgramBindOK with default headers values +func NewReplaceDgramBindOK() *ReplaceDgramBindOK { + + return &ReplaceDgramBindOK{} +} + +// WithPayload adds the payload to the replace dgram bind o k response +func (o *ReplaceDgramBindOK) WithPayload(payload *models.DgramBind) *ReplaceDgramBindOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace dgram bind o k response +func (o *ReplaceDgramBindOK) SetPayload(payload *models.DgramBind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDgramBindOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDgramBindAcceptedCode is the HTTP code returned for type ReplaceDgramBindAccepted +const ReplaceDgramBindAcceptedCode int = 202 + +/* +ReplaceDgramBindAccepted Configuration change accepted and reload requested + +swagger:response replaceDgramBindAccepted +*/ +type ReplaceDgramBindAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.DgramBind `json:"body,omitempty"` +} + +// NewReplaceDgramBindAccepted creates ReplaceDgramBindAccepted with default headers values +func NewReplaceDgramBindAccepted() *ReplaceDgramBindAccepted { + + return &ReplaceDgramBindAccepted{} +} + +// WithReloadID adds the reloadId to the replace dgram bind accepted response +func (o *ReplaceDgramBindAccepted) WithReloadID(reloadID string) *ReplaceDgramBindAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace dgram bind accepted response +func (o *ReplaceDgramBindAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace dgram bind accepted response +func (o *ReplaceDgramBindAccepted) WithPayload(payload *models.DgramBind) *ReplaceDgramBindAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace dgram bind accepted response +func (o *ReplaceDgramBindAccepted) SetPayload(payload *models.DgramBind) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDgramBindAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDgramBindBadRequestCode is the HTTP code returned for type ReplaceDgramBindBadRequest +const ReplaceDgramBindBadRequestCode int = 400 + +/* +ReplaceDgramBindBadRequest Bad request + +swagger:response replaceDgramBindBadRequest +*/ +type ReplaceDgramBindBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDgramBindBadRequest creates ReplaceDgramBindBadRequest with default headers values +func NewReplaceDgramBindBadRequest() *ReplaceDgramBindBadRequest { + + return &ReplaceDgramBindBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace dgram bind bad request response +func (o *ReplaceDgramBindBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceDgramBindBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace dgram bind bad request response +func (o *ReplaceDgramBindBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace dgram bind bad request response +func (o *ReplaceDgramBindBadRequest) WithPayload(payload *models.Error) *ReplaceDgramBindBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace dgram bind bad request response +func (o *ReplaceDgramBindBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDgramBindBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceDgramBindNotFoundCode is the HTTP code returned for type ReplaceDgramBindNotFound +const ReplaceDgramBindNotFoundCode int = 404 + +/* +ReplaceDgramBindNotFound The specified resource was not found + +swagger:response replaceDgramBindNotFound +*/ +type ReplaceDgramBindNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDgramBindNotFound creates ReplaceDgramBindNotFound with default headers values +func NewReplaceDgramBindNotFound() *ReplaceDgramBindNotFound { + + return &ReplaceDgramBindNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace dgram bind not found response +func (o *ReplaceDgramBindNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceDgramBindNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace dgram bind not found response +func (o *ReplaceDgramBindNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace dgram bind not found response +func (o *ReplaceDgramBindNotFound) WithPayload(payload *models.Error) *ReplaceDgramBindNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace dgram bind not found response +func (o *ReplaceDgramBindNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDgramBindNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceDgramBindDefault General Error + +swagger:response replaceDgramBindDefault +*/ +type ReplaceDgramBindDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceDgramBindDefault creates ReplaceDgramBindDefault with default headers values +func NewReplaceDgramBindDefault(code int) *ReplaceDgramBindDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceDgramBindDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace dgram bind default response +func (o *ReplaceDgramBindDefault) WithStatusCode(code int) *ReplaceDgramBindDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace dgram bind default response +func (o *ReplaceDgramBindDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace dgram bind default response +func (o *ReplaceDgramBindDefault) WithConfigurationVersion(configurationVersion string) *ReplaceDgramBindDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace dgram bind default response +func (o *ReplaceDgramBindDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace dgram bind default response +func (o *ReplaceDgramBindDefault) WithPayload(payload *models.Error) *ReplaceDgramBindDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace dgram bind default response +func (o *ReplaceDgramBindDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceDgramBindDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/dgram_bind/replace_dgram_bind_urlbuilder.go b/operations/dgram_bind/replace_dgram_bind_urlbuilder.go new file mode 100644 index 00000000..e36bd84e --- /dev/null +++ b/operations/dgram_bind/replace_dgram_bind_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package dgram_bind + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceDgramBindURL generates an URL for the replace dgram bind operation +type ReplaceDgramBindURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDgramBindURL) WithBasePath(bp string) *ReplaceDgramBindURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceDgramBindURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceDgramBindURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/dgram_binds/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceDgramBindURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceDgramBindURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceDgramBindURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceDgramBindURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceDgramBindURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceDgramBindURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceDgramBindURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceDgramBindURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/discovery/get_api_endpoints.go b/operations/discovery/get_api_endpoints.go index 819b363c..117baf47 100644 --- a/operations/discovery/get_api_endpoints.go +++ b/operations/discovery/get_api_endpoints.go @@ -23,7 +23,7 @@ package discovery import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetAPIEndpointsHandlerFunc turns a function with the right signature into a get API endpoints handler @@ -44,12 +44,12 @@ func NewGetAPIEndpoints(ctx *middleware.Context, handler GetAPIEndpointsHandler) return &GetAPIEndpoints{Context: ctx, Handler: handler} } -/*GetAPIEndpoints swagger:route GET / Discovery getApiEndpoints +/* + GetAPIEndpoints swagger:route GET / Discovery getApiEndpoints -Return list of root endpoints +# Return list of root endpoints Returns a list of root endpoints. - */ type GetAPIEndpoints struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetAPIEndpoints struct { func (o *GetAPIEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetAPIEndpointsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetAPIEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/discovery/get_api_endpoints_parameters.go b/operations/discovery/get_api_endpoints_parameters.go index b093f551..c5f9f3f0 100644 --- a/operations/discovery/get_api_endpoints_parameters.go +++ b/operations/discovery/get_api_endpoints_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetAPIEndpointsParams creates a new GetAPIEndpointsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetAPIEndpointsParams() GetAPIEndpointsParams { return GetAPIEndpointsParams{} diff --git a/operations/discovery/get_api_endpoints_responses.go b/operations/discovery/get_api_endpoints_responses.go index c5d30d04..ed226ca5 100644 --- a/operations/discovery/get_api_endpoints_responses.go +++ b/operations/discovery/get_api_endpoints_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetAPIEndpointsOKCode is the HTTP code returned for type GetAPIEndpointsOK const GetAPIEndpointsOKCode int = 200 -/*GetAPIEndpointsOK Success +/* +GetAPIEndpointsOK Success swagger:response getApiEndpointsOK */ @@ -76,7 +76,8 @@ func (o *GetAPIEndpointsOK) WriteResponse(rw http.ResponseWriter, producer runti } } -/*GetAPIEndpointsDefault General Error +/* +GetAPIEndpointsDefault General Error swagger:response getApiEndpointsDefault */ @@ -85,7 +86,7 @@ type GetAPIEndpointsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -116,13 +117,13 @@ func (o *GetAPIEndpointsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get API endpoints default response -func (o *GetAPIEndpointsDefault) WithConfigurationVersion(configurationVersion int64) *GetAPIEndpointsDefault { +func (o *GetAPIEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetAPIEndpointsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get API endpoints default response -func (o *GetAPIEndpointsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetAPIEndpointsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -142,7 +143,7 @@ func (o *GetAPIEndpointsDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/discovery/get_api_endpoints_urlbuilder.go b/operations/discovery/get_api_endpoints_urlbuilder.go index 941738d9..8eb7185d 100644 --- a/operations/discovery/get_api_endpoints_urlbuilder.go +++ b/operations/discovery/get_api_endpoints_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetAPIEndpointsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/discovery/get_configuration_endpoints.go b/operations/discovery/get_configuration_endpoints.go index 4f0658f1..c42a7ea9 100644 --- a/operations/discovery/get_configuration_endpoints.go +++ b/operations/discovery/get_configuration_endpoints.go @@ -23,7 +23,7 @@ package discovery import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetConfigurationEndpointsHandlerFunc turns a function with the right signature into a get configuration endpoints handler @@ -44,12 +44,12 @@ func NewGetConfigurationEndpoints(ctx *middleware.Context, handler GetConfigurat return &GetConfigurationEndpoints{Context: ctx, Handler: handler} } -/*GetConfigurationEndpoints swagger:route GET /services/haproxy/configuration Discovery getConfigurationEndpoints +/* + GetConfigurationEndpoints swagger:route GET /services/haproxy/configuration Discovery getConfigurationEndpoints -Return list of HAProxy advanced configuration endpoints +# Return list of HAProxy advanced configuration endpoints Returns a list of endpoints to be used for advanced configuration of HAProxy objects. - */ type GetConfigurationEndpoints struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetConfigurationEndpoints struct { func (o *GetConfigurationEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetConfigurationEndpointsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetConfigurationEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Re } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/discovery/get_configuration_endpoints_parameters.go b/operations/discovery/get_configuration_endpoints_parameters.go index 0d4f8e93..2b0231fd 100644 --- a/operations/discovery/get_configuration_endpoints_parameters.go +++ b/operations/discovery/get_configuration_endpoints_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetConfigurationEndpointsParams creates a new GetConfigurationEndpointsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetConfigurationEndpointsParams() GetConfigurationEndpointsParams { return GetConfigurationEndpointsParams{} diff --git a/operations/discovery/get_configuration_endpoints_responses.go b/operations/discovery/get_configuration_endpoints_responses.go index 92ab04e6..be13edba 100644 --- a/operations/discovery/get_configuration_endpoints_responses.go +++ b/operations/discovery/get_configuration_endpoints_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetConfigurationEndpointsOKCode is the HTTP code returned for type GetConfigurationEndpointsOK const GetConfigurationEndpointsOKCode int = 200 -/*GetConfigurationEndpointsOK Success +/* +GetConfigurationEndpointsOK Success swagger:response getConfigurationEndpointsOK */ @@ -76,7 +76,8 @@ func (o *GetConfigurationEndpointsOK) WriteResponse(rw http.ResponseWriter, prod } } -/*GetConfigurationEndpointsDefault General Error +/* +GetConfigurationEndpointsDefault General Error swagger:response getConfigurationEndpointsDefault */ @@ -85,7 +86,7 @@ type GetConfigurationEndpointsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -116,13 +117,13 @@ func (o *GetConfigurationEndpointsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get configuration endpoints default response -func (o *GetConfigurationEndpointsDefault) WithConfigurationVersion(configurationVersion int64) *GetConfigurationEndpointsDefault { +func (o *GetConfigurationEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetConfigurationEndpointsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get configuration endpoints default response -func (o *GetConfigurationEndpointsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetConfigurationEndpointsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -142,7 +143,7 @@ func (o *GetConfigurationEndpointsDefault) WriteResponse(rw http.ResponseWriter, // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/discovery/get_configuration_endpoints_urlbuilder.go b/operations/discovery/get_configuration_endpoints_urlbuilder.go index d1306401..4791a8fc 100644 --- a/operations/discovery/get_configuration_endpoints_urlbuilder.go +++ b/operations/discovery/get_configuration_endpoints_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetConfigurationEndpointsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/discovery/get_haproxy_endpoints.go b/operations/discovery/get_haproxy_endpoints.go index e856aed6..390df601 100644 --- a/operations/discovery/get_haproxy_endpoints.go +++ b/operations/discovery/get_haproxy_endpoints.go @@ -23,7 +23,7 @@ package discovery import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetHaproxyEndpointsHandlerFunc turns a function with the right signature into a get haproxy endpoints handler @@ -44,12 +44,12 @@ func NewGetHaproxyEndpoints(ctx *middleware.Context, handler GetHaproxyEndpoints return &GetHaproxyEndpoints{Context: ctx, Handler: handler} } -/*GetHaproxyEndpoints swagger:route GET /services/haproxy Discovery getHaproxyEndpoints +/* + GetHaproxyEndpoints swagger:route GET /services/haproxy Discovery getHaproxyEndpoints -Return list of HAProxy related endpoints +# Return list of HAProxy related endpoints Returns a list of HAProxy related endpoints. - */ type GetHaproxyEndpoints struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetHaproxyEndpoints struct { func (o *GetHaproxyEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetHaproxyEndpointsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetHaproxyEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/discovery/get_haproxy_endpoints_parameters.go b/operations/discovery/get_haproxy_endpoints_parameters.go index 9558133e..0147ae1c 100644 --- a/operations/discovery/get_haproxy_endpoints_parameters.go +++ b/operations/discovery/get_haproxy_endpoints_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetHaproxyEndpointsParams creates a new GetHaproxyEndpointsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetHaproxyEndpointsParams() GetHaproxyEndpointsParams { return GetHaproxyEndpointsParams{} diff --git a/operations/discovery/get_haproxy_endpoints_responses.go b/operations/discovery/get_haproxy_endpoints_responses.go index 96ea398c..d499bb4c 100644 --- a/operations/discovery/get_haproxy_endpoints_responses.go +++ b/operations/discovery/get_haproxy_endpoints_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetHaproxyEndpointsOKCode is the HTTP code returned for type GetHaproxyEndpointsOK const GetHaproxyEndpointsOKCode int = 200 -/*GetHaproxyEndpointsOK Success +/* +GetHaproxyEndpointsOK Success swagger:response getHaproxyEndpointsOK */ @@ -76,7 +76,8 @@ func (o *GetHaproxyEndpointsOK) WriteResponse(rw http.ResponseWriter, producer r } } -/*GetHaproxyEndpointsDefault General Error +/* +GetHaproxyEndpointsDefault General Error swagger:response getHaproxyEndpointsDefault */ @@ -85,7 +86,7 @@ type GetHaproxyEndpointsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -116,13 +117,13 @@ func (o *GetHaproxyEndpointsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get haproxy endpoints default response -func (o *GetHaproxyEndpointsDefault) WithConfigurationVersion(configurationVersion int64) *GetHaproxyEndpointsDefault { +func (o *GetHaproxyEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetHaproxyEndpointsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get haproxy endpoints default response -func (o *GetHaproxyEndpointsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetHaproxyEndpointsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -142,7 +143,7 @@ func (o *GetHaproxyEndpointsDefault) WriteResponse(rw http.ResponseWriter, produ // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/discovery/get_haproxy_endpoints_urlbuilder.go b/operations/discovery/get_haproxy_endpoints_urlbuilder.go index 326070f9..1939b95a 100644 --- a/operations/discovery/get_haproxy_endpoints_urlbuilder.go +++ b/operations/discovery/get_haproxy_endpoints_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetHaproxyEndpointsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/discovery/get_runtime_endpoints.go b/operations/discovery/get_runtime_endpoints.go new file mode 100644 index 00000000..06d6abbf --- /dev/null +++ b/operations/discovery/get_runtime_endpoints.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRuntimeEndpointsHandlerFunc turns a function with the right signature into a get runtime endpoints handler +type GetRuntimeEndpointsHandlerFunc func(GetRuntimeEndpointsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRuntimeEndpointsHandlerFunc) Handle(params GetRuntimeEndpointsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRuntimeEndpointsHandler interface for that can handle valid get runtime endpoints params +type GetRuntimeEndpointsHandler interface { + Handle(GetRuntimeEndpointsParams, interface{}) middleware.Responder +} + +// NewGetRuntimeEndpoints creates a new http.Handler for the get runtime endpoints operation +func NewGetRuntimeEndpoints(ctx *middleware.Context, handler GetRuntimeEndpointsHandler) *GetRuntimeEndpoints { + return &GetRuntimeEndpoints{Context: ctx, Handler: handler} +} + +/* + GetRuntimeEndpoints swagger:route GET /services/haproxy/runtime Discovery getRuntimeEndpoints + +# Return list of HAProxy advanced runtime endpoints + +Returns a list of endpoints to be used for advanced runtime settings of HAProxy objects. +*/ +type GetRuntimeEndpoints struct { + Context *middleware.Context + Handler GetRuntimeEndpointsHandler +} + +func (o *GetRuntimeEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetRuntimeEndpointsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/discovery/get_runtime_endpoints_parameters.go b/operations/discovery/get_runtime_endpoints_parameters.go new file mode 100644 index 00000000..15baaed8 --- /dev/null +++ b/operations/discovery/get_runtime_endpoints_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetRuntimeEndpointsParams creates a new GetRuntimeEndpointsParams object +// +// There are no default values defined in the spec. +func NewGetRuntimeEndpointsParams() GetRuntimeEndpointsParams { + + return GetRuntimeEndpointsParams{} +} + +// GetRuntimeEndpointsParams contains all the bound params for the get runtime endpoints operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRuntimeEndpoints +type GetRuntimeEndpointsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRuntimeEndpointsParams() beforehand. +func (o *GetRuntimeEndpointsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/discovery/get_runtime_endpoints_responses.go b/operations/discovery/get_runtime_endpoints_responses.go new file mode 100644 index 00000000..1c2c95f5 --- /dev/null +++ b/operations/discovery/get_runtime_endpoints_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetRuntimeEndpointsOKCode is the HTTP code returned for type GetRuntimeEndpointsOK +const GetRuntimeEndpointsOKCode int = 200 + +/* +GetRuntimeEndpointsOK Success + +swagger:response getRuntimeEndpointsOK +*/ +type GetRuntimeEndpointsOK struct { + + /* + In: Body + */ + Payload models.Endpoints `json:"body,omitempty"` +} + +// NewGetRuntimeEndpointsOK creates GetRuntimeEndpointsOK with default headers values +func NewGetRuntimeEndpointsOK() *GetRuntimeEndpointsOK { + + return &GetRuntimeEndpointsOK{} +} + +// WithPayload adds the payload to the get runtime endpoints o k response +func (o *GetRuntimeEndpointsOK) WithPayload(payload models.Endpoints) *GetRuntimeEndpointsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime endpoints o k response +func (o *GetRuntimeEndpointsOK) SetPayload(payload models.Endpoints) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeEndpointsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Endpoints{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetRuntimeEndpointsDefault General Error + +swagger:response getRuntimeEndpointsDefault +*/ +type GetRuntimeEndpointsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRuntimeEndpointsDefault creates GetRuntimeEndpointsDefault with default headers values +func NewGetRuntimeEndpointsDefault(code int) *GetRuntimeEndpointsDefault { + if code <= 0 { + code = 500 + } + + return &GetRuntimeEndpointsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get runtime endpoints default response +func (o *GetRuntimeEndpointsDefault) WithStatusCode(code int) *GetRuntimeEndpointsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get runtime endpoints default response +func (o *GetRuntimeEndpointsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get runtime endpoints default response +func (o *GetRuntimeEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetRuntimeEndpointsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get runtime endpoints default response +func (o *GetRuntimeEndpointsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get runtime endpoints default response +func (o *GetRuntimeEndpointsDefault) WithPayload(payload *models.Error) *GetRuntimeEndpointsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime endpoints default response +func (o *GetRuntimeEndpointsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeEndpointsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/discovery/get_runtime_endpoints_urlbuilder.go b/operations/discovery/get_runtime_endpoints_urlbuilder.go new file mode 100644 index 00000000..e5f0f245 --- /dev/null +++ b/operations/discovery/get_runtime_endpoints_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetRuntimeEndpointsURL generates an URL for the get runtime endpoints operation +type GetRuntimeEndpointsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRuntimeEndpointsURL) WithBasePath(bp string) *GetRuntimeEndpointsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRuntimeEndpointsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRuntimeEndpointsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRuntimeEndpointsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRuntimeEndpointsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRuntimeEndpointsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRuntimeEndpointsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRuntimeEndpointsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRuntimeEndpointsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/discovery/get_services_endpoints.go b/operations/discovery/get_services_endpoints.go index 967eeb7b..cbd8f1b9 100644 --- a/operations/discovery/get_services_endpoints.go +++ b/operations/discovery/get_services_endpoints.go @@ -23,7 +23,7 @@ package discovery import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetServicesEndpointsHandlerFunc turns a function with the right signature into a get services endpoints handler @@ -44,12 +44,12 @@ func NewGetServicesEndpoints(ctx *middleware.Context, handler GetServicesEndpoin return &GetServicesEndpoints{Context: ctx, Handler: handler} } -/*GetServicesEndpoints swagger:route GET /services Discovery getServicesEndpoints +/* + GetServicesEndpoints swagger:route GET /services Discovery getServicesEndpoints -Return list of service endpoints +# Return list of service endpoints Returns a list of API managed services endpoints. - */ type GetServicesEndpoints struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetServicesEndpoints struct { func (o *GetServicesEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetServicesEndpointsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetServicesEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/discovery/get_services_endpoints_parameters.go b/operations/discovery/get_services_endpoints_parameters.go index 8cd540a0..8ac7f3ea 100644 --- a/operations/discovery/get_services_endpoints_parameters.go +++ b/operations/discovery/get_services_endpoints_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetServicesEndpointsParams creates a new GetServicesEndpointsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetServicesEndpointsParams() GetServicesEndpointsParams { return GetServicesEndpointsParams{} diff --git a/operations/discovery/get_services_endpoints_responses.go b/operations/discovery/get_services_endpoints_responses.go index d1d2a064..e3f06036 100644 --- a/operations/discovery/get_services_endpoints_responses.go +++ b/operations/discovery/get_services_endpoints_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetServicesEndpointsOKCode is the HTTP code returned for type GetServicesEndpointsOK const GetServicesEndpointsOKCode int = 200 -/*GetServicesEndpointsOK Success +/* +GetServicesEndpointsOK Success swagger:response getServicesEndpointsOK */ @@ -76,7 +76,8 @@ func (o *GetServicesEndpointsOK) WriteResponse(rw http.ResponseWriter, producer } } -/*GetServicesEndpointsDefault General Error +/* +GetServicesEndpointsDefault General Error swagger:response getServicesEndpointsDefault */ @@ -85,7 +86,7 @@ type GetServicesEndpointsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -116,13 +117,13 @@ func (o *GetServicesEndpointsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get services endpoints default response -func (o *GetServicesEndpointsDefault) WithConfigurationVersion(configurationVersion int64) *GetServicesEndpointsDefault { +func (o *GetServicesEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetServicesEndpointsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get services endpoints default response -func (o *GetServicesEndpointsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetServicesEndpointsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -142,7 +143,7 @@ func (o *GetServicesEndpointsDefault) WriteResponse(rw http.ResponseWriter, prod // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/discovery/get_services_endpoints_urlbuilder.go b/operations/discovery/get_services_endpoints_urlbuilder.go index 97635ebd..b9066f9a 100644 --- a/operations/discovery/get_services_endpoints_urlbuilder.go +++ b/operations/discovery/get_services_endpoints_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetServicesEndpointsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/discovery/get_spoe_endpoints.go b/operations/discovery/get_spoe_endpoints.go new file mode 100644 index 00000000..3164494e --- /dev/null +++ b/operations/discovery/get_spoe_endpoints.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSpoeEndpointsHandlerFunc turns a function with the right signature into a get spoe endpoints handler +type GetSpoeEndpointsHandlerFunc func(GetSpoeEndpointsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSpoeEndpointsHandlerFunc) Handle(params GetSpoeEndpointsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSpoeEndpointsHandler interface for that can handle valid get spoe endpoints params +type GetSpoeEndpointsHandler interface { + Handle(GetSpoeEndpointsParams, interface{}) middleware.Responder +} + +// NewGetSpoeEndpoints creates a new http.Handler for the get spoe endpoints operation +func NewGetSpoeEndpoints(ctx *middleware.Context, handler GetSpoeEndpointsHandler) *GetSpoeEndpoints { + return &GetSpoeEndpoints{Context: ctx, Handler: handler} +} + +/* + GetSpoeEndpoints swagger:route GET /services/haproxy/spoe Discovery getSpoeEndpoints + +# Return list of HAProxy SPOE endpoints + +Returns a list of endpoints to be used for SPOE settings of HAProxy. +*/ +type GetSpoeEndpoints struct { + Context *middleware.Context + Handler GetSpoeEndpointsHandler +} + +func (o *GetSpoeEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSpoeEndpointsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/discovery/get_spoe_endpoints_parameters.go b/operations/discovery/get_spoe_endpoints_parameters.go new file mode 100644 index 00000000..85fb9fe6 --- /dev/null +++ b/operations/discovery/get_spoe_endpoints_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetSpoeEndpointsParams creates a new GetSpoeEndpointsParams object +// +// There are no default values defined in the spec. +func NewGetSpoeEndpointsParams() GetSpoeEndpointsParams { + + return GetSpoeEndpointsParams{} +} + +// GetSpoeEndpointsParams contains all the bound params for the get spoe endpoints operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSpoeEndpoints +type GetSpoeEndpointsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSpoeEndpointsParams() beforehand. +func (o *GetSpoeEndpointsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/discovery/get_spoe_endpoints_responses.go b/operations/discovery/get_spoe_endpoints_responses.go new file mode 100644 index 00000000..93249c5a --- /dev/null +++ b/operations/discovery/get_spoe_endpoints_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSpoeEndpointsOKCode is the HTTP code returned for type GetSpoeEndpointsOK +const GetSpoeEndpointsOKCode int = 200 + +/* +GetSpoeEndpointsOK Success + +swagger:response getSpoeEndpointsOK +*/ +type GetSpoeEndpointsOK struct { + + /* + In: Body + */ + Payload models.Endpoints `json:"body,omitempty"` +} + +// NewGetSpoeEndpointsOK creates GetSpoeEndpointsOK with default headers values +func NewGetSpoeEndpointsOK() *GetSpoeEndpointsOK { + + return &GetSpoeEndpointsOK{} +} + +// WithPayload adds the payload to the get spoe endpoints o k response +func (o *GetSpoeEndpointsOK) WithPayload(payload models.Endpoints) *GetSpoeEndpointsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe endpoints o k response +func (o *GetSpoeEndpointsOK) SetPayload(payload models.Endpoints) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeEndpointsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Endpoints{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetSpoeEndpointsDefault General Error + +swagger:response getSpoeEndpointsDefault +*/ +type GetSpoeEndpointsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeEndpointsDefault creates GetSpoeEndpointsDefault with default headers values +func NewGetSpoeEndpointsDefault(code int) *GetSpoeEndpointsDefault { + if code <= 0 { + code = 500 + } + + return &GetSpoeEndpointsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get spoe endpoints default response +func (o *GetSpoeEndpointsDefault) WithStatusCode(code int) *GetSpoeEndpointsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get spoe endpoints default response +func (o *GetSpoeEndpointsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe endpoints default response +func (o *GetSpoeEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetSpoeEndpointsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe endpoints default response +func (o *GetSpoeEndpointsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe endpoints default response +func (o *GetSpoeEndpointsDefault) WithPayload(payload *models.Error) *GetSpoeEndpointsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe endpoints default response +func (o *GetSpoeEndpointsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeEndpointsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/discovery/get_spoe_endpoints_urlbuilder.go b/operations/discovery/get_spoe_endpoints_urlbuilder.go new file mode 100644 index 00000000..5f805734 --- /dev/null +++ b/operations/discovery/get_spoe_endpoints_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetSpoeEndpointsURL generates an URL for the get spoe endpoints operation +type GetSpoeEndpointsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeEndpointsURL) WithBasePath(bp string) *GetSpoeEndpointsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeEndpointsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSpoeEndpointsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSpoeEndpointsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSpoeEndpointsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSpoeEndpointsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSpoeEndpointsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSpoeEndpointsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSpoeEndpointsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/discovery/get_stats_endpoints.go b/operations/discovery/get_stats_endpoints.go index 2f00e10d..4751b343 100644 --- a/operations/discovery/get_stats_endpoints.go +++ b/operations/discovery/get_stats_endpoints.go @@ -23,7 +23,7 @@ package discovery import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetStatsEndpointsHandlerFunc turns a function with the right signature into a get stats endpoints handler @@ -44,12 +44,12 @@ func NewGetStatsEndpoints(ctx *middleware.Context, handler GetStatsEndpointsHand return &GetStatsEndpoints{Context: ctx, Handler: handler} } -/*GetStatsEndpoints swagger:route GET /services/haproxy/stats Discovery getStatsEndpoints +/* + GetStatsEndpoints swagger:route GET /services/haproxy/stats Discovery getStatsEndpoints -Return list of HAProxy stats endpoints +# Return list of HAProxy stats endpoints Returns a list of HAProxy stats endpoints. - */ type GetStatsEndpoints struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetStatsEndpoints struct { func (o *GetStatsEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetStatsEndpointsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetStatsEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/discovery/get_stats_endpoints_parameters.go b/operations/discovery/get_stats_endpoints_parameters.go index ffb5d2d7..d0d1a583 100644 --- a/operations/discovery/get_stats_endpoints_parameters.go +++ b/operations/discovery/get_stats_endpoints_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetStatsEndpointsParams creates a new GetStatsEndpointsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetStatsEndpointsParams() GetStatsEndpointsParams { return GetStatsEndpointsParams{} diff --git a/operations/discovery/get_stats_endpoints_responses.go b/operations/discovery/get_stats_endpoints_responses.go index 87c10b81..2a6c2cf2 100644 --- a/operations/discovery/get_stats_endpoints_responses.go +++ b/operations/discovery/get_stats_endpoints_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetStatsEndpointsOKCode is the HTTP code returned for type GetStatsEndpointsOK const GetStatsEndpointsOKCode int = 200 -/*GetStatsEndpointsOK Success +/* +GetStatsEndpointsOK Success swagger:response getStatsEndpointsOK */ @@ -76,7 +76,8 @@ func (o *GetStatsEndpointsOK) WriteResponse(rw http.ResponseWriter, producer run } } -/*GetStatsEndpointsDefault General Error +/* +GetStatsEndpointsDefault General Error swagger:response getStatsEndpointsDefault */ @@ -85,7 +86,7 @@ type GetStatsEndpointsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -116,13 +117,13 @@ func (o *GetStatsEndpointsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get stats endpoints default response -func (o *GetStatsEndpointsDefault) WithConfigurationVersion(configurationVersion int64) *GetStatsEndpointsDefault { +func (o *GetStatsEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetStatsEndpointsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get stats endpoints default response -func (o *GetStatsEndpointsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetStatsEndpointsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -142,7 +143,7 @@ func (o *GetStatsEndpointsDefault) WriteResponse(rw http.ResponseWriter, produce // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/discovery/get_stats_endpoints_urlbuilder.go b/operations/discovery/get_stats_endpoints_urlbuilder.go index cb9b93cf..0cc2e4b8 100644 --- a/operations/discovery/get_stats_endpoints_urlbuilder.go +++ b/operations/discovery/get_stats_endpoints_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetStatsEndpointsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/discovery/get_storage_endpoints.go b/operations/discovery/get_storage_endpoints.go new file mode 100644 index 00000000..2ce054a7 --- /dev/null +++ b/operations/discovery/get_storage_endpoints.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetStorageEndpointsHandlerFunc turns a function with the right signature into a get storage endpoints handler +type GetStorageEndpointsHandlerFunc func(GetStorageEndpointsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetStorageEndpointsHandlerFunc) Handle(params GetStorageEndpointsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetStorageEndpointsHandler interface for that can handle valid get storage endpoints params +type GetStorageEndpointsHandler interface { + Handle(GetStorageEndpointsParams, interface{}) middleware.Responder +} + +// NewGetStorageEndpoints creates a new http.Handler for the get storage endpoints operation +func NewGetStorageEndpoints(ctx *middleware.Context, handler GetStorageEndpointsHandler) *GetStorageEndpoints { + return &GetStorageEndpoints{Context: ctx, Handler: handler} +} + +/* + GetStorageEndpoints swagger:route GET /services/haproxy/storage Discovery getStorageEndpoints + +# Return list of HAProxy storage endpoints + +Returns a list of endpoints that use HAProxy storage for persistency, e.g. maps, ssl certificates... +*/ +type GetStorageEndpoints struct { + Context *middleware.Context + Handler GetStorageEndpointsHandler +} + +func (o *GetStorageEndpoints) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetStorageEndpointsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/discovery/get_storage_endpoints_parameters.go b/operations/discovery/get_storage_endpoints_parameters.go new file mode 100644 index 00000000..b021624a --- /dev/null +++ b/operations/discovery/get_storage_endpoints_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetStorageEndpointsParams creates a new GetStorageEndpointsParams object +// +// There are no default values defined in the spec. +func NewGetStorageEndpointsParams() GetStorageEndpointsParams { + + return GetStorageEndpointsParams{} +} + +// GetStorageEndpointsParams contains all the bound params for the get storage endpoints operation +// typically these are obtained from a http.Request +// +// swagger:parameters getStorageEndpoints +type GetStorageEndpointsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetStorageEndpointsParams() beforehand. +func (o *GetStorageEndpointsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/discovery/get_storage_endpoints_responses.go b/operations/discovery/get_storage_endpoints_responses.go new file mode 100644 index 00000000..ca13cf00 --- /dev/null +++ b/operations/discovery/get_storage_endpoints_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetStorageEndpointsOKCode is the HTTP code returned for type GetStorageEndpointsOK +const GetStorageEndpointsOKCode int = 200 + +/* +GetStorageEndpointsOK Success + +swagger:response getStorageEndpointsOK +*/ +type GetStorageEndpointsOK struct { + + /* + In: Body + */ + Payload models.Endpoints `json:"body,omitempty"` +} + +// NewGetStorageEndpointsOK creates GetStorageEndpointsOK with default headers values +func NewGetStorageEndpointsOK() *GetStorageEndpointsOK { + + return &GetStorageEndpointsOK{} +} + +// WithPayload adds the payload to the get storage endpoints o k response +func (o *GetStorageEndpointsOK) WithPayload(payload models.Endpoints) *GetStorageEndpointsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get storage endpoints o k response +func (o *GetStorageEndpointsOK) SetPayload(payload models.Endpoints) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStorageEndpointsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Endpoints{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetStorageEndpointsDefault General Error + +swagger:response getStorageEndpointsDefault +*/ +type GetStorageEndpointsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetStorageEndpointsDefault creates GetStorageEndpointsDefault with default headers values +func NewGetStorageEndpointsDefault(code int) *GetStorageEndpointsDefault { + if code <= 0 { + code = 500 + } + + return &GetStorageEndpointsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get storage endpoints default response +func (o *GetStorageEndpointsDefault) WithStatusCode(code int) *GetStorageEndpointsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get storage endpoints default response +func (o *GetStorageEndpointsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get storage endpoints default response +func (o *GetStorageEndpointsDefault) WithConfigurationVersion(configurationVersion string) *GetStorageEndpointsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get storage endpoints default response +func (o *GetStorageEndpointsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get storage endpoints default response +func (o *GetStorageEndpointsDefault) WithPayload(payload *models.Error) *GetStorageEndpointsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get storage endpoints default response +func (o *GetStorageEndpointsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStorageEndpointsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/discovery/get_storage_endpoints_urlbuilder.go b/operations/discovery/get_storage_endpoints_urlbuilder.go new file mode 100644 index 00000000..8112dd05 --- /dev/null +++ b/operations/discovery/get_storage_endpoints_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetStorageEndpointsURL generates an URL for the get storage endpoints operation +type GetStorageEndpointsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStorageEndpointsURL) WithBasePath(bp string) *GetStorageEndpointsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStorageEndpointsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetStorageEndpointsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetStorageEndpointsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetStorageEndpointsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetStorageEndpointsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetStorageEndpointsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetStorageEndpointsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetStorageEndpointsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/fcgi_app/create_fcgi_app.go b/operations/fcgi_app/create_fcgi_app.go new file mode 100644 index 00000000..f0517a80 --- /dev/null +++ b/operations/fcgi_app/create_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateFCGIAppHandlerFunc turns a function with the right signature into a create FCGI app handler +type CreateFCGIAppHandlerFunc func(CreateFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateFCGIAppHandlerFunc) Handle(params CreateFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateFCGIAppHandler interface for that can handle valid create FCGI app params +type CreateFCGIAppHandler interface { + Handle(CreateFCGIAppParams, interface{}) middleware.Responder +} + +// NewCreateFCGIApp creates a new http.Handler for the create FCGI app operation +func NewCreateFCGIApp(ctx *middleware.Context, handler CreateFCGIAppHandler) *CreateFCGIApp { + return &CreateFCGIApp{Context: ctx, Handler: handler} +} + +/* + CreateFCGIApp swagger:route POST /services/haproxy/configuration/fcgi_apps FCGIApp createFcgiApp + +# Add an FCGI app + +Adds a new FCGI application to the configuration file. +*/ +type CreateFCGIApp struct { + Context *middleware.Context + Handler CreateFCGIAppHandler +} + +func (o *CreateFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/fcgi_app/create_fcgi_app_parameters.go b/operations/fcgi_app/create_fcgi_app_parameters.go new file mode 100644 index 00000000..5147e6a4 --- /dev/null +++ b/operations/fcgi_app/create_fcgi_app_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateFCGIAppParams creates a new CreateFCGIAppParams object +// with the default values initialized. +func NewCreateFCGIAppParams() CreateFCGIAppParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreateFCGIAppParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreateFCGIAppParams contains all the bound params for the create FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters createFCGIApp +type CreateFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.FCGIApp + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateFCGIAppParams() beforehand. +func (o *CreateFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.FCGIApp + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateFCGIAppParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateFCGIAppParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateFCGIAppParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/fcgi_app/create_fcgi_app_responses.go b/operations/fcgi_app/create_fcgi_app_responses.go new file mode 100644 index 00000000..6ad3f307 --- /dev/null +++ b/operations/fcgi_app/create_fcgi_app_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateFCGIAppCreatedCode is the HTTP code returned for type CreateFCGIAppCreated +const CreateFCGIAppCreatedCode int = 201 + +/* +CreateFCGIAppCreated Application created + +swagger:response createFcgiAppCreated +*/ +type CreateFCGIAppCreated struct { + + /* + In: Body + */ + Payload *models.FCGIApp `json:"body,omitempty"` +} + +// NewCreateFCGIAppCreated creates CreateFCGIAppCreated with default headers values +func NewCreateFCGIAppCreated() *CreateFCGIAppCreated { + + return &CreateFCGIAppCreated{} +} + +// WithPayload adds the payload to the create Fcgi app created response +func (o *CreateFCGIAppCreated) WithPayload(payload *models.FCGIApp) *CreateFCGIAppCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Fcgi app created response +func (o *CreateFCGIAppCreated) SetPayload(payload *models.FCGIApp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFCGIAppCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFCGIAppAcceptedCode is the HTTP code returned for type CreateFCGIAppAccepted +const CreateFCGIAppAcceptedCode int = 202 + +/* +CreateFCGIAppAccepted Configuration change accepted and reload requested + +swagger:response createFcgiAppAccepted +*/ +type CreateFCGIAppAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.FCGIApp `json:"body,omitempty"` +} + +// NewCreateFCGIAppAccepted creates CreateFCGIAppAccepted with default headers values +func NewCreateFCGIAppAccepted() *CreateFCGIAppAccepted { + + return &CreateFCGIAppAccepted{} +} + +// WithReloadID adds the reloadId to the create Fcgi app accepted response +func (o *CreateFCGIAppAccepted) WithReloadID(reloadID string) *CreateFCGIAppAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Fcgi app accepted response +func (o *CreateFCGIAppAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Fcgi app accepted response +func (o *CreateFCGIAppAccepted) WithPayload(payload *models.FCGIApp) *CreateFCGIAppAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Fcgi app accepted response +func (o *CreateFCGIAppAccepted) SetPayload(payload *models.FCGIApp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFCGIAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFCGIAppBadRequestCode is the HTTP code returned for type CreateFCGIAppBadRequest +const CreateFCGIAppBadRequestCode int = 400 + +/* +CreateFCGIAppBadRequest Bad request + +swagger:response createFcgiAppBadRequest +*/ +type CreateFCGIAppBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFCGIAppBadRequest creates CreateFCGIAppBadRequest with default headers values +func NewCreateFCGIAppBadRequest() *CreateFCGIAppBadRequest { + + return &CreateFCGIAppBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Fcgi app bad request response +func (o *CreateFCGIAppBadRequest) WithConfigurationVersion(configurationVersion string) *CreateFCGIAppBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Fcgi app bad request response +func (o *CreateFCGIAppBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Fcgi app bad request response +func (o *CreateFCGIAppBadRequest) WithPayload(payload *models.Error) *CreateFCGIAppBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Fcgi app bad request response +func (o *CreateFCGIAppBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFCGIAppBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFCGIAppConflictCode is the HTTP code returned for type CreateFCGIAppConflict +const CreateFCGIAppConflictCode int = 409 + +/* +CreateFCGIAppConflict The specified resource already exists + +swagger:response createFcgiAppConflict +*/ +type CreateFCGIAppConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFCGIAppConflict creates CreateFCGIAppConflict with default headers values +func NewCreateFCGIAppConflict() *CreateFCGIAppConflict { + + return &CreateFCGIAppConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Fcgi app conflict response +func (o *CreateFCGIAppConflict) WithConfigurationVersion(configurationVersion string) *CreateFCGIAppConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Fcgi app conflict response +func (o *CreateFCGIAppConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Fcgi app conflict response +func (o *CreateFCGIAppConflict) WithPayload(payload *models.Error) *CreateFCGIAppConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Fcgi app conflict response +func (o *CreateFCGIAppConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFCGIAppConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateFCGIAppDefault General Error + +swagger:response createFcgiAppDefault +*/ +type CreateFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFCGIAppDefault creates CreateFCGIAppDefault with default headers values +func NewCreateFCGIAppDefault(code int) *CreateFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &CreateFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create FCGI app default response +func (o *CreateFCGIAppDefault) WithStatusCode(code int) *CreateFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create FCGI app default response +func (o *CreateFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create FCGI app default response +func (o *CreateFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *CreateFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create FCGI app default response +func (o *CreateFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create FCGI app default response +func (o *CreateFCGIAppDefault) WithPayload(payload *models.Error) *CreateFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create FCGI app default response +func (o *CreateFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/fcgi_app/create_fcgi_app_urlbuilder.go b/operations/fcgi_app/create_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..bdf719eb --- /dev/null +++ b/operations/fcgi_app/create_fcgi_app_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateFCGIAppURL generates an URL for the create FCGI app operation +type CreateFCGIAppURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateFCGIAppURL) WithBasePath(bp string) *CreateFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/fcgi_app/delete_fcgi_app.go b/operations/fcgi_app/delete_fcgi_app.go new file mode 100644 index 00000000..40f54672 --- /dev/null +++ b/operations/fcgi_app/delete_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteFCGIAppHandlerFunc turns a function with the right signature into a delete FCGI app handler +type DeleteFCGIAppHandlerFunc func(DeleteFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteFCGIAppHandlerFunc) Handle(params DeleteFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteFCGIAppHandler interface for that can handle valid delete FCGI app params +type DeleteFCGIAppHandler interface { + Handle(DeleteFCGIAppParams, interface{}) middleware.Responder +} + +// NewDeleteFCGIApp creates a new http.Handler for the delete FCGI app operation +func NewDeleteFCGIApp(ctx *middleware.Context, handler DeleteFCGIAppHandler) *DeleteFCGIApp { + return &DeleteFCGIApp{Context: ctx, Handler: handler} +} + +/* + DeleteFCGIApp swagger:route DELETE /services/haproxy/configuration/fcgi_apps/{name} FCGIApp deleteFcgiApp + +# Delete an FCGI app + +Deletes an FCGI application from the configuration by its name. +*/ +type DeleteFCGIApp struct { + Context *middleware.Context + Handler DeleteFCGIAppHandler +} + +func (o *DeleteFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/fcgi_app/delete_fcgi_app_parameters.go b/operations/fcgi_app/delete_fcgi_app_parameters.go new file mode 100644 index 00000000..035598f3 --- /dev/null +++ b/operations/fcgi_app/delete_fcgi_app_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteFCGIAppParams creates a new DeleteFCGIAppParams object +// with the default values initialized. +func NewDeleteFCGIAppParams() DeleteFCGIAppParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteFCGIAppParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteFCGIAppParams contains all the bound params for the delete FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteFCGIApp +type DeleteFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Application name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteFCGIAppParams() beforehand. +func (o *DeleteFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteFCGIAppParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteFCGIAppParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteFCGIAppParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/fcgi_app/delete_fcgi_app_responses.go b/operations/fcgi_app/delete_fcgi_app_responses.go new file mode 100644 index 00000000..ead0a628 --- /dev/null +++ b/operations/fcgi_app/delete_fcgi_app_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteFCGIAppAcceptedCode is the HTTP code returned for type DeleteFCGIAppAccepted +const DeleteFCGIAppAcceptedCode int = 202 + +/* +DeleteFCGIAppAccepted Configuration change accepted and reload requested + +swagger:response deleteFcgiAppAccepted +*/ +type DeleteFCGIAppAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteFCGIAppAccepted creates DeleteFCGIAppAccepted with default headers values +func NewDeleteFCGIAppAccepted() *DeleteFCGIAppAccepted { + + return &DeleteFCGIAppAccepted{} +} + +// WithReloadID adds the reloadId to the delete Fcgi app accepted response +func (o *DeleteFCGIAppAccepted) WithReloadID(reloadID string) *DeleteFCGIAppAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Fcgi app accepted response +func (o *DeleteFCGIAppAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteFCGIAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteFCGIAppNoContentCode is the HTTP code returned for type DeleteFCGIAppNoContent +const DeleteFCGIAppNoContentCode int = 204 + +/* +DeleteFCGIAppNoContent Application deleted + +swagger:response deleteFcgiAppNoContent +*/ +type DeleteFCGIAppNoContent struct { +} + +// NewDeleteFCGIAppNoContent creates DeleteFCGIAppNoContent with default headers values +func NewDeleteFCGIAppNoContent() *DeleteFCGIAppNoContent { + + return &DeleteFCGIAppNoContent{} +} + +// WriteResponse to the client +func (o *DeleteFCGIAppNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteFCGIAppNotFoundCode is the HTTP code returned for type DeleteFCGIAppNotFound +const DeleteFCGIAppNotFoundCode int = 404 + +/* +DeleteFCGIAppNotFound The specified resource was not found + +swagger:response deleteFcgiAppNotFound +*/ +type DeleteFCGIAppNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteFCGIAppNotFound creates DeleteFCGIAppNotFound with default headers values +func NewDeleteFCGIAppNotFound() *DeleteFCGIAppNotFound { + + return &DeleteFCGIAppNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Fcgi app not found response +func (o *DeleteFCGIAppNotFound) WithConfigurationVersion(configurationVersion string) *DeleteFCGIAppNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Fcgi app not found response +func (o *DeleteFCGIAppNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Fcgi app not found response +func (o *DeleteFCGIAppNotFound) WithPayload(payload *models.Error) *DeleteFCGIAppNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Fcgi app not found response +func (o *DeleteFCGIAppNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteFCGIAppNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteFCGIAppDefault General Error + +swagger:response deleteFcgiAppDefault +*/ +type DeleteFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteFCGIAppDefault creates DeleteFCGIAppDefault with default headers values +func NewDeleteFCGIAppDefault(code int) *DeleteFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &DeleteFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete FCGI app default response +func (o *DeleteFCGIAppDefault) WithStatusCode(code int) *DeleteFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete FCGI app default response +func (o *DeleteFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete FCGI app default response +func (o *DeleteFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *DeleteFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete FCGI app default response +func (o *DeleteFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete FCGI app default response +func (o *DeleteFCGIAppDefault) WithPayload(payload *models.Error) *DeleteFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete FCGI app default response +func (o *DeleteFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/fcgi_app/delete_fcgi_app_urlbuilder.go b/operations/fcgi_app/delete_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..1ac44748 --- /dev/null +++ b/operations/fcgi_app/delete_fcgi_app_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteFCGIAppURL generates an URL for the delete FCGI app operation +type DeleteFCGIAppURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteFCGIAppURL) WithBasePath(bp string) *DeleteFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/fcgi_app/get_fcgi_app.go b/operations/fcgi_app/get_fcgi_app.go new file mode 100644 index 00000000..0c0a4101 --- /dev/null +++ b/operations/fcgi_app/get_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetFCGIAppHandlerFunc turns a function with the right signature into a get FCGI app handler +type GetFCGIAppHandlerFunc func(GetFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetFCGIAppHandlerFunc) Handle(params GetFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetFCGIAppHandler interface for that can handle valid get FCGI app params +type GetFCGIAppHandler interface { + Handle(GetFCGIAppParams, interface{}) middleware.Responder +} + +// NewGetFCGIApp creates a new http.Handler for the get FCGI app operation +func NewGetFCGIApp(ctx *middleware.Context, handler GetFCGIAppHandler) *GetFCGIApp { + return &GetFCGIApp{Context: ctx, Handler: handler} +} + +/* + GetFCGIApp swagger:route GET /services/haproxy/configuration/fcgi_apps/{name} FCGIApp getFcgiApp + +# Return a FCGI app + +Returns one FCGI application configuration by its name. +*/ +type GetFCGIApp struct { + Context *middleware.Context + Handler GetFCGIAppHandler +} + +func (o *GetFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/fcgi_app/get_fcgi_app_parameters.go b/operations/fcgi_app/get_fcgi_app_parameters.go new file mode 100644 index 00000000..e04470f3 --- /dev/null +++ b/operations/fcgi_app/get_fcgi_app_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetFCGIAppParams creates a new GetFCGIAppParams object +// with the default values initialized. +func NewGetFCGIAppParams() GetFCGIAppParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetFCGIAppParams{ + FullSection: &fullSectionDefault, + } +} + +// GetFCGIAppParams contains all the bound params for the get FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters getFCGIApp +type GetFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Application name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetFCGIAppParams() beforehand. +func (o *GetFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetFCGIAppParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetFCGIAppParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/fcgi_app/get_fcgi_app_responses.go b/operations/fcgi_app/get_fcgi_app_responses.go new file mode 100644 index 00000000..ff276a56 --- /dev/null +++ b/operations/fcgi_app/get_fcgi_app_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetFCGIAppOKCode is the HTTP code returned for type GetFCGIAppOK +const GetFCGIAppOKCode int = 200 + +/* +GetFCGIAppOK Successful operation + +swagger:response getFcgiAppOK +*/ +type GetFCGIAppOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.FCGIApp `json:"body,omitempty"` +} + +// NewGetFCGIAppOK creates GetFCGIAppOK with default headers values +func NewGetFCGIAppOK() *GetFCGIAppOK { + + return &GetFCGIAppOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Fcgi app o k response +func (o *GetFCGIAppOK) WithConfigurationVersion(configurationVersion string) *GetFCGIAppOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Fcgi app o k response +func (o *GetFCGIAppOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Fcgi app o k response +func (o *GetFCGIAppOK) WithPayload(payload *models.FCGIApp) *GetFCGIAppOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Fcgi app o k response +func (o *GetFCGIAppOK) SetPayload(payload *models.FCGIApp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFCGIAppOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetFCGIAppNotFoundCode is the HTTP code returned for type GetFCGIAppNotFound +const GetFCGIAppNotFoundCode int = 404 + +/* +GetFCGIAppNotFound The specified resource was not found + +swagger:response getFcgiAppNotFound +*/ +type GetFCGIAppNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetFCGIAppNotFound creates GetFCGIAppNotFound with default headers values +func NewGetFCGIAppNotFound() *GetFCGIAppNotFound { + + return &GetFCGIAppNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Fcgi app not found response +func (o *GetFCGIAppNotFound) WithConfigurationVersion(configurationVersion string) *GetFCGIAppNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Fcgi app not found response +func (o *GetFCGIAppNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Fcgi app not found response +func (o *GetFCGIAppNotFound) WithPayload(payload *models.Error) *GetFCGIAppNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Fcgi app not found response +func (o *GetFCGIAppNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFCGIAppNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetFCGIAppDefault General Error + +swagger:response getFcgiAppDefault +*/ +type GetFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetFCGIAppDefault creates GetFCGIAppDefault with default headers values +func NewGetFCGIAppDefault(code int) *GetFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &GetFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get FCGI app default response +func (o *GetFCGIAppDefault) WithStatusCode(code int) *GetFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get FCGI app default response +func (o *GetFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get FCGI app default response +func (o *GetFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *GetFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get FCGI app default response +func (o *GetFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get FCGI app default response +func (o *GetFCGIAppDefault) WithPayload(payload *models.Error) *GetFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get FCGI app default response +func (o *GetFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/fcgi_app/get_fcgi_app_urlbuilder.go b/operations/fcgi_app/get_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..c5eef7a5 --- /dev/null +++ b/operations/fcgi_app/get_fcgi_app_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetFCGIAppURL generates an URL for the get FCGI app operation +type GetFCGIAppURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFCGIAppURL) WithBasePath(bp string) *GetFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/fcgi_app/get_fcgi_apps.go b/operations/fcgi_app/get_fcgi_apps.go new file mode 100644 index 00000000..ada779c4 --- /dev/null +++ b/operations/fcgi_app/get_fcgi_apps.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetFCGIAppsHandlerFunc turns a function with the right signature into a get FCGI apps handler +type GetFCGIAppsHandlerFunc func(GetFCGIAppsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetFCGIAppsHandlerFunc) Handle(params GetFCGIAppsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetFCGIAppsHandler interface for that can handle valid get FCGI apps params +type GetFCGIAppsHandler interface { + Handle(GetFCGIAppsParams, interface{}) middleware.Responder +} + +// NewGetFCGIApps creates a new http.Handler for the get FCGI apps operation +func NewGetFCGIApps(ctx *middleware.Context, handler GetFCGIAppsHandler) *GetFCGIApps { + return &GetFCGIApps{Context: ctx, Handler: handler} +} + +/* + GetFCGIApps swagger:route GET /services/haproxy/configuration/fcgi_apps FCGIApp getFcgiApps + +# Return an array of FCGI apps + +Returns an array of all configured FCGI applications. +*/ +type GetFCGIApps struct { + Context *middleware.Context + Handler GetFCGIAppsHandler +} + +func (o *GetFCGIApps) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetFCGIAppsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/fcgi_app/get_fcgi_apps_parameters.go b/operations/fcgi_app/get_fcgi_apps_parameters.go new file mode 100644 index 00000000..f3f88f39 --- /dev/null +++ b/operations/fcgi_app/get_fcgi_apps_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetFCGIAppsParams creates a new GetFCGIAppsParams object +// with the default values initialized. +func NewGetFCGIAppsParams() GetFCGIAppsParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetFCGIAppsParams{ + FullSection: &fullSectionDefault, + } +} + +// GetFCGIAppsParams contains all the bound params for the get FCGI apps operation +// typically these are obtained from a http.Request +// +// swagger:parameters getFCGIApps +type GetFCGIAppsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetFCGIAppsParams() beforehand. +func (o *GetFCGIAppsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetFCGIAppsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetFCGIAppsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetFCGIAppsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/fcgi_app/get_fcgi_apps_responses.go b/operations/fcgi_app/get_fcgi_apps_responses.go new file mode 100644 index 00000000..18ed9ac2 --- /dev/null +++ b/operations/fcgi_app/get_fcgi_apps_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetFCGIAppsOKCode is the HTTP code returned for type GetFCGIAppsOK +const GetFCGIAppsOKCode int = 200 + +/* +GetFCGIAppsOK Successful operation + +swagger:response getFcgiAppsOK +*/ +type GetFCGIAppsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.FCGIApps `json:"body,omitempty"` +} + +// NewGetFCGIAppsOK creates GetFCGIAppsOK with default headers values +func NewGetFCGIAppsOK() *GetFCGIAppsOK { + + return &GetFCGIAppsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Fcgi apps o k response +func (o *GetFCGIAppsOK) WithConfigurationVersion(configurationVersion string) *GetFCGIAppsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Fcgi apps o k response +func (o *GetFCGIAppsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Fcgi apps o k response +func (o *GetFCGIAppsOK) WithPayload(payload models.FCGIApps) *GetFCGIAppsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Fcgi apps o k response +func (o *GetFCGIAppsOK) SetPayload(payload models.FCGIApps) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFCGIAppsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.FCGIApps{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetFCGIAppsDefault General Error + +swagger:response getFcgiAppsDefault +*/ +type GetFCGIAppsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetFCGIAppsDefault creates GetFCGIAppsDefault with default headers values +func NewGetFCGIAppsDefault(code int) *GetFCGIAppsDefault { + if code <= 0 { + code = 500 + } + + return &GetFCGIAppsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get FCGI apps default response +func (o *GetFCGIAppsDefault) WithStatusCode(code int) *GetFCGIAppsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get FCGI apps default response +func (o *GetFCGIAppsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get FCGI apps default response +func (o *GetFCGIAppsDefault) WithConfigurationVersion(configurationVersion string) *GetFCGIAppsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get FCGI apps default response +func (o *GetFCGIAppsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get FCGI apps default response +func (o *GetFCGIAppsDefault) WithPayload(payload *models.Error) *GetFCGIAppsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get FCGI apps default response +func (o *GetFCGIAppsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFCGIAppsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/fcgi_app/get_fcgi_apps_urlbuilder.go b/operations/fcgi_app/get_fcgi_apps_urlbuilder.go new file mode 100644 index 00000000..95afd49b --- /dev/null +++ b/operations/fcgi_app/get_fcgi_apps_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetFCGIAppsURL generates an URL for the get FCGI apps operation +type GetFCGIAppsURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFCGIAppsURL) WithBasePath(bp string) *GetFCGIAppsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFCGIAppsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetFCGIAppsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetFCGIAppsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetFCGIAppsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetFCGIAppsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetFCGIAppsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetFCGIAppsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetFCGIAppsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/fcgi_app/replace_fcgi_app.go b/operations/fcgi_app/replace_fcgi_app.go new file mode 100644 index 00000000..d93bd787 --- /dev/null +++ b/operations/fcgi_app/replace_fcgi_app.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceFCGIAppHandlerFunc turns a function with the right signature into a replace FCGI app handler +type ReplaceFCGIAppHandlerFunc func(ReplaceFCGIAppParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceFCGIAppHandlerFunc) Handle(params ReplaceFCGIAppParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceFCGIAppHandler interface for that can handle valid replace FCGI app params +type ReplaceFCGIAppHandler interface { + Handle(ReplaceFCGIAppParams, interface{}) middleware.Responder +} + +// NewReplaceFCGIApp creates a new http.Handler for the replace FCGI app operation +func NewReplaceFCGIApp(ctx *middleware.Context, handler ReplaceFCGIAppHandler) *ReplaceFCGIApp { + return &ReplaceFCGIApp{Context: ctx, Handler: handler} +} + +/* + ReplaceFCGIApp swagger:route PUT /services/haproxy/configuration/fcgi_apps/{name} FCGIApp replaceFcgiApp + +# Replace a FCGI app + +Replaces a FCGI application configuration by its name. +*/ +type ReplaceFCGIApp struct { + Context *middleware.Context + Handler ReplaceFCGIAppHandler +} + +func (o *ReplaceFCGIApp) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceFCGIAppParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/fcgi_app/replace_fcgi_app_parameters.go b/operations/fcgi_app/replace_fcgi_app_parameters.go new file mode 100644 index 00000000..a0b1896e --- /dev/null +++ b/operations/fcgi_app/replace_fcgi_app_parameters.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceFCGIAppParams creates a new ReplaceFCGIAppParams object +// with the default values initialized. +func NewReplaceFCGIAppParams() ReplaceFCGIAppParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return ReplaceFCGIAppParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// ReplaceFCGIAppParams contains all the bound params for the replace FCGI app operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceFCGIApp +type ReplaceFCGIAppParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.FCGIApp + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Application name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceFCGIAppParams() beforehand. +func (o *ReplaceFCGIAppParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.FCGIApp + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceFCGIAppParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceFCGIAppParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceFCGIAppParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceFCGIAppParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceFCGIAppParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceFCGIAppParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/fcgi_app/replace_fcgi_app_responses.go b/operations/fcgi_app/replace_fcgi_app_responses.go new file mode 100644 index 00000000..3f62ff5a --- /dev/null +++ b/operations/fcgi_app/replace_fcgi_app_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceFCGIAppOKCode is the HTTP code returned for type ReplaceFCGIAppOK +const ReplaceFCGIAppOKCode int = 200 + +/* +ReplaceFCGIAppOK Application replaced + +swagger:response replaceFcgiAppOK +*/ +type ReplaceFCGIAppOK struct { + + /* + In: Body + */ + Payload *models.FCGIApp `json:"body,omitempty"` +} + +// NewReplaceFCGIAppOK creates ReplaceFCGIAppOK with default headers values +func NewReplaceFCGIAppOK() *ReplaceFCGIAppOK { + + return &ReplaceFCGIAppOK{} +} + +// WithPayload adds the payload to the replace Fcgi app o k response +func (o *ReplaceFCGIAppOK) WithPayload(payload *models.FCGIApp) *ReplaceFCGIAppOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Fcgi app o k response +func (o *ReplaceFCGIAppOK) SetPayload(payload *models.FCGIApp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFCGIAppOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFCGIAppAcceptedCode is the HTTP code returned for type ReplaceFCGIAppAccepted +const ReplaceFCGIAppAcceptedCode int = 202 + +/* +ReplaceFCGIAppAccepted Configuration change accepted and reload requested + +swagger:response replaceFcgiAppAccepted +*/ +type ReplaceFCGIAppAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.FCGIApp `json:"body,omitempty"` +} + +// NewReplaceFCGIAppAccepted creates ReplaceFCGIAppAccepted with default headers values +func NewReplaceFCGIAppAccepted() *ReplaceFCGIAppAccepted { + + return &ReplaceFCGIAppAccepted{} +} + +// WithReloadID adds the reloadId to the replace Fcgi app accepted response +func (o *ReplaceFCGIAppAccepted) WithReloadID(reloadID string) *ReplaceFCGIAppAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Fcgi app accepted response +func (o *ReplaceFCGIAppAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Fcgi app accepted response +func (o *ReplaceFCGIAppAccepted) WithPayload(payload *models.FCGIApp) *ReplaceFCGIAppAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Fcgi app accepted response +func (o *ReplaceFCGIAppAccepted) SetPayload(payload *models.FCGIApp) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFCGIAppAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFCGIAppBadRequestCode is the HTTP code returned for type ReplaceFCGIAppBadRequest +const ReplaceFCGIAppBadRequestCode int = 400 + +/* +ReplaceFCGIAppBadRequest Bad request + +swagger:response replaceFcgiAppBadRequest +*/ +type ReplaceFCGIAppBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFCGIAppBadRequest creates ReplaceFCGIAppBadRequest with default headers values +func NewReplaceFCGIAppBadRequest() *ReplaceFCGIAppBadRequest { + + return &ReplaceFCGIAppBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Fcgi app bad request response +func (o *ReplaceFCGIAppBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceFCGIAppBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Fcgi app bad request response +func (o *ReplaceFCGIAppBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Fcgi app bad request response +func (o *ReplaceFCGIAppBadRequest) WithPayload(payload *models.Error) *ReplaceFCGIAppBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Fcgi app bad request response +func (o *ReplaceFCGIAppBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFCGIAppBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFCGIAppNotFoundCode is the HTTP code returned for type ReplaceFCGIAppNotFound +const ReplaceFCGIAppNotFoundCode int = 404 + +/* +ReplaceFCGIAppNotFound The specified resource was not found + +swagger:response replaceFcgiAppNotFound +*/ +type ReplaceFCGIAppNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFCGIAppNotFound creates ReplaceFCGIAppNotFound with default headers values +func NewReplaceFCGIAppNotFound() *ReplaceFCGIAppNotFound { + + return &ReplaceFCGIAppNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Fcgi app not found response +func (o *ReplaceFCGIAppNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceFCGIAppNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Fcgi app not found response +func (o *ReplaceFCGIAppNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Fcgi app not found response +func (o *ReplaceFCGIAppNotFound) WithPayload(payload *models.Error) *ReplaceFCGIAppNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Fcgi app not found response +func (o *ReplaceFCGIAppNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFCGIAppNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceFCGIAppDefault General Error + +swagger:response replaceFcgiAppDefault +*/ +type ReplaceFCGIAppDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFCGIAppDefault creates ReplaceFCGIAppDefault with default headers values +func NewReplaceFCGIAppDefault(code int) *ReplaceFCGIAppDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceFCGIAppDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace FCGI app default response +func (o *ReplaceFCGIAppDefault) WithStatusCode(code int) *ReplaceFCGIAppDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace FCGI app default response +func (o *ReplaceFCGIAppDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace FCGI app default response +func (o *ReplaceFCGIAppDefault) WithConfigurationVersion(configurationVersion string) *ReplaceFCGIAppDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace FCGI app default response +func (o *ReplaceFCGIAppDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace FCGI app default response +func (o *ReplaceFCGIAppDefault) WithPayload(payload *models.Error) *ReplaceFCGIAppDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace FCGI app default response +func (o *ReplaceFCGIAppDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFCGIAppDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/fcgi_app/replace_fcgi_app_urlbuilder.go b/operations/fcgi_app/replace_fcgi_app_urlbuilder.go new file mode 100644 index 00000000..78a2e412 --- /dev/null +++ b/operations/fcgi_app/replace_fcgi_app_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package fcgi_app + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceFCGIAppURL generates an URL for the replace FCGI app operation +type ReplaceFCGIAppURL struct { + Name string + + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceFCGIAppURL) WithBasePath(bp string) *ReplaceFCGIAppURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceFCGIAppURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceFCGIAppURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/fcgi_apps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceFCGIAppURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceFCGIAppURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceFCGIAppURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceFCGIAppURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceFCGIAppURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceFCGIAppURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceFCGIAppURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/create_filter.go b/operations/filter/create_filter.go deleted file mode 100644 index abe0d3f8..00000000 --- a/operations/filter/create_filter.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateFilterHandlerFunc turns a function with the right signature into a create filter handler -type CreateFilterHandlerFunc func(CreateFilterParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateFilterHandlerFunc) Handle(params CreateFilterParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateFilterHandler interface for that can handle valid create filter params -type CreateFilterHandler interface { - Handle(CreateFilterParams, interface{}) middleware.Responder -} - -// NewCreateFilter creates a new http.Handler for the create filter operation -func NewCreateFilter(ctx *middleware.Context, handler CreateFilterHandler) *CreateFilter { - return &CreateFilter{Context: ctx, Handler: handler} -} - -/*CreateFilter swagger:route POST /services/haproxy/configuration/filters Filter createFilter - -Add a new Filter - -Adds a new Filter of the specified type in the specified parent. - -*/ -type CreateFilter struct { - Context *middleware.Context - Handler CreateFilterHandler -} - -func (o *CreateFilter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateFilterParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/filter/create_filter_backend.go b/operations/filter/create_filter_backend.go new file mode 100644 index 00000000..adebc3fa --- /dev/null +++ b/operations/filter/create_filter_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateFilterBackendHandlerFunc turns a function with the right signature into a create filter backend handler +type CreateFilterBackendHandlerFunc func(CreateFilterBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateFilterBackendHandlerFunc) Handle(params CreateFilterBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateFilterBackendHandler interface for that can handle valid create filter backend params +type CreateFilterBackendHandler interface { + Handle(CreateFilterBackendParams, interface{}) middleware.Responder +} + +// NewCreateFilterBackend creates a new http.Handler for the create filter backend operation +func NewCreateFilterBackend(ctx *middleware.Context, handler CreateFilterBackendHandler) *CreateFilterBackend { + return &CreateFilterBackend{Context: ctx, Handler: handler} +} + +/* + CreateFilterBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/filters/{index} Filter createFilterBackend + +# Add a new Filter + +Adds a new Filter of the specified type in the specified parent. +*/ +type CreateFilterBackend struct { + Context *middleware.Context + Handler CreateFilterBackendHandler +} + +func (o *CreateFilterBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateFilterBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/create_filter_backend_parameters.go b/operations/filter/create_filter_backend_parameters.go new file mode 100644 index 00000000..0e0f6d25 --- /dev/null +++ b/operations/filter/create_filter_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateFilterBackendParams creates a new CreateFilterBackendParams object +// with the default values initialized. +func NewCreateFilterBackendParams() CreateFilterBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateFilterBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateFilterBackendParams contains all the bound params for the create filter backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createFilterBackend +type CreateFilterBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Filter + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateFilterBackendParams() beforehand. +func (o *CreateFilterBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Filter + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateFilterBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateFilterBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateFilterBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateFilterBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateFilterBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateFilterBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/create_filter_backend_responses.go b/operations/filter/create_filter_backend_responses.go new file mode 100644 index 00000000..ddf6426d --- /dev/null +++ b/operations/filter/create_filter_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateFilterBackendCreatedCode is the HTTP code returned for type CreateFilterBackendCreated +const CreateFilterBackendCreatedCode int = 201 + +/* +CreateFilterBackendCreated Filter created + +swagger:response createFilterBackendCreated +*/ +type CreateFilterBackendCreated struct { + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewCreateFilterBackendCreated creates CreateFilterBackendCreated with default headers values +func NewCreateFilterBackendCreated() *CreateFilterBackendCreated { + + return &CreateFilterBackendCreated{} +} + +// WithPayload adds the payload to the create filter backend created response +func (o *CreateFilterBackendCreated) WithPayload(payload *models.Filter) *CreateFilterBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter backend created response +func (o *CreateFilterBackendCreated) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFilterBackendAcceptedCode is the HTTP code returned for type CreateFilterBackendAccepted +const CreateFilterBackendAcceptedCode int = 202 + +/* +CreateFilterBackendAccepted Configuration change accepted and reload requested + +swagger:response createFilterBackendAccepted +*/ +type CreateFilterBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewCreateFilterBackendAccepted creates CreateFilterBackendAccepted with default headers values +func NewCreateFilterBackendAccepted() *CreateFilterBackendAccepted { + + return &CreateFilterBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create filter backend accepted response +func (o *CreateFilterBackendAccepted) WithReloadID(reloadID string) *CreateFilterBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create filter backend accepted response +func (o *CreateFilterBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create filter backend accepted response +func (o *CreateFilterBackendAccepted) WithPayload(payload *models.Filter) *CreateFilterBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter backend accepted response +func (o *CreateFilterBackendAccepted) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFilterBackendBadRequestCode is the HTTP code returned for type CreateFilterBackendBadRequest +const CreateFilterBackendBadRequestCode int = 400 + +/* +CreateFilterBackendBadRequest Bad request + +swagger:response createFilterBackendBadRequest +*/ +type CreateFilterBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFilterBackendBadRequest creates CreateFilterBackendBadRequest with default headers values +func NewCreateFilterBackendBadRequest() *CreateFilterBackendBadRequest { + + return &CreateFilterBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create filter backend bad request response +func (o *CreateFilterBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateFilterBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create filter backend bad request response +func (o *CreateFilterBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create filter backend bad request response +func (o *CreateFilterBackendBadRequest) WithPayload(payload *models.Error) *CreateFilterBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter backend bad request response +func (o *CreateFilterBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFilterBackendConflictCode is the HTTP code returned for type CreateFilterBackendConflict +const CreateFilterBackendConflictCode int = 409 + +/* +CreateFilterBackendConflict The specified resource already exists + +swagger:response createFilterBackendConflict +*/ +type CreateFilterBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFilterBackendConflict creates CreateFilterBackendConflict with default headers values +func NewCreateFilterBackendConflict() *CreateFilterBackendConflict { + + return &CreateFilterBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create filter backend conflict response +func (o *CreateFilterBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateFilterBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create filter backend conflict response +func (o *CreateFilterBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create filter backend conflict response +func (o *CreateFilterBackendConflict) WithPayload(payload *models.Error) *CreateFilterBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter backend conflict response +func (o *CreateFilterBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateFilterBackendDefault General Error + +swagger:response createFilterBackendDefault +*/ +type CreateFilterBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFilterBackendDefault creates CreateFilterBackendDefault with default headers values +func NewCreateFilterBackendDefault(code int) *CreateFilterBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateFilterBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create filter backend default response +func (o *CreateFilterBackendDefault) WithStatusCode(code int) *CreateFilterBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create filter backend default response +func (o *CreateFilterBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create filter backend default response +func (o *CreateFilterBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateFilterBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create filter backend default response +func (o *CreateFilterBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create filter backend default response +func (o *CreateFilterBackendDefault) WithPayload(payload *models.Error) *CreateFilterBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter backend default response +func (o *CreateFilterBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/create_filter_backend_urlbuilder.go b/operations/filter/create_filter_backend_urlbuilder.go new file mode 100644 index 00000000..f7cfbb93 --- /dev/null +++ b/operations/filter/create_filter_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateFilterBackendURL generates an URL for the create filter backend operation +type CreateFilterBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateFilterBackendURL) WithBasePath(bp string) *CreateFilterBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateFilterBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateFilterBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateFilterBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateFilterBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateFilterBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateFilterBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateFilterBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateFilterBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateFilterBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateFilterBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/create_filter_frontend.go b/operations/filter/create_filter_frontend.go new file mode 100644 index 00000000..7a707a4a --- /dev/null +++ b/operations/filter/create_filter_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateFilterFrontendHandlerFunc turns a function with the right signature into a create filter frontend handler +type CreateFilterFrontendHandlerFunc func(CreateFilterFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateFilterFrontendHandlerFunc) Handle(params CreateFilterFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateFilterFrontendHandler interface for that can handle valid create filter frontend params +type CreateFilterFrontendHandler interface { + Handle(CreateFilterFrontendParams, interface{}) middleware.Responder +} + +// NewCreateFilterFrontend creates a new http.Handler for the create filter frontend operation +func NewCreateFilterFrontend(ctx *middleware.Context, handler CreateFilterFrontendHandler) *CreateFilterFrontend { + return &CreateFilterFrontend{Context: ctx, Handler: handler} +} + +/* + CreateFilterFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/filters/{index} Filter createFilterFrontend + +# Add a new Filter + +Adds a new Filter of the specified type in the specified parent. +*/ +type CreateFilterFrontend struct { + Context *middleware.Context + Handler CreateFilterFrontendHandler +} + +func (o *CreateFilterFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateFilterFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/create_filter_frontend_parameters.go b/operations/filter/create_filter_frontend_parameters.go new file mode 100644 index 00000000..f81af086 --- /dev/null +++ b/operations/filter/create_filter_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateFilterFrontendParams creates a new CreateFilterFrontendParams object +// with the default values initialized. +func NewCreateFilterFrontendParams() CreateFilterFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateFilterFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateFilterFrontendParams contains all the bound params for the create filter frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createFilterFrontend +type CreateFilterFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Filter + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateFilterFrontendParams() beforehand. +func (o *CreateFilterFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Filter + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateFilterFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateFilterFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateFilterFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateFilterFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateFilterFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateFilterFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/create_filter_frontend_responses.go b/operations/filter/create_filter_frontend_responses.go new file mode 100644 index 00000000..5e21d253 --- /dev/null +++ b/operations/filter/create_filter_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateFilterFrontendCreatedCode is the HTTP code returned for type CreateFilterFrontendCreated +const CreateFilterFrontendCreatedCode int = 201 + +/* +CreateFilterFrontendCreated Filter created + +swagger:response createFilterFrontendCreated +*/ +type CreateFilterFrontendCreated struct { + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewCreateFilterFrontendCreated creates CreateFilterFrontendCreated with default headers values +func NewCreateFilterFrontendCreated() *CreateFilterFrontendCreated { + + return &CreateFilterFrontendCreated{} +} + +// WithPayload adds the payload to the create filter frontend created response +func (o *CreateFilterFrontendCreated) WithPayload(payload *models.Filter) *CreateFilterFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter frontend created response +func (o *CreateFilterFrontendCreated) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFilterFrontendAcceptedCode is the HTTP code returned for type CreateFilterFrontendAccepted +const CreateFilterFrontendAcceptedCode int = 202 + +/* +CreateFilterFrontendAccepted Configuration change accepted and reload requested + +swagger:response createFilterFrontendAccepted +*/ +type CreateFilterFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewCreateFilterFrontendAccepted creates CreateFilterFrontendAccepted with default headers values +func NewCreateFilterFrontendAccepted() *CreateFilterFrontendAccepted { + + return &CreateFilterFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create filter frontend accepted response +func (o *CreateFilterFrontendAccepted) WithReloadID(reloadID string) *CreateFilterFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create filter frontend accepted response +func (o *CreateFilterFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create filter frontend accepted response +func (o *CreateFilterFrontendAccepted) WithPayload(payload *models.Filter) *CreateFilterFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter frontend accepted response +func (o *CreateFilterFrontendAccepted) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFilterFrontendBadRequestCode is the HTTP code returned for type CreateFilterFrontendBadRequest +const CreateFilterFrontendBadRequestCode int = 400 + +/* +CreateFilterFrontendBadRequest Bad request + +swagger:response createFilterFrontendBadRequest +*/ +type CreateFilterFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFilterFrontendBadRequest creates CreateFilterFrontendBadRequest with default headers values +func NewCreateFilterFrontendBadRequest() *CreateFilterFrontendBadRequest { + + return &CreateFilterFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create filter frontend bad request response +func (o *CreateFilterFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateFilterFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create filter frontend bad request response +func (o *CreateFilterFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create filter frontend bad request response +func (o *CreateFilterFrontendBadRequest) WithPayload(payload *models.Error) *CreateFilterFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter frontend bad request response +func (o *CreateFilterFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateFilterFrontendConflictCode is the HTTP code returned for type CreateFilterFrontendConflict +const CreateFilterFrontendConflictCode int = 409 + +/* +CreateFilterFrontendConflict The specified resource already exists + +swagger:response createFilterFrontendConflict +*/ +type CreateFilterFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFilterFrontendConflict creates CreateFilterFrontendConflict with default headers values +func NewCreateFilterFrontendConflict() *CreateFilterFrontendConflict { + + return &CreateFilterFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create filter frontend conflict response +func (o *CreateFilterFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateFilterFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create filter frontend conflict response +func (o *CreateFilterFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create filter frontend conflict response +func (o *CreateFilterFrontendConflict) WithPayload(payload *models.Error) *CreateFilterFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter frontend conflict response +func (o *CreateFilterFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateFilterFrontendDefault General Error + +swagger:response createFilterFrontendDefault +*/ +type CreateFilterFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateFilterFrontendDefault creates CreateFilterFrontendDefault with default headers values +func NewCreateFilterFrontendDefault(code int) *CreateFilterFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateFilterFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create filter frontend default response +func (o *CreateFilterFrontendDefault) WithStatusCode(code int) *CreateFilterFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create filter frontend default response +func (o *CreateFilterFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create filter frontend default response +func (o *CreateFilterFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateFilterFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create filter frontend default response +func (o *CreateFilterFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create filter frontend default response +func (o *CreateFilterFrontendDefault) WithPayload(payload *models.Error) *CreateFilterFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create filter frontend default response +func (o *CreateFilterFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateFilterFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/create_filter_frontend_urlbuilder.go b/operations/filter/create_filter_frontend_urlbuilder.go new file mode 100644 index 00000000..5e0fdc3a --- /dev/null +++ b/operations/filter/create_filter_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateFilterFrontendURL generates an URL for the create filter frontend operation +type CreateFilterFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateFilterFrontendURL) WithBasePath(bp string) *CreateFilterFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateFilterFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateFilterFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateFilterFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateFilterFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateFilterFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateFilterFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateFilterFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateFilterFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateFilterFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateFilterFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/create_filter_parameters.go b/operations/filter/create_filter_parameters.go deleted file mode 100644 index d937416b..00000000 --- a/operations/filter/create_filter_parameters.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateFilterParams creates a new CreateFilterParams object -// with the default values initialized. -func NewCreateFilterParams() CreateFilterParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateFilterParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateFilterParams contains all the bound params for the create filter operation -// typically these are obtained from a http.Request -// -// swagger:parameters createFilter -type CreateFilterParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.Filter - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateFilterParams() beforehand. -func (o *CreateFilterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.Filter - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateFilterParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateFilterParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *CreateFilterParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *CreateFilterParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *CreateFilterParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateFilterParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateFilterParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/filter/create_filter_responses.go b/operations/filter/create_filter_responses.go deleted file mode 100644 index dcdebfd3..00000000 --- a/operations/filter/create_filter_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateFilterCreatedCode is the HTTP code returned for type CreateFilterCreated -const CreateFilterCreatedCode int = 201 - -/*CreateFilterCreated Filter created - -swagger:response createFilterCreated -*/ -type CreateFilterCreated struct { - - /* - In: Body - */ - Payload *models.Filter `json:"body,omitempty"` -} - -// NewCreateFilterCreated creates CreateFilterCreated with default headers values -func NewCreateFilterCreated() *CreateFilterCreated { - - return &CreateFilterCreated{} -} - -// WithPayload adds the payload to the create filter created response -func (o *CreateFilterCreated) WithPayload(payload *models.Filter) *CreateFilterCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create filter created response -func (o *CreateFilterCreated) SetPayload(payload *models.Filter) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateFilterCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateFilterAcceptedCode is the HTTP code returned for type CreateFilterAccepted -const CreateFilterAcceptedCode int = 202 - -/*CreateFilterAccepted Configuration change accepted and reload requested - -swagger:response createFilterAccepted -*/ -type CreateFilterAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.Filter `json:"body,omitempty"` -} - -// NewCreateFilterAccepted creates CreateFilterAccepted with default headers values -func NewCreateFilterAccepted() *CreateFilterAccepted { - - return &CreateFilterAccepted{} -} - -// WithReloadID adds the reloadId to the create filter accepted response -func (o *CreateFilterAccepted) WithReloadID(reloadID string) *CreateFilterAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create filter accepted response -func (o *CreateFilterAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create filter accepted response -func (o *CreateFilterAccepted) WithPayload(payload *models.Filter) *CreateFilterAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create filter accepted response -func (o *CreateFilterAccepted) SetPayload(payload *models.Filter) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateFilterAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateFilterBadRequestCode is the HTTP code returned for type CreateFilterBadRequest -const CreateFilterBadRequestCode int = 400 - -/*CreateFilterBadRequest Bad request - -swagger:response createFilterBadRequest -*/ -type CreateFilterBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateFilterBadRequest creates CreateFilterBadRequest with default headers values -func NewCreateFilterBadRequest() *CreateFilterBadRequest { - - return &CreateFilterBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create filter bad request response -func (o *CreateFilterBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateFilterBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create filter bad request response -func (o *CreateFilterBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create filter bad request response -func (o *CreateFilterBadRequest) WithPayload(payload *models.Error) *CreateFilterBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create filter bad request response -func (o *CreateFilterBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateFilterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateFilterConflictCode is the HTTP code returned for type CreateFilterConflict -const CreateFilterConflictCode int = 409 - -/*CreateFilterConflict The specified resource already exists - -swagger:response createFilterConflict -*/ -type CreateFilterConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateFilterConflict creates CreateFilterConflict with default headers values -func NewCreateFilterConflict() *CreateFilterConflict { - - return &CreateFilterConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create filter conflict response -func (o *CreateFilterConflict) WithConfigurationVersion(configurationVersion int64) *CreateFilterConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create filter conflict response -func (o *CreateFilterConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create filter conflict response -func (o *CreateFilterConflict) WithPayload(payload *models.Error) *CreateFilterConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create filter conflict response -func (o *CreateFilterConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateFilterConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateFilterDefault General Error - -swagger:response createFilterDefault -*/ -type CreateFilterDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateFilterDefault creates CreateFilterDefault with default headers values -func NewCreateFilterDefault(code int) *CreateFilterDefault { - if code <= 0 { - code = 500 - } - - return &CreateFilterDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create filter default response -func (o *CreateFilterDefault) WithStatusCode(code int) *CreateFilterDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create filter default response -func (o *CreateFilterDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create filter default response -func (o *CreateFilterDefault) WithConfigurationVersion(configurationVersion int64) *CreateFilterDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create filter default response -func (o *CreateFilterDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create filter default response -func (o *CreateFilterDefault) WithPayload(payload *models.Error) *CreateFilterDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create filter default response -func (o *CreateFilterDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateFilterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/filter/create_filter_urlbuilder.go b/operations/filter/create_filter_urlbuilder.go deleted file mode 100644 index d38d4a0e..00000000 --- a/operations/filter/create_filter_urlbuilder.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateFilterURL generates an URL for the create filter operation -type CreateFilterURL struct { - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateFilterURL) WithBasePath(bp string) *CreateFilterURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateFilterURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateFilterURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/filters" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateFilterURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateFilterURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateFilterURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateFilterURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateFilterURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateFilterURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/filter/delete_filter.go b/operations/filter/delete_filter.go deleted file mode 100644 index dd354d53..00000000 --- a/operations/filter/delete_filter.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteFilterHandlerFunc turns a function with the right signature into a delete filter handler -type DeleteFilterHandlerFunc func(DeleteFilterParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteFilterHandlerFunc) Handle(params DeleteFilterParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteFilterHandler interface for that can handle valid delete filter params -type DeleteFilterHandler interface { - Handle(DeleteFilterParams, interface{}) middleware.Responder -} - -// NewDeleteFilter creates a new http.Handler for the delete filter operation -func NewDeleteFilter(ctx *middleware.Context, handler DeleteFilterHandler) *DeleteFilter { - return &DeleteFilter{Context: ctx, Handler: handler} -} - -/*DeleteFilter swagger:route DELETE /services/haproxy/configuration/filters/{id} Filter deleteFilter - -Delete a Filter - -Deletes a Filter configuration by it's ID from the specified parent. - -*/ -type DeleteFilter struct { - Context *middleware.Context - Handler DeleteFilterHandler -} - -func (o *DeleteFilter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteFilterParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/filter/delete_filter_backend.go b/operations/filter/delete_filter_backend.go new file mode 100644 index 00000000..c374c467 --- /dev/null +++ b/operations/filter/delete_filter_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteFilterBackendHandlerFunc turns a function with the right signature into a delete filter backend handler +type DeleteFilterBackendHandlerFunc func(DeleteFilterBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteFilterBackendHandlerFunc) Handle(params DeleteFilterBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteFilterBackendHandler interface for that can handle valid delete filter backend params +type DeleteFilterBackendHandler interface { + Handle(DeleteFilterBackendParams, interface{}) middleware.Responder +} + +// NewDeleteFilterBackend creates a new http.Handler for the delete filter backend operation +func NewDeleteFilterBackend(ctx *middleware.Context, handler DeleteFilterBackendHandler) *DeleteFilterBackend { + return &DeleteFilterBackend{Context: ctx, Handler: handler} +} + +/* + DeleteFilterBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/filters/{index} Filter deleteFilterBackend + +# Delete a Filter + +Deletes a Filter configuration by it's index from the specified parent. +*/ +type DeleteFilterBackend struct { + Context *middleware.Context + Handler DeleteFilterBackendHandler +} + +func (o *DeleteFilterBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteFilterBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/delete_filter_backend_parameters.go b/operations/filter/delete_filter_backend_parameters.go new file mode 100644 index 00000000..28e77f9d --- /dev/null +++ b/operations/filter/delete_filter_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteFilterBackendParams creates a new DeleteFilterBackendParams object +// with the default values initialized. +func NewDeleteFilterBackendParams() DeleteFilterBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteFilterBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteFilterBackendParams contains all the bound params for the delete filter backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteFilterBackend +type DeleteFilterBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteFilterBackendParams() beforehand. +func (o *DeleteFilterBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteFilterBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteFilterBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteFilterBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteFilterBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteFilterBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteFilterBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/delete_filter_backend_responses.go b/operations/filter/delete_filter_backend_responses.go new file mode 100644 index 00000000..59ba86df --- /dev/null +++ b/operations/filter/delete_filter_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteFilterBackendAcceptedCode is the HTTP code returned for type DeleteFilterBackendAccepted +const DeleteFilterBackendAcceptedCode int = 202 + +/* +DeleteFilterBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteFilterBackendAccepted +*/ +type DeleteFilterBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteFilterBackendAccepted creates DeleteFilterBackendAccepted with default headers values +func NewDeleteFilterBackendAccepted() *DeleteFilterBackendAccepted { + + return &DeleteFilterBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete filter backend accepted response +func (o *DeleteFilterBackendAccepted) WithReloadID(reloadID string) *DeleteFilterBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete filter backend accepted response +func (o *DeleteFilterBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteFilterBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteFilterBackendNoContentCode is the HTTP code returned for type DeleteFilterBackendNoContent +const DeleteFilterBackendNoContentCode int = 204 + +/* +DeleteFilterBackendNoContent Filter deleted + +swagger:response deleteFilterBackendNoContent +*/ +type DeleteFilterBackendNoContent struct { +} + +// NewDeleteFilterBackendNoContent creates DeleteFilterBackendNoContent with default headers values +func NewDeleteFilterBackendNoContent() *DeleteFilterBackendNoContent { + + return &DeleteFilterBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteFilterBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteFilterBackendNotFoundCode is the HTTP code returned for type DeleteFilterBackendNotFound +const DeleteFilterBackendNotFoundCode int = 404 + +/* +DeleteFilterBackendNotFound The specified resource was not found + +swagger:response deleteFilterBackendNotFound +*/ +type DeleteFilterBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteFilterBackendNotFound creates DeleteFilterBackendNotFound with default headers values +func NewDeleteFilterBackendNotFound() *DeleteFilterBackendNotFound { + + return &DeleteFilterBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete filter backend not found response +func (o *DeleteFilterBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteFilterBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete filter backend not found response +func (o *DeleteFilterBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete filter backend not found response +func (o *DeleteFilterBackendNotFound) WithPayload(payload *models.Error) *DeleteFilterBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete filter backend not found response +func (o *DeleteFilterBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteFilterBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteFilterBackendDefault General Error + +swagger:response deleteFilterBackendDefault +*/ +type DeleteFilterBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteFilterBackendDefault creates DeleteFilterBackendDefault with default headers values +func NewDeleteFilterBackendDefault(code int) *DeleteFilterBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteFilterBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete filter backend default response +func (o *DeleteFilterBackendDefault) WithStatusCode(code int) *DeleteFilterBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete filter backend default response +func (o *DeleteFilterBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete filter backend default response +func (o *DeleteFilterBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteFilterBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete filter backend default response +func (o *DeleteFilterBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete filter backend default response +func (o *DeleteFilterBackendDefault) WithPayload(payload *models.Error) *DeleteFilterBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete filter backend default response +func (o *DeleteFilterBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteFilterBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/delete_filter_backend_urlbuilder.go b/operations/filter/delete_filter_backend_urlbuilder.go new file mode 100644 index 00000000..3bfdbd29 --- /dev/null +++ b/operations/filter/delete_filter_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteFilterBackendURL generates an URL for the delete filter backend operation +type DeleteFilterBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteFilterBackendURL) WithBasePath(bp string) *DeleteFilterBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteFilterBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteFilterBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteFilterBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteFilterBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteFilterBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteFilterBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteFilterBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteFilterBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteFilterBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteFilterBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/delete_filter_frontend.go b/operations/filter/delete_filter_frontend.go new file mode 100644 index 00000000..8eb89dc7 --- /dev/null +++ b/operations/filter/delete_filter_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteFilterFrontendHandlerFunc turns a function with the right signature into a delete filter frontend handler +type DeleteFilterFrontendHandlerFunc func(DeleteFilterFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteFilterFrontendHandlerFunc) Handle(params DeleteFilterFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteFilterFrontendHandler interface for that can handle valid delete filter frontend params +type DeleteFilterFrontendHandler interface { + Handle(DeleteFilterFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteFilterFrontend creates a new http.Handler for the delete filter frontend operation +func NewDeleteFilterFrontend(ctx *middleware.Context, handler DeleteFilterFrontendHandler) *DeleteFilterFrontend { + return &DeleteFilterFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteFilterFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/filters/{index} Filter deleteFilterFrontend + +# Delete a Filter + +Deletes a Filter configuration by it's index from the specified parent. +*/ +type DeleteFilterFrontend struct { + Context *middleware.Context + Handler DeleteFilterFrontendHandler +} + +func (o *DeleteFilterFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteFilterFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/delete_filter_frontend_parameters.go b/operations/filter/delete_filter_frontend_parameters.go new file mode 100644 index 00000000..e7c9af9c --- /dev/null +++ b/operations/filter/delete_filter_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteFilterFrontendParams creates a new DeleteFilterFrontendParams object +// with the default values initialized. +func NewDeleteFilterFrontendParams() DeleteFilterFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteFilterFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteFilterFrontendParams contains all the bound params for the delete filter frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteFilterFrontend +type DeleteFilterFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteFilterFrontendParams() beforehand. +func (o *DeleteFilterFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteFilterFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteFilterFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteFilterFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteFilterFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteFilterFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteFilterFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/delete_filter_frontend_responses.go b/operations/filter/delete_filter_frontend_responses.go new file mode 100644 index 00000000..9316c107 --- /dev/null +++ b/operations/filter/delete_filter_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteFilterFrontendAcceptedCode is the HTTP code returned for type DeleteFilterFrontendAccepted +const DeleteFilterFrontendAcceptedCode int = 202 + +/* +DeleteFilterFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteFilterFrontendAccepted +*/ +type DeleteFilterFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteFilterFrontendAccepted creates DeleteFilterFrontendAccepted with default headers values +func NewDeleteFilterFrontendAccepted() *DeleteFilterFrontendAccepted { + + return &DeleteFilterFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete filter frontend accepted response +func (o *DeleteFilterFrontendAccepted) WithReloadID(reloadID string) *DeleteFilterFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete filter frontend accepted response +func (o *DeleteFilterFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteFilterFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteFilterFrontendNoContentCode is the HTTP code returned for type DeleteFilterFrontendNoContent +const DeleteFilterFrontendNoContentCode int = 204 + +/* +DeleteFilterFrontendNoContent Filter deleted + +swagger:response deleteFilterFrontendNoContent +*/ +type DeleteFilterFrontendNoContent struct { +} + +// NewDeleteFilterFrontendNoContent creates DeleteFilterFrontendNoContent with default headers values +func NewDeleteFilterFrontendNoContent() *DeleteFilterFrontendNoContent { + + return &DeleteFilterFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteFilterFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteFilterFrontendNotFoundCode is the HTTP code returned for type DeleteFilterFrontendNotFound +const DeleteFilterFrontendNotFoundCode int = 404 + +/* +DeleteFilterFrontendNotFound The specified resource was not found + +swagger:response deleteFilterFrontendNotFound +*/ +type DeleteFilterFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteFilterFrontendNotFound creates DeleteFilterFrontendNotFound with default headers values +func NewDeleteFilterFrontendNotFound() *DeleteFilterFrontendNotFound { + + return &DeleteFilterFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete filter frontend not found response +func (o *DeleteFilterFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteFilterFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete filter frontend not found response +func (o *DeleteFilterFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete filter frontend not found response +func (o *DeleteFilterFrontendNotFound) WithPayload(payload *models.Error) *DeleteFilterFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete filter frontend not found response +func (o *DeleteFilterFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteFilterFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteFilterFrontendDefault General Error + +swagger:response deleteFilterFrontendDefault +*/ +type DeleteFilterFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteFilterFrontendDefault creates DeleteFilterFrontendDefault with default headers values +func NewDeleteFilterFrontendDefault(code int) *DeleteFilterFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteFilterFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete filter frontend default response +func (o *DeleteFilterFrontendDefault) WithStatusCode(code int) *DeleteFilterFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete filter frontend default response +func (o *DeleteFilterFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete filter frontend default response +func (o *DeleteFilterFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteFilterFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete filter frontend default response +func (o *DeleteFilterFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete filter frontend default response +func (o *DeleteFilterFrontendDefault) WithPayload(payload *models.Error) *DeleteFilterFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete filter frontend default response +func (o *DeleteFilterFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteFilterFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/delete_filter_frontend_urlbuilder.go b/operations/filter/delete_filter_frontend_urlbuilder.go new file mode 100644 index 00000000..662f6c0f --- /dev/null +++ b/operations/filter/delete_filter_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteFilterFrontendURL generates an URL for the delete filter frontend operation +type DeleteFilterFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteFilterFrontendURL) WithBasePath(bp string) *DeleteFilterFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteFilterFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteFilterFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteFilterFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteFilterFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteFilterFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteFilterFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteFilterFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteFilterFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteFilterFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteFilterFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/delete_filter_parameters.go b/operations/filter/delete_filter_parameters.go deleted file mode 100644 index c27eaaf8..00000000 --- a/operations/filter/delete_filter_parameters.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteFilterParams creates a new DeleteFilterParams object -// with the default values initialized. -func NewDeleteFilterParams() DeleteFilterParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteFilterParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteFilterParams contains all the bound params for the delete filter operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteFilter -type DeleteFilterParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Filter ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteFilterParams() beforehand. -func (o *DeleteFilterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteFilterParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteFilterParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *DeleteFilterParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *DeleteFilterParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *DeleteFilterParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *DeleteFilterParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteFilterParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteFilterParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/filter/delete_filter_responses.go b/operations/filter/delete_filter_responses.go deleted file mode 100644 index 01468c67..00000000 --- a/operations/filter/delete_filter_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteFilterAcceptedCode is the HTTP code returned for type DeleteFilterAccepted -const DeleteFilterAcceptedCode int = 202 - -/*DeleteFilterAccepted Configuration change accepted and reload requested - -swagger:response deleteFilterAccepted -*/ -type DeleteFilterAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteFilterAccepted creates DeleteFilterAccepted with default headers values -func NewDeleteFilterAccepted() *DeleteFilterAccepted { - - return &DeleteFilterAccepted{} -} - -// WithReloadID adds the reloadId to the delete filter accepted response -func (o *DeleteFilterAccepted) WithReloadID(reloadID string) *DeleteFilterAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete filter accepted response -func (o *DeleteFilterAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteFilterAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteFilterNoContentCode is the HTTP code returned for type DeleteFilterNoContent -const DeleteFilterNoContentCode int = 204 - -/*DeleteFilterNoContent Filter deleted - -swagger:response deleteFilterNoContent -*/ -type DeleteFilterNoContent struct { -} - -// NewDeleteFilterNoContent creates DeleteFilterNoContent with default headers values -func NewDeleteFilterNoContent() *DeleteFilterNoContent { - - return &DeleteFilterNoContent{} -} - -// WriteResponse to the client -func (o *DeleteFilterNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteFilterNotFoundCode is the HTTP code returned for type DeleteFilterNotFound -const DeleteFilterNotFoundCode int = 404 - -/*DeleteFilterNotFound The specified resource was not found - -swagger:response deleteFilterNotFound -*/ -type DeleteFilterNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteFilterNotFound creates DeleteFilterNotFound with default headers values -func NewDeleteFilterNotFound() *DeleteFilterNotFound { - - return &DeleteFilterNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete filter not found response -func (o *DeleteFilterNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteFilterNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete filter not found response -func (o *DeleteFilterNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete filter not found response -func (o *DeleteFilterNotFound) WithPayload(payload *models.Error) *DeleteFilterNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete filter not found response -func (o *DeleteFilterNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteFilterNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteFilterDefault General Error - -swagger:response deleteFilterDefault -*/ -type DeleteFilterDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteFilterDefault creates DeleteFilterDefault with default headers values -func NewDeleteFilterDefault(code int) *DeleteFilterDefault { - if code <= 0 { - code = 500 - } - - return &DeleteFilterDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete filter default response -func (o *DeleteFilterDefault) WithStatusCode(code int) *DeleteFilterDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete filter default response -func (o *DeleteFilterDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete filter default response -func (o *DeleteFilterDefault) WithConfigurationVersion(configurationVersion int64) *DeleteFilterDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete filter default response -func (o *DeleteFilterDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete filter default response -func (o *DeleteFilterDefault) WithPayload(payload *models.Error) *DeleteFilterDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete filter default response -func (o *DeleteFilterDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteFilterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/filter/delete_filter_urlbuilder.go b/operations/filter/delete_filter_urlbuilder.go deleted file mode 100644 index 907aa937..00000000 --- a/operations/filter/delete_filter_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteFilterURL generates an URL for the delete filter operation -type DeleteFilterURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteFilterURL) WithBasePath(bp string) *DeleteFilterURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteFilterURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteFilterURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/filters/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on DeleteFilterURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteFilterURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteFilterURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteFilterURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteFilterURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteFilterURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteFilterURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/filter/get_all_filter_backend.go b/operations/filter/get_all_filter_backend.go new file mode 100644 index 00000000..49102e32 --- /dev/null +++ b/operations/filter/get_all_filter_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllFilterBackendHandlerFunc turns a function with the right signature into a get all filter backend handler +type GetAllFilterBackendHandlerFunc func(GetAllFilterBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllFilterBackendHandlerFunc) Handle(params GetAllFilterBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllFilterBackendHandler interface for that can handle valid get all filter backend params +type GetAllFilterBackendHandler interface { + Handle(GetAllFilterBackendParams, interface{}) middleware.Responder +} + +// NewGetAllFilterBackend creates a new http.Handler for the get all filter backend operation +func NewGetAllFilterBackend(ctx *middleware.Context, handler GetAllFilterBackendHandler) *GetAllFilterBackend { + return &GetAllFilterBackend{Context: ctx, Handler: handler} +} + +/* + GetAllFilterBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/filters Filter getAllFilterBackend + +# Return an array of all Filters + +Returns all Filters that are configured in specified parent. +*/ +type GetAllFilterBackend struct { + Context *middleware.Context + Handler GetAllFilterBackendHandler +} + +func (o *GetAllFilterBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllFilterBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/get_all_filter_backend_parameters.go b/operations/filter/get_all_filter_backend_parameters.go new file mode 100644 index 00000000..262f48c4 --- /dev/null +++ b/operations/filter/get_all_filter_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllFilterBackendParams creates a new GetAllFilterBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllFilterBackendParams() GetAllFilterBackendParams { + + return GetAllFilterBackendParams{} +} + +// GetAllFilterBackendParams contains all the bound params for the get all filter backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllFilterBackend +type GetAllFilterBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllFilterBackendParams() beforehand. +func (o *GetAllFilterBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllFilterBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllFilterBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/filter/get_all_filter_backend_responses.go b/operations/filter/get_all_filter_backend_responses.go new file mode 100644 index 00000000..80ddb6c2 --- /dev/null +++ b/operations/filter/get_all_filter_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllFilterBackendOKCode is the HTTP code returned for type GetAllFilterBackendOK +const GetAllFilterBackendOKCode int = 200 + +/* +GetAllFilterBackendOK Successful operation + +swagger:response getAllFilterBackendOK +*/ +type GetAllFilterBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Filters `json:"body,omitempty"` +} + +// NewGetAllFilterBackendOK creates GetAllFilterBackendOK with default headers values +func NewGetAllFilterBackendOK() *GetAllFilterBackendOK { + + return &GetAllFilterBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all filter backend o k response +func (o *GetAllFilterBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllFilterBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all filter backend o k response +func (o *GetAllFilterBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all filter backend o k response +func (o *GetAllFilterBackendOK) WithPayload(payload models.Filters) *GetAllFilterBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all filter backend o k response +func (o *GetAllFilterBackendOK) SetPayload(payload models.Filters) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllFilterBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Filters{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllFilterBackendDefault General Error + +swagger:response getAllFilterBackendDefault +*/ +type GetAllFilterBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllFilterBackendDefault creates GetAllFilterBackendDefault with default headers values +func NewGetAllFilterBackendDefault(code int) *GetAllFilterBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllFilterBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all filter backend default response +func (o *GetAllFilterBackendDefault) WithStatusCode(code int) *GetAllFilterBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all filter backend default response +func (o *GetAllFilterBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all filter backend default response +func (o *GetAllFilterBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllFilterBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all filter backend default response +func (o *GetAllFilterBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all filter backend default response +func (o *GetAllFilterBackendDefault) WithPayload(payload *models.Error) *GetAllFilterBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all filter backend default response +func (o *GetAllFilterBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllFilterBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/get_all_filter_backend_urlbuilder.go b/operations/filter/get_all_filter_backend_urlbuilder.go new file mode 100644 index 00000000..b263931a --- /dev/null +++ b/operations/filter/get_all_filter_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllFilterBackendURL generates an URL for the get all filter backend operation +type GetAllFilterBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllFilterBackendURL) WithBasePath(bp string) *GetAllFilterBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllFilterBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllFilterBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/filters" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllFilterBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllFilterBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllFilterBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllFilterBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllFilterBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllFilterBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllFilterBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/get_all_filter_frontend.go b/operations/filter/get_all_filter_frontend.go new file mode 100644 index 00000000..2d57290e --- /dev/null +++ b/operations/filter/get_all_filter_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllFilterFrontendHandlerFunc turns a function with the right signature into a get all filter frontend handler +type GetAllFilterFrontendHandlerFunc func(GetAllFilterFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllFilterFrontendHandlerFunc) Handle(params GetAllFilterFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllFilterFrontendHandler interface for that can handle valid get all filter frontend params +type GetAllFilterFrontendHandler interface { + Handle(GetAllFilterFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllFilterFrontend creates a new http.Handler for the get all filter frontend operation +func NewGetAllFilterFrontend(ctx *middleware.Context, handler GetAllFilterFrontendHandler) *GetAllFilterFrontend { + return &GetAllFilterFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllFilterFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/filters Filter getAllFilterFrontend + +# Return an array of all Filters + +Returns all Filters that are configured in specified parent. +*/ +type GetAllFilterFrontend struct { + Context *middleware.Context + Handler GetAllFilterFrontendHandler +} + +func (o *GetAllFilterFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllFilterFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/get_all_filter_frontend_parameters.go b/operations/filter/get_all_filter_frontend_parameters.go new file mode 100644 index 00000000..f7266252 --- /dev/null +++ b/operations/filter/get_all_filter_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllFilterFrontendParams creates a new GetAllFilterFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllFilterFrontendParams() GetAllFilterFrontendParams { + + return GetAllFilterFrontendParams{} +} + +// GetAllFilterFrontendParams contains all the bound params for the get all filter frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllFilterFrontend +type GetAllFilterFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllFilterFrontendParams() beforehand. +func (o *GetAllFilterFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllFilterFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllFilterFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/filter/get_all_filter_frontend_responses.go b/operations/filter/get_all_filter_frontend_responses.go new file mode 100644 index 00000000..4cf844b9 --- /dev/null +++ b/operations/filter/get_all_filter_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllFilterFrontendOKCode is the HTTP code returned for type GetAllFilterFrontendOK +const GetAllFilterFrontendOKCode int = 200 + +/* +GetAllFilterFrontendOK Successful operation + +swagger:response getAllFilterFrontendOK +*/ +type GetAllFilterFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Filters `json:"body,omitempty"` +} + +// NewGetAllFilterFrontendOK creates GetAllFilterFrontendOK with default headers values +func NewGetAllFilterFrontendOK() *GetAllFilterFrontendOK { + + return &GetAllFilterFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all filter frontend o k response +func (o *GetAllFilterFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllFilterFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all filter frontend o k response +func (o *GetAllFilterFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all filter frontend o k response +func (o *GetAllFilterFrontendOK) WithPayload(payload models.Filters) *GetAllFilterFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all filter frontend o k response +func (o *GetAllFilterFrontendOK) SetPayload(payload models.Filters) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllFilterFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Filters{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllFilterFrontendDefault General Error + +swagger:response getAllFilterFrontendDefault +*/ +type GetAllFilterFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllFilterFrontendDefault creates GetAllFilterFrontendDefault with default headers values +func NewGetAllFilterFrontendDefault(code int) *GetAllFilterFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllFilterFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all filter frontend default response +func (o *GetAllFilterFrontendDefault) WithStatusCode(code int) *GetAllFilterFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all filter frontend default response +func (o *GetAllFilterFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all filter frontend default response +func (o *GetAllFilterFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllFilterFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all filter frontend default response +func (o *GetAllFilterFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all filter frontend default response +func (o *GetAllFilterFrontendDefault) WithPayload(payload *models.Error) *GetAllFilterFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all filter frontend default response +func (o *GetAllFilterFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllFilterFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/get_all_filter_frontend_urlbuilder.go b/operations/filter/get_all_filter_frontend_urlbuilder.go new file mode 100644 index 00000000..ba91b420 --- /dev/null +++ b/operations/filter/get_all_filter_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllFilterFrontendURL generates an URL for the get all filter frontend operation +type GetAllFilterFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllFilterFrontendURL) WithBasePath(bp string) *GetAllFilterFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllFilterFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllFilterFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/filters" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllFilterFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllFilterFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllFilterFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllFilterFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllFilterFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllFilterFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllFilterFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/get_filter.go b/operations/filter/get_filter.go deleted file mode 100644 index 5fce43ba..00000000 --- a/operations/filter/get_filter.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetFilterHandlerFunc turns a function with the right signature into a get filter handler -type GetFilterHandlerFunc func(GetFilterParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetFilterHandlerFunc) Handle(params GetFilterParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetFilterHandler interface for that can handle valid get filter params -type GetFilterHandler interface { - Handle(GetFilterParams, interface{}) middleware.Responder -} - -// NewGetFilter creates a new http.Handler for the get filter operation -func NewGetFilter(ctx *middleware.Context, handler GetFilterHandler) *GetFilter { - return &GetFilter{Context: ctx, Handler: handler} -} - -/*GetFilter swagger:route GET /services/haproxy/configuration/filters/{id} Filter getFilter - -Return one Filter - -Returns one Filter configuration by it's ID in the specified parent. - -*/ -type GetFilter struct { - Context *middleware.Context - Handler GetFilterHandler -} - -func (o *GetFilter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetFilterParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetFilterOKBody get filter o k body -// swagger:model GetFilterOKBody -type GetFilterOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Filter `json:"data,omitempty"` -} - -// Validate validates this get filter o k body -func (o *GetFilterOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetFilterOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getFilterOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetFilterOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetFilterOKBody) UnmarshalBinary(b []byte) error { - var res GetFilterOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/filter/get_filter_backend.go b/operations/filter/get_filter_backend.go new file mode 100644 index 00000000..22825cdb --- /dev/null +++ b/operations/filter/get_filter_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetFilterBackendHandlerFunc turns a function with the right signature into a get filter backend handler +type GetFilterBackendHandlerFunc func(GetFilterBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetFilterBackendHandlerFunc) Handle(params GetFilterBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetFilterBackendHandler interface for that can handle valid get filter backend params +type GetFilterBackendHandler interface { + Handle(GetFilterBackendParams, interface{}) middleware.Responder +} + +// NewGetFilterBackend creates a new http.Handler for the get filter backend operation +func NewGetFilterBackend(ctx *middleware.Context, handler GetFilterBackendHandler) *GetFilterBackend { + return &GetFilterBackend{Context: ctx, Handler: handler} +} + +/* + GetFilterBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/filters/{index} Filter getFilterBackend + +# Return one Filter + +Returns one Filter configuration by it's index in the specified parent. +*/ +type GetFilterBackend struct { + Context *middleware.Context + Handler GetFilterBackendHandler +} + +func (o *GetFilterBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetFilterBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/get_filter_backend_parameters.go b/operations/filter/get_filter_backend_parameters.go new file mode 100644 index 00000000..20342b83 --- /dev/null +++ b/operations/filter/get_filter_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetFilterBackendParams creates a new GetFilterBackendParams object +// +// There are no default values defined in the spec. +func NewGetFilterBackendParams() GetFilterBackendParams { + + return GetFilterBackendParams{} +} + +// GetFilterBackendParams contains all the bound params for the get filter backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getFilterBackend +type GetFilterBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetFilterBackendParams() beforehand. +func (o *GetFilterBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetFilterBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetFilterBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetFilterBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/filter/get_filter_backend_responses.go b/operations/filter/get_filter_backend_responses.go new file mode 100644 index 00000000..be2879bf --- /dev/null +++ b/operations/filter/get_filter_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetFilterBackendOKCode is the HTTP code returned for type GetFilterBackendOK +const GetFilterBackendOKCode int = 200 + +/* +GetFilterBackendOK Successful operation + +swagger:response getFilterBackendOK +*/ +type GetFilterBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewGetFilterBackendOK creates GetFilterBackendOK with default headers values +func NewGetFilterBackendOK() *GetFilterBackendOK { + + return &GetFilterBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get filter backend o k response +func (o *GetFilterBackendOK) WithConfigurationVersion(configurationVersion string) *GetFilterBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get filter backend o k response +func (o *GetFilterBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get filter backend o k response +func (o *GetFilterBackendOK) WithPayload(payload *models.Filter) *GetFilterBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get filter backend o k response +func (o *GetFilterBackendOK) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFilterBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetFilterBackendNotFoundCode is the HTTP code returned for type GetFilterBackendNotFound +const GetFilterBackendNotFoundCode int = 404 + +/* +GetFilterBackendNotFound The specified resource was not found + +swagger:response getFilterBackendNotFound +*/ +type GetFilterBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetFilterBackendNotFound creates GetFilterBackendNotFound with default headers values +func NewGetFilterBackendNotFound() *GetFilterBackendNotFound { + + return &GetFilterBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get filter backend not found response +func (o *GetFilterBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetFilterBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get filter backend not found response +func (o *GetFilterBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get filter backend not found response +func (o *GetFilterBackendNotFound) WithPayload(payload *models.Error) *GetFilterBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get filter backend not found response +func (o *GetFilterBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFilterBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetFilterBackendDefault General Error + +swagger:response getFilterBackendDefault +*/ +type GetFilterBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetFilterBackendDefault creates GetFilterBackendDefault with default headers values +func NewGetFilterBackendDefault(code int) *GetFilterBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetFilterBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get filter backend default response +func (o *GetFilterBackendDefault) WithStatusCode(code int) *GetFilterBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get filter backend default response +func (o *GetFilterBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get filter backend default response +func (o *GetFilterBackendDefault) WithConfigurationVersion(configurationVersion string) *GetFilterBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get filter backend default response +func (o *GetFilterBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get filter backend default response +func (o *GetFilterBackendDefault) WithPayload(payload *models.Error) *GetFilterBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get filter backend default response +func (o *GetFilterBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFilterBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/get_filter_backend_urlbuilder.go b/operations/filter/get_filter_backend_urlbuilder.go new file mode 100644 index 00000000..fbce3db8 --- /dev/null +++ b/operations/filter/get_filter_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetFilterBackendURL generates an URL for the get filter backend operation +type GetFilterBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFilterBackendURL) WithBasePath(bp string) *GetFilterBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFilterBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetFilterBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetFilterBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetFilterBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetFilterBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetFilterBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetFilterBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetFilterBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetFilterBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetFilterBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/get_filter_frontend.go b/operations/filter/get_filter_frontend.go new file mode 100644 index 00000000..2e2aa667 --- /dev/null +++ b/operations/filter/get_filter_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetFilterFrontendHandlerFunc turns a function with the right signature into a get filter frontend handler +type GetFilterFrontendHandlerFunc func(GetFilterFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetFilterFrontendHandlerFunc) Handle(params GetFilterFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetFilterFrontendHandler interface for that can handle valid get filter frontend params +type GetFilterFrontendHandler interface { + Handle(GetFilterFrontendParams, interface{}) middleware.Responder +} + +// NewGetFilterFrontend creates a new http.Handler for the get filter frontend operation +func NewGetFilterFrontend(ctx *middleware.Context, handler GetFilterFrontendHandler) *GetFilterFrontend { + return &GetFilterFrontend{Context: ctx, Handler: handler} +} + +/* + GetFilterFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/filters/{index} Filter getFilterFrontend + +# Return one Filter + +Returns one Filter configuration by it's index in the specified parent. +*/ +type GetFilterFrontend struct { + Context *middleware.Context + Handler GetFilterFrontendHandler +} + +func (o *GetFilterFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetFilterFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/get_filter_frontend_parameters.go b/operations/filter/get_filter_frontend_parameters.go new file mode 100644 index 00000000..5f5bf3b7 --- /dev/null +++ b/operations/filter/get_filter_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetFilterFrontendParams creates a new GetFilterFrontendParams object +// +// There are no default values defined in the spec. +func NewGetFilterFrontendParams() GetFilterFrontendParams { + + return GetFilterFrontendParams{} +} + +// GetFilterFrontendParams contains all the bound params for the get filter frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getFilterFrontend +type GetFilterFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetFilterFrontendParams() beforehand. +func (o *GetFilterFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetFilterFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetFilterFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetFilterFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/filter/get_filter_frontend_responses.go b/operations/filter/get_filter_frontend_responses.go new file mode 100644 index 00000000..df339541 --- /dev/null +++ b/operations/filter/get_filter_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetFilterFrontendOKCode is the HTTP code returned for type GetFilterFrontendOK +const GetFilterFrontendOKCode int = 200 + +/* +GetFilterFrontendOK Successful operation + +swagger:response getFilterFrontendOK +*/ +type GetFilterFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewGetFilterFrontendOK creates GetFilterFrontendOK with default headers values +func NewGetFilterFrontendOK() *GetFilterFrontendOK { + + return &GetFilterFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get filter frontend o k response +func (o *GetFilterFrontendOK) WithConfigurationVersion(configurationVersion string) *GetFilterFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get filter frontend o k response +func (o *GetFilterFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get filter frontend o k response +func (o *GetFilterFrontendOK) WithPayload(payload *models.Filter) *GetFilterFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get filter frontend o k response +func (o *GetFilterFrontendOK) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFilterFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetFilterFrontendNotFoundCode is the HTTP code returned for type GetFilterFrontendNotFound +const GetFilterFrontendNotFoundCode int = 404 + +/* +GetFilterFrontendNotFound The specified resource was not found + +swagger:response getFilterFrontendNotFound +*/ +type GetFilterFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetFilterFrontendNotFound creates GetFilterFrontendNotFound with default headers values +func NewGetFilterFrontendNotFound() *GetFilterFrontendNotFound { + + return &GetFilterFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get filter frontend not found response +func (o *GetFilterFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetFilterFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get filter frontend not found response +func (o *GetFilterFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get filter frontend not found response +func (o *GetFilterFrontendNotFound) WithPayload(payload *models.Error) *GetFilterFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get filter frontend not found response +func (o *GetFilterFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFilterFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetFilterFrontendDefault General Error + +swagger:response getFilterFrontendDefault +*/ +type GetFilterFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetFilterFrontendDefault creates GetFilterFrontendDefault with default headers values +func NewGetFilterFrontendDefault(code int) *GetFilterFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetFilterFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get filter frontend default response +func (o *GetFilterFrontendDefault) WithStatusCode(code int) *GetFilterFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get filter frontend default response +func (o *GetFilterFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get filter frontend default response +func (o *GetFilterFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetFilterFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get filter frontend default response +func (o *GetFilterFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get filter frontend default response +func (o *GetFilterFrontendDefault) WithPayload(payload *models.Error) *GetFilterFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get filter frontend default response +func (o *GetFilterFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetFilterFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/get_filter_frontend_urlbuilder.go b/operations/filter/get_filter_frontend_urlbuilder.go new file mode 100644 index 00000000..4cdff3bd --- /dev/null +++ b/operations/filter/get_filter_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetFilterFrontendURL generates an URL for the get filter frontend operation +type GetFilterFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFilterFrontendURL) WithBasePath(bp string) *GetFilterFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetFilterFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetFilterFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetFilterFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetFilterFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetFilterFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetFilterFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetFilterFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetFilterFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetFilterFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetFilterFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/get_filter_parameters.go b/operations/filter/get_filter_parameters.go deleted file mode 100644 index 4832e4bb..00000000 --- a/operations/filter/get_filter_parameters.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetFilterParams creates a new GetFilterParams object -// no default values defined in spec. -func NewGetFilterParams() GetFilterParams { - - return GetFilterParams{} -} - -// GetFilterParams contains all the bound params for the get filter operation -// typically these are obtained from a http.Request -// -// swagger:parameters getFilter -type GetFilterParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Filter ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetFilterParams() beforehand. -func (o *GetFilterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *GetFilterParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetFilterParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetFilterParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetFilterParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetFilterParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/filter/get_filter_responses.go b/operations/filter/get_filter_responses.go deleted file mode 100644 index 69e60f5c..00000000 --- a/operations/filter/get_filter_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetFilterOKCode is the HTTP code returned for type GetFilterOK -const GetFilterOKCode int = 200 - -/*GetFilterOK Successful operation - -swagger:response getFilterOK -*/ -type GetFilterOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetFilterOKBody `json:"body,omitempty"` -} - -// NewGetFilterOK creates GetFilterOK with default headers values -func NewGetFilterOK() *GetFilterOK { - - return &GetFilterOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get filter o k response -func (o *GetFilterOK) WithConfigurationVersion(configurationVersion int64) *GetFilterOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get filter o k response -func (o *GetFilterOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get filter o k response -func (o *GetFilterOK) WithPayload(payload *GetFilterOKBody) *GetFilterOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get filter o k response -func (o *GetFilterOK) SetPayload(payload *GetFilterOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetFilterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetFilterNotFoundCode is the HTTP code returned for type GetFilterNotFound -const GetFilterNotFoundCode int = 404 - -/*GetFilterNotFound The specified resource was not found - -swagger:response getFilterNotFound -*/ -type GetFilterNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetFilterNotFound creates GetFilterNotFound with default headers values -func NewGetFilterNotFound() *GetFilterNotFound { - - return &GetFilterNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get filter not found response -func (o *GetFilterNotFound) WithConfigurationVersion(configurationVersion int64) *GetFilterNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get filter not found response -func (o *GetFilterNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get filter not found response -func (o *GetFilterNotFound) WithPayload(payload *models.Error) *GetFilterNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get filter not found response -func (o *GetFilterNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetFilterNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetFilterDefault General Error - -swagger:response getFilterDefault -*/ -type GetFilterDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetFilterDefault creates GetFilterDefault with default headers values -func NewGetFilterDefault(code int) *GetFilterDefault { - if code <= 0 { - code = 500 - } - - return &GetFilterDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get filter default response -func (o *GetFilterDefault) WithStatusCode(code int) *GetFilterDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get filter default response -func (o *GetFilterDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get filter default response -func (o *GetFilterDefault) WithConfigurationVersion(configurationVersion int64) *GetFilterDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get filter default response -func (o *GetFilterDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get filter default response -func (o *GetFilterDefault) WithPayload(payload *models.Error) *GetFilterDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get filter default response -func (o *GetFilterDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetFilterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/filter/get_filter_urlbuilder.go b/operations/filter/get_filter_urlbuilder.go deleted file mode 100644 index 30ccc863..00000000 --- a/operations/filter/get_filter_urlbuilder.go +++ /dev/null @@ -1,142 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// GetFilterURL generates an URL for the get filter operation -type GetFilterURL struct { - ID int64 - - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetFilterURL) WithBasePath(bp string) *GetFilterURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetFilterURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetFilterURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/filters/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on GetFilterURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetFilterURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetFilterURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetFilterURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetFilterURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetFilterURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetFilterURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/filter/get_filters.go b/operations/filter/get_filters.go deleted file mode 100644 index e56dc130..00000000 --- a/operations/filter/get_filters.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetFiltersHandlerFunc turns a function with the right signature into a get filters handler -type GetFiltersHandlerFunc func(GetFiltersParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetFiltersHandlerFunc) Handle(params GetFiltersParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetFiltersHandler interface for that can handle valid get filters params -type GetFiltersHandler interface { - Handle(GetFiltersParams, interface{}) middleware.Responder -} - -// NewGetFilters creates a new http.Handler for the get filters operation -func NewGetFilters(ctx *middleware.Context, handler GetFiltersHandler) *GetFilters { - return &GetFilters{Context: ctx, Handler: handler} -} - -/*GetFilters swagger:route GET /services/haproxy/configuration/filters Filter getFilters - -Return an array of all Filters - -Returns all Filters that are configured in specified parent. - -*/ -type GetFilters struct { - Context *middleware.Context - Handler GetFiltersHandler -} - -func (o *GetFilters) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetFiltersParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetFiltersOKBody get filters o k body -// swagger:model GetFiltersOKBody -type GetFiltersOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.Filters `json:"data"` -} - -// Validate validates this get filters o k body -func (o *GetFiltersOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetFiltersOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getFiltersOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getFiltersOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetFiltersOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetFiltersOKBody) UnmarshalBinary(b []byte) error { - var res GetFiltersOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/filter/get_filters_parameters.go b/operations/filter/get_filters_parameters.go deleted file mode 100644 index ee627e5c..00000000 --- a/operations/filter/get_filters_parameters.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetFiltersParams creates a new GetFiltersParams object -// no default values defined in spec. -func NewGetFiltersParams() GetFiltersParams { - - return GetFiltersParams{} -} - -// GetFiltersParams contains all the bound params for the get filters operation -// typically these are obtained from a http.Request -// -// swagger:parameters getFilters -type GetFiltersParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetFiltersParams() beforehand. -func (o *GetFiltersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetFiltersParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetFiltersParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetFiltersParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetFiltersParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/filter/get_filters_responses.go b/operations/filter/get_filters_responses.go deleted file mode 100644 index 03f917c4..00000000 --- a/operations/filter/get_filters_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetFiltersOKCode is the HTTP code returned for type GetFiltersOK -const GetFiltersOKCode int = 200 - -/*GetFiltersOK Successful operation - -swagger:response getFiltersOK -*/ -type GetFiltersOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetFiltersOKBody `json:"body,omitempty"` -} - -// NewGetFiltersOK creates GetFiltersOK with default headers values -func NewGetFiltersOK() *GetFiltersOK { - - return &GetFiltersOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get filters o k response -func (o *GetFiltersOK) WithConfigurationVersion(configurationVersion int64) *GetFiltersOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get filters o k response -func (o *GetFiltersOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get filters o k response -func (o *GetFiltersOK) WithPayload(payload *GetFiltersOKBody) *GetFiltersOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get filters o k response -func (o *GetFiltersOK) SetPayload(payload *GetFiltersOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetFiltersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetFiltersDefault General Error - -swagger:response getFiltersDefault -*/ -type GetFiltersDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetFiltersDefault creates GetFiltersDefault with default headers values -func NewGetFiltersDefault(code int) *GetFiltersDefault { - if code <= 0 { - code = 500 - } - - return &GetFiltersDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get filters default response -func (o *GetFiltersDefault) WithStatusCode(code int) *GetFiltersDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get filters default response -func (o *GetFiltersDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get filters default response -func (o *GetFiltersDefault) WithConfigurationVersion(configurationVersion int64) *GetFiltersDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get filters default response -func (o *GetFiltersDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get filters default response -func (o *GetFiltersDefault) WithPayload(payload *models.Error) *GetFiltersDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get filters default response -func (o *GetFiltersDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetFiltersDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/filter/get_filters_urlbuilder.go b/operations/filter/get_filters_urlbuilder.go deleted file mode 100644 index a2989e7f..00000000 --- a/operations/filter/get_filters_urlbuilder.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetFiltersURL generates an URL for the get filters operation -type GetFiltersURL struct { - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetFiltersURL) WithBasePath(bp string) *GetFiltersURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetFiltersURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetFiltersURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/filters" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetFiltersURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetFiltersURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetFiltersURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetFiltersURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetFiltersURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetFiltersURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/filter/replace_all_filter_backend.go b/operations/filter/replace_all_filter_backend.go new file mode 100644 index 00000000..4efcf569 --- /dev/null +++ b/operations/filter/replace_all_filter_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllFilterBackendHandlerFunc turns a function with the right signature into a replace all filter backend handler +type ReplaceAllFilterBackendHandlerFunc func(ReplaceAllFilterBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllFilterBackendHandlerFunc) Handle(params ReplaceAllFilterBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllFilterBackendHandler interface for that can handle valid replace all filter backend params +type ReplaceAllFilterBackendHandler interface { + Handle(ReplaceAllFilterBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllFilterBackend creates a new http.Handler for the replace all filter backend operation +func NewReplaceAllFilterBackend(ctx *middleware.Context, handler ReplaceAllFilterBackendHandler) *ReplaceAllFilterBackend { + return &ReplaceAllFilterBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllFilterBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/filters Filter replaceAllFilterBackend + +# Replace a Filter list + +Replaces a whole list of Filters with the list given in parameter +*/ +type ReplaceAllFilterBackend struct { + Context *middleware.Context + Handler ReplaceAllFilterBackendHandler +} + +func (o *ReplaceAllFilterBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllFilterBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/replace_all_filter_backend_parameters.go b/operations/filter/replace_all_filter_backend_parameters.go new file mode 100644 index 00000000..50d155c4 --- /dev/null +++ b/operations/filter/replace_all_filter_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllFilterBackendParams creates a new ReplaceAllFilterBackendParams object +// with the default values initialized. +func NewReplaceAllFilterBackendParams() ReplaceAllFilterBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllFilterBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllFilterBackendParams contains all the bound params for the replace all filter backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllFilterBackend +type ReplaceAllFilterBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.Filters + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllFilterBackendParams() beforehand. +func (o *ReplaceAllFilterBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Filters + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllFilterBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllFilterBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllFilterBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllFilterBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllFilterBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/replace_all_filter_backend_responses.go b/operations/filter/replace_all_filter_backend_responses.go new file mode 100644 index 00000000..81ef2380 --- /dev/null +++ b/operations/filter/replace_all_filter_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllFilterBackendOKCode is the HTTP code returned for type ReplaceAllFilterBackendOK +const ReplaceAllFilterBackendOKCode int = 200 + +/* +ReplaceAllFilterBackendOK All Filter lines replaced + +swagger:response replaceAllFilterBackendOK +*/ +type ReplaceAllFilterBackendOK struct { + + /* + In: Body + */ + Payload models.Filters `json:"body,omitempty"` +} + +// NewReplaceAllFilterBackendOK creates ReplaceAllFilterBackendOK with default headers values +func NewReplaceAllFilterBackendOK() *ReplaceAllFilterBackendOK { + + return &ReplaceAllFilterBackendOK{} +} + +// WithPayload adds the payload to the replace all filter backend o k response +func (o *ReplaceAllFilterBackendOK) WithPayload(payload models.Filters) *ReplaceAllFilterBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter backend o k response +func (o *ReplaceAllFilterBackendOK) SetPayload(payload models.Filters) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Filters{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllFilterBackendAcceptedCode is the HTTP code returned for type ReplaceAllFilterBackendAccepted +const ReplaceAllFilterBackendAcceptedCode int = 202 + +/* +ReplaceAllFilterBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllFilterBackendAccepted +*/ +type ReplaceAllFilterBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.Filters `json:"body,omitempty"` +} + +// NewReplaceAllFilterBackendAccepted creates ReplaceAllFilterBackendAccepted with default headers values +func NewReplaceAllFilterBackendAccepted() *ReplaceAllFilterBackendAccepted { + + return &ReplaceAllFilterBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all filter backend accepted response +func (o *ReplaceAllFilterBackendAccepted) WithReloadID(reloadID string) *ReplaceAllFilterBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all filter backend accepted response +func (o *ReplaceAllFilterBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all filter backend accepted response +func (o *ReplaceAllFilterBackendAccepted) WithPayload(payload models.Filters) *ReplaceAllFilterBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter backend accepted response +func (o *ReplaceAllFilterBackendAccepted) SetPayload(payload models.Filters) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Filters{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllFilterBackendBadRequestCode is the HTTP code returned for type ReplaceAllFilterBackendBadRequest +const ReplaceAllFilterBackendBadRequestCode int = 400 + +/* +ReplaceAllFilterBackendBadRequest Bad request + +swagger:response replaceAllFilterBackendBadRequest +*/ +type ReplaceAllFilterBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllFilterBackendBadRequest creates ReplaceAllFilterBackendBadRequest with default headers values +func NewReplaceAllFilterBackendBadRequest() *ReplaceAllFilterBackendBadRequest { + + return &ReplaceAllFilterBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all filter backend bad request response +func (o *ReplaceAllFilterBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllFilterBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all filter backend bad request response +func (o *ReplaceAllFilterBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all filter backend bad request response +func (o *ReplaceAllFilterBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllFilterBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter backend bad request response +func (o *ReplaceAllFilterBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllFilterBackendDefault General Error + +swagger:response replaceAllFilterBackendDefault +*/ +type ReplaceAllFilterBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllFilterBackendDefault creates ReplaceAllFilterBackendDefault with default headers values +func NewReplaceAllFilterBackendDefault(code int) *ReplaceAllFilterBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllFilterBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all filter backend default response +func (o *ReplaceAllFilterBackendDefault) WithStatusCode(code int) *ReplaceAllFilterBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all filter backend default response +func (o *ReplaceAllFilterBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all filter backend default response +func (o *ReplaceAllFilterBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllFilterBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all filter backend default response +func (o *ReplaceAllFilterBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all filter backend default response +func (o *ReplaceAllFilterBackendDefault) WithPayload(payload *models.Error) *ReplaceAllFilterBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter backend default response +func (o *ReplaceAllFilterBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/replace_all_filter_backend_urlbuilder.go b/operations/filter/replace_all_filter_backend_urlbuilder.go new file mode 100644 index 00000000..f218296c --- /dev/null +++ b/operations/filter/replace_all_filter_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllFilterBackendURL generates an URL for the replace all filter backend operation +type ReplaceAllFilterBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllFilterBackendURL) WithBasePath(bp string) *ReplaceAllFilterBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllFilterBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllFilterBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/filters" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllFilterBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllFilterBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllFilterBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllFilterBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllFilterBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllFilterBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllFilterBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/replace_all_filter_frontend.go b/operations/filter/replace_all_filter_frontend.go new file mode 100644 index 00000000..aca3bf40 --- /dev/null +++ b/operations/filter/replace_all_filter_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllFilterFrontendHandlerFunc turns a function with the right signature into a replace all filter frontend handler +type ReplaceAllFilterFrontendHandlerFunc func(ReplaceAllFilterFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllFilterFrontendHandlerFunc) Handle(params ReplaceAllFilterFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllFilterFrontendHandler interface for that can handle valid replace all filter frontend params +type ReplaceAllFilterFrontendHandler interface { + Handle(ReplaceAllFilterFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllFilterFrontend creates a new http.Handler for the replace all filter frontend operation +func NewReplaceAllFilterFrontend(ctx *middleware.Context, handler ReplaceAllFilterFrontendHandler) *ReplaceAllFilterFrontend { + return &ReplaceAllFilterFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllFilterFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/filters Filter replaceAllFilterFrontend + +# Replace a Filter list + +Replaces a whole list of Filters with the list given in parameter +*/ +type ReplaceAllFilterFrontend struct { + Context *middleware.Context + Handler ReplaceAllFilterFrontendHandler +} + +func (o *ReplaceAllFilterFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllFilterFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/replace_all_filter_frontend_parameters.go b/operations/filter/replace_all_filter_frontend_parameters.go new file mode 100644 index 00000000..a29bfad9 --- /dev/null +++ b/operations/filter/replace_all_filter_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllFilterFrontendParams creates a new ReplaceAllFilterFrontendParams object +// with the default values initialized. +func NewReplaceAllFilterFrontendParams() ReplaceAllFilterFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllFilterFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllFilterFrontendParams contains all the bound params for the replace all filter frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllFilterFrontend +type ReplaceAllFilterFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.Filters + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllFilterFrontendParams() beforehand. +func (o *ReplaceAllFilterFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Filters + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllFilterFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllFilterFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllFilterFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllFilterFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllFilterFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/replace_all_filter_frontend_responses.go b/operations/filter/replace_all_filter_frontend_responses.go new file mode 100644 index 00000000..ce9e2295 --- /dev/null +++ b/operations/filter/replace_all_filter_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllFilterFrontendOKCode is the HTTP code returned for type ReplaceAllFilterFrontendOK +const ReplaceAllFilterFrontendOKCode int = 200 + +/* +ReplaceAllFilterFrontendOK All Filter lines replaced + +swagger:response replaceAllFilterFrontendOK +*/ +type ReplaceAllFilterFrontendOK struct { + + /* + In: Body + */ + Payload models.Filters `json:"body,omitempty"` +} + +// NewReplaceAllFilterFrontendOK creates ReplaceAllFilterFrontendOK with default headers values +func NewReplaceAllFilterFrontendOK() *ReplaceAllFilterFrontendOK { + + return &ReplaceAllFilterFrontendOK{} +} + +// WithPayload adds the payload to the replace all filter frontend o k response +func (o *ReplaceAllFilterFrontendOK) WithPayload(payload models.Filters) *ReplaceAllFilterFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter frontend o k response +func (o *ReplaceAllFilterFrontendOK) SetPayload(payload models.Filters) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Filters{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllFilterFrontendAcceptedCode is the HTTP code returned for type ReplaceAllFilterFrontendAccepted +const ReplaceAllFilterFrontendAcceptedCode int = 202 + +/* +ReplaceAllFilterFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllFilterFrontendAccepted +*/ +type ReplaceAllFilterFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.Filters `json:"body,omitempty"` +} + +// NewReplaceAllFilterFrontendAccepted creates ReplaceAllFilterFrontendAccepted with default headers values +func NewReplaceAllFilterFrontendAccepted() *ReplaceAllFilterFrontendAccepted { + + return &ReplaceAllFilterFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all filter frontend accepted response +func (o *ReplaceAllFilterFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllFilterFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all filter frontend accepted response +func (o *ReplaceAllFilterFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all filter frontend accepted response +func (o *ReplaceAllFilterFrontendAccepted) WithPayload(payload models.Filters) *ReplaceAllFilterFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter frontend accepted response +func (o *ReplaceAllFilterFrontendAccepted) SetPayload(payload models.Filters) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Filters{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllFilterFrontendBadRequestCode is the HTTP code returned for type ReplaceAllFilterFrontendBadRequest +const ReplaceAllFilterFrontendBadRequestCode int = 400 + +/* +ReplaceAllFilterFrontendBadRequest Bad request + +swagger:response replaceAllFilterFrontendBadRequest +*/ +type ReplaceAllFilterFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllFilterFrontendBadRequest creates ReplaceAllFilterFrontendBadRequest with default headers values +func NewReplaceAllFilterFrontendBadRequest() *ReplaceAllFilterFrontendBadRequest { + + return &ReplaceAllFilterFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all filter frontend bad request response +func (o *ReplaceAllFilterFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllFilterFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all filter frontend bad request response +func (o *ReplaceAllFilterFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all filter frontend bad request response +func (o *ReplaceAllFilterFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllFilterFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter frontend bad request response +func (o *ReplaceAllFilterFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllFilterFrontendDefault General Error + +swagger:response replaceAllFilterFrontendDefault +*/ +type ReplaceAllFilterFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllFilterFrontendDefault creates ReplaceAllFilterFrontendDefault with default headers values +func NewReplaceAllFilterFrontendDefault(code int) *ReplaceAllFilterFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllFilterFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all filter frontend default response +func (o *ReplaceAllFilterFrontendDefault) WithStatusCode(code int) *ReplaceAllFilterFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all filter frontend default response +func (o *ReplaceAllFilterFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all filter frontend default response +func (o *ReplaceAllFilterFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllFilterFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all filter frontend default response +func (o *ReplaceAllFilterFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all filter frontend default response +func (o *ReplaceAllFilterFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllFilterFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all filter frontend default response +func (o *ReplaceAllFilterFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllFilterFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/replace_all_filter_frontend_urlbuilder.go b/operations/filter/replace_all_filter_frontend_urlbuilder.go new file mode 100644 index 00000000..1d0d7437 --- /dev/null +++ b/operations/filter/replace_all_filter_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllFilterFrontendURL generates an URL for the replace all filter frontend operation +type ReplaceAllFilterFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllFilterFrontendURL) WithBasePath(bp string) *ReplaceAllFilterFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllFilterFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllFilterFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/filters" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllFilterFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllFilterFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllFilterFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllFilterFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllFilterFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllFilterFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllFilterFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/replace_filter.go b/operations/filter/replace_filter.go deleted file mode 100644 index 70ac912b..00000000 --- a/operations/filter/replace_filter.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceFilterHandlerFunc turns a function with the right signature into a replace filter handler -type ReplaceFilterHandlerFunc func(ReplaceFilterParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceFilterHandlerFunc) Handle(params ReplaceFilterParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceFilterHandler interface for that can handle valid replace filter params -type ReplaceFilterHandler interface { - Handle(ReplaceFilterParams, interface{}) middleware.Responder -} - -// NewReplaceFilter creates a new http.Handler for the replace filter operation -func NewReplaceFilter(ctx *middleware.Context, handler ReplaceFilterHandler) *ReplaceFilter { - return &ReplaceFilter{Context: ctx, Handler: handler} -} - -/*ReplaceFilter swagger:route PUT /services/haproxy/configuration/filters/{id} Filter replaceFilter - -Replace a Filter - -Replaces a Filter configuration by it's ID in the specified parent. - -*/ -type ReplaceFilter struct { - Context *middleware.Context - Handler ReplaceFilterHandler -} - -func (o *ReplaceFilter) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceFilterParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/filter/replace_filter_backend.go b/operations/filter/replace_filter_backend.go new file mode 100644 index 00000000..3266ec60 --- /dev/null +++ b/operations/filter/replace_filter_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceFilterBackendHandlerFunc turns a function with the right signature into a replace filter backend handler +type ReplaceFilterBackendHandlerFunc func(ReplaceFilterBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceFilterBackendHandlerFunc) Handle(params ReplaceFilterBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceFilterBackendHandler interface for that can handle valid replace filter backend params +type ReplaceFilterBackendHandler interface { + Handle(ReplaceFilterBackendParams, interface{}) middleware.Responder +} + +// NewReplaceFilterBackend creates a new http.Handler for the replace filter backend operation +func NewReplaceFilterBackend(ctx *middleware.Context, handler ReplaceFilterBackendHandler) *ReplaceFilterBackend { + return &ReplaceFilterBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceFilterBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/filters/{index} Filter replaceFilterBackend + +# Replace a Filter + +Replaces a Filter configuration by it's index in the specified parent. +*/ +type ReplaceFilterBackend struct { + Context *middleware.Context + Handler ReplaceFilterBackendHandler +} + +func (o *ReplaceFilterBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceFilterBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/replace_filter_backend_parameters.go b/operations/filter/replace_filter_backend_parameters.go new file mode 100644 index 00000000..1aed1d8f --- /dev/null +++ b/operations/filter/replace_filter_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceFilterBackendParams creates a new ReplaceFilterBackendParams object +// with the default values initialized. +func NewReplaceFilterBackendParams() ReplaceFilterBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceFilterBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceFilterBackendParams contains all the bound params for the replace filter backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceFilterBackend +type ReplaceFilterBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Filter + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceFilterBackendParams() beforehand. +func (o *ReplaceFilterBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Filter + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceFilterBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceFilterBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceFilterBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceFilterBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceFilterBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceFilterBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/replace_filter_backend_responses.go b/operations/filter/replace_filter_backend_responses.go new file mode 100644 index 00000000..52054750 --- /dev/null +++ b/operations/filter/replace_filter_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceFilterBackendOKCode is the HTTP code returned for type ReplaceFilterBackendOK +const ReplaceFilterBackendOKCode int = 200 + +/* +ReplaceFilterBackendOK Filter replaced + +swagger:response replaceFilterBackendOK +*/ +type ReplaceFilterBackendOK struct { + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewReplaceFilterBackendOK creates ReplaceFilterBackendOK with default headers values +func NewReplaceFilterBackendOK() *ReplaceFilterBackendOK { + + return &ReplaceFilterBackendOK{} +} + +// WithPayload adds the payload to the replace filter backend o k response +func (o *ReplaceFilterBackendOK) WithPayload(payload *models.Filter) *ReplaceFilterBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter backend o k response +func (o *ReplaceFilterBackendOK) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFilterBackendAcceptedCode is the HTTP code returned for type ReplaceFilterBackendAccepted +const ReplaceFilterBackendAcceptedCode int = 202 + +/* +ReplaceFilterBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceFilterBackendAccepted +*/ +type ReplaceFilterBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewReplaceFilterBackendAccepted creates ReplaceFilterBackendAccepted with default headers values +func NewReplaceFilterBackendAccepted() *ReplaceFilterBackendAccepted { + + return &ReplaceFilterBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace filter backend accepted response +func (o *ReplaceFilterBackendAccepted) WithReloadID(reloadID string) *ReplaceFilterBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace filter backend accepted response +func (o *ReplaceFilterBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace filter backend accepted response +func (o *ReplaceFilterBackendAccepted) WithPayload(payload *models.Filter) *ReplaceFilterBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter backend accepted response +func (o *ReplaceFilterBackendAccepted) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFilterBackendBadRequestCode is the HTTP code returned for type ReplaceFilterBackendBadRequest +const ReplaceFilterBackendBadRequestCode int = 400 + +/* +ReplaceFilterBackendBadRequest Bad request + +swagger:response replaceFilterBackendBadRequest +*/ +type ReplaceFilterBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFilterBackendBadRequest creates ReplaceFilterBackendBadRequest with default headers values +func NewReplaceFilterBackendBadRequest() *ReplaceFilterBackendBadRequest { + + return &ReplaceFilterBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace filter backend bad request response +func (o *ReplaceFilterBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceFilterBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace filter backend bad request response +func (o *ReplaceFilterBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace filter backend bad request response +func (o *ReplaceFilterBackendBadRequest) WithPayload(payload *models.Error) *ReplaceFilterBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter backend bad request response +func (o *ReplaceFilterBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFilterBackendNotFoundCode is the HTTP code returned for type ReplaceFilterBackendNotFound +const ReplaceFilterBackendNotFoundCode int = 404 + +/* +ReplaceFilterBackendNotFound The specified resource was not found + +swagger:response replaceFilterBackendNotFound +*/ +type ReplaceFilterBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFilterBackendNotFound creates ReplaceFilterBackendNotFound with default headers values +func NewReplaceFilterBackendNotFound() *ReplaceFilterBackendNotFound { + + return &ReplaceFilterBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace filter backend not found response +func (o *ReplaceFilterBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceFilterBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace filter backend not found response +func (o *ReplaceFilterBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace filter backend not found response +func (o *ReplaceFilterBackendNotFound) WithPayload(payload *models.Error) *ReplaceFilterBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter backend not found response +func (o *ReplaceFilterBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceFilterBackendDefault General Error + +swagger:response replaceFilterBackendDefault +*/ +type ReplaceFilterBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFilterBackendDefault creates ReplaceFilterBackendDefault with default headers values +func NewReplaceFilterBackendDefault(code int) *ReplaceFilterBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceFilterBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace filter backend default response +func (o *ReplaceFilterBackendDefault) WithStatusCode(code int) *ReplaceFilterBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace filter backend default response +func (o *ReplaceFilterBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace filter backend default response +func (o *ReplaceFilterBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceFilterBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace filter backend default response +func (o *ReplaceFilterBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace filter backend default response +func (o *ReplaceFilterBackendDefault) WithPayload(payload *models.Error) *ReplaceFilterBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter backend default response +func (o *ReplaceFilterBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/replace_filter_backend_urlbuilder.go b/operations/filter/replace_filter_backend_urlbuilder.go new file mode 100644 index 00000000..cc80867d --- /dev/null +++ b/operations/filter/replace_filter_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceFilterBackendURL generates an URL for the replace filter backend operation +type ReplaceFilterBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceFilterBackendURL) WithBasePath(bp string) *ReplaceFilterBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceFilterBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceFilterBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceFilterBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceFilterBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceFilterBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceFilterBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceFilterBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceFilterBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceFilterBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceFilterBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/replace_filter_frontend.go b/operations/filter/replace_filter_frontend.go new file mode 100644 index 00000000..3d16f7eb --- /dev/null +++ b/operations/filter/replace_filter_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceFilterFrontendHandlerFunc turns a function with the right signature into a replace filter frontend handler +type ReplaceFilterFrontendHandlerFunc func(ReplaceFilterFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceFilterFrontendHandlerFunc) Handle(params ReplaceFilterFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceFilterFrontendHandler interface for that can handle valid replace filter frontend params +type ReplaceFilterFrontendHandler interface { + Handle(ReplaceFilterFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceFilterFrontend creates a new http.Handler for the replace filter frontend operation +func NewReplaceFilterFrontend(ctx *middleware.Context, handler ReplaceFilterFrontendHandler) *ReplaceFilterFrontend { + return &ReplaceFilterFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceFilterFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/filters/{index} Filter replaceFilterFrontend + +# Replace a Filter + +Replaces a Filter configuration by it's index in the specified parent. +*/ +type ReplaceFilterFrontend struct { + Context *middleware.Context + Handler ReplaceFilterFrontendHandler +} + +func (o *ReplaceFilterFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceFilterFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/filter/replace_filter_frontend_parameters.go b/operations/filter/replace_filter_frontend_parameters.go new file mode 100644 index 00000000..f302cb4c --- /dev/null +++ b/operations/filter/replace_filter_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceFilterFrontendParams creates a new ReplaceFilterFrontendParams object +// with the default values initialized. +func NewReplaceFilterFrontendParams() ReplaceFilterFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceFilterFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceFilterFrontendParams contains all the bound params for the replace filter frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceFilterFrontend +type ReplaceFilterFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Filter + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Filter Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceFilterFrontendParams() beforehand. +func (o *ReplaceFilterFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Filter + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceFilterFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceFilterFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceFilterFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceFilterFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceFilterFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceFilterFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/filter/replace_filter_frontend_responses.go b/operations/filter/replace_filter_frontend_responses.go new file mode 100644 index 00000000..4b7a6526 --- /dev/null +++ b/operations/filter/replace_filter_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceFilterFrontendOKCode is the HTTP code returned for type ReplaceFilterFrontendOK +const ReplaceFilterFrontendOKCode int = 200 + +/* +ReplaceFilterFrontendOK Filter replaced + +swagger:response replaceFilterFrontendOK +*/ +type ReplaceFilterFrontendOK struct { + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewReplaceFilterFrontendOK creates ReplaceFilterFrontendOK with default headers values +func NewReplaceFilterFrontendOK() *ReplaceFilterFrontendOK { + + return &ReplaceFilterFrontendOK{} +} + +// WithPayload adds the payload to the replace filter frontend o k response +func (o *ReplaceFilterFrontendOK) WithPayload(payload *models.Filter) *ReplaceFilterFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter frontend o k response +func (o *ReplaceFilterFrontendOK) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFilterFrontendAcceptedCode is the HTTP code returned for type ReplaceFilterFrontendAccepted +const ReplaceFilterFrontendAcceptedCode int = 202 + +/* +ReplaceFilterFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceFilterFrontendAccepted +*/ +type ReplaceFilterFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Filter `json:"body,omitempty"` +} + +// NewReplaceFilterFrontendAccepted creates ReplaceFilterFrontendAccepted with default headers values +func NewReplaceFilterFrontendAccepted() *ReplaceFilterFrontendAccepted { + + return &ReplaceFilterFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace filter frontend accepted response +func (o *ReplaceFilterFrontendAccepted) WithReloadID(reloadID string) *ReplaceFilterFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace filter frontend accepted response +func (o *ReplaceFilterFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace filter frontend accepted response +func (o *ReplaceFilterFrontendAccepted) WithPayload(payload *models.Filter) *ReplaceFilterFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter frontend accepted response +func (o *ReplaceFilterFrontendAccepted) SetPayload(payload *models.Filter) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFilterFrontendBadRequestCode is the HTTP code returned for type ReplaceFilterFrontendBadRequest +const ReplaceFilterFrontendBadRequestCode int = 400 + +/* +ReplaceFilterFrontendBadRequest Bad request + +swagger:response replaceFilterFrontendBadRequest +*/ +type ReplaceFilterFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFilterFrontendBadRequest creates ReplaceFilterFrontendBadRequest with default headers values +func NewReplaceFilterFrontendBadRequest() *ReplaceFilterFrontendBadRequest { + + return &ReplaceFilterFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace filter frontend bad request response +func (o *ReplaceFilterFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceFilterFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace filter frontend bad request response +func (o *ReplaceFilterFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace filter frontend bad request response +func (o *ReplaceFilterFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceFilterFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter frontend bad request response +func (o *ReplaceFilterFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceFilterFrontendNotFoundCode is the HTTP code returned for type ReplaceFilterFrontendNotFound +const ReplaceFilterFrontendNotFoundCode int = 404 + +/* +ReplaceFilterFrontendNotFound The specified resource was not found + +swagger:response replaceFilterFrontendNotFound +*/ +type ReplaceFilterFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFilterFrontendNotFound creates ReplaceFilterFrontendNotFound with default headers values +func NewReplaceFilterFrontendNotFound() *ReplaceFilterFrontendNotFound { + + return &ReplaceFilterFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace filter frontend not found response +func (o *ReplaceFilterFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceFilterFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace filter frontend not found response +func (o *ReplaceFilterFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace filter frontend not found response +func (o *ReplaceFilterFrontendNotFound) WithPayload(payload *models.Error) *ReplaceFilterFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter frontend not found response +func (o *ReplaceFilterFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceFilterFrontendDefault General Error + +swagger:response replaceFilterFrontendDefault +*/ +type ReplaceFilterFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceFilterFrontendDefault creates ReplaceFilterFrontendDefault with default headers values +func NewReplaceFilterFrontendDefault(code int) *ReplaceFilterFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceFilterFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace filter frontend default response +func (o *ReplaceFilterFrontendDefault) WithStatusCode(code int) *ReplaceFilterFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace filter frontend default response +func (o *ReplaceFilterFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace filter frontend default response +func (o *ReplaceFilterFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceFilterFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace filter frontend default response +func (o *ReplaceFilterFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace filter frontend default response +func (o *ReplaceFilterFrontendDefault) WithPayload(payload *models.Error) *ReplaceFilterFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace filter frontend default response +func (o *ReplaceFilterFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceFilterFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/filter/replace_filter_frontend_urlbuilder.go b/operations/filter/replace_filter_frontend_urlbuilder.go new file mode 100644 index 00000000..07383f6f --- /dev/null +++ b/operations/filter/replace_filter_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package filter + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceFilterFrontendURL generates an URL for the replace filter frontend operation +type ReplaceFilterFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceFilterFrontendURL) WithBasePath(bp string) *ReplaceFilterFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceFilterFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceFilterFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/filters/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceFilterFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceFilterFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceFilterFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceFilterFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceFilterFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceFilterFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceFilterFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceFilterFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/filter/replace_filter_parameters.go b/operations/filter/replace_filter_parameters.go deleted file mode 100644 index 9356c6f6..00000000 --- a/operations/filter/replace_filter_parameters.go +++ /dev/null @@ -1,302 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceFilterParams creates a new ReplaceFilterParams object -// with the default values initialized. -func NewReplaceFilterParams() ReplaceFilterParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceFilterParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceFilterParams contains all the bound params for the replace filter operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceFilter -type ReplaceFilterParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.Filter - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Filter ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceFilterParams() beforehand. -func (o *ReplaceFilterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.Filter - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceFilterParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceFilterParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *ReplaceFilterParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *ReplaceFilterParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *ReplaceFilterParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *ReplaceFilterParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceFilterParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceFilterParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/filter/replace_filter_responses.go b/operations/filter/replace_filter_responses.go deleted file mode 100644 index 7bae5bcb..00000000 --- a/operations/filter/replace_filter_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceFilterOKCode is the HTTP code returned for type ReplaceFilterOK -const ReplaceFilterOKCode int = 200 - -/*ReplaceFilterOK Filter replaced - -swagger:response replaceFilterOK -*/ -type ReplaceFilterOK struct { - - /* - In: Body - */ - Payload *models.Filter `json:"body,omitempty"` -} - -// NewReplaceFilterOK creates ReplaceFilterOK with default headers values -func NewReplaceFilterOK() *ReplaceFilterOK { - - return &ReplaceFilterOK{} -} - -// WithPayload adds the payload to the replace filter o k response -func (o *ReplaceFilterOK) WithPayload(payload *models.Filter) *ReplaceFilterOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace filter o k response -func (o *ReplaceFilterOK) SetPayload(payload *models.Filter) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceFilterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceFilterAcceptedCode is the HTTP code returned for type ReplaceFilterAccepted -const ReplaceFilterAcceptedCode int = 202 - -/*ReplaceFilterAccepted Configuration change accepted and reload requested - -swagger:response replaceFilterAccepted -*/ -type ReplaceFilterAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.Filter `json:"body,omitempty"` -} - -// NewReplaceFilterAccepted creates ReplaceFilterAccepted with default headers values -func NewReplaceFilterAccepted() *ReplaceFilterAccepted { - - return &ReplaceFilterAccepted{} -} - -// WithReloadID adds the reloadId to the replace filter accepted response -func (o *ReplaceFilterAccepted) WithReloadID(reloadID string) *ReplaceFilterAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace filter accepted response -func (o *ReplaceFilterAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace filter accepted response -func (o *ReplaceFilterAccepted) WithPayload(payload *models.Filter) *ReplaceFilterAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace filter accepted response -func (o *ReplaceFilterAccepted) SetPayload(payload *models.Filter) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceFilterAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceFilterBadRequestCode is the HTTP code returned for type ReplaceFilterBadRequest -const ReplaceFilterBadRequestCode int = 400 - -/*ReplaceFilterBadRequest Bad request - -swagger:response replaceFilterBadRequest -*/ -type ReplaceFilterBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceFilterBadRequest creates ReplaceFilterBadRequest with default headers values -func NewReplaceFilterBadRequest() *ReplaceFilterBadRequest { - - return &ReplaceFilterBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace filter bad request response -func (o *ReplaceFilterBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceFilterBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace filter bad request response -func (o *ReplaceFilterBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace filter bad request response -func (o *ReplaceFilterBadRequest) WithPayload(payload *models.Error) *ReplaceFilterBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace filter bad request response -func (o *ReplaceFilterBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceFilterBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceFilterNotFoundCode is the HTTP code returned for type ReplaceFilterNotFound -const ReplaceFilterNotFoundCode int = 404 - -/*ReplaceFilterNotFound The specified resource was not found - -swagger:response replaceFilterNotFound -*/ -type ReplaceFilterNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceFilterNotFound creates ReplaceFilterNotFound with default headers values -func NewReplaceFilterNotFound() *ReplaceFilterNotFound { - - return &ReplaceFilterNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace filter not found response -func (o *ReplaceFilterNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceFilterNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace filter not found response -func (o *ReplaceFilterNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace filter not found response -func (o *ReplaceFilterNotFound) WithPayload(payload *models.Error) *ReplaceFilterNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace filter not found response -func (o *ReplaceFilterNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceFilterNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceFilterDefault General Error - -swagger:response replaceFilterDefault -*/ -type ReplaceFilterDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceFilterDefault creates ReplaceFilterDefault with default headers values -func NewReplaceFilterDefault(code int) *ReplaceFilterDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceFilterDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace filter default response -func (o *ReplaceFilterDefault) WithStatusCode(code int) *ReplaceFilterDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace filter default response -func (o *ReplaceFilterDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace filter default response -func (o *ReplaceFilterDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceFilterDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace filter default response -func (o *ReplaceFilterDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace filter default response -func (o *ReplaceFilterDefault) WithPayload(payload *models.Error) *ReplaceFilterDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace filter default response -func (o *ReplaceFilterDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceFilterDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/filter/replace_filter_urlbuilder.go b/operations/filter/replace_filter_urlbuilder.go deleted file mode 100644 index 152fe5bd..00000000 --- a/operations/filter/replace_filter_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package filter - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceFilterURL generates an URL for the replace filter operation -type ReplaceFilterURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceFilterURL) WithBasePath(bp string) *ReplaceFilterURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceFilterURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceFilterURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/filters/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on ReplaceFilterURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceFilterURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceFilterURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceFilterURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceFilterURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceFilterURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceFilterURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/frontend/create_frontend.go b/operations/frontend/create_frontend.go index f114a535..7f2b2ae1 100644 --- a/operations/frontend/create_frontend.go +++ b/operations/frontend/create_frontend.go @@ -23,7 +23,7 @@ package frontend import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // CreateFrontendHandlerFunc turns a function with the right signature into a create frontend handler @@ -44,12 +44,12 @@ func NewCreateFrontend(ctx *middleware.Context, handler CreateFrontendHandler) * return &CreateFrontend{Context: ctx, Handler: handler} } -/*CreateFrontend swagger:route POST /services/haproxy/configuration/frontends Frontend createFrontend +/* + CreateFrontend swagger:route POST /services/haproxy/configuration/frontends Frontend createFrontend -Add a frontend +# Add a frontend Adds a new frontend to the configuration file. - */ type CreateFrontend struct { Context *middleware.Context @@ -59,21 +59,20 @@ type CreateFrontend struct { func (o *CreateFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewCreateFrontendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *CreateFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/frontend/create_frontend_parameters.go b/operations/frontend/create_frontend_parameters.go index 14795309..7baecf28 100644 --- a/operations/frontend/create_frontend_parameters.go +++ b/operations/frontend/create_frontend_parameters.go @@ -27,11 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewCreateFrontendParams creates a new CreateFrontendParams object @@ -42,10 +41,13 @@ func NewCreateFrontendParams() CreateFrontendParams { // initialize parameters with default values forceReloadDefault = bool(false) + fullSectionDefault = bool(false) ) return CreateFrontendParams{ ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, } } @@ -68,6 +70,11 @@ type CreateFrontendParams struct { Default: false */ ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -94,7 +101,7 @@ func (o *CreateFrontendParams) BindRequest(r *http.Request, route *middleware.Ma var body models.Frontend if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -109,13 +116,19 @@ func (o *CreateFrontendParams) BindRequest(r *http.Request, route *middleware.Ma } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) @@ -125,7 +138,6 @@ func (o *CreateFrontendParams) BindRequest(r *http.Request, route *middleware.Ma if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -141,6 +153,7 @@ func (o *CreateFrontendParams) bindForceReload(rawData []string, hasKey bool, fo // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewCreateFrontendParams() return nil @@ -155,6 +168,30 @@ func (o *CreateFrontendParams) bindForceReload(rawData []string, hasKey bool, fo return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateFrontendParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindTransactionID binds and validates parameter TransactionID from query. func (o *CreateFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -164,10 +201,10 @@ func (o *CreateFrontendParams) bindTransactionID(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -182,6 +219,7 @@ func (o *CreateFrontendParams) bindVersion(rawData []string, hasKey bool, format // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/frontend/create_frontend_responses.go b/operations/frontend/create_frontend_responses.go index ca26db84..045c601f 100644 --- a/operations/frontend/create_frontend_responses.go +++ b/operations/frontend/create_frontend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // CreateFrontendCreatedCode is the HTTP code returned for type CreateFrontendCreated const CreateFrontendCreatedCode int = 201 -/*CreateFrontendCreated Frontend created +/* +CreateFrontendCreated Frontend created swagger:response createFrontendCreated */ @@ -76,7 +76,8 @@ func (o *CreateFrontendCreated) WriteResponse(rw http.ResponseWriter, producer r // CreateFrontendAcceptedCode is the HTTP code returned for type CreateFrontendAccepted const CreateFrontendAcceptedCode int = 202 -/*CreateFrontendAccepted Configuration change accepted and reload requested +/* +CreateFrontendAccepted Configuration change accepted and reload requested swagger:response createFrontendAccepted */ @@ -142,7 +143,8 @@ func (o *CreateFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer // CreateFrontendBadRequestCode is the HTTP code returned for type CreateFrontendBadRequest const CreateFrontendBadRequestCode int = 400 -/*CreateFrontendBadRequest Bad request +/* +CreateFrontendBadRequest Bad request swagger:response createFrontendBadRequest */ @@ -150,7 +152,7 @@ type CreateFrontendBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewCreateFrontendBadRequest() *CreateFrontendBadRequest { } // WithConfigurationVersion adds the configurationVersion to the create frontend bad request response -func (o *CreateFrontendBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateFrontendBadRequest { +func (o *CreateFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateFrontendBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create frontend bad request response -func (o *CreateFrontendBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *CreateFrontendBadRequest) WriteResponse(rw http.ResponseWriter, produce // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *CreateFrontendBadRequest) WriteResponse(rw http.ResponseWriter, produce // CreateFrontendConflictCode is the HTTP code returned for type CreateFrontendConflict const CreateFrontendConflictCode int = 409 -/*CreateFrontendConflict The specified resource already exists +/* +CreateFrontendConflict The specified resource already exists swagger:response createFrontendConflict */ @@ -216,7 +219,7 @@ type CreateFrontendConflict struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewCreateFrontendConflict() *CreateFrontendConflict { } // WithConfigurationVersion adds the configurationVersion to the create frontend conflict response -func (o *CreateFrontendConflict) WithConfigurationVersion(configurationVersion int64) *CreateFrontendConflict { +func (o *CreateFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateFrontendConflict { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create frontend conflict response -func (o *CreateFrontendConflict) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateFrontendConflict) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *CreateFrontendConflict) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *CreateFrontendConflict) WriteResponse(rw http.ResponseWriter, producer } } -/*CreateFrontendDefault General Error +/* +CreateFrontendDefault General Error swagger:response createFrontendDefault */ @@ -280,7 +284,7 @@ type CreateFrontendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *CreateFrontendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the create frontend default response -func (o *CreateFrontendDefault) WithConfigurationVersion(configurationVersion int64) *CreateFrontendDefault { +func (o *CreateFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateFrontendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create frontend default response -func (o *CreateFrontendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateFrontendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *CreateFrontendDefault) WriteResponse(rw http.ResponseWriter, producer r // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/frontend/create_frontend_urlbuilder.go b/operations/frontend/create_frontend_urlbuilder.go index 803d3f08..540281c4 100644 --- a/operations/frontend/create_frontend_urlbuilder.go +++ b/operations/frontend/create_frontend_urlbuilder.go @@ -31,6 +31,7 @@ import ( // CreateFrontendURL generates an URL for the create frontend operation type CreateFrontendURL struct { ForceReload *bool + FullSection *bool TransactionID *string Version *int64 @@ -62,34 +63,42 @@ func (o *CreateFrontendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/frontend/delete_frontend.go b/operations/frontend/delete_frontend.go index d1775578..cac9c8f4 100644 --- a/operations/frontend/delete_frontend.go +++ b/operations/frontend/delete_frontend.go @@ -23,7 +23,7 @@ package frontend import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // DeleteFrontendHandlerFunc turns a function with the right signature into a delete frontend handler @@ -44,12 +44,12 @@ func NewDeleteFrontend(ctx *middleware.Context, handler DeleteFrontendHandler) * return &DeleteFrontend{Context: ctx, Handler: handler} } -/*DeleteFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{name} Frontend deleteFrontend +/* + DeleteFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{name} Frontend deleteFrontend -Delete a frontend +# Delete a frontend Deletes a frontend from the configuration by it's name. - */ type DeleteFrontend struct { Context *middleware.Context @@ -59,21 +59,20 @@ type DeleteFrontend struct { func (o *DeleteFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewDeleteFrontendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *DeleteFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/frontend/delete_frontend_parameters.go b/operations/frontend/delete_frontend_parameters.go index d11dd283..c27add2e 100644 --- a/operations/frontend/delete_frontend_parameters.go +++ b/operations/frontend/delete_frontend_parameters.go @@ -26,9 +26,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) // NewDeleteFrontendParams creates a new DeleteFrontendParams object @@ -105,7 +104,6 @@ func (o *DeleteFrontendParams) BindRequest(r *http.Request, route *middleware.Ma if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -121,6 +119,7 @@ func (o *DeleteFrontendParams) bindForceReload(rawData []string, hasKey bool, fo // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewDeleteFrontendParams() return nil @@ -144,7 +143,6 @@ func (o *DeleteFrontendParams) bindName(rawData []string, hasKey bool, formats s // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -159,10 +157,10 @@ func (o *DeleteFrontendParams) bindTransactionID(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -177,6 +175,7 @@ func (o *DeleteFrontendParams) bindVersion(rawData []string, hasKey bool, format // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/frontend/delete_frontend_responses.go b/operations/frontend/delete_frontend_responses.go index c930d42c..298c8ef2 100644 --- a/operations/frontend/delete_frontend_responses.go +++ b/operations/frontend/delete_frontend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // DeleteFrontendAcceptedCode is the HTTP code returned for type DeleteFrontendAccepted const DeleteFrontendAcceptedCode int = 202 -/*DeleteFrontendAccepted Configuration change accepted and reload requested +/* +DeleteFrontendAccepted Configuration change accepted and reload requested swagger:response deleteFrontendAccepted */ @@ -78,7 +78,8 @@ func (o *DeleteFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer // DeleteFrontendNoContentCode is the HTTP code returned for type DeleteFrontendNoContent const DeleteFrontendNoContentCode int = 204 -/*DeleteFrontendNoContent Frontend deleted +/* +DeleteFrontendNoContent Frontend deleted swagger:response deleteFrontendNoContent */ @@ -102,7 +103,8 @@ func (o *DeleteFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer // DeleteFrontendNotFoundCode is the HTTP code returned for type DeleteFrontendNotFound const DeleteFrontendNotFoundCode int = 404 -/*DeleteFrontendNotFound The specified resource was not found +/* +DeleteFrontendNotFound The specified resource was not found swagger:response deleteFrontendNotFound */ @@ -110,7 +112,7 @@ type DeleteFrontendNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -125,13 +127,13 @@ func NewDeleteFrontendNotFound() *DeleteFrontendNotFound { } // WithConfigurationVersion adds the configurationVersion to the delete frontend not found response -func (o *DeleteFrontendNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteFrontendNotFound { +func (o *DeleteFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteFrontendNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete frontend not found response -func (o *DeleteFrontendNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteFrontendNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -151,7 +153,7 @@ func (o *DeleteFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -165,7 +167,8 @@ func (o *DeleteFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer } } -/*DeleteFrontendDefault General Error +/* +DeleteFrontendDefault General Error swagger:response deleteFrontendDefault */ @@ -174,7 +177,7 @@ type DeleteFrontendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -205,13 +208,13 @@ func (o *DeleteFrontendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the delete frontend default response -func (o *DeleteFrontendDefault) WithConfigurationVersion(configurationVersion int64) *DeleteFrontendDefault { +func (o *DeleteFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteFrontendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete frontend default response -func (o *DeleteFrontendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteFrontendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -231,7 +234,7 @@ func (o *DeleteFrontendDefault) WriteResponse(rw http.ResponseWriter, producer r // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/frontend/delete_frontend_urlbuilder.go b/operations/frontend/delete_frontend_urlbuilder.go index 62b0acdd..d2abf34c 100644 --- a/operations/frontend/delete_frontend_urlbuilder.go +++ b/operations/frontend/delete_frontend_urlbuilder.go @@ -72,34 +72,34 @@ func (o *DeleteFrontendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/frontend/get_frontend.go b/operations/frontend/get_frontend.go index 12f48aea..88f26e16 100644 --- a/operations/frontend/get_frontend.go +++ b/operations/frontend/get_frontend.go @@ -23,12 +23,7 @@ package frontend import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetFrontendHandlerFunc turns a function with the right signature into a get frontend handler @@ -49,12 +44,12 @@ func NewGetFrontend(ctx *middleware.Context, handler GetFrontendHandler) *GetFro return &GetFrontend{Context: ctx, Handler: handler} } -/*GetFrontend swagger:route GET /services/haproxy/configuration/frontends/{name} Frontend getFrontend +/* + GetFrontend swagger:route GET /services/haproxy/configuration/frontends/{name} Frontend getFrontend -Return a frontend +# Return a frontend Returns one frontend configuration by it's name. - */ type GetFrontend struct { Context *middleware.Context @@ -64,21 +59,20 @@ type GetFrontend struct { func (o *GetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetFrontendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -87,68 +81,6 @@ func (o *GetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetFrontendOKBody get frontend o k body -// swagger:model GetFrontendOKBody -type GetFrontendOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Frontend `json:"data,omitempty"` -} - -// Validate validates this get frontend o k body -func (o *GetFrontendOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetFrontendOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getFrontendOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetFrontendOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetFrontendOKBody) UnmarshalBinary(b []byte) error { - var res GetFrontendOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/frontend/get_frontend_parameters.go b/operations/frontend/get_frontend_parameters.go index b432e83d..68c4bf8e 100644 --- a/operations/frontend/get_frontend_parameters.go +++ b/operations/frontend/get_frontend_parameters.go @@ -26,15 +26,23 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetFrontendParams creates a new GetFrontendParams object -// no default values defined in spec. +// with the default values initialized. func NewGetFrontendParams() GetFrontendParams { - return GetFrontendParams{} + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetFrontendParams{ + FullSection: &fullSectionDefault, + } } // GetFrontendParams contains all the bound params for the get frontend operation @@ -46,6 +54,11 @@ type GetFrontendParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*Frontend name Required: true In: path @@ -68,6 +81,11 @@ func (o *GetFrontendParams) BindRequest(r *http.Request, route *middleware.Match qs := runtime.Values(r.URL.Query()) + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + rName, rhkName, _ := route.Params.GetOK("name") if err := o.bindName(rName, rhkName, route.Formats); err != nil { res = append(res, err) @@ -77,13 +95,36 @@ func (o *GetFrontendParams) BindRequest(r *http.Request, route *middleware.Match if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetFrontendParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindName binds and validates parameter Name from path. func (o *GetFrontendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -93,7 +134,6 @@ func (o *GetFrontendParams) bindName(rawData []string, hasKey bool, formats strf // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -108,10 +148,10 @@ func (o *GetFrontendParams) bindTransactionID(rawData []string, hasKey bool, for // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/frontend/get_frontend_responses.go b/operations/frontend/get_frontend_responses.go index 3269a91f..f400254c 100644 --- a/operations/frontend/get_frontend_responses.go +++ b/operations/frontend/get_frontend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetFrontendOKCode is the HTTP code returned for type GetFrontendOK const GetFrontendOKCode int = 200 -/*GetFrontendOK Successful operation +/* +GetFrontendOK Successful operation swagger:response getFrontendOK */ @@ -40,12 +40,12 @@ type GetFrontendOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetFrontendOKBody `json:"body,omitempty"` + Payload *models.Frontend `json:"body,omitempty"` } // NewGetFrontendOK creates GetFrontendOK with default headers values @@ -55,24 +55,24 @@ func NewGetFrontendOK() *GetFrontendOK { } // WithConfigurationVersion adds the configurationVersion to the get frontend o k response -func (o *GetFrontendOK) WithConfigurationVersion(configurationVersion int64) *GetFrontendOK { +func (o *GetFrontendOK) WithConfigurationVersion(configurationVersion string) *GetFrontendOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get frontend o k response -func (o *GetFrontendOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetFrontendOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get frontend o k response -func (o *GetFrontendOK) WithPayload(payload *GetFrontendOKBody) *GetFrontendOK { +func (o *GetFrontendOK) WithPayload(payload *models.Frontend) *GetFrontendOK { o.Payload = payload return o } // SetPayload sets the payload to the get frontend o k response -func (o *GetFrontendOK) SetPayload(payload *GetFrontendOKBody) { +func (o *GetFrontendOK) SetPayload(payload *models.Frontend) { o.Payload = payload } @@ -81,7 +81,7 @@ func (o *GetFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.P // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -98,7 +98,8 @@ func (o *GetFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.P // GetFrontendNotFoundCode is the HTTP code returned for type GetFrontendNotFound const GetFrontendNotFoundCode int = 404 -/*GetFrontendNotFound The specified resource was not found +/* +GetFrontendNotFound The specified resource was not found swagger:response getFrontendNotFound */ @@ -106,7 +107,7 @@ type GetFrontendNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -121,13 +122,13 @@ func NewGetFrontendNotFound() *GetFrontendNotFound { } // WithConfigurationVersion adds the configurationVersion to the get frontend not found response -func (o *GetFrontendNotFound) WithConfigurationVersion(configurationVersion int64) *GetFrontendNotFound { +func (o *GetFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetFrontendNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get frontend not found response -func (o *GetFrontendNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetFrontendNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -147,7 +148,7 @@ func (o *GetFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer run // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -161,7 +162,8 @@ func (o *GetFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer run } } -/*GetFrontendDefault General Error +/* +GetFrontendDefault General Error swagger:response getFrontendDefault */ @@ -170,7 +172,7 @@ type GetFrontendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -201,13 +203,13 @@ func (o *GetFrontendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get frontend default response -func (o *GetFrontendDefault) WithConfigurationVersion(configurationVersion int64) *GetFrontendDefault { +func (o *GetFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetFrontendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get frontend default response -func (o *GetFrontendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetFrontendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -227,7 +229,7 @@ func (o *GetFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runt // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/frontend/get_frontend_urlbuilder.go b/operations/frontend/get_frontend_urlbuilder.go index 3b27449c..eed2e838 100644 --- a/operations/frontend/get_frontend_urlbuilder.go +++ b/operations/frontend/get_frontend_urlbuilder.go @@ -25,12 +25,15 @@ import ( "net/url" golangswaggerpaths "path" "strings" + + "github.com/go-openapi/swag" ) // GetFrontendURL generates an URL for the get frontend operation type GetFrontendURL struct { Name string + FullSection *bool TransactionID *string _basePath string @@ -68,18 +71,26 @@ func (o *GetFrontendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/frontend/get_frontends.go b/operations/frontend/get_frontends.go index 4ee29861..ea2cc9ec 100644 --- a/operations/frontend/get_frontends.go +++ b/operations/frontend/get_frontends.go @@ -23,13 +23,7 @@ package frontend import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetFrontendsHandlerFunc turns a function with the right signature into a get frontends handler @@ -50,12 +44,12 @@ func NewGetFrontends(ctx *middleware.Context, handler GetFrontendsHandler) *GetF return &GetFrontends{Context: ctx, Handler: handler} } -/*GetFrontends swagger:route GET /services/haproxy/configuration/frontends Frontend getFrontends +/* + GetFrontends swagger:route GET /services/haproxy/configuration/frontends Frontend getFrontends -Return an array of frontends +# Return an array of frontends Returns an array of all configured frontends. - */ type GetFrontends struct { Context *middleware.Context @@ -65,21 +59,20 @@ type GetFrontends struct { func (o *GetFrontends) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetFrontendsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -88,67 +81,6 @@ func (o *GetFrontends) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetFrontendsOKBody get frontends o k body -// swagger:model GetFrontendsOKBody -type GetFrontendsOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.Frontends `json:"data"` -} - -// Validate validates this get frontends o k body -func (o *GetFrontendsOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetFrontendsOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getFrontendsOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getFrontendsOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetFrontendsOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetFrontendsOKBody) UnmarshalBinary(b []byte) error { - var res GetFrontendsOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/frontend/get_frontends_parameters.go b/operations/frontend/get_frontends_parameters.go index 59ffe4bf..0ad50b47 100644 --- a/operations/frontend/get_frontends_parameters.go +++ b/operations/frontend/get_frontends_parameters.go @@ -26,15 +26,23 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetFrontendsParams creates a new GetFrontendsParams object -// no default values defined in spec. +// with the default values initialized. func NewGetFrontendsParams() GetFrontendsParams { - return GetFrontendsParams{} + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetFrontendsParams{ + FullSection: &fullSectionDefault, + } } // GetFrontendsParams contains all the bound params for the get frontends operation @@ -46,6 +54,11 @@ type GetFrontendsParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -63,17 +76,45 @@ func (o *GetFrontendsParams) BindRequest(r *http.Request, route *middleware.Matc qs := runtime.Values(r.URL.Query()) + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetFrontendsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetFrontendsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindTransactionID binds and validates parameter TransactionID from query. func (o *GetFrontendsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -83,10 +124,10 @@ func (o *GetFrontendsParams) bindTransactionID(rawData []string, hasKey bool, fo // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/frontend/get_frontends_responses.go b/operations/frontend/get_frontends_responses.go index 89c57d7d..eaaa4e90 100644 --- a/operations/frontend/get_frontends_responses.go +++ b/operations/frontend/get_frontends_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetFrontendsOKCode is the HTTP code returned for type GetFrontendsOK const GetFrontendsOKCode int = 200 -/*GetFrontendsOK Successful operation +/* +GetFrontendsOK Successful operation swagger:response getFrontendsOK */ @@ -40,12 +40,12 @@ type GetFrontendsOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetFrontendsOKBody `json:"body,omitempty"` + Payload models.Frontends `json:"body,omitempty"` } // NewGetFrontendsOK creates GetFrontendsOK with default headers values @@ -55,24 +55,24 @@ func NewGetFrontendsOK() *GetFrontendsOK { } // WithConfigurationVersion adds the configurationVersion to the get frontends o k response -func (o *GetFrontendsOK) WithConfigurationVersion(configurationVersion int64) *GetFrontendsOK { +func (o *GetFrontendsOK) WithConfigurationVersion(configurationVersion string) *GetFrontendsOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get frontends o k response -func (o *GetFrontendsOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetFrontendsOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get frontends o k response -func (o *GetFrontendsOK) WithPayload(payload *GetFrontendsOKBody) *GetFrontendsOK { +func (o *GetFrontendsOK) WithPayload(payload models.Frontends) *GetFrontendsOK { o.Payload = payload return o } // SetPayload sets the payload to the get frontends o k response -func (o *GetFrontendsOK) SetPayload(payload *GetFrontendsOKBody) { +func (o *GetFrontendsOK) SetPayload(payload models.Frontends) { o.Payload = payload } @@ -81,21 +81,25 @@ func (o *GetFrontendsOK) WriteResponse(rw http.ResponseWriter, producer runtime. // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Frontends{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*GetFrontendsDefault General Error +/* +GetFrontendsDefault General Error swagger:response getFrontendsDefault */ @@ -104,7 +108,7 @@ type GetFrontendsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -135,13 +139,13 @@ func (o *GetFrontendsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get frontends default response -func (o *GetFrontendsDefault) WithConfigurationVersion(configurationVersion int64) *GetFrontendsDefault { +func (o *GetFrontendsDefault) WithConfigurationVersion(configurationVersion string) *GetFrontendsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get frontends default response -func (o *GetFrontendsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetFrontendsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -161,7 +165,7 @@ func (o *GetFrontendsDefault) WriteResponse(rw http.ResponseWriter, producer run // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/frontend/get_frontends_urlbuilder.go b/operations/frontend/get_frontends_urlbuilder.go index bed2f84b..9ad42b2b 100644 --- a/operations/frontend/get_frontends_urlbuilder.go +++ b/operations/frontend/get_frontends_urlbuilder.go @@ -24,10 +24,13 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // GetFrontendsURL generates an URL for the get frontends operation type GetFrontendsURL struct { + FullSection *bool TransactionID *string _basePath string @@ -58,18 +61,26 @@ func (o *GetFrontendsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/frontend/replace_frontend.go b/operations/frontend/replace_frontend.go index 45e89880..7cac6737 100644 --- a/operations/frontend/replace_frontend.go +++ b/operations/frontend/replace_frontend.go @@ -23,7 +23,7 @@ package frontend import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // ReplaceFrontendHandlerFunc turns a function with the right signature into a replace frontend handler @@ -44,12 +44,12 @@ func NewReplaceFrontend(ctx *middleware.Context, handler ReplaceFrontendHandler) return &ReplaceFrontend{Context: ctx, Handler: handler} } -/*ReplaceFrontend swagger:route PUT /services/haproxy/configuration/frontends/{name} Frontend replaceFrontend +/* + ReplaceFrontend swagger:route PUT /services/haproxy/configuration/frontends/{name} Frontend replaceFrontend -Replace a frontend +# Replace a frontend Replaces a frontend configuration by it's name. - */ type ReplaceFrontend struct { Context *middleware.Context @@ -59,21 +59,20 @@ type ReplaceFrontend struct { func (o *ReplaceFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewReplaceFrontendParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *ReplaceFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/frontend/replace_frontend_parameters.go b/operations/frontend/replace_frontend_parameters.go index d542e24b..94db3bfc 100644 --- a/operations/frontend/replace_frontend_parameters.go +++ b/operations/frontend/replace_frontend_parameters.go @@ -27,11 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewReplaceFrontendParams creates a new ReplaceFrontendParams object @@ -42,10 +41,13 @@ func NewReplaceFrontendParams() ReplaceFrontendParams { // initialize parameters with default values forceReloadDefault = bool(false) + fullSectionDefault = bool(false) ) return ReplaceFrontendParams{ ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, } } @@ -68,6 +70,11 @@ type ReplaceFrontendParams struct { Default: false */ ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*Frontend name Required: true In: path @@ -99,7 +106,7 @@ func (o *ReplaceFrontendParams) BindRequest(r *http.Request, route *middleware.M var body models.Frontend if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -114,13 +121,19 @@ func (o *ReplaceFrontendParams) BindRequest(r *http.Request, route *middleware.M } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + rName, rhkName, _ := route.Params.GetOK("name") if err := o.bindName(rName, rhkName, route.Formats); err != nil { res = append(res, err) @@ -135,7 +148,6 @@ func (o *ReplaceFrontendParams) BindRequest(r *http.Request, route *middleware.M if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -151,6 +163,7 @@ func (o *ReplaceFrontendParams) bindForceReload(rawData []string, hasKey bool, f // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewReplaceFrontendParams() return nil @@ -165,6 +178,30 @@ func (o *ReplaceFrontendParams) bindForceReload(rawData []string, hasKey bool, f return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceFrontendParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindName binds and validates parameter Name from path. func (o *ReplaceFrontendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -174,7 +211,6 @@ func (o *ReplaceFrontendParams) bindName(rawData []string, hasKey bool, formats // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -189,10 +225,10 @@ func (o *ReplaceFrontendParams) bindTransactionID(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -207,6 +243,7 @@ func (o *ReplaceFrontendParams) bindVersion(rawData []string, hasKey bool, forma // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/frontend/replace_frontend_responses.go b/operations/frontend/replace_frontend_responses.go index 86f4eba8..42da8e6e 100644 --- a/operations/frontend/replace_frontend_responses.go +++ b/operations/frontend/replace_frontend_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // ReplaceFrontendOKCode is the HTTP code returned for type ReplaceFrontendOK const ReplaceFrontendOKCode int = 200 -/*ReplaceFrontendOK Frontend replaced +/* +ReplaceFrontendOK Frontend replaced swagger:response replaceFrontendOK */ @@ -76,7 +76,8 @@ func (o *ReplaceFrontendOK) WriteResponse(rw http.ResponseWriter, producer runti // ReplaceFrontendAcceptedCode is the HTTP code returned for type ReplaceFrontendAccepted const ReplaceFrontendAcceptedCode int = 202 -/*ReplaceFrontendAccepted Configuration change accepted and reload requested +/* +ReplaceFrontendAccepted Configuration change accepted and reload requested swagger:response replaceFrontendAccepted */ @@ -142,7 +143,8 @@ func (o *ReplaceFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer // ReplaceFrontendBadRequestCode is the HTTP code returned for type ReplaceFrontendBadRequest const ReplaceFrontendBadRequestCode int = 400 -/*ReplaceFrontendBadRequest Bad request +/* +ReplaceFrontendBadRequest Bad request swagger:response replaceFrontendBadRequest */ @@ -150,7 +152,7 @@ type ReplaceFrontendBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewReplaceFrontendBadRequest() *ReplaceFrontendBadRequest { } // WithConfigurationVersion adds the configurationVersion to the replace frontend bad request response -func (o *ReplaceFrontendBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceFrontendBadRequest { +func (o *ReplaceFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceFrontendBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace frontend bad request response -func (o *ReplaceFrontendBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *ReplaceFrontendBadRequest) WriteResponse(rw http.ResponseWriter, produc // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *ReplaceFrontendBadRequest) WriteResponse(rw http.ResponseWriter, produc // ReplaceFrontendNotFoundCode is the HTTP code returned for type ReplaceFrontendNotFound const ReplaceFrontendNotFoundCode int = 404 -/*ReplaceFrontendNotFound The specified resource was not found +/* +ReplaceFrontendNotFound The specified resource was not found swagger:response replaceFrontendNotFound */ @@ -216,7 +219,7 @@ type ReplaceFrontendNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewReplaceFrontendNotFound() *ReplaceFrontendNotFound { } // WithConfigurationVersion adds the configurationVersion to the replace frontend not found response -func (o *ReplaceFrontendNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceFrontendNotFound { +func (o *ReplaceFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceFrontendNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace frontend not found response -func (o *ReplaceFrontendNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceFrontendNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *ReplaceFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *ReplaceFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer } } -/*ReplaceFrontendDefault General Error +/* +ReplaceFrontendDefault General Error swagger:response replaceFrontendDefault */ @@ -280,7 +284,7 @@ type ReplaceFrontendDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *ReplaceFrontendDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the replace frontend default response -func (o *ReplaceFrontendDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceFrontendDefault { +func (o *ReplaceFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceFrontendDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace frontend default response -func (o *ReplaceFrontendDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceFrontendDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *ReplaceFrontendDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/frontend/replace_frontend_urlbuilder.go b/operations/frontend/replace_frontend_urlbuilder.go index 7356a6c9..ca4c3405 100644 --- a/operations/frontend/replace_frontend_urlbuilder.go +++ b/operations/frontend/replace_frontend_urlbuilder.go @@ -34,6 +34,7 @@ type ReplaceFrontendURL struct { Name string ForceReload *bool + FullSection *bool TransactionID *string Version *int64 @@ -72,34 +73,42 @@ func (o *ReplaceFrontendURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/global/get_global.go b/operations/global/get_global.go index 1f7ab55a..1b717c77 100644 --- a/operations/global/get_global.go +++ b/operations/global/get_global.go @@ -23,12 +23,7 @@ package global import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetGlobalHandlerFunc turns a function with the right signature into a get global handler @@ -49,12 +44,12 @@ func NewGetGlobal(ctx *middleware.Context, handler GetGlobalHandler) *GetGlobal return &GetGlobal{Context: ctx, Handler: handler} } -/*GetGlobal swagger:route GET /services/haproxy/configuration/global Global getGlobal +/* + GetGlobal swagger:route GET /services/haproxy/configuration/global Global getGlobal -Return a global part of configuration +# Return a global part of configuration Returns global part of configuration. - */ type GetGlobal struct { Context *middleware.Context @@ -64,21 +59,20 @@ type GetGlobal struct { func (o *GetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetGlobalParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -87,68 +81,6 @@ func (o *GetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetGlobalOKBody get global o k body -// swagger:model GetGlobalOKBody -type GetGlobalOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Global `json:"data,omitempty"` -} - -// Validate validates this get global o k body -func (o *GetGlobalOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetGlobalOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getGlobalOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetGlobalOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetGlobalOKBody) UnmarshalBinary(b []byte) error { - var res GetGlobalOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/global/get_global_parameters.go b/operations/global/get_global_parameters.go index 65bbb8c4..8b5579c8 100644 --- a/operations/global/get_global_parameters.go +++ b/operations/global/get_global_parameters.go @@ -26,15 +26,23 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetGlobalParams creates a new GetGlobalParams object -// no default values defined in spec. +// with the default values initialized. func NewGetGlobalParams() GetGlobalParams { - return GetGlobalParams{} + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetGlobalParams{ + FullSection: &fullSectionDefault, + } } // GetGlobalParams contains all the bound params for the get global operation @@ -46,6 +54,11 @@ type GetGlobalParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -63,17 +76,45 @@ func (o *GetGlobalParams) BindRequest(r *http.Request, route *middleware.Matched qs := runtime.Values(r.URL.Query()) + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetGlobalParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetGlobalParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindTransactionID binds and validates parameter TransactionID from query. func (o *GetGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -83,10 +124,10 @@ func (o *GetGlobalParams) bindTransactionID(rawData []string, hasKey bool, forma // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/global/get_global_responses.go b/operations/global/get_global_responses.go index 7f3f5951..283bc111 100644 --- a/operations/global/get_global_responses.go +++ b/operations/global/get_global_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetGlobalOKCode is the HTTP code returned for type GetGlobalOK const GetGlobalOKCode int = 200 -/*GetGlobalOK Successful operation +/* +GetGlobalOK Successful operation swagger:response getGlobalOK */ @@ -40,12 +40,12 @@ type GetGlobalOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetGlobalOKBody `json:"body,omitempty"` + Payload *models.Global `json:"body,omitempty"` } // NewGetGlobalOK creates GetGlobalOK with default headers values @@ -55,24 +55,24 @@ func NewGetGlobalOK() *GetGlobalOK { } // WithConfigurationVersion adds the configurationVersion to the get global o k response -func (o *GetGlobalOK) WithConfigurationVersion(configurationVersion int64) *GetGlobalOK { +func (o *GetGlobalOK) WithConfigurationVersion(configurationVersion string) *GetGlobalOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get global o k response -func (o *GetGlobalOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetGlobalOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get global o k response -func (o *GetGlobalOK) WithPayload(payload *GetGlobalOKBody) *GetGlobalOK { +func (o *GetGlobalOK) WithPayload(payload *models.Global) *GetGlobalOK { o.Payload = payload return o } // SetPayload sets the payload to the get global o k response -func (o *GetGlobalOK) SetPayload(payload *GetGlobalOKBody) { +func (o *GetGlobalOK) SetPayload(payload *models.Global) { o.Payload = payload } @@ -81,7 +81,7 @@ func (o *GetGlobalOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pro // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -95,7 +95,8 @@ func (o *GetGlobalOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pro } } -/*GetGlobalDefault General Error +/* +GetGlobalDefault General Error swagger:response getGlobalDefault */ @@ -104,7 +105,7 @@ type GetGlobalDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -135,13 +136,13 @@ func (o *GetGlobalDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get global default response -func (o *GetGlobalDefault) WithConfigurationVersion(configurationVersion int64) *GetGlobalDefault { +func (o *GetGlobalDefault) WithConfigurationVersion(configurationVersion string) *GetGlobalDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get global default response -func (o *GetGlobalDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetGlobalDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -161,7 +162,7 @@ func (o *GetGlobalDefault) WriteResponse(rw http.ResponseWriter, producer runtim // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/global/get_global_urlbuilder.go b/operations/global/get_global_urlbuilder.go index 66639df1..8e448ffb 100644 --- a/operations/global/get_global_urlbuilder.go +++ b/operations/global/get_global_urlbuilder.go @@ -24,10 +24,13 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // GetGlobalURL generates an URL for the get global operation type GetGlobalURL struct { + FullSection *bool TransactionID *string _basePath string @@ -58,18 +61,26 @@ func (o *GetGlobalURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/global/replace_global.go b/operations/global/replace_global.go index 37b691a4..be43146d 100644 --- a/operations/global/replace_global.go +++ b/operations/global/replace_global.go @@ -23,7 +23,7 @@ package global import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // ReplaceGlobalHandlerFunc turns a function with the right signature into a replace global handler @@ -44,12 +44,12 @@ func NewReplaceGlobal(ctx *middleware.Context, handler ReplaceGlobalHandler) *Re return &ReplaceGlobal{Context: ctx, Handler: handler} } -/*ReplaceGlobal swagger:route PUT /services/haproxy/configuration/global Global replaceGlobal +/* + ReplaceGlobal swagger:route PUT /services/haproxy/configuration/global Global replaceGlobal -Replace global +# Replace global Replace global part of config - */ type ReplaceGlobal struct { Context *middleware.Context @@ -59,21 +59,20 @@ type ReplaceGlobal struct { func (o *ReplaceGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewReplaceGlobalParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *ReplaceGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/global/replace_global_parameters.go b/operations/global/replace_global_parameters.go index acc925d6..878bae6c 100644 --- a/operations/global/replace_global_parameters.go +++ b/operations/global/replace_global_parameters.go @@ -27,11 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewReplaceGlobalParams creates a new ReplaceGlobalParams object @@ -42,10 +41,13 @@ func NewReplaceGlobalParams() ReplaceGlobalParams { // initialize parameters with default values forceReloadDefault = bool(false) + fullSectionDefault = bool(false) ) return ReplaceGlobalParams{ ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, } } @@ -68,6 +70,11 @@ type ReplaceGlobalParams struct { Default: false */ ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -94,7 +101,7 @@ func (o *ReplaceGlobalParams) BindRequest(r *http.Request, route *middleware.Mat var body models.Global if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -109,13 +116,19 @@ func (o *ReplaceGlobalParams) BindRequest(r *http.Request, route *middleware.Mat } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) @@ -125,7 +138,6 @@ func (o *ReplaceGlobalParams) BindRequest(r *http.Request, route *middleware.Mat if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -141,6 +153,7 @@ func (o *ReplaceGlobalParams) bindForceReload(rawData []string, hasKey bool, for // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewReplaceGlobalParams() return nil @@ -155,6 +168,30 @@ func (o *ReplaceGlobalParams) bindForceReload(rawData []string, hasKey bool, for return nil } +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceGlobalParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceGlobalParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + // bindTransactionID binds and validates parameter TransactionID from query. func (o *ReplaceGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -164,10 +201,10 @@ func (o *ReplaceGlobalParams) bindTransactionID(rawData []string, hasKey bool, f // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -182,6 +219,7 @@ func (o *ReplaceGlobalParams) bindVersion(rawData []string, hasKey bool, formats // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/global/replace_global_responses.go b/operations/global/replace_global_responses.go index 3600e667..8297de5b 100644 --- a/operations/global/replace_global_responses.go +++ b/operations/global/replace_global_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // ReplaceGlobalOKCode is the HTTP code returned for type ReplaceGlobalOK const ReplaceGlobalOKCode int = 200 -/*ReplaceGlobalOK Global replaced +/* +ReplaceGlobalOK Global replaced swagger:response replaceGlobalOK */ @@ -76,7 +76,8 @@ func (o *ReplaceGlobalOK) WriteResponse(rw http.ResponseWriter, producer runtime // ReplaceGlobalAcceptedCode is the HTTP code returned for type ReplaceGlobalAccepted const ReplaceGlobalAcceptedCode int = 202 -/*ReplaceGlobalAccepted Configuration change accepted and reload requested +/* +ReplaceGlobalAccepted Configuration change accepted and reload requested swagger:response replaceGlobalAccepted */ @@ -142,7 +143,8 @@ func (o *ReplaceGlobalAccepted) WriteResponse(rw http.ResponseWriter, producer r // ReplaceGlobalBadRequestCode is the HTTP code returned for type ReplaceGlobalBadRequest const ReplaceGlobalBadRequestCode int = 400 -/*ReplaceGlobalBadRequest Bad request +/* +ReplaceGlobalBadRequest Bad request swagger:response replaceGlobalBadRequest */ @@ -150,7 +152,7 @@ type ReplaceGlobalBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewReplaceGlobalBadRequest() *ReplaceGlobalBadRequest { } // WithConfigurationVersion adds the configurationVersion to the replace global bad request response -func (o *ReplaceGlobalBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceGlobalBadRequest { +func (o *ReplaceGlobalBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceGlobalBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace global bad request response -func (o *ReplaceGlobalBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceGlobalBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *ReplaceGlobalBadRequest) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -205,7 +207,8 @@ func (o *ReplaceGlobalBadRequest) WriteResponse(rw http.ResponseWriter, producer } } -/*ReplaceGlobalDefault General Error +/* +ReplaceGlobalDefault General Error swagger:response replaceGlobalDefault */ @@ -214,7 +217,7 @@ type ReplaceGlobalDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -245,13 +248,13 @@ func (o *ReplaceGlobalDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the replace global default response -func (o *ReplaceGlobalDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceGlobalDefault { +func (o *ReplaceGlobalDefault) WithConfigurationVersion(configurationVersion string) *ReplaceGlobalDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace global default response -func (o *ReplaceGlobalDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceGlobalDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -271,7 +274,7 @@ func (o *ReplaceGlobalDefault) WriteResponse(rw http.ResponseWriter, producer ru // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/global/replace_global_urlbuilder.go b/operations/global/replace_global_urlbuilder.go index bc1cdad4..f78ef828 100644 --- a/operations/global/replace_global_urlbuilder.go +++ b/operations/global/replace_global_urlbuilder.go @@ -31,6 +31,7 @@ import ( // ReplaceGlobalURL generates an URL for the replace global operation type ReplaceGlobalURL struct { ForceReload *bool + FullSection *bool TransactionID *string Version *int64 @@ -62,34 +63,42 @@ func (o *ReplaceGlobalURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/group/create_group.go b/operations/group/create_group.go new file mode 100644 index 00000000..e17e6529 --- /dev/null +++ b/operations/group/create_group.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateGroupHandlerFunc turns a function with the right signature into a create group handler +type CreateGroupHandlerFunc func(CreateGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateGroupHandlerFunc) Handle(params CreateGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateGroupHandler interface for that can handle valid create group params +type CreateGroupHandler interface { + Handle(CreateGroupParams, interface{}) middleware.Responder +} + +// NewCreateGroup creates a new http.Handler for the create group operation +func NewCreateGroup(ctx *middleware.Context, handler CreateGroupHandler) *CreateGroup { + return &CreateGroup{Context: ctx, Handler: handler} +} + +/* + CreateGroup swagger:route POST /services/haproxy/configuration/groups Group createGroup + +Add a new userlist group +*/ +type CreateGroup struct { + Context *middleware.Context + Handler CreateGroupHandler +} + +func (o *CreateGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/group/create_group_parameters.go b/operations/group/create_group_parameters.go new file mode 100644 index 00000000..4d078d7f --- /dev/null +++ b/operations/group/create_group_parameters.go @@ -0,0 +1,229 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateGroupParams creates a new CreateGroupParams object +// with the default values initialized. +func NewCreateGroupParams() CreateGroupParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateGroupParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateGroupParams contains all the bound params for the create group operation +// typically these are obtained from a http.Request +// +// swagger:parameters createGroup +type CreateGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Group + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateGroupParams() beforehand. +func (o *CreateGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Group + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateGroupParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateGroupParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *CreateGroupParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateGroupParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/group/create_group_responses.go b/operations/group/create_group_responses.go new file mode 100644 index 00000000..ceaf76a3 --- /dev/null +++ b/operations/group/create_group_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateGroupCreatedCode is the HTTP code returned for type CreateGroupCreated +const CreateGroupCreatedCode int = 201 + +/* +CreateGroupCreated Group created + +swagger:response createGroupCreated +*/ +type CreateGroupCreated struct { + + /* + In: Body + */ + Payload *models.Group `json:"body,omitempty"` +} + +// NewCreateGroupCreated creates CreateGroupCreated with default headers values +func NewCreateGroupCreated() *CreateGroupCreated { + + return &CreateGroupCreated{} +} + +// WithPayload adds the payload to the create group created response +func (o *CreateGroupCreated) WithPayload(payload *models.Group) *CreateGroupCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create group created response +func (o *CreateGroupCreated) SetPayload(payload *models.Group) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGroupCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateGroupAcceptedCode is the HTTP code returned for type CreateGroupAccepted +const CreateGroupAcceptedCode int = 202 + +/* +CreateGroupAccepted Configuration change accepted and reload requested + +swagger:response createGroupAccepted +*/ +type CreateGroupAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Group `json:"body,omitempty"` +} + +// NewCreateGroupAccepted creates CreateGroupAccepted with default headers values +func NewCreateGroupAccepted() *CreateGroupAccepted { + + return &CreateGroupAccepted{} +} + +// WithReloadID adds the reloadId to the create group accepted response +func (o *CreateGroupAccepted) WithReloadID(reloadID string) *CreateGroupAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create group accepted response +func (o *CreateGroupAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create group accepted response +func (o *CreateGroupAccepted) WithPayload(payload *models.Group) *CreateGroupAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create group accepted response +func (o *CreateGroupAccepted) SetPayload(payload *models.Group) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGroupAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateGroupBadRequestCode is the HTTP code returned for type CreateGroupBadRequest +const CreateGroupBadRequestCode int = 400 + +/* +CreateGroupBadRequest Bad request + +swagger:response createGroupBadRequest +*/ +type CreateGroupBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateGroupBadRequest creates CreateGroupBadRequest with default headers values +func NewCreateGroupBadRequest() *CreateGroupBadRequest { + + return &CreateGroupBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create group bad request response +func (o *CreateGroupBadRequest) WithConfigurationVersion(configurationVersion string) *CreateGroupBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create group bad request response +func (o *CreateGroupBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create group bad request response +func (o *CreateGroupBadRequest) WithPayload(payload *models.Error) *CreateGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create group bad request response +func (o *CreateGroupBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateGroupConflictCode is the HTTP code returned for type CreateGroupConflict +const CreateGroupConflictCode int = 409 + +/* +CreateGroupConflict The specified resource already exists + +swagger:response createGroupConflict +*/ +type CreateGroupConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateGroupConflict creates CreateGroupConflict with default headers values +func NewCreateGroupConflict() *CreateGroupConflict { + + return &CreateGroupConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create group conflict response +func (o *CreateGroupConflict) WithConfigurationVersion(configurationVersion string) *CreateGroupConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create group conflict response +func (o *CreateGroupConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create group conflict response +func (o *CreateGroupConflict) WithPayload(payload *models.Error) *CreateGroupConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create group conflict response +func (o *CreateGroupConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGroupConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateGroupDefault General Error + +swagger:response createGroupDefault +*/ +type CreateGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateGroupDefault creates CreateGroupDefault with default headers values +func NewCreateGroupDefault(code int) *CreateGroupDefault { + if code <= 0 { + code = 500 + } + + return &CreateGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create group default response +func (o *CreateGroupDefault) WithStatusCode(code int) *CreateGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create group default response +func (o *CreateGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create group default response +func (o *CreateGroupDefault) WithConfigurationVersion(configurationVersion string) *CreateGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create group default response +func (o *CreateGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create group default response +func (o *CreateGroupDefault) WithPayload(payload *models.Error) *CreateGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create group default response +func (o *CreateGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/group/create_group_urlbuilder.go b/operations/group/create_group_urlbuilder.go new file mode 100644 index 00000000..d4095381 --- /dev/null +++ b/operations/group/create_group_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateGroupURL generates an URL for the create group operation +type CreateGroupURL struct { + ForceReload *bool + TransactionID *string + Userlist string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateGroupURL) WithBasePath(bp string) *CreateGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/groups" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/group/delete_group.go b/operations/group/delete_group.go new file mode 100644 index 00000000..3916d88b --- /dev/null +++ b/operations/group/delete_group.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteGroupHandlerFunc turns a function with the right signature into a delete group handler +type DeleteGroupHandlerFunc func(DeleteGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteGroupHandlerFunc) Handle(params DeleteGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteGroupHandler interface for that can handle valid delete group params +type DeleteGroupHandler interface { + Handle(DeleteGroupParams, interface{}) middleware.Responder +} + +// NewDeleteGroup creates a new http.Handler for the delete group operation +func NewDeleteGroup(ctx *middleware.Context, handler DeleteGroupHandler) *DeleteGroup { + return &DeleteGroup{Context: ctx, Handler: handler} +} + +/* + DeleteGroup swagger:route DELETE /services/haproxy/configuration/groups/{name} Group deleteGroup + +Delete a group +*/ +type DeleteGroup struct { + Context *middleware.Context + Handler DeleteGroupHandler +} + +func (o *DeleteGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/group/delete_group_parameters.go b/operations/group/delete_group_parameters.go new file mode 100644 index 00000000..cec73c10 --- /dev/null +++ b/operations/group/delete_group_parameters.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteGroupParams creates a new DeleteGroupParams object +// with the default values initialized. +func NewDeleteGroupParams() DeleteGroupParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteGroupParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteGroupParams contains all the bound params for the delete group operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteGroup +type DeleteGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*group name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteGroupParams() beforehand. +func (o *DeleteGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteGroupParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteGroupParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *DeleteGroupParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteGroupParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/group/delete_group_responses.go b/operations/group/delete_group_responses.go new file mode 100644 index 00000000..b0b7085d --- /dev/null +++ b/operations/group/delete_group_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteGroupAcceptedCode is the HTTP code returned for type DeleteGroupAccepted +const DeleteGroupAcceptedCode int = 202 + +/* +DeleteGroupAccepted Configuration change accepted and reload requested + +swagger:response deleteGroupAccepted +*/ +type DeleteGroupAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteGroupAccepted creates DeleteGroupAccepted with default headers values +func NewDeleteGroupAccepted() *DeleteGroupAccepted { + + return &DeleteGroupAccepted{} +} + +// WithReloadID adds the reloadId to the delete group accepted response +func (o *DeleteGroupAccepted) WithReloadID(reloadID string) *DeleteGroupAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete group accepted response +func (o *DeleteGroupAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteGroupAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteGroupNoContentCode is the HTTP code returned for type DeleteGroupNoContent +const DeleteGroupNoContentCode int = 204 + +/* +DeleteGroupNoContent Group deleted + +swagger:response deleteGroupNoContent +*/ +type DeleteGroupNoContent struct { +} + +// NewDeleteGroupNoContent creates DeleteGroupNoContent with default headers values +func NewDeleteGroupNoContent() *DeleteGroupNoContent { + + return &DeleteGroupNoContent{} +} + +// WriteResponse to the client +func (o *DeleteGroupNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteGroupNotFoundCode is the HTTP code returned for type DeleteGroupNotFound +const DeleteGroupNotFoundCode int = 404 + +/* +DeleteGroupNotFound The specified resource was not found + +swagger:response deleteGroupNotFound +*/ +type DeleteGroupNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteGroupNotFound creates DeleteGroupNotFound with default headers values +func NewDeleteGroupNotFound() *DeleteGroupNotFound { + + return &DeleteGroupNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete group not found response +func (o *DeleteGroupNotFound) WithConfigurationVersion(configurationVersion string) *DeleteGroupNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete group not found response +func (o *DeleteGroupNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete group not found response +func (o *DeleteGroupNotFound) WithPayload(payload *models.Error) *DeleteGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete group not found response +func (o *DeleteGroupNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteGroupDefault General Error + +swagger:response deleteGroupDefault +*/ +type DeleteGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteGroupDefault creates DeleteGroupDefault with default headers values +func NewDeleteGroupDefault(code int) *DeleteGroupDefault { + if code <= 0 { + code = 500 + } + + return &DeleteGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete group default response +func (o *DeleteGroupDefault) WithStatusCode(code int) *DeleteGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete group default response +func (o *DeleteGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete group default response +func (o *DeleteGroupDefault) WithConfigurationVersion(configurationVersion string) *DeleteGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete group default response +func (o *DeleteGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete group default response +func (o *DeleteGroupDefault) WithPayload(payload *models.Error) *DeleteGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete group default response +func (o *DeleteGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/group/delete_group_urlbuilder.go b/operations/group/delete_group_urlbuilder.go new file mode 100644 index 00000000..ceafe4c7 --- /dev/null +++ b/operations/group/delete_group_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteGroupURL generates an URL for the delete group operation +type DeleteGroupURL struct { + Name string + + ForceReload *bool + TransactionID *string + Userlist string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteGroupURL) WithBasePath(bp string) *DeleteGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/groups/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/group/get_group.go b/operations/group/get_group.go new file mode 100644 index 00000000..4b133368 --- /dev/null +++ b/operations/group/get_group.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetGroupHandlerFunc turns a function with the right signature into a get group handler +type GetGroupHandlerFunc func(GetGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetGroupHandlerFunc) Handle(params GetGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetGroupHandler interface for that can handle valid get group params +type GetGroupHandler interface { + Handle(GetGroupParams, interface{}) middleware.Responder +} + +// NewGetGroup creates a new http.Handler for the get group operation +func NewGetGroup(ctx *middleware.Context, handler GetGroupHandler) *GetGroup { + return &GetGroup{Context: ctx, Handler: handler} +} + +/* + GetGroup swagger:route GET /services/haproxy/configuration/groups/{name} Group getGroup + +Return one userlist group +*/ +type GetGroup struct { + Context *middleware.Context + Handler GetGroupHandler +} + +func (o *GetGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/group/get_group_parameters.go b/operations/group/get_group_parameters.go new file mode 100644 index 00000000..e3692f2d --- /dev/null +++ b/operations/group/get_group_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetGroupParams creates a new GetGroupParams object +// +// There are no default values defined in the spec. +func NewGetGroupParams() GetGroupParams { + + return GetGroupParams{} +} + +// GetGroupParams contains all the bound params for the get group operation +// typically these are obtained from a http.Request +// +// swagger:parameters getGroup +type GetGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Group name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetGroupParams() beforehand. +func (o *GetGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *GetGroupParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} diff --git a/operations/group/get_group_responses.go b/operations/group/get_group_responses.go new file mode 100644 index 00000000..dc240ad8 --- /dev/null +++ b/operations/group/get_group_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetGroupOKCode is the HTTP code returned for type GetGroupOK +const GetGroupOKCode int = 200 + +/* +GetGroupOK Successful operation + +swagger:response getGroupOK +*/ +type GetGroupOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Group `json:"body,omitempty"` +} + +// NewGetGroupOK creates GetGroupOK with default headers values +func NewGetGroupOK() *GetGroupOK { + + return &GetGroupOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get group o k response +func (o *GetGroupOK) WithConfigurationVersion(configurationVersion string) *GetGroupOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get group o k response +func (o *GetGroupOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get group o k response +func (o *GetGroupOK) WithPayload(payload *models.Group) *GetGroupOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get group o k response +func (o *GetGroupOK) SetPayload(payload *models.Group) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetGroupNotFoundCode is the HTTP code returned for type GetGroupNotFound +const GetGroupNotFoundCode int = 404 + +/* +GetGroupNotFound The specified resource already exists + +swagger:response getGroupNotFound +*/ +type GetGroupNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetGroupNotFound creates GetGroupNotFound with default headers values +func NewGetGroupNotFound() *GetGroupNotFound { + + return &GetGroupNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get group not found response +func (o *GetGroupNotFound) WithConfigurationVersion(configurationVersion string) *GetGroupNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get group not found response +func (o *GetGroupNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get group not found response +func (o *GetGroupNotFound) WithPayload(payload *models.Error) *GetGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get group not found response +func (o *GetGroupNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetGroupDefault General Error + +swagger:response getGroupDefault +*/ +type GetGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetGroupDefault creates GetGroupDefault with default headers values +func NewGetGroupDefault(code int) *GetGroupDefault { + if code <= 0 { + code = 500 + } + + return &GetGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get group default response +func (o *GetGroupDefault) WithStatusCode(code int) *GetGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get group default response +func (o *GetGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get group default response +func (o *GetGroupDefault) WithConfigurationVersion(configurationVersion string) *GetGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get group default response +func (o *GetGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get group default response +func (o *GetGroupDefault) WithPayload(payload *models.Error) *GetGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get group default response +func (o *GetGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/group/get_group_urlbuilder.go b/operations/group/get_group_urlbuilder.go new file mode 100644 index 00000000..f02baf5c --- /dev/null +++ b/operations/group/get_group_urlbuilder.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetGroupURL generates an URL for the get group operation +type GetGroupURL struct { + Name string + + TransactionID *string + Userlist string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGroupURL) WithBasePath(bp string) *GetGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/groups/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/group/get_groups.go b/operations/group/get_groups.go new file mode 100644 index 00000000..5a72f79f --- /dev/null +++ b/operations/group/get_groups.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetGroupsHandlerFunc turns a function with the right signature into a get groups handler +type GetGroupsHandlerFunc func(GetGroupsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetGroupsHandlerFunc) Handle(params GetGroupsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetGroupsHandler interface for that can handle valid get groups params +type GetGroupsHandler interface { + Handle(GetGroupsParams, interface{}) middleware.Responder +} + +// NewGetGroups creates a new http.Handler for the get groups operation +func NewGetGroups(ctx *middleware.Context, handler GetGroupsHandler) *GetGroups { + return &GetGroups{Context: ctx, Handler: handler} +} + +/* + GetGroups swagger:route GET /services/haproxy/configuration/groups Group getGroups + +Return an array of userlist groups +*/ +type GetGroups struct { + Context *middleware.Context + Handler GetGroupsHandler +} + +func (o *GetGroups) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetGroupsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/group/get_groups_parameters.go b/operations/group/get_groups_parameters.go new file mode 100644 index 00000000..c878f46b --- /dev/null +++ b/operations/group/get_groups_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetGroupsParams creates a new GetGroupsParams object +// +// There are no default values defined in the spec. +func NewGetGroupsParams() GetGroupsParams { + + return GetGroupsParams{} +} + +// GetGroupsParams contains all the bound params for the get groups operation +// typically these are obtained from a http.Request +// +// swagger:parameters getGroups +type GetGroupsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetGroupsParams() beforehand. +func (o *GetGroupsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetGroupsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *GetGroupsParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} diff --git a/operations/group/get_groups_responses.go b/operations/group/get_groups_responses.go new file mode 100644 index 00000000..9dea6fbc --- /dev/null +++ b/operations/group/get_groups_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetGroupsOKCode is the HTTP code returned for type GetGroupsOK +const GetGroupsOKCode int = 200 + +/* +GetGroupsOK Successful operation + +swagger:response getGroupsOK +*/ +type GetGroupsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Groups `json:"body,omitempty"` +} + +// NewGetGroupsOK creates GetGroupsOK with default headers values +func NewGetGroupsOK() *GetGroupsOK { + + return &GetGroupsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get groups o k response +func (o *GetGroupsOK) WithConfigurationVersion(configurationVersion string) *GetGroupsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get groups o k response +func (o *GetGroupsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get groups o k response +func (o *GetGroupsOK) WithPayload(payload models.Groups) *GetGroupsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get groups o k response +func (o *GetGroupsOK) SetPayload(payload models.Groups) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGroupsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Groups{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetGroupsDefault General Error + +swagger:response getGroupsDefault +*/ +type GetGroupsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetGroupsDefault creates GetGroupsDefault with default headers values +func NewGetGroupsDefault(code int) *GetGroupsDefault { + if code <= 0 { + code = 500 + } + + return &GetGroupsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get groups default response +func (o *GetGroupsDefault) WithStatusCode(code int) *GetGroupsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get groups default response +func (o *GetGroupsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get groups default response +func (o *GetGroupsDefault) WithConfigurationVersion(configurationVersion string) *GetGroupsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get groups default response +func (o *GetGroupsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get groups default response +func (o *GetGroupsDefault) WithPayload(payload *models.Error) *GetGroupsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get groups default response +func (o *GetGroupsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetGroupsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/group/get_groups_urlbuilder.go b/operations/group/get_groups_urlbuilder.go new file mode 100644 index 00000000..c8e303e9 --- /dev/null +++ b/operations/group/get_groups_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetGroupsURL generates an URL for the get groups operation +type GetGroupsURL struct { + TransactionID *string + Userlist string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGroupsURL) WithBasePath(bp string) *GetGroupsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetGroupsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetGroupsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/groups" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetGroupsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetGroupsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetGroupsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetGroupsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetGroupsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetGroupsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/group/replace_group.go b/operations/group/replace_group.go new file mode 100644 index 00000000..0d483c9a --- /dev/null +++ b/operations/group/replace_group.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceGroupHandlerFunc turns a function with the right signature into a replace group handler +type ReplaceGroupHandlerFunc func(ReplaceGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceGroupHandlerFunc) Handle(params ReplaceGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceGroupHandler interface for that can handle valid replace group params +type ReplaceGroupHandler interface { + Handle(ReplaceGroupParams, interface{}) middleware.Responder +} + +// NewReplaceGroup creates a new http.Handler for the replace group operation +func NewReplaceGroup(ctx *middleware.Context, handler ReplaceGroupHandler) *ReplaceGroup { + return &ReplaceGroup{Context: ctx, Handler: handler} +} + +/* + ReplaceGroup swagger:route PUT /services/haproxy/configuration/groups/{name} Group replaceGroup + +Replace a group +*/ +type ReplaceGroup struct { + Context *middleware.Context + Handler ReplaceGroupHandler +} + +func (o *ReplaceGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/group/replace_group_parameters.go b/operations/group/replace_group_parameters.go new file mode 100644 index 00000000..6277ad6f --- /dev/null +++ b/operations/group/replace_group_parameters.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceGroupParams creates a new ReplaceGroupParams object +// with the default values initialized. +func NewReplaceGroupParams() ReplaceGroupParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceGroupParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceGroupParams contains all the bound params for the replace group operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceGroup +type ReplaceGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Group + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*group name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceGroupParams() beforehand. +func (o *ReplaceGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Group + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceGroupParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceGroupParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *ReplaceGroupParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceGroupParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/group/replace_group_responses.go b/operations/group/replace_group_responses.go new file mode 100644 index 00000000..28713fcf --- /dev/null +++ b/operations/group/replace_group_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceGroupOKCode is the HTTP code returned for type ReplaceGroupOK +const ReplaceGroupOKCode int = 200 + +/* +ReplaceGroupOK Group replaced + +swagger:response replaceGroupOK +*/ +type ReplaceGroupOK struct { + + /* + In: Body + */ + Payload *models.Group `json:"body,omitempty"` +} + +// NewReplaceGroupOK creates ReplaceGroupOK with default headers values +func NewReplaceGroupOK() *ReplaceGroupOK { + + return &ReplaceGroupOK{} +} + +// WithPayload adds the payload to the replace group o k response +func (o *ReplaceGroupOK) WithPayload(payload *models.Group) *ReplaceGroupOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace group o k response +func (o *ReplaceGroupOK) SetPayload(payload *models.Group) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceGroupAcceptedCode is the HTTP code returned for type ReplaceGroupAccepted +const ReplaceGroupAcceptedCode int = 202 + +/* +ReplaceGroupAccepted Configuration change accepted and reload requested + +swagger:response replaceGroupAccepted +*/ +type ReplaceGroupAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Group `json:"body,omitempty"` +} + +// NewReplaceGroupAccepted creates ReplaceGroupAccepted with default headers values +func NewReplaceGroupAccepted() *ReplaceGroupAccepted { + + return &ReplaceGroupAccepted{} +} + +// WithReloadID adds the reloadId to the replace group accepted response +func (o *ReplaceGroupAccepted) WithReloadID(reloadID string) *ReplaceGroupAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace group accepted response +func (o *ReplaceGroupAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace group accepted response +func (o *ReplaceGroupAccepted) WithPayload(payload *models.Group) *ReplaceGroupAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace group accepted response +func (o *ReplaceGroupAccepted) SetPayload(payload *models.Group) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceGroupAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceGroupBadRequestCode is the HTTP code returned for type ReplaceGroupBadRequest +const ReplaceGroupBadRequestCode int = 400 + +/* +ReplaceGroupBadRequest Bad request + +swagger:response replaceGroupBadRequest +*/ +type ReplaceGroupBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceGroupBadRequest creates ReplaceGroupBadRequest with default headers values +func NewReplaceGroupBadRequest() *ReplaceGroupBadRequest { + + return &ReplaceGroupBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace group bad request response +func (o *ReplaceGroupBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceGroupBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace group bad request response +func (o *ReplaceGroupBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace group bad request response +func (o *ReplaceGroupBadRequest) WithPayload(payload *models.Error) *ReplaceGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace group bad request response +func (o *ReplaceGroupBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceGroupNotFoundCode is the HTTP code returned for type ReplaceGroupNotFound +const ReplaceGroupNotFoundCode int = 404 + +/* +ReplaceGroupNotFound The specified resource was not found + +swagger:response replaceGroupNotFound +*/ +type ReplaceGroupNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceGroupNotFound creates ReplaceGroupNotFound with default headers values +func NewReplaceGroupNotFound() *ReplaceGroupNotFound { + + return &ReplaceGroupNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace group not found response +func (o *ReplaceGroupNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceGroupNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace group not found response +func (o *ReplaceGroupNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace group not found response +func (o *ReplaceGroupNotFound) WithPayload(payload *models.Error) *ReplaceGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace group not found response +func (o *ReplaceGroupNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceGroupDefault General Error + +swagger:response replaceGroupDefault +*/ +type ReplaceGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceGroupDefault creates ReplaceGroupDefault with default headers values +func NewReplaceGroupDefault(code int) *ReplaceGroupDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace group default response +func (o *ReplaceGroupDefault) WithStatusCode(code int) *ReplaceGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace group default response +func (o *ReplaceGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace group default response +func (o *ReplaceGroupDefault) WithConfigurationVersion(configurationVersion string) *ReplaceGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace group default response +func (o *ReplaceGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace group default response +func (o *ReplaceGroupDefault) WithPayload(payload *models.Error) *ReplaceGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace group default response +func (o *ReplaceGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/group/replace_group_urlbuilder.go b/operations/group/replace_group_urlbuilder.go new file mode 100644 index 00000000..2cd07d3e --- /dev/null +++ b/operations/group/replace_group_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package group + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceGroupURL generates an URL for the replace group operation +type ReplaceGroupURL struct { + Name string + + ForceReload *bool + TransactionID *string + Userlist string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceGroupURL) WithBasePath(bp string) *ReplaceGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/groups/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/health/get_health.go b/operations/health/get_health.go new file mode 100644 index 00000000..52491667 --- /dev/null +++ b/operations/health/get_health.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHealthHandlerFunc turns a function with the right signature into a get health handler +type GetHealthHandlerFunc func(GetHealthParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHealthHandlerFunc) Handle(params GetHealthParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHealthHandler interface for that can handle valid get health params +type GetHealthHandler interface { + Handle(GetHealthParams, interface{}) middleware.Responder +} + +// NewGetHealth creates a new http.Handler for the get health operation +func NewGetHealth(ctx *middleware.Context, handler GetHealthHandler) *GetHealth { + return &GetHealth{Context: ctx, Handler: handler} +} + +/* + GetHealth swagger:route GET /health Health getHealth + +# Return managed services health + +Return managed services health +*/ +type GetHealth struct { + Context *middleware.Context + Handler GetHealthHandler +} + +func (o *GetHealth) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHealthParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/health/get_health_parameters.go b/operations/health/get_health_parameters.go new file mode 100644 index 00000000..4a5e5d86 --- /dev/null +++ b/operations/health/get_health_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetHealthParams creates a new GetHealthParams object +// +// There are no default values defined in the spec. +func NewGetHealthParams() GetHealthParams { + + return GetHealthParams{} +} + +// GetHealthParams contains all the bound params for the get health operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHealth +type GetHealthParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHealthParams() beforehand. +func (o *GetHealthParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/health/get_health_responses.go b/operations/health/get_health_responses.go new file mode 100644 index 00000000..adf0d5cf --- /dev/null +++ b/operations/health/get_health_responses.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHealthOKCode is the HTTP code returned for type GetHealthOK +const GetHealthOKCode int = 200 + +/* +GetHealthOK Success + +swagger:response getHealthOK +*/ +type GetHealthOK struct { + + /* + In: Body + */ + Payload *models.Health `json:"body,omitempty"` +} + +// NewGetHealthOK creates GetHealthOK with default headers values +func NewGetHealthOK() *GetHealthOK { + + return &GetHealthOK{} +} + +// WithPayload adds the payload to the get health o k response +func (o *GetHealthOK) WithPayload(payload *models.Health) *GetHealthOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get health o k response +func (o *GetHealthOK) SetPayload(payload *models.Health) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHealthOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHealthDefault General Error + +swagger:response getHealthDefault +*/ +type GetHealthDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHealthDefault creates GetHealthDefault with default headers values +func NewGetHealthDefault(code int) *GetHealthDefault { + if code <= 0 { + code = 500 + } + + return &GetHealthDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get health default response +func (o *GetHealthDefault) WithStatusCode(code int) *GetHealthDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get health default response +func (o *GetHealthDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get health default response +func (o *GetHealthDefault) WithConfigurationVersion(configurationVersion string) *GetHealthDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get health default response +func (o *GetHealthDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get health default response +func (o *GetHealthDefault) WithPayload(payload *models.Error) *GetHealthDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get health default response +func (o *GetHealthDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHealthDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/health/get_health_urlbuilder.go b/operations/health/get_health_urlbuilder.go new file mode 100644 index 00000000..d9be758e --- /dev/null +++ b/operations/health/get_health_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetHealthURL generates an URL for the get health operation +type GetHealthURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHealthURL) WithBasePath(bp string) *GetHealthURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHealthURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHealthURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/health" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHealthURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHealthURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHealthURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHealthURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHealthURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHealthURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_backend.go b/operations/http_after_response_rule/create_http_after_response_rule_backend.go new file mode 100644 index 00000000..f118f10a --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPAfterResponseRuleBackendHandlerFunc turns a function with the right signature into a create HTTP after response rule backend handler +type CreateHTTPAfterResponseRuleBackendHandlerFunc func(CreateHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPAfterResponseRuleBackendHandlerFunc) Handle(params CreateHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPAfterResponseRuleBackendHandler interface for that can handle valid create HTTP after response rule backend params +type CreateHTTPAfterResponseRuleBackendHandler interface { + Handle(CreateHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPAfterResponseRuleBackend creates a new http.Handler for the create HTTP after response rule backend operation +func NewCreateHTTPAfterResponseRuleBackend(ctx *middleware.Context, handler CreateHTTPAfterResponseRuleBackendHandler) *CreateHTTPAfterResponseRuleBackend { + return &CreateHTTPAfterResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPAfterResponseRuleBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule createHttpAfterResponseRuleBackend + +# Add a new HTTP After Response Rule + +Adds a new HTTP After Response Rule of the specified type in the specified parent. +*/ +type CreateHTTPAfterResponseRuleBackend struct { + Context *middleware.Context + Handler CreateHTTPAfterResponseRuleBackendHandler +} + +func (o *CreateHTTPAfterResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPAfterResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_backend_parameters.go b/operations/http_after_response_rule/create_http_after_response_rule_backend_parameters.go new file mode 100644 index 00000000..619314d1 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPAfterResponseRuleBackendParams creates a new CreateHTTPAfterResponseRuleBackendParams object +// with the default values initialized. +func NewCreateHTTPAfterResponseRuleBackendParams() CreateHTTPAfterResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPAfterResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPAfterResponseRuleBackendParams contains all the bound params for the create HTTP after response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPAfterResponseRuleBackend +type CreateHTTPAfterResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPAfterResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPAfterResponseRuleBackendParams() beforehand. +func (o *CreateHTTPAfterResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPAfterResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPAfterResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPAfterResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPAfterResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPAfterResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPAfterResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_backend_responses.go b/operations/http_after_response_rule/create_http_after_response_rule_backend_responses.go new file mode 100644 index 00000000..0b62f5d7 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPAfterResponseRuleBackendCreatedCode is the HTTP code returned for type CreateHTTPAfterResponseRuleBackendCreated +const CreateHTTPAfterResponseRuleBackendCreatedCode int = 201 + +/* +CreateHTTPAfterResponseRuleBackendCreated HTTP Response Rule created + +swagger:response createHttpAfterResponseRuleBackendCreated +*/ +type CreateHTTPAfterResponseRuleBackendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleBackendCreated creates CreateHTTPAfterResponseRuleBackendCreated with default headers values +func NewCreateHTTPAfterResponseRuleBackendCreated() *CreateHTTPAfterResponseRuleBackendCreated { + + return &CreateHTTPAfterResponseRuleBackendCreated{} +} + +// WithPayload adds the payload to the create Http after response rule backend created response +func (o *CreateHTTPAfterResponseRuleBackendCreated) WithPayload(payload *models.HTTPAfterResponseRule) *CreateHTTPAfterResponseRuleBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule backend created response +func (o *CreateHTTPAfterResponseRuleBackendCreated) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleBackendAcceptedCode is the HTTP code returned for type CreateHTTPAfterResponseRuleBackendAccepted +const CreateHTTPAfterResponseRuleBackendAcceptedCode int = 202 + +/* +CreateHTTPAfterResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response createHttpAfterResponseRuleBackendAccepted +*/ +type CreateHTTPAfterResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleBackendAccepted creates CreateHTTPAfterResponseRuleBackendAccepted with default headers values +func NewCreateHTTPAfterResponseRuleBackendAccepted() *CreateHTTPAfterResponseRuleBackendAccepted { + + return &CreateHTTPAfterResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http after response rule backend accepted response +func (o *CreateHTTPAfterResponseRuleBackendAccepted) WithReloadID(reloadID string) *CreateHTTPAfterResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http after response rule backend accepted response +func (o *CreateHTTPAfterResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http after response rule backend accepted response +func (o *CreateHTTPAfterResponseRuleBackendAccepted) WithPayload(payload *models.HTTPAfterResponseRule) *CreateHTTPAfterResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule backend accepted response +func (o *CreateHTTPAfterResponseRuleBackendAccepted) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleBackendBadRequestCode is the HTTP code returned for type CreateHTTPAfterResponseRuleBackendBadRequest +const CreateHTTPAfterResponseRuleBackendBadRequestCode int = 400 + +/* +CreateHTTPAfterResponseRuleBackendBadRequest Bad request + +swagger:response createHttpAfterResponseRuleBackendBadRequest +*/ +type CreateHTTPAfterResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleBackendBadRequest creates CreateHTTPAfterResponseRuleBackendBadRequest with default headers values +func NewCreateHTTPAfterResponseRuleBackendBadRequest() *CreateHTTPAfterResponseRuleBackendBadRequest { + + return &CreateHTTPAfterResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http after response rule backend bad request response +func (o *CreateHTTPAfterResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http after response rule backend bad request response +func (o *CreateHTTPAfterResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http after response rule backend bad request response +func (o *CreateHTTPAfterResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule backend bad request response +func (o *CreateHTTPAfterResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleBackendConflictCode is the HTTP code returned for type CreateHTTPAfterResponseRuleBackendConflict +const CreateHTTPAfterResponseRuleBackendConflictCode int = 409 + +/* +CreateHTTPAfterResponseRuleBackendConflict The specified resource already exists + +swagger:response createHttpAfterResponseRuleBackendConflict +*/ +type CreateHTTPAfterResponseRuleBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleBackendConflict creates CreateHTTPAfterResponseRuleBackendConflict with default headers values +func NewCreateHTTPAfterResponseRuleBackendConflict() *CreateHTTPAfterResponseRuleBackendConflict { + + return &CreateHTTPAfterResponseRuleBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http after response rule backend conflict response +func (o *CreateHTTPAfterResponseRuleBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http after response rule backend conflict response +func (o *CreateHTTPAfterResponseRuleBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http after response rule backend conflict response +func (o *CreateHTTPAfterResponseRuleBackendConflict) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule backend conflict response +func (o *CreateHTTPAfterResponseRuleBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPAfterResponseRuleBackendDefault General Error + +swagger:response createHttpAfterResponseRuleBackendDefault +*/ +type CreateHTTPAfterResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleBackendDefault creates CreateHTTPAfterResponseRuleBackendDefault with default headers values +func NewCreateHTTPAfterResponseRuleBackendDefault(code int) *CreateHTTPAfterResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPAfterResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP after response rule backend default response +func (o *CreateHTTPAfterResponseRuleBackendDefault) WithStatusCode(code int) *CreateHTTPAfterResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP after response rule backend default response +func (o *CreateHTTPAfterResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP after response rule backend default response +func (o *CreateHTTPAfterResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP after response rule backend default response +func (o *CreateHTTPAfterResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP after response rule backend default response +func (o *CreateHTTPAfterResponseRuleBackendDefault) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP after response rule backend default response +func (o *CreateHTTPAfterResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_backend_urlbuilder.go b/operations/http_after_response_rule/create_http_after_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..10def3cd --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPAfterResponseRuleBackendURL generates an URL for the create HTTP after response rule backend operation +type CreateHTTPAfterResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPAfterResponseRuleBackendURL) WithBasePath(bp string) *CreateHTTPAfterResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPAfterResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPAfterResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPAfterResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPAfterResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPAfterResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPAfterResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPAfterResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPAfterResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPAfterResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPAfterResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_defaults.go b/operations/http_after_response_rule/create_http_after_response_rule_defaults.go new file mode 100644 index 00000000..35a1f880 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPAfterResponseRuleDefaultsHandlerFunc turns a function with the right signature into a create HTTP after response rule defaults handler +type CreateHTTPAfterResponseRuleDefaultsHandlerFunc func(CreateHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPAfterResponseRuleDefaultsHandlerFunc) Handle(params CreateHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPAfterResponseRuleDefaultsHandler interface for that can handle valid create HTTP after response rule defaults params +type CreateHTTPAfterResponseRuleDefaultsHandler interface { + Handle(CreateHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateHTTPAfterResponseRuleDefaults creates a new http.Handler for the create HTTP after response rule defaults operation +func NewCreateHTTPAfterResponseRuleDefaults(ctx *middleware.Context, handler CreateHTTPAfterResponseRuleDefaultsHandler) *CreateHTTPAfterResponseRuleDefaults { + return &CreateHTTPAfterResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + CreateHTTPAfterResponseRuleDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule createHttpAfterResponseRuleDefaults + +# Add a new HTTP After Response Rule + +Adds a new HTTP After Response Rule of the specified type in the specified parent. +*/ +type CreateHTTPAfterResponseRuleDefaults struct { + Context *middleware.Context + Handler CreateHTTPAfterResponseRuleDefaultsHandler +} + +func (o *CreateHTTPAfterResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPAfterResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_defaults_parameters.go b/operations/http_after_response_rule/create_http_after_response_rule_defaults_parameters.go new file mode 100644 index 00000000..dfd9ab9c --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPAfterResponseRuleDefaultsParams creates a new CreateHTTPAfterResponseRuleDefaultsParams object +// with the default values initialized. +func NewCreateHTTPAfterResponseRuleDefaultsParams() CreateHTTPAfterResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPAfterResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPAfterResponseRuleDefaultsParams contains all the bound params for the create HTTP after response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPAfterResponseRuleDefaults +type CreateHTTPAfterResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPAfterResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPAfterResponseRuleDefaultsParams() beforehand. +func (o *CreateHTTPAfterResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPAfterResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPAfterResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPAfterResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPAfterResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPAfterResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPAfterResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_defaults_responses.go b/operations/http_after_response_rule/create_http_after_response_rule_defaults_responses.go new file mode 100644 index 00000000..af5c2ac1 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPAfterResponseRuleDefaultsCreatedCode is the HTTP code returned for type CreateHTTPAfterResponseRuleDefaultsCreated +const CreateHTTPAfterResponseRuleDefaultsCreatedCode int = 201 + +/* +CreateHTTPAfterResponseRuleDefaultsCreated HTTP Response Rule created + +swagger:response createHttpAfterResponseRuleDefaultsCreated +*/ +type CreateHTTPAfterResponseRuleDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleDefaultsCreated creates CreateHTTPAfterResponseRuleDefaultsCreated with default headers values +func NewCreateHTTPAfterResponseRuleDefaultsCreated() *CreateHTTPAfterResponseRuleDefaultsCreated { + + return &CreateHTTPAfterResponseRuleDefaultsCreated{} +} + +// WithPayload adds the payload to the create Http after response rule defaults created response +func (o *CreateHTTPAfterResponseRuleDefaultsCreated) WithPayload(payload *models.HTTPAfterResponseRule) *CreateHTTPAfterResponseRuleDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule defaults created response +func (o *CreateHTTPAfterResponseRuleDefaultsCreated) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleDefaultsAcceptedCode is the HTTP code returned for type CreateHTTPAfterResponseRuleDefaultsAccepted +const CreateHTTPAfterResponseRuleDefaultsAcceptedCode int = 202 + +/* +CreateHTTPAfterResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createHttpAfterResponseRuleDefaultsAccepted +*/ +type CreateHTTPAfterResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleDefaultsAccepted creates CreateHTTPAfterResponseRuleDefaultsAccepted with default headers values +func NewCreateHTTPAfterResponseRuleDefaultsAccepted() *CreateHTTPAfterResponseRuleDefaultsAccepted { + + return &CreateHTTPAfterResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Http after response rule defaults accepted response +func (o *CreateHTTPAfterResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *CreateHTTPAfterResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http after response rule defaults accepted response +func (o *CreateHTTPAfterResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http after response rule defaults accepted response +func (o *CreateHTTPAfterResponseRuleDefaultsAccepted) WithPayload(payload *models.HTTPAfterResponseRule) *CreateHTTPAfterResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule defaults accepted response +func (o *CreateHTTPAfterResponseRuleDefaultsAccepted) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleDefaultsBadRequestCode is the HTTP code returned for type CreateHTTPAfterResponseRuleDefaultsBadRequest +const CreateHTTPAfterResponseRuleDefaultsBadRequestCode int = 400 + +/* +CreateHTTPAfterResponseRuleDefaultsBadRequest Bad request + +swagger:response createHttpAfterResponseRuleDefaultsBadRequest +*/ +type CreateHTTPAfterResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleDefaultsBadRequest creates CreateHTTPAfterResponseRuleDefaultsBadRequest with default headers values +func NewCreateHTTPAfterResponseRuleDefaultsBadRequest() *CreateHTTPAfterResponseRuleDefaultsBadRequest { + + return &CreateHTTPAfterResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http after response rule defaults bad request response +func (o *CreateHTTPAfterResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http after response rule defaults bad request response +func (o *CreateHTTPAfterResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http after response rule defaults bad request response +func (o *CreateHTTPAfterResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule defaults bad request response +func (o *CreateHTTPAfterResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleDefaultsConflictCode is the HTTP code returned for type CreateHTTPAfterResponseRuleDefaultsConflict +const CreateHTTPAfterResponseRuleDefaultsConflictCode int = 409 + +/* +CreateHTTPAfterResponseRuleDefaultsConflict The specified resource already exists + +swagger:response createHttpAfterResponseRuleDefaultsConflict +*/ +type CreateHTTPAfterResponseRuleDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleDefaultsConflict creates CreateHTTPAfterResponseRuleDefaultsConflict with default headers values +func NewCreateHTTPAfterResponseRuleDefaultsConflict() *CreateHTTPAfterResponseRuleDefaultsConflict { + + return &CreateHTTPAfterResponseRuleDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http after response rule defaults conflict response +func (o *CreateHTTPAfterResponseRuleDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http after response rule defaults conflict response +func (o *CreateHTTPAfterResponseRuleDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http after response rule defaults conflict response +func (o *CreateHTTPAfterResponseRuleDefaultsConflict) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule defaults conflict response +func (o *CreateHTTPAfterResponseRuleDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPAfterResponseRuleDefaultsDefault General Error + +swagger:response createHttpAfterResponseRuleDefaultsDefault +*/ +type CreateHTTPAfterResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleDefaultsDefault creates CreateHTTPAfterResponseRuleDefaultsDefault with default headers values +func NewCreateHTTPAfterResponseRuleDefaultsDefault(code int) *CreateHTTPAfterResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPAfterResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP after response rule defaults default response +func (o *CreateHTTPAfterResponseRuleDefaultsDefault) WithStatusCode(code int) *CreateHTTPAfterResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP after response rule defaults default response +func (o *CreateHTTPAfterResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP after response rule defaults default response +func (o *CreateHTTPAfterResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP after response rule defaults default response +func (o *CreateHTTPAfterResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP after response rule defaults default response +func (o *CreateHTTPAfterResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP after response rule defaults default response +func (o *CreateHTTPAfterResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_defaults_urlbuilder.go b/operations/http_after_response_rule/create_http_after_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..ff023151 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPAfterResponseRuleDefaultsURL generates an URL for the create HTTP after response rule defaults operation +type CreateHTTPAfterResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPAfterResponseRuleDefaultsURL) WithBasePath(bp string) *CreateHTTPAfterResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPAfterResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPAfterResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPAfterResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPAfterResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPAfterResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPAfterResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPAfterResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPAfterResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPAfterResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPAfterResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_frontend.go b/operations/http_after_response_rule/create_http_after_response_rule_frontend.go new file mode 100644 index 00000000..2744b175 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPAfterResponseRuleFrontendHandlerFunc turns a function with the right signature into a create HTTP after response rule frontend handler +type CreateHTTPAfterResponseRuleFrontendHandlerFunc func(CreateHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPAfterResponseRuleFrontendHandlerFunc) Handle(params CreateHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPAfterResponseRuleFrontendHandler interface for that can handle valid create HTTP after response rule frontend params +type CreateHTTPAfterResponseRuleFrontendHandler interface { + Handle(CreateHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPAfterResponseRuleFrontend creates a new http.Handler for the create HTTP after response rule frontend operation +func NewCreateHTTPAfterResponseRuleFrontend(ctx *middleware.Context, handler CreateHTTPAfterResponseRuleFrontendHandler) *CreateHTTPAfterResponseRuleFrontend { + return &CreateHTTPAfterResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPAfterResponseRuleFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule createHttpAfterResponseRuleFrontend + +# Add a new HTTP After Response Rule + +Adds a new HTTP After Response Rule of the specified type in the specified parent. +*/ +type CreateHTTPAfterResponseRuleFrontend struct { + Context *middleware.Context + Handler CreateHTTPAfterResponseRuleFrontendHandler +} + +func (o *CreateHTTPAfterResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPAfterResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_frontend_parameters.go b/operations/http_after_response_rule/create_http_after_response_rule_frontend_parameters.go new file mode 100644 index 00000000..b4c0fec9 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPAfterResponseRuleFrontendParams creates a new CreateHTTPAfterResponseRuleFrontendParams object +// with the default values initialized. +func NewCreateHTTPAfterResponseRuleFrontendParams() CreateHTTPAfterResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPAfterResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPAfterResponseRuleFrontendParams contains all the bound params for the create HTTP after response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPAfterResponseRuleFrontend +type CreateHTTPAfterResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPAfterResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPAfterResponseRuleFrontendParams() beforehand. +func (o *CreateHTTPAfterResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPAfterResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPAfterResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPAfterResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPAfterResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPAfterResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPAfterResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_frontend_responses.go b/operations/http_after_response_rule/create_http_after_response_rule_frontend_responses.go new file mode 100644 index 00000000..8582bfaa --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPAfterResponseRuleFrontendCreatedCode is the HTTP code returned for type CreateHTTPAfterResponseRuleFrontendCreated +const CreateHTTPAfterResponseRuleFrontendCreatedCode int = 201 + +/* +CreateHTTPAfterResponseRuleFrontendCreated HTTP Response Rule created + +swagger:response createHttpAfterResponseRuleFrontendCreated +*/ +type CreateHTTPAfterResponseRuleFrontendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleFrontendCreated creates CreateHTTPAfterResponseRuleFrontendCreated with default headers values +func NewCreateHTTPAfterResponseRuleFrontendCreated() *CreateHTTPAfterResponseRuleFrontendCreated { + + return &CreateHTTPAfterResponseRuleFrontendCreated{} +} + +// WithPayload adds the payload to the create Http after response rule frontend created response +func (o *CreateHTTPAfterResponseRuleFrontendCreated) WithPayload(payload *models.HTTPAfterResponseRule) *CreateHTTPAfterResponseRuleFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule frontend created response +func (o *CreateHTTPAfterResponseRuleFrontendCreated) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleFrontendAcceptedCode is the HTTP code returned for type CreateHTTPAfterResponseRuleFrontendAccepted +const CreateHTTPAfterResponseRuleFrontendAcceptedCode int = 202 + +/* +CreateHTTPAfterResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response createHttpAfterResponseRuleFrontendAccepted +*/ +type CreateHTTPAfterResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleFrontendAccepted creates CreateHTTPAfterResponseRuleFrontendAccepted with default headers values +func NewCreateHTTPAfterResponseRuleFrontendAccepted() *CreateHTTPAfterResponseRuleFrontendAccepted { + + return &CreateHTTPAfterResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http after response rule frontend accepted response +func (o *CreateHTTPAfterResponseRuleFrontendAccepted) WithReloadID(reloadID string) *CreateHTTPAfterResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http after response rule frontend accepted response +func (o *CreateHTTPAfterResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http after response rule frontend accepted response +func (o *CreateHTTPAfterResponseRuleFrontendAccepted) WithPayload(payload *models.HTTPAfterResponseRule) *CreateHTTPAfterResponseRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule frontend accepted response +func (o *CreateHTTPAfterResponseRuleFrontendAccepted) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleFrontendBadRequestCode is the HTTP code returned for type CreateHTTPAfterResponseRuleFrontendBadRequest +const CreateHTTPAfterResponseRuleFrontendBadRequestCode int = 400 + +/* +CreateHTTPAfterResponseRuleFrontendBadRequest Bad request + +swagger:response createHttpAfterResponseRuleFrontendBadRequest +*/ +type CreateHTTPAfterResponseRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleFrontendBadRequest creates CreateHTTPAfterResponseRuleFrontendBadRequest with default headers values +func NewCreateHTTPAfterResponseRuleFrontendBadRequest() *CreateHTTPAfterResponseRuleFrontendBadRequest { + + return &CreateHTTPAfterResponseRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http after response rule frontend bad request response +func (o *CreateHTTPAfterResponseRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http after response rule frontend bad request response +func (o *CreateHTTPAfterResponseRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http after response rule frontend bad request response +func (o *CreateHTTPAfterResponseRuleFrontendBadRequest) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule frontend bad request response +func (o *CreateHTTPAfterResponseRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPAfterResponseRuleFrontendConflictCode is the HTTP code returned for type CreateHTTPAfterResponseRuleFrontendConflict +const CreateHTTPAfterResponseRuleFrontendConflictCode int = 409 + +/* +CreateHTTPAfterResponseRuleFrontendConflict The specified resource already exists + +swagger:response createHttpAfterResponseRuleFrontendConflict +*/ +type CreateHTTPAfterResponseRuleFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleFrontendConflict creates CreateHTTPAfterResponseRuleFrontendConflict with default headers values +func NewCreateHTTPAfterResponseRuleFrontendConflict() *CreateHTTPAfterResponseRuleFrontendConflict { + + return &CreateHTTPAfterResponseRuleFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http after response rule frontend conflict response +func (o *CreateHTTPAfterResponseRuleFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http after response rule frontend conflict response +func (o *CreateHTTPAfterResponseRuleFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http after response rule frontend conflict response +func (o *CreateHTTPAfterResponseRuleFrontendConflict) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http after response rule frontend conflict response +func (o *CreateHTTPAfterResponseRuleFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPAfterResponseRuleFrontendDefault General Error + +swagger:response createHttpAfterResponseRuleFrontendDefault +*/ +type CreateHTTPAfterResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPAfterResponseRuleFrontendDefault creates CreateHTTPAfterResponseRuleFrontendDefault with default headers values +func NewCreateHTTPAfterResponseRuleFrontendDefault(code int) *CreateHTTPAfterResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPAfterResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP after response rule frontend default response +func (o *CreateHTTPAfterResponseRuleFrontendDefault) WithStatusCode(code int) *CreateHTTPAfterResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP after response rule frontend default response +func (o *CreateHTTPAfterResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP after response rule frontend default response +func (o *CreateHTTPAfterResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPAfterResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP after response rule frontend default response +func (o *CreateHTTPAfterResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP after response rule frontend default response +func (o *CreateHTTPAfterResponseRuleFrontendDefault) WithPayload(payload *models.Error) *CreateHTTPAfterResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP after response rule frontend default response +func (o *CreateHTTPAfterResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPAfterResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/create_http_after_response_rule_frontend_urlbuilder.go b/operations/http_after_response_rule/create_http_after_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..dfbd5d28 --- /dev/null +++ b/operations/http_after_response_rule/create_http_after_response_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPAfterResponseRuleFrontendURL generates an URL for the create HTTP after response rule frontend operation +type CreateHTTPAfterResponseRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPAfterResponseRuleFrontendURL) WithBasePath(bp string) *CreateHTTPAfterResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPAfterResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPAfterResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPAfterResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPAfterResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPAfterResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPAfterResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPAfterResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPAfterResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPAfterResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPAfterResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_backend.go b/operations/http_after_response_rule/delete_http_after_response_rule_backend.go new file mode 100644 index 00000000..34df7c33 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPAfterResponseRuleBackendHandlerFunc turns a function with the right signature into a delete HTTP after response rule backend handler +type DeleteHTTPAfterResponseRuleBackendHandlerFunc func(DeleteHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPAfterResponseRuleBackendHandlerFunc) Handle(params DeleteHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPAfterResponseRuleBackendHandler interface for that can handle valid delete HTTP after response rule backend params +type DeleteHTTPAfterResponseRuleBackendHandler interface { + Handle(DeleteHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPAfterResponseRuleBackend creates a new http.Handler for the delete HTTP after response rule backend operation +func NewDeleteHTTPAfterResponseRuleBackend(ctx *middleware.Context, handler DeleteHTTPAfterResponseRuleBackendHandler) *DeleteHTTPAfterResponseRuleBackend { + return &DeleteHTTPAfterResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPAfterResponseRuleBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule deleteHttpAfterResponseRuleBackend + +# Delete a HTTP After Response Rule + +Deletes a HTTP After Response Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPAfterResponseRuleBackend struct { + Context *middleware.Context + Handler DeleteHTTPAfterResponseRuleBackendHandler +} + +func (o *DeleteHTTPAfterResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPAfterResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_backend_parameters.go b/operations/http_after_response_rule/delete_http_after_response_rule_backend_parameters.go new file mode 100644 index 00000000..2991d84a --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPAfterResponseRuleBackendParams creates a new DeleteHTTPAfterResponseRuleBackendParams object +// with the default values initialized. +func NewDeleteHTTPAfterResponseRuleBackendParams() DeleteHTTPAfterResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPAfterResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPAfterResponseRuleBackendParams contains all the bound params for the delete HTTP after response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPAfterResponseRuleBackend +type DeleteHTTPAfterResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPAfterResponseRuleBackendParams() beforehand. +func (o *DeleteHTTPAfterResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPAfterResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPAfterResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPAfterResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPAfterResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPAfterResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPAfterResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_backend_responses.go b/operations/http_after_response_rule/delete_http_after_response_rule_backend_responses.go new file mode 100644 index 00000000..f54d702a --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPAfterResponseRuleBackendAcceptedCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleBackendAccepted +const DeleteHTTPAfterResponseRuleBackendAcceptedCode int = 202 + +/* +DeleteHTTPAfterResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpAfterResponseRuleBackendAccepted +*/ +type DeleteHTTPAfterResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPAfterResponseRuleBackendAccepted creates DeleteHTTPAfterResponseRuleBackendAccepted with default headers values +func NewDeleteHTTPAfterResponseRuleBackendAccepted() *DeleteHTTPAfterResponseRuleBackendAccepted { + + return &DeleteHTTPAfterResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http after response rule backend accepted response +func (o *DeleteHTTPAfterResponseRuleBackendAccepted) WithReloadID(reloadID string) *DeleteHTTPAfterResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http after response rule backend accepted response +func (o *DeleteHTTPAfterResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPAfterResponseRuleBackendNoContentCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleBackendNoContent +const DeleteHTTPAfterResponseRuleBackendNoContentCode int = 204 + +/* +DeleteHTTPAfterResponseRuleBackendNoContent HTTP After Response Rule deleted + +swagger:response deleteHttpAfterResponseRuleBackendNoContent +*/ +type DeleteHTTPAfterResponseRuleBackendNoContent struct { +} + +// NewDeleteHTTPAfterResponseRuleBackendNoContent creates DeleteHTTPAfterResponseRuleBackendNoContent with default headers values +func NewDeleteHTTPAfterResponseRuleBackendNoContent() *DeleteHTTPAfterResponseRuleBackendNoContent { + + return &DeleteHTTPAfterResponseRuleBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPAfterResponseRuleBackendNotFoundCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleBackendNotFound +const DeleteHTTPAfterResponseRuleBackendNotFoundCode int = 404 + +/* +DeleteHTTPAfterResponseRuleBackendNotFound The specified resource was not found + +swagger:response deleteHttpAfterResponseRuleBackendNotFound +*/ +type DeleteHTTPAfterResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPAfterResponseRuleBackendNotFound creates DeleteHTTPAfterResponseRuleBackendNotFound with default headers values +func NewDeleteHTTPAfterResponseRuleBackendNotFound() *DeleteHTTPAfterResponseRuleBackendNotFound { + + return &DeleteHTTPAfterResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http after response rule backend not found response +func (o *DeleteHTTPAfterResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPAfterResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http after response rule backend not found response +func (o *DeleteHTTPAfterResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http after response rule backend not found response +func (o *DeleteHTTPAfterResponseRuleBackendNotFound) WithPayload(payload *models.Error) *DeleteHTTPAfterResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http after response rule backend not found response +func (o *DeleteHTTPAfterResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPAfterResponseRuleBackendDefault General Error + +swagger:response deleteHttpAfterResponseRuleBackendDefault +*/ +type DeleteHTTPAfterResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPAfterResponseRuleBackendDefault creates DeleteHTTPAfterResponseRuleBackendDefault with default headers values +func NewDeleteHTTPAfterResponseRuleBackendDefault(code int) *DeleteHTTPAfterResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPAfterResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP after response rule backend default response +func (o *DeleteHTTPAfterResponseRuleBackendDefault) WithStatusCode(code int) *DeleteHTTPAfterResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP after response rule backend default response +func (o *DeleteHTTPAfterResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP after response rule backend default response +func (o *DeleteHTTPAfterResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPAfterResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP after response rule backend default response +func (o *DeleteHTTPAfterResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP after response rule backend default response +func (o *DeleteHTTPAfterResponseRuleBackendDefault) WithPayload(payload *models.Error) *DeleteHTTPAfterResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP after response rule backend default response +func (o *DeleteHTTPAfterResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_backend_urlbuilder.go b/operations/http_after_response_rule/delete_http_after_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..15f3cb55 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPAfterResponseRuleBackendURL generates an URL for the delete HTTP after response rule backend operation +type DeleteHTTPAfterResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPAfterResponseRuleBackendURL) WithBasePath(bp string) *DeleteHTTPAfterResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPAfterResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPAfterResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPAfterResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPAfterResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPAfterResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPAfterResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPAfterResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPAfterResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPAfterResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPAfterResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_defaults.go b/operations/http_after_response_rule/delete_http_after_response_rule_defaults.go new file mode 100644 index 00000000..7be69e53 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPAfterResponseRuleDefaultsHandlerFunc turns a function with the right signature into a delete HTTP after response rule defaults handler +type DeleteHTTPAfterResponseRuleDefaultsHandlerFunc func(DeleteHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPAfterResponseRuleDefaultsHandlerFunc) Handle(params DeleteHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPAfterResponseRuleDefaultsHandler interface for that can handle valid delete HTTP after response rule defaults params +type DeleteHTTPAfterResponseRuleDefaultsHandler interface { + Handle(DeleteHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPAfterResponseRuleDefaults creates a new http.Handler for the delete HTTP after response rule defaults operation +func NewDeleteHTTPAfterResponseRuleDefaults(ctx *middleware.Context, handler DeleteHTTPAfterResponseRuleDefaultsHandler) *DeleteHTTPAfterResponseRuleDefaults { + return &DeleteHTTPAfterResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPAfterResponseRuleDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule deleteHttpAfterResponseRuleDefaults + +# Delete a HTTP After Response Rule + +Deletes a HTTP After Response Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPAfterResponseRuleDefaults struct { + Context *middleware.Context + Handler DeleteHTTPAfterResponseRuleDefaultsHandler +} + +func (o *DeleteHTTPAfterResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPAfterResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_defaults_parameters.go b/operations/http_after_response_rule/delete_http_after_response_rule_defaults_parameters.go new file mode 100644 index 00000000..70e173f5 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPAfterResponseRuleDefaultsParams creates a new DeleteHTTPAfterResponseRuleDefaultsParams object +// with the default values initialized. +func NewDeleteHTTPAfterResponseRuleDefaultsParams() DeleteHTTPAfterResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPAfterResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPAfterResponseRuleDefaultsParams contains all the bound params for the delete HTTP after response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPAfterResponseRuleDefaults +type DeleteHTTPAfterResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPAfterResponseRuleDefaultsParams() beforehand. +func (o *DeleteHTTPAfterResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPAfterResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPAfterResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPAfterResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPAfterResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPAfterResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPAfterResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_defaults_responses.go b/operations/http_after_response_rule/delete_http_after_response_rule_defaults_responses.go new file mode 100644 index 00000000..66cf1e49 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPAfterResponseRuleDefaultsAcceptedCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleDefaultsAccepted +const DeleteHTTPAfterResponseRuleDefaultsAcceptedCode int = 202 + +/* +DeleteHTTPAfterResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpAfterResponseRuleDefaultsAccepted +*/ +type DeleteHTTPAfterResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPAfterResponseRuleDefaultsAccepted creates DeleteHTTPAfterResponseRuleDefaultsAccepted with default headers values +func NewDeleteHTTPAfterResponseRuleDefaultsAccepted() *DeleteHTTPAfterResponseRuleDefaultsAccepted { + + return &DeleteHTTPAfterResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http after response rule defaults accepted response +func (o *DeleteHTTPAfterResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *DeleteHTTPAfterResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http after response rule defaults accepted response +func (o *DeleteHTTPAfterResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPAfterResponseRuleDefaultsNoContentCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleDefaultsNoContent +const DeleteHTTPAfterResponseRuleDefaultsNoContentCode int = 204 + +/* +DeleteHTTPAfterResponseRuleDefaultsNoContent HTTP After Response Rule deleted + +swagger:response deleteHttpAfterResponseRuleDefaultsNoContent +*/ +type DeleteHTTPAfterResponseRuleDefaultsNoContent struct { +} + +// NewDeleteHTTPAfterResponseRuleDefaultsNoContent creates DeleteHTTPAfterResponseRuleDefaultsNoContent with default headers values +func NewDeleteHTTPAfterResponseRuleDefaultsNoContent() *DeleteHTTPAfterResponseRuleDefaultsNoContent { + + return &DeleteHTTPAfterResponseRuleDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPAfterResponseRuleDefaultsNotFoundCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleDefaultsNotFound +const DeleteHTTPAfterResponseRuleDefaultsNotFoundCode int = 404 + +/* +DeleteHTTPAfterResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response deleteHttpAfterResponseRuleDefaultsNotFound +*/ +type DeleteHTTPAfterResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPAfterResponseRuleDefaultsNotFound creates DeleteHTTPAfterResponseRuleDefaultsNotFound with default headers values +func NewDeleteHTTPAfterResponseRuleDefaultsNotFound() *DeleteHTTPAfterResponseRuleDefaultsNotFound { + + return &DeleteHTTPAfterResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http after response rule defaults not found response +func (o *DeleteHTTPAfterResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPAfterResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http after response rule defaults not found response +func (o *DeleteHTTPAfterResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http after response rule defaults not found response +func (o *DeleteHTTPAfterResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *DeleteHTTPAfterResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http after response rule defaults not found response +func (o *DeleteHTTPAfterResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPAfterResponseRuleDefaultsDefault General Error + +swagger:response deleteHttpAfterResponseRuleDefaultsDefault +*/ +type DeleteHTTPAfterResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPAfterResponseRuleDefaultsDefault creates DeleteHTTPAfterResponseRuleDefaultsDefault with default headers values +func NewDeleteHTTPAfterResponseRuleDefaultsDefault(code int) *DeleteHTTPAfterResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPAfterResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP after response rule defaults default response +func (o *DeleteHTTPAfterResponseRuleDefaultsDefault) WithStatusCode(code int) *DeleteHTTPAfterResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP after response rule defaults default response +func (o *DeleteHTTPAfterResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP after response rule defaults default response +func (o *DeleteHTTPAfterResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPAfterResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP after response rule defaults default response +func (o *DeleteHTTPAfterResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP after response rule defaults default response +func (o *DeleteHTTPAfterResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *DeleteHTTPAfterResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP after response rule defaults default response +func (o *DeleteHTTPAfterResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_defaults_urlbuilder.go b/operations/http_after_response_rule/delete_http_after_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..0c077d79 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPAfterResponseRuleDefaultsURL generates an URL for the delete HTTP after response rule defaults operation +type DeleteHTTPAfterResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPAfterResponseRuleDefaultsURL) WithBasePath(bp string) *DeleteHTTPAfterResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPAfterResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPAfterResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPAfterResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPAfterResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPAfterResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPAfterResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPAfterResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPAfterResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPAfterResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPAfterResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_frontend.go b/operations/http_after_response_rule/delete_http_after_response_rule_frontend.go new file mode 100644 index 00000000..1e6224d5 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPAfterResponseRuleFrontendHandlerFunc turns a function with the right signature into a delete HTTP after response rule frontend handler +type DeleteHTTPAfterResponseRuleFrontendHandlerFunc func(DeleteHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPAfterResponseRuleFrontendHandlerFunc) Handle(params DeleteHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPAfterResponseRuleFrontendHandler interface for that can handle valid delete HTTP after response rule frontend params +type DeleteHTTPAfterResponseRuleFrontendHandler interface { + Handle(DeleteHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPAfterResponseRuleFrontend creates a new http.Handler for the delete HTTP after response rule frontend operation +func NewDeleteHTTPAfterResponseRuleFrontend(ctx *middleware.Context, handler DeleteHTTPAfterResponseRuleFrontendHandler) *DeleteHTTPAfterResponseRuleFrontend { + return &DeleteHTTPAfterResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPAfterResponseRuleFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule deleteHttpAfterResponseRuleFrontend + +# Delete a HTTP After Response Rule + +Deletes a HTTP After Response Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPAfterResponseRuleFrontend struct { + Context *middleware.Context + Handler DeleteHTTPAfterResponseRuleFrontendHandler +} + +func (o *DeleteHTTPAfterResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPAfterResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_frontend_parameters.go b/operations/http_after_response_rule/delete_http_after_response_rule_frontend_parameters.go new file mode 100644 index 00000000..b64c8963 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPAfterResponseRuleFrontendParams creates a new DeleteHTTPAfterResponseRuleFrontendParams object +// with the default values initialized. +func NewDeleteHTTPAfterResponseRuleFrontendParams() DeleteHTTPAfterResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPAfterResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPAfterResponseRuleFrontendParams contains all the bound params for the delete HTTP after response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPAfterResponseRuleFrontend +type DeleteHTTPAfterResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPAfterResponseRuleFrontendParams() beforehand. +func (o *DeleteHTTPAfterResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPAfterResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPAfterResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPAfterResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPAfterResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPAfterResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPAfterResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_frontend_responses.go b/operations/http_after_response_rule/delete_http_after_response_rule_frontend_responses.go new file mode 100644 index 00000000..af41a95e --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPAfterResponseRuleFrontendAcceptedCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleFrontendAccepted +const DeleteHTTPAfterResponseRuleFrontendAcceptedCode int = 202 + +/* +DeleteHTTPAfterResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpAfterResponseRuleFrontendAccepted +*/ +type DeleteHTTPAfterResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPAfterResponseRuleFrontendAccepted creates DeleteHTTPAfterResponseRuleFrontendAccepted with default headers values +func NewDeleteHTTPAfterResponseRuleFrontendAccepted() *DeleteHTTPAfterResponseRuleFrontendAccepted { + + return &DeleteHTTPAfterResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http after response rule frontend accepted response +func (o *DeleteHTTPAfterResponseRuleFrontendAccepted) WithReloadID(reloadID string) *DeleteHTTPAfterResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http after response rule frontend accepted response +func (o *DeleteHTTPAfterResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPAfterResponseRuleFrontendNoContentCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleFrontendNoContent +const DeleteHTTPAfterResponseRuleFrontendNoContentCode int = 204 + +/* +DeleteHTTPAfterResponseRuleFrontendNoContent HTTP After Response Rule deleted + +swagger:response deleteHttpAfterResponseRuleFrontendNoContent +*/ +type DeleteHTTPAfterResponseRuleFrontendNoContent struct { +} + +// NewDeleteHTTPAfterResponseRuleFrontendNoContent creates DeleteHTTPAfterResponseRuleFrontendNoContent with default headers values +func NewDeleteHTTPAfterResponseRuleFrontendNoContent() *DeleteHTTPAfterResponseRuleFrontendNoContent { + + return &DeleteHTTPAfterResponseRuleFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPAfterResponseRuleFrontendNotFoundCode is the HTTP code returned for type DeleteHTTPAfterResponseRuleFrontendNotFound +const DeleteHTTPAfterResponseRuleFrontendNotFoundCode int = 404 + +/* +DeleteHTTPAfterResponseRuleFrontendNotFound The specified resource was not found + +swagger:response deleteHttpAfterResponseRuleFrontendNotFound +*/ +type DeleteHTTPAfterResponseRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPAfterResponseRuleFrontendNotFound creates DeleteHTTPAfterResponseRuleFrontendNotFound with default headers values +func NewDeleteHTTPAfterResponseRuleFrontendNotFound() *DeleteHTTPAfterResponseRuleFrontendNotFound { + + return &DeleteHTTPAfterResponseRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http after response rule frontend not found response +func (o *DeleteHTTPAfterResponseRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPAfterResponseRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http after response rule frontend not found response +func (o *DeleteHTTPAfterResponseRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http after response rule frontend not found response +func (o *DeleteHTTPAfterResponseRuleFrontendNotFound) WithPayload(payload *models.Error) *DeleteHTTPAfterResponseRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http after response rule frontend not found response +func (o *DeleteHTTPAfterResponseRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPAfterResponseRuleFrontendDefault General Error + +swagger:response deleteHttpAfterResponseRuleFrontendDefault +*/ +type DeleteHTTPAfterResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPAfterResponseRuleFrontendDefault creates DeleteHTTPAfterResponseRuleFrontendDefault with default headers values +func NewDeleteHTTPAfterResponseRuleFrontendDefault(code int) *DeleteHTTPAfterResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPAfterResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP after response rule frontend default response +func (o *DeleteHTTPAfterResponseRuleFrontendDefault) WithStatusCode(code int) *DeleteHTTPAfterResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP after response rule frontend default response +func (o *DeleteHTTPAfterResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP after response rule frontend default response +func (o *DeleteHTTPAfterResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPAfterResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP after response rule frontend default response +func (o *DeleteHTTPAfterResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP after response rule frontend default response +func (o *DeleteHTTPAfterResponseRuleFrontendDefault) WithPayload(payload *models.Error) *DeleteHTTPAfterResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP after response rule frontend default response +func (o *DeleteHTTPAfterResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPAfterResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/delete_http_after_response_rule_frontend_urlbuilder.go b/operations/http_after_response_rule/delete_http_after_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..6e3168b8 --- /dev/null +++ b/operations/http_after_response_rule/delete_http_after_response_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPAfterResponseRuleFrontendURL generates an URL for the delete HTTP after response rule frontend operation +type DeleteHTTPAfterResponseRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPAfterResponseRuleFrontendURL) WithBasePath(bp string) *DeleteHTTPAfterResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPAfterResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPAfterResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPAfterResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPAfterResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPAfterResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPAfterResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPAfterResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPAfterResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPAfterResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPAfterResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_backend.go b/operations/http_after_response_rule/get_all_http_after_response_rule_backend.go new file mode 100644 index 00000000..de9de95b --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPAfterResponseRuleBackendHandlerFunc turns a function with the right signature into a get all HTTP after response rule backend handler +type GetAllHTTPAfterResponseRuleBackendHandlerFunc func(GetAllHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPAfterResponseRuleBackendHandlerFunc) Handle(params GetAllHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPAfterResponseRuleBackendHandler interface for that can handle valid get all HTTP after response rule backend params +type GetAllHTTPAfterResponseRuleBackendHandler interface { + Handle(GetAllHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPAfterResponseRuleBackend creates a new http.Handler for the get all HTTP after response rule backend operation +func NewGetAllHTTPAfterResponseRuleBackend(ctx *middleware.Context, handler GetAllHTTPAfterResponseRuleBackendHandler) *GetAllHTTPAfterResponseRuleBackend { + return &GetAllHTTPAfterResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPAfterResponseRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_after_response_rules HTTPAfterResponseRule getAllHttpAfterResponseRuleBackend + +# Return an array of all HTTP After Response Rules + +Returns all HTTP After Response Rules that are configured in specified parent. +*/ +type GetAllHTTPAfterResponseRuleBackend struct { + Context *middleware.Context + Handler GetAllHTTPAfterResponseRuleBackendHandler +} + +func (o *GetAllHTTPAfterResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPAfterResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_backend_parameters.go b/operations/http_after_response_rule/get_all_http_after_response_rule_backend_parameters.go new file mode 100644 index 00000000..2e5fcd45 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPAfterResponseRuleBackendParams creates a new GetAllHTTPAfterResponseRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPAfterResponseRuleBackendParams() GetAllHTTPAfterResponseRuleBackendParams { + + return GetAllHTTPAfterResponseRuleBackendParams{} +} + +// GetAllHTTPAfterResponseRuleBackendParams contains all the bound params for the get all HTTP after response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPAfterResponseRuleBackend +type GetAllHTTPAfterResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPAfterResponseRuleBackendParams() beforehand. +func (o *GetAllHTTPAfterResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPAfterResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPAfterResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_backend_responses.go b/operations/http_after_response_rule/get_all_http_after_response_rule_backend_responses.go new file mode 100644 index 00000000..6b5f690b --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPAfterResponseRuleBackendOKCode is the HTTP code returned for type GetAllHTTPAfterResponseRuleBackendOK +const GetAllHTTPAfterResponseRuleBackendOKCode int = 200 + +/* +GetAllHTTPAfterResponseRuleBackendOK Successful operation + +swagger:response getAllHttpAfterResponseRuleBackendOK +*/ +type GetAllHTTPAfterResponseRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewGetAllHTTPAfterResponseRuleBackendOK creates GetAllHTTPAfterResponseRuleBackendOK with default headers values +func NewGetAllHTTPAfterResponseRuleBackendOK() *GetAllHTTPAfterResponseRuleBackendOK { + + return &GetAllHTTPAfterResponseRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http after response rule backend o k response +func (o *GetAllHTTPAfterResponseRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPAfterResponseRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http after response rule backend o k response +func (o *GetAllHTTPAfterResponseRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http after response rule backend o k response +func (o *GetAllHTTPAfterResponseRuleBackendOK) WithPayload(payload models.HTTPAfterResponseRules) *GetAllHTTPAfterResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http after response rule backend o k response +func (o *GetAllHTTPAfterResponseRuleBackendOK) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPAfterResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPAfterResponseRuleBackendDefault General Error + +swagger:response getAllHttpAfterResponseRuleBackendDefault +*/ +type GetAllHTTPAfterResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPAfterResponseRuleBackendDefault creates GetAllHTTPAfterResponseRuleBackendDefault with default headers values +func NewGetAllHTTPAfterResponseRuleBackendDefault(code int) *GetAllHTTPAfterResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPAfterResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP after response rule backend default response +func (o *GetAllHTTPAfterResponseRuleBackendDefault) WithStatusCode(code int) *GetAllHTTPAfterResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP after response rule backend default response +func (o *GetAllHTTPAfterResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP after response rule backend default response +func (o *GetAllHTTPAfterResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPAfterResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP after response rule backend default response +func (o *GetAllHTTPAfterResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP after response rule backend default response +func (o *GetAllHTTPAfterResponseRuleBackendDefault) WithPayload(payload *models.Error) *GetAllHTTPAfterResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP after response rule backend default response +func (o *GetAllHTTPAfterResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPAfterResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_backend_urlbuilder.go b/operations/http_after_response_rule/get_all_http_after_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..4e5ac497 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPAfterResponseRuleBackendURL generates an URL for the get all HTTP after response rule backend operation +type GetAllHTTPAfterResponseRuleBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPAfterResponseRuleBackendURL) WithBasePath(bp string) *GetAllHTTPAfterResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPAfterResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPAfterResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPAfterResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPAfterResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPAfterResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPAfterResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPAfterResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPAfterResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPAfterResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_defaults.go b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults.go new file mode 100644 index 00000000..a7fd8e90 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPAfterResponseRuleDefaultsHandlerFunc turns a function with the right signature into a get all HTTP after response rule defaults handler +type GetAllHTTPAfterResponseRuleDefaultsHandlerFunc func(GetAllHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPAfterResponseRuleDefaultsHandlerFunc) Handle(params GetAllHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPAfterResponseRuleDefaultsHandler interface for that can handle valid get all HTTP after response rule defaults params +type GetAllHTTPAfterResponseRuleDefaultsHandler interface { + Handle(GetAllHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPAfterResponseRuleDefaults creates a new http.Handler for the get all HTTP after response rule defaults operation +func NewGetAllHTTPAfterResponseRuleDefaults(ctx *middleware.Context, handler GetAllHTTPAfterResponseRuleDefaultsHandler) *GetAllHTTPAfterResponseRuleDefaults { + return &GetAllHTTPAfterResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPAfterResponseRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules HTTPAfterResponseRule getAllHttpAfterResponseRuleDefaults + +# Return an array of all HTTP After Response Rules + +Returns all HTTP After Response Rules that are configured in specified parent. +*/ +type GetAllHTTPAfterResponseRuleDefaults struct { + Context *middleware.Context + Handler GetAllHTTPAfterResponseRuleDefaultsHandler +} + +func (o *GetAllHTTPAfterResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPAfterResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_parameters.go b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_parameters.go new file mode 100644 index 00000000..5977f515 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPAfterResponseRuleDefaultsParams creates a new GetAllHTTPAfterResponseRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPAfterResponseRuleDefaultsParams() GetAllHTTPAfterResponseRuleDefaultsParams { + + return GetAllHTTPAfterResponseRuleDefaultsParams{} +} + +// GetAllHTTPAfterResponseRuleDefaultsParams contains all the bound params for the get all HTTP after response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPAfterResponseRuleDefaults +type GetAllHTTPAfterResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPAfterResponseRuleDefaultsParams() beforehand. +func (o *GetAllHTTPAfterResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPAfterResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPAfterResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_responses.go b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_responses.go new file mode 100644 index 00000000..c1d18050 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPAfterResponseRuleDefaultsOKCode is the HTTP code returned for type GetAllHTTPAfterResponseRuleDefaultsOK +const GetAllHTTPAfterResponseRuleDefaultsOKCode int = 200 + +/* +GetAllHTTPAfterResponseRuleDefaultsOK Successful operation + +swagger:response getAllHttpAfterResponseRuleDefaultsOK +*/ +type GetAllHTTPAfterResponseRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewGetAllHTTPAfterResponseRuleDefaultsOK creates GetAllHTTPAfterResponseRuleDefaultsOK with default headers values +func NewGetAllHTTPAfterResponseRuleDefaultsOK() *GetAllHTTPAfterResponseRuleDefaultsOK { + + return &GetAllHTTPAfterResponseRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http after response rule defaults o k response +func (o *GetAllHTTPAfterResponseRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPAfterResponseRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http after response rule defaults o k response +func (o *GetAllHTTPAfterResponseRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http after response rule defaults o k response +func (o *GetAllHTTPAfterResponseRuleDefaultsOK) WithPayload(payload models.HTTPAfterResponseRules) *GetAllHTTPAfterResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http after response rule defaults o k response +func (o *GetAllHTTPAfterResponseRuleDefaultsOK) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPAfterResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPAfterResponseRuleDefaultsDefault General Error + +swagger:response getAllHttpAfterResponseRuleDefaultsDefault +*/ +type GetAllHTTPAfterResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPAfterResponseRuleDefaultsDefault creates GetAllHTTPAfterResponseRuleDefaultsDefault with default headers values +func NewGetAllHTTPAfterResponseRuleDefaultsDefault(code int) *GetAllHTTPAfterResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPAfterResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP after response rule defaults default response +func (o *GetAllHTTPAfterResponseRuleDefaultsDefault) WithStatusCode(code int) *GetAllHTTPAfterResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP after response rule defaults default response +func (o *GetAllHTTPAfterResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP after response rule defaults default response +func (o *GetAllHTTPAfterResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPAfterResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP after response rule defaults default response +func (o *GetAllHTTPAfterResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP after response rule defaults default response +func (o *GetAllHTTPAfterResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *GetAllHTTPAfterResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP after response rule defaults default response +func (o *GetAllHTTPAfterResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPAfterResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_urlbuilder.go b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..03bbdc6b --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPAfterResponseRuleDefaultsURL generates an URL for the get all HTTP after response rule defaults operation +type GetAllHTTPAfterResponseRuleDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPAfterResponseRuleDefaultsURL) WithBasePath(bp string) *GetAllHTTPAfterResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPAfterResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPAfterResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPAfterResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPAfterResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPAfterResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPAfterResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPAfterResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPAfterResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPAfterResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_frontend.go b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend.go new file mode 100644 index 00000000..14140fa0 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPAfterResponseRuleFrontendHandlerFunc turns a function with the right signature into a get all HTTP after response rule frontend handler +type GetAllHTTPAfterResponseRuleFrontendHandlerFunc func(GetAllHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPAfterResponseRuleFrontendHandlerFunc) Handle(params GetAllHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPAfterResponseRuleFrontendHandler interface for that can handle valid get all HTTP after response rule frontend params +type GetAllHTTPAfterResponseRuleFrontendHandler interface { + Handle(GetAllHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPAfterResponseRuleFrontend creates a new http.Handler for the get all HTTP after response rule frontend operation +func NewGetAllHTTPAfterResponseRuleFrontend(ctx *middleware.Context, handler GetAllHTTPAfterResponseRuleFrontendHandler) *GetAllHTTPAfterResponseRuleFrontend { + return &GetAllHTTPAfterResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPAfterResponseRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules HTTPAfterResponseRule getAllHttpAfterResponseRuleFrontend + +# Return an array of all HTTP After Response Rules + +Returns all HTTP After Response Rules that are configured in specified parent. +*/ +type GetAllHTTPAfterResponseRuleFrontend struct { + Context *middleware.Context + Handler GetAllHTTPAfterResponseRuleFrontendHandler +} + +func (o *GetAllHTTPAfterResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPAfterResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_parameters.go b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_parameters.go new file mode 100644 index 00000000..1f4ff913 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPAfterResponseRuleFrontendParams creates a new GetAllHTTPAfterResponseRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPAfterResponseRuleFrontendParams() GetAllHTTPAfterResponseRuleFrontendParams { + + return GetAllHTTPAfterResponseRuleFrontendParams{} +} + +// GetAllHTTPAfterResponseRuleFrontendParams contains all the bound params for the get all HTTP after response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPAfterResponseRuleFrontend +type GetAllHTTPAfterResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPAfterResponseRuleFrontendParams() beforehand. +func (o *GetAllHTTPAfterResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPAfterResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPAfterResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_responses.go b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_responses.go new file mode 100644 index 00000000..7420df63 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPAfterResponseRuleFrontendOKCode is the HTTP code returned for type GetAllHTTPAfterResponseRuleFrontendOK +const GetAllHTTPAfterResponseRuleFrontendOKCode int = 200 + +/* +GetAllHTTPAfterResponseRuleFrontendOK Successful operation + +swagger:response getAllHttpAfterResponseRuleFrontendOK +*/ +type GetAllHTTPAfterResponseRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewGetAllHTTPAfterResponseRuleFrontendOK creates GetAllHTTPAfterResponseRuleFrontendOK with default headers values +func NewGetAllHTTPAfterResponseRuleFrontendOK() *GetAllHTTPAfterResponseRuleFrontendOK { + + return &GetAllHTTPAfterResponseRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http after response rule frontend o k response +func (o *GetAllHTTPAfterResponseRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPAfterResponseRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http after response rule frontend o k response +func (o *GetAllHTTPAfterResponseRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http after response rule frontend o k response +func (o *GetAllHTTPAfterResponseRuleFrontendOK) WithPayload(payload models.HTTPAfterResponseRules) *GetAllHTTPAfterResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http after response rule frontend o k response +func (o *GetAllHTTPAfterResponseRuleFrontendOK) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPAfterResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPAfterResponseRuleFrontendDefault General Error + +swagger:response getAllHttpAfterResponseRuleFrontendDefault +*/ +type GetAllHTTPAfterResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPAfterResponseRuleFrontendDefault creates GetAllHTTPAfterResponseRuleFrontendDefault with default headers values +func NewGetAllHTTPAfterResponseRuleFrontendDefault(code int) *GetAllHTTPAfterResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPAfterResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP after response rule frontend default response +func (o *GetAllHTTPAfterResponseRuleFrontendDefault) WithStatusCode(code int) *GetAllHTTPAfterResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP after response rule frontend default response +func (o *GetAllHTTPAfterResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP after response rule frontend default response +func (o *GetAllHTTPAfterResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPAfterResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP after response rule frontend default response +func (o *GetAllHTTPAfterResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP after response rule frontend default response +func (o *GetAllHTTPAfterResponseRuleFrontendDefault) WithPayload(payload *models.Error) *GetAllHTTPAfterResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP after response rule frontend default response +func (o *GetAllHTTPAfterResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPAfterResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_urlbuilder.go b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..4e069d69 --- /dev/null +++ b/operations/http_after_response_rule/get_all_http_after_response_rule_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPAfterResponseRuleFrontendURL generates an URL for the get all HTTP after response rule frontend operation +type GetAllHTTPAfterResponseRuleFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPAfterResponseRuleFrontendURL) WithBasePath(bp string) *GetAllHTTPAfterResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPAfterResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPAfterResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPAfterResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPAfterResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPAfterResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPAfterResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPAfterResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPAfterResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPAfterResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_backend.go b/operations/http_after_response_rule/get_http_after_response_rule_backend.go new file mode 100644 index 00000000..ec42e733 --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPAfterResponseRuleBackendHandlerFunc turns a function with the right signature into a get HTTP after response rule backend handler +type GetHTTPAfterResponseRuleBackendHandlerFunc func(GetHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPAfterResponseRuleBackendHandlerFunc) Handle(params GetHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPAfterResponseRuleBackendHandler interface for that can handle valid get HTTP after response rule backend params +type GetHTTPAfterResponseRuleBackendHandler interface { + Handle(GetHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetHTTPAfterResponseRuleBackend creates a new http.Handler for the get HTTP after response rule backend operation +func NewGetHTTPAfterResponseRuleBackend(ctx *middleware.Context, handler GetHTTPAfterResponseRuleBackendHandler) *GetHTTPAfterResponseRuleBackend { + return &GetHTTPAfterResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetHTTPAfterResponseRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule getHttpAfterResponseRuleBackend + +# Return one HTTP After Response Rule + +Returns one HTTP After Response Rule configuration by it's index in the specified parent. +*/ +type GetHTTPAfterResponseRuleBackend struct { + Context *middleware.Context + Handler GetHTTPAfterResponseRuleBackendHandler +} + +func (o *GetHTTPAfterResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPAfterResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_backend_parameters.go b/operations/http_after_response_rule/get_http_after_response_rule_backend_parameters.go new file mode 100644 index 00000000..a296c30e --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPAfterResponseRuleBackendParams creates a new GetHTTPAfterResponseRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPAfterResponseRuleBackendParams() GetHTTPAfterResponseRuleBackendParams { + + return GetHTTPAfterResponseRuleBackendParams{} +} + +// GetHTTPAfterResponseRuleBackendParams contains all the bound params for the get HTTP after response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPAfterResponseRuleBackend +type GetHTTPAfterResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPAfterResponseRuleBackendParams() beforehand. +func (o *GetHTTPAfterResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPAfterResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPAfterResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPAfterResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_backend_responses.go b/operations/http_after_response_rule/get_http_after_response_rule_backend_responses.go new file mode 100644 index 00000000..15d4e38f --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPAfterResponseRuleBackendOKCode is the HTTP code returned for type GetHTTPAfterResponseRuleBackendOK +const GetHTTPAfterResponseRuleBackendOKCode int = 200 + +/* +GetHTTPAfterResponseRuleBackendOK Successful operation + +swagger:response getHttpAfterResponseRuleBackendOK +*/ +type GetHTTPAfterResponseRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleBackendOK creates GetHTTPAfterResponseRuleBackendOK with default headers values +func NewGetHTTPAfterResponseRuleBackendOK() *GetHTTPAfterResponseRuleBackendOK { + + return &GetHTTPAfterResponseRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http after response rule backend o k response +func (o *GetHTTPAfterResponseRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http after response rule backend o k response +func (o *GetHTTPAfterResponseRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http after response rule backend o k response +func (o *GetHTTPAfterResponseRuleBackendOK) WithPayload(payload *models.HTTPAfterResponseRule) *GetHTTPAfterResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http after response rule backend o k response +func (o *GetHTTPAfterResponseRuleBackendOK) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPAfterResponseRuleBackendNotFoundCode is the HTTP code returned for type GetHTTPAfterResponseRuleBackendNotFound +const GetHTTPAfterResponseRuleBackendNotFoundCode int = 404 + +/* +GetHTTPAfterResponseRuleBackendNotFound The specified resource was not found + +swagger:response getHttpAfterResponseRuleBackendNotFound +*/ +type GetHTTPAfterResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleBackendNotFound creates GetHTTPAfterResponseRuleBackendNotFound with default headers values +func NewGetHTTPAfterResponseRuleBackendNotFound() *GetHTTPAfterResponseRuleBackendNotFound { + + return &GetHTTPAfterResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http after response rule backend not found response +func (o *GetHTTPAfterResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http after response rule backend not found response +func (o *GetHTTPAfterResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http after response rule backend not found response +func (o *GetHTTPAfterResponseRuleBackendNotFound) WithPayload(payload *models.Error) *GetHTTPAfterResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http after response rule backend not found response +func (o *GetHTTPAfterResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPAfterResponseRuleBackendDefault General Error + +swagger:response getHttpAfterResponseRuleBackendDefault +*/ +type GetHTTPAfterResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleBackendDefault creates GetHTTPAfterResponseRuleBackendDefault with default headers values +func NewGetHTTPAfterResponseRuleBackendDefault(code int) *GetHTTPAfterResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPAfterResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP after response rule backend default response +func (o *GetHTTPAfterResponseRuleBackendDefault) WithStatusCode(code int) *GetHTTPAfterResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP after response rule backend default response +func (o *GetHTTPAfterResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP after response rule backend default response +func (o *GetHTTPAfterResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP after response rule backend default response +func (o *GetHTTPAfterResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP after response rule backend default response +func (o *GetHTTPAfterResponseRuleBackendDefault) WithPayload(payload *models.Error) *GetHTTPAfterResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP after response rule backend default response +func (o *GetHTTPAfterResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_backend_urlbuilder.go b/operations/http_after_response_rule/get_http_after_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..192c8de8 --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPAfterResponseRuleBackendURL generates an URL for the get HTTP after response rule backend operation +type GetHTTPAfterResponseRuleBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPAfterResponseRuleBackendURL) WithBasePath(bp string) *GetHTTPAfterResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPAfterResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPAfterResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPAfterResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPAfterResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPAfterResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPAfterResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPAfterResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPAfterResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPAfterResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPAfterResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_defaults.go b/operations/http_after_response_rule/get_http_after_response_rule_defaults.go new file mode 100644 index 00000000..dc69e517 --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPAfterResponseRuleDefaultsHandlerFunc turns a function with the right signature into a get HTTP after response rule defaults handler +type GetHTTPAfterResponseRuleDefaultsHandlerFunc func(GetHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPAfterResponseRuleDefaultsHandlerFunc) Handle(params GetHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPAfterResponseRuleDefaultsHandler interface for that can handle valid get HTTP after response rule defaults params +type GetHTTPAfterResponseRuleDefaultsHandler interface { + Handle(GetHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetHTTPAfterResponseRuleDefaults creates a new http.Handler for the get HTTP after response rule defaults operation +func NewGetHTTPAfterResponseRuleDefaults(ctx *middleware.Context, handler GetHTTPAfterResponseRuleDefaultsHandler) *GetHTTPAfterResponseRuleDefaults { + return &GetHTTPAfterResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetHTTPAfterResponseRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule getHttpAfterResponseRuleDefaults + +# Return one HTTP After Response Rule + +Returns one HTTP After Response Rule configuration by it's index in the specified parent. +*/ +type GetHTTPAfterResponseRuleDefaults struct { + Context *middleware.Context + Handler GetHTTPAfterResponseRuleDefaultsHandler +} + +func (o *GetHTTPAfterResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPAfterResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_defaults_parameters.go b/operations/http_after_response_rule/get_http_after_response_rule_defaults_parameters.go new file mode 100644 index 00000000..339de0e2 --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPAfterResponseRuleDefaultsParams creates a new GetHTTPAfterResponseRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetHTTPAfterResponseRuleDefaultsParams() GetHTTPAfterResponseRuleDefaultsParams { + + return GetHTTPAfterResponseRuleDefaultsParams{} +} + +// GetHTTPAfterResponseRuleDefaultsParams contains all the bound params for the get HTTP after response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPAfterResponseRuleDefaults +type GetHTTPAfterResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPAfterResponseRuleDefaultsParams() beforehand. +func (o *GetHTTPAfterResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPAfterResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPAfterResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPAfterResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_defaults_responses.go b/operations/http_after_response_rule/get_http_after_response_rule_defaults_responses.go new file mode 100644 index 00000000..bc257cec --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPAfterResponseRuleDefaultsOKCode is the HTTP code returned for type GetHTTPAfterResponseRuleDefaultsOK +const GetHTTPAfterResponseRuleDefaultsOKCode int = 200 + +/* +GetHTTPAfterResponseRuleDefaultsOK Successful operation + +swagger:response getHttpAfterResponseRuleDefaultsOK +*/ +type GetHTTPAfterResponseRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleDefaultsOK creates GetHTTPAfterResponseRuleDefaultsOK with default headers values +func NewGetHTTPAfterResponseRuleDefaultsOK() *GetHTTPAfterResponseRuleDefaultsOK { + + return &GetHTTPAfterResponseRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http after response rule defaults o k response +func (o *GetHTTPAfterResponseRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http after response rule defaults o k response +func (o *GetHTTPAfterResponseRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http after response rule defaults o k response +func (o *GetHTTPAfterResponseRuleDefaultsOK) WithPayload(payload *models.HTTPAfterResponseRule) *GetHTTPAfterResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http after response rule defaults o k response +func (o *GetHTTPAfterResponseRuleDefaultsOK) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPAfterResponseRuleDefaultsNotFoundCode is the HTTP code returned for type GetHTTPAfterResponseRuleDefaultsNotFound +const GetHTTPAfterResponseRuleDefaultsNotFoundCode int = 404 + +/* +GetHTTPAfterResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response getHttpAfterResponseRuleDefaultsNotFound +*/ +type GetHTTPAfterResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleDefaultsNotFound creates GetHTTPAfterResponseRuleDefaultsNotFound with default headers values +func NewGetHTTPAfterResponseRuleDefaultsNotFound() *GetHTTPAfterResponseRuleDefaultsNotFound { + + return &GetHTTPAfterResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http after response rule defaults not found response +func (o *GetHTTPAfterResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http after response rule defaults not found response +func (o *GetHTTPAfterResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http after response rule defaults not found response +func (o *GetHTTPAfterResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *GetHTTPAfterResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http after response rule defaults not found response +func (o *GetHTTPAfterResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPAfterResponseRuleDefaultsDefault General Error + +swagger:response getHttpAfterResponseRuleDefaultsDefault +*/ +type GetHTTPAfterResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleDefaultsDefault creates GetHTTPAfterResponseRuleDefaultsDefault with default headers values +func NewGetHTTPAfterResponseRuleDefaultsDefault(code int) *GetHTTPAfterResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPAfterResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP after response rule defaults default response +func (o *GetHTTPAfterResponseRuleDefaultsDefault) WithStatusCode(code int) *GetHTTPAfterResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP after response rule defaults default response +func (o *GetHTTPAfterResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP after response rule defaults default response +func (o *GetHTTPAfterResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP after response rule defaults default response +func (o *GetHTTPAfterResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP after response rule defaults default response +func (o *GetHTTPAfterResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *GetHTTPAfterResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP after response rule defaults default response +func (o *GetHTTPAfterResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_defaults_urlbuilder.go b/operations/http_after_response_rule/get_http_after_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..4ffb9146 --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPAfterResponseRuleDefaultsURL generates an URL for the get HTTP after response rule defaults operation +type GetHTTPAfterResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPAfterResponseRuleDefaultsURL) WithBasePath(bp string) *GetHTTPAfterResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPAfterResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPAfterResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPAfterResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPAfterResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPAfterResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPAfterResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPAfterResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPAfterResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPAfterResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPAfterResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_frontend.go b/operations/http_after_response_rule/get_http_after_response_rule_frontend.go new file mode 100644 index 00000000..58eb6ea7 --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPAfterResponseRuleFrontendHandlerFunc turns a function with the right signature into a get HTTP after response rule frontend handler +type GetHTTPAfterResponseRuleFrontendHandlerFunc func(GetHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPAfterResponseRuleFrontendHandlerFunc) Handle(params GetHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPAfterResponseRuleFrontendHandler interface for that can handle valid get HTTP after response rule frontend params +type GetHTTPAfterResponseRuleFrontendHandler interface { + Handle(GetHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetHTTPAfterResponseRuleFrontend creates a new http.Handler for the get HTTP after response rule frontend operation +func NewGetHTTPAfterResponseRuleFrontend(ctx *middleware.Context, handler GetHTTPAfterResponseRuleFrontendHandler) *GetHTTPAfterResponseRuleFrontend { + return &GetHTTPAfterResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetHTTPAfterResponseRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule getHttpAfterResponseRuleFrontend + +# Return one HTTP After Response Rule + +Returns one HTTP After Response Rule configuration by it's index in the specified parent. +*/ +type GetHTTPAfterResponseRuleFrontend struct { + Context *middleware.Context + Handler GetHTTPAfterResponseRuleFrontendHandler +} + +func (o *GetHTTPAfterResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPAfterResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_frontend_parameters.go b/operations/http_after_response_rule/get_http_after_response_rule_frontend_parameters.go new file mode 100644 index 00000000..af73db0d --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPAfterResponseRuleFrontendParams creates a new GetHTTPAfterResponseRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPAfterResponseRuleFrontendParams() GetHTTPAfterResponseRuleFrontendParams { + + return GetHTTPAfterResponseRuleFrontendParams{} +} + +// GetHTTPAfterResponseRuleFrontendParams contains all the bound params for the get HTTP after response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPAfterResponseRuleFrontend +type GetHTTPAfterResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPAfterResponseRuleFrontendParams() beforehand. +func (o *GetHTTPAfterResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPAfterResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPAfterResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPAfterResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_frontend_responses.go b/operations/http_after_response_rule/get_http_after_response_rule_frontend_responses.go new file mode 100644 index 00000000..f672ab1c --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPAfterResponseRuleFrontendOKCode is the HTTP code returned for type GetHTTPAfterResponseRuleFrontendOK +const GetHTTPAfterResponseRuleFrontendOKCode int = 200 + +/* +GetHTTPAfterResponseRuleFrontendOK Successful operation + +swagger:response getHttpAfterResponseRuleFrontendOK +*/ +type GetHTTPAfterResponseRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleFrontendOK creates GetHTTPAfterResponseRuleFrontendOK with default headers values +func NewGetHTTPAfterResponseRuleFrontendOK() *GetHTTPAfterResponseRuleFrontendOK { + + return &GetHTTPAfterResponseRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http after response rule frontend o k response +func (o *GetHTTPAfterResponseRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http after response rule frontend o k response +func (o *GetHTTPAfterResponseRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http after response rule frontend o k response +func (o *GetHTTPAfterResponseRuleFrontendOK) WithPayload(payload *models.HTTPAfterResponseRule) *GetHTTPAfterResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http after response rule frontend o k response +func (o *GetHTTPAfterResponseRuleFrontendOK) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPAfterResponseRuleFrontendNotFoundCode is the HTTP code returned for type GetHTTPAfterResponseRuleFrontendNotFound +const GetHTTPAfterResponseRuleFrontendNotFoundCode int = 404 + +/* +GetHTTPAfterResponseRuleFrontendNotFound The specified resource was not found + +swagger:response getHttpAfterResponseRuleFrontendNotFound +*/ +type GetHTTPAfterResponseRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleFrontendNotFound creates GetHTTPAfterResponseRuleFrontendNotFound with default headers values +func NewGetHTTPAfterResponseRuleFrontendNotFound() *GetHTTPAfterResponseRuleFrontendNotFound { + + return &GetHTTPAfterResponseRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http after response rule frontend not found response +func (o *GetHTTPAfterResponseRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http after response rule frontend not found response +func (o *GetHTTPAfterResponseRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http after response rule frontend not found response +func (o *GetHTTPAfterResponseRuleFrontendNotFound) WithPayload(payload *models.Error) *GetHTTPAfterResponseRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http after response rule frontend not found response +func (o *GetHTTPAfterResponseRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPAfterResponseRuleFrontendDefault General Error + +swagger:response getHttpAfterResponseRuleFrontendDefault +*/ +type GetHTTPAfterResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPAfterResponseRuleFrontendDefault creates GetHTTPAfterResponseRuleFrontendDefault with default headers values +func NewGetHTTPAfterResponseRuleFrontendDefault(code int) *GetHTTPAfterResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPAfterResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP after response rule frontend default response +func (o *GetHTTPAfterResponseRuleFrontendDefault) WithStatusCode(code int) *GetHTTPAfterResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP after response rule frontend default response +func (o *GetHTTPAfterResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP after response rule frontend default response +func (o *GetHTTPAfterResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPAfterResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP after response rule frontend default response +func (o *GetHTTPAfterResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP after response rule frontend default response +func (o *GetHTTPAfterResponseRuleFrontendDefault) WithPayload(payload *models.Error) *GetHTTPAfterResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP after response rule frontend default response +func (o *GetHTTPAfterResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPAfterResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/get_http_after_response_rule_frontend_urlbuilder.go b/operations/http_after_response_rule/get_http_after_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..94dfe8cd --- /dev/null +++ b/operations/http_after_response_rule/get_http_after_response_rule_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPAfterResponseRuleFrontendURL generates an URL for the get HTTP after response rule frontend operation +type GetHTTPAfterResponseRuleFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPAfterResponseRuleFrontendURL) WithBasePath(bp string) *GetHTTPAfterResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPAfterResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPAfterResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPAfterResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPAfterResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPAfterResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPAfterResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPAfterResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPAfterResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPAfterResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPAfterResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_backend.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend.go new file mode 100644 index 00000000..8e7a7b99 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPAfterResponseRuleBackendHandlerFunc turns a function with the right signature into a replace all HTTP after response rule backend handler +type ReplaceAllHTTPAfterResponseRuleBackendHandlerFunc func(ReplaceAllHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPAfterResponseRuleBackendHandlerFunc) Handle(params ReplaceAllHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPAfterResponseRuleBackendHandler interface for that can handle valid replace all HTTP after response rule backend params +type ReplaceAllHTTPAfterResponseRuleBackendHandler interface { + Handle(ReplaceAllHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPAfterResponseRuleBackend creates a new http.Handler for the replace all HTTP after response rule backend operation +func NewReplaceAllHTTPAfterResponseRuleBackend(ctx *middleware.Context, handler ReplaceAllHTTPAfterResponseRuleBackendHandler) *ReplaceAllHTTPAfterResponseRuleBackend { + return &ReplaceAllHTTPAfterResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPAfterResponseRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_after_response_rules HTTPAfterResponseRule replaceAllHttpAfterResponseRuleBackend + +# Replace an HTTP After Response Rules list + +Replaces a whole list of HTTP After Response Rules with the list given in parameter +*/ +type ReplaceAllHTTPAfterResponseRuleBackend struct { + Context *middleware.Context + Handler ReplaceAllHTTPAfterResponseRuleBackendHandler +} + +func (o *ReplaceAllHTTPAfterResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPAfterResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_parameters.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_parameters.go new file mode 100644 index 00000000..6f98b854 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPAfterResponseRuleBackendParams creates a new ReplaceAllHTTPAfterResponseRuleBackendParams object +// with the default values initialized. +func NewReplaceAllHTTPAfterResponseRuleBackendParams() ReplaceAllHTTPAfterResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPAfterResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPAfterResponseRuleBackendParams contains all the bound params for the replace all HTTP after response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPAfterResponseRuleBackend +type ReplaceAllHTTPAfterResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPAfterResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPAfterResponseRuleBackendParams() beforehand. +func (o *ReplaceAllHTTPAfterResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPAfterResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPAfterResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPAfterResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPAfterResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPAfterResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_responses.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_responses.go new file mode 100644 index 00000000..a1f90582 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPAfterResponseRuleBackendOKCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleBackendOK +const ReplaceAllHTTPAfterResponseRuleBackendOKCode int = 200 + +/* +ReplaceAllHTTPAfterResponseRuleBackendOK All TTP After Response Rules lines replaced + +swagger:response replaceAllHttpAfterResponseRuleBackendOK +*/ +type ReplaceAllHTTPAfterResponseRuleBackendOK struct { + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleBackendOK creates ReplaceAllHTTPAfterResponseRuleBackendOK with default headers values +func NewReplaceAllHTTPAfterResponseRuleBackendOK() *ReplaceAllHTTPAfterResponseRuleBackendOK { + + return &ReplaceAllHTTPAfterResponseRuleBackendOK{} +} + +// WithPayload adds the payload to the replace all Http after response rule backend o k response +func (o *ReplaceAllHTTPAfterResponseRuleBackendOK) WithPayload(payload models.HTTPAfterResponseRules) *ReplaceAllHTTPAfterResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule backend o k response +func (o *ReplaceAllHTTPAfterResponseRuleBackendOK) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPAfterResponseRuleBackendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleBackendAccepted +const ReplaceAllHTTPAfterResponseRuleBackendAcceptedCode int = 202 + +/* +ReplaceAllHTTPAfterResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpAfterResponseRuleBackendAccepted +*/ +type ReplaceAllHTTPAfterResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleBackendAccepted creates ReplaceAllHTTPAfterResponseRuleBackendAccepted with default headers values +func NewReplaceAllHTTPAfterResponseRuleBackendAccepted() *ReplaceAllHTTPAfterResponseRuleBackendAccepted { + + return &ReplaceAllHTTPAfterResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http after response rule backend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPAfterResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http after response rule backend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http after response rule backend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleBackendAccepted) WithPayload(payload models.HTTPAfterResponseRules) *ReplaceAllHTTPAfterResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule backend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleBackendAccepted) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPAfterResponseRuleBackendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleBackendBadRequest +const ReplaceAllHTTPAfterResponseRuleBackendBadRequestCode int = 400 + +/* +ReplaceAllHTTPAfterResponseRuleBackendBadRequest Bad request + +swagger:response replaceAllHttpAfterResponseRuleBackendBadRequest +*/ +type ReplaceAllHTTPAfterResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleBackendBadRequest creates ReplaceAllHTTPAfterResponseRuleBackendBadRequest with default headers values +func NewReplaceAllHTTPAfterResponseRuleBackendBadRequest() *ReplaceAllHTTPAfterResponseRuleBackendBadRequest { + + return &ReplaceAllHTTPAfterResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http after response rule backend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPAfterResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http after response rule backend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http after response rule backend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPAfterResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule backend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPAfterResponseRuleBackendDefault General Error + +swagger:response replaceAllHttpAfterResponseRuleBackendDefault +*/ +type ReplaceAllHTTPAfterResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleBackendDefault creates ReplaceAllHTTPAfterResponseRuleBackendDefault with default headers values +func NewReplaceAllHTTPAfterResponseRuleBackendDefault(code int) *ReplaceAllHTTPAfterResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPAfterResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP after response rule backend default response +func (o *ReplaceAllHTTPAfterResponseRuleBackendDefault) WithStatusCode(code int) *ReplaceAllHTTPAfterResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP after response rule backend default response +func (o *ReplaceAllHTTPAfterResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP after response rule backend default response +func (o *ReplaceAllHTTPAfterResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPAfterResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP after response rule backend default response +func (o *ReplaceAllHTTPAfterResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP after response rule backend default response +func (o *ReplaceAllHTTPAfterResponseRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPAfterResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP after response rule backend default response +func (o *ReplaceAllHTTPAfterResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_urlbuilder.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..aa4d9aeb --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPAfterResponseRuleBackendURL generates an URL for the replace all HTTP after response rule backend operation +type ReplaceAllHTTPAfterResponseRuleBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPAfterResponseRuleBackendURL) WithBasePath(bp string) *ReplaceAllHTTPAfterResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPAfterResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPAfterResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPAfterResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPAfterResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPAfterResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPAfterResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPAfterResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPAfterResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPAfterResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults.go new file mode 100644 index 00000000..c62c30f6 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPAfterResponseRuleDefaultsHandlerFunc turns a function with the right signature into a replace all HTTP after response rule defaults handler +type ReplaceAllHTTPAfterResponseRuleDefaultsHandlerFunc func(ReplaceAllHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPAfterResponseRuleDefaultsHandlerFunc) Handle(params ReplaceAllHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPAfterResponseRuleDefaultsHandler interface for that can handle valid replace all HTTP after response rule defaults params +type ReplaceAllHTTPAfterResponseRuleDefaultsHandler interface { + Handle(ReplaceAllHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPAfterResponseRuleDefaults creates a new http.Handler for the replace all HTTP after response rule defaults operation +func NewReplaceAllHTTPAfterResponseRuleDefaults(ctx *middleware.Context, handler ReplaceAllHTTPAfterResponseRuleDefaultsHandler) *ReplaceAllHTTPAfterResponseRuleDefaults { + return &ReplaceAllHTTPAfterResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPAfterResponseRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules HTTPAfterResponseRule replaceAllHttpAfterResponseRuleDefaults + +# Replace an HTTP After Response Rules list + +Replaces a whole list of HTTP After Response Rules with the list given in parameter +*/ +type ReplaceAllHTTPAfterResponseRuleDefaults struct { + Context *middleware.Context + Handler ReplaceAllHTTPAfterResponseRuleDefaultsHandler +} + +func (o *ReplaceAllHTTPAfterResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPAfterResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_parameters.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_parameters.go new file mode 100644 index 00000000..345e37ea --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPAfterResponseRuleDefaultsParams creates a new ReplaceAllHTTPAfterResponseRuleDefaultsParams object +// with the default values initialized. +func NewReplaceAllHTTPAfterResponseRuleDefaultsParams() ReplaceAllHTTPAfterResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPAfterResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPAfterResponseRuleDefaultsParams contains all the bound params for the replace all HTTP after response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPAfterResponseRuleDefaults +type ReplaceAllHTTPAfterResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPAfterResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPAfterResponseRuleDefaultsParams() beforehand. +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPAfterResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_responses.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_responses.go new file mode 100644 index 00000000..1ba0806d --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPAfterResponseRuleDefaultsOKCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleDefaultsOK +const ReplaceAllHTTPAfterResponseRuleDefaultsOKCode int = 200 + +/* +ReplaceAllHTTPAfterResponseRuleDefaultsOK All TTP After Response Rules lines replaced + +swagger:response replaceAllHttpAfterResponseRuleDefaultsOK +*/ +type ReplaceAllHTTPAfterResponseRuleDefaultsOK struct { + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleDefaultsOK creates ReplaceAllHTTPAfterResponseRuleDefaultsOK with default headers values +func NewReplaceAllHTTPAfterResponseRuleDefaultsOK() *ReplaceAllHTTPAfterResponseRuleDefaultsOK { + + return &ReplaceAllHTTPAfterResponseRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Http after response rule defaults o k response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsOK) WithPayload(payload models.HTTPAfterResponseRules) *ReplaceAllHTTPAfterResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule defaults o k response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsOK) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPAfterResponseRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleDefaultsAccepted +const ReplaceAllHTTPAfterResponseRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceAllHTTPAfterResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpAfterResponseRuleDefaultsAccepted +*/ +type ReplaceAllHTTPAfterResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleDefaultsAccepted creates ReplaceAllHTTPAfterResponseRuleDefaultsAccepted with default headers values +func NewReplaceAllHTTPAfterResponseRuleDefaultsAccepted() *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted { + + return &ReplaceAllHTTPAfterResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http after response rule defaults accepted response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http after response rule defaults accepted response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http after response rule defaults accepted response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted) WithPayload(payload models.HTTPAfterResponseRules) *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule defaults accepted response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPAfterResponseRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest +const ReplaceAllHTTPAfterResponseRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest Bad request + +swagger:response replaceAllHttpAfterResponseRuleDefaultsBadRequest +*/ +type ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleDefaultsBadRequest creates ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest with default headers values +func NewReplaceAllHTTPAfterResponseRuleDefaultsBadRequest() *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest { + + return &ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http after response rule defaults bad request response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http after response rule defaults bad request response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http after response rule defaults bad request response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule defaults bad request response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPAfterResponseRuleDefaultsDefault General Error + +swagger:response replaceAllHttpAfterResponseRuleDefaultsDefault +*/ +type ReplaceAllHTTPAfterResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleDefaultsDefault creates ReplaceAllHTTPAfterResponseRuleDefaultsDefault with default headers values +func NewReplaceAllHTTPAfterResponseRuleDefaultsDefault(code int) *ReplaceAllHTTPAfterResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPAfterResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP after response rule defaults default response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsDefault) WithStatusCode(code int) *ReplaceAllHTTPAfterResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP after response rule defaults default response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP after response rule defaults default response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPAfterResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP after response rule defaults default response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP after response rule defaults default response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPAfterResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP after response rule defaults default response +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_urlbuilder.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..ba516977 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPAfterResponseRuleDefaultsURL generates an URL for the replace all HTTP after response rule defaults operation +type ReplaceAllHTTPAfterResponseRuleDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsURL) WithBasePath(bp string) *ReplaceAllHTTPAfterResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPAfterResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPAfterResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPAfterResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPAfterResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend.go new file mode 100644 index 00000000..10ecff47 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPAfterResponseRuleFrontendHandlerFunc turns a function with the right signature into a replace all HTTP after response rule frontend handler +type ReplaceAllHTTPAfterResponseRuleFrontendHandlerFunc func(ReplaceAllHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPAfterResponseRuleFrontendHandlerFunc) Handle(params ReplaceAllHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPAfterResponseRuleFrontendHandler interface for that can handle valid replace all HTTP after response rule frontend params +type ReplaceAllHTTPAfterResponseRuleFrontendHandler interface { + Handle(ReplaceAllHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPAfterResponseRuleFrontend creates a new http.Handler for the replace all HTTP after response rule frontend operation +func NewReplaceAllHTTPAfterResponseRuleFrontend(ctx *middleware.Context, handler ReplaceAllHTTPAfterResponseRuleFrontendHandler) *ReplaceAllHTTPAfterResponseRuleFrontend { + return &ReplaceAllHTTPAfterResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPAfterResponseRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules HTTPAfterResponseRule replaceAllHttpAfterResponseRuleFrontend + +# Replace an HTTP After Response Rules list + +Replaces a whole list of HTTP After Response Rules with the list given in parameter +*/ +type ReplaceAllHTTPAfterResponseRuleFrontend struct { + Context *middleware.Context + Handler ReplaceAllHTTPAfterResponseRuleFrontendHandler +} + +func (o *ReplaceAllHTTPAfterResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPAfterResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_parameters.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_parameters.go new file mode 100644 index 00000000..8ea77a58 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPAfterResponseRuleFrontendParams creates a new ReplaceAllHTTPAfterResponseRuleFrontendParams object +// with the default values initialized. +func NewReplaceAllHTTPAfterResponseRuleFrontendParams() ReplaceAllHTTPAfterResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPAfterResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPAfterResponseRuleFrontendParams contains all the bound params for the replace all HTTP after response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPAfterResponseRuleFrontend +type ReplaceAllHTTPAfterResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPAfterResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPAfterResponseRuleFrontendParams() beforehand. +func (o *ReplaceAllHTTPAfterResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPAfterResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPAfterResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPAfterResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPAfterResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPAfterResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_responses.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_responses.go new file mode 100644 index 00000000..949f4ba9 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPAfterResponseRuleFrontendOKCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleFrontendOK +const ReplaceAllHTTPAfterResponseRuleFrontendOKCode int = 200 + +/* +ReplaceAllHTTPAfterResponseRuleFrontendOK All TTP After Response Rules lines replaced + +swagger:response replaceAllHttpAfterResponseRuleFrontendOK +*/ +type ReplaceAllHTTPAfterResponseRuleFrontendOK struct { + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleFrontendOK creates ReplaceAllHTTPAfterResponseRuleFrontendOK with default headers values +func NewReplaceAllHTTPAfterResponseRuleFrontendOK() *ReplaceAllHTTPAfterResponseRuleFrontendOK { + + return &ReplaceAllHTTPAfterResponseRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace all Http after response rule frontend o k response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendOK) WithPayload(payload models.HTTPAfterResponseRules) *ReplaceAllHTTPAfterResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule frontend o k response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendOK) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPAfterResponseRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleFrontendAccepted +const ReplaceAllHTTPAfterResponseRuleFrontendAcceptedCode int = 202 + +/* +ReplaceAllHTTPAfterResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpAfterResponseRuleFrontendAccepted +*/ +type ReplaceAllHTTPAfterResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPAfterResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleFrontendAccepted creates ReplaceAllHTTPAfterResponseRuleFrontendAccepted with default headers values +func NewReplaceAllHTTPAfterResponseRuleFrontendAccepted() *ReplaceAllHTTPAfterResponseRuleFrontendAccepted { + + return &ReplaceAllHTTPAfterResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http after response rule frontend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPAfterResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http after response rule frontend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http after response rule frontend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendAccepted) WithPayload(payload models.HTTPAfterResponseRules) *ReplaceAllHTTPAfterResponseRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule frontend accepted response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendAccepted) SetPayload(payload models.HTTPAfterResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPAfterResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPAfterResponseRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPAfterResponseRuleFrontendBadRequest +const ReplaceAllHTTPAfterResponseRuleFrontendBadRequestCode int = 400 + +/* +ReplaceAllHTTPAfterResponseRuleFrontendBadRequest Bad request + +swagger:response replaceAllHttpAfterResponseRuleFrontendBadRequest +*/ +type ReplaceAllHTTPAfterResponseRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleFrontendBadRequest creates ReplaceAllHTTPAfterResponseRuleFrontendBadRequest with default headers values +func NewReplaceAllHTTPAfterResponseRuleFrontendBadRequest() *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest { + + return &ReplaceAllHTTPAfterResponseRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http after response rule frontend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http after response rule frontend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http after response rule frontend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http after response rule frontend bad request response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPAfterResponseRuleFrontendDefault General Error + +swagger:response replaceAllHttpAfterResponseRuleFrontendDefault +*/ +type ReplaceAllHTTPAfterResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPAfterResponseRuleFrontendDefault creates ReplaceAllHTTPAfterResponseRuleFrontendDefault with default headers values +func NewReplaceAllHTTPAfterResponseRuleFrontendDefault(code int) *ReplaceAllHTTPAfterResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPAfterResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP after response rule frontend default response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendDefault) WithStatusCode(code int) *ReplaceAllHTTPAfterResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP after response rule frontend default response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP after response rule frontend default response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPAfterResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP after response rule frontend default response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP after response rule frontend default response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPAfterResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP after response rule frontend default response +func (o *ReplaceAllHTTPAfterResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPAfterResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_urlbuilder.go b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..8b82f6d7 --- /dev/null +++ b/operations/http_after_response_rule/replace_all_http_after_response_rule_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPAfterResponseRuleFrontendURL generates an URL for the replace all HTTP after response rule frontend operation +type ReplaceAllHTTPAfterResponseRuleFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPAfterResponseRuleFrontendURL) WithBasePath(bp string) *ReplaceAllHTTPAfterResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPAfterResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPAfterResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPAfterResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPAfterResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPAfterResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPAfterResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPAfterResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPAfterResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPAfterResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_backend.go b/operations/http_after_response_rule/replace_http_after_response_rule_backend.go new file mode 100644 index 00000000..c9860cd7 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPAfterResponseRuleBackendHandlerFunc turns a function with the right signature into a replace HTTP after response rule backend handler +type ReplaceHTTPAfterResponseRuleBackendHandlerFunc func(ReplaceHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPAfterResponseRuleBackendHandlerFunc) Handle(params ReplaceHTTPAfterResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPAfterResponseRuleBackendHandler interface for that can handle valid replace HTTP after response rule backend params +type ReplaceHTTPAfterResponseRuleBackendHandler interface { + Handle(ReplaceHTTPAfterResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPAfterResponseRuleBackend creates a new http.Handler for the replace HTTP after response rule backend operation +func NewReplaceHTTPAfterResponseRuleBackend(ctx *middleware.Context, handler ReplaceHTTPAfterResponseRuleBackendHandler) *ReplaceHTTPAfterResponseRuleBackend { + return &ReplaceHTTPAfterResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPAfterResponseRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule replaceHttpAfterResponseRuleBackend + +# Replace a HTTP After Response Rule + +Replaces a HTTP After Response Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPAfterResponseRuleBackend struct { + Context *middleware.Context + Handler ReplaceHTTPAfterResponseRuleBackendHandler +} + +func (o *ReplaceHTTPAfterResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPAfterResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_backend_parameters.go b/operations/http_after_response_rule/replace_http_after_response_rule_backend_parameters.go new file mode 100644 index 00000000..477be655 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPAfterResponseRuleBackendParams creates a new ReplaceHTTPAfterResponseRuleBackendParams object +// with the default values initialized. +func NewReplaceHTTPAfterResponseRuleBackendParams() ReplaceHTTPAfterResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPAfterResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPAfterResponseRuleBackendParams contains all the bound params for the replace HTTP after response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPAfterResponseRuleBackend +type ReplaceHTTPAfterResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPAfterResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPAfterResponseRuleBackendParams() beforehand. +func (o *ReplaceHTTPAfterResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPAfterResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPAfterResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPAfterResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPAfterResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPAfterResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPAfterResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_backend_responses.go b/operations/http_after_response_rule/replace_http_after_response_rule_backend_responses.go new file mode 100644 index 00000000..cb0b17a7 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPAfterResponseRuleBackendOKCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleBackendOK +const ReplaceHTTPAfterResponseRuleBackendOKCode int = 200 + +/* +ReplaceHTTPAfterResponseRuleBackendOK HTTP After Response Rule replaced + +swagger:response replaceHttpAfterResponseRuleBackendOK +*/ +type ReplaceHTTPAfterResponseRuleBackendOK struct { + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleBackendOK creates ReplaceHTTPAfterResponseRuleBackendOK with default headers values +func NewReplaceHTTPAfterResponseRuleBackendOK() *ReplaceHTTPAfterResponseRuleBackendOK { + + return &ReplaceHTTPAfterResponseRuleBackendOK{} +} + +// WithPayload adds the payload to the replace Http after response rule backend o k response +func (o *ReplaceHTTPAfterResponseRuleBackendOK) WithPayload(payload *models.HTTPAfterResponseRule) *ReplaceHTTPAfterResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule backend o k response +func (o *ReplaceHTTPAfterResponseRuleBackendOK) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleBackendAcceptedCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleBackendAccepted +const ReplaceHTTPAfterResponseRuleBackendAcceptedCode int = 202 + +/* +ReplaceHTTPAfterResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpAfterResponseRuleBackendAccepted +*/ +type ReplaceHTTPAfterResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleBackendAccepted creates ReplaceHTTPAfterResponseRuleBackendAccepted with default headers values +func NewReplaceHTTPAfterResponseRuleBackendAccepted() *ReplaceHTTPAfterResponseRuleBackendAccepted { + + return &ReplaceHTTPAfterResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http after response rule backend accepted response +func (o *ReplaceHTTPAfterResponseRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceHTTPAfterResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http after response rule backend accepted response +func (o *ReplaceHTTPAfterResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http after response rule backend accepted response +func (o *ReplaceHTTPAfterResponseRuleBackendAccepted) WithPayload(payload *models.HTTPAfterResponseRule) *ReplaceHTTPAfterResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule backend accepted response +func (o *ReplaceHTTPAfterResponseRuleBackendAccepted) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleBackendBadRequestCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleBackendBadRequest +const ReplaceHTTPAfterResponseRuleBackendBadRequestCode int = 400 + +/* +ReplaceHTTPAfterResponseRuleBackendBadRequest Bad request + +swagger:response replaceHttpAfterResponseRuleBackendBadRequest +*/ +type ReplaceHTTPAfterResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleBackendBadRequest creates ReplaceHTTPAfterResponseRuleBackendBadRequest with default headers values +func NewReplaceHTTPAfterResponseRuleBackendBadRequest() *ReplaceHTTPAfterResponseRuleBackendBadRequest { + + return &ReplaceHTTPAfterResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http after response rule backend bad request response +func (o *ReplaceHTTPAfterResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http after response rule backend bad request response +func (o *ReplaceHTTPAfterResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http after response rule backend bad request response +func (o *ReplaceHTTPAfterResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule backend bad request response +func (o *ReplaceHTTPAfterResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleBackendNotFoundCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleBackendNotFound +const ReplaceHTTPAfterResponseRuleBackendNotFoundCode int = 404 + +/* +ReplaceHTTPAfterResponseRuleBackendNotFound The specified resource was not found + +swagger:response replaceHttpAfterResponseRuleBackendNotFound +*/ +type ReplaceHTTPAfterResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleBackendNotFound creates ReplaceHTTPAfterResponseRuleBackendNotFound with default headers values +func NewReplaceHTTPAfterResponseRuleBackendNotFound() *ReplaceHTTPAfterResponseRuleBackendNotFound { + + return &ReplaceHTTPAfterResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http after response rule backend not found response +func (o *ReplaceHTTPAfterResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http after response rule backend not found response +func (o *ReplaceHTTPAfterResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http after response rule backend not found response +func (o *ReplaceHTTPAfterResponseRuleBackendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule backend not found response +func (o *ReplaceHTTPAfterResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPAfterResponseRuleBackendDefault General Error + +swagger:response replaceHttpAfterResponseRuleBackendDefault +*/ +type ReplaceHTTPAfterResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleBackendDefault creates ReplaceHTTPAfterResponseRuleBackendDefault with default headers values +func NewReplaceHTTPAfterResponseRuleBackendDefault(code int) *ReplaceHTTPAfterResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPAfterResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP after response rule backend default response +func (o *ReplaceHTTPAfterResponseRuleBackendDefault) WithStatusCode(code int) *ReplaceHTTPAfterResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP after response rule backend default response +func (o *ReplaceHTTPAfterResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP after response rule backend default response +func (o *ReplaceHTTPAfterResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP after response rule backend default response +func (o *ReplaceHTTPAfterResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP after response rule backend default response +func (o *ReplaceHTTPAfterResponseRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP after response rule backend default response +func (o *ReplaceHTTPAfterResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_backend_urlbuilder.go b/operations/http_after_response_rule/replace_http_after_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..1d81f287 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPAfterResponseRuleBackendURL generates an URL for the replace HTTP after response rule backend operation +type ReplaceHTTPAfterResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPAfterResponseRuleBackendURL) WithBasePath(bp string) *ReplaceHTTPAfterResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPAfterResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPAfterResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPAfterResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPAfterResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPAfterResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPAfterResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPAfterResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPAfterResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPAfterResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPAfterResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_defaults.go b/operations/http_after_response_rule/replace_http_after_response_rule_defaults.go new file mode 100644 index 00000000..47391e46 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPAfterResponseRuleDefaultsHandlerFunc turns a function with the right signature into a replace HTTP after response rule defaults handler +type ReplaceHTTPAfterResponseRuleDefaultsHandlerFunc func(ReplaceHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPAfterResponseRuleDefaultsHandlerFunc) Handle(params ReplaceHTTPAfterResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPAfterResponseRuleDefaultsHandler interface for that can handle valid replace HTTP after response rule defaults params +type ReplaceHTTPAfterResponseRuleDefaultsHandler interface { + Handle(ReplaceHTTPAfterResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPAfterResponseRuleDefaults creates a new http.Handler for the replace HTTP after response rule defaults operation +func NewReplaceHTTPAfterResponseRuleDefaults(ctx *middleware.Context, handler ReplaceHTTPAfterResponseRuleDefaultsHandler) *ReplaceHTTPAfterResponseRuleDefaults { + return &ReplaceHTTPAfterResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPAfterResponseRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule replaceHttpAfterResponseRuleDefaults + +# Replace a HTTP After Response Rule + +Replaces a HTTP After Response Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPAfterResponseRuleDefaults struct { + Context *middleware.Context + Handler ReplaceHTTPAfterResponseRuleDefaultsHandler +} + +func (o *ReplaceHTTPAfterResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPAfterResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_defaults_parameters.go b/operations/http_after_response_rule/replace_http_after_response_rule_defaults_parameters.go new file mode 100644 index 00000000..73c11bee --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPAfterResponseRuleDefaultsParams creates a new ReplaceHTTPAfterResponseRuleDefaultsParams object +// with the default values initialized. +func NewReplaceHTTPAfterResponseRuleDefaultsParams() ReplaceHTTPAfterResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPAfterResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPAfterResponseRuleDefaultsParams contains all the bound params for the replace HTTP after response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPAfterResponseRuleDefaults +type ReplaceHTTPAfterResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPAfterResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPAfterResponseRuleDefaultsParams() beforehand. +func (o *ReplaceHTTPAfterResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPAfterResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPAfterResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPAfterResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPAfterResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPAfterResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPAfterResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_defaults_responses.go b/operations/http_after_response_rule/replace_http_after_response_rule_defaults_responses.go new file mode 100644 index 00000000..6bd6deb6 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPAfterResponseRuleDefaultsOKCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleDefaultsOK +const ReplaceHTTPAfterResponseRuleDefaultsOKCode int = 200 + +/* +ReplaceHTTPAfterResponseRuleDefaultsOK HTTP After Response Rule replaced + +swagger:response replaceHttpAfterResponseRuleDefaultsOK +*/ +type ReplaceHTTPAfterResponseRuleDefaultsOK struct { + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleDefaultsOK creates ReplaceHTTPAfterResponseRuleDefaultsOK with default headers values +func NewReplaceHTTPAfterResponseRuleDefaultsOK() *ReplaceHTTPAfterResponseRuleDefaultsOK { + + return &ReplaceHTTPAfterResponseRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace Http after response rule defaults o k response +func (o *ReplaceHTTPAfterResponseRuleDefaultsOK) WithPayload(payload *models.HTTPAfterResponseRule) *ReplaceHTTPAfterResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule defaults o k response +func (o *ReplaceHTTPAfterResponseRuleDefaultsOK) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleDefaultsAccepted +const ReplaceHTTPAfterResponseRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceHTTPAfterResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpAfterResponseRuleDefaultsAccepted +*/ +type ReplaceHTTPAfterResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleDefaultsAccepted creates ReplaceHTTPAfterResponseRuleDefaultsAccepted with default headers values +func NewReplaceHTTPAfterResponseRuleDefaultsAccepted() *ReplaceHTTPAfterResponseRuleDefaultsAccepted { + + return &ReplaceHTTPAfterResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http after response rule defaults accepted response +func (o *ReplaceHTTPAfterResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceHTTPAfterResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http after response rule defaults accepted response +func (o *ReplaceHTTPAfterResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http after response rule defaults accepted response +func (o *ReplaceHTTPAfterResponseRuleDefaultsAccepted) WithPayload(payload *models.HTTPAfterResponseRule) *ReplaceHTTPAfterResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule defaults accepted response +func (o *ReplaceHTTPAfterResponseRuleDefaultsAccepted) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleDefaultsBadRequest +const ReplaceHTTPAfterResponseRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceHTTPAfterResponseRuleDefaultsBadRequest Bad request + +swagger:response replaceHttpAfterResponseRuleDefaultsBadRequest +*/ +type ReplaceHTTPAfterResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleDefaultsBadRequest creates ReplaceHTTPAfterResponseRuleDefaultsBadRequest with default headers values +func NewReplaceHTTPAfterResponseRuleDefaultsBadRequest() *ReplaceHTTPAfterResponseRuleDefaultsBadRequest { + + return &ReplaceHTTPAfterResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http after response rule defaults bad request response +func (o *ReplaceHTTPAfterResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http after response rule defaults bad request response +func (o *ReplaceHTTPAfterResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http after response rule defaults bad request response +func (o *ReplaceHTTPAfterResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule defaults bad request response +func (o *ReplaceHTTPAfterResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleDefaultsNotFoundCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleDefaultsNotFound +const ReplaceHTTPAfterResponseRuleDefaultsNotFoundCode int = 404 + +/* +ReplaceHTTPAfterResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response replaceHttpAfterResponseRuleDefaultsNotFound +*/ +type ReplaceHTTPAfterResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleDefaultsNotFound creates ReplaceHTTPAfterResponseRuleDefaultsNotFound with default headers values +func NewReplaceHTTPAfterResponseRuleDefaultsNotFound() *ReplaceHTTPAfterResponseRuleDefaultsNotFound { + + return &ReplaceHTTPAfterResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http after response rule defaults not found response +func (o *ReplaceHTTPAfterResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http after response rule defaults not found response +func (o *ReplaceHTTPAfterResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http after response rule defaults not found response +func (o *ReplaceHTTPAfterResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule defaults not found response +func (o *ReplaceHTTPAfterResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPAfterResponseRuleDefaultsDefault General Error + +swagger:response replaceHttpAfterResponseRuleDefaultsDefault +*/ +type ReplaceHTTPAfterResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleDefaultsDefault creates ReplaceHTTPAfterResponseRuleDefaultsDefault with default headers values +func NewReplaceHTTPAfterResponseRuleDefaultsDefault(code int) *ReplaceHTTPAfterResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPAfterResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP after response rule defaults default response +func (o *ReplaceHTTPAfterResponseRuleDefaultsDefault) WithStatusCode(code int) *ReplaceHTTPAfterResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP after response rule defaults default response +func (o *ReplaceHTTPAfterResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP after response rule defaults default response +func (o *ReplaceHTTPAfterResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP after response rule defaults default response +func (o *ReplaceHTTPAfterResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP after response rule defaults default response +func (o *ReplaceHTTPAfterResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP after response rule defaults default response +func (o *ReplaceHTTPAfterResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_defaults_urlbuilder.go b/operations/http_after_response_rule/replace_http_after_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..6519aaea --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPAfterResponseRuleDefaultsURL generates an URL for the replace HTTP after response rule defaults operation +type ReplaceHTTPAfterResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPAfterResponseRuleDefaultsURL) WithBasePath(bp string) *ReplaceHTTPAfterResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPAfterResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPAfterResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPAfterResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPAfterResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPAfterResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPAfterResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPAfterResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPAfterResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPAfterResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPAfterResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_frontend.go b/operations/http_after_response_rule/replace_http_after_response_rule_frontend.go new file mode 100644 index 00000000..3545eb06 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPAfterResponseRuleFrontendHandlerFunc turns a function with the right signature into a replace HTTP after response rule frontend handler +type ReplaceHTTPAfterResponseRuleFrontendHandlerFunc func(ReplaceHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPAfterResponseRuleFrontendHandlerFunc) Handle(params ReplaceHTTPAfterResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPAfterResponseRuleFrontendHandler interface for that can handle valid replace HTTP after response rule frontend params +type ReplaceHTTPAfterResponseRuleFrontendHandler interface { + Handle(ReplaceHTTPAfterResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPAfterResponseRuleFrontend creates a new http.Handler for the replace HTTP after response rule frontend operation +func NewReplaceHTTPAfterResponseRuleFrontend(ctx *middleware.Context, handler ReplaceHTTPAfterResponseRuleFrontendHandler) *ReplaceHTTPAfterResponseRuleFrontend { + return &ReplaceHTTPAfterResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPAfterResponseRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index} HTTPAfterResponseRule replaceHttpAfterResponseRuleFrontend + +# Replace a HTTP After Response Rule + +Replaces a HTTP After Response Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPAfterResponseRuleFrontend struct { + Context *middleware.Context + Handler ReplaceHTTPAfterResponseRuleFrontendHandler +} + +func (o *ReplaceHTTPAfterResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPAfterResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_frontend_parameters.go b/operations/http_after_response_rule/replace_http_after_response_rule_frontend_parameters.go new file mode 100644 index 00000000..d1b4304e --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPAfterResponseRuleFrontendParams creates a new ReplaceHTTPAfterResponseRuleFrontendParams object +// with the default values initialized. +func NewReplaceHTTPAfterResponseRuleFrontendParams() ReplaceHTTPAfterResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPAfterResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPAfterResponseRuleFrontendParams contains all the bound params for the replace HTTP after response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPAfterResponseRuleFrontend +type ReplaceHTTPAfterResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPAfterResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP After Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPAfterResponseRuleFrontendParams() beforehand. +func (o *ReplaceHTTPAfterResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPAfterResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPAfterResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPAfterResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPAfterResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPAfterResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPAfterResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPAfterResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_frontend_responses.go b/operations/http_after_response_rule/replace_http_after_response_rule_frontend_responses.go new file mode 100644 index 00000000..20c8e377 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPAfterResponseRuleFrontendOKCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleFrontendOK +const ReplaceHTTPAfterResponseRuleFrontendOKCode int = 200 + +/* +ReplaceHTTPAfterResponseRuleFrontendOK HTTP After Response Rule replaced + +swagger:response replaceHttpAfterResponseRuleFrontendOK +*/ +type ReplaceHTTPAfterResponseRuleFrontendOK struct { + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleFrontendOK creates ReplaceHTTPAfterResponseRuleFrontendOK with default headers values +func NewReplaceHTTPAfterResponseRuleFrontendOK() *ReplaceHTTPAfterResponseRuleFrontendOK { + + return &ReplaceHTTPAfterResponseRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace Http after response rule frontend o k response +func (o *ReplaceHTTPAfterResponseRuleFrontendOK) WithPayload(payload *models.HTTPAfterResponseRule) *ReplaceHTTPAfterResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule frontend o k response +func (o *ReplaceHTTPAfterResponseRuleFrontendOK) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleFrontendAccepted +const ReplaceHTTPAfterResponseRuleFrontendAcceptedCode int = 202 + +/* +ReplaceHTTPAfterResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpAfterResponseRuleFrontendAccepted +*/ +type ReplaceHTTPAfterResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPAfterResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleFrontendAccepted creates ReplaceHTTPAfterResponseRuleFrontendAccepted with default headers values +func NewReplaceHTTPAfterResponseRuleFrontendAccepted() *ReplaceHTTPAfterResponseRuleFrontendAccepted { + + return &ReplaceHTTPAfterResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http after response rule frontend accepted response +func (o *ReplaceHTTPAfterResponseRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceHTTPAfterResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http after response rule frontend accepted response +func (o *ReplaceHTTPAfterResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http after response rule frontend accepted response +func (o *ReplaceHTTPAfterResponseRuleFrontendAccepted) WithPayload(payload *models.HTTPAfterResponseRule) *ReplaceHTTPAfterResponseRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule frontend accepted response +func (o *ReplaceHTTPAfterResponseRuleFrontendAccepted) SetPayload(payload *models.HTTPAfterResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleFrontendBadRequest +const ReplaceHTTPAfterResponseRuleFrontendBadRequestCode int = 400 + +/* +ReplaceHTTPAfterResponseRuleFrontendBadRequest Bad request + +swagger:response replaceHttpAfterResponseRuleFrontendBadRequest +*/ +type ReplaceHTTPAfterResponseRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleFrontendBadRequest creates ReplaceHTTPAfterResponseRuleFrontendBadRequest with default headers values +func NewReplaceHTTPAfterResponseRuleFrontendBadRequest() *ReplaceHTTPAfterResponseRuleFrontendBadRequest { + + return &ReplaceHTTPAfterResponseRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http after response rule frontend bad request response +func (o *ReplaceHTTPAfterResponseRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http after response rule frontend bad request response +func (o *ReplaceHTTPAfterResponseRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http after response rule frontend bad request response +func (o *ReplaceHTTPAfterResponseRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule frontend bad request response +func (o *ReplaceHTTPAfterResponseRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPAfterResponseRuleFrontendNotFoundCode is the HTTP code returned for type ReplaceHTTPAfterResponseRuleFrontendNotFound +const ReplaceHTTPAfterResponseRuleFrontendNotFoundCode int = 404 + +/* +ReplaceHTTPAfterResponseRuleFrontendNotFound The specified resource was not found + +swagger:response replaceHttpAfterResponseRuleFrontendNotFound +*/ +type ReplaceHTTPAfterResponseRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleFrontendNotFound creates ReplaceHTTPAfterResponseRuleFrontendNotFound with default headers values +func NewReplaceHTTPAfterResponseRuleFrontendNotFound() *ReplaceHTTPAfterResponseRuleFrontendNotFound { + + return &ReplaceHTTPAfterResponseRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http after response rule frontend not found response +func (o *ReplaceHTTPAfterResponseRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http after response rule frontend not found response +func (o *ReplaceHTTPAfterResponseRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http after response rule frontend not found response +func (o *ReplaceHTTPAfterResponseRuleFrontendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http after response rule frontend not found response +func (o *ReplaceHTTPAfterResponseRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPAfterResponseRuleFrontendDefault General Error + +swagger:response replaceHttpAfterResponseRuleFrontendDefault +*/ +type ReplaceHTTPAfterResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPAfterResponseRuleFrontendDefault creates ReplaceHTTPAfterResponseRuleFrontendDefault with default headers values +func NewReplaceHTTPAfterResponseRuleFrontendDefault(code int) *ReplaceHTTPAfterResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPAfterResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP after response rule frontend default response +func (o *ReplaceHTTPAfterResponseRuleFrontendDefault) WithStatusCode(code int) *ReplaceHTTPAfterResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP after response rule frontend default response +func (o *ReplaceHTTPAfterResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP after response rule frontend default response +func (o *ReplaceHTTPAfterResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPAfterResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP after response rule frontend default response +func (o *ReplaceHTTPAfterResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP after response rule frontend default response +func (o *ReplaceHTTPAfterResponseRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceHTTPAfterResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP after response rule frontend default response +func (o *ReplaceHTTPAfterResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPAfterResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_after_response_rule/replace_http_after_response_rule_frontend_urlbuilder.go b/operations/http_after_response_rule/replace_http_after_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..0939a6a2 --- /dev/null +++ b/operations/http_after_response_rule/replace_http_after_response_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_after_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPAfterResponseRuleFrontendURL generates an URL for the replace HTTP after response rule frontend operation +type ReplaceHTTPAfterResponseRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPAfterResponseRuleFrontendURL) WithBasePath(bp string) *ReplaceHTTPAfterResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPAfterResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPAfterResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_after_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPAfterResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPAfterResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPAfterResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPAfterResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPAfterResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPAfterResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPAfterResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPAfterResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/create_http_check_backend.go b/operations/http_check/create_http_check_backend.go new file mode 100644 index 00000000..0c433993 --- /dev/null +++ b/operations/http_check/create_http_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPCheckBackendHandlerFunc turns a function with the right signature into a create HTTP check backend handler +type CreateHTTPCheckBackendHandlerFunc func(CreateHTTPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPCheckBackendHandlerFunc) Handle(params CreateHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPCheckBackendHandler interface for that can handle valid create HTTP check backend params +type CreateHTTPCheckBackendHandler interface { + Handle(CreateHTTPCheckBackendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPCheckBackend creates a new http.Handler for the create HTTP check backend operation +func NewCreateHTTPCheckBackend(ctx *middleware.Context, handler CreateHTTPCheckBackendHandler) *CreateHTTPCheckBackend { + return &CreateHTTPCheckBackend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPCheckBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/http_checks/{index} HTTPCheck createHttpCheckBackend + +# Add a new HTTP check + +Adds a new HTTP check of the specified type in the specified parent. +*/ +type CreateHTTPCheckBackend struct { + Context *middleware.Context + Handler CreateHTTPCheckBackendHandler +} + +func (o *CreateHTTPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/create_http_check_backend_parameters.go b/operations/http_check/create_http_check_backend_parameters.go new file mode 100644 index 00000000..9e7ba597 --- /dev/null +++ b/operations/http_check/create_http_check_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPCheckBackendParams creates a new CreateHTTPCheckBackendParams object +// with the default values initialized. +func NewCreateHTTPCheckBackendParams() CreateHTTPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPCheckBackendParams contains all the bound params for the create HTTP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPCheckBackend +type CreateHTTPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPCheckBackendParams() beforehand. +func (o *CreateHTTPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/create_http_check_backend_responses.go b/operations/http_check/create_http_check_backend_responses.go new file mode 100644 index 00000000..58bab841 --- /dev/null +++ b/operations/http_check/create_http_check_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPCheckBackendCreatedCode is the HTTP code returned for type CreateHTTPCheckBackendCreated +const CreateHTTPCheckBackendCreatedCode int = 201 + +/* +CreateHTTPCheckBackendCreated HTTP check created + +swagger:response createHttpCheckBackendCreated +*/ +type CreateHTTPCheckBackendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewCreateHTTPCheckBackendCreated creates CreateHTTPCheckBackendCreated with default headers values +func NewCreateHTTPCheckBackendCreated() *CreateHTTPCheckBackendCreated { + + return &CreateHTTPCheckBackendCreated{} +} + +// WithPayload adds the payload to the create Http check backend created response +func (o *CreateHTTPCheckBackendCreated) WithPayload(payload *models.HTTPCheck) *CreateHTTPCheckBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check backend created response +func (o *CreateHTTPCheckBackendCreated) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPCheckBackendAcceptedCode is the HTTP code returned for type CreateHTTPCheckBackendAccepted +const CreateHTTPCheckBackendAcceptedCode int = 202 + +/* +CreateHTTPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response createHttpCheckBackendAccepted +*/ +type CreateHTTPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewCreateHTTPCheckBackendAccepted creates CreateHTTPCheckBackendAccepted with default headers values +func NewCreateHTTPCheckBackendAccepted() *CreateHTTPCheckBackendAccepted { + + return &CreateHTTPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http check backend accepted response +func (o *CreateHTTPCheckBackendAccepted) WithReloadID(reloadID string) *CreateHTTPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http check backend accepted response +func (o *CreateHTTPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http check backend accepted response +func (o *CreateHTTPCheckBackendAccepted) WithPayload(payload *models.HTTPCheck) *CreateHTTPCheckBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check backend accepted response +func (o *CreateHTTPCheckBackendAccepted) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPCheckBackendBadRequestCode is the HTTP code returned for type CreateHTTPCheckBackendBadRequest +const CreateHTTPCheckBackendBadRequestCode int = 400 + +/* +CreateHTTPCheckBackendBadRequest Bad request + +swagger:response createHttpCheckBackendBadRequest +*/ +type CreateHTTPCheckBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPCheckBackendBadRequest creates CreateHTTPCheckBackendBadRequest with default headers values +func NewCreateHTTPCheckBackendBadRequest() *CreateHTTPCheckBackendBadRequest { + + return &CreateHTTPCheckBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http check backend bad request response +func (o *CreateHTTPCheckBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPCheckBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http check backend bad request response +func (o *CreateHTTPCheckBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http check backend bad request response +func (o *CreateHTTPCheckBackendBadRequest) WithPayload(payload *models.Error) *CreateHTTPCheckBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check backend bad request response +func (o *CreateHTTPCheckBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPCheckBackendConflictCode is the HTTP code returned for type CreateHTTPCheckBackendConflict +const CreateHTTPCheckBackendConflictCode int = 409 + +/* +CreateHTTPCheckBackendConflict The specified resource already exists + +swagger:response createHttpCheckBackendConflict +*/ +type CreateHTTPCheckBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPCheckBackendConflict creates CreateHTTPCheckBackendConflict with default headers values +func NewCreateHTTPCheckBackendConflict() *CreateHTTPCheckBackendConflict { + + return &CreateHTTPCheckBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http check backend conflict response +func (o *CreateHTTPCheckBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPCheckBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http check backend conflict response +func (o *CreateHTTPCheckBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http check backend conflict response +func (o *CreateHTTPCheckBackendConflict) WithPayload(payload *models.Error) *CreateHTTPCheckBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check backend conflict response +func (o *CreateHTTPCheckBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPCheckBackendDefault General Error + +swagger:response createHttpCheckBackendDefault +*/ +type CreateHTTPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPCheckBackendDefault creates CreateHTTPCheckBackendDefault with default headers values +func NewCreateHTTPCheckBackendDefault(code int) *CreateHTTPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP check backend default response +func (o *CreateHTTPCheckBackendDefault) WithStatusCode(code int) *CreateHTTPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP check backend default response +func (o *CreateHTTPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP check backend default response +func (o *CreateHTTPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP check backend default response +func (o *CreateHTTPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP check backend default response +func (o *CreateHTTPCheckBackendDefault) WithPayload(payload *models.Error) *CreateHTTPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP check backend default response +func (o *CreateHTTPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/create_http_check_backend_urlbuilder.go b/operations/http_check/create_http_check_backend_urlbuilder.go new file mode 100644 index 00000000..b6478ed7 --- /dev/null +++ b/operations/http_check/create_http_check_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPCheckBackendURL generates an URL for the create HTTP check backend operation +type CreateHTTPCheckBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPCheckBackendURL) WithBasePath(bp string) *CreateHTTPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/create_http_check_defaults.go b/operations/http_check/create_http_check_defaults.go new file mode 100644 index 00000000..109bce16 --- /dev/null +++ b/operations/http_check/create_http_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPCheckDefaultsHandlerFunc turns a function with the right signature into a create HTTP check defaults handler +type CreateHTTPCheckDefaultsHandlerFunc func(CreateHTTPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPCheckDefaultsHandlerFunc) Handle(params CreateHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPCheckDefaultsHandler interface for that can handle valid create HTTP check defaults params +type CreateHTTPCheckDefaultsHandler interface { + Handle(CreateHTTPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateHTTPCheckDefaults creates a new http.Handler for the create HTTP check defaults operation +func NewCreateHTTPCheckDefaults(ctx *middleware.Context, handler CreateHTTPCheckDefaultsHandler) *CreateHTTPCheckDefaults { + return &CreateHTTPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + CreateHTTPCheckDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/http_checks/{index} HTTPCheck createHttpCheckDefaults + +# Add a new HTTP check + +Adds a new HTTP check of the specified type in the specified parent. +*/ +type CreateHTTPCheckDefaults struct { + Context *middleware.Context + Handler CreateHTTPCheckDefaultsHandler +} + +func (o *CreateHTTPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/create_http_check_defaults_parameters.go b/operations/http_check/create_http_check_defaults_parameters.go new file mode 100644 index 00000000..75b62bed --- /dev/null +++ b/operations/http_check/create_http_check_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPCheckDefaultsParams creates a new CreateHTTPCheckDefaultsParams object +// with the default values initialized. +func NewCreateHTTPCheckDefaultsParams() CreateHTTPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPCheckDefaultsParams contains all the bound params for the create HTTP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPCheckDefaults +type CreateHTTPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPCheckDefaultsParams() beforehand. +func (o *CreateHTTPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/create_http_check_defaults_responses.go b/operations/http_check/create_http_check_defaults_responses.go new file mode 100644 index 00000000..9e3c6373 --- /dev/null +++ b/operations/http_check/create_http_check_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPCheckDefaultsCreatedCode is the HTTP code returned for type CreateHTTPCheckDefaultsCreated +const CreateHTTPCheckDefaultsCreatedCode int = 201 + +/* +CreateHTTPCheckDefaultsCreated HTTP check created + +swagger:response createHttpCheckDefaultsCreated +*/ +type CreateHTTPCheckDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewCreateHTTPCheckDefaultsCreated creates CreateHTTPCheckDefaultsCreated with default headers values +func NewCreateHTTPCheckDefaultsCreated() *CreateHTTPCheckDefaultsCreated { + + return &CreateHTTPCheckDefaultsCreated{} +} + +// WithPayload adds the payload to the create Http check defaults created response +func (o *CreateHTTPCheckDefaultsCreated) WithPayload(payload *models.HTTPCheck) *CreateHTTPCheckDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check defaults created response +func (o *CreateHTTPCheckDefaultsCreated) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPCheckDefaultsAcceptedCode is the HTTP code returned for type CreateHTTPCheckDefaultsAccepted +const CreateHTTPCheckDefaultsAcceptedCode int = 202 + +/* +CreateHTTPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createHttpCheckDefaultsAccepted +*/ +type CreateHTTPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewCreateHTTPCheckDefaultsAccepted creates CreateHTTPCheckDefaultsAccepted with default headers values +func NewCreateHTTPCheckDefaultsAccepted() *CreateHTTPCheckDefaultsAccepted { + + return &CreateHTTPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Http check defaults accepted response +func (o *CreateHTTPCheckDefaultsAccepted) WithReloadID(reloadID string) *CreateHTTPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http check defaults accepted response +func (o *CreateHTTPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http check defaults accepted response +func (o *CreateHTTPCheckDefaultsAccepted) WithPayload(payload *models.HTTPCheck) *CreateHTTPCheckDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check defaults accepted response +func (o *CreateHTTPCheckDefaultsAccepted) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPCheckDefaultsBadRequestCode is the HTTP code returned for type CreateHTTPCheckDefaultsBadRequest +const CreateHTTPCheckDefaultsBadRequestCode int = 400 + +/* +CreateHTTPCheckDefaultsBadRequest Bad request + +swagger:response createHttpCheckDefaultsBadRequest +*/ +type CreateHTTPCheckDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPCheckDefaultsBadRequest creates CreateHTTPCheckDefaultsBadRequest with default headers values +func NewCreateHTTPCheckDefaultsBadRequest() *CreateHTTPCheckDefaultsBadRequest { + + return &CreateHTTPCheckDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http check defaults bad request response +func (o *CreateHTTPCheckDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPCheckDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http check defaults bad request response +func (o *CreateHTTPCheckDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http check defaults bad request response +func (o *CreateHTTPCheckDefaultsBadRequest) WithPayload(payload *models.Error) *CreateHTTPCheckDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check defaults bad request response +func (o *CreateHTTPCheckDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPCheckDefaultsConflictCode is the HTTP code returned for type CreateHTTPCheckDefaultsConflict +const CreateHTTPCheckDefaultsConflictCode int = 409 + +/* +CreateHTTPCheckDefaultsConflict The specified resource already exists + +swagger:response createHttpCheckDefaultsConflict +*/ +type CreateHTTPCheckDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPCheckDefaultsConflict creates CreateHTTPCheckDefaultsConflict with default headers values +func NewCreateHTTPCheckDefaultsConflict() *CreateHTTPCheckDefaultsConflict { + + return &CreateHTTPCheckDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http check defaults conflict response +func (o *CreateHTTPCheckDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPCheckDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http check defaults conflict response +func (o *CreateHTTPCheckDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http check defaults conflict response +func (o *CreateHTTPCheckDefaultsConflict) WithPayload(payload *models.Error) *CreateHTTPCheckDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http check defaults conflict response +func (o *CreateHTTPCheckDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPCheckDefaultsDefault General Error + +swagger:response createHttpCheckDefaultsDefault +*/ +type CreateHTTPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPCheckDefaultsDefault creates CreateHTTPCheckDefaultsDefault with default headers values +func NewCreateHTTPCheckDefaultsDefault(code int) *CreateHTTPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP check defaults default response +func (o *CreateHTTPCheckDefaultsDefault) WithStatusCode(code int) *CreateHTTPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP check defaults default response +func (o *CreateHTTPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP check defaults default response +func (o *CreateHTTPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP check defaults default response +func (o *CreateHTTPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP check defaults default response +func (o *CreateHTTPCheckDefaultsDefault) WithPayload(payload *models.Error) *CreateHTTPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP check defaults default response +func (o *CreateHTTPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/create_http_check_defaults_urlbuilder.go b/operations/http_check/create_http_check_defaults_urlbuilder.go new file mode 100644 index 00000000..cc676e7b --- /dev/null +++ b/operations/http_check/create_http_check_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPCheckDefaultsURL generates an URL for the create HTTP check defaults operation +type CreateHTTPCheckDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPCheckDefaultsURL) WithBasePath(bp string) *CreateHTTPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/delete_http_check_backend.go b/operations/http_check/delete_http_check_backend.go new file mode 100644 index 00000000..bed6f045 --- /dev/null +++ b/operations/http_check/delete_http_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPCheckBackendHandlerFunc turns a function with the right signature into a delete HTTP check backend handler +type DeleteHTTPCheckBackendHandlerFunc func(DeleteHTTPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPCheckBackendHandlerFunc) Handle(params DeleteHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPCheckBackendHandler interface for that can handle valid delete HTTP check backend params +type DeleteHTTPCheckBackendHandler interface { + Handle(DeleteHTTPCheckBackendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPCheckBackend creates a new http.Handler for the delete HTTP check backend operation +func NewDeleteHTTPCheckBackend(ctx *middleware.Context, handler DeleteHTTPCheckBackendHandler) *DeleteHTTPCheckBackend { + return &DeleteHTTPCheckBackend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPCheckBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/http_checks/{index} HTTPCheck deleteHttpCheckBackend + +# Delete a HTTP check + +Deletes a HTTP check configuration by it's index from the specified parent. +*/ +type DeleteHTTPCheckBackend struct { + Context *middleware.Context + Handler DeleteHTTPCheckBackendHandler +} + +func (o *DeleteHTTPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/delete_http_check_backend_parameters.go b/operations/http_check/delete_http_check_backend_parameters.go new file mode 100644 index 00000000..5255e0e4 --- /dev/null +++ b/operations/http_check/delete_http_check_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPCheckBackendParams creates a new DeleteHTTPCheckBackendParams object +// with the default values initialized. +func NewDeleteHTTPCheckBackendParams() DeleteHTTPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPCheckBackendParams contains all the bound params for the delete HTTP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPCheckBackend +type DeleteHTTPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPCheckBackendParams() beforehand. +func (o *DeleteHTTPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/delete_http_check_backend_responses.go b/operations/http_check/delete_http_check_backend_responses.go new file mode 100644 index 00000000..d0e0e3d2 --- /dev/null +++ b/operations/http_check/delete_http_check_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPCheckBackendAcceptedCode is the HTTP code returned for type DeleteHTTPCheckBackendAccepted +const DeleteHTTPCheckBackendAcceptedCode int = 202 + +/* +DeleteHTTPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpCheckBackendAccepted +*/ +type DeleteHTTPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPCheckBackendAccepted creates DeleteHTTPCheckBackendAccepted with default headers values +func NewDeleteHTTPCheckBackendAccepted() *DeleteHTTPCheckBackendAccepted { + + return &DeleteHTTPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http check backend accepted response +func (o *DeleteHTTPCheckBackendAccepted) WithReloadID(reloadID string) *DeleteHTTPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http check backend accepted response +func (o *DeleteHTTPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPCheckBackendNoContentCode is the HTTP code returned for type DeleteHTTPCheckBackendNoContent +const DeleteHTTPCheckBackendNoContentCode int = 204 + +/* +DeleteHTTPCheckBackendNoContent HTTP check deleted + +swagger:response deleteHttpCheckBackendNoContent +*/ +type DeleteHTTPCheckBackendNoContent struct { +} + +// NewDeleteHTTPCheckBackendNoContent creates DeleteHTTPCheckBackendNoContent with default headers values +func NewDeleteHTTPCheckBackendNoContent() *DeleteHTTPCheckBackendNoContent { + + return &DeleteHTTPCheckBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPCheckBackendNotFoundCode is the HTTP code returned for type DeleteHTTPCheckBackendNotFound +const DeleteHTTPCheckBackendNotFoundCode int = 404 + +/* +DeleteHTTPCheckBackendNotFound The specified resource was not found + +swagger:response deleteHttpCheckBackendNotFound +*/ +type DeleteHTTPCheckBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPCheckBackendNotFound creates DeleteHTTPCheckBackendNotFound with default headers values +func NewDeleteHTTPCheckBackendNotFound() *DeleteHTTPCheckBackendNotFound { + + return &DeleteHTTPCheckBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http check backend not found response +func (o *DeleteHTTPCheckBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPCheckBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http check backend not found response +func (o *DeleteHTTPCheckBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http check backend not found response +func (o *DeleteHTTPCheckBackendNotFound) WithPayload(payload *models.Error) *DeleteHTTPCheckBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http check backend not found response +func (o *DeleteHTTPCheckBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPCheckBackendDefault General Error + +swagger:response deleteHttpCheckBackendDefault +*/ +type DeleteHTTPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPCheckBackendDefault creates DeleteHTTPCheckBackendDefault with default headers values +func NewDeleteHTTPCheckBackendDefault(code int) *DeleteHTTPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP check backend default response +func (o *DeleteHTTPCheckBackendDefault) WithStatusCode(code int) *DeleteHTTPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP check backend default response +func (o *DeleteHTTPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP check backend default response +func (o *DeleteHTTPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP check backend default response +func (o *DeleteHTTPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP check backend default response +func (o *DeleteHTTPCheckBackendDefault) WithPayload(payload *models.Error) *DeleteHTTPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP check backend default response +func (o *DeleteHTTPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/delete_http_check_backend_urlbuilder.go b/operations/http_check/delete_http_check_backend_urlbuilder.go new file mode 100644 index 00000000..d8a11ce1 --- /dev/null +++ b/operations/http_check/delete_http_check_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPCheckBackendURL generates an URL for the delete HTTP check backend operation +type DeleteHTTPCheckBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPCheckBackendURL) WithBasePath(bp string) *DeleteHTTPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/delete_http_check_defaults.go b/operations/http_check/delete_http_check_defaults.go new file mode 100644 index 00000000..4eea6d68 --- /dev/null +++ b/operations/http_check/delete_http_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPCheckDefaultsHandlerFunc turns a function with the right signature into a delete HTTP check defaults handler +type DeleteHTTPCheckDefaultsHandlerFunc func(DeleteHTTPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPCheckDefaultsHandlerFunc) Handle(params DeleteHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPCheckDefaultsHandler interface for that can handle valid delete HTTP check defaults params +type DeleteHTTPCheckDefaultsHandler interface { + Handle(DeleteHTTPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPCheckDefaults creates a new http.Handler for the delete HTTP check defaults operation +func NewDeleteHTTPCheckDefaults(ctx *middleware.Context, handler DeleteHTTPCheckDefaultsHandler) *DeleteHTTPCheckDefaults { + return &DeleteHTTPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPCheckDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/http_checks/{index} HTTPCheck deleteHttpCheckDefaults + +# Delete a HTTP check + +Deletes a HTTP check configuration by it's index from the specified parent. +*/ +type DeleteHTTPCheckDefaults struct { + Context *middleware.Context + Handler DeleteHTTPCheckDefaultsHandler +} + +func (o *DeleteHTTPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/delete_http_check_defaults_parameters.go b/operations/http_check/delete_http_check_defaults_parameters.go new file mode 100644 index 00000000..46d2fb26 --- /dev/null +++ b/operations/http_check/delete_http_check_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPCheckDefaultsParams creates a new DeleteHTTPCheckDefaultsParams object +// with the default values initialized. +func NewDeleteHTTPCheckDefaultsParams() DeleteHTTPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPCheckDefaultsParams contains all the bound params for the delete HTTP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPCheckDefaults +type DeleteHTTPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPCheckDefaultsParams() beforehand. +func (o *DeleteHTTPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/delete_http_check_defaults_responses.go b/operations/http_check/delete_http_check_defaults_responses.go new file mode 100644 index 00000000..39dd5a33 --- /dev/null +++ b/operations/http_check/delete_http_check_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPCheckDefaultsAcceptedCode is the HTTP code returned for type DeleteHTTPCheckDefaultsAccepted +const DeleteHTTPCheckDefaultsAcceptedCode int = 202 + +/* +DeleteHTTPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpCheckDefaultsAccepted +*/ +type DeleteHTTPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPCheckDefaultsAccepted creates DeleteHTTPCheckDefaultsAccepted with default headers values +func NewDeleteHTTPCheckDefaultsAccepted() *DeleteHTTPCheckDefaultsAccepted { + + return &DeleteHTTPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http check defaults accepted response +func (o *DeleteHTTPCheckDefaultsAccepted) WithReloadID(reloadID string) *DeleteHTTPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http check defaults accepted response +func (o *DeleteHTTPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPCheckDefaultsNoContentCode is the HTTP code returned for type DeleteHTTPCheckDefaultsNoContent +const DeleteHTTPCheckDefaultsNoContentCode int = 204 + +/* +DeleteHTTPCheckDefaultsNoContent HTTP check deleted + +swagger:response deleteHttpCheckDefaultsNoContent +*/ +type DeleteHTTPCheckDefaultsNoContent struct { +} + +// NewDeleteHTTPCheckDefaultsNoContent creates DeleteHTTPCheckDefaultsNoContent with default headers values +func NewDeleteHTTPCheckDefaultsNoContent() *DeleteHTTPCheckDefaultsNoContent { + + return &DeleteHTTPCheckDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPCheckDefaultsNotFoundCode is the HTTP code returned for type DeleteHTTPCheckDefaultsNotFound +const DeleteHTTPCheckDefaultsNotFoundCode int = 404 + +/* +DeleteHTTPCheckDefaultsNotFound The specified resource was not found + +swagger:response deleteHttpCheckDefaultsNotFound +*/ +type DeleteHTTPCheckDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPCheckDefaultsNotFound creates DeleteHTTPCheckDefaultsNotFound with default headers values +func NewDeleteHTTPCheckDefaultsNotFound() *DeleteHTTPCheckDefaultsNotFound { + + return &DeleteHTTPCheckDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http check defaults not found response +func (o *DeleteHTTPCheckDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPCheckDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http check defaults not found response +func (o *DeleteHTTPCheckDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http check defaults not found response +func (o *DeleteHTTPCheckDefaultsNotFound) WithPayload(payload *models.Error) *DeleteHTTPCheckDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http check defaults not found response +func (o *DeleteHTTPCheckDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPCheckDefaultsDefault General Error + +swagger:response deleteHttpCheckDefaultsDefault +*/ +type DeleteHTTPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPCheckDefaultsDefault creates DeleteHTTPCheckDefaultsDefault with default headers values +func NewDeleteHTTPCheckDefaultsDefault(code int) *DeleteHTTPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP check defaults default response +func (o *DeleteHTTPCheckDefaultsDefault) WithStatusCode(code int) *DeleteHTTPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP check defaults default response +func (o *DeleteHTTPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP check defaults default response +func (o *DeleteHTTPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP check defaults default response +func (o *DeleteHTTPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP check defaults default response +func (o *DeleteHTTPCheckDefaultsDefault) WithPayload(payload *models.Error) *DeleteHTTPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP check defaults default response +func (o *DeleteHTTPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/delete_http_check_defaults_urlbuilder.go b/operations/http_check/delete_http_check_defaults_urlbuilder.go new file mode 100644 index 00000000..cebd6550 --- /dev/null +++ b/operations/http_check/delete_http_check_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPCheckDefaultsURL generates an URL for the delete HTTP check defaults operation +type DeleteHTTPCheckDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPCheckDefaultsURL) WithBasePath(bp string) *DeleteHTTPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/get_all_http_check_backend.go b/operations/http_check/get_all_http_check_backend.go new file mode 100644 index 00000000..9a05839f --- /dev/null +++ b/operations/http_check/get_all_http_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPCheckBackendHandlerFunc turns a function with the right signature into a get all HTTP check backend handler +type GetAllHTTPCheckBackendHandlerFunc func(GetAllHTTPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPCheckBackendHandlerFunc) Handle(params GetAllHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPCheckBackendHandler interface for that can handle valid get all HTTP check backend params +type GetAllHTTPCheckBackendHandler interface { + Handle(GetAllHTTPCheckBackendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPCheckBackend creates a new http.Handler for the get all HTTP check backend operation +func NewGetAllHTTPCheckBackend(ctx *middleware.Context, handler GetAllHTTPCheckBackendHandler) *GetAllHTTPCheckBackend { + return &GetAllHTTPCheckBackend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPCheckBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_checks HTTPCheck getAllHttpCheckBackend + +# Return an array of HTTP checks + +Returns all HTTP checks that are configured in specified parent. +*/ +type GetAllHTTPCheckBackend struct { + Context *middleware.Context + Handler GetAllHTTPCheckBackendHandler +} + +func (o *GetAllHTTPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/get_all_http_check_backend_parameters.go b/operations/http_check/get_all_http_check_backend_parameters.go new file mode 100644 index 00000000..5155ce84 --- /dev/null +++ b/operations/http_check/get_all_http_check_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPCheckBackendParams creates a new GetAllHTTPCheckBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPCheckBackendParams() GetAllHTTPCheckBackendParams { + + return GetAllHTTPCheckBackendParams{} +} + +// GetAllHTTPCheckBackendParams contains all the bound params for the get all HTTP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPCheckBackend +type GetAllHTTPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPCheckBackendParams() beforehand. +func (o *GetAllHTTPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_check/get_all_http_check_backend_responses.go b/operations/http_check/get_all_http_check_backend_responses.go new file mode 100644 index 00000000..cf332d02 --- /dev/null +++ b/operations/http_check/get_all_http_check_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPCheckBackendOKCode is the HTTP code returned for type GetAllHTTPCheckBackendOK +const GetAllHTTPCheckBackendOKCode int = 200 + +/* +GetAllHTTPCheckBackendOK Successful operation + +swagger:response getAllHttpCheckBackendOK +*/ +type GetAllHTTPCheckBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPChecks `json:"body,omitempty"` +} + +// NewGetAllHTTPCheckBackendOK creates GetAllHTTPCheckBackendOK with default headers values +func NewGetAllHTTPCheckBackendOK() *GetAllHTTPCheckBackendOK { + + return &GetAllHTTPCheckBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http check backend o k response +func (o *GetAllHTTPCheckBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPCheckBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http check backend o k response +func (o *GetAllHTTPCheckBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http check backend o k response +func (o *GetAllHTTPCheckBackendOK) WithPayload(payload models.HTTPChecks) *GetAllHTTPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http check backend o k response +func (o *GetAllHTTPCheckBackendOK) SetPayload(payload models.HTTPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPCheckBackendDefault General Error + +swagger:response getAllHttpCheckBackendDefault +*/ +type GetAllHTTPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPCheckBackendDefault creates GetAllHTTPCheckBackendDefault with default headers values +func NewGetAllHTTPCheckBackendDefault(code int) *GetAllHTTPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP check backend default response +func (o *GetAllHTTPCheckBackendDefault) WithStatusCode(code int) *GetAllHTTPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP check backend default response +func (o *GetAllHTTPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP check backend default response +func (o *GetAllHTTPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP check backend default response +func (o *GetAllHTTPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP check backend default response +func (o *GetAllHTTPCheckBackendDefault) WithPayload(payload *models.Error) *GetAllHTTPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP check backend default response +func (o *GetAllHTTPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/get_all_http_check_backend_urlbuilder.go b/operations/http_check/get_all_http_check_backend_urlbuilder.go new file mode 100644 index 00000000..3b7b3e8b --- /dev/null +++ b/operations/http_check/get_all_http_check_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPCheckBackendURL generates an URL for the get all HTTP check backend operation +type GetAllHTTPCheckBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPCheckBackendURL) WithBasePath(bp string) *GetAllHTTPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/get_all_http_check_defaults.go b/operations/http_check/get_all_http_check_defaults.go new file mode 100644 index 00000000..8f39f420 --- /dev/null +++ b/operations/http_check/get_all_http_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPCheckDefaultsHandlerFunc turns a function with the right signature into a get all HTTP check defaults handler +type GetAllHTTPCheckDefaultsHandlerFunc func(GetAllHTTPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPCheckDefaultsHandlerFunc) Handle(params GetAllHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPCheckDefaultsHandler interface for that can handle valid get all HTTP check defaults params +type GetAllHTTPCheckDefaultsHandler interface { + Handle(GetAllHTTPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPCheckDefaults creates a new http.Handler for the get all HTTP check defaults operation +func NewGetAllHTTPCheckDefaults(ctx *middleware.Context, handler GetAllHTTPCheckDefaultsHandler) *GetAllHTTPCheckDefaults { + return &GetAllHTTPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPCheckDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_checks HTTPCheck getAllHttpCheckDefaults + +# Return an array of HTTP checks + +Returns all HTTP checks that are configured in specified parent. +*/ +type GetAllHTTPCheckDefaults struct { + Context *middleware.Context + Handler GetAllHTTPCheckDefaultsHandler +} + +func (o *GetAllHTTPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/get_all_http_check_defaults_parameters.go b/operations/http_check/get_all_http_check_defaults_parameters.go new file mode 100644 index 00000000..6e398d48 --- /dev/null +++ b/operations/http_check/get_all_http_check_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPCheckDefaultsParams creates a new GetAllHTTPCheckDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPCheckDefaultsParams() GetAllHTTPCheckDefaultsParams { + + return GetAllHTTPCheckDefaultsParams{} +} + +// GetAllHTTPCheckDefaultsParams contains all the bound params for the get all HTTP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPCheckDefaults +type GetAllHTTPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPCheckDefaultsParams() beforehand. +func (o *GetAllHTTPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_check/get_all_http_check_defaults_responses.go b/operations/http_check/get_all_http_check_defaults_responses.go new file mode 100644 index 00000000..5617b676 --- /dev/null +++ b/operations/http_check/get_all_http_check_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPCheckDefaultsOKCode is the HTTP code returned for type GetAllHTTPCheckDefaultsOK +const GetAllHTTPCheckDefaultsOKCode int = 200 + +/* +GetAllHTTPCheckDefaultsOK Successful operation + +swagger:response getAllHttpCheckDefaultsOK +*/ +type GetAllHTTPCheckDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPChecks `json:"body,omitempty"` +} + +// NewGetAllHTTPCheckDefaultsOK creates GetAllHTTPCheckDefaultsOK with default headers values +func NewGetAllHTTPCheckDefaultsOK() *GetAllHTTPCheckDefaultsOK { + + return &GetAllHTTPCheckDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http check defaults o k response +func (o *GetAllHTTPCheckDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPCheckDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http check defaults o k response +func (o *GetAllHTTPCheckDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http check defaults o k response +func (o *GetAllHTTPCheckDefaultsOK) WithPayload(payload models.HTTPChecks) *GetAllHTTPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http check defaults o k response +func (o *GetAllHTTPCheckDefaultsOK) SetPayload(payload models.HTTPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPCheckDefaultsDefault General Error + +swagger:response getAllHttpCheckDefaultsDefault +*/ +type GetAllHTTPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPCheckDefaultsDefault creates GetAllHTTPCheckDefaultsDefault with default headers values +func NewGetAllHTTPCheckDefaultsDefault(code int) *GetAllHTTPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP check defaults default response +func (o *GetAllHTTPCheckDefaultsDefault) WithStatusCode(code int) *GetAllHTTPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP check defaults default response +func (o *GetAllHTTPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP check defaults default response +func (o *GetAllHTTPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP check defaults default response +func (o *GetAllHTTPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP check defaults default response +func (o *GetAllHTTPCheckDefaultsDefault) WithPayload(payload *models.Error) *GetAllHTTPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP check defaults default response +func (o *GetAllHTTPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/get_all_http_check_defaults_urlbuilder.go b/operations/http_check/get_all_http_check_defaults_urlbuilder.go new file mode 100644 index 00000000..aeb0abf2 --- /dev/null +++ b/operations/http_check/get_all_http_check_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPCheckDefaultsURL generates an URL for the get all HTTP check defaults operation +type GetAllHTTPCheckDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPCheckDefaultsURL) WithBasePath(bp string) *GetAllHTTPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/get_http_check_backend.go b/operations/http_check/get_http_check_backend.go new file mode 100644 index 00000000..75aa429c --- /dev/null +++ b/operations/http_check/get_http_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPCheckBackendHandlerFunc turns a function with the right signature into a get HTTP check backend handler +type GetHTTPCheckBackendHandlerFunc func(GetHTTPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPCheckBackendHandlerFunc) Handle(params GetHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPCheckBackendHandler interface for that can handle valid get HTTP check backend params +type GetHTTPCheckBackendHandler interface { + Handle(GetHTTPCheckBackendParams, interface{}) middleware.Responder +} + +// NewGetHTTPCheckBackend creates a new http.Handler for the get HTTP check backend operation +func NewGetHTTPCheckBackend(ctx *middleware.Context, handler GetHTTPCheckBackendHandler) *GetHTTPCheckBackend { + return &GetHTTPCheckBackend{Context: ctx, Handler: handler} +} + +/* + GetHTTPCheckBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_checks/{index} HTTPCheck getHttpCheckBackend + +# Return one HTTP check + +Returns one HTTP check configuration by it's index in the specified parent. +*/ +type GetHTTPCheckBackend struct { + Context *middleware.Context + Handler GetHTTPCheckBackendHandler +} + +func (o *GetHTTPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/get_http_check_backend_parameters.go b/operations/http_check/get_http_check_backend_parameters.go new file mode 100644 index 00000000..490eec9a --- /dev/null +++ b/operations/http_check/get_http_check_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPCheckBackendParams creates a new GetHTTPCheckBackendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPCheckBackendParams() GetHTTPCheckBackendParams { + + return GetHTTPCheckBackendParams{} +} + +// GetHTTPCheckBackendParams contains all the bound params for the get HTTP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPCheckBackend +type GetHTTPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPCheckBackendParams() beforehand. +func (o *GetHTTPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_check/get_http_check_backend_responses.go b/operations/http_check/get_http_check_backend_responses.go new file mode 100644 index 00000000..9743dd9d --- /dev/null +++ b/operations/http_check/get_http_check_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPCheckBackendOKCode is the HTTP code returned for type GetHTTPCheckBackendOK +const GetHTTPCheckBackendOKCode int = 200 + +/* +GetHTTPCheckBackendOK Successful operation + +swagger:response getHttpCheckBackendOK +*/ +type GetHTTPCheckBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewGetHTTPCheckBackendOK creates GetHTTPCheckBackendOK with default headers values +func NewGetHTTPCheckBackendOK() *GetHTTPCheckBackendOK { + + return &GetHTTPCheckBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http check backend o k response +func (o *GetHTTPCheckBackendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPCheckBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http check backend o k response +func (o *GetHTTPCheckBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http check backend o k response +func (o *GetHTTPCheckBackendOK) WithPayload(payload *models.HTTPCheck) *GetHTTPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http check backend o k response +func (o *GetHTTPCheckBackendOK) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPCheckBackendNotFoundCode is the HTTP code returned for type GetHTTPCheckBackendNotFound +const GetHTTPCheckBackendNotFoundCode int = 404 + +/* +GetHTTPCheckBackendNotFound The specified resource was not found + +swagger:response getHttpCheckBackendNotFound +*/ +type GetHTTPCheckBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPCheckBackendNotFound creates GetHTTPCheckBackendNotFound with default headers values +func NewGetHTTPCheckBackendNotFound() *GetHTTPCheckBackendNotFound { + + return &GetHTTPCheckBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http check backend not found response +func (o *GetHTTPCheckBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPCheckBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http check backend not found response +func (o *GetHTTPCheckBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http check backend not found response +func (o *GetHTTPCheckBackendNotFound) WithPayload(payload *models.Error) *GetHTTPCheckBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http check backend not found response +func (o *GetHTTPCheckBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPCheckBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPCheckBackendDefault General Error + +swagger:response getHttpCheckBackendDefault +*/ +type GetHTTPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPCheckBackendDefault creates GetHTTPCheckBackendDefault with default headers values +func NewGetHTTPCheckBackendDefault(code int) *GetHTTPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP check backend default response +func (o *GetHTTPCheckBackendDefault) WithStatusCode(code int) *GetHTTPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP check backend default response +func (o *GetHTTPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP check backend default response +func (o *GetHTTPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP check backend default response +func (o *GetHTTPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP check backend default response +func (o *GetHTTPCheckBackendDefault) WithPayload(payload *models.Error) *GetHTTPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP check backend default response +func (o *GetHTTPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/get_http_check_backend_urlbuilder.go b/operations/http_check/get_http_check_backend_urlbuilder.go new file mode 100644 index 00000000..78632526 --- /dev/null +++ b/operations/http_check/get_http_check_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPCheckBackendURL generates an URL for the get HTTP check backend operation +type GetHTTPCheckBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPCheckBackendURL) WithBasePath(bp string) *GetHTTPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/get_http_check_defaults.go b/operations/http_check/get_http_check_defaults.go new file mode 100644 index 00000000..512d1f12 --- /dev/null +++ b/operations/http_check/get_http_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPCheckDefaultsHandlerFunc turns a function with the right signature into a get HTTP check defaults handler +type GetHTTPCheckDefaultsHandlerFunc func(GetHTTPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPCheckDefaultsHandlerFunc) Handle(params GetHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPCheckDefaultsHandler interface for that can handle valid get HTTP check defaults params +type GetHTTPCheckDefaultsHandler interface { + Handle(GetHTTPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewGetHTTPCheckDefaults creates a new http.Handler for the get HTTP check defaults operation +func NewGetHTTPCheckDefaults(ctx *middleware.Context, handler GetHTTPCheckDefaultsHandler) *GetHTTPCheckDefaults { + return &GetHTTPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + GetHTTPCheckDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_checks/{index} HTTPCheck getHttpCheckDefaults + +# Return one HTTP check + +Returns one HTTP check configuration by it's index in the specified parent. +*/ +type GetHTTPCheckDefaults struct { + Context *middleware.Context + Handler GetHTTPCheckDefaultsHandler +} + +func (o *GetHTTPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/get_http_check_defaults_parameters.go b/operations/http_check/get_http_check_defaults_parameters.go new file mode 100644 index 00000000..de85fd3a --- /dev/null +++ b/operations/http_check/get_http_check_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPCheckDefaultsParams creates a new GetHTTPCheckDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetHTTPCheckDefaultsParams() GetHTTPCheckDefaultsParams { + + return GetHTTPCheckDefaultsParams{} +} + +// GetHTTPCheckDefaultsParams contains all the bound params for the get HTTP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPCheckDefaults +type GetHTTPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPCheckDefaultsParams() beforehand. +func (o *GetHTTPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_check/get_http_check_defaults_responses.go b/operations/http_check/get_http_check_defaults_responses.go new file mode 100644 index 00000000..eb739b7a --- /dev/null +++ b/operations/http_check/get_http_check_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPCheckDefaultsOKCode is the HTTP code returned for type GetHTTPCheckDefaultsOK +const GetHTTPCheckDefaultsOKCode int = 200 + +/* +GetHTTPCheckDefaultsOK Successful operation + +swagger:response getHttpCheckDefaultsOK +*/ +type GetHTTPCheckDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewGetHTTPCheckDefaultsOK creates GetHTTPCheckDefaultsOK with default headers values +func NewGetHTTPCheckDefaultsOK() *GetHTTPCheckDefaultsOK { + + return &GetHTTPCheckDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http check defaults o k response +func (o *GetHTTPCheckDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetHTTPCheckDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http check defaults o k response +func (o *GetHTTPCheckDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http check defaults o k response +func (o *GetHTTPCheckDefaultsOK) WithPayload(payload *models.HTTPCheck) *GetHTTPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http check defaults o k response +func (o *GetHTTPCheckDefaultsOK) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPCheckDefaultsNotFoundCode is the HTTP code returned for type GetHTTPCheckDefaultsNotFound +const GetHTTPCheckDefaultsNotFoundCode int = 404 + +/* +GetHTTPCheckDefaultsNotFound The specified resource was not found + +swagger:response getHttpCheckDefaultsNotFound +*/ +type GetHTTPCheckDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPCheckDefaultsNotFound creates GetHTTPCheckDefaultsNotFound with default headers values +func NewGetHTTPCheckDefaultsNotFound() *GetHTTPCheckDefaultsNotFound { + + return &GetHTTPCheckDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http check defaults not found response +func (o *GetHTTPCheckDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPCheckDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http check defaults not found response +func (o *GetHTTPCheckDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http check defaults not found response +func (o *GetHTTPCheckDefaultsNotFound) WithPayload(payload *models.Error) *GetHTTPCheckDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http check defaults not found response +func (o *GetHTTPCheckDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPCheckDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPCheckDefaultsDefault General Error + +swagger:response getHttpCheckDefaultsDefault +*/ +type GetHTTPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPCheckDefaultsDefault creates GetHTTPCheckDefaultsDefault with default headers values +func NewGetHTTPCheckDefaultsDefault(code int) *GetHTTPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP check defaults default response +func (o *GetHTTPCheckDefaultsDefault) WithStatusCode(code int) *GetHTTPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP check defaults default response +func (o *GetHTTPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP check defaults default response +func (o *GetHTTPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP check defaults default response +func (o *GetHTTPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP check defaults default response +func (o *GetHTTPCheckDefaultsDefault) WithPayload(payload *models.Error) *GetHTTPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP check defaults default response +func (o *GetHTTPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/get_http_check_defaults_urlbuilder.go b/operations/http_check/get_http_check_defaults_urlbuilder.go new file mode 100644 index 00000000..7c41f974 --- /dev/null +++ b/operations/http_check/get_http_check_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPCheckDefaultsURL generates an URL for the get HTTP check defaults operation +type GetHTTPCheckDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPCheckDefaultsURL) WithBasePath(bp string) *GetHTTPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/replace_all_http_check_backend.go b/operations/http_check/replace_all_http_check_backend.go new file mode 100644 index 00000000..37d43acf --- /dev/null +++ b/operations/http_check/replace_all_http_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPCheckBackendHandlerFunc turns a function with the right signature into a replace all HTTP check backend handler +type ReplaceAllHTTPCheckBackendHandlerFunc func(ReplaceAllHTTPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPCheckBackendHandlerFunc) Handle(params ReplaceAllHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPCheckBackendHandler interface for that can handle valid replace all HTTP check backend params +type ReplaceAllHTTPCheckBackendHandler interface { + Handle(ReplaceAllHTTPCheckBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPCheckBackend creates a new http.Handler for the replace all HTTP check backend operation +func NewReplaceAllHTTPCheckBackend(ctx *middleware.Context, handler ReplaceAllHTTPCheckBackendHandler) *ReplaceAllHTTPCheckBackend { + return &ReplaceAllHTTPCheckBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPCheckBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_checks HTTPCheck replaceAllHttpCheckBackend + +# Replace an HTTP checks list + +Replaces a whole list of HTTP checks with the list given in parameter +*/ +type ReplaceAllHTTPCheckBackend struct { + Context *middleware.Context + Handler ReplaceAllHTTPCheckBackendHandler +} + +func (o *ReplaceAllHTTPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/replace_all_http_check_backend_parameters.go b/operations/http_check/replace_all_http_check_backend_parameters.go new file mode 100644 index 00000000..3569802c --- /dev/null +++ b/operations/http_check/replace_all_http_check_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPCheckBackendParams creates a new ReplaceAllHTTPCheckBackendParams object +// with the default values initialized. +func NewReplaceAllHTTPCheckBackendParams() ReplaceAllHTTPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPCheckBackendParams contains all the bound params for the replace all HTTP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPCheckBackend +type ReplaceAllHTTPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPChecks + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPCheckBackendParams() beforehand. +func (o *ReplaceAllHTTPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPChecks + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/replace_all_http_check_backend_responses.go b/operations/http_check/replace_all_http_check_backend_responses.go new file mode 100644 index 00000000..b5f0721c --- /dev/null +++ b/operations/http_check/replace_all_http_check_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPCheckBackendOKCode is the HTTP code returned for type ReplaceAllHTTPCheckBackendOK +const ReplaceAllHTTPCheckBackendOKCode int = 200 + +/* +ReplaceAllHTTPCheckBackendOK All HTTP checks lines replaced + +swagger:response replaceAllHttpCheckBackendOK +*/ +type ReplaceAllHTTPCheckBackendOK struct { + + /* + In: Body + */ + Payload models.HTTPChecks `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckBackendOK creates ReplaceAllHTTPCheckBackendOK with default headers values +func NewReplaceAllHTTPCheckBackendOK() *ReplaceAllHTTPCheckBackendOK { + + return &ReplaceAllHTTPCheckBackendOK{} +} + +// WithPayload adds the payload to the replace all Http check backend o k response +func (o *ReplaceAllHTTPCheckBackendOK) WithPayload(payload models.HTTPChecks) *ReplaceAllHTTPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http check backend o k response +func (o *ReplaceAllHTTPCheckBackendOK) SetPayload(payload models.HTTPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPCheckBackendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPCheckBackendAccepted +const ReplaceAllHTTPCheckBackendAcceptedCode int = 202 + +/* +ReplaceAllHTTPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpCheckBackendAccepted +*/ +type ReplaceAllHTTPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPChecks `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckBackendAccepted creates ReplaceAllHTTPCheckBackendAccepted with default headers values +func NewReplaceAllHTTPCheckBackendAccepted() *ReplaceAllHTTPCheckBackendAccepted { + + return &ReplaceAllHTTPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http check backend accepted response +func (o *ReplaceAllHTTPCheckBackendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http check backend accepted response +func (o *ReplaceAllHTTPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http check backend accepted response +func (o *ReplaceAllHTTPCheckBackendAccepted) WithPayload(payload models.HTTPChecks) *ReplaceAllHTTPCheckBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http check backend accepted response +func (o *ReplaceAllHTTPCheckBackendAccepted) SetPayload(payload models.HTTPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPCheckBackendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPCheckBackendBadRequest +const ReplaceAllHTTPCheckBackendBadRequestCode int = 400 + +/* +ReplaceAllHTTPCheckBackendBadRequest Bad request + +swagger:response replaceAllHttpCheckBackendBadRequest +*/ +type ReplaceAllHTTPCheckBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckBackendBadRequest creates ReplaceAllHTTPCheckBackendBadRequest with default headers values +func NewReplaceAllHTTPCheckBackendBadRequest() *ReplaceAllHTTPCheckBackendBadRequest { + + return &ReplaceAllHTTPCheckBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http check backend bad request response +func (o *ReplaceAllHTTPCheckBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPCheckBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http check backend bad request response +func (o *ReplaceAllHTTPCheckBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http check backend bad request response +func (o *ReplaceAllHTTPCheckBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPCheckBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http check backend bad request response +func (o *ReplaceAllHTTPCheckBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPCheckBackendDefault General Error + +swagger:response replaceAllHttpCheckBackendDefault +*/ +type ReplaceAllHTTPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckBackendDefault creates ReplaceAllHTTPCheckBackendDefault with default headers values +func NewReplaceAllHTTPCheckBackendDefault(code int) *ReplaceAllHTTPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP check backend default response +func (o *ReplaceAllHTTPCheckBackendDefault) WithStatusCode(code int) *ReplaceAllHTTPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP check backend default response +func (o *ReplaceAllHTTPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP check backend default response +func (o *ReplaceAllHTTPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP check backend default response +func (o *ReplaceAllHTTPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP check backend default response +func (o *ReplaceAllHTTPCheckBackendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP check backend default response +func (o *ReplaceAllHTTPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/replace_all_http_check_backend_urlbuilder.go b/operations/http_check/replace_all_http_check_backend_urlbuilder.go new file mode 100644 index 00000000..8b4941c7 --- /dev/null +++ b/operations/http_check/replace_all_http_check_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPCheckBackendURL generates an URL for the replace all HTTP check backend operation +type ReplaceAllHTTPCheckBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPCheckBackendURL) WithBasePath(bp string) *ReplaceAllHTTPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/replace_all_http_check_defaults.go b/operations/http_check/replace_all_http_check_defaults.go new file mode 100644 index 00000000..05e0f64f --- /dev/null +++ b/operations/http_check/replace_all_http_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPCheckDefaultsHandlerFunc turns a function with the right signature into a replace all HTTP check defaults handler +type ReplaceAllHTTPCheckDefaultsHandlerFunc func(ReplaceAllHTTPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPCheckDefaultsHandlerFunc) Handle(params ReplaceAllHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPCheckDefaultsHandler interface for that can handle valid replace all HTTP check defaults params +type ReplaceAllHTTPCheckDefaultsHandler interface { + Handle(ReplaceAllHTTPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPCheckDefaults creates a new http.Handler for the replace all HTTP check defaults operation +func NewReplaceAllHTTPCheckDefaults(ctx *middleware.Context, handler ReplaceAllHTTPCheckDefaultsHandler) *ReplaceAllHTTPCheckDefaults { + return &ReplaceAllHTTPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPCheckDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_checks HTTPCheck replaceAllHttpCheckDefaults + +# Replace an HTTP checks list + +Replaces a whole list of HTTP checks with the list given in parameter +*/ +type ReplaceAllHTTPCheckDefaults struct { + Context *middleware.Context + Handler ReplaceAllHTTPCheckDefaultsHandler +} + +func (o *ReplaceAllHTTPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/replace_all_http_check_defaults_parameters.go b/operations/http_check/replace_all_http_check_defaults_parameters.go new file mode 100644 index 00000000..0eb7a155 --- /dev/null +++ b/operations/http_check/replace_all_http_check_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPCheckDefaultsParams creates a new ReplaceAllHTTPCheckDefaultsParams object +// with the default values initialized. +func NewReplaceAllHTTPCheckDefaultsParams() ReplaceAllHTTPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPCheckDefaultsParams contains all the bound params for the replace all HTTP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPCheckDefaults +type ReplaceAllHTTPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPChecks + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPCheckDefaultsParams() beforehand. +func (o *ReplaceAllHTTPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPChecks + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/replace_all_http_check_defaults_responses.go b/operations/http_check/replace_all_http_check_defaults_responses.go new file mode 100644 index 00000000..a6882dd7 --- /dev/null +++ b/operations/http_check/replace_all_http_check_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPCheckDefaultsOKCode is the HTTP code returned for type ReplaceAllHTTPCheckDefaultsOK +const ReplaceAllHTTPCheckDefaultsOKCode int = 200 + +/* +ReplaceAllHTTPCheckDefaultsOK All HTTP checks lines replaced + +swagger:response replaceAllHttpCheckDefaultsOK +*/ +type ReplaceAllHTTPCheckDefaultsOK struct { + + /* + In: Body + */ + Payload models.HTTPChecks `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckDefaultsOK creates ReplaceAllHTTPCheckDefaultsOK with default headers values +func NewReplaceAllHTTPCheckDefaultsOK() *ReplaceAllHTTPCheckDefaultsOK { + + return &ReplaceAllHTTPCheckDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Http check defaults o k response +func (o *ReplaceAllHTTPCheckDefaultsOK) WithPayload(payload models.HTTPChecks) *ReplaceAllHTTPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http check defaults o k response +func (o *ReplaceAllHTTPCheckDefaultsOK) SetPayload(payload models.HTTPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPCheckDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllHTTPCheckDefaultsAccepted +const ReplaceAllHTTPCheckDefaultsAcceptedCode int = 202 + +/* +ReplaceAllHTTPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpCheckDefaultsAccepted +*/ +type ReplaceAllHTTPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPChecks `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckDefaultsAccepted creates ReplaceAllHTTPCheckDefaultsAccepted with default headers values +func NewReplaceAllHTTPCheckDefaultsAccepted() *ReplaceAllHTTPCheckDefaultsAccepted { + + return &ReplaceAllHTTPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http check defaults accepted response +func (o *ReplaceAllHTTPCheckDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http check defaults accepted response +func (o *ReplaceAllHTTPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http check defaults accepted response +func (o *ReplaceAllHTTPCheckDefaultsAccepted) WithPayload(payload models.HTTPChecks) *ReplaceAllHTTPCheckDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http check defaults accepted response +func (o *ReplaceAllHTTPCheckDefaultsAccepted) SetPayload(payload models.HTTPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPCheckDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllHTTPCheckDefaultsBadRequest +const ReplaceAllHTTPCheckDefaultsBadRequestCode int = 400 + +/* +ReplaceAllHTTPCheckDefaultsBadRequest Bad request + +swagger:response replaceAllHttpCheckDefaultsBadRequest +*/ +type ReplaceAllHTTPCheckDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckDefaultsBadRequest creates ReplaceAllHTTPCheckDefaultsBadRequest with default headers values +func NewReplaceAllHTTPCheckDefaultsBadRequest() *ReplaceAllHTTPCheckDefaultsBadRequest { + + return &ReplaceAllHTTPCheckDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http check defaults bad request response +func (o *ReplaceAllHTTPCheckDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPCheckDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http check defaults bad request response +func (o *ReplaceAllHTTPCheckDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http check defaults bad request response +func (o *ReplaceAllHTTPCheckDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPCheckDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http check defaults bad request response +func (o *ReplaceAllHTTPCheckDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPCheckDefaultsDefault General Error + +swagger:response replaceAllHttpCheckDefaultsDefault +*/ +type ReplaceAllHTTPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPCheckDefaultsDefault creates ReplaceAllHTTPCheckDefaultsDefault with default headers values +func NewReplaceAllHTTPCheckDefaultsDefault(code int) *ReplaceAllHTTPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP check defaults default response +func (o *ReplaceAllHTTPCheckDefaultsDefault) WithStatusCode(code int) *ReplaceAllHTTPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP check defaults default response +func (o *ReplaceAllHTTPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP check defaults default response +func (o *ReplaceAllHTTPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP check defaults default response +func (o *ReplaceAllHTTPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP check defaults default response +func (o *ReplaceAllHTTPCheckDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP check defaults default response +func (o *ReplaceAllHTTPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/replace_all_http_check_defaults_urlbuilder.go b/operations/http_check/replace_all_http_check_defaults_urlbuilder.go new file mode 100644 index 00000000..38c1d3d6 --- /dev/null +++ b/operations/http_check/replace_all_http_check_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPCheckDefaultsURL generates an URL for the replace all HTTP check defaults operation +type ReplaceAllHTTPCheckDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPCheckDefaultsURL) WithBasePath(bp string) *ReplaceAllHTTPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/replace_http_check_backend.go b/operations/http_check/replace_http_check_backend.go new file mode 100644 index 00000000..f6043b1b --- /dev/null +++ b/operations/http_check/replace_http_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPCheckBackendHandlerFunc turns a function with the right signature into a replace HTTP check backend handler +type ReplaceHTTPCheckBackendHandlerFunc func(ReplaceHTTPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPCheckBackendHandlerFunc) Handle(params ReplaceHTTPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPCheckBackendHandler interface for that can handle valid replace HTTP check backend params +type ReplaceHTTPCheckBackendHandler interface { + Handle(ReplaceHTTPCheckBackendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPCheckBackend creates a new http.Handler for the replace HTTP check backend operation +func NewReplaceHTTPCheckBackend(ctx *middleware.Context, handler ReplaceHTTPCheckBackendHandler) *ReplaceHTTPCheckBackend { + return &ReplaceHTTPCheckBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPCheckBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_checks/{index} HTTPCheck replaceHttpCheckBackend + +# Replace a HTTP check + +Replaces a HTTP Check configuration by it's index in the specified parent. +*/ +type ReplaceHTTPCheckBackend struct { + Context *middleware.Context + Handler ReplaceHTTPCheckBackendHandler +} + +func (o *ReplaceHTTPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/replace_http_check_backend_parameters.go b/operations/http_check/replace_http_check_backend_parameters.go new file mode 100644 index 00000000..77edcfdb --- /dev/null +++ b/operations/http_check/replace_http_check_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPCheckBackendParams creates a new ReplaceHTTPCheckBackendParams object +// with the default values initialized. +func NewReplaceHTTPCheckBackendParams() ReplaceHTTPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPCheckBackendParams contains all the bound params for the replace HTTP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPCheckBackend +type ReplaceHTTPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPCheckBackendParams() beforehand. +func (o *ReplaceHTTPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/replace_http_check_backend_responses.go b/operations/http_check/replace_http_check_backend_responses.go new file mode 100644 index 00000000..9da64dc2 --- /dev/null +++ b/operations/http_check/replace_http_check_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPCheckBackendOKCode is the HTTP code returned for type ReplaceHTTPCheckBackendOK +const ReplaceHTTPCheckBackendOKCode int = 200 + +/* +ReplaceHTTPCheckBackendOK HTTP check replaced + +swagger:response replaceHttpCheckBackendOK +*/ +type ReplaceHTTPCheckBackendOK struct { + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckBackendOK creates ReplaceHTTPCheckBackendOK with default headers values +func NewReplaceHTTPCheckBackendOK() *ReplaceHTTPCheckBackendOK { + + return &ReplaceHTTPCheckBackendOK{} +} + +// WithPayload adds the payload to the replace Http check backend o k response +func (o *ReplaceHTTPCheckBackendOK) WithPayload(payload *models.HTTPCheck) *ReplaceHTTPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check backend o k response +func (o *ReplaceHTTPCheckBackendOK) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPCheckBackendAcceptedCode is the HTTP code returned for type ReplaceHTTPCheckBackendAccepted +const ReplaceHTTPCheckBackendAcceptedCode int = 202 + +/* +ReplaceHTTPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpCheckBackendAccepted +*/ +type ReplaceHTTPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckBackendAccepted creates ReplaceHTTPCheckBackendAccepted with default headers values +func NewReplaceHTTPCheckBackendAccepted() *ReplaceHTTPCheckBackendAccepted { + + return &ReplaceHTTPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http check backend accepted response +func (o *ReplaceHTTPCheckBackendAccepted) WithReloadID(reloadID string) *ReplaceHTTPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http check backend accepted response +func (o *ReplaceHTTPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http check backend accepted response +func (o *ReplaceHTTPCheckBackendAccepted) WithPayload(payload *models.HTTPCheck) *ReplaceHTTPCheckBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check backend accepted response +func (o *ReplaceHTTPCheckBackendAccepted) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPCheckBackendBadRequestCode is the HTTP code returned for type ReplaceHTTPCheckBackendBadRequest +const ReplaceHTTPCheckBackendBadRequestCode int = 400 + +/* +ReplaceHTTPCheckBackendBadRequest Bad request + +swagger:response replaceHttpCheckBackendBadRequest +*/ +type ReplaceHTTPCheckBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckBackendBadRequest creates ReplaceHTTPCheckBackendBadRequest with default headers values +func NewReplaceHTTPCheckBackendBadRequest() *ReplaceHTTPCheckBackendBadRequest { + + return &ReplaceHTTPCheckBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http check backend bad request response +func (o *ReplaceHTTPCheckBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPCheckBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http check backend bad request response +func (o *ReplaceHTTPCheckBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http check backend bad request response +func (o *ReplaceHTTPCheckBackendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPCheckBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check backend bad request response +func (o *ReplaceHTTPCheckBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPCheckBackendNotFoundCode is the HTTP code returned for type ReplaceHTTPCheckBackendNotFound +const ReplaceHTTPCheckBackendNotFoundCode int = 404 + +/* +ReplaceHTTPCheckBackendNotFound The specified resource was not found + +swagger:response replaceHttpCheckBackendNotFound +*/ +type ReplaceHTTPCheckBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckBackendNotFound creates ReplaceHTTPCheckBackendNotFound with default headers values +func NewReplaceHTTPCheckBackendNotFound() *ReplaceHTTPCheckBackendNotFound { + + return &ReplaceHTTPCheckBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http check backend not found response +func (o *ReplaceHTTPCheckBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPCheckBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http check backend not found response +func (o *ReplaceHTTPCheckBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http check backend not found response +func (o *ReplaceHTTPCheckBackendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPCheckBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check backend not found response +func (o *ReplaceHTTPCheckBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPCheckBackendDefault General Error + +swagger:response replaceHttpCheckBackendDefault +*/ +type ReplaceHTTPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckBackendDefault creates ReplaceHTTPCheckBackendDefault with default headers values +func NewReplaceHTTPCheckBackendDefault(code int) *ReplaceHTTPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP check backend default response +func (o *ReplaceHTTPCheckBackendDefault) WithStatusCode(code int) *ReplaceHTTPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP check backend default response +func (o *ReplaceHTTPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP check backend default response +func (o *ReplaceHTTPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP check backend default response +func (o *ReplaceHTTPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP check backend default response +func (o *ReplaceHTTPCheckBackendDefault) WithPayload(payload *models.Error) *ReplaceHTTPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP check backend default response +func (o *ReplaceHTTPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/replace_http_check_backend_urlbuilder.go b/operations/http_check/replace_http_check_backend_urlbuilder.go new file mode 100644 index 00000000..eb617d41 --- /dev/null +++ b/operations/http_check/replace_http_check_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPCheckBackendURL generates an URL for the replace HTTP check backend operation +type ReplaceHTTPCheckBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPCheckBackendURL) WithBasePath(bp string) *ReplaceHTTPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_check/replace_http_check_defaults.go b/operations/http_check/replace_http_check_defaults.go new file mode 100644 index 00000000..abdae708 --- /dev/null +++ b/operations/http_check/replace_http_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPCheckDefaultsHandlerFunc turns a function with the right signature into a replace HTTP check defaults handler +type ReplaceHTTPCheckDefaultsHandlerFunc func(ReplaceHTTPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPCheckDefaultsHandlerFunc) Handle(params ReplaceHTTPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPCheckDefaultsHandler interface for that can handle valid replace HTTP check defaults params +type ReplaceHTTPCheckDefaultsHandler interface { + Handle(ReplaceHTTPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPCheckDefaults creates a new http.Handler for the replace HTTP check defaults operation +func NewReplaceHTTPCheckDefaults(ctx *middleware.Context, handler ReplaceHTTPCheckDefaultsHandler) *ReplaceHTTPCheckDefaults { + return &ReplaceHTTPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPCheckDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_checks/{index} HTTPCheck replaceHttpCheckDefaults + +# Replace a HTTP check + +Replaces a HTTP Check configuration by it's index in the specified parent. +*/ +type ReplaceHTTPCheckDefaults struct { + Context *middleware.Context + Handler ReplaceHTTPCheckDefaultsHandler +} + +func (o *ReplaceHTTPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_check/replace_http_check_defaults_parameters.go b/operations/http_check/replace_http_check_defaults_parameters.go new file mode 100644 index 00000000..01775240 --- /dev/null +++ b/operations/http_check/replace_http_check_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPCheckDefaultsParams creates a new ReplaceHTTPCheckDefaultsParams object +// with the default values initialized. +func NewReplaceHTTPCheckDefaultsParams() ReplaceHTTPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPCheckDefaultsParams contains all the bound params for the replace HTTP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPCheckDefaults +type ReplaceHTTPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPCheckDefaultsParams() beforehand. +func (o *ReplaceHTTPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_check/replace_http_check_defaults_responses.go b/operations/http_check/replace_http_check_defaults_responses.go new file mode 100644 index 00000000..27012528 --- /dev/null +++ b/operations/http_check/replace_http_check_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPCheckDefaultsOKCode is the HTTP code returned for type ReplaceHTTPCheckDefaultsOK +const ReplaceHTTPCheckDefaultsOKCode int = 200 + +/* +ReplaceHTTPCheckDefaultsOK HTTP check replaced + +swagger:response replaceHttpCheckDefaultsOK +*/ +type ReplaceHTTPCheckDefaultsOK struct { + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckDefaultsOK creates ReplaceHTTPCheckDefaultsOK with default headers values +func NewReplaceHTTPCheckDefaultsOK() *ReplaceHTTPCheckDefaultsOK { + + return &ReplaceHTTPCheckDefaultsOK{} +} + +// WithPayload adds the payload to the replace Http check defaults o k response +func (o *ReplaceHTTPCheckDefaultsOK) WithPayload(payload *models.HTTPCheck) *ReplaceHTTPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check defaults o k response +func (o *ReplaceHTTPCheckDefaultsOK) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPCheckDefaultsAcceptedCode is the HTTP code returned for type ReplaceHTTPCheckDefaultsAccepted +const ReplaceHTTPCheckDefaultsAcceptedCode int = 202 + +/* +ReplaceHTTPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpCheckDefaultsAccepted +*/ +type ReplaceHTTPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPCheck `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckDefaultsAccepted creates ReplaceHTTPCheckDefaultsAccepted with default headers values +func NewReplaceHTTPCheckDefaultsAccepted() *ReplaceHTTPCheckDefaultsAccepted { + + return &ReplaceHTTPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http check defaults accepted response +func (o *ReplaceHTTPCheckDefaultsAccepted) WithReloadID(reloadID string) *ReplaceHTTPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http check defaults accepted response +func (o *ReplaceHTTPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http check defaults accepted response +func (o *ReplaceHTTPCheckDefaultsAccepted) WithPayload(payload *models.HTTPCheck) *ReplaceHTTPCheckDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check defaults accepted response +func (o *ReplaceHTTPCheckDefaultsAccepted) SetPayload(payload *models.HTTPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPCheckDefaultsBadRequestCode is the HTTP code returned for type ReplaceHTTPCheckDefaultsBadRequest +const ReplaceHTTPCheckDefaultsBadRequestCode int = 400 + +/* +ReplaceHTTPCheckDefaultsBadRequest Bad request + +swagger:response replaceHttpCheckDefaultsBadRequest +*/ +type ReplaceHTTPCheckDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckDefaultsBadRequest creates ReplaceHTTPCheckDefaultsBadRequest with default headers values +func NewReplaceHTTPCheckDefaultsBadRequest() *ReplaceHTTPCheckDefaultsBadRequest { + + return &ReplaceHTTPCheckDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http check defaults bad request response +func (o *ReplaceHTTPCheckDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPCheckDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http check defaults bad request response +func (o *ReplaceHTTPCheckDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http check defaults bad request response +func (o *ReplaceHTTPCheckDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPCheckDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check defaults bad request response +func (o *ReplaceHTTPCheckDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPCheckDefaultsNotFoundCode is the HTTP code returned for type ReplaceHTTPCheckDefaultsNotFound +const ReplaceHTTPCheckDefaultsNotFoundCode int = 404 + +/* +ReplaceHTTPCheckDefaultsNotFound The specified resource was not found + +swagger:response replaceHttpCheckDefaultsNotFound +*/ +type ReplaceHTTPCheckDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckDefaultsNotFound creates ReplaceHTTPCheckDefaultsNotFound with default headers values +func NewReplaceHTTPCheckDefaultsNotFound() *ReplaceHTTPCheckDefaultsNotFound { + + return &ReplaceHTTPCheckDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http check defaults not found response +func (o *ReplaceHTTPCheckDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPCheckDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http check defaults not found response +func (o *ReplaceHTTPCheckDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http check defaults not found response +func (o *ReplaceHTTPCheckDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceHTTPCheckDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http check defaults not found response +func (o *ReplaceHTTPCheckDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPCheckDefaultsDefault General Error + +swagger:response replaceHttpCheckDefaultsDefault +*/ +type ReplaceHTTPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPCheckDefaultsDefault creates ReplaceHTTPCheckDefaultsDefault with default headers values +func NewReplaceHTTPCheckDefaultsDefault(code int) *ReplaceHTTPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP check defaults default response +func (o *ReplaceHTTPCheckDefaultsDefault) WithStatusCode(code int) *ReplaceHTTPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP check defaults default response +func (o *ReplaceHTTPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP check defaults default response +func (o *ReplaceHTTPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP check defaults default response +func (o *ReplaceHTTPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP check defaults default response +func (o *ReplaceHTTPCheckDefaultsDefault) WithPayload(payload *models.Error) *ReplaceHTTPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP check defaults default response +func (o *ReplaceHTTPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_check/replace_http_check_defaults_urlbuilder.go b/operations/http_check/replace_http_check_defaults_urlbuilder.go new file mode 100644 index 00000000..45ccc7ed --- /dev/null +++ b/operations/http_check/replace_http_check_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPCheckDefaultsURL generates an URL for the replace HTTP check defaults operation +type ReplaceHTTPCheckDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPCheckDefaultsURL) WithBasePath(bp string) *ReplaceHTTPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/create_http_error_rule_backend.go b/operations/http_error_rule/create_http_error_rule_backend.go new file mode 100644 index 00000000..577ec15b --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPErrorRuleBackendHandlerFunc turns a function with the right signature into a create HTTP error rule backend handler +type CreateHTTPErrorRuleBackendHandlerFunc func(CreateHTTPErrorRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPErrorRuleBackendHandlerFunc) Handle(params CreateHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPErrorRuleBackendHandler interface for that can handle valid create HTTP error rule backend params +type CreateHTTPErrorRuleBackendHandler interface { + Handle(CreateHTTPErrorRuleBackendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPErrorRuleBackend creates a new http.Handler for the create HTTP error rule backend operation +func NewCreateHTTPErrorRuleBackend(ctx *middleware.Context, handler CreateHTTPErrorRuleBackendHandler) *CreateHTTPErrorRuleBackend { + return &CreateHTTPErrorRuleBackend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPErrorRuleBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index} HTTPErrorRule createHttpErrorRuleBackend + +# Add a new HTTP Error Rule + +Adds a new HTTP Error Rule of the specified type in the specified parent. +*/ +type CreateHTTPErrorRuleBackend struct { + Context *middleware.Context + Handler CreateHTTPErrorRuleBackendHandler +} + +func (o *CreateHTTPErrorRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPErrorRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/create_http_error_rule_backend_parameters.go b/operations/http_error_rule/create_http_error_rule_backend_parameters.go new file mode 100644 index 00000000..aeb5b09d --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPErrorRuleBackendParams creates a new CreateHTTPErrorRuleBackendParams object +// with the default values initialized. +func NewCreateHTTPErrorRuleBackendParams() CreateHTTPErrorRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPErrorRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPErrorRuleBackendParams contains all the bound params for the create HTTP error rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPErrorRuleBackend +type CreateHTTPErrorRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPErrorRuleBackendParams() beforehand. +func (o *CreateHTTPErrorRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPErrorRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPErrorRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPErrorRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPErrorRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPErrorRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPErrorRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/create_http_error_rule_backend_responses.go b/operations/http_error_rule/create_http_error_rule_backend_responses.go new file mode 100644 index 00000000..58cb631f --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPErrorRuleBackendCreatedCode is the HTTP code returned for type CreateHTTPErrorRuleBackendCreated +const CreateHTTPErrorRuleBackendCreatedCode int = 201 + +/* +CreateHTTPErrorRuleBackendCreated HTTP Error Rule created + +swagger:response createHttpErrorRuleBackendCreated +*/ +type CreateHTTPErrorRuleBackendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleBackendCreated creates CreateHTTPErrorRuleBackendCreated with default headers values +func NewCreateHTTPErrorRuleBackendCreated() *CreateHTTPErrorRuleBackendCreated { + + return &CreateHTTPErrorRuleBackendCreated{} +} + +// WithPayload adds the payload to the create Http error rule backend created response +func (o *CreateHTTPErrorRuleBackendCreated) WithPayload(payload *models.HTTPErrorRule) *CreateHTTPErrorRuleBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule backend created response +func (o *CreateHTTPErrorRuleBackendCreated) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleBackendAcceptedCode is the HTTP code returned for type CreateHTTPErrorRuleBackendAccepted +const CreateHTTPErrorRuleBackendAcceptedCode int = 202 + +/* +CreateHTTPErrorRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response createHttpErrorRuleBackendAccepted +*/ +type CreateHTTPErrorRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleBackendAccepted creates CreateHTTPErrorRuleBackendAccepted with default headers values +func NewCreateHTTPErrorRuleBackendAccepted() *CreateHTTPErrorRuleBackendAccepted { + + return &CreateHTTPErrorRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http error rule backend accepted response +func (o *CreateHTTPErrorRuleBackendAccepted) WithReloadID(reloadID string) *CreateHTTPErrorRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http error rule backend accepted response +func (o *CreateHTTPErrorRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http error rule backend accepted response +func (o *CreateHTTPErrorRuleBackendAccepted) WithPayload(payload *models.HTTPErrorRule) *CreateHTTPErrorRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule backend accepted response +func (o *CreateHTTPErrorRuleBackendAccepted) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleBackendBadRequestCode is the HTTP code returned for type CreateHTTPErrorRuleBackendBadRequest +const CreateHTTPErrorRuleBackendBadRequestCode int = 400 + +/* +CreateHTTPErrorRuleBackendBadRequest Bad request + +swagger:response createHttpErrorRuleBackendBadRequest +*/ +type CreateHTTPErrorRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleBackendBadRequest creates CreateHTTPErrorRuleBackendBadRequest with default headers values +func NewCreateHTTPErrorRuleBackendBadRequest() *CreateHTTPErrorRuleBackendBadRequest { + + return &CreateHTTPErrorRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http error rule backend bad request response +func (o *CreateHTTPErrorRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http error rule backend bad request response +func (o *CreateHTTPErrorRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http error rule backend bad request response +func (o *CreateHTTPErrorRuleBackendBadRequest) WithPayload(payload *models.Error) *CreateHTTPErrorRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule backend bad request response +func (o *CreateHTTPErrorRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleBackendConflictCode is the HTTP code returned for type CreateHTTPErrorRuleBackendConflict +const CreateHTTPErrorRuleBackendConflictCode int = 409 + +/* +CreateHTTPErrorRuleBackendConflict The specified resource already exists + +swagger:response createHttpErrorRuleBackendConflict +*/ +type CreateHTTPErrorRuleBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleBackendConflict creates CreateHTTPErrorRuleBackendConflict with default headers values +func NewCreateHTTPErrorRuleBackendConflict() *CreateHTTPErrorRuleBackendConflict { + + return &CreateHTTPErrorRuleBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http error rule backend conflict response +func (o *CreateHTTPErrorRuleBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http error rule backend conflict response +func (o *CreateHTTPErrorRuleBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http error rule backend conflict response +func (o *CreateHTTPErrorRuleBackendConflict) WithPayload(payload *models.Error) *CreateHTTPErrorRuleBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule backend conflict response +func (o *CreateHTTPErrorRuleBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPErrorRuleBackendDefault General Error + +swagger:response createHttpErrorRuleBackendDefault +*/ +type CreateHTTPErrorRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleBackendDefault creates CreateHTTPErrorRuleBackendDefault with default headers values +func NewCreateHTTPErrorRuleBackendDefault(code int) *CreateHTTPErrorRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPErrorRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP error rule backend default response +func (o *CreateHTTPErrorRuleBackendDefault) WithStatusCode(code int) *CreateHTTPErrorRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP error rule backend default response +func (o *CreateHTTPErrorRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP error rule backend default response +func (o *CreateHTTPErrorRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP error rule backend default response +func (o *CreateHTTPErrorRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP error rule backend default response +func (o *CreateHTTPErrorRuleBackendDefault) WithPayload(payload *models.Error) *CreateHTTPErrorRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP error rule backend default response +func (o *CreateHTTPErrorRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/create_http_error_rule_backend_urlbuilder.go b/operations/http_error_rule/create_http_error_rule_backend_urlbuilder.go new file mode 100644 index 00000000..e497992d --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPErrorRuleBackendURL generates an URL for the create HTTP error rule backend operation +type CreateHTTPErrorRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorRuleBackendURL) WithBasePath(bp string) *CreateHTTPErrorRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPErrorRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPErrorRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPErrorRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPErrorRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPErrorRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPErrorRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPErrorRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPErrorRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPErrorRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/create_http_error_rule_defaults.go b/operations/http_error_rule/create_http_error_rule_defaults.go new file mode 100644 index 00000000..569e6be5 --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPErrorRuleDefaultsHandlerFunc turns a function with the right signature into a create HTTP error rule defaults handler +type CreateHTTPErrorRuleDefaultsHandlerFunc func(CreateHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPErrorRuleDefaultsHandlerFunc) Handle(params CreateHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPErrorRuleDefaultsHandler interface for that can handle valid create HTTP error rule defaults params +type CreateHTTPErrorRuleDefaultsHandler interface { + Handle(CreateHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateHTTPErrorRuleDefaults creates a new http.Handler for the create HTTP error rule defaults operation +func NewCreateHTTPErrorRuleDefaults(ctx *middleware.Context, handler CreateHTTPErrorRuleDefaultsHandler) *CreateHTTPErrorRuleDefaults { + return &CreateHTTPErrorRuleDefaults{Context: ctx, Handler: handler} +} + +/* + CreateHTTPErrorRuleDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index} HTTPErrorRule createHttpErrorRuleDefaults + +# Add a new HTTP Error Rule + +Adds a new HTTP Error Rule of the specified type in the specified parent. +*/ +type CreateHTTPErrorRuleDefaults struct { + Context *middleware.Context + Handler CreateHTTPErrorRuleDefaultsHandler +} + +func (o *CreateHTTPErrorRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPErrorRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/create_http_error_rule_defaults_parameters.go b/operations/http_error_rule/create_http_error_rule_defaults_parameters.go new file mode 100644 index 00000000..3c60a513 --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPErrorRuleDefaultsParams creates a new CreateHTTPErrorRuleDefaultsParams object +// with the default values initialized. +func NewCreateHTTPErrorRuleDefaultsParams() CreateHTTPErrorRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPErrorRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPErrorRuleDefaultsParams contains all the bound params for the create HTTP error rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPErrorRuleDefaults +type CreateHTTPErrorRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPErrorRuleDefaultsParams() beforehand. +func (o *CreateHTTPErrorRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPErrorRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPErrorRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPErrorRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPErrorRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPErrorRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPErrorRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/create_http_error_rule_defaults_responses.go b/operations/http_error_rule/create_http_error_rule_defaults_responses.go new file mode 100644 index 00000000..d2439b8f --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPErrorRuleDefaultsCreatedCode is the HTTP code returned for type CreateHTTPErrorRuleDefaultsCreated +const CreateHTTPErrorRuleDefaultsCreatedCode int = 201 + +/* +CreateHTTPErrorRuleDefaultsCreated HTTP Error Rule created + +swagger:response createHttpErrorRuleDefaultsCreated +*/ +type CreateHTTPErrorRuleDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleDefaultsCreated creates CreateHTTPErrorRuleDefaultsCreated with default headers values +func NewCreateHTTPErrorRuleDefaultsCreated() *CreateHTTPErrorRuleDefaultsCreated { + + return &CreateHTTPErrorRuleDefaultsCreated{} +} + +// WithPayload adds the payload to the create Http error rule defaults created response +func (o *CreateHTTPErrorRuleDefaultsCreated) WithPayload(payload *models.HTTPErrorRule) *CreateHTTPErrorRuleDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule defaults created response +func (o *CreateHTTPErrorRuleDefaultsCreated) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleDefaultsAcceptedCode is the HTTP code returned for type CreateHTTPErrorRuleDefaultsAccepted +const CreateHTTPErrorRuleDefaultsAcceptedCode int = 202 + +/* +CreateHTTPErrorRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createHttpErrorRuleDefaultsAccepted +*/ +type CreateHTTPErrorRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleDefaultsAccepted creates CreateHTTPErrorRuleDefaultsAccepted with default headers values +func NewCreateHTTPErrorRuleDefaultsAccepted() *CreateHTTPErrorRuleDefaultsAccepted { + + return &CreateHTTPErrorRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Http error rule defaults accepted response +func (o *CreateHTTPErrorRuleDefaultsAccepted) WithReloadID(reloadID string) *CreateHTTPErrorRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http error rule defaults accepted response +func (o *CreateHTTPErrorRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http error rule defaults accepted response +func (o *CreateHTTPErrorRuleDefaultsAccepted) WithPayload(payload *models.HTTPErrorRule) *CreateHTTPErrorRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule defaults accepted response +func (o *CreateHTTPErrorRuleDefaultsAccepted) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleDefaultsBadRequestCode is the HTTP code returned for type CreateHTTPErrorRuleDefaultsBadRequest +const CreateHTTPErrorRuleDefaultsBadRequestCode int = 400 + +/* +CreateHTTPErrorRuleDefaultsBadRequest Bad request + +swagger:response createHttpErrorRuleDefaultsBadRequest +*/ +type CreateHTTPErrorRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleDefaultsBadRequest creates CreateHTTPErrorRuleDefaultsBadRequest with default headers values +func NewCreateHTTPErrorRuleDefaultsBadRequest() *CreateHTTPErrorRuleDefaultsBadRequest { + + return &CreateHTTPErrorRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http error rule defaults bad request response +func (o *CreateHTTPErrorRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http error rule defaults bad request response +func (o *CreateHTTPErrorRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http error rule defaults bad request response +func (o *CreateHTTPErrorRuleDefaultsBadRequest) WithPayload(payload *models.Error) *CreateHTTPErrorRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule defaults bad request response +func (o *CreateHTTPErrorRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleDefaultsConflictCode is the HTTP code returned for type CreateHTTPErrorRuleDefaultsConflict +const CreateHTTPErrorRuleDefaultsConflictCode int = 409 + +/* +CreateHTTPErrorRuleDefaultsConflict The specified resource already exists + +swagger:response createHttpErrorRuleDefaultsConflict +*/ +type CreateHTTPErrorRuleDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleDefaultsConflict creates CreateHTTPErrorRuleDefaultsConflict with default headers values +func NewCreateHTTPErrorRuleDefaultsConflict() *CreateHTTPErrorRuleDefaultsConflict { + + return &CreateHTTPErrorRuleDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http error rule defaults conflict response +func (o *CreateHTTPErrorRuleDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http error rule defaults conflict response +func (o *CreateHTTPErrorRuleDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http error rule defaults conflict response +func (o *CreateHTTPErrorRuleDefaultsConflict) WithPayload(payload *models.Error) *CreateHTTPErrorRuleDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule defaults conflict response +func (o *CreateHTTPErrorRuleDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPErrorRuleDefaultsDefault General Error + +swagger:response createHttpErrorRuleDefaultsDefault +*/ +type CreateHTTPErrorRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleDefaultsDefault creates CreateHTTPErrorRuleDefaultsDefault with default headers values +func NewCreateHTTPErrorRuleDefaultsDefault(code int) *CreateHTTPErrorRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPErrorRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP error rule defaults default response +func (o *CreateHTTPErrorRuleDefaultsDefault) WithStatusCode(code int) *CreateHTTPErrorRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP error rule defaults default response +func (o *CreateHTTPErrorRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP error rule defaults default response +func (o *CreateHTTPErrorRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP error rule defaults default response +func (o *CreateHTTPErrorRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP error rule defaults default response +func (o *CreateHTTPErrorRuleDefaultsDefault) WithPayload(payload *models.Error) *CreateHTTPErrorRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP error rule defaults default response +func (o *CreateHTTPErrorRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/create_http_error_rule_defaults_urlbuilder.go b/operations/http_error_rule/create_http_error_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..f01e00ec --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPErrorRuleDefaultsURL generates an URL for the create HTTP error rule defaults operation +type CreateHTTPErrorRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorRuleDefaultsURL) WithBasePath(bp string) *CreateHTTPErrorRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPErrorRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPErrorRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPErrorRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPErrorRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPErrorRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPErrorRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPErrorRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPErrorRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPErrorRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/create_http_error_rule_frontend.go b/operations/http_error_rule/create_http_error_rule_frontend.go new file mode 100644 index 00000000..2bcbff56 --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPErrorRuleFrontendHandlerFunc turns a function with the right signature into a create HTTP error rule frontend handler +type CreateHTTPErrorRuleFrontendHandlerFunc func(CreateHTTPErrorRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPErrorRuleFrontendHandlerFunc) Handle(params CreateHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPErrorRuleFrontendHandler interface for that can handle valid create HTTP error rule frontend params +type CreateHTTPErrorRuleFrontendHandler interface { + Handle(CreateHTTPErrorRuleFrontendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPErrorRuleFrontend creates a new http.Handler for the create HTTP error rule frontend operation +func NewCreateHTTPErrorRuleFrontend(ctx *middleware.Context, handler CreateHTTPErrorRuleFrontendHandler) *CreateHTTPErrorRuleFrontend { + return &CreateHTTPErrorRuleFrontend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPErrorRuleFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index} HTTPErrorRule createHttpErrorRuleFrontend + +# Add a new HTTP Error Rule + +Adds a new HTTP Error Rule of the specified type in the specified parent. +*/ +type CreateHTTPErrorRuleFrontend struct { + Context *middleware.Context + Handler CreateHTTPErrorRuleFrontendHandler +} + +func (o *CreateHTTPErrorRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPErrorRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/create_http_error_rule_frontend_parameters.go b/operations/http_error_rule/create_http_error_rule_frontend_parameters.go new file mode 100644 index 00000000..29024d0a --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPErrorRuleFrontendParams creates a new CreateHTTPErrorRuleFrontendParams object +// with the default values initialized. +func NewCreateHTTPErrorRuleFrontendParams() CreateHTTPErrorRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPErrorRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPErrorRuleFrontendParams contains all the bound params for the create HTTP error rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPErrorRuleFrontend +type CreateHTTPErrorRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPErrorRuleFrontendParams() beforehand. +func (o *CreateHTTPErrorRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPErrorRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPErrorRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPErrorRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPErrorRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPErrorRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPErrorRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/create_http_error_rule_frontend_responses.go b/operations/http_error_rule/create_http_error_rule_frontend_responses.go new file mode 100644 index 00000000..845dcf23 --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPErrorRuleFrontendCreatedCode is the HTTP code returned for type CreateHTTPErrorRuleFrontendCreated +const CreateHTTPErrorRuleFrontendCreatedCode int = 201 + +/* +CreateHTTPErrorRuleFrontendCreated HTTP Error Rule created + +swagger:response createHttpErrorRuleFrontendCreated +*/ +type CreateHTTPErrorRuleFrontendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleFrontendCreated creates CreateHTTPErrorRuleFrontendCreated with default headers values +func NewCreateHTTPErrorRuleFrontendCreated() *CreateHTTPErrorRuleFrontendCreated { + + return &CreateHTTPErrorRuleFrontendCreated{} +} + +// WithPayload adds the payload to the create Http error rule frontend created response +func (o *CreateHTTPErrorRuleFrontendCreated) WithPayload(payload *models.HTTPErrorRule) *CreateHTTPErrorRuleFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule frontend created response +func (o *CreateHTTPErrorRuleFrontendCreated) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleFrontendAcceptedCode is the HTTP code returned for type CreateHTTPErrorRuleFrontendAccepted +const CreateHTTPErrorRuleFrontendAcceptedCode int = 202 + +/* +CreateHTTPErrorRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response createHttpErrorRuleFrontendAccepted +*/ +type CreateHTTPErrorRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleFrontendAccepted creates CreateHTTPErrorRuleFrontendAccepted with default headers values +func NewCreateHTTPErrorRuleFrontendAccepted() *CreateHTTPErrorRuleFrontendAccepted { + + return &CreateHTTPErrorRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http error rule frontend accepted response +func (o *CreateHTTPErrorRuleFrontendAccepted) WithReloadID(reloadID string) *CreateHTTPErrorRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http error rule frontend accepted response +func (o *CreateHTTPErrorRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http error rule frontend accepted response +func (o *CreateHTTPErrorRuleFrontendAccepted) WithPayload(payload *models.HTTPErrorRule) *CreateHTTPErrorRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule frontend accepted response +func (o *CreateHTTPErrorRuleFrontendAccepted) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleFrontendBadRequestCode is the HTTP code returned for type CreateHTTPErrorRuleFrontendBadRequest +const CreateHTTPErrorRuleFrontendBadRequestCode int = 400 + +/* +CreateHTTPErrorRuleFrontendBadRequest Bad request + +swagger:response createHttpErrorRuleFrontendBadRequest +*/ +type CreateHTTPErrorRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleFrontendBadRequest creates CreateHTTPErrorRuleFrontendBadRequest with default headers values +func NewCreateHTTPErrorRuleFrontendBadRequest() *CreateHTTPErrorRuleFrontendBadRequest { + + return &CreateHTTPErrorRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http error rule frontend bad request response +func (o *CreateHTTPErrorRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http error rule frontend bad request response +func (o *CreateHTTPErrorRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http error rule frontend bad request response +func (o *CreateHTTPErrorRuleFrontendBadRequest) WithPayload(payload *models.Error) *CreateHTTPErrorRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule frontend bad request response +func (o *CreateHTTPErrorRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorRuleFrontendConflictCode is the HTTP code returned for type CreateHTTPErrorRuleFrontendConflict +const CreateHTTPErrorRuleFrontendConflictCode int = 409 + +/* +CreateHTTPErrorRuleFrontendConflict The specified resource already exists + +swagger:response createHttpErrorRuleFrontendConflict +*/ +type CreateHTTPErrorRuleFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleFrontendConflict creates CreateHTTPErrorRuleFrontendConflict with default headers values +func NewCreateHTTPErrorRuleFrontendConflict() *CreateHTTPErrorRuleFrontendConflict { + + return &CreateHTTPErrorRuleFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http error rule frontend conflict response +func (o *CreateHTTPErrorRuleFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http error rule frontend conflict response +func (o *CreateHTTPErrorRuleFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http error rule frontend conflict response +func (o *CreateHTTPErrorRuleFrontendConflict) WithPayload(payload *models.Error) *CreateHTTPErrorRuleFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http error rule frontend conflict response +func (o *CreateHTTPErrorRuleFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPErrorRuleFrontendDefault General Error + +swagger:response createHttpErrorRuleFrontendDefault +*/ +type CreateHTTPErrorRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorRuleFrontendDefault creates CreateHTTPErrorRuleFrontendDefault with default headers values +func NewCreateHTTPErrorRuleFrontendDefault(code int) *CreateHTTPErrorRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPErrorRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP error rule frontend default response +func (o *CreateHTTPErrorRuleFrontendDefault) WithStatusCode(code int) *CreateHTTPErrorRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP error rule frontend default response +func (o *CreateHTTPErrorRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP error rule frontend default response +func (o *CreateHTTPErrorRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP error rule frontend default response +func (o *CreateHTTPErrorRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP error rule frontend default response +func (o *CreateHTTPErrorRuleFrontendDefault) WithPayload(payload *models.Error) *CreateHTTPErrorRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP error rule frontend default response +func (o *CreateHTTPErrorRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/create_http_error_rule_frontend_urlbuilder.go b/operations/http_error_rule/create_http_error_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..bacf7224 --- /dev/null +++ b/operations/http_error_rule/create_http_error_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPErrorRuleFrontendURL generates an URL for the create HTTP error rule frontend operation +type CreateHTTPErrorRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorRuleFrontendURL) WithBasePath(bp string) *CreateHTTPErrorRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPErrorRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPErrorRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPErrorRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPErrorRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPErrorRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPErrorRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPErrorRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPErrorRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPErrorRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/delete_http_error_rule_backend.go b/operations/http_error_rule/delete_http_error_rule_backend.go new file mode 100644 index 00000000..14188449 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPErrorRuleBackendHandlerFunc turns a function with the right signature into a delete HTTP error rule backend handler +type DeleteHTTPErrorRuleBackendHandlerFunc func(DeleteHTTPErrorRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPErrorRuleBackendHandlerFunc) Handle(params DeleteHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPErrorRuleBackendHandler interface for that can handle valid delete HTTP error rule backend params +type DeleteHTTPErrorRuleBackendHandler interface { + Handle(DeleteHTTPErrorRuleBackendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPErrorRuleBackend creates a new http.Handler for the delete HTTP error rule backend operation +func NewDeleteHTTPErrorRuleBackend(ctx *middleware.Context, handler DeleteHTTPErrorRuleBackendHandler) *DeleteHTTPErrorRuleBackend { + return &DeleteHTTPErrorRuleBackend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPErrorRuleBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index} HTTPErrorRule deleteHttpErrorRuleBackend + +# Delete a HTTP Error Rule + +Deletes a HTTP Error Rule configuration by its index from the specified parent. +*/ +type DeleteHTTPErrorRuleBackend struct { + Context *middleware.Context + Handler DeleteHTTPErrorRuleBackendHandler +} + +func (o *DeleteHTTPErrorRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPErrorRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/delete_http_error_rule_backend_parameters.go b/operations/http_error_rule/delete_http_error_rule_backend_parameters.go new file mode 100644 index 00000000..47f7a25a --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPErrorRuleBackendParams creates a new DeleteHTTPErrorRuleBackendParams object +// with the default values initialized. +func NewDeleteHTTPErrorRuleBackendParams() DeleteHTTPErrorRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPErrorRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPErrorRuleBackendParams contains all the bound params for the delete HTTP error rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPErrorRuleBackend +type DeleteHTTPErrorRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPErrorRuleBackendParams() beforehand. +func (o *DeleteHTTPErrorRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPErrorRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPErrorRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPErrorRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPErrorRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPErrorRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPErrorRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/delete_http_error_rule_backend_responses.go b/operations/http_error_rule/delete_http_error_rule_backend_responses.go new file mode 100644 index 00000000..879e5bea --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPErrorRuleBackendAcceptedCode is the HTTP code returned for type DeleteHTTPErrorRuleBackendAccepted +const DeleteHTTPErrorRuleBackendAcceptedCode int = 202 + +/* +DeleteHTTPErrorRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpErrorRuleBackendAccepted +*/ +type DeleteHTTPErrorRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPErrorRuleBackendAccepted creates DeleteHTTPErrorRuleBackendAccepted with default headers values +func NewDeleteHTTPErrorRuleBackendAccepted() *DeleteHTTPErrorRuleBackendAccepted { + + return &DeleteHTTPErrorRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http error rule backend accepted response +func (o *DeleteHTTPErrorRuleBackendAccepted) WithReloadID(reloadID string) *DeleteHTTPErrorRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http error rule backend accepted response +func (o *DeleteHTTPErrorRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPErrorRuleBackendNoContentCode is the HTTP code returned for type DeleteHTTPErrorRuleBackendNoContent +const DeleteHTTPErrorRuleBackendNoContentCode int = 204 + +/* +DeleteHTTPErrorRuleBackendNoContent HTTP Error Rule deleted + +swagger:response deleteHttpErrorRuleBackendNoContent +*/ +type DeleteHTTPErrorRuleBackendNoContent struct { +} + +// NewDeleteHTTPErrorRuleBackendNoContent creates DeleteHTTPErrorRuleBackendNoContent with default headers values +func NewDeleteHTTPErrorRuleBackendNoContent() *DeleteHTTPErrorRuleBackendNoContent { + + return &DeleteHTTPErrorRuleBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPErrorRuleBackendNotFoundCode is the HTTP code returned for type DeleteHTTPErrorRuleBackendNotFound +const DeleteHTTPErrorRuleBackendNotFoundCode int = 404 + +/* +DeleteHTTPErrorRuleBackendNotFound The specified resource was not found + +swagger:response deleteHttpErrorRuleBackendNotFound +*/ +type DeleteHTTPErrorRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorRuleBackendNotFound creates DeleteHTTPErrorRuleBackendNotFound with default headers values +func NewDeleteHTTPErrorRuleBackendNotFound() *DeleteHTTPErrorRuleBackendNotFound { + + return &DeleteHTTPErrorRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http error rule backend not found response +func (o *DeleteHTTPErrorRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http error rule backend not found response +func (o *DeleteHTTPErrorRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http error rule backend not found response +func (o *DeleteHTTPErrorRuleBackendNotFound) WithPayload(payload *models.Error) *DeleteHTTPErrorRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http error rule backend not found response +func (o *DeleteHTTPErrorRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPErrorRuleBackendDefault General Error + +swagger:response deleteHttpErrorRuleBackendDefault +*/ +type DeleteHTTPErrorRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorRuleBackendDefault creates DeleteHTTPErrorRuleBackendDefault with default headers values +func NewDeleteHTTPErrorRuleBackendDefault(code int) *DeleteHTTPErrorRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPErrorRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP error rule backend default response +func (o *DeleteHTTPErrorRuleBackendDefault) WithStatusCode(code int) *DeleteHTTPErrorRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP error rule backend default response +func (o *DeleteHTTPErrorRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP error rule backend default response +func (o *DeleteHTTPErrorRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP error rule backend default response +func (o *DeleteHTTPErrorRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP error rule backend default response +func (o *DeleteHTTPErrorRuleBackendDefault) WithPayload(payload *models.Error) *DeleteHTTPErrorRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP error rule backend default response +func (o *DeleteHTTPErrorRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/delete_http_error_rule_backend_urlbuilder.go b/operations/http_error_rule/delete_http_error_rule_backend_urlbuilder.go new file mode 100644 index 00000000..9caf1e60 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPErrorRuleBackendURL generates an URL for the delete HTTP error rule backend operation +type DeleteHTTPErrorRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorRuleBackendURL) WithBasePath(bp string) *DeleteHTTPErrorRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPErrorRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPErrorRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPErrorRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPErrorRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPErrorRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPErrorRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPErrorRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPErrorRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPErrorRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/delete_http_error_rule_defaults.go b/operations/http_error_rule/delete_http_error_rule_defaults.go new file mode 100644 index 00000000..d423efe4 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPErrorRuleDefaultsHandlerFunc turns a function with the right signature into a delete HTTP error rule defaults handler +type DeleteHTTPErrorRuleDefaultsHandlerFunc func(DeleteHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPErrorRuleDefaultsHandlerFunc) Handle(params DeleteHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPErrorRuleDefaultsHandler interface for that can handle valid delete HTTP error rule defaults params +type DeleteHTTPErrorRuleDefaultsHandler interface { + Handle(DeleteHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPErrorRuleDefaults creates a new http.Handler for the delete HTTP error rule defaults operation +func NewDeleteHTTPErrorRuleDefaults(ctx *middleware.Context, handler DeleteHTTPErrorRuleDefaultsHandler) *DeleteHTTPErrorRuleDefaults { + return &DeleteHTTPErrorRuleDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPErrorRuleDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index} HTTPErrorRule deleteHttpErrorRuleDefaults + +# Delete a HTTP Error Rule + +Deletes a HTTP Error Rule configuration by its index from the specified parent. +*/ +type DeleteHTTPErrorRuleDefaults struct { + Context *middleware.Context + Handler DeleteHTTPErrorRuleDefaultsHandler +} + +func (o *DeleteHTTPErrorRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPErrorRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/delete_http_error_rule_defaults_parameters.go b/operations/http_error_rule/delete_http_error_rule_defaults_parameters.go new file mode 100644 index 00000000..93dd1b48 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPErrorRuleDefaultsParams creates a new DeleteHTTPErrorRuleDefaultsParams object +// with the default values initialized. +func NewDeleteHTTPErrorRuleDefaultsParams() DeleteHTTPErrorRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPErrorRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPErrorRuleDefaultsParams contains all the bound params for the delete HTTP error rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPErrorRuleDefaults +type DeleteHTTPErrorRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPErrorRuleDefaultsParams() beforehand. +func (o *DeleteHTTPErrorRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPErrorRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPErrorRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPErrorRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPErrorRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPErrorRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPErrorRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/delete_http_error_rule_defaults_responses.go b/operations/http_error_rule/delete_http_error_rule_defaults_responses.go new file mode 100644 index 00000000..e8fce5ff --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPErrorRuleDefaultsAcceptedCode is the HTTP code returned for type DeleteHTTPErrorRuleDefaultsAccepted +const DeleteHTTPErrorRuleDefaultsAcceptedCode int = 202 + +/* +DeleteHTTPErrorRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpErrorRuleDefaultsAccepted +*/ +type DeleteHTTPErrorRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPErrorRuleDefaultsAccepted creates DeleteHTTPErrorRuleDefaultsAccepted with default headers values +func NewDeleteHTTPErrorRuleDefaultsAccepted() *DeleteHTTPErrorRuleDefaultsAccepted { + + return &DeleteHTTPErrorRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http error rule defaults accepted response +func (o *DeleteHTTPErrorRuleDefaultsAccepted) WithReloadID(reloadID string) *DeleteHTTPErrorRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http error rule defaults accepted response +func (o *DeleteHTTPErrorRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPErrorRuleDefaultsNoContentCode is the HTTP code returned for type DeleteHTTPErrorRuleDefaultsNoContent +const DeleteHTTPErrorRuleDefaultsNoContentCode int = 204 + +/* +DeleteHTTPErrorRuleDefaultsNoContent HTTP Error Rule deleted + +swagger:response deleteHttpErrorRuleDefaultsNoContent +*/ +type DeleteHTTPErrorRuleDefaultsNoContent struct { +} + +// NewDeleteHTTPErrorRuleDefaultsNoContent creates DeleteHTTPErrorRuleDefaultsNoContent with default headers values +func NewDeleteHTTPErrorRuleDefaultsNoContent() *DeleteHTTPErrorRuleDefaultsNoContent { + + return &DeleteHTTPErrorRuleDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPErrorRuleDefaultsNotFoundCode is the HTTP code returned for type DeleteHTTPErrorRuleDefaultsNotFound +const DeleteHTTPErrorRuleDefaultsNotFoundCode int = 404 + +/* +DeleteHTTPErrorRuleDefaultsNotFound The specified resource was not found + +swagger:response deleteHttpErrorRuleDefaultsNotFound +*/ +type DeleteHTTPErrorRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorRuleDefaultsNotFound creates DeleteHTTPErrorRuleDefaultsNotFound with default headers values +func NewDeleteHTTPErrorRuleDefaultsNotFound() *DeleteHTTPErrorRuleDefaultsNotFound { + + return &DeleteHTTPErrorRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http error rule defaults not found response +func (o *DeleteHTTPErrorRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http error rule defaults not found response +func (o *DeleteHTTPErrorRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http error rule defaults not found response +func (o *DeleteHTTPErrorRuleDefaultsNotFound) WithPayload(payload *models.Error) *DeleteHTTPErrorRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http error rule defaults not found response +func (o *DeleteHTTPErrorRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPErrorRuleDefaultsDefault General Error + +swagger:response deleteHttpErrorRuleDefaultsDefault +*/ +type DeleteHTTPErrorRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorRuleDefaultsDefault creates DeleteHTTPErrorRuleDefaultsDefault with default headers values +func NewDeleteHTTPErrorRuleDefaultsDefault(code int) *DeleteHTTPErrorRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPErrorRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP error rule defaults default response +func (o *DeleteHTTPErrorRuleDefaultsDefault) WithStatusCode(code int) *DeleteHTTPErrorRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP error rule defaults default response +func (o *DeleteHTTPErrorRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP error rule defaults default response +func (o *DeleteHTTPErrorRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP error rule defaults default response +func (o *DeleteHTTPErrorRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP error rule defaults default response +func (o *DeleteHTTPErrorRuleDefaultsDefault) WithPayload(payload *models.Error) *DeleteHTTPErrorRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP error rule defaults default response +func (o *DeleteHTTPErrorRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/delete_http_error_rule_defaults_urlbuilder.go b/operations/http_error_rule/delete_http_error_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..a6550389 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPErrorRuleDefaultsURL generates an URL for the delete HTTP error rule defaults operation +type DeleteHTTPErrorRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorRuleDefaultsURL) WithBasePath(bp string) *DeleteHTTPErrorRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPErrorRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPErrorRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPErrorRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPErrorRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPErrorRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPErrorRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPErrorRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPErrorRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPErrorRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/delete_http_error_rule_frontend.go b/operations/http_error_rule/delete_http_error_rule_frontend.go new file mode 100644 index 00000000..18de76d7 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPErrorRuleFrontendHandlerFunc turns a function with the right signature into a delete HTTP error rule frontend handler +type DeleteHTTPErrorRuleFrontendHandlerFunc func(DeleteHTTPErrorRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPErrorRuleFrontendHandlerFunc) Handle(params DeleteHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPErrorRuleFrontendHandler interface for that can handle valid delete HTTP error rule frontend params +type DeleteHTTPErrorRuleFrontendHandler interface { + Handle(DeleteHTTPErrorRuleFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPErrorRuleFrontend creates a new http.Handler for the delete HTTP error rule frontend operation +func NewDeleteHTTPErrorRuleFrontend(ctx *middleware.Context, handler DeleteHTTPErrorRuleFrontendHandler) *DeleteHTTPErrorRuleFrontend { + return &DeleteHTTPErrorRuleFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPErrorRuleFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index} HTTPErrorRule deleteHttpErrorRuleFrontend + +# Delete a HTTP Error Rule + +Deletes a HTTP Error Rule configuration by its index from the specified parent. +*/ +type DeleteHTTPErrorRuleFrontend struct { + Context *middleware.Context + Handler DeleteHTTPErrorRuleFrontendHandler +} + +func (o *DeleteHTTPErrorRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPErrorRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/delete_http_error_rule_frontend_parameters.go b/operations/http_error_rule/delete_http_error_rule_frontend_parameters.go new file mode 100644 index 00000000..091a494e --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPErrorRuleFrontendParams creates a new DeleteHTTPErrorRuleFrontendParams object +// with the default values initialized. +func NewDeleteHTTPErrorRuleFrontendParams() DeleteHTTPErrorRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPErrorRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPErrorRuleFrontendParams contains all the bound params for the delete HTTP error rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPErrorRuleFrontend +type DeleteHTTPErrorRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPErrorRuleFrontendParams() beforehand. +func (o *DeleteHTTPErrorRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPErrorRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPErrorRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPErrorRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPErrorRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPErrorRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPErrorRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/delete_http_error_rule_frontend_responses.go b/operations/http_error_rule/delete_http_error_rule_frontend_responses.go new file mode 100644 index 00000000..b1961794 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPErrorRuleFrontendAcceptedCode is the HTTP code returned for type DeleteHTTPErrorRuleFrontendAccepted +const DeleteHTTPErrorRuleFrontendAcceptedCode int = 202 + +/* +DeleteHTTPErrorRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpErrorRuleFrontendAccepted +*/ +type DeleteHTTPErrorRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPErrorRuleFrontendAccepted creates DeleteHTTPErrorRuleFrontendAccepted with default headers values +func NewDeleteHTTPErrorRuleFrontendAccepted() *DeleteHTTPErrorRuleFrontendAccepted { + + return &DeleteHTTPErrorRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http error rule frontend accepted response +func (o *DeleteHTTPErrorRuleFrontendAccepted) WithReloadID(reloadID string) *DeleteHTTPErrorRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http error rule frontend accepted response +func (o *DeleteHTTPErrorRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPErrorRuleFrontendNoContentCode is the HTTP code returned for type DeleteHTTPErrorRuleFrontendNoContent +const DeleteHTTPErrorRuleFrontendNoContentCode int = 204 + +/* +DeleteHTTPErrorRuleFrontendNoContent HTTP Error Rule deleted + +swagger:response deleteHttpErrorRuleFrontendNoContent +*/ +type DeleteHTTPErrorRuleFrontendNoContent struct { +} + +// NewDeleteHTTPErrorRuleFrontendNoContent creates DeleteHTTPErrorRuleFrontendNoContent with default headers values +func NewDeleteHTTPErrorRuleFrontendNoContent() *DeleteHTTPErrorRuleFrontendNoContent { + + return &DeleteHTTPErrorRuleFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPErrorRuleFrontendNotFoundCode is the HTTP code returned for type DeleteHTTPErrorRuleFrontendNotFound +const DeleteHTTPErrorRuleFrontendNotFoundCode int = 404 + +/* +DeleteHTTPErrorRuleFrontendNotFound The specified resource was not found + +swagger:response deleteHttpErrorRuleFrontendNotFound +*/ +type DeleteHTTPErrorRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorRuleFrontendNotFound creates DeleteHTTPErrorRuleFrontendNotFound with default headers values +func NewDeleteHTTPErrorRuleFrontendNotFound() *DeleteHTTPErrorRuleFrontendNotFound { + + return &DeleteHTTPErrorRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http error rule frontend not found response +func (o *DeleteHTTPErrorRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http error rule frontend not found response +func (o *DeleteHTTPErrorRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http error rule frontend not found response +func (o *DeleteHTTPErrorRuleFrontendNotFound) WithPayload(payload *models.Error) *DeleteHTTPErrorRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http error rule frontend not found response +func (o *DeleteHTTPErrorRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPErrorRuleFrontendDefault General Error + +swagger:response deleteHttpErrorRuleFrontendDefault +*/ +type DeleteHTTPErrorRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorRuleFrontendDefault creates DeleteHTTPErrorRuleFrontendDefault with default headers values +func NewDeleteHTTPErrorRuleFrontendDefault(code int) *DeleteHTTPErrorRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPErrorRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP error rule frontend default response +func (o *DeleteHTTPErrorRuleFrontendDefault) WithStatusCode(code int) *DeleteHTTPErrorRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP error rule frontend default response +func (o *DeleteHTTPErrorRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP error rule frontend default response +func (o *DeleteHTTPErrorRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP error rule frontend default response +func (o *DeleteHTTPErrorRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP error rule frontend default response +func (o *DeleteHTTPErrorRuleFrontendDefault) WithPayload(payload *models.Error) *DeleteHTTPErrorRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP error rule frontend default response +func (o *DeleteHTTPErrorRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/delete_http_error_rule_frontend_urlbuilder.go b/operations/http_error_rule/delete_http_error_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..e28eb514 --- /dev/null +++ b/operations/http_error_rule/delete_http_error_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPErrorRuleFrontendURL generates an URL for the delete HTTP error rule frontend operation +type DeleteHTTPErrorRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorRuleFrontendURL) WithBasePath(bp string) *DeleteHTTPErrorRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPErrorRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPErrorRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPErrorRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPErrorRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPErrorRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPErrorRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPErrorRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPErrorRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPErrorRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/get_all_http_error_rule_backend.go b/operations/http_error_rule/get_all_http_error_rule_backend.go new file mode 100644 index 00000000..e285389b --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPErrorRuleBackendHandlerFunc turns a function with the right signature into a get all HTTP error rule backend handler +type GetAllHTTPErrorRuleBackendHandlerFunc func(GetAllHTTPErrorRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPErrorRuleBackendHandlerFunc) Handle(params GetAllHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPErrorRuleBackendHandler interface for that can handle valid get all HTTP error rule backend params +type GetAllHTTPErrorRuleBackendHandler interface { + Handle(GetAllHTTPErrorRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPErrorRuleBackend creates a new http.Handler for the get all HTTP error rule backend operation +func NewGetAllHTTPErrorRuleBackend(ctx *middleware.Context, handler GetAllHTTPErrorRuleBackendHandler) *GetAllHTTPErrorRuleBackend { + return &GetAllHTTPErrorRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPErrorRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_error_rules HTTPErrorRule getAllHttpErrorRuleBackend + +# Return an array of all HTTP Error Rules + +Returns all HTTP Error Rules that are configured in the specified parent. +*/ +type GetAllHTTPErrorRuleBackend struct { + Context *middleware.Context + Handler GetAllHTTPErrorRuleBackendHandler +} + +func (o *GetAllHTTPErrorRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPErrorRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/get_all_http_error_rule_backend_parameters.go b/operations/http_error_rule/get_all_http_error_rule_backend_parameters.go new file mode 100644 index 00000000..d035242d --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPErrorRuleBackendParams creates a new GetAllHTTPErrorRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPErrorRuleBackendParams() GetAllHTTPErrorRuleBackendParams { + + return GetAllHTTPErrorRuleBackendParams{} +} + +// GetAllHTTPErrorRuleBackendParams contains all the bound params for the get all HTTP error rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPErrorRuleBackend +type GetAllHTTPErrorRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPErrorRuleBackendParams() beforehand. +func (o *GetAllHTTPErrorRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPErrorRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPErrorRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_error_rule/get_all_http_error_rule_backend_responses.go b/operations/http_error_rule/get_all_http_error_rule_backend_responses.go new file mode 100644 index 00000000..5c54e7fd --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPErrorRuleBackendOKCode is the HTTP code returned for type GetAllHTTPErrorRuleBackendOK +const GetAllHTTPErrorRuleBackendOKCode int = 200 + +/* +GetAllHTTPErrorRuleBackendOK Successful operation + +swagger:response getAllHttpErrorRuleBackendOK +*/ +type GetAllHTTPErrorRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewGetAllHTTPErrorRuleBackendOK creates GetAllHTTPErrorRuleBackendOK with default headers values +func NewGetAllHTTPErrorRuleBackendOK() *GetAllHTTPErrorRuleBackendOK { + + return &GetAllHTTPErrorRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http error rule backend o k response +func (o *GetAllHTTPErrorRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPErrorRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http error rule backend o k response +func (o *GetAllHTTPErrorRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http error rule backend o k response +func (o *GetAllHTTPErrorRuleBackendOK) WithPayload(payload models.HTTPErrorRules) *GetAllHTTPErrorRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http error rule backend o k response +func (o *GetAllHTTPErrorRuleBackendOK) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPErrorRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPErrorRuleBackendDefault General Error + +swagger:response getAllHttpErrorRuleBackendDefault +*/ +type GetAllHTTPErrorRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPErrorRuleBackendDefault creates GetAllHTTPErrorRuleBackendDefault with default headers values +func NewGetAllHTTPErrorRuleBackendDefault(code int) *GetAllHTTPErrorRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPErrorRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP error rule backend default response +func (o *GetAllHTTPErrorRuleBackendDefault) WithStatusCode(code int) *GetAllHTTPErrorRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP error rule backend default response +func (o *GetAllHTTPErrorRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP error rule backend default response +func (o *GetAllHTTPErrorRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPErrorRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP error rule backend default response +func (o *GetAllHTTPErrorRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP error rule backend default response +func (o *GetAllHTTPErrorRuleBackendDefault) WithPayload(payload *models.Error) *GetAllHTTPErrorRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP error rule backend default response +func (o *GetAllHTTPErrorRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPErrorRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/get_all_http_error_rule_backend_urlbuilder.go b/operations/http_error_rule/get_all_http_error_rule_backend_urlbuilder.go new file mode 100644 index 00000000..9e33716b --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPErrorRuleBackendURL generates an URL for the get all HTTP error rule backend operation +type GetAllHTTPErrorRuleBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPErrorRuleBackendURL) WithBasePath(bp string) *GetAllHTTPErrorRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPErrorRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPErrorRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_error_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPErrorRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPErrorRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPErrorRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPErrorRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPErrorRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPErrorRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPErrorRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/get_all_http_error_rule_defaults.go b/operations/http_error_rule/get_all_http_error_rule_defaults.go new file mode 100644 index 00000000..66c0e4dc --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPErrorRuleDefaultsHandlerFunc turns a function with the right signature into a get all HTTP error rule defaults handler +type GetAllHTTPErrorRuleDefaultsHandlerFunc func(GetAllHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPErrorRuleDefaultsHandlerFunc) Handle(params GetAllHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPErrorRuleDefaultsHandler interface for that can handle valid get all HTTP error rule defaults params +type GetAllHTTPErrorRuleDefaultsHandler interface { + Handle(GetAllHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPErrorRuleDefaults creates a new http.Handler for the get all HTTP error rule defaults operation +func NewGetAllHTTPErrorRuleDefaults(ctx *middleware.Context, handler GetAllHTTPErrorRuleDefaultsHandler) *GetAllHTTPErrorRuleDefaults { + return &GetAllHTTPErrorRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPErrorRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_error_rules HTTPErrorRule getAllHttpErrorRuleDefaults + +# Return an array of all HTTP Error Rules + +Returns all HTTP Error Rules that are configured in the specified parent. +*/ +type GetAllHTTPErrorRuleDefaults struct { + Context *middleware.Context + Handler GetAllHTTPErrorRuleDefaultsHandler +} + +func (o *GetAllHTTPErrorRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPErrorRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/get_all_http_error_rule_defaults_parameters.go b/operations/http_error_rule/get_all_http_error_rule_defaults_parameters.go new file mode 100644 index 00000000..0fef73aa --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPErrorRuleDefaultsParams creates a new GetAllHTTPErrorRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPErrorRuleDefaultsParams() GetAllHTTPErrorRuleDefaultsParams { + + return GetAllHTTPErrorRuleDefaultsParams{} +} + +// GetAllHTTPErrorRuleDefaultsParams contains all the bound params for the get all HTTP error rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPErrorRuleDefaults +type GetAllHTTPErrorRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPErrorRuleDefaultsParams() beforehand. +func (o *GetAllHTTPErrorRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPErrorRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPErrorRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_error_rule/get_all_http_error_rule_defaults_responses.go b/operations/http_error_rule/get_all_http_error_rule_defaults_responses.go new file mode 100644 index 00000000..9b3fb21b --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPErrorRuleDefaultsOKCode is the HTTP code returned for type GetAllHTTPErrorRuleDefaultsOK +const GetAllHTTPErrorRuleDefaultsOKCode int = 200 + +/* +GetAllHTTPErrorRuleDefaultsOK Successful operation + +swagger:response getAllHttpErrorRuleDefaultsOK +*/ +type GetAllHTTPErrorRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewGetAllHTTPErrorRuleDefaultsOK creates GetAllHTTPErrorRuleDefaultsOK with default headers values +func NewGetAllHTTPErrorRuleDefaultsOK() *GetAllHTTPErrorRuleDefaultsOK { + + return &GetAllHTTPErrorRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http error rule defaults o k response +func (o *GetAllHTTPErrorRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPErrorRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http error rule defaults o k response +func (o *GetAllHTTPErrorRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http error rule defaults o k response +func (o *GetAllHTTPErrorRuleDefaultsOK) WithPayload(payload models.HTTPErrorRules) *GetAllHTTPErrorRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http error rule defaults o k response +func (o *GetAllHTTPErrorRuleDefaultsOK) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPErrorRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPErrorRuleDefaultsDefault General Error + +swagger:response getAllHttpErrorRuleDefaultsDefault +*/ +type GetAllHTTPErrorRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPErrorRuleDefaultsDefault creates GetAllHTTPErrorRuleDefaultsDefault with default headers values +func NewGetAllHTTPErrorRuleDefaultsDefault(code int) *GetAllHTTPErrorRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPErrorRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP error rule defaults default response +func (o *GetAllHTTPErrorRuleDefaultsDefault) WithStatusCode(code int) *GetAllHTTPErrorRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP error rule defaults default response +func (o *GetAllHTTPErrorRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP error rule defaults default response +func (o *GetAllHTTPErrorRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPErrorRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP error rule defaults default response +func (o *GetAllHTTPErrorRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP error rule defaults default response +func (o *GetAllHTTPErrorRuleDefaultsDefault) WithPayload(payload *models.Error) *GetAllHTTPErrorRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP error rule defaults default response +func (o *GetAllHTTPErrorRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPErrorRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/get_all_http_error_rule_defaults_urlbuilder.go b/operations/http_error_rule/get_all_http_error_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..ee731257 --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPErrorRuleDefaultsURL generates an URL for the get all HTTP error rule defaults operation +type GetAllHTTPErrorRuleDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPErrorRuleDefaultsURL) WithBasePath(bp string) *GetAllHTTPErrorRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPErrorRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPErrorRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPErrorRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPErrorRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPErrorRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPErrorRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPErrorRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPErrorRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPErrorRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/get_all_http_error_rule_frontend.go b/operations/http_error_rule/get_all_http_error_rule_frontend.go new file mode 100644 index 00000000..71a7fa5c --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPErrorRuleFrontendHandlerFunc turns a function with the right signature into a get all HTTP error rule frontend handler +type GetAllHTTPErrorRuleFrontendHandlerFunc func(GetAllHTTPErrorRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPErrorRuleFrontendHandlerFunc) Handle(params GetAllHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPErrorRuleFrontendHandler interface for that can handle valid get all HTTP error rule frontend params +type GetAllHTTPErrorRuleFrontendHandler interface { + Handle(GetAllHTTPErrorRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPErrorRuleFrontend creates a new http.Handler for the get all HTTP error rule frontend operation +func NewGetAllHTTPErrorRuleFrontend(ctx *middleware.Context, handler GetAllHTTPErrorRuleFrontendHandler) *GetAllHTTPErrorRuleFrontend { + return &GetAllHTTPErrorRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPErrorRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_error_rules HTTPErrorRule getAllHttpErrorRuleFrontend + +# Return an array of all HTTP Error Rules + +Returns all HTTP Error Rules that are configured in the specified parent. +*/ +type GetAllHTTPErrorRuleFrontend struct { + Context *middleware.Context + Handler GetAllHTTPErrorRuleFrontendHandler +} + +func (o *GetAllHTTPErrorRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPErrorRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/get_all_http_error_rule_frontend_parameters.go b/operations/http_error_rule/get_all_http_error_rule_frontend_parameters.go new file mode 100644 index 00000000..1ad477c3 --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPErrorRuleFrontendParams creates a new GetAllHTTPErrorRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPErrorRuleFrontendParams() GetAllHTTPErrorRuleFrontendParams { + + return GetAllHTTPErrorRuleFrontendParams{} +} + +// GetAllHTTPErrorRuleFrontendParams contains all the bound params for the get all HTTP error rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPErrorRuleFrontend +type GetAllHTTPErrorRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPErrorRuleFrontendParams() beforehand. +func (o *GetAllHTTPErrorRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPErrorRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPErrorRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_error_rule/get_all_http_error_rule_frontend_responses.go b/operations/http_error_rule/get_all_http_error_rule_frontend_responses.go new file mode 100644 index 00000000..035d4205 --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPErrorRuleFrontendOKCode is the HTTP code returned for type GetAllHTTPErrorRuleFrontendOK +const GetAllHTTPErrorRuleFrontendOKCode int = 200 + +/* +GetAllHTTPErrorRuleFrontendOK Successful operation + +swagger:response getAllHttpErrorRuleFrontendOK +*/ +type GetAllHTTPErrorRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewGetAllHTTPErrorRuleFrontendOK creates GetAllHTTPErrorRuleFrontendOK with default headers values +func NewGetAllHTTPErrorRuleFrontendOK() *GetAllHTTPErrorRuleFrontendOK { + + return &GetAllHTTPErrorRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http error rule frontend o k response +func (o *GetAllHTTPErrorRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPErrorRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http error rule frontend o k response +func (o *GetAllHTTPErrorRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http error rule frontend o k response +func (o *GetAllHTTPErrorRuleFrontendOK) WithPayload(payload models.HTTPErrorRules) *GetAllHTTPErrorRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http error rule frontend o k response +func (o *GetAllHTTPErrorRuleFrontendOK) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPErrorRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPErrorRuleFrontendDefault General Error + +swagger:response getAllHttpErrorRuleFrontendDefault +*/ +type GetAllHTTPErrorRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPErrorRuleFrontendDefault creates GetAllHTTPErrorRuleFrontendDefault with default headers values +func NewGetAllHTTPErrorRuleFrontendDefault(code int) *GetAllHTTPErrorRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPErrorRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP error rule frontend default response +func (o *GetAllHTTPErrorRuleFrontendDefault) WithStatusCode(code int) *GetAllHTTPErrorRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP error rule frontend default response +func (o *GetAllHTTPErrorRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP error rule frontend default response +func (o *GetAllHTTPErrorRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPErrorRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP error rule frontend default response +func (o *GetAllHTTPErrorRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP error rule frontend default response +func (o *GetAllHTTPErrorRuleFrontendDefault) WithPayload(payload *models.Error) *GetAllHTTPErrorRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP error rule frontend default response +func (o *GetAllHTTPErrorRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPErrorRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/get_all_http_error_rule_frontend_urlbuilder.go b/operations/http_error_rule/get_all_http_error_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..78dfc902 --- /dev/null +++ b/operations/http_error_rule/get_all_http_error_rule_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPErrorRuleFrontendURL generates an URL for the get all HTTP error rule frontend operation +type GetAllHTTPErrorRuleFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPErrorRuleFrontendURL) WithBasePath(bp string) *GetAllHTTPErrorRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPErrorRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPErrorRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPErrorRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPErrorRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPErrorRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPErrorRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPErrorRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPErrorRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPErrorRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/get_http_error_rule_backend.go b/operations/http_error_rule/get_http_error_rule_backend.go new file mode 100644 index 00000000..10010c6f --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPErrorRuleBackendHandlerFunc turns a function with the right signature into a get HTTP error rule backend handler +type GetHTTPErrorRuleBackendHandlerFunc func(GetHTTPErrorRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPErrorRuleBackendHandlerFunc) Handle(params GetHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPErrorRuleBackendHandler interface for that can handle valid get HTTP error rule backend params +type GetHTTPErrorRuleBackendHandler interface { + Handle(GetHTTPErrorRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetHTTPErrorRuleBackend creates a new http.Handler for the get HTTP error rule backend operation +func NewGetHTTPErrorRuleBackend(ctx *middleware.Context, handler GetHTTPErrorRuleBackendHandler) *GetHTTPErrorRuleBackend { + return &GetHTTPErrorRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetHTTPErrorRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index} HTTPErrorRule getHttpErrorRuleBackend + +# Return one HTTP Error Rule + +Returns one HTTP Error Rule configuration by its index in the specified parent. +*/ +type GetHTTPErrorRuleBackend struct { + Context *middleware.Context + Handler GetHTTPErrorRuleBackendHandler +} + +func (o *GetHTTPErrorRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPErrorRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/get_http_error_rule_backend_parameters.go b/operations/http_error_rule/get_http_error_rule_backend_parameters.go new file mode 100644 index 00000000..e98e511c --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPErrorRuleBackendParams creates a new GetHTTPErrorRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPErrorRuleBackendParams() GetHTTPErrorRuleBackendParams { + + return GetHTTPErrorRuleBackendParams{} +} + +// GetHTTPErrorRuleBackendParams contains all the bound params for the get HTTP error rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPErrorRuleBackend +type GetHTTPErrorRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPErrorRuleBackendParams() beforehand. +func (o *GetHTTPErrorRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPErrorRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPErrorRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPErrorRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_error_rule/get_http_error_rule_backend_responses.go b/operations/http_error_rule/get_http_error_rule_backend_responses.go new file mode 100644 index 00000000..602f2132 --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPErrorRuleBackendOKCode is the HTTP code returned for type GetHTTPErrorRuleBackendOK +const GetHTTPErrorRuleBackendOKCode int = 200 + +/* +GetHTTPErrorRuleBackendOK Successful operation + +swagger:response getHttpErrorRuleBackendOK +*/ +type GetHTTPErrorRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleBackendOK creates GetHTTPErrorRuleBackendOK with default headers values +func NewGetHTTPErrorRuleBackendOK() *GetHTTPErrorRuleBackendOK { + + return &GetHTTPErrorRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http error rule backend o k response +func (o *GetHTTPErrorRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http error rule backend o k response +func (o *GetHTTPErrorRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http error rule backend o k response +func (o *GetHTTPErrorRuleBackendOK) WithPayload(payload *models.HTTPErrorRule) *GetHTTPErrorRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http error rule backend o k response +func (o *GetHTTPErrorRuleBackendOK) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPErrorRuleBackendNotFoundCode is the HTTP code returned for type GetHTTPErrorRuleBackendNotFound +const GetHTTPErrorRuleBackendNotFoundCode int = 404 + +/* +GetHTTPErrorRuleBackendNotFound The specified resource was not found + +swagger:response getHttpErrorRuleBackendNotFound +*/ +type GetHTTPErrorRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleBackendNotFound creates GetHTTPErrorRuleBackendNotFound with default headers values +func NewGetHTTPErrorRuleBackendNotFound() *GetHTTPErrorRuleBackendNotFound { + + return &GetHTTPErrorRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http error rule backend not found response +func (o *GetHTTPErrorRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http error rule backend not found response +func (o *GetHTTPErrorRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http error rule backend not found response +func (o *GetHTTPErrorRuleBackendNotFound) WithPayload(payload *models.Error) *GetHTTPErrorRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http error rule backend not found response +func (o *GetHTTPErrorRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPErrorRuleBackendDefault General Error + +swagger:response getHttpErrorRuleBackendDefault +*/ +type GetHTTPErrorRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleBackendDefault creates GetHTTPErrorRuleBackendDefault with default headers values +func NewGetHTTPErrorRuleBackendDefault(code int) *GetHTTPErrorRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPErrorRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP error rule backend default response +func (o *GetHTTPErrorRuleBackendDefault) WithStatusCode(code int) *GetHTTPErrorRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP error rule backend default response +func (o *GetHTTPErrorRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP error rule backend default response +func (o *GetHTTPErrorRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP error rule backend default response +func (o *GetHTTPErrorRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP error rule backend default response +func (o *GetHTTPErrorRuleBackendDefault) WithPayload(payload *models.Error) *GetHTTPErrorRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP error rule backend default response +func (o *GetHTTPErrorRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/get_http_error_rule_backend_urlbuilder.go b/operations/http_error_rule/get_http_error_rule_backend_urlbuilder.go new file mode 100644 index 00000000..521c2199 --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPErrorRuleBackendURL generates an URL for the get HTTP error rule backend operation +type GetHTTPErrorRuleBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorRuleBackendURL) WithBasePath(bp string) *GetHTTPErrorRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPErrorRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPErrorRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPErrorRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPErrorRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPErrorRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPErrorRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPErrorRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPErrorRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPErrorRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/get_http_error_rule_defaults.go b/operations/http_error_rule/get_http_error_rule_defaults.go new file mode 100644 index 00000000..a123c248 --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPErrorRuleDefaultsHandlerFunc turns a function with the right signature into a get HTTP error rule defaults handler +type GetHTTPErrorRuleDefaultsHandlerFunc func(GetHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPErrorRuleDefaultsHandlerFunc) Handle(params GetHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPErrorRuleDefaultsHandler interface for that can handle valid get HTTP error rule defaults params +type GetHTTPErrorRuleDefaultsHandler interface { + Handle(GetHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetHTTPErrorRuleDefaults creates a new http.Handler for the get HTTP error rule defaults operation +func NewGetHTTPErrorRuleDefaults(ctx *middleware.Context, handler GetHTTPErrorRuleDefaultsHandler) *GetHTTPErrorRuleDefaults { + return &GetHTTPErrorRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetHTTPErrorRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index} HTTPErrorRule getHttpErrorRuleDefaults + +# Return one HTTP Error Rule + +Returns one HTTP Error Rule configuration by its index in the specified parent. +*/ +type GetHTTPErrorRuleDefaults struct { + Context *middleware.Context + Handler GetHTTPErrorRuleDefaultsHandler +} + +func (o *GetHTTPErrorRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPErrorRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/get_http_error_rule_defaults_parameters.go b/operations/http_error_rule/get_http_error_rule_defaults_parameters.go new file mode 100644 index 00000000..291419a8 --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPErrorRuleDefaultsParams creates a new GetHTTPErrorRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetHTTPErrorRuleDefaultsParams() GetHTTPErrorRuleDefaultsParams { + + return GetHTTPErrorRuleDefaultsParams{} +} + +// GetHTTPErrorRuleDefaultsParams contains all the bound params for the get HTTP error rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPErrorRuleDefaults +type GetHTTPErrorRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPErrorRuleDefaultsParams() beforehand. +func (o *GetHTTPErrorRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPErrorRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPErrorRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPErrorRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_error_rule/get_http_error_rule_defaults_responses.go b/operations/http_error_rule/get_http_error_rule_defaults_responses.go new file mode 100644 index 00000000..b1ee104b --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPErrorRuleDefaultsOKCode is the HTTP code returned for type GetHTTPErrorRuleDefaultsOK +const GetHTTPErrorRuleDefaultsOKCode int = 200 + +/* +GetHTTPErrorRuleDefaultsOK Successful operation + +swagger:response getHttpErrorRuleDefaultsOK +*/ +type GetHTTPErrorRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleDefaultsOK creates GetHTTPErrorRuleDefaultsOK with default headers values +func NewGetHTTPErrorRuleDefaultsOK() *GetHTTPErrorRuleDefaultsOK { + + return &GetHTTPErrorRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http error rule defaults o k response +func (o *GetHTTPErrorRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http error rule defaults o k response +func (o *GetHTTPErrorRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http error rule defaults o k response +func (o *GetHTTPErrorRuleDefaultsOK) WithPayload(payload *models.HTTPErrorRule) *GetHTTPErrorRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http error rule defaults o k response +func (o *GetHTTPErrorRuleDefaultsOK) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPErrorRuleDefaultsNotFoundCode is the HTTP code returned for type GetHTTPErrorRuleDefaultsNotFound +const GetHTTPErrorRuleDefaultsNotFoundCode int = 404 + +/* +GetHTTPErrorRuleDefaultsNotFound The specified resource was not found + +swagger:response getHttpErrorRuleDefaultsNotFound +*/ +type GetHTTPErrorRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleDefaultsNotFound creates GetHTTPErrorRuleDefaultsNotFound with default headers values +func NewGetHTTPErrorRuleDefaultsNotFound() *GetHTTPErrorRuleDefaultsNotFound { + + return &GetHTTPErrorRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http error rule defaults not found response +func (o *GetHTTPErrorRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http error rule defaults not found response +func (o *GetHTTPErrorRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http error rule defaults not found response +func (o *GetHTTPErrorRuleDefaultsNotFound) WithPayload(payload *models.Error) *GetHTTPErrorRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http error rule defaults not found response +func (o *GetHTTPErrorRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPErrorRuleDefaultsDefault General Error + +swagger:response getHttpErrorRuleDefaultsDefault +*/ +type GetHTTPErrorRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleDefaultsDefault creates GetHTTPErrorRuleDefaultsDefault with default headers values +func NewGetHTTPErrorRuleDefaultsDefault(code int) *GetHTTPErrorRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPErrorRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP error rule defaults default response +func (o *GetHTTPErrorRuleDefaultsDefault) WithStatusCode(code int) *GetHTTPErrorRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP error rule defaults default response +func (o *GetHTTPErrorRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP error rule defaults default response +func (o *GetHTTPErrorRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP error rule defaults default response +func (o *GetHTTPErrorRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP error rule defaults default response +func (o *GetHTTPErrorRuleDefaultsDefault) WithPayload(payload *models.Error) *GetHTTPErrorRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP error rule defaults default response +func (o *GetHTTPErrorRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/get_http_error_rule_defaults_urlbuilder.go b/operations/http_error_rule/get_http_error_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..890cc04e --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPErrorRuleDefaultsURL generates an URL for the get HTTP error rule defaults operation +type GetHTTPErrorRuleDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorRuleDefaultsURL) WithBasePath(bp string) *GetHTTPErrorRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPErrorRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPErrorRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPErrorRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPErrorRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPErrorRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPErrorRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPErrorRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPErrorRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPErrorRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/get_http_error_rule_frontend.go b/operations/http_error_rule/get_http_error_rule_frontend.go new file mode 100644 index 00000000..bc2510ac --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPErrorRuleFrontendHandlerFunc turns a function with the right signature into a get HTTP error rule frontend handler +type GetHTTPErrorRuleFrontendHandlerFunc func(GetHTTPErrorRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPErrorRuleFrontendHandlerFunc) Handle(params GetHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPErrorRuleFrontendHandler interface for that can handle valid get HTTP error rule frontend params +type GetHTTPErrorRuleFrontendHandler interface { + Handle(GetHTTPErrorRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetHTTPErrorRuleFrontend creates a new http.Handler for the get HTTP error rule frontend operation +func NewGetHTTPErrorRuleFrontend(ctx *middleware.Context, handler GetHTTPErrorRuleFrontendHandler) *GetHTTPErrorRuleFrontend { + return &GetHTTPErrorRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetHTTPErrorRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index} HTTPErrorRule getHttpErrorRuleFrontend + +# Return one HTTP Error Rule + +Returns one HTTP Error Rule configuration by its index in the specified parent. +*/ +type GetHTTPErrorRuleFrontend struct { + Context *middleware.Context + Handler GetHTTPErrorRuleFrontendHandler +} + +func (o *GetHTTPErrorRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPErrorRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/get_http_error_rule_frontend_parameters.go b/operations/http_error_rule/get_http_error_rule_frontend_parameters.go new file mode 100644 index 00000000..9fff8ee0 --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPErrorRuleFrontendParams creates a new GetHTTPErrorRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPErrorRuleFrontendParams() GetHTTPErrorRuleFrontendParams { + + return GetHTTPErrorRuleFrontendParams{} +} + +// GetHTTPErrorRuleFrontendParams contains all the bound params for the get HTTP error rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPErrorRuleFrontend +type GetHTTPErrorRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPErrorRuleFrontendParams() beforehand. +func (o *GetHTTPErrorRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPErrorRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPErrorRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPErrorRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_error_rule/get_http_error_rule_frontend_responses.go b/operations/http_error_rule/get_http_error_rule_frontend_responses.go new file mode 100644 index 00000000..b3227462 --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPErrorRuleFrontendOKCode is the HTTP code returned for type GetHTTPErrorRuleFrontendOK +const GetHTTPErrorRuleFrontendOKCode int = 200 + +/* +GetHTTPErrorRuleFrontendOK Successful operation + +swagger:response getHttpErrorRuleFrontendOK +*/ +type GetHTTPErrorRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleFrontendOK creates GetHTTPErrorRuleFrontendOK with default headers values +func NewGetHTTPErrorRuleFrontendOK() *GetHTTPErrorRuleFrontendOK { + + return &GetHTTPErrorRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http error rule frontend o k response +func (o *GetHTTPErrorRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http error rule frontend o k response +func (o *GetHTTPErrorRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http error rule frontend o k response +func (o *GetHTTPErrorRuleFrontendOK) WithPayload(payload *models.HTTPErrorRule) *GetHTTPErrorRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http error rule frontend o k response +func (o *GetHTTPErrorRuleFrontendOK) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPErrorRuleFrontendNotFoundCode is the HTTP code returned for type GetHTTPErrorRuleFrontendNotFound +const GetHTTPErrorRuleFrontendNotFoundCode int = 404 + +/* +GetHTTPErrorRuleFrontendNotFound The specified resource was not found + +swagger:response getHttpErrorRuleFrontendNotFound +*/ +type GetHTTPErrorRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleFrontendNotFound creates GetHTTPErrorRuleFrontendNotFound with default headers values +func NewGetHTTPErrorRuleFrontendNotFound() *GetHTTPErrorRuleFrontendNotFound { + + return &GetHTTPErrorRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http error rule frontend not found response +func (o *GetHTTPErrorRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http error rule frontend not found response +func (o *GetHTTPErrorRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http error rule frontend not found response +func (o *GetHTTPErrorRuleFrontendNotFound) WithPayload(payload *models.Error) *GetHTTPErrorRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http error rule frontend not found response +func (o *GetHTTPErrorRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPErrorRuleFrontendDefault General Error + +swagger:response getHttpErrorRuleFrontendDefault +*/ +type GetHTTPErrorRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorRuleFrontendDefault creates GetHTTPErrorRuleFrontendDefault with default headers values +func NewGetHTTPErrorRuleFrontendDefault(code int) *GetHTTPErrorRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPErrorRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP error rule frontend default response +func (o *GetHTTPErrorRuleFrontendDefault) WithStatusCode(code int) *GetHTTPErrorRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP error rule frontend default response +func (o *GetHTTPErrorRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP error rule frontend default response +func (o *GetHTTPErrorRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP error rule frontend default response +func (o *GetHTTPErrorRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP error rule frontend default response +func (o *GetHTTPErrorRuleFrontendDefault) WithPayload(payload *models.Error) *GetHTTPErrorRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP error rule frontend default response +func (o *GetHTTPErrorRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/get_http_error_rule_frontend_urlbuilder.go b/operations/http_error_rule/get_http_error_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..c466e7f3 --- /dev/null +++ b/operations/http_error_rule/get_http_error_rule_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPErrorRuleFrontendURL generates an URL for the get HTTP error rule frontend operation +type GetHTTPErrorRuleFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorRuleFrontendURL) WithBasePath(bp string) *GetHTTPErrorRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPErrorRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPErrorRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPErrorRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPErrorRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPErrorRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPErrorRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPErrorRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPErrorRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPErrorRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_backend.go b/operations/http_error_rule/replace_all_http_error_rule_backend.go new file mode 100644 index 00000000..8fc1a354 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPErrorRuleBackendHandlerFunc turns a function with the right signature into a replace all HTTP error rule backend handler +type ReplaceAllHTTPErrorRuleBackendHandlerFunc func(ReplaceAllHTTPErrorRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPErrorRuleBackendHandlerFunc) Handle(params ReplaceAllHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPErrorRuleBackendHandler interface for that can handle valid replace all HTTP error rule backend params +type ReplaceAllHTTPErrorRuleBackendHandler interface { + Handle(ReplaceAllHTTPErrorRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPErrorRuleBackend creates a new http.Handler for the replace all HTTP error rule backend operation +func NewReplaceAllHTTPErrorRuleBackend(ctx *middleware.Context, handler ReplaceAllHTTPErrorRuleBackendHandler) *ReplaceAllHTTPErrorRuleBackend { + return &ReplaceAllHTTPErrorRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPErrorRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_error_rules HTTPErrorRule replaceAllHttpErrorRuleBackend + +# Replace an HTTP Error Rules list + +Replaces a whole list of HTTP Error Rules with the list given in parameter +*/ +type ReplaceAllHTTPErrorRuleBackend struct { + Context *middleware.Context + Handler ReplaceAllHTTPErrorRuleBackendHandler +} + +func (o *ReplaceAllHTTPErrorRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPErrorRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_backend_parameters.go b/operations/http_error_rule/replace_all_http_error_rule_backend_parameters.go new file mode 100644 index 00000000..ac8581e9 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPErrorRuleBackendParams creates a new ReplaceAllHTTPErrorRuleBackendParams object +// with the default values initialized. +func NewReplaceAllHTTPErrorRuleBackendParams() ReplaceAllHTTPErrorRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPErrorRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPErrorRuleBackendParams contains all the bound params for the replace all HTTP error rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPErrorRuleBackend +type ReplaceAllHTTPErrorRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPErrorRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPErrorRuleBackendParams() beforehand. +func (o *ReplaceAllHTTPErrorRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPErrorRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPErrorRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPErrorRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPErrorRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPErrorRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_backend_responses.go b/operations/http_error_rule/replace_all_http_error_rule_backend_responses.go new file mode 100644 index 00000000..12f84493 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPErrorRuleBackendOKCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleBackendOK +const ReplaceAllHTTPErrorRuleBackendOKCode int = 200 + +/* +ReplaceAllHTTPErrorRuleBackendOK All HTTP Error Rules lines replaced + +swagger:response replaceAllHttpErrorRuleBackendOK +*/ +type ReplaceAllHTTPErrorRuleBackendOK struct { + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleBackendOK creates ReplaceAllHTTPErrorRuleBackendOK with default headers values +func NewReplaceAllHTTPErrorRuleBackendOK() *ReplaceAllHTTPErrorRuleBackendOK { + + return &ReplaceAllHTTPErrorRuleBackendOK{} +} + +// WithPayload adds the payload to the replace all Http error rule backend o k response +func (o *ReplaceAllHTTPErrorRuleBackendOK) WithPayload(payload models.HTTPErrorRules) *ReplaceAllHTTPErrorRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule backend o k response +func (o *ReplaceAllHTTPErrorRuleBackendOK) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPErrorRuleBackendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleBackendAccepted +const ReplaceAllHTTPErrorRuleBackendAcceptedCode int = 202 + +/* +ReplaceAllHTTPErrorRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpErrorRuleBackendAccepted +*/ +type ReplaceAllHTTPErrorRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleBackendAccepted creates ReplaceAllHTTPErrorRuleBackendAccepted with default headers values +func NewReplaceAllHTTPErrorRuleBackendAccepted() *ReplaceAllHTTPErrorRuleBackendAccepted { + + return &ReplaceAllHTTPErrorRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http error rule backend accepted response +func (o *ReplaceAllHTTPErrorRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPErrorRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http error rule backend accepted response +func (o *ReplaceAllHTTPErrorRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http error rule backend accepted response +func (o *ReplaceAllHTTPErrorRuleBackendAccepted) WithPayload(payload models.HTTPErrorRules) *ReplaceAllHTTPErrorRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule backend accepted response +func (o *ReplaceAllHTTPErrorRuleBackendAccepted) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPErrorRuleBackendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleBackendBadRequest +const ReplaceAllHTTPErrorRuleBackendBadRequestCode int = 400 + +/* +ReplaceAllHTTPErrorRuleBackendBadRequest Bad request + +swagger:response replaceAllHttpErrorRuleBackendBadRequest +*/ +type ReplaceAllHTTPErrorRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleBackendBadRequest creates ReplaceAllHTTPErrorRuleBackendBadRequest with default headers values +func NewReplaceAllHTTPErrorRuleBackendBadRequest() *ReplaceAllHTTPErrorRuleBackendBadRequest { + + return &ReplaceAllHTTPErrorRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http error rule backend bad request response +func (o *ReplaceAllHTTPErrorRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPErrorRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http error rule backend bad request response +func (o *ReplaceAllHTTPErrorRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http error rule backend bad request response +func (o *ReplaceAllHTTPErrorRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPErrorRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule backend bad request response +func (o *ReplaceAllHTTPErrorRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPErrorRuleBackendDefault General Error + +swagger:response replaceAllHttpErrorRuleBackendDefault +*/ +type ReplaceAllHTTPErrorRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleBackendDefault creates ReplaceAllHTTPErrorRuleBackendDefault with default headers values +func NewReplaceAllHTTPErrorRuleBackendDefault(code int) *ReplaceAllHTTPErrorRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPErrorRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP error rule backend default response +func (o *ReplaceAllHTTPErrorRuleBackendDefault) WithStatusCode(code int) *ReplaceAllHTTPErrorRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP error rule backend default response +func (o *ReplaceAllHTTPErrorRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP error rule backend default response +func (o *ReplaceAllHTTPErrorRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPErrorRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP error rule backend default response +func (o *ReplaceAllHTTPErrorRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP error rule backend default response +func (o *ReplaceAllHTTPErrorRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPErrorRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP error rule backend default response +func (o *ReplaceAllHTTPErrorRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_backend_urlbuilder.go b/operations/http_error_rule/replace_all_http_error_rule_backend_urlbuilder.go new file mode 100644 index 00000000..a29aa22d --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPErrorRuleBackendURL generates an URL for the replace all HTTP error rule backend operation +type ReplaceAllHTTPErrorRuleBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPErrorRuleBackendURL) WithBasePath(bp string) *ReplaceAllHTTPErrorRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPErrorRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPErrorRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_error_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPErrorRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPErrorRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPErrorRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPErrorRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPErrorRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPErrorRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPErrorRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_defaults.go b/operations/http_error_rule/replace_all_http_error_rule_defaults.go new file mode 100644 index 00000000..e98d93bc --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPErrorRuleDefaultsHandlerFunc turns a function with the right signature into a replace all HTTP error rule defaults handler +type ReplaceAllHTTPErrorRuleDefaultsHandlerFunc func(ReplaceAllHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPErrorRuleDefaultsHandlerFunc) Handle(params ReplaceAllHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPErrorRuleDefaultsHandler interface for that can handle valid replace all HTTP error rule defaults params +type ReplaceAllHTTPErrorRuleDefaultsHandler interface { + Handle(ReplaceAllHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPErrorRuleDefaults creates a new http.Handler for the replace all HTTP error rule defaults operation +func NewReplaceAllHTTPErrorRuleDefaults(ctx *middleware.Context, handler ReplaceAllHTTPErrorRuleDefaultsHandler) *ReplaceAllHTTPErrorRuleDefaults { + return &ReplaceAllHTTPErrorRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPErrorRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_error_rules HTTPErrorRule replaceAllHttpErrorRuleDefaults + +# Replace an HTTP Error Rules list + +Replaces a whole list of HTTP Error Rules with the list given in parameter +*/ +type ReplaceAllHTTPErrorRuleDefaults struct { + Context *middleware.Context + Handler ReplaceAllHTTPErrorRuleDefaultsHandler +} + +func (o *ReplaceAllHTTPErrorRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPErrorRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_defaults_parameters.go b/operations/http_error_rule/replace_all_http_error_rule_defaults_parameters.go new file mode 100644 index 00000000..46e22230 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPErrorRuleDefaultsParams creates a new ReplaceAllHTTPErrorRuleDefaultsParams object +// with the default values initialized. +func NewReplaceAllHTTPErrorRuleDefaultsParams() ReplaceAllHTTPErrorRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPErrorRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPErrorRuleDefaultsParams contains all the bound params for the replace all HTTP error rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPErrorRuleDefaults +type ReplaceAllHTTPErrorRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPErrorRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPErrorRuleDefaultsParams() beforehand. +func (o *ReplaceAllHTTPErrorRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPErrorRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPErrorRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPErrorRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPErrorRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPErrorRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_defaults_responses.go b/operations/http_error_rule/replace_all_http_error_rule_defaults_responses.go new file mode 100644 index 00000000..374527b6 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPErrorRuleDefaultsOKCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleDefaultsOK +const ReplaceAllHTTPErrorRuleDefaultsOKCode int = 200 + +/* +ReplaceAllHTTPErrorRuleDefaultsOK All HTTP Error Rules lines replaced + +swagger:response replaceAllHttpErrorRuleDefaultsOK +*/ +type ReplaceAllHTTPErrorRuleDefaultsOK struct { + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleDefaultsOK creates ReplaceAllHTTPErrorRuleDefaultsOK with default headers values +func NewReplaceAllHTTPErrorRuleDefaultsOK() *ReplaceAllHTTPErrorRuleDefaultsOK { + + return &ReplaceAllHTTPErrorRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Http error rule defaults o k response +func (o *ReplaceAllHTTPErrorRuleDefaultsOK) WithPayload(payload models.HTTPErrorRules) *ReplaceAllHTTPErrorRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule defaults o k response +func (o *ReplaceAllHTTPErrorRuleDefaultsOK) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPErrorRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleDefaultsAccepted +const ReplaceAllHTTPErrorRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceAllHTTPErrorRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpErrorRuleDefaultsAccepted +*/ +type ReplaceAllHTTPErrorRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleDefaultsAccepted creates ReplaceAllHTTPErrorRuleDefaultsAccepted with default headers values +func NewReplaceAllHTTPErrorRuleDefaultsAccepted() *ReplaceAllHTTPErrorRuleDefaultsAccepted { + + return &ReplaceAllHTTPErrorRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http error rule defaults accepted response +func (o *ReplaceAllHTTPErrorRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPErrorRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http error rule defaults accepted response +func (o *ReplaceAllHTTPErrorRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http error rule defaults accepted response +func (o *ReplaceAllHTTPErrorRuleDefaultsAccepted) WithPayload(payload models.HTTPErrorRules) *ReplaceAllHTTPErrorRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule defaults accepted response +func (o *ReplaceAllHTTPErrorRuleDefaultsAccepted) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPErrorRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleDefaultsBadRequest +const ReplaceAllHTTPErrorRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceAllHTTPErrorRuleDefaultsBadRequest Bad request + +swagger:response replaceAllHttpErrorRuleDefaultsBadRequest +*/ +type ReplaceAllHTTPErrorRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleDefaultsBadRequest creates ReplaceAllHTTPErrorRuleDefaultsBadRequest with default headers values +func NewReplaceAllHTTPErrorRuleDefaultsBadRequest() *ReplaceAllHTTPErrorRuleDefaultsBadRequest { + + return &ReplaceAllHTTPErrorRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http error rule defaults bad request response +func (o *ReplaceAllHTTPErrorRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPErrorRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http error rule defaults bad request response +func (o *ReplaceAllHTTPErrorRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http error rule defaults bad request response +func (o *ReplaceAllHTTPErrorRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPErrorRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule defaults bad request response +func (o *ReplaceAllHTTPErrorRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPErrorRuleDefaultsDefault General Error + +swagger:response replaceAllHttpErrorRuleDefaultsDefault +*/ +type ReplaceAllHTTPErrorRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleDefaultsDefault creates ReplaceAllHTTPErrorRuleDefaultsDefault with default headers values +func NewReplaceAllHTTPErrorRuleDefaultsDefault(code int) *ReplaceAllHTTPErrorRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPErrorRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP error rule defaults default response +func (o *ReplaceAllHTTPErrorRuleDefaultsDefault) WithStatusCode(code int) *ReplaceAllHTTPErrorRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP error rule defaults default response +func (o *ReplaceAllHTTPErrorRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP error rule defaults default response +func (o *ReplaceAllHTTPErrorRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPErrorRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP error rule defaults default response +func (o *ReplaceAllHTTPErrorRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP error rule defaults default response +func (o *ReplaceAllHTTPErrorRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPErrorRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP error rule defaults default response +func (o *ReplaceAllHTTPErrorRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_defaults_urlbuilder.go b/operations/http_error_rule/replace_all_http_error_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..745c95c9 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPErrorRuleDefaultsURL generates an URL for the replace all HTTP error rule defaults operation +type ReplaceAllHTTPErrorRuleDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPErrorRuleDefaultsURL) WithBasePath(bp string) *ReplaceAllHTTPErrorRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPErrorRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPErrorRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPErrorRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPErrorRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPErrorRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPErrorRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPErrorRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPErrorRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPErrorRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_frontend.go b/operations/http_error_rule/replace_all_http_error_rule_frontend.go new file mode 100644 index 00000000..9cb0d328 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPErrorRuleFrontendHandlerFunc turns a function with the right signature into a replace all HTTP error rule frontend handler +type ReplaceAllHTTPErrorRuleFrontendHandlerFunc func(ReplaceAllHTTPErrorRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPErrorRuleFrontendHandlerFunc) Handle(params ReplaceAllHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPErrorRuleFrontendHandler interface for that can handle valid replace all HTTP error rule frontend params +type ReplaceAllHTTPErrorRuleFrontendHandler interface { + Handle(ReplaceAllHTTPErrorRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPErrorRuleFrontend creates a new http.Handler for the replace all HTTP error rule frontend operation +func NewReplaceAllHTTPErrorRuleFrontend(ctx *middleware.Context, handler ReplaceAllHTTPErrorRuleFrontendHandler) *ReplaceAllHTTPErrorRuleFrontend { + return &ReplaceAllHTTPErrorRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPErrorRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_error_rules HTTPErrorRule replaceAllHttpErrorRuleFrontend + +# Replace an HTTP Error Rules list + +Replaces a whole list of HTTP Error Rules with the list given in parameter +*/ +type ReplaceAllHTTPErrorRuleFrontend struct { + Context *middleware.Context + Handler ReplaceAllHTTPErrorRuleFrontendHandler +} + +func (o *ReplaceAllHTTPErrorRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPErrorRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_frontend_parameters.go b/operations/http_error_rule/replace_all_http_error_rule_frontend_parameters.go new file mode 100644 index 00000000..e31239a1 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPErrorRuleFrontendParams creates a new ReplaceAllHTTPErrorRuleFrontendParams object +// with the default values initialized. +func NewReplaceAllHTTPErrorRuleFrontendParams() ReplaceAllHTTPErrorRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPErrorRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPErrorRuleFrontendParams contains all the bound params for the replace all HTTP error rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPErrorRuleFrontend +type ReplaceAllHTTPErrorRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPErrorRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPErrorRuleFrontendParams() beforehand. +func (o *ReplaceAllHTTPErrorRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPErrorRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPErrorRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPErrorRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPErrorRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPErrorRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_frontend_responses.go b/operations/http_error_rule/replace_all_http_error_rule_frontend_responses.go new file mode 100644 index 00000000..abcfc5d2 --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPErrorRuleFrontendOKCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleFrontendOK +const ReplaceAllHTTPErrorRuleFrontendOKCode int = 200 + +/* +ReplaceAllHTTPErrorRuleFrontendOK All HTTP Error Rules lines replaced + +swagger:response replaceAllHttpErrorRuleFrontendOK +*/ +type ReplaceAllHTTPErrorRuleFrontendOK struct { + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleFrontendOK creates ReplaceAllHTTPErrorRuleFrontendOK with default headers values +func NewReplaceAllHTTPErrorRuleFrontendOK() *ReplaceAllHTTPErrorRuleFrontendOK { + + return &ReplaceAllHTTPErrorRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace all Http error rule frontend o k response +func (o *ReplaceAllHTTPErrorRuleFrontendOK) WithPayload(payload models.HTTPErrorRules) *ReplaceAllHTTPErrorRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule frontend o k response +func (o *ReplaceAllHTTPErrorRuleFrontendOK) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPErrorRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleFrontendAccepted +const ReplaceAllHTTPErrorRuleFrontendAcceptedCode int = 202 + +/* +ReplaceAllHTTPErrorRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpErrorRuleFrontendAccepted +*/ +type ReplaceAllHTTPErrorRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPErrorRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleFrontendAccepted creates ReplaceAllHTTPErrorRuleFrontendAccepted with default headers values +func NewReplaceAllHTTPErrorRuleFrontendAccepted() *ReplaceAllHTTPErrorRuleFrontendAccepted { + + return &ReplaceAllHTTPErrorRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http error rule frontend accepted response +func (o *ReplaceAllHTTPErrorRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPErrorRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http error rule frontend accepted response +func (o *ReplaceAllHTTPErrorRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http error rule frontend accepted response +func (o *ReplaceAllHTTPErrorRuleFrontendAccepted) WithPayload(payload models.HTTPErrorRules) *ReplaceAllHTTPErrorRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule frontend accepted response +func (o *ReplaceAllHTTPErrorRuleFrontendAccepted) SetPayload(payload models.HTTPErrorRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPErrorRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPErrorRuleFrontendBadRequest +const ReplaceAllHTTPErrorRuleFrontendBadRequestCode int = 400 + +/* +ReplaceAllHTTPErrorRuleFrontendBadRequest Bad request + +swagger:response replaceAllHttpErrorRuleFrontendBadRequest +*/ +type ReplaceAllHTTPErrorRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleFrontendBadRequest creates ReplaceAllHTTPErrorRuleFrontendBadRequest with default headers values +func NewReplaceAllHTTPErrorRuleFrontendBadRequest() *ReplaceAllHTTPErrorRuleFrontendBadRequest { + + return &ReplaceAllHTTPErrorRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http error rule frontend bad request response +func (o *ReplaceAllHTTPErrorRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPErrorRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http error rule frontend bad request response +func (o *ReplaceAllHTTPErrorRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http error rule frontend bad request response +func (o *ReplaceAllHTTPErrorRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPErrorRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http error rule frontend bad request response +func (o *ReplaceAllHTTPErrorRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPErrorRuleFrontendDefault General Error + +swagger:response replaceAllHttpErrorRuleFrontendDefault +*/ +type ReplaceAllHTTPErrorRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPErrorRuleFrontendDefault creates ReplaceAllHTTPErrorRuleFrontendDefault with default headers values +func NewReplaceAllHTTPErrorRuleFrontendDefault(code int) *ReplaceAllHTTPErrorRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPErrorRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP error rule frontend default response +func (o *ReplaceAllHTTPErrorRuleFrontendDefault) WithStatusCode(code int) *ReplaceAllHTTPErrorRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP error rule frontend default response +func (o *ReplaceAllHTTPErrorRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP error rule frontend default response +func (o *ReplaceAllHTTPErrorRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPErrorRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP error rule frontend default response +func (o *ReplaceAllHTTPErrorRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP error rule frontend default response +func (o *ReplaceAllHTTPErrorRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPErrorRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP error rule frontend default response +func (o *ReplaceAllHTTPErrorRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPErrorRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/replace_all_http_error_rule_frontend_urlbuilder.go b/operations/http_error_rule/replace_all_http_error_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..d8b20f9c --- /dev/null +++ b/operations/http_error_rule/replace_all_http_error_rule_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPErrorRuleFrontendURL generates an URL for the replace all HTTP error rule frontend operation +type ReplaceAllHTTPErrorRuleFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPErrorRuleFrontendURL) WithBasePath(bp string) *ReplaceAllHTTPErrorRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPErrorRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPErrorRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPErrorRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPErrorRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPErrorRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPErrorRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPErrorRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPErrorRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPErrorRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/replace_http_error_rule_backend.go b/operations/http_error_rule/replace_http_error_rule_backend.go new file mode 100644 index 00000000..d66c2de3 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPErrorRuleBackendHandlerFunc turns a function with the right signature into a replace HTTP error rule backend handler +type ReplaceHTTPErrorRuleBackendHandlerFunc func(ReplaceHTTPErrorRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPErrorRuleBackendHandlerFunc) Handle(params ReplaceHTTPErrorRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPErrorRuleBackendHandler interface for that can handle valid replace HTTP error rule backend params +type ReplaceHTTPErrorRuleBackendHandler interface { + Handle(ReplaceHTTPErrorRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPErrorRuleBackend creates a new http.Handler for the replace HTTP error rule backend operation +func NewReplaceHTTPErrorRuleBackend(ctx *middleware.Context, handler ReplaceHTTPErrorRuleBackendHandler) *ReplaceHTTPErrorRuleBackend { + return &ReplaceHTTPErrorRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPErrorRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index} HTTPErrorRule replaceHttpErrorRuleBackend + +# Replace a HTTP Error Rule + +Replaces a HTTP Error Rule configuration by its index in the specified parent. +*/ +type ReplaceHTTPErrorRuleBackend struct { + Context *middleware.Context + Handler ReplaceHTTPErrorRuleBackendHandler +} + +func (o *ReplaceHTTPErrorRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPErrorRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/replace_http_error_rule_backend_parameters.go b/operations/http_error_rule/replace_http_error_rule_backend_parameters.go new file mode 100644 index 00000000..cbb6f4f7 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPErrorRuleBackendParams creates a new ReplaceHTTPErrorRuleBackendParams object +// with the default values initialized. +func NewReplaceHTTPErrorRuleBackendParams() ReplaceHTTPErrorRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPErrorRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPErrorRuleBackendParams contains all the bound params for the replace HTTP error rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPErrorRuleBackend +type ReplaceHTTPErrorRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPErrorRuleBackendParams() beforehand. +func (o *ReplaceHTTPErrorRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPErrorRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPErrorRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPErrorRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPErrorRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPErrorRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPErrorRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/replace_http_error_rule_backend_responses.go b/operations/http_error_rule/replace_http_error_rule_backend_responses.go new file mode 100644 index 00000000..aaa7fc2f --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPErrorRuleBackendOKCode is the HTTP code returned for type ReplaceHTTPErrorRuleBackendOK +const ReplaceHTTPErrorRuleBackendOKCode int = 200 + +/* +ReplaceHTTPErrorRuleBackendOK HTTP Error Rule replaced + +swagger:response replaceHttpErrorRuleBackendOK +*/ +type ReplaceHTTPErrorRuleBackendOK struct { + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleBackendOK creates ReplaceHTTPErrorRuleBackendOK with default headers values +func NewReplaceHTTPErrorRuleBackendOK() *ReplaceHTTPErrorRuleBackendOK { + + return &ReplaceHTTPErrorRuleBackendOK{} +} + +// WithPayload adds the payload to the replace Http error rule backend o k response +func (o *ReplaceHTTPErrorRuleBackendOK) WithPayload(payload *models.HTTPErrorRule) *ReplaceHTTPErrorRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule backend o k response +func (o *ReplaceHTTPErrorRuleBackendOK) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleBackendAcceptedCode is the HTTP code returned for type ReplaceHTTPErrorRuleBackendAccepted +const ReplaceHTTPErrorRuleBackendAcceptedCode int = 202 + +/* +ReplaceHTTPErrorRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpErrorRuleBackendAccepted +*/ +type ReplaceHTTPErrorRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleBackendAccepted creates ReplaceHTTPErrorRuleBackendAccepted with default headers values +func NewReplaceHTTPErrorRuleBackendAccepted() *ReplaceHTTPErrorRuleBackendAccepted { + + return &ReplaceHTTPErrorRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http error rule backend accepted response +func (o *ReplaceHTTPErrorRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceHTTPErrorRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http error rule backend accepted response +func (o *ReplaceHTTPErrorRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http error rule backend accepted response +func (o *ReplaceHTTPErrorRuleBackendAccepted) WithPayload(payload *models.HTTPErrorRule) *ReplaceHTTPErrorRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule backend accepted response +func (o *ReplaceHTTPErrorRuleBackendAccepted) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleBackendBadRequestCode is the HTTP code returned for type ReplaceHTTPErrorRuleBackendBadRequest +const ReplaceHTTPErrorRuleBackendBadRequestCode int = 400 + +/* +ReplaceHTTPErrorRuleBackendBadRequest Bad request + +swagger:response replaceHttpErrorRuleBackendBadRequest +*/ +type ReplaceHTTPErrorRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleBackendBadRequest creates ReplaceHTTPErrorRuleBackendBadRequest with default headers values +func NewReplaceHTTPErrorRuleBackendBadRequest() *ReplaceHTTPErrorRuleBackendBadRequest { + + return &ReplaceHTTPErrorRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http error rule backend bad request response +func (o *ReplaceHTTPErrorRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http error rule backend bad request response +func (o *ReplaceHTTPErrorRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http error rule backend bad request response +func (o *ReplaceHTTPErrorRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule backend bad request response +func (o *ReplaceHTTPErrorRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleBackendNotFoundCode is the HTTP code returned for type ReplaceHTTPErrorRuleBackendNotFound +const ReplaceHTTPErrorRuleBackendNotFoundCode int = 404 + +/* +ReplaceHTTPErrorRuleBackendNotFound The specified resource was not found + +swagger:response replaceHttpErrorRuleBackendNotFound +*/ +type ReplaceHTTPErrorRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleBackendNotFound creates ReplaceHTTPErrorRuleBackendNotFound with default headers values +func NewReplaceHTTPErrorRuleBackendNotFound() *ReplaceHTTPErrorRuleBackendNotFound { + + return &ReplaceHTTPErrorRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http error rule backend not found response +func (o *ReplaceHTTPErrorRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http error rule backend not found response +func (o *ReplaceHTTPErrorRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http error rule backend not found response +func (o *ReplaceHTTPErrorRuleBackendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule backend not found response +func (o *ReplaceHTTPErrorRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPErrorRuleBackendDefault General Error + +swagger:response replaceHttpErrorRuleBackendDefault +*/ +type ReplaceHTTPErrorRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleBackendDefault creates ReplaceHTTPErrorRuleBackendDefault with default headers values +func NewReplaceHTTPErrorRuleBackendDefault(code int) *ReplaceHTTPErrorRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPErrorRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP error rule backend default response +func (o *ReplaceHTTPErrorRuleBackendDefault) WithStatusCode(code int) *ReplaceHTTPErrorRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP error rule backend default response +func (o *ReplaceHTTPErrorRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP error rule backend default response +func (o *ReplaceHTTPErrorRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP error rule backend default response +func (o *ReplaceHTTPErrorRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP error rule backend default response +func (o *ReplaceHTTPErrorRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP error rule backend default response +func (o *ReplaceHTTPErrorRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/replace_http_error_rule_backend_urlbuilder.go b/operations/http_error_rule/replace_http_error_rule_backend_urlbuilder.go new file mode 100644 index 00000000..7704dea4 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPErrorRuleBackendURL generates an URL for the replace HTTP error rule backend operation +type ReplaceHTTPErrorRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorRuleBackendURL) WithBasePath(bp string) *ReplaceHTTPErrorRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPErrorRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPErrorRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPErrorRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPErrorRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPErrorRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPErrorRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPErrorRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPErrorRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPErrorRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/replace_http_error_rule_defaults.go b/operations/http_error_rule/replace_http_error_rule_defaults.go new file mode 100644 index 00000000..c49037f2 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPErrorRuleDefaultsHandlerFunc turns a function with the right signature into a replace HTTP error rule defaults handler +type ReplaceHTTPErrorRuleDefaultsHandlerFunc func(ReplaceHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPErrorRuleDefaultsHandlerFunc) Handle(params ReplaceHTTPErrorRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPErrorRuleDefaultsHandler interface for that can handle valid replace HTTP error rule defaults params +type ReplaceHTTPErrorRuleDefaultsHandler interface { + Handle(ReplaceHTTPErrorRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPErrorRuleDefaults creates a new http.Handler for the replace HTTP error rule defaults operation +func NewReplaceHTTPErrorRuleDefaults(ctx *middleware.Context, handler ReplaceHTTPErrorRuleDefaultsHandler) *ReplaceHTTPErrorRuleDefaults { + return &ReplaceHTTPErrorRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPErrorRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index} HTTPErrorRule replaceHttpErrorRuleDefaults + +# Replace a HTTP Error Rule + +Replaces a HTTP Error Rule configuration by its index in the specified parent. +*/ +type ReplaceHTTPErrorRuleDefaults struct { + Context *middleware.Context + Handler ReplaceHTTPErrorRuleDefaultsHandler +} + +func (o *ReplaceHTTPErrorRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPErrorRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/replace_http_error_rule_defaults_parameters.go b/operations/http_error_rule/replace_http_error_rule_defaults_parameters.go new file mode 100644 index 00000000..6b883e15 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPErrorRuleDefaultsParams creates a new ReplaceHTTPErrorRuleDefaultsParams object +// with the default values initialized. +func NewReplaceHTTPErrorRuleDefaultsParams() ReplaceHTTPErrorRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPErrorRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPErrorRuleDefaultsParams contains all the bound params for the replace HTTP error rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPErrorRuleDefaults +type ReplaceHTTPErrorRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPErrorRuleDefaultsParams() beforehand. +func (o *ReplaceHTTPErrorRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPErrorRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPErrorRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPErrorRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPErrorRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPErrorRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPErrorRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/replace_http_error_rule_defaults_responses.go b/operations/http_error_rule/replace_http_error_rule_defaults_responses.go new file mode 100644 index 00000000..feaaff9e --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPErrorRuleDefaultsOKCode is the HTTP code returned for type ReplaceHTTPErrorRuleDefaultsOK +const ReplaceHTTPErrorRuleDefaultsOKCode int = 200 + +/* +ReplaceHTTPErrorRuleDefaultsOK HTTP Error Rule replaced + +swagger:response replaceHttpErrorRuleDefaultsOK +*/ +type ReplaceHTTPErrorRuleDefaultsOK struct { + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleDefaultsOK creates ReplaceHTTPErrorRuleDefaultsOK with default headers values +func NewReplaceHTTPErrorRuleDefaultsOK() *ReplaceHTTPErrorRuleDefaultsOK { + + return &ReplaceHTTPErrorRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace Http error rule defaults o k response +func (o *ReplaceHTTPErrorRuleDefaultsOK) WithPayload(payload *models.HTTPErrorRule) *ReplaceHTTPErrorRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule defaults o k response +func (o *ReplaceHTTPErrorRuleDefaultsOK) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceHTTPErrorRuleDefaultsAccepted +const ReplaceHTTPErrorRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceHTTPErrorRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpErrorRuleDefaultsAccepted +*/ +type ReplaceHTTPErrorRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleDefaultsAccepted creates ReplaceHTTPErrorRuleDefaultsAccepted with default headers values +func NewReplaceHTTPErrorRuleDefaultsAccepted() *ReplaceHTTPErrorRuleDefaultsAccepted { + + return &ReplaceHTTPErrorRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http error rule defaults accepted response +func (o *ReplaceHTTPErrorRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceHTTPErrorRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http error rule defaults accepted response +func (o *ReplaceHTTPErrorRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http error rule defaults accepted response +func (o *ReplaceHTTPErrorRuleDefaultsAccepted) WithPayload(payload *models.HTTPErrorRule) *ReplaceHTTPErrorRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule defaults accepted response +func (o *ReplaceHTTPErrorRuleDefaultsAccepted) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceHTTPErrorRuleDefaultsBadRequest +const ReplaceHTTPErrorRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceHTTPErrorRuleDefaultsBadRequest Bad request + +swagger:response replaceHttpErrorRuleDefaultsBadRequest +*/ +type ReplaceHTTPErrorRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleDefaultsBadRequest creates ReplaceHTTPErrorRuleDefaultsBadRequest with default headers values +func NewReplaceHTTPErrorRuleDefaultsBadRequest() *ReplaceHTTPErrorRuleDefaultsBadRequest { + + return &ReplaceHTTPErrorRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http error rule defaults bad request response +func (o *ReplaceHTTPErrorRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http error rule defaults bad request response +func (o *ReplaceHTTPErrorRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http error rule defaults bad request response +func (o *ReplaceHTTPErrorRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule defaults bad request response +func (o *ReplaceHTTPErrorRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleDefaultsNotFoundCode is the HTTP code returned for type ReplaceHTTPErrorRuleDefaultsNotFound +const ReplaceHTTPErrorRuleDefaultsNotFoundCode int = 404 + +/* +ReplaceHTTPErrorRuleDefaultsNotFound The specified resource was not found + +swagger:response replaceHttpErrorRuleDefaultsNotFound +*/ +type ReplaceHTTPErrorRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleDefaultsNotFound creates ReplaceHTTPErrorRuleDefaultsNotFound with default headers values +func NewReplaceHTTPErrorRuleDefaultsNotFound() *ReplaceHTTPErrorRuleDefaultsNotFound { + + return &ReplaceHTTPErrorRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http error rule defaults not found response +func (o *ReplaceHTTPErrorRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http error rule defaults not found response +func (o *ReplaceHTTPErrorRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http error rule defaults not found response +func (o *ReplaceHTTPErrorRuleDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule defaults not found response +func (o *ReplaceHTTPErrorRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPErrorRuleDefaultsDefault General Error + +swagger:response replaceHttpErrorRuleDefaultsDefault +*/ +type ReplaceHTTPErrorRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleDefaultsDefault creates ReplaceHTTPErrorRuleDefaultsDefault with default headers values +func NewReplaceHTTPErrorRuleDefaultsDefault(code int) *ReplaceHTTPErrorRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPErrorRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP error rule defaults default response +func (o *ReplaceHTTPErrorRuleDefaultsDefault) WithStatusCode(code int) *ReplaceHTTPErrorRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP error rule defaults default response +func (o *ReplaceHTTPErrorRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP error rule defaults default response +func (o *ReplaceHTTPErrorRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP error rule defaults default response +func (o *ReplaceHTTPErrorRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP error rule defaults default response +func (o *ReplaceHTTPErrorRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP error rule defaults default response +func (o *ReplaceHTTPErrorRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/replace_http_error_rule_defaults_urlbuilder.go b/operations/http_error_rule/replace_http_error_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..ce879f9f --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPErrorRuleDefaultsURL generates an URL for the replace HTTP error rule defaults operation +type ReplaceHTTPErrorRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorRuleDefaultsURL) WithBasePath(bp string) *ReplaceHTTPErrorRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPErrorRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPErrorRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPErrorRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPErrorRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPErrorRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPErrorRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPErrorRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPErrorRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPErrorRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_error_rule/replace_http_error_rule_frontend.go b/operations/http_error_rule/replace_http_error_rule_frontend.go new file mode 100644 index 00000000..440ae3fd --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPErrorRuleFrontendHandlerFunc turns a function with the right signature into a replace HTTP error rule frontend handler +type ReplaceHTTPErrorRuleFrontendHandlerFunc func(ReplaceHTTPErrorRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPErrorRuleFrontendHandlerFunc) Handle(params ReplaceHTTPErrorRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPErrorRuleFrontendHandler interface for that can handle valid replace HTTP error rule frontend params +type ReplaceHTTPErrorRuleFrontendHandler interface { + Handle(ReplaceHTTPErrorRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPErrorRuleFrontend creates a new http.Handler for the replace HTTP error rule frontend operation +func NewReplaceHTTPErrorRuleFrontend(ctx *middleware.Context, handler ReplaceHTTPErrorRuleFrontendHandler) *ReplaceHTTPErrorRuleFrontend { + return &ReplaceHTTPErrorRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPErrorRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index} HTTPErrorRule replaceHttpErrorRuleFrontend + +# Replace a HTTP Error Rule + +Replaces a HTTP Error Rule configuration by its index in the specified parent. +*/ +type ReplaceHTTPErrorRuleFrontend struct { + Context *middleware.Context + Handler ReplaceHTTPErrorRuleFrontendHandler +} + +func (o *ReplaceHTTPErrorRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPErrorRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_error_rule/replace_http_error_rule_frontend_parameters.go b/operations/http_error_rule/replace_http_error_rule_frontend_parameters.go new file mode 100644 index 00000000..2fca35e8 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPErrorRuleFrontendParams creates a new ReplaceHTTPErrorRuleFrontendParams object +// with the default values initialized. +func NewReplaceHTTPErrorRuleFrontendParams() ReplaceHTTPErrorRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPErrorRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPErrorRuleFrontendParams contains all the bound params for the replace HTTP error rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPErrorRuleFrontend +type ReplaceHTTPErrorRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Error Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPErrorRuleFrontendParams() beforehand. +func (o *ReplaceHTTPErrorRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPErrorRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPErrorRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPErrorRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPErrorRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPErrorRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPErrorRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_error_rule/replace_http_error_rule_frontend_responses.go b/operations/http_error_rule/replace_http_error_rule_frontend_responses.go new file mode 100644 index 00000000..d82a0bb2 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPErrorRuleFrontendOKCode is the HTTP code returned for type ReplaceHTTPErrorRuleFrontendOK +const ReplaceHTTPErrorRuleFrontendOKCode int = 200 + +/* +ReplaceHTTPErrorRuleFrontendOK HTTP Error Rule replaced + +swagger:response replaceHttpErrorRuleFrontendOK +*/ +type ReplaceHTTPErrorRuleFrontendOK struct { + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleFrontendOK creates ReplaceHTTPErrorRuleFrontendOK with default headers values +func NewReplaceHTTPErrorRuleFrontendOK() *ReplaceHTTPErrorRuleFrontendOK { + + return &ReplaceHTTPErrorRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace Http error rule frontend o k response +func (o *ReplaceHTTPErrorRuleFrontendOK) WithPayload(payload *models.HTTPErrorRule) *ReplaceHTTPErrorRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule frontend o k response +func (o *ReplaceHTTPErrorRuleFrontendOK) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceHTTPErrorRuleFrontendAccepted +const ReplaceHTTPErrorRuleFrontendAcceptedCode int = 202 + +/* +ReplaceHTTPErrorRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpErrorRuleFrontendAccepted +*/ +type ReplaceHTTPErrorRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorRule `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleFrontendAccepted creates ReplaceHTTPErrorRuleFrontendAccepted with default headers values +func NewReplaceHTTPErrorRuleFrontendAccepted() *ReplaceHTTPErrorRuleFrontendAccepted { + + return &ReplaceHTTPErrorRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http error rule frontend accepted response +func (o *ReplaceHTTPErrorRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceHTTPErrorRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http error rule frontend accepted response +func (o *ReplaceHTTPErrorRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http error rule frontend accepted response +func (o *ReplaceHTTPErrorRuleFrontendAccepted) WithPayload(payload *models.HTTPErrorRule) *ReplaceHTTPErrorRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule frontend accepted response +func (o *ReplaceHTTPErrorRuleFrontendAccepted) SetPayload(payload *models.HTTPErrorRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceHTTPErrorRuleFrontendBadRequest +const ReplaceHTTPErrorRuleFrontendBadRequestCode int = 400 + +/* +ReplaceHTTPErrorRuleFrontendBadRequest Bad request + +swagger:response replaceHttpErrorRuleFrontendBadRequest +*/ +type ReplaceHTTPErrorRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleFrontendBadRequest creates ReplaceHTTPErrorRuleFrontendBadRequest with default headers values +func NewReplaceHTTPErrorRuleFrontendBadRequest() *ReplaceHTTPErrorRuleFrontendBadRequest { + + return &ReplaceHTTPErrorRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http error rule frontend bad request response +func (o *ReplaceHTTPErrorRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http error rule frontend bad request response +func (o *ReplaceHTTPErrorRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http error rule frontend bad request response +func (o *ReplaceHTTPErrorRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule frontend bad request response +func (o *ReplaceHTTPErrorRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorRuleFrontendNotFoundCode is the HTTP code returned for type ReplaceHTTPErrorRuleFrontendNotFound +const ReplaceHTTPErrorRuleFrontendNotFoundCode int = 404 + +/* +ReplaceHTTPErrorRuleFrontendNotFound The specified resource was not found + +swagger:response replaceHttpErrorRuleFrontendNotFound +*/ +type ReplaceHTTPErrorRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleFrontendNotFound creates ReplaceHTTPErrorRuleFrontendNotFound with default headers values +func NewReplaceHTTPErrorRuleFrontendNotFound() *ReplaceHTTPErrorRuleFrontendNotFound { + + return &ReplaceHTTPErrorRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http error rule frontend not found response +func (o *ReplaceHTTPErrorRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http error rule frontend not found response +func (o *ReplaceHTTPErrorRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http error rule frontend not found response +func (o *ReplaceHTTPErrorRuleFrontendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http error rule frontend not found response +func (o *ReplaceHTTPErrorRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPErrorRuleFrontendDefault General Error + +swagger:response replaceHttpErrorRuleFrontendDefault +*/ +type ReplaceHTTPErrorRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorRuleFrontendDefault creates ReplaceHTTPErrorRuleFrontendDefault with default headers values +func NewReplaceHTTPErrorRuleFrontendDefault(code int) *ReplaceHTTPErrorRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPErrorRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP error rule frontend default response +func (o *ReplaceHTTPErrorRuleFrontendDefault) WithStatusCode(code int) *ReplaceHTTPErrorRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP error rule frontend default response +func (o *ReplaceHTTPErrorRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP error rule frontend default response +func (o *ReplaceHTTPErrorRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP error rule frontend default response +func (o *ReplaceHTTPErrorRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP error rule frontend default response +func (o *ReplaceHTTPErrorRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceHTTPErrorRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP error rule frontend default response +func (o *ReplaceHTTPErrorRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_error_rule/replace_http_error_rule_frontend_urlbuilder.go b/operations/http_error_rule/replace_http_error_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..2eac0515 --- /dev/null +++ b/operations/http_error_rule/replace_http_error_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_error_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPErrorRuleFrontendURL generates an URL for the replace HTTP error rule frontend operation +type ReplaceHTTPErrorRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorRuleFrontendURL) WithBasePath(bp string) *ReplaceHTTPErrorRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPErrorRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_error_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPErrorRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPErrorRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPErrorRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPErrorRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPErrorRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPErrorRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPErrorRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPErrorRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_errors/create_http_errors_section.go b/operations/http_errors/create_http_errors_section.go new file mode 100644 index 00000000..0289fc48 --- /dev/null +++ b/operations/http_errors/create_http_errors_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPErrorsSectionHandlerFunc turns a function with the right signature into a create HTTP errors section handler +type CreateHTTPErrorsSectionHandlerFunc func(CreateHTTPErrorsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPErrorsSectionHandlerFunc) Handle(params CreateHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPErrorsSectionHandler interface for that can handle valid create HTTP errors section params +type CreateHTTPErrorsSectionHandler interface { + Handle(CreateHTTPErrorsSectionParams, interface{}) middleware.Responder +} + +// NewCreateHTTPErrorsSection creates a new http.Handler for the create HTTP errors section operation +func NewCreateHTTPErrorsSection(ctx *middleware.Context, handler CreateHTTPErrorsSectionHandler) *CreateHTTPErrorsSection { + return &CreateHTTPErrorsSection{Context: ctx, Handler: handler} +} + +/* + CreateHTTPErrorsSection swagger:route POST /services/haproxy/configuration/http_errors_sections HTTPErrors createHttpErrorsSection + +# Add a new http-error section + +Adds a new http-error section to the configuration. +*/ +type CreateHTTPErrorsSection struct { + Context *middleware.Context + Handler CreateHTTPErrorsSectionHandler +} + +func (o *CreateHTTPErrorsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPErrorsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_errors/create_http_errors_section_parameters.go b/operations/http_errors/create_http_errors_section_parameters.go new file mode 100644 index 00000000..91dae721 --- /dev/null +++ b/operations/http_errors/create_http_errors_section_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPErrorsSectionParams creates a new CreateHTTPErrorsSectionParams object +// with the default values initialized. +func NewCreateHTTPErrorsSectionParams() CreateHTTPErrorsSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPErrorsSectionParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPErrorsSectionParams contains all the bound params for the create HTTP errors section operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPErrorsSection +type CreateHTTPErrorsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorsSection + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPErrorsSectionParams() beforehand. +func (o *CreateHTTPErrorsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorsSection + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPErrorsSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPErrorsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPErrorsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPErrorsSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_errors/create_http_errors_section_responses.go b/operations/http_errors/create_http_errors_section_responses.go new file mode 100644 index 00000000..1a681087 --- /dev/null +++ b/operations/http_errors/create_http_errors_section_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPErrorsSectionCreatedCode is the HTTP code returned for type CreateHTTPErrorsSectionCreated +const CreateHTTPErrorsSectionCreatedCode int = 201 + +/* +CreateHTTPErrorsSectionCreated http-error section created + +swagger:response createHttpErrorsSectionCreated +*/ +type CreateHTTPErrorsSectionCreated struct { + + /* + In: Body + */ + Payload *models.HTTPErrorsSection `json:"body,omitempty"` +} + +// NewCreateHTTPErrorsSectionCreated creates CreateHTTPErrorsSectionCreated with default headers values +func NewCreateHTTPErrorsSectionCreated() *CreateHTTPErrorsSectionCreated { + + return &CreateHTTPErrorsSectionCreated{} +} + +// WithPayload adds the payload to the create Http errors section created response +func (o *CreateHTTPErrorsSectionCreated) WithPayload(payload *models.HTTPErrorsSection) *CreateHTTPErrorsSectionCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http errors section created response +func (o *CreateHTTPErrorsSectionCreated) SetPayload(payload *models.HTTPErrorsSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorsSectionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorsSectionAcceptedCode is the HTTP code returned for type CreateHTTPErrorsSectionAccepted +const CreateHTTPErrorsSectionAcceptedCode int = 202 + +/* +CreateHTTPErrorsSectionAccepted Configuration change accepted and reload requested + +swagger:response createHttpErrorsSectionAccepted +*/ +type CreateHTTPErrorsSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorsSection `json:"body,omitempty"` +} + +// NewCreateHTTPErrorsSectionAccepted creates CreateHTTPErrorsSectionAccepted with default headers values +func NewCreateHTTPErrorsSectionAccepted() *CreateHTTPErrorsSectionAccepted { + + return &CreateHTTPErrorsSectionAccepted{} +} + +// WithReloadID adds the reloadId to the create Http errors section accepted response +func (o *CreateHTTPErrorsSectionAccepted) WithReloadID(reloadID string) *CreateHTTPErrorsSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http errors section accepted response +func (o *CreateHTTPErrorsSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http errors section accepted response +func (o *CreateHTTPErrorsSectionAccepted) WithPayload(payload *models.HTTPErrorsSection) *CreateHTTPErrorsSectionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http errors section accepted response +func (o *CreateHTTPErrorsSectionAccepted) SetPayload(payload *models.HTTPErrorsSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorsSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorsSectionBadRequestCode is the HTTP code returned for type CreateHTTPErrorsSectionBadRequest +const CreateHTTPErrorsSectionBadRequestCode int = 400 + +/* +CreateHTTPErrorsSectionBadRequest Bad request + +swagger:response createHttpErrorsSectionBadRequest +*/ +type CreateHTTPErrorsSectionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorsSectionBadRequest creates CreateHTTPErrorsSectionBadRequest with default headers values +func NewCreateHTTPErrorsSectionBadRequest() *CreateHTTPErrorsSectionBadRequest { + + return &CreateHTTPErrorsSectionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http errors section bad request response +func (o *CreateHTTPErrorsSectionBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorsSectionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http errors section bad request response +func (o *CreateHTTPErrorsSectionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http errors section bad request response +func (o *CreateHTTPErrorsSectionBadRequest) WithPayload(payload *models.Error) *CreateHTTPErrorsSectionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http errors section bad request response +func (o *CreateHTTPErrorsSectionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorsSectionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPErrorsSectionConflictCode is the HTTP code returned for type CreateHTTPErrorsSectionConflict +const CreateHTTPErrorsSectionConflictCode int = 409 + +/* +CreateHTTPErrorsSectionConflict The specified resource already exists + +swagger:response createHttpErrorsSectionConflict +*/ +type CreateHTTPErrorsSectionConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorsSectionConflict creates CreateHTTPErrorsSectionConflict with default headers values +func NewCreateHTTPErrorsSectionConflict() *CreateHTTPErrorsSectionConflict { + + return &CreateHTTPErrorsSectionConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http errors section conflict response +func (o *CreateHTTPErrorsSectionConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorsSectionConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http errors section conflict response +func (o *CreateHTTPErrorsSectionConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http errors section conflict response +func (o *CreateHTTPErrorsSectionConflict) WithPayload(payload *models.Error) *CreateHTTPErrorsSectionConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http errors section conflict response +func (o *CreateHTTPErrorsSectionConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorsSectionConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPErrorsSectionDefault General Error + +swagger:response createHttpErrorsSectionDefault +*/ +type CreateHTTPErrorsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPErrorsSectionDefault creates CreateHTTPErrorsSectionDefault with default headers values +func NewCreateHTTPErrorsSectionDefault(code int) *CreateHTTPErrorsSectionDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPErrorsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP errors section default response +func (o *CreateHTTPErrorsSectionDefault) WithStatusCode(code int) *CreateHTTPErrorsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP errors section default response +func (o *CreateHTTPErrorsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP errors section default response +func (o *CreateHTTPErrorsSectionDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPErrorsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP errors section default response +func (o *CreateHTTPErrorsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP errors section default response +func (o *CreateHTTPErrorsSectionDefault) WithPayload(payload *models.Error) *CreateHTTPErrorsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP errors section default response +func (o *CreateHTTPErrorsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPErrorsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_errors/create_http_errors_section_urlbuilder.go b/operations/http_errors/create_http_errors_section_urlbuilder.go new file mode 100644 index 00000000..5f729d41 --- /dev/null +++ b/operations/http_errors/create_http_errors_section_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateHTTPErrorsSectionURL generates an URL for the create HTTP errors section operation +type CreateHTTPErrorsSectionURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorsSectionURL) WithBasePath(bp string) *CreateHTTPErrorsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPErrorsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPErrorsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/http_errors_sections" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPErrorsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPErrorsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPErrorsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPErrorsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPErrorsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPErrorsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_errors/delete_http_errors_section.go b/operations/http_errors/delete_http_errors_section.go new file mode 100644 index 00000000..f2ed6646 --- /dev/null +++ b/operations/http_errors/delete_http_errors_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPErrorsSectionHandlerFunc turns a function with the right signature into a delete HTTP errors section handler +type DeleteHTTPErrorsSectionHandlerFunc func(DeleteHTTPErrorsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPErrorsSectionHandlerFunc) Handle(params DeleteHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPErrorsSectionHandler interface for that can handle valid delete HTTP errors section params +type DeleteHTTPErrorsSectionHandler interface { + Handle(DeleteHTTPErrorsSectionParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPErrorsSection creates a new http.Handler for the delete HTTP errors section operation +func NewDeleteHTTPErrorsSection(ctx *middleware.Context, handler DeleteHTTPErrorsSectionHandler) *DeleteHTTPErrorsSection { + return &DeleteHTTPErrorsSection{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPErrorsSection swagger:route DELETE /services/haproxy/configuration/http_errors_sections/{name} HTTPErrors deleteHttpErrorsSection + +# Delete a http-error section + +Deletes a http-error section with a given name from the configuration. +*/ +type DeleteHTTPErrorsSection struct { + Context *middleware.Context + Handler DeleteHTTPErrorsSectionHandler +} + +func (o *DeleteHTTPErrorsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPErrorsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_errors/delete_http_errors_section_parameters.go b/operations/http_errors/delete_http_errors_section_parameters.go new file mode 100644 index 00000000..5cbc4668 --- /dev/null +++ b/operations/http_errors/delete_http_errors_section_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPErrorsSectionParams creates a new DeleteHTTPErrorsSectionParams object +// with the default values initialized. +func NewDeleteHTTPErrorsSectionParams() DeleteHTTPErrorsSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPErrorsSectionParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPErrorsSectionParams contains all the bound params for the delete HTTP errors section operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPErrorsSection +type DeleteHTTPErrorsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*http-error section name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPErrorsSectionParams() beforehand. +func (o *DeleteHTTPErrorsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPErrorsSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPErrorsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteHTTPErrorsSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPErrorsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPErrorsSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_errors/delete_http_errors_section_responses.go b/operations/http_errors/delete_http_errors_section_responses.go new file mode 100644 index 00000000..232ab1e7 --- /dev/null +++ b/operations/http_errors/delete_http_errors_section_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPErrorsSectionAcceptedCode is the HTTP code returned for type DeleteHTTPErrorsSectionAccepted +const DeleteHTTPErrorsSectionAcceptedCode int = 202 + +/* +DeleteHTTPErrorsSectionAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpErrorsSectionAccepted +*/ +type DeleteHTTPErrorsSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPErrorsSectionAccepted creates DeleteHTTPErrorsSectionAccepted with default headers values +func NewDeleteHTTPErrorsSectionAccepted() *DeleteHTTPErrorsSectionAccepted { + + return &DeleteHTTPErrorsSectionAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http errors section accepted response +func (o *DeleteHTTPErrorsSectionAccepted) WithReloadID(reloadID string) *DeleteHTTPErrorsSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http errors section accepted response +func (o *DeleteHTTPErrorsSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorsSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPErrorsSectionNoContentCode is the HTTP code returned for type DeleteHTTPErrorsSectionNoContent +const DeleteHTTPErrorsSectionNoContentCode int = 204 + +/* +DeleteHTTPErrorsSectionNoContent http-error section deleted + +swagger:response deleteHttpErrorsSectionNoContent +*/ +type DeleteHTTPErrorsSectionNoContent struct { +} + +// NewDeleteHTTPErrorsSectionNoContent creates DeleteHTTPErrorsSectionNoContent with default headers values +func NewDeleteHTTPErrorsSectionNoContent() *DeleteHTTPErrorsSectionNoContent { + + return &DeleteHTTPErrorsSectionNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorsSectionNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPErrorsSectionNotFoundCode is the HTTP code returned for type DeleteHTTPErrorsSectionNotFound +const DeleteHTTPErrorsSectionNotFoundCode int = 404 + +/* +DeleteHTTPErrorsSectionNotFound The specified resource was not found + +swagger:response deleteHttpErrorsSectionNotFound +*/ +type DeleteHTTPErrorsSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorsSectionNotFound creates DeleteHTTPErrorsSectionNotFound with default headers values +func NewDeleteHTTPErrorsSectionNotFound() *DeleteHTTPErrorsSectionNotFound { + + return &DeleteHTTPErrorsSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http errors section not found response +func (o *DeleteHTTPErrorsSectionNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorsSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http errors section not found response +func (o *DeleteHTTPErrorsSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http errors section not found response +func (o *DeleteHTTPErrorsSectionNotFound) WithPayload(payload *models.Error) *DeleteHTTPErrorsSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http errors section not found response +func (o *DeleteHTTPErrorsSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorsSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPErrorsSectionDefault General Error + +swagger:response deleteHttpErrorsSectionDefault +*/ +type DeleteHTTPErrorsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPErrorsSectionDefault creates DeleteHTTPErrorsSectionDefault with default headers values +func NewDeleteHTTPErrorsSectionDefault(code int) *DeleteHTTPErrorsSectionDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPErrorsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP errors section default response +func (o *DeleteHTTPErrorsSectionDefault) WithStatusCode(code int) *DeleteHTTPErrorsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP errors section default response +func (o *DeleteHTTPErrorsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP errors section default response +func (o *DeleteHTTPErrorsSectionDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPErrorsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP errors section default response +func (o *DeleteHTTPErrorsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP errors section default response +func (o *DeleteHTTPErrorsSectionDefault) WithPayload(payload *models.Error) *DeleteHTTPErrorsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP errors section default response +func (o *DeleteHTTPErrorsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPErrorsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_errors/delete_http_errors_section_urlbuilder.go b/operations/http_errors/delete_http_errors_section_urlbuilder.go new file mode 100644 index 00000000..9503858e --- /dev/null +++ b/operations/http_errors/delete_http_errors_section_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPErrorsSectionURL generates an URL for the delete HTTP errors section operation +type DeleteHTTPErrorsSectionURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorsSectionURL) WithBasePath(bp string) *DeleteHTTPErrorsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPErrorsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPErrorsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/http_errors_sections/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteHTTPErrorsSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPErrorsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPErrorsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPErrorsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPErrorsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPErrorsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPErrorsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_errors/get_http_errors_section.go b/operations/http_errors/get_http_errors_section.go new file mode 100644 index 00000000..203e6089 --- /dev/null +++ b/operations/http_errors/get_http_errors_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPErrorsSectionHandlerFunc turns a function with the right signature into a get HTTP errors section handler +type GetHTTPErrorsSectionHandlerFunc func(GetHTTPErrorsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPErrorsSectionHandlerFunc) Handle(params GetHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPErrorsSectionHandler interface for that can handle valid get HTTP errors section params +type GetHTTPErrorsSectionHandler interface { + Handle(GetHTTPErrorsSectionParams, interface{}) middleware.Responder +} + +// NewGetHTTPErrorsSection creates a new http.Handler for the get HTTP errors section operation +func NewGetHTTPErrorsSection(ctx *middleware.Context, handler GetHTTPErrorsSectionHandler) *GetHTTPErrorsSection { + return &GetHTTPErrorsSection{Context: ctx, Handler: handler} +} + +/* + GetHTTPErrorsSection swagger:route GET /services/haproxy/configuration/http_errors_sections/{name} HTTPErrors getHttpErrorsSection + +# Return a http-error section + +Returns one http-error section with a given name from the configuration. +*/ +type GetHTTPErrorsSection struct { + Context *middleware.Context + Handler GetHTTPErrorsSectionHandler +} + +func (o *GetHTTPErrorsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPErrorsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_errors/get_http_errors_section_parameters.go b/operations/http_errors/get_http_errors_section_parameters.go new file mode 100644 index 00000000..fdf564d2 --- /dev/null +++ b/operations/http_errors/get_http_errors_section_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetHTTPErrorsSectionParams creates a new GetHTTPErrorsSectionParams object +// +// There are no default values defined in the spec. +func NewGetHTTPErrorsSectionParams() GetHTTPErrorsSectionParams { + + return GetHTTPErrorsSectionParams{} +} + +// GetHTTPErrorsSectionParams contains all the bound params for the get HTTP errors section operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPErrorsSection +type GetHTTPErrorsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*http-error section name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPErrorsSectionParams() beforehand. +func (o *GetHTTPErrorsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetHTTPErrorsSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPErrorsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_errors/get_http_errors_section_responses.go b/operations/http_errors/get_http_errors_section_responses.go new file mode 100644 index 00000000..af39dacf --- /dev/null +++ b/operations/http_errors/get_http_errors_section_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPErrorsSectionOKCode is the HTTP code returned for type GetHTTPErrorsSectionOK +const GetHTTPErrorsSectionOKCode int = 200 + +/* +GetHTTPErrorsSectionOK Successful operation + +swagger:response getHttpErrorsSectionOK +*/ +type GetHTTPErrorsSectionOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPErrorsSection `json:"body,omitempty"` +} + +// NewGetHTTPErrorsSectionOK creates GetHTTPErrorsSectionOK with default headers values +func NewGetHTTPErrorsSectionOK() *GetHTTPErrorsSectionOK { + + return &GetHTTPErrorsSectionOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http errors section o k response +func (o *GetHTTPErrorsSectionOK) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorsSectionOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http errors section o k response +func (o *GetHTTPErrorsSectionOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http errors section o k response +func (o *GetHTTPErrorsSectionOK) WithPayload(payload *models.HTTPErrorsSection) *GetHTTPErrorsSectionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http errors section o k response +func (o *GetHTTPErrorsSectionOK) SetPayload(payload *models.HTTPErrorsSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorsSectionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPErrorsSectionNotFoundCode is the HTTP code returned for type GetHTTPErrorsSectionNotFound +const GetHTTPErrorsSectionNotFoundCode int = 404 + +/* +GetHTTPErrorsSectionNotFound The specified resource was not found + +swagger:response getHttpErrorsSectionNotFound +*/ +type GetHTTPErrorsSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorsSectionNotFound creates GetHTTPErrorsSectionNotFound with default headers values +func NewGetHTTPErrorsSectionNotFound() *GetHTTPErrorsSectionNotFound { + + return &GetHTTPErrorsSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http errors section not found response +func (o *GetHTTPErrorsSectionNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorsSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http errors section not found response +func (o *GetHTTPErrorsSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http errors section not found response +func (o *GetHTTPErrorsSectionNotFound) WithPayload(payload *models.Error) *GetHTTPErrorsSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http errors section not found response +func (o *GetHTTPErrorsSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorsSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPErrorsSectionDefault General Error + +swagger:response getHttpErrorsSectionDefault +*/ +type GetHTTPErrorsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorsSectionDefault creates GetHTTPErrorsSectionDefault with default headers values +func NewGetHTTPErrorsSectionDefault(code int) *GetHTTPErrorsSectionDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPErrorsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP errors section default response +func (o *GetHTTPErrorsSectionDefault) WithStatusCode(code int) *GetHTTPErrorsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP errors section default response +func (o *GetHTTPErrorsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP errors section default response +func (o *GetHTTPErrorsSectionDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP errors section default response +func (o *GetHTTPErrorsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP errors section default response +func (o *GetHTTPErrorsSectionDefault) WithPayload(payload *models.Error) *GetHTTPErrorsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP errors section default response +func (o *GetHTTPErrorsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_errors/get_http_errors_section_urlbuilder.go b/operations/http_errors/get_http_errors_section_urlbuilder.go new file mode 100644 index 00000000..45cce8e3 --- /dev/null +++ b/operations/http_errors/get_http_errors_section_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetHTTPErrorsSectionURL generates an URL for the get HTTP errors section operation +type GetHTTPErrorsSectionURL struct { + Name string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorsSectionURL) WithBasePath(bp string) *GetHTTPErrorsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPErrorsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/http_errors_sections/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetHTTPErrorsSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPErrorsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPErrorsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPErrorsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPErrorsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPErrorsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPErrorsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_errors/get_http_errors_sections.go b/operations/http_errors/get_http_errors_sections.go new file mode 100644 index 00000000..c715c3dc --- /dev/null +++ b/operations/http_errors/get_http_errors_sections.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPErrorsSectionsHandlerFunc turns a function with the right signature into a get HTTP errors sections handler +type GetHTTPErrorsSectionsHandlerFunc func(GetHTTPErrorsSectionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPErrorsSectionsHandlerFunc) Handle(params GetHTTPErrorsSectionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPErrorsSectionsHandler interface for that can handle valid get HTTP errors sections params +type GetHTTPErrorsSectionsHandler interface { + Handle(GetHTTPErrorsSectionsParams, interface{}) middleware.Responder +} + +// NewGetHTTPErrorsSections creates a new http.Handler for the get HTTP errors sections operation +func NewGetHTTPErrorsSections(ctx *middleware.Context, handler GetHTTPErrorsSectionsHandler) *GetHTTPErrorsSections { + return &GetHTTPErrorsSections{Context: ctx, Handler: handler} +} + +/* + GetHTTPErrorsSections swagger:route GET /services/haproxy/configuration/http_errors_sections HTTPErrors getHttpErrorsSections + +# Return an array of http-error sections + +Returns an array of all configured http-error sections. +*/ +type GetHTTPErrorsSections struct { + Context *middleware.Context + Handler GetHTTPErrorsSectionsHandler +} + +func (o *GetHTTPErrorsSections) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPErrorsSectionsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_errors/get_http_errors_sections_parameters.go b/operations/http_errors/get_http_errors_sections_parameters.go new file mode 100644 index 00000000..d765df8b --- /dev/null +++ b/operations/http_errors/get_http_errors_sections_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetHTTPErrorsSectionsParams creates a new GetHTTPErrorsSectionsParams object +// +// There are no default values defined in the spec. +func NewGetHTTPErrorsSectionsParams() GetHTTPErrorsSectionsParams { + + return GetHTTPErrorsSectionsParams{} +} + +// GetHTTPErrorsSectionsParams contains all the bound params for the get HTTP errors sections operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPErrorsSections +type GetHTTPErrorsSectionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPErrorsSectionsParams() beforehand. +func (o *GetHTTPErrorsSectionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPErrorsSectionsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_errors/get_http_errors_sections_responses.go b/operations/http_errors/get_http_errors_sections_responses.go new file mode 100644 index 00000000..43829ded --- /dev/null +++ b/operations/http_errors/get_http_errors_sections_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPErrorsSectionsOKCode is the HTTP code returned for type GetHTTPErrorsSectionsOK +const GetHTTPErrorsSectionsOKCode int = 200 + +/* +GetHTTPErrorsSectionsOK Successful operation + +swagger:response getHttpErrorsSectionsOK +*/ +type GetHTTPErrorsSectionsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPErrorsSections `json:"body,omitempty"` +} + +// NewGetHTTPErrorsSectionsOK creates GetHTTPErrorsSectionsOK with default headers values +func NewGetHTTPErrorsSectionsOK() *GetHTTPErrorsSectionsOK { + + return &GetHTTPErrorsSectionsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http errors sections o k response +func (o *GetHTTPErrorsSectionsOK) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorsSectionsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http errors sections o k response +func (o *GetHTTPErrorsSectionsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http errors sections o k response +func (o *GetHTTPErrorsSectionsOK) WithPayload(payload models.HTTPErrorsSections) *GetHTTPErrorsSectionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http errors sections o k response +func (o *GetHTTPErrorsSectionsOK) SetPayload(payload models.HTTPErrorsSections) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorsSectionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPErrorsSections{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetHTTPErrorsSectionsDefault General Error + +swagger:response getHttpErrorsSectionsDefault +*/ +type GetHTTPErrorsSectionsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPErrorsSectionsDefault creates GetHTTPErrorsSectionsDefault with default headers values +func NewGetHTTPErrorsSectionsDefault(code int) *GetHTTPErrorsSectionsDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPErrorsSectionsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP errors sections default response +func (o *GetHTTPErrorsSectionsDefault) WithStatusCode(code int) *GetHTTPErrorsSectionsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP errors sections default response +func (o *GetHTTPErrorsSectionsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP errors sections default response +func (o *GetHTTPErrorsSectionsDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPErrorsSectionsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP errors sections default response +func (o *GetHTTPErrorsSectionsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP errors sections default response +func (o *GetHTTPErrorsSectionsDefault) WithPayload(payload *models.Error) *GetHTTPErrorsSectionsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP errors sections default response +func (o *GetHTTPErrorsSectionsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPErrorsSectionsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_errors/get_http_errors_sections_urlbuilder.go b/operations/http_errors/get_http_errors_sections_urlbuilder.go new file mode 100644 index 00000000..28764ed7 --- /dev/null +++ b/operations/http_errors/get_http_errors_sections_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetHTTPErrorsSectionsURL generates an URL for the get HTTP errors sections operation +type GetHTTPErrorsSectionsURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorsSectionsURL) WithBasePath(bp string) *GetHTTPErrorsSectionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPErrorsSectionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPErrorsSectionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/http_errors_sections" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPErrorsSectionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPErrorsSectionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPErrorsSectionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPErrorsSectionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPErrorsSectionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPErrorsSectionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_errors/replace_http_errors_section.go b/operations/http_errors/replace_http_errors_section.go new file mode 100644 index 00000000..57cb2447 --- /dev/null +++ b/operations/http_errors/replace_http_errors_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPErrorsSectionHandlerFunc turns a function with the right signature into a replace HTTP errors section handler +type ReplaceHTTPErrorsSectionHandlerFunc func(ReplaceHTTPErrorsSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPErrorsSectionHandlerFunc) Handle(params ReplaceHTTPErrorsSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPErrorsSectionHandler interface for that can handle valid replace HTTP errors section params +type ReplaceHTTPErrorsSectionHandler interface { + Handle(ReplaceHTTPErrorsSectionParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPErrorsSection creates a new http.Handler for the replace HTTP errors section operation +func NewReplaceHTTPErrorsSection(ctx *middleware.Context, handler ReplaceHTTPErrorsSectionHandler) *ReplaceHTTPErrorsSection { + return &ReplaceHTTPErrorsSection{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPErrorsSection swagger:route PUT /services/haproxy/configuration/http_errors_sections/{name} HTTPErrors replaceHttpErrorsSection + +# Replace a http-error section + +Replaces a http-error section with a given name in the configuration. +*/ +type ReplaceHTTPErrorsSection struct { + Context *middleware.Context + Handler ReplaceHTTPErrorsSectionHandler +} + +func (o *ReplaceHTTPErrorsSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPErrorsSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_errors/replace_http_errors_section_parameters.go b/operations/http_errors/replace_http_errors_section_parameters.go new file mode 100644 index 00000000..79f65393 --- /dev/null +++ b/operations/http_errors/replace_http_errors_section_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPErrorsSectionParams creates a new ReplaceHTTPErrorsSectionParams object +// with the default values initialized. +func NewReplaceHTTPErrorsSectionParams() ReplaceHTTPErrorsSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPErrorsSectionParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPErrorsSectionParams contains all the bound params for the replace HTTP errors section operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPErrorsSection +type ReplaceHTTPErrorsSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPErrorsSection + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*http-error section name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPErrorsSectionParams() beforehand. +func (o *ReplaceHTTPErrorsSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPErrorsSection + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPErrorsSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPErrorsSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceHTTPErrorsSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPErrorsSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPErrorsSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_errors/replace_http_errors_section_responses.go b/operations/http_errors/replace_http_errors_section_responses.go new file mode 100644 index 00000000..3dc172ff --- /dev/null +++ b/operations/http_errors/replace_http_errors_section_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPErrorsSectionOKCode is the HTTP code returned for type ReplaceHTTPErrorsSectionOK +const ReplaceHTTPErrorsSectionOKCode int = 200 + +/* +ReplaceHTTPErrorsSectionOK http-error section updated + +swagger:response replaceHttpErrorsSectionOK +*/ +type ReplaceHTTPErrorsSectionOK struct { + + /* + In: Body + */ + Payload *models.HTTPErrorsSection `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorsSectionOK creates ReplaceHTTPErrorsSectionOK with default headers values +func NewReplaceHTTPErrorsSectionOK() *ReplaceHTTPErrorsSectionOK { + + return &ReplaceHTTPErrorsSectionOK{} +} + +// WithPayload adds the payload to the replace Http errors section o k response +func (o *ReplaceHTTPErrorsSectionOK) WithPayload(payload *models.HTTPErrorsSection) *ReplaceHTTPErrorsSectionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http errors section o k response +func (o *ReplaceHTTPErrorsSectionOK) SetPayload(payload *models.HTTPErrorsSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorsSectionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorsSectionAcceptedCode is the HTTP code returned for type ReplaceHTTPErrorsSectionAccepted +const ReplaceHTTPErrorsSectionAcceptedCode int = 202 + +/* +ReplaceHTTPErrorsSectionAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpErrorsSectionAccepted +*/ +type ReplaceHTTPErrorsSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPErrorsSection `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorsSectionAccepted creates ReplaceHTTPErrorsSectionAccepted with default headers values +func NewReplaceHTTPErrorsSectionAccepted() *ReplaceHTTPErrorsSectionAccepted { + + return &ReplaceHTTPErrorsSectionAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http errors section accepted response +func (o *ReplaceHTTPErrorsSectionAccepted) WithReloadID(reloadID string) *ReplaceHTTPErrorsSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http errors section accepted response +func (o *ReplaceHTTPErrorsSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http errors section accepted response +func (o *ReplaceHTTPErrorsSectionAccepted) WithPayload(payload *models.HTTPErrorsSection) *ReplaceHTTPErrorsSectionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http errors section accepted response +func (o *ReplaceHTTPErrorsSectionAccepted) SetPayload(payload *models.HTTPErrorsSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorsSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorsSectionBadRequestCode is the HTTP code returned for type ReplaceHTTPErrorsSectionBadRequest +const ReplaceHTTPErrorsSectionBadRequestCode int = 400 + +/* +ReplaceHTTPErrorsSectionBadRequest Bad request + +swagger:response replaceHttpErrorsSectionBadRequest +*/ +type ReplaceHTTPErrorsSectionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorsSectionBadRequest creates ReplaceHTTPErrorsSectionBadRequest with default headers values +func NewReplaceHTTPErrorsSectionBadRequest() *ReplaceHTTPErrorsSectionBadRequest { + + return &ReplaceHTTPErrorsSectionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http errors section bad request response +func (o *ReplaceHTTPErrorsSectionBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorsSectionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http errors section bad request response +func (o *ReplaceHTTPErrorsSectionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http errors section bad request response +func (o *ReplaceHTTPErrorsSectionBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPErrorsSectionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http errors section bad request response +func (o *ReplaceHTTPErrorsSectionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorsSectionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPErrorsSectionNotFoundCode is the HTTP code returned for type ReplaceHTTPErrorsSectionNotFound +const ReplaceHTTPErrorsSectionNotFoundCode int = 404 + +/* +ReplaceHTTPErrorsSectionNotFound The specified resource was not found + +swagger:response replaceHttpErrorsSectionNotFound +*/ +type ReplaceHTTPErrorsSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorsSectionNotFound creates ReplaceHTTPErrorsSectionNotFound with default headers values +func NewReplaceHTTPErrorsSectionNotFound() *ReplaceHTTPErrorsSectionNotFound { + + return &ReplaceHTTPErrorsSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http errors section not found response +func (o *ReplaceHTTPErrorsSectionNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorsSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http errors section not found response +func (o *ReplaceHTTPErrorsSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http errors section not found response +func (o *ReplaceHTTPErrorsSectionNotFound) WithPayload(payload *models.Error) *ReplaceHTTPErrorsSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http errors section not found response +func (o *ReplaceHTTPErrorsSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorsSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPErrorsSectionDefault General Error + +swagger:response replaceHttpErrorsSectionDefault +*/ +type ReplaceHTTPErrorsSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPErrorsSectionDefault creates ReplaceHTTPErrorsSectionDefault with default headers values +func NewReplaceHTTPErrorsSectionDefault(code int) *ReplaceHTTPErrorsSectionDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPErrorsSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP errors section default response +func (o *ReplaceHTTPErrorsSectionDefault) WithStatusCode(code int) *ReplaceHTTPErrorsSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP errors section default response +func (o *ReplaceHTTPErrorsSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP errors section default response +func (o *ReplaceHTTPErrorsSectionDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPErrorsSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP errors section default response +func (o *ReplaceHTTPErrorsSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP errors section default response +func (o *ReplaceHTTPErrorsSectionDefault) WithPayload(payload *models.Error) *ReplaceHTTPErrorsSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP errors section default response +func (o *ReplaceHTTPErrorsSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPErrorsSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_errors/replace_http_errors_section_urlbuilder.go b/operations/http_errors/replace_http_errors_section_urlbuilder.go new file mode 100644 index 00000000..2ad5b195 --- /dev/null +++ b/operations/http_errors/replace_http_errors_section_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_errors + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPErrorsSectionURL generates an URL for the replace HTTP errors section operation +type ReplaceHTTPErrorsSectionURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorsSectionURL) WithBasePath(bp string) *ReplaceHTTPErrorsSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPErrorsSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPErrorsSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/http_errors_sections/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceHTTPErrorsSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPErrorsSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPErrorsSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPErrorsSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPErrorsSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPErrorsSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPErrorsSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/create_http_request_rule.go b/operations/http_request_rule/create_http_request_rule.go deleted file mode 100644 index 0ba7a70f..00000000 --- a/operations/http_request_rule/create_http_request_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateHTTPRequestRuleHandlerFunc turns a function with the right signature into a create HTTP request rule handler -type CreateHTTPRequestRuleHandlerFunc func(CreateHTTPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateHTTPRequestRuleHandlerFunc) Handle(params CreateHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateHTTPRequestRuleHandler interface for that can handle valid create HTTP request rule params -type CreateHTTPRequestRuleHandler interface { - Handle(CreateHTTPRequestRuleParams, interface{}) middleware.Responder -} - -// NewCreateHTTPRequestRule creates a new http.Handler for the create HTTP request rule operation -func NewCreateHTTPRequestRule(ctx *middleware.Context, handler CreateHTTPRequestRuleHandler) *CreateHTTPRequestRule { - return &CreateHTTPRequestRule{Context: ctx, Handler: handler} -} - -/*CreateHTTPRequestRule swagger:route POST /services/haproxy/configuration/http_request_rules HTTPRequestRule createHttpRequestRule - -Add a new HTTP Request Rule - -Adds a new HTTP Request Rule of the specified type in the specified parent. - -*/ -type CreateHTTPRequestRule struct { - Context *middleware.Context - Handler CreateHTTPRequestRuleHandler -} - -func (o *CreateHTTPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateHTTPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/http_request_rule/create_http_request_rule_backend.go b/operations/http_request_rule/create_http_request_rule_backend.go new file mode 100644 index 00000000..7c8b0e5a --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPRequestRuleBackendHandlerFunc turns a function with the right signature into a create HTTP request rule backend handler +type CreateHTTPRequestRuleBackendHandlerFunc func(CreateHTTPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPRequestRuleBackendHandlerFunc) Handle(params CreateHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPRequestRuleBackendHandler interface for that can handle valid create HTTP request rule backend params +type CreateHTTPRequestRuleBackendHandler interface { + Handle(CreateHTTPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPRequestRuleBackend creates a new http.Handler for the create HTTP request rule backend operation +func NewCreateHTTPRequestRuleBackend(ctx *middleware.Context, handler CreateHTTPRequestRuleBackendHandler) *CreateHTTPRequestRuleBackend { + return &CreateHTTPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPRequestRuleBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index} HTTPRequestRule createHttpRequestRuleBackend + +# Add a new HTTP Request Rule + +Adds a new HTTP Request Rule of the specified type in the specified parent. +*/ +type CreateHTTPRequestRuleBackend struct { + Context *middleware.Context + Handler CreateHTTPRequestRuleBackendHandler +} + +func (o *CreateHTTPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/create_http_request_rule_backend_parameters.go b/operations/http_request_rule/create_http_request_rule_backend_parameters.go new file mode 100644 index 00000000..41a9c904 --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPRequestRuleBackendParams creates a new CreateHTTPRequestRuleBackendParams object +// with the default values initialized. +func NewCreateHTTPRequestRuleBackendParams() CreateHTTPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPRequestRuleBackendParams contains all the bound params for the create HTTP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPRequestRuleBackend +type CreateHTTPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPRequestRuleBackendParams() beforehand. +func (o *CreateHTTPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/create_http_request_rule_backend_responses.go b/operations/http_request_rule/create_http_request_rule_backend_responses.go new file mode 100644 index 00000000..b310d13c --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPRequestRuleBackendCreatedCode is the HTTP code returned for type CreateHTTPRequestRuleBackendCreated +const CreateHTTPRequestRuleBackendCreatedCode int = 201 + +/* +CreateHTTPRequestRuleBackendCreated HTTP Request Rule created + +swagger:response createHttpRequestRuleBackendCreated +*/ +type CreateHTTPRequestRuleBackendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleBackendCreated creates CreateHTTPRequestRuleBackendCreated with default headers values +func NewCreateHTTPRequestRuleBackendCreated() *CreateHTTPRequestRuleBackendCreated { + + return &CreateHTTPRequestRuleBackendCreated{} +} + +// WithPayload adds the payload to the create Http request rule backend created response +func (o *CreateHTTPRequestRuleBackendCreated) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule backend created response +func (o *CreateHTTPRequestRuleBackendCreated) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleBackendAcceptedCode is the HTTP code returned for type CreateHTTPRequestRuleBackendAccepted +const CreateHTTPRequestRuleBackendAcceptedCode int = 202 + +/* +CreateHTTPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response createHttpRequestRuleBackendAccepted +*/ +type CreateHTTPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleBackendAccepted creates CreateHTTPRequestRuleBackendAccepted with default headers values +func NewCreateHTTPRequestRuleBackendAccepted() *CreateHTTPRequestRuleBackendAccepted { + + return &CreateHTTPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http request rule backend accepted response +func (o *CreateHTTPRequestRuleBackendAccepted) WithReloadID(reloadID string) *CreateHTTPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http request rule backend accepted response +func (o *CreateHTTPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http request rule backend accepted response +func (o *CreateHTTPRequestRuleBackendAccepted) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule backend accepted response +func (o *CreateHTTPRequestRuleBackendAccepted) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleBackendBadRequestCode is the HTTP code returned for type CreateHTTPRequestRuleBackendBadRequest +const CreateHTTPRequestRuleBackendBadRequestCode int = 400 + +/* +CreateHTTPRequestRuleBackendBadRequest Bad request + +swagger:response createHttpRequestRuleBackendBadRequest +*/ +type CreateHTTPRequestRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleBackendBadRequest creates CreateHTTPRequestRuleBackendBadRequest with default headers values +func NewCreateHTTPRequestRuleBackendBadRequest() *CreateHTTPRequestRuleBackendBadRequest { + + return &CreateHTTPRequestRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http request rule backend bad request response +func (o *CreateHTTPRequestRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http request rule backend bad request response +func (o *CreateHTTPRequestRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http request rule backend bad request response +func (o *CreateHTTPRequestRuleBackendBadRequest) WithPayload(payload *models.Error) *CreateHTTPRequestRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule backend bad request response +func (o *CreateHTTPRequestRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleBackendConflictCode is the HTTP code returned for type CreateHTTPRequestRuleBackendConflict +const CreateHTTPRequestRuleBackendConflictCode int = 409 + +/* +CreateHTTPRequestRuleBackendConflict The specified resource already exists + +swagger:response createHttpRequestRuleBackendConflict +*/ +type CreateHTTPRequestRuleBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleBackendConflict creates CreateHTTPRequestRuleBackendConflict with default headers values +func NewCreateHTTPRequestRuleBackendConflict() *CreateHTTPRequestRuleBackendConflict { + + return &CreateHTTPRequestRuleBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http request rule backend conflict response +func (o *CreateHTTPRequestRuleBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http request rule backend conflict response +func (o *CreateHTTPRequestRuleBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http request rule backend conflict response +func (o *CreateHTTPRequestRuleBackendConflict) WithPayload(payload *models.Error) *CreateHTTPRequestRuleBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule backend conflict response +func (o *CreateHTTPRequestRuleBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPRequestRuleBackendDefault General Error + +swagger:response createHttpRequestRuleBackendDefault +*/ +type CreateHTTPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleBackendDefault creates CreateHTTPRequestRuleBackendDefault with default headers values +func NewCreateHTTPRequestRuleBackendDefault(code int) *CreateHTTPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP request rule backend default response +func (o *CreateHTTPRequestRuleBackendDefault) WithStatusCode(code int) *CreateHTTPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP request rule backend default response +func (o *CreateHTTPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP request rule backend default response +func (o *CreateHTTPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP request rule backend default response +func (o *CreateHTTPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP request rule backend default response +func (o *CreateHTTPRequestRuleBackendDefault) WithPayload(payload *models.Error) *CreateHTTPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP request rule backend default response +func (o *CreateHTTPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/create_http_request_rule_backend_urlbuilder.go b/operations/http_request_rule/create_http_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..c5b99edb --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPRequestRuleBackendURL generates an URL for the create HTTP request rule backend operation +type CreateHTTPRequestRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPRequestRuleBackendURL) WithBasePath(bp string) *CreateHTTPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/create_http_request_rule_defaults.go b/operations/http_request_rule/create_http_request_rule_defaults.go new file mode 100644 index 00000000..179b3ede --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a create HTTP request rule defaults handler +type CreateHTTPRequestRuleDefaultsHandlerFunc func(CreateHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPRequestRuleDefaultsHandlerFunc) Handle(params CreateHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPRequestRuleDefaultsHandler interface for that can handle valid create HTTP request rule defaults params +type CreateHTTPRequestRuleDefaultsHandler interface { + Handle(CreateHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateHTTPRequestRuleDefaults creates a new http.Handler for the create HTTP request rule defaults operation +func NewCreateHTTPRequestRuleDefaults(ctx *middleware.Context, handler CreateHTTPRequestRuleDefaultsHandler) *CreateHTTPRequestRuleDefaults { + return &CreateHTTPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + CreateHTTPRequestRuleDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index} HTTPRequestRule createHttpRequestRuleDefaults + +# Add a new HTTP Request Rule + +Adds a new HTTP Request Rule of the specified type in the specified parent. +*/ +type CreateHTTPRequestRuleDefaults struct { + Context *middleware.Context + Handler CreateHTTPRequestRuleDefaultsHandler +} + +func (o *CreateHTTPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/create_http_request_rule_defaults_parameters.go b/operations/http_request_rule/create_http_request_rule_defaults_parameters.go new file mode 100644 index 00000000..b11f6ee6 --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPRequestRuleDefaultsParams creates a new CreateHTTPRequestRuleDefaultsParams object +// with the default values initialized. +func NewCreateHTTPRequestRuleDefaultsParams() CreateHTTPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPRequestRuleDefaultsParams contains all the bound params for the create HTTP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPRequestRuleDefaults +type CreateHTTPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPRequestRuleDefaultsParams() beforehand. +func (o *CreateHTTPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/create_http_request_rule_defaults_responses.go b/operations/http_request_rule/create_http_request_rule_defaults_responses.go new file mode 100644 index 00000000..f919fb00 --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPRequestRuleDefaultsCreatedCode is the HTTP code returned for type CreateHTTPRequestRuleDefaultsCreated +const CreateHTTPRequestRuleDefaultsCreatedCode int = 201 + +/* +CreateHTTPRequestRuleDefaultsCreated HTTP Request Rule created + +swagger:response createHttpRequestRuleDefaultsCreated +*/ +type CreateHTTPRequestRuleDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleDefaultsCreated creates CreateHTTPRequestRuleDefaultsCreated with default headers values +func NewCreateHTTPRequestRuleDefaultsCreated() *CreateHTTPRequestRuleDefaultsCreated { + + return &CreateHTTPRequestRuleDefaultsCreated{} +} + +// WithPayload adds the payload to the create Http request rule defaults created response +func (o *CreateHTTPRequestRuleDefaultsCreated) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule defaults created response +func (o *CreateHTTPRequestRuleDefaultsCreated) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type CreateHTTPRequestRuleDefaultsAccepted +const CreateHTTPRequestRuleDefaultsAcceptedCode int = 202 + +/* +CreateHTTPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createHttpRequestRuleDefaultsAccepted +*/ +type CreateHTTPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleDefaultsAccepted creates CreateHTTPRequestRuleDefaultsAccepted with default headers values +func NewCreateHTTPRequestRuleDefaultsAccepted() *CreateHTTPRequestRuleDefaultsAccepted { + + return &CreateHTTPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Http request rule defaults accepted response +func (o *CreateHTTPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *CreateHTTPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http request rule defaults accepted response +func (o *CreateHTTPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http request rule defaults accepted response +func (o *CreateHTTPRequestRuleDefaultsAccepted) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule defaults accepted response +func (o *CreateHTTPRequestRuleDefaultsAccepted) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleDefaultsBadRequestCode is the HTTP code returned for type CreateHTTPRequestRuleDefaultsBadRequest +const CreateHTTPRequestRuleDefaultsBadRequestCode int = 400 + +/* +CreateHTTPRequestRuleDefaultsBadRequest Bad request + +swagger:response createHttpRequestRuleDefaultsBadRequest +*/ +type CreateHTTPRequestRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleDefaultsBadRequest creates CreateHTTPRequestRuleDefaultsBadRequest with default headers values +func NewCreateHTTPRequestRuleDefaultsBadRequest() *CreateHTTPRequestRuleDefaultsBadRequest { + + return &CreateHTTPRequestRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http request rule defaults bad request response +func (o *CreateHTTPRequestRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http request rule defaults bad request response +func (o *CreateHTTPRequestRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http request rule defaults bad request response +func (o *CreateHTTPRequestRuleDefaultsBadRequest) WithPayload(payload *models.Error) *CreateHTTPRequestRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule defaults bad request response +func (o *CreateHTTPRequestRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleDefaultsConflictCode is the HTTP code returned for type CreateHTTPRequestRuleDefaultsConflict +const CreateHTTPRequestRuleDefaultsConflictCode int = 409 + +/* +CreateHTTPRequestRuleDefaultsConflict The specified resource already exists + +swagger:response createHttpRequestRuleDefaultsConflict +*/ +type CreateHTTPRequestRuleDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleDefaultsConflict creates CreateHTTPRequestRuleDefaultsConflict with default headers values +func NewCreateHTTPRequestRuleDefaultsConflict() *CreateHTTPRequestRuleDefaultsConflict { + + return &CreateHTTPRequestRuleDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http request rule defaults conflict response +func (o *CreateHTTPRequestRuleDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http request rule defaults conflict response +func (o *CreateHTTPRequestRuleDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http request rule defaults conflict response +func (o *CreateHTTPRequestRuleDefaultsConflict) WithPayload(payload *models.Error) *CreateHTTPRequestRuleDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule defaults conflict response +func (o *CreateHTTPRequestRuleDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPRequestRuleDefaultsDefault General Error + +swagger:response createHttpRequestRuleDefaultsDefault +*/ +type CreateHTTPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleDefaultsDefault creates CreateHTTPRequestRuleDefaultsDefault with default headers values +func NewCreateHTTPRequestRuleDefaultsDefault(code int) *CreateHTTPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP request rule defaults default response +func (o *CreateHTTPRequestRuleDefaultsDefault) WithStatusCode(code int) *CreateHTTPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP request rule defaults default response +func (o *CreateHTTPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP request rule defaults default response +func (o *CreateHTTPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP request rule defaults default response +func (o *CreateHTTPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP request rule defaults default response +func (o *CreateHTTPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *CreateHTTPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP request rule defaults default response +func (o *CreateHTTPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/create_http_request_rule_defaults_urlbuilder.go b/operations/http_request_rule/create_http_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..388a18b9 --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPRequestRuleDefaultsURL generates an URL for the create HTTP request rule defaults operation +type CreateHTTPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPRequestRuleDefaultsURL) WithBasePath(bp string) *CreateHTTPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/create_http_request_rule_frontend.go b/operations/http_request_rule/create_http_request_rule_frontend.go new file mode 100644 index 00000000..17621119 --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPRequestRuleFrontendHandlerFunc turns a function with the right signature into a create HTTP request rule frontend handler +type CreateHTTPRequestRuleFrontendHandlerFunc func(CreateHTTPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPRequestRuleFrontendHandlerFunc) Handle(params CreateHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPRequestRuleFrontendHandler interface for that can handle valid create HTTP request rule frontend params +type CreateHTTPRequestRuleFrontendHandler interface { + Handle(CreateHTTPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPRequestRuleFrontend creates a new http.Handler for the create HTTP request rule frontend operation +func NewCreateHTTPRequestRuleFrontend(ctx *middleware.Context, handler CreateHTTPRequestRuleFrontendHandler) *CreateHTTPRequestRuleFrontend { + return &CreateHTTPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPRequestRuleFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index} HTTPRequestRule createHttpRequestRuleFrontend + +# Add a new HTTP Request Rule + +Adds a new HTTP Request Rule of the specified type in the specified parent. +*/ +type CreateHTTPRequestRuleFrontend struct { + Context *middleware.Context + Handler CreateHTTPRequestRuleFrontendHandler +} + +func (o *CreateHTTPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/create_http_request_rule_frontend_parameters.go b/operations/http_request_rule/create_http_request_rule_frontend_parameters.go new file mode 100644 index 00000000..f14c1300 --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPRequestRuleFrontendParams creates a new CreateHTTPRequestRuleFrontendParams object +// with the default values initialized. +func NewCreateHTTPRequestRuleFrontendParams() CreateHTTPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPRequestRuleFrontendParams contains all the bound params for the create HTTP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPRequestRuleFrontend +type CreateHTTPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPRequestRuleFrontendParams() beforehand. +func (o *CreateHTTPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/create_http_request_rule_frontend_responses.go b/operations/http_request_rule/create_http_request_rule_frontend_responses.go new file mode 100644 index 00000000..b8cbb16a --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPRequestRuleFrontendCreatedCode is the HTTP code returned for type CreateHTTPRequestRuleFrontendCreated +const CreateHTTPRequestRuleFrontendCreatedCode int = 201 + +/* +CreateHTTPRequestRuleFrontendCreated HTTP Request Rule created + +swagger:response createHttpRequestRuleFrontendCreated +*/ +type CreateHTTPRequestRuleFrontendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleFrontendCreated creates CreateHTTPRequestRuleFrontendCreated with default headers values +func NewCreateHTTPRequestRuleFrontendCreated() *CreateHTTPRequestRuleFrontendCreated { + + return &CreateHTTPRequestRuleFrontendCreated{} +} + +// WithPayload adds the payload to the create Http request rule frontend created response +func (o *CreateHTTPRequestRuleFrontendCreated) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule frontend created response +func (o *CreateHTTPRequestRuleFrontendCreated) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleFrontendAcceptedCode is the HTTP code returned for type CreateHTTPRequestRuleFrontendAccepted +const CreateHTTPRequestRuleFrontendAcceptedCode int = 202 + +/* +CreateHTTPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response createHttpRequestRuleFrontendAccepted +*/ +type CreateHTTPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleFrontendAccepted creates CreateHTTPRequestRuleFrontendAccepted with default headers values +func NewCreateHTTPRequestRuleFrontendAccepted() *CreateHTTPRequestRuleFrontendAccepted { + + return &CreateHTTPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http request rule frontend accepted response +func (o *CreateHTTPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *CreateHTTPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http request rule frontend accepted response +func (o *CreateHTTPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http request rule frontend accepted response +func (o *CreateHTTPRequestRuleFrontendAccepted) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule frontend accepted response +func (o *CreateHTTPRequestRuleFrontendAccepted) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleFrontendBadRequestCode is the HTTP code returned for type CreateHTTPRequestRuleFrontendBadRequest +const CreateHTTPRequestRuleFrontendBadRequestCode int = 400 + +/* +CreateHTTPRequestRuleFrontendBadRequest Bad request + +swagger:response createHttpRequestRuleFrontendBadRequest +*/ +type CreateHTTPRequestRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleFrontendBadRequest creates CreateHTTPRequestRuleFrontendBadRequest with default headers values +func NewCreateHTTPRequestRuleFrontendBadRequest() *CreateHTTPRequestRuleFrontendBadRequest { + + return &CreateHTTPRequestRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http request rule frontend bad request response +func (o *CreateHTTPRequestRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http request rule frontend bad request response +func (o *CreateHTTPRequestRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http request rule frontend bad request response +func (o *CreateHTTPRequestRuleFrontendBadRequest) WithPayload(payload *models.Error) *CreateHTTPRequestRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule frontend bad request response +func (o *CreateHTTPRequestRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPRequestRuleFrontendConflictCode is the HTTP code returned for type CreateHTTPRequestRuleFrontendConflict +const CreateHTTPRequestRuleFrontendConflictCode int = 409 + +/* +CreateHTTPRequestRuleFrontendConflict The specified resource already exists + +swagger:response createHttpRequestRuleFrontendConflict +*/ +type CreateHTTPRequestRuleFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleFrontendConflict creates CreateHTTPRequestRuleFrontendConflict with default headers values +func NewCreateHTTPRequestRuleFrontendConflict() *CreateHTTPRequestRuleFrontendConflict { + + return &CreateHTTPRequestRuleFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http request rule frontend conflict response +func (o *CreateHTTPRequestRuleFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http request rule frontend conflict response +func (o *CreateHTTPRequestRuleFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http request rule frontend conflict response +func (o *CreateHTTPRequestRuleFrontendConflict) WithPayload(payload *models.Error) *CreateHTTPRequestRuleFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http request rule frontend conflict response +func (o *CreateHTTPRequestRuleFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPRequestRuleFrontendDefault General Error + +swagger:response createHttpRequestRuleFrontendDefault +*/ +type CreateHTTPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPRequestRuleFrontendDefault creates CreateHTTPRequestRuleFrontendDefault with default headers values +func NewCreateHTTPRequestRuleFrontendDefault(code int) *CreateHTTPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP request rule frontend default response +func (o *CreateHTTPRequestRuleFrontendDefault) WithStatusCode(code int) *CreateHTTPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP request rule frontend default response +func (o *CreateHTTPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP request rule frontend default response +func (o *CreateHTTPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP request rule frontend default response +func (o *CreateHTTPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP request rule frontend default response +func (o *CreateHTTPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *CreateHTTPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP request rule frontend default response +func (o *CreateHTTPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/create_http_request_rule_frontend_urlbuilder.go b/operations/http_request_rule/create_http_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..ca46cf46 --- /dev/null +++ b/operations/http_request_rule/create_http_request_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPRequestRuleFrontendURL generates an URL for the create HTTP request rule frontend operation +type CreateHTTPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPRequestRuleFrontendURL) WithBasePath(bp string) *CreateHTTPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/create_http_request_rule_parameters.go b/operations/http_request_rule/create_http_request_rule_parameters.go deleted file mode 100644 index 899f389d..00000000 --- a/operations/http_request_rule/create_http_request_rule_parameters.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateHTTPRequestRuleParams creates a new CreateHTTPRequestRuleParams object -// with the default values initialized. -func NewCreateHTTPRequestRuleParams() CreateHTTPRequestRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateHTTPRequestRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateHTTPRequestRuleParams contains all the bound params for the create HTTP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters createHTTPRequestRule -type CreateHTTPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.HTTPRequestRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateHTTPRequestRuleParams() beforehand. -func (o *CreateHTTPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.HTTPRequestRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateHTTPRequestRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateHTTPRequestRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *CreateHTTPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *CreateHTTPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *CreateHTTPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateHTTPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateHTTPRequestRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/http_request_rule/create_http_request_rule_responses.go b/operations/http_request_rule/create_http_request_rule_responses.go deleted file mode 100644 index 5c9078ae..00000000 --- a/operations/http_request_rule/create_http_request_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateHTTPRequestRuleCreatedCode is the HTTP code returned for type CreateHTTPRequestRuleCreated -const CreateHTTPRequestRuleCreatedCode int = 201 - -/*CreateHTTPRequestRuleCreated HTTP Request Rule created - -swagger:response createHttpRequestRuleCreated -*/ -type CreateHTTPRequestRuleCreated struct { - - /* - In: Body - */ - Payload *models.HTTPRequestRule `json:"body,omitempty"` -} - -// NewCreateHTTPRequestRuleCreated creates CreateHTTPRequestRuleCreated with default headers values -func NewCreateHTTPRequestRuleCreated() *CreateHTTPRequestRuleCreated { - - return &CreateHTTPRequestRuleCreated{} -} - -// WithPayload adds the payload to the create Http request rule created response -func (o *CreateHTTPRequestRuleCreated) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http request rule created response -func (o *CreateHTTPRequestRuleCreated) SetPayload(payload *models.HTTPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPRequestRuleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateHTTPRequestRuleAcceptedCode is the HTTP code returned for type CreateHTTPRequestRuleAccepted -const CreateHTTPRequestRuleAcceptedCode int = 202 - -/*CreateHTTPRequestRuleAccepted Configuration change accepted and reload requested - -swagger:response createHttpRequestRuleAccepted -*/ -type CreateHTTPRequestRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.HTTPRequestRule `json:"body,omitempty"` -} - -// NewCreateHTTPRequestRuleAccepted creates CreateHTTPRequestRuleAccepted with default headers values -func NewCreateHTTPRequestRuleAccepted() *CreateHTTPRequestRuleAccepted { - - return &CreateHTTPRequestRuleAccepted{} -} - -// WithReloadID adds the reloadId to the create Http request rule accepted response -func (o *CreateHTTPRequestRuleAccepted) WithReloadID(reloadID string) *CreateHTTPRequestRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create Http request rule accepted response -func (o *CreateHTTPRequestRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create Http request rule accepted response -func (o *CreateHTTPRequestRuleAccepted) WithPayload(payload *models.HTTPRequestRule) *CreateHTTPRequestRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http request rule accepted response -func (o *CreateHTTPRequestRuleAccepted) SetPayload(payload *models.HTTPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPRequestRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateHTTPRequestRuleBadRequestCode is the HTTP code returned for type CreateHTTPRequestRuleBadRequest -const CreateHTTPRequestRuleBadRequestCode int = 400 - -/*CreateHTTPRequestRuleBadRequest Bad request - -swagger:response createHttpRequestRuleBadRequest -*/ -type CreateHTTPRequestRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateHTTPRequestRuleBadRequest creates CreateHTTPRequestRuleBadRequest with default headers values -func NewCreateHTTPRequestRuleBadRequest() *CreateHTTPRequestRuleBadRequest { - - return &CreateHTTPRequestRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Http request rule bad request response -func (o *CreateHTTPRequestRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateHTTPRequestRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Http request rule bad request response -func (o *CreateHTTPRequestRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Http request rule bad request response -func (o *CreateHTTPRequestRuleBadRequest) WithPayload(payload *models.Error) *CreateHTTPRequestRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http request rule bad request response -func (o *CreateHTTPRequestRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPRequestRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateHTTPRequestRuleConflictCode is the HTTP code returned for type CreateHTTPRequestRuleConflict -const CreateHTTPRequestRuleConflictCode int = 409 - -/*CreateHTTPRequestRuleConflict The specified resource already exists - -swagger:response createHttpRequestRuleConflict -*/ -type CreateHTTPRequestRuleConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateHTTPRequestRuleConflict creates CreateHTTPRequestRuleConflict with default headers values -func NewCreateHTTPRequestRuleConflict() *CreateHTTPRequestRuleConflict { - - return &CreateHTTPRequestRuleConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Http request rule conflict response -func (o *CreateHTTPRequestRuleConflict) WithConfigurationVersion(configurationVersion int64) *CreateHTTPRequestRuleConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Http request rule conflict response -func (o *CreateHTTPRequestRuleConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Http request rule conflict response -func (o *CreateHTTPRequestRuleConflict) WithPayload(payload *models.Error) *CreateHTTPRequestRuleConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http request rule conflict response -func (o *CreateHTTPRequestRuleConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPRequestRuleConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateHTTPRequestRuleDefault General Error - -swagger:response createHttpRequestRuleDefault -*/ -type CreateHTTPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateHTTPRequestRuleDefault creates CreateHTTPRequestRuleDefault with default headers values -func NewCreateHTTPRequestRuleDefault(code int) *CreateHTTPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &CreateHTTPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create HTTP request rule default response -func (o *CreateHTTPRequestRuleDefault) WithStatusCode(code int) *CreateHTTPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create HTTP request rule default response -func (o *CreateHTTPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create HTTP request rule default response -func (o *CreateHTTPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *CreateHTTPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create HTTP request rule default response -func (o *CreateHTTPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create HTTP request rule default response -func (o *CreateHTTPRequestRuleDefault) WithPayload(payload *models.Error) *CreateHTTPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create HTTP request rule default response -func (o *CreateHTTPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_request_rule/create_http_request_rule_urlbuilder.go b/operations/http_request_rule/create_http_request_rule_urlbuilder.go deleted file mode 100644 index 89afb058..00000000 --- a/operations/http_request_rule/create_http_request_rule_urlbuilder.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateHTTPRequestRuleURL generates an URL for the create HTTP request rule operation -type CreateHTTPRequestRuleURL struct { - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateHTTPRequestRuleURL) WithBasePath(bp string) *CreateHTTPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateHTTPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateHTTPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_request_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateHTTPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateHTTPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateHTTPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateHTTPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateHTTPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateHTTPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_request_rule/delete_http_request_rule.go b/operations/http_request_rule/delete_http_request_rule.go deleted file mode 100644 index 4101dcf6..00000000 --- a/operations/http_request_rule/delete_http_request_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteHTTPRequestRuleHandlerFunc turns a function with the right signature into a delete HTTP request rule handler -type DeleteHTTPRequestRuleHandlerFunc func(DeleteHTTPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteHTTPRequestRuleHandlerFunc) Handle(params DeleteHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteHTTPRequestRuleHandler interface for that can handle valid delete HTTP request rule params -type DeleteHTTPRequestRuleHandler interface { - Handle(DeleteHTTPRequestRuleParams, interface{}) middleware.Responder -} - -// NewDeleteHTTPRequestRule creates a new http.Handler for the delete HTTP request rule operation -func NewDeleteHTTPRequestRule(ctx *middleware.Context, handler DeleteHTTPRequestRuleHandler) *DeleteHTTPRequestRule { - return &DeleteHTTPRequestRule{Context: ctx, Handler: handler} -} - -/*DeleteHTTPRequestRule swagger:route DELETE /services/haproxy/configuration/http_request_rules/{id} HTTPRequestRule deleteHttpRequestRule - -Delete a HTTP Request Rule - -Deletes a HTTP Request Rule configuration by it's ID from the specified parent. - -*/ -type DeleteHTTPRequestRule struct { - Context *middleware.Context - Handler DeleteHTTPRequestRuleHandler -} - -func (o *DeleteHTTPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteHTTPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/http_request_rule/delete_http_request_rule_backend.go b/operations/http_request_rule/delete_http_request_rule_backend.go new file mode 100644 index 00000000..d97b4040 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPRequestRuleBackendHandlerFunc turns a function with the right signature into a delete HTTP request rule backend handler +type DeleteHTTPRequestRuleBackendHandlerFunc func(DeleteHTTPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPRequestRuleBackendHandlerFunc) Handle(params DeleteHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPRequestRuleBackendHandler interface for that can handle valid delete HTTP request rule backend params +type DeleteHTTPRequestRuleBackendHandler interface { + Handle(DeleteHTTPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPRequestRuleBackend creates a new http.Handler for the delete HTTP request rule backend operation +func NewDeleteHTTPRequestRuleBackend(ctx *middleware.Context, handler DeleteHTTPRequestRuleBackendHandler) *DeleteHTTPRequestRuleBackend { + return &DeleteHTTPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPRequestRuleBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index} HTTPRequestRule deleteHttpRequestRuleBackend + +# Delete a HTTP Request Rule + +Deletes a HTTP Request Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPRequestRuleBackend struct { + Context *middleware.Context + Handler DeleteHTTPRequestRuleBackendHandler +} + +func (o *DeleteHTTPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/delete_http_request_rule_backend_parameters.go b/operations/http_request_rule/delete_http_request_rule_backend_parameters.go new file mode 100644 index 00000000..11d009ad --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPRequestRuleBackendParams creates a new DeleteHTTPRequestRuleBackendParams object +// with the default values initialized. +func NewDeleteHTTPRequestRuleBackendParams() DeleteHTTPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPRequestRuleBackendParams contains all the bound params for the delete HTTP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPRequestRuleBackend +type DeleteHTTPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPRequestRuleBackendParams() beforehand. +func (o *DeleteHTTPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/delete_http_request_rule_backend_responses.go b/operations/http_request_rule/delete_http_request_rule_backend_responses.go new file mode 100644 index 00000000..536f1414 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPRequestRuleBackendAcceptedCode is the HTTP code returned for type DeleteHTTPRequestRuleBackendAccepted +const DeleteHTTPRequestRuleBackendAcceptedCode int = 202 + +/* +DeleteHTTPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpRequestRuleBackendAccepted +*/ +type DeleteHTTPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPRequestRuleBackendAccepted creates DeleteHTTPRequestRuleBackendAccepted with default headers values +func NewDeleteHTTPRequestRuleBackendAccepted() *DeleteHTTPRequestRuleBackendAccepted { + + return &DeleteHTTPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http request rule backend accepted response +func (o *DeleteHTTPRequestRuleBackendAccepted) WithReloadID(reloadID string) *DeleteHTTPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http request rule backend accepted response +func (o *DeleteHTTPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPRequestRuleBackendNoContentCode is the HTTP code returned for type DeleteHTTPRequestRuleBackendNoContent +const DeleteHTTPRequestRuleBackendNoContentCode int = 204 + +/* +DeleteHTTPRequestRuleBackendNoContent HTTP Request Rule deleted + +swagger:response deleteHttpRequestRuleBackendNoContent +*/ +type DeleteHTTPRequestRuleBackendNoContent struct { +} + +// NewDeleteHTTPRequestRuleBackendNoContent creates DeleteHTTPRequestRuleBackendNoContent with default headers values +func NewDeleteHTTPRequestRuleBackendNoContent() *DeleteHTTPRequestRuleBackendNoContent { + + return &DeleteHTTPRequestRuleBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPRequestRuleBackendNotFoundCode is the HTTP code returned for type DeleteHTTPRequestRuleBackendNotFound +const DeleteHTTPRequestRuleBackendNotFoundCode int = 404 + +/* +DeleteHTTPRequestRuleBackendNotFound The specified resource was not found + +swagger:response deleteHttpRequestRuleBackendNotFound +*/ +type DeleteHTTPRequestRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPRequestRuleBackendNotFound creates DeleteHTTPRequestRuleBackendNotFound with default headers values +func NewDeleteHTTPRequestRuleBackendNotFound() *DeleteHTTPRequestRuleBackendNotFound { + + return &DeleteHTTPRequestRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http request rule backend not found response +func (o *DeleteHTTPRequestRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPRequestRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http request rule backend not found response +func (o *DeleteHTTPRequestRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http request rule backend not found response +func (o *DeleteHTTPRequestRuleBackendNotFound) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http request rule backend not found response +func (o *DeleteHTTPRequestRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPRequestRuleBackendDefault General Error + +swagger:response deleteHttpRequestRuleBackendDefault +*/ +type DeleteHTTPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPRequestRuleBackendDefault creates DeleteHTTPRequestRuleBackendDefault with default headers values +func NewDeleteHTTPRequestRuleBackendDefault(code int) *DeleteHTTPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP request rule backend default response +func (o *DeleteHTTPRequestRuleBackendDefault) WithStatusCode(code int) *DeleteHTTPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP request rule backend default response +func (o *DeleteHTTPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP request rule backend default response +func (o *DeleteHTTPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP request rule backend default response +func (o *DeleteHTTPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP request rule backend default response +func (o *DeleteHTTPRequestRuleBackendDefault) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP request rule backend default response +func (o *DeleteHTTPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/delete_http_request_rule_backend_urlbuilder.go b/operations/http_request_rule/delete_http_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..8731fc7e --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPRequestRuleBackendURL generates an URL for the delete HTTP request rule backend operation +type DeleteHTTPRequestRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPRequestRuleBackendURL) WithBasePath(bp string) *DeleteHTTPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/delete_http_request_rule_defaults.go b/operations/http_request_rule/delete_http_request_rule_defaults.go new file mode 100644 index 00000000..316095e4 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a delete HTTP request rule defaults handler +type DeleteHTTPRequestRuleDefaultsHandlerFunc func(DeleteHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPRequestRuleDefaultsHandlerFunc) Handle(params DeleteHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPRequestRuleDefaultsHandler interface for that can handle valid delete HTTP request rule defaults params +type DeleteHTTPRequestRuleDefaultsHandler interface { + Handle(DeleteHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPRequestRuleDefaults creates a new http.Handler for the delete HTTP request rule defaults operation +func NewDeleteHTTPRequestRuleDefaults(ctx *middleware.Context, handler DeleteHTTPRequestRuleDefaultsHandler) *DeleteHTTPRequestRuleDefaults { + return &DeleteHTTPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPRequestRuleDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index} HTTPRequestRule deleteHttpRequestRuleDefaults + +# Delete a HTTP Request Rule + +Deletes a HTTP Request Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPRequestRuleDefaults struct { + Context *middleware.Context + Handler DeleteHTTPRequestRuleDefaultsHandler +} + +func (o *DeleteHTTPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/delete_http_request_rule_defaults_parameters.go b/operations/http_request_rule/delete_http_request_rule_defaults_parameters.go new file mode 100644 index 00000000..d4371873 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPRequestRuleDefaultsParams creates a new DeleteHTTPRequestRuleDefaultsParams object +// with the default values initialized. +func NewDeleteHTTPRequestRuleDefaultsParams() DeleteHTTPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPRequestRuleDefaultsParams contains all the bound params for the delete HTTP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPRequestRuleDefaults +type DeleteHTTPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPRequestRuleDefaultsParams() beforehand. +func (o *DeleteHTTPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/delete_http_request_rule_defaults_responses.go b/operations/http_request_rule/delete_http_request_rule_defaults_responses.go new file mode 100644 index 00000000..7c692799 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type DeleteHTTPRequestRuleDefaultsAccepted +const DeleteHTTPRequestRuleDefaultsAcceptedCode int = 202 + +/* +DeleteHTTPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpRequestRuleDefaultsAccepted +*/ +type DeleteHTTPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPRequestRuleDefaultsAccepted creates DeleteHTTPRequestRuleDefaultsAccepted with default headers values +func NewDeleteHTTPRequestRuleDefaultsAccepted() *DeleteHTTPRequestRuleDefaultsAccepted { + + return &DeleteHTTPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http request rule defaults accepted response +func (o *DeleteHTTPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *DeleteHTTPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http request rule defaults accepted response +func (o *DeleteHTTPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPRequestRuleDefaultsNoContentCode is the HTTP code returned for type DeleteHTTPRequestRuleDefaultsNoContent +const DeleteHTTPRequestRuleDefaultsNoContentCode int = 204 + +/* +DeleteHTTPRequestRuleDefaultsNoContent HTTP Request Rule deleted + +swagger:response deleteHttpRequestRuleDefaultsNoContent +*/ +type DeleteHTTPRequestRuleDefaultsNoContent struct { +} + +// NewDeleteHTTPRequestRuleDefaultsNoContent creates DeleteHTTPRequestRuleDefaultsNoContent with default headers values +func NewDeleteHTTPRequestRuleDefaultsNoContent() *DeleteHTTPRequestRuleDefaultsNoContent { + + return &DeleteHTTPRequestRuleDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPRequestRuleDefaultsNotFoundCode is the HTTP code returned for type DeleteHTTPRequestRuleDefaultsNotFound +const DeleteHTTPRequestRuleDefaultsNotFoundCode int = 404 + +/* +DeleteHTTPRequestRuleDefaultsNotFound The specified resource was not found + +swagger:response deleteHttpRequestRuleDefaultsNotFound +*/ +type DeleteHTTPRequestRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPRequestRuleDefaultsNotFound creates DeleteHTTPRequestRuleDefaultsNotFound with default headers values +func NewDeleteHTTPRequestRuleDefaultsNotFound() *DeleteHTTPRequestRuleDefaultsNotFound { + + return &DeleteHTTPRequestRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http request rule defaults not found response +func (o *DeleteHTTPRequestRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPRequestRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http request rule defaults not found response +func (o *DeleteHTTPRequestRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http request rule defaults not found response +func (o *DeleteHTTPRequestRuleDefaultsNotFound) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http request rule defaults not found response +func (o *DeleteHTTPRequestRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPRequestRuleDefaultsDefault General Error + +swagger:response deleteHttpRequestRuleDefaultsDefault +*/ +type DeleteHTTPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPRequestRuleDefaultsDefault creates DeleteHTTPRequestRuleDefaultsDefault with default headers values +func NewDeleteHTTPRequestRuleDefaultsDefault(code int) *DeleteHTTPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP request rule defaults default response +func (o *DeleteHTTPRequestRuleDefaultsDefault) WithStatusCode(code int) *DeleteHTTPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP request rule defaults default response +func (o *DeleteHTTPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP request rule defaults default response +func (o *DeleteHTTPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP request rule defaults default response +func (o *DeleteHTTPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP request rule defaults default response +func (o *DeleteHTTPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP request rule defaults default response +func (o *DeleteHTTPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/delete_http_request_rule_defaults_urlbuilder.go b/operations/http_request_rule/delete_http_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..5baa2b88 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPRequestRuleDefaultsURL generates an URL for the delete HTTP request rule defaults operation +type DeleteHTTPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPRequestRuleDefaultsURL) WithBasePath(bp string) *DeleteHTTPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/delete_http_request_rule_frontend.go b/operations/http_request_rule/delete_http_request_rule_frontend.go new file mode 100644 index 00000000..0dab4b79 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPRequestRuleFrontendHandlerFunc turns a function with the right signature into a delete HTTP request rule frontend handler +type DeleteHTTPRequestRuleFrontendHandlerFunc func(DeleteHTTPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPRequestRuleFrontendHandlerFunc) Handle(params DeleteHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPRequestRuleFrontendHandler interface for that can handle valid delete HTTP request rule frontend params +type DeleteHTTPRequestRuleFrontendHandler interface { + Handle(DeleteHTTPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPRequestRuleFrontend creates a new http.Handler for the delete HTTP request rule frontend operation +func NewDeleteHTTPRequestRuleFrontend(ctx *middleware.Context, handler DeleteHTTPRequestRuleFrontendHandler) *DeleteHTTPRequestRuleFrontend { + return &DeleteHTTPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPRequestRuleFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index} HTTPRequestRule deleteHttpRequestRuleFrontend + +# Delete a HTTP Request Rule + +Deletes a HTTP Request Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPRequestRuleFrontend struct { + Context *middleware.Context + Handler DeleteHTTPRequestRuleFrontendHandler +} + +func (o *DeleteHTTPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/delete_http_request_rule_frontend_parameters.go b/operations/http_request_rule/delete_http_request_rule_frontend_parameters.go new file mode 100644 index 00000000..d020eb92 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPRequestRuleFrontendParams creates a new DeleteHTTPRequestRuleFrontendParams object +// with the default values initialized. +func NewDeleteHTTPRequestRuleFrontendParams() DeleteHTTPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPRequestRuleFrontendParams contains all the bound params for the delete HTTP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPRequestRuleFrontend +type DeleteHTTPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPRequestRuleFrontendParams() beforehand. +func (o *DeleteHTTPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/delete_http_request_rule_frontend_responses.go b/operations/http_request_rule/delete_http_request_rule_frontend_responses.go new file mode 100644 index 00000000..f3ad7fe0 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPRequestRuleFrontendAcceptedCode is the HTTP code returned for type DeleteHTTPRequestRuleFrontendAccepted +const DeleteHTTPRequestRuleFrontendAcceptedCode int = 202 + +/* +DeleteHTTPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpRequestRuleFrontendAccepted +*/ +type DeleteHTTPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPRequestRuleFrontendAccepted creates DeleteHTTPRequestRuleFrontendAccepted with default headers values +func NewDeleteHTTPRequestRuleFrontendAccepted() *DeleteHTTPRequestRuleFrontendAccepted { + + return &DeleteHTTPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http request rule frontend accepted response +func (o *DeleteHTTPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *DeleteHTTPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http request rule frontend accepted response +func (o *DeleteHTTPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPRequestRuleFrontendNoContentCode is the HTTP code returned for type DeleteHTTPRequestRuleFrontendNoContent +const DeleteHTTPRequestRuleFrontendNoContentCode int = 204 + +/* +DeleteHTTPRequestRuleFrontendNoContent HTTP Request Rule deleted + +swagger:response deleteHttpRequestRuleFrontendNoContent +*/ +type DeleteHTTPRequestRuleFrontendNoContent struct { +} + +// NewDeleteHTTPRequestRuleFrontendNoContent creates DeleteHTTPRequestRuleFrontendNoContent with default headers values +func NewDeleteHTTPRequestRuleFrontendNoContent() *DeleteHTTPRequestRuleFrontendNoContent { + + return &DeleteHTTPRequestRuleFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPRequestRuleFrontendNotFoundCode is the HTTP code returned for type DeleteHTTPRequestRuleFrontendNotFound +const DeleteHTTPRequestRuleFrontendNotFoundCode int = 404 + +/* +DeleteHTTPRequestRuleFrontendNotFound The specified resource was not found + +swagger:response deleteHttpRequestRuleFrontendNotFound +*/ +type DeleteHTTPRequestRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPRequestRuleFrontendNotFound creates DeleteHTTPRequestRuleFrontendNotFound with default headers values +func NewDeleteHTTPRequestRuleFrontendNotFound() *DeleteHTTPRequestRuleFrontendNotFound { + + return &DeleteHTTPRequestRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http request rule frontend not found response +func (o *DeleteHTTPRequestRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPRequestRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http request rule frontend not found response +func (o *DeleteHTTPRequestRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http request rule frontend not found response +func (o *DeleteHTTPRequestRuleFrontendNotFound) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http request rule frontend not found response +func (o *DeleteHTTPRequestRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPRequestRuleFrontendDefault General Error + +swagger:response deleteHttpRequestRuleFrontendDefault +*/ +type DeleteHTTPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPRequestRuleFrontendDefault creates DeleteHTTPRequestRuleFrontendDefault with default headers values +func NewDeleteHTTPRequestRuleFrontendDefault(code int) *DeleteHTTPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP request rule frontend default response +func (o *DeleteHTTPRequestRuleFrontendDefault) WithStatusCode(code int) *DeleteHTTPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP request rule frontend default response +func (o *DeleteHTTPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP request rule frontend default response +func (o *DeleteHTTPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP request rule frontend default response +func (o *DeleteHTTPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP request rule frontend default response +func (o *DeleteHTTPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP request rule frontend default response +func (o *DeleteHTTPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/delete_http_request_rule_frontend_urlbuilder.go b/operations/http_request_rule/delete_http_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..88963fe3 --- /dev/null +++ b/operations/http_request_rule/delete_http_request_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPRequestRuleFrontendURL generates an URL for the delete HTTP request rule frontend operation +type DeleteHTTPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPRequestRuleFrontendURL) WithBasePath(bp string) *DeleteHTTPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/delete_http_request_rule_parameters.go b/operations/http_request_rule/delete_http_request_rule_parameters.go deleted file mode 100644 index 686851c1..00000000 --- a/operations/http_request_rule/delete_http_request_rule_parameters.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteHTTPRequestRuleParams creates a new DeleteHTTPRequestRuleParams object -// with the default values initialized. -func NewDeleteHTTPRequestRuleParams() DeleteHTTPRequestRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteHTTPRequestRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteHTTPRequestRuleParams contains all the bound params for the delete HTTP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteHTTPRequestRule -type DeleteHTTPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*HTTP Request Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteHTTPRequestRuleParams() beforehand. -func (o *DeleteHTTPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteHTTPRequestRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteHTTPRequestRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *DeleteHTTPRequestRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *DeleteHTTPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *DeleteHTTPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *DeleteHTTPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteHTTPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteHTTPRequestRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/http_request_rule/delete_http_request_rule_responses.go b/operations/http_request_rule/delete_http_request_rule_responses.go deleted file mode 100644 index 0464bf1a..00000000 --- a/operations/http_request_rule/delete_http_request_rule_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteHTTPRequestRuleAcceptedCode is the HTTP code returned for type DeleteHTTPRequestRuleAccepted -const DeleteHTTPRequestRuleAcceptedCode int = 202 - -/*DeleteHTTPRequestRuleAccepted Configuration change accepted and reload requested - -swagger:response deleteHttpRequestRuleAccepted -*/ -type DeleteHTTPRequestRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteHTTPRequestRuleAccepted creates DeleteHTTPRequestRuleAccepted with default headers values -func NewDeleteHTTPRequestRuleAccepted() *DeleteHTTPRequestRuleAccepted { - - return &DeleteHTTPRequestRuleAccepted{} -} - -// WithReloadID adds the reloadId to the delete Http request rule accepted response -func (o *DeleteHTTPRequestRuleAccepted) WithReloadID(reloadID string) *DeleteHTTPRequestRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete Http request rule accepted response -func (o *DeleteHTTPRequestRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteHTTPRequestRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteHTTPRequestRuleNoContentCode is the HTTP code returned for type DeleteHTTPRequestRuleNoContent -const DeleteHTTPRequestRuleNoContentCode int = 204 - -/*DeleteHTTPRequestRuleNoContent HTTP Request Rule deleted - -swagger:response deleteHttpRequestRuleNoContent -*/ -type DeleteHTTPRequestRuleNoContent struct { -} - -// NewDeleteHTTPRequestRuleNoContent creates DeleteHTTPRequestRuleNoContent with default headers values -func NewDeleteHTTPRequestRuleNoContent() *DeleteHTTPRequestRuleNoContent { - - return &DeleteHTTPRequestRuleNoContent{} -} - -// WriteResponse to the client -func (o *DeleteHTTPRequestRuleNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteHTTPRequestRuleNotFoundCode is the HTTP code returned for type DeleteHTTPRequestRuleNotFound -const DeleteHTTPRequestRuleNotFoundCode int = 404 - -/*DeleteHTTPRequestRuleNotFound The specified resource was not found - -swagger:response deleteHttpRequestRuleNotFound -*/ -type DeleteHTTPRequestRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteHTTPRequestRuleNotFound creates DeleteHTTPRequestRuleNotFound with default headers values -func NewDeleteHTTPRequestRuleNotFound() *DeleteHTTPRequestRuleNotFound { - - return &DeleteHTTPRequestRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete Http request rule not found response -func (o *DeleteHTTPRequestRuleNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteHTTPRequestRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete Http request rule not found response -func (o *DeleteHTTPRequestRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete Http request rule not found response -func (o *DeleteHTTPRequestRuleNotFound) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete Http request rule not found response -func (o *DeleteHTTPRequestRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteHTTPRequestRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteHTTPRequestRuleDefault General Error - -swagger:response deleteHttpRequestRuleDefault -*/ -type DeleteHTTPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteHTTPRequestRuleDefault creates DeleteHTTPRequestRuleDefault with default headers values -func NewDeleteHTTPRequestRuleDefault(code int) *DeleteHTTPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &DeleteHTTPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete HTTP request rule default response -func (o *DeleteHTTPRequestRuleDefault) WithStatusCode(code int) *DeleteHTTPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete HTTP request rule default response -func (o *DeleteHTTPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete HTTP request rule default response -func (o *DeleteHTTPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *DeleteHTTPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete HTTP request rule default response -func (o *DeleteHTTPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete HTTP request rule default response -func (o *DeleteHTTPRequestRuleDefault) WithPayload(payload *models.Error) *DeleteHTTPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete HTTP request rule default response -func (o *DeleteHTTPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteHTTPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_request_rule/delete_http_request_rule_urlbuilder.go b/operations/http_request_rule/delete_http_request_rule_urlbuilder.go deleted file mode 100644 index e46c5cf7..00000000 --- a/operations/http_request_rule/delete_http_request_rule_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteHTTPRequestRuleURL generates an URL for the delete HTTP request rule operation -type DeleteHTTPRequestRuleURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteHTTPRequestRuleURL) WithBasePath(bp string) *DeleteHTTPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteHTTPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteHTTPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_request_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on DeleteHTTPRequestRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteHTTPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteHTTPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteHTTPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteHTTPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteHTTPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteHTTPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_request_rule/get_all_http_request_rule_backend.go b/operations/http_request_rule/get_all_http_request_rule_backend.go new file mode 100644 index 00000000..52d72b33 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPRequestRuleBackendHandlerFunc turns a function with the right signature into a get all HTTP request rule backend handler +type GetAllHTTPRequestRuleBackendHandlerFunc func(GetAllHTTPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPRequestRuleBackendHandlerFunc) Handle(params GetAllHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPRequestRuleBackendHandler interface for that can handle valid get all HTTP request rule backend params +type GetAllHTTPRequestRuleBackendHandler interface { + Handle(GetAllHTTPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPRequestRuleBackend creates a new http.Handler for the get all HTTP request rule backend operation +func NewGetAllHTTPRequestRuleBackend(ctx *middleware.Context, handler GetAllHTTPRequestRuleBackendHandler) *GetAllHTTPRequestRuleBackend { + return &GetAllHTTPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPRequestRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_request_rules HTTPRequestRule getAllHttpRequestRuleBackend + +# Return an array of all HTTP Request Rules + +Returns all HTTP Request Rules that are configured in specified parent. +*/ +type GetAllHTTPRequestRuleBackend struct { + Context *middleware.Context + Handler GetAllHTTPRequestRuleBackendHandler +} + +func (o *GetAllHTTPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/get_all_http_request_rule_backend_parameters.go b/operations/http_request_rule/get_all_http_request_rule_backend_parameters.go new file mode 100644 index 00000000..79dd9c24 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPRequestRuleBackendParams creates a new GetAllHTTPRequestRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPRequestRuleBackendParams() GetAllHTTPRequestRuleBackendParams { + + return GetAllHTTPRequestRuleBackendParams{} +} + +// GetAllHTTPRequestRuleBackendParams contains all the bound params for the get all HTTP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPRequestRuleBackend +type GetAllHTTPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPRequestRuleBackendParams() beforehand. +func (o *GetAllHTTPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_request_rule/get_all_http_request_rule_backend_responses.go b/operations/http_request_rule/get_all_http_request_rule_backend_responses.go new file mode 100644 index 00000000..355485c4 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPRequestRuleBackendOKCode is the HTTP code returned for type GetAllHTTPRequestRuleBackendOK +const GetAllHTTPRequestRuleBackendOKCode int = 200 + +/* +GetAllHTTPRequestRuleBackendOK Successful operation + +swagger:response getAllHttpRequestRuleBackendOK +*/ +type GetAllHTTPRequestRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewGetAllHTTPRequestRuleBackendOK creates GetAllHTTPRequestRuleBackendOK with default headers values +func NewGetAllHTTPRequestRuleBackendOK() *GetAllHTTPRequestRuleBackendOK { + + return &GetAllHTTPRequestRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http request rule backend o k response +func (o *GetAllHTTPRequestRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPRequestRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http request rule backend o k response +func (o *GetAllHTTPRequestRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http request rule backend o k response +func (o *GetAllHTTPRequestRuleBackendOK) WithPayload(payload models.HTTPRequestRules) *GetAllHTTPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http request rule backend o k response +func (o *GetAllHTTPRequestRuleBackendOK) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPRequestRuleBackendDefault General Error + +swagger:response getAllHttpRequestRuleBackendDefault +*/ +type GetAllHTTPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPRequestRuleBackendDefault creates GetAllHTTPRequestRuleBackendDefault with default headers values +func NewGetAllHTTPRequestRuleBackendDefault(code int) *GetAllHTTPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP request rule backend default response +func (o *GetAllHTTPRequestRuleBackendDefault) WithStatusCode(code int) *GetAllHTTPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP request rule backend default response +func (o *GetAllHTTPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP request rule backend default response +func (o *GetAllHTTPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP request rule backend default response +func (o *GetAllHTTPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP request rule backend default response +func (o *GetAllHTTPRequestRuleBackendDefault) WithPayload(payload *models.Error) *GetAllHTTPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP request rule backend default response +func (o *GetAllHTTPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/get_all_http_request_rule_backend_urlbuilder.go b/operations/http_request_rule/get_all_http_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..b8ecf015 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPRequestRuleBackendURL generates an URL for the get all HTTP request rule backend operation +type GetAllHTTPRequestRuleBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPRequestRuleBackendURL) WithBasePath(bp string) *GetAllHTTPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/get_all_http_request_rule_defaults.go b/operations/http_request_rule/get_all_http_request_rule_defaults.go new file mode 100644 index 00000000..5c2f5bdf --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a get all HTTP request rule defaults handler +type GetAllHTTPRequestRuleDefaultsHandlerFunc func(GetAllHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPRequestRuleDefaultsHandlerFunc) Handle(params GetAllHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPRequestRuleDefaultsHandler interface for that can handle valid get all HTTP request rule defaults params +type GetAllHTTPRequestRuleDefaultsHandler interface { + Handle(GetAllHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPRequestRuleDefaults creates a new http.Handler for the get all HTTP request rule defaults operation +func NewGetAllHTTPRequestRuleDefaults(ctx *middleware.Context, handler GetAllHTTPRequestRuleDefaultsHandler) *GetAllHTTPRequestRuleDefaults { + return &GetAllHTTPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPRequestRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_request_rules HTTPRequestRule getAllHttpRequestRuleDefaults + +# Return an array of all HTTP Request Rules + +Returns all HTTP Request Rules that are configured in specified parent. +*/ +type GetAllHTTPRequestRuleDefaults struct { + Context *middleware.Context + Handler GetAllHTTPRequestRuleDefaultsHandler +} + +func (o *GetAllHTTPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/get_all_http_request_rule_defaults_parameters.go b/operations/http_request_rule/get_all_http_request_rule_defaults_parameters.go new file mode 100644 index 00000000..d44850d0 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPRequestRuleDefaultsParams creates a new GetAllHTTPRequestRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPRequestRuleDefaultsParams() GetAllHTTPRequestRuleDefaultsParams { + + return GetAllHTTPRequestRuleDefaultsParams{} +} + +// GetAllHTTPRequestRuleDefaultsParams contains all the bound params for the get all HTTP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPRequestRuleDefaults +type GetAllHTTPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPRequestRuleDefaultsParams() beforehand. +func (o *GetAllHTTPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_request_rule/get_all_http_request_rule_defaults_responses.go b/operations/http_request_rule/get_all_http_request_rule_defaults_responses.go new file mode 100644 index 00000000..2fe34239 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPRequestRuleDefaultsOKCode is the HTTP code returned for type GetAllHTTPRequestRuleDefaultsOK +const GetAllHTTPRequestRuleDefaultsOKCode int = 200 + +/* +GetAllHTTPRequestRuleDefaultsOK Successful operation + +swagger:response getAllHttpRequestRuleDefaultsOK +*/ +type GetAllHTTPRequestRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewGetAllHTTPRequestRuleDefaultsOK creates GetAllHTTPRequestRuleDefaultsOK with default headers values +func NewGetAllHTTPRequestRuleDefaultsOK() *GetAllHTTPRequestRuleDefaultsOK { + + return &GetAllHTTPRequestRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http request rule defaults o k response +func (o *GetAllHTTPRequestRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPRequestRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http request rule defaults o k response +func (o *GetAllHTTPRequestRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http request rule defaults o k response +func (o *GetAllHTTPRequestRuleDefaultsOK) WithPayload(payload models.HTTPRequestRules) *GetAllHTTPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http request rule defaults o k response +func (o *GetAllHTTPRequestRuleDefaultsOK) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPRequestRuleDefaultsDefault General Error + +swagger:response getAllHttpRequestRuleDefaultsDefault +*/ +type GetAllHTTPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPRequestRuleDefaultsDefault creates GetAllHTTPRequestRuleDefaultsDefault with default headers values +func NewGetAllHTTPRequestRuleDefaultsDefault(code int) *GetAllHTTPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP request rule defaults default response +func (o *GetAllHTTPRequestRuleDefaultsDefault) WithStatusCode(code int) *GetAllHTTPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP request rule defaults default response +func (o *GetAllHTTPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP request rule defaults default response +func (o *GetAllHTTPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP request rule defaults default response +func (o *GetAllHTTPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP request rule defaults default response +func (o *GetAllHTTPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *GetAllHTTPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP request rule defaults default response +func (o *GetAllHTTPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/get_all_http_request_rule_defaults_urlbuilder.go b/operations/http_request_rule/get_all_http_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..8fa0db96 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPRequestRuleDefaultsURL generates an URL for the get all HTTP request rule defaults operation +type GetAllHTTPRequestRuleDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPRequestRuleDefaultsURL) WithBasePath(bp string) *GetAllHTTPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/get_all_http_request_rule_frontend.go b/operations/http_request_rule/get_all_http_request_rule_frontend.go new file mode 100644 index 00000000..88274661 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPRequestRuleFrontendHandlerFunc turns a function with the right signature into a get all HTTP request rule frontend handler +type GetAllHTTPRequestRuleFrontendHandlerFunc func(GetAllHTTPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPRequestRuleFrontendHandlerFunc) Handle(params GetAllHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPRequestRuleFrontendHandler interface for that can handle valid get all HTTP request rule frontend params +type GetAllHTTPRequestRuleFrontendHandler interface { + Handle(GetAllHTTPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPRequestRuleFrontend creates a new http.Handler for the get all HTTP request rule frontend operation +func NewGetAllHTTPRequestRuleFrontend(ctx *middleware.Context, handler GetAllHTTPRequestRuleFrontendHandler) *GetAllHTTPRequestRuleFrontend { + return &GetAllHTTPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPRequestRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_request_rules HTTPRequestRule getAllHttpRequestRuleFrontend + +# Return an array of all HTTP Request Rules + +Returns all HTTP Request Rules that are configured in specified parent. +*/ +type GetAllHTTPRequestRuleFrontend struct { + Context *middleware.Context + Handler GetAllHTTPRequestRuleFrontendHandler +} + +func (o *GetAllHTTPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/get_all_http_request_rule_frontend_parameters.go b/operations/http_request_rule/get_all_http_request_rule_frontend_parameters.go new file mode 100644 index 00000000..3d65849b --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPRequestRuleFrontendParams creates a new GetAllHTTPRequestRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPRequestRuleFrontendParams() GetAllHTTPRequestRuleFrontendParams { + + return GetAllHTTPRequestRuleFrontendParams{} +} + +// GetAllHTTPRequestRuleFrontendParams contains all the bound params for the get all HTTP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPRequestRuleFrontend +type GetAllHTTPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPRequestRuleFrontendParams() beforehand. +func (o *GetAllHTTPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_request_rule/get_all_http_request_rule_frontend_responses.go b/operations/http_request_rule/get_all_http_request_rule_frontend_responses.go new file mode 100644 index 00000000..cb32fa71 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPRequestRuleFrontendOKCode is the HTTP code returned for type GetAllHTTPRequestRuleFrontendOK +const GetAllHTTPRequestRuleFrontendOKCode int = 200 + +/* +GetAllHTTPRequestRuleFrontendOK Successful operation + +swagger:response getAllHttpRequestRuleFrontendOK +*/ +type GetAllHTTPRequestRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewGetAllHTTPRequestRuleFrontendOK creates GetAllHTTPRequestRuleFrontendOK with default headers values +func NewGetAllHTTPRequestRuleFrontendOK() *GetAllHTTPRequestRuleFrontendOK { + + return &GetAllHTTPRequestRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http request rule frontend o k response +func (o *GetAllHTTPRequestRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPRequestRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http request rule frontend o k response +func (o *GetAllHTTPRequestRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http request rule frontend o k response +func (o *GetAllHTTPRequestRuleFrontendOK) WithPayload(payload models.HTTPRequestRules) *GetAllHTTPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http request rule frontend o k response +func (o *GetAllHTTPRequestRuleFrontendOK) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPRequestRuleFrontendDefault General Error + +swagger:response getAllHttpRequestRuleFrontendDefault +*/ +type GetAllHTTPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPRequestRuleFrontendDefault creates GetAllHTTPRequestRuleFrontendDefault with default headers values +func NewGetAllHTTPRequestRuleFrontendDefault(code int) *GetAllHTTPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP request rule frontend default response +func (o *GetAllHTTPRequestRuleFrontendDefault) WithStatusCode(code int) *GetAllHTTPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP request rule frontend default response +func (o *GetAllHTTPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP request rule frontend default response +func (o *GetAllHTTPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP request rule frontend default response +func (o *GetAllHTTPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP request rule frontend default response +func (o *GetAllHTTPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *GetAllHTTPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP request rule frontend default response +func (o *GetAllHTTPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/get_all_http_request_rule_frontend_urlbuilder.go b/operations/http_request_rule/get_all_http_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..77c76688 --- /dev/null +++ b/operations/http_request_rule/get_all_http_request_rule_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPRequestRuleFrontendURL generates an URL for the get all HTTP request rule frontend operation +type GetAllHTTPRequestRuleFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPRequestRuleFrontendURL) WithBasePath(bp string) *GetAllHTTPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/get_http_request_rule.go b/operations/http_request_rule/get_http_request_rule.go deleted file mode 100644 index 442b4773..00000000 --- a/operations/http_request_rule/get_http_request_rule.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetHTTPRequestRuleHandlerFunc turns a function with the right signature into a get HTTP request rule handler -type GetHTTPRequestRuleHandlerFunc func(GetHTTPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetHTTPRequestRuleHandlerFunc) Handle(params GetHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetHTTPRequestRuleHandler interface for that can handle valid get HTTP request rule params -type GetHTTPRequestRuleHandler interface { - Handle(GetHTTPRequestRuleParams, interface{}) middleware.Responder -} - -// NewGetHTTPRequestRule creates a new http.Handler for the get HTTP request rule operation -func NewGetHTTPRequestRule(ctx *middleware.Context, handler GetHTTPRequestRuleHandler) *GetHTTPRequestRule { - return &GetHTTPRequestRule{Context: ctx, Handler: handler} -} - -/*GetHTTPRequestRule swagger:route GET /services/haproxy/configuration/http_request_rules/{id} HTTPRequestRule getHttpRequestRule - -Return one HTTP Request Rule - -Returns one HTTP Request Rule configuration by it's ID in the specified parent. - -*/ -type GetHTTPRequestRule struct { - Context *middleware.Context - Handler GetHTTPRequestRuleHandler -} - -func (o *GetHTTPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetHTTPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetHTTPRequestRuleOKBody get HTTP request rule o k body -// swagger:model GetHTTPRequestRuleOKBody -type GetHTTPRequestRuleOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.HTTPRequestRule `json:"data,omitempty"` -} - -// Validate validates this get HTTP request rule o k body -func (o *GetHTTPRequestRuleOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetHTTPRequestRuleOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getHttpRequestRuleOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetHTTPRequestRuleOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetHTTPRequestRuleOKBody) UnmarshalBinary(b []byte) error { - var res GetHTTPRequestRuleOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/http_request_rule/get_http_request_rule_backend.go b/operations/http_request_rule/get_http_request_rule_backend.go new file mode 100644 index 00000000..ee470e96 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPRequestRuleBackendHandlerFunc turns a function with the right signature into a get HTTP request rule backend handler +type GetHTTPRequestRuleBackendHandlerFunc func(GetHTTPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPRequestRuleBackendHandlerFunc) Handle(params GetHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPRequestRuleBackendHandler interface for that can handle valid get HTTP request rule backend params +type GetHTTPRequestRuleBackendHandler interface { + Handle(GetHTTPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetHTTPRequestRuleBackend creates a new http.Handler for the get HTTP request rule backend operation +func NewGetHTTPRequestRuleBackend(ctx *middleware.Context, handler GetHTTPRequestRuleBackendHandler) *GetHTTPRequestRuleBackend { + return &GetHTTPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetHTTPRequestRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index} HTTPRequestRule getHttpRequestRuleBackend + +# Return one HTTP Request Rule + +Returns one HTTP Request Rule configuration by it's index in the specified parent. +*/ +type GetHTTPRequestRuleBackend struct { + Context *middleware.Context + Handler GetHTTPRequestRuleBackendHandler +} + +func (o *GetHTTPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/get_http_request_rule_backend_parameters.go b/operations/http_request_rule/get_http_request_rule_backend_parameters.go new file mode 100644 index 00000000..84ba784c --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPRequestRuleBackendParams creates a new GetHTTPRequestRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPRequestRuleBackendParams() GetHTTPRequestRuleBackendParams { + + return GetHTTPRequestRuleBackendParams{} +} + +// GetHTTPRequestRuleBackendParams contains all the bound params for the get HTTP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPRequestRuleBackend +type GetHTTPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPRequestRuleBackendParams() beforehand. +func (o *GetHTTPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_request_rule/get_http_request_rule_backend_responses.go b/operations/http_request_rule/get_http_request_rule_backend_responses.go new file mode 100644 index 00000000..205ccf51 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPRequestRuleBackendOKCode is the HTTP code returned for type GetHTTPRequestRuleBackendOK +const GetHTTPRequestRuleBackendOKCode int = 200 + +/* +GetHTTPRequestRuleBackendOK Successful operation + +swagger:response getHttpRequestRuleBackendOK +*/ +type GetHTTPRequestRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleBackendOK creates GetHTTPRequestRuleBackendOK with default headers values +func NewGetHTTPRequestRuleBackendOK() *GetHTTPRequestRuleBackendOK { + + return &GetHTTPRequestRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http request rule backend o k response +func (o *GetHTTPRequestRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http request rule backend o k response +func (o *GetHTTPRequestRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http request rule backend o k response +func (o *GetHTTPRequestRuleBackendOK) WithPayload(payload *models.HTTPRequestRule) *GetHTTPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http request rule backend o k response +func (o *GetHTTPRequestRuleBackendOK) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPRequestRuleBackendNotFoundCode is the HTTP code returned for type GetHTTPRequestRuleBackendNotFound +const GetHTTPRequestRuleBackendNotFoundCode int = 404 + +/* +GetHTTPRequestRuleBackendNotFound The specified resource was not found + +swagger:response getHttpRequestRuleBackendNotFound +*/ +type GetHTTPRequestRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleBackendNotFound creates GetHTTPRequestRuleBackendNotFound with default headers values +func NewGetHTTPRequestRuleBackendNotFound() *GetHTTPRequestRuleBackendNotFound { + + return &GetHTTPRequestRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http request rule backend not found response +func (o *GetHTTPRequestRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http request rule backend not found response +func (o *GetHTTPRequestRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http request rule backend not found response +func (o *GetHTTPRequestRuleBackendNotFound) WithPayload(payload *models.Error) *GetHTTPRequestRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http request rule backend not found response +func (o *GetHTTPRequestRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPRequestRuleBackendDefault General Error + +swagger:response getHttpRequestRuleBackendDefault +*/ +type GetHTTPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleBackendDefault creates GetHTTPRequestRuleBackendDefault with default headers values +func NewGetHTTPRequestRuleBackendDefault(code int) *GetHTTPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP request rule backend default response +func (o *GetHTTPRequestRuleBackendDefault) WithStatusCode(code int) *GetHTTPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP request rule backend default response +func (o *GetHTTPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP request rule backend default response +func (o *GetHTTPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP request rule backend default response +func (o *GetHTTPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP request rule backend default response +func (o *GetHTTPRequestRuleBackendDefault) WithPayload(payload *models.Error) *GetHTTPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP request rule backend default response +func (o *GetHTTPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/get_http_request_rule_backend_urlbuilder.go b/operations/http_request_rule/get_http_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..f05bc08d --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPRequestRuleBackendURL generates an URL for the get HTTP request rule backend operation +type GetHTTPRequestRuleBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPRequestRuleBackendURL) WithBasePath(bp string) *GetHTTPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/get_http_request_rule_defaults.go b/operations/http_request_rule/get_http_request_rule_defaults.go new file mode 100644 index 00000000..f9095a92 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a get HTTP request rule defaults handler +type GetHTTPRequestRuleDefaultsHandlerFunc func(GetHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPRequestRuleDefaultsHandlerFunc) Handle(params GetHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPRequestRuleDefaultsHandler interface for that can handle valid get HTTP request rule defaults params +type GetHTTPRequestRuleDefaultsHandler interface { + Handle(GetHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetHTTPRequestRuleDefaults creates a new http.Handler for the get HTTP request rule defaults operation +func NewGetHTTPRequestRuleDefaults(ctx *middleware.Context, handler GetHTTPRequestRuleDefaultsHandler) *GetHTTPRequestRuleDefaults { + return &GetHTTPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetHTTPRequestRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index} HTTPRequestRule getHttpRequestRuleDefaults + +# Return one HTTP Request Rule + +Returns one HTTP Request Rule configuration by it's index in the specified parent. +*/ +type GetHTTPRequestRuleDefaults struct { + Context *middleware.Context + Handler GetHTTPRequestRuleDefaultsHandler +} + +func (o *GetHTTPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/get_http_request_rule_defaults_parameters.go b/operations/http_request_rule/get_http_request_rule_defaults_parameters.go new file mode 100644 index 00000000..8360f053 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPRequestRuleDefaultsParams creates a new GetHTTPRequestRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetHTTPRequestRuleDefaultsParams() GetHTTPRequestRuleDefaultsParams { + + return GetHTTPRequestRuleDefaultsParams{} +} + +// GetHTTPRequestRuleDefaultsParams contains all the bound params for the get HTTP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPRequestRuleDefaults +type GetHTTPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPRequestRuleDefaultsParams() beforehand. +func (o *GetHTTPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_request_rule/get_http_request_rule_defaults_responses.go b/operations/http_request_rule/get_http_request_rule_defaults_responses.go new file mode 100644 index 00000000..acb75fe1 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPRequestRuleDefaultsOKCode is the HTTP code returned for type GetHTTPRequestRuleDefaultsOK +const GetHTTPRequestRuleDefaultsOKCode int = 200 + +/* +GetHTTPRequestRuleDefaultsOK Successful operation + +swagger:response getHttpRequestRuleDefaultsOK +*/ +type GetHTTPRequestRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleDefaultsOK creates GetHTTPRequestRuleDefaultsOK with default headers values +func NewGetHTTPRequestRuleDefaultsOK() *GetHTTPRequestRuleDefaultsOK { + + return &GetHTTPRequestRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http request rule defaults o k response +func (o *GetHTTPRequestRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http request rule defaults o k response +func (o *GetHTTPRequestRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http request rule defaults o k response +func (o *GetHTTPRequestRuleDefaultsOK) WithPayload(payload *models.HTTPRequestRule) *GetHTTPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http request rule defaults o k response +func (o *GetHTTPRequestRuleDefaultsOK) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPRequestRuleDefaultsNotFoundCode is the HTTP code returned for type GetHTTPRequestRuleDefaultsNotFound +const GetHTTPRequestRuleDefaultsNotFoundCode int = 404 + +/* +GetHTTPRequestRuleDefaultsNotFound The specified resource was not found + +swagger:response getHttpRequestRuleDefaultsNotFound +*/ +type GetHTTPRequestRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleDefaultsNotFound creates GetHTTPRequestRuleDefaultsNotFound with default headers values +func NewGetHTTPRequestRuleDefaultsNotFound() *GetHTTPRequestRuleDefaultsNotFound { + + return &GetHTTPRequestRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http request rule defaults not found response +func (o *GetHTTPRequestRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http request rule defaults not found response +func (o *GetHTTPRequestRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http request rule defaults not found response +func (o *GetHTTPRequestRuleDefaultsNotFound) WithPayload(payload *models.Error) *GetHTTPRequestRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http request rule defaults not found response +func (o *GetHTTPRequestRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPRequestRuleDefaultsDefault General Error + +swagger:response getHttpRequestRuleDefaultsDefault +*/ +type GetHTTPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleDefaultsDefault creates GetHTTPRequestRuleDefaultsDefault with default headers values +func NewGetHTTPRequestRuleDefaultsDefault(code int) *GetHTTPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP request rule defaults default response +func (o *GetHTTPRequestRuleDefaultsDefault) WithStatusCode(code int) *GetHTTPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP request rule defaults default response +func (o *GetHTTPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP request rule defaults default response +func (o *GetHTTPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP request rule defaults default response +func (o *GetHTTPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP request rule defaults default response +func (o *GetHTTPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *GetHTTPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP request rule defaults default response +func (o *GetHTTPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/get_http_request_rule_defaults_urlbuilder.go b/operations/http_request_rule/get_http_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..d304b595 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPRequestRuleDefaultsURL generates an URL for the get HTTP request rule defaults operation +type GetHTTPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPRequestRuleDefaultsURL) WithBasePath(bp string) *GetHTTPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/get_http_request_rule_frontend.go b/operations/http_request_rule/get_http_request_rule_frontend.go new file mode 100644 index 00000000..37e5c652 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPRequestRuleFrontendHandlerFunc turns a function with the right signature into a get HTTP request rule frontend handler +type GetHTTPRequestRuleFrontendHandlerFunc func(GetHTTPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPRequestRuleFrontendHandlerFunc) Handle(params GetHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPRequestRuleFrontendHandler interface for that can handle valid get HTTP request rule frontend params +type GetHTTPRequestRuleFrontendHandler interface { + Handle(GetHTTPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetHTTPRequestRuleFrontend creates a new http.Handler for the get HTTP request rule frontend operation +func NewGetHTTPRequestRuleFrontend(ctx *middleware.Context, handler GetHTTPRequestRuleFrontendHandler) *GetHTTPRequestRuleFrontend { + return &GetHTTPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetHTTPRequestRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index} HTTPRequestRule getHttpRequestRuleFrontend + +# Return one HTTP Request Rule + +Returns one HTTP Request Rule configuration by it's index in the specified parent. +*/ +type GetHTTPRequestRuleFrontend struct { + Context *middleware.Context + Handler GetHTTPRequestRuleFrontendHandler +} + +func (o *GetHTTPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/get_http_request_rule_frontend_parameters.go b/operations/http_request_rule/get_http_request_rule_frontend_parameters.go new file mode 100644 index 00000000..1a737167 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPRequestRuleFrontendParams creates a new GetHTTPRequestRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPRequestRuleFrontendParams() GetHTTPRequestRuleFrontendParams { + + return GetHTTPRequestRuleFrontendParams{} +} + +// GetHTTPRequestRuleFrontendParams contains all the bound params for the get HTTP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPRequestRuleFrontend +type GetHTTPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPRequestRuleFrontendParams() beforehand. +func (o *GetHTTPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_request_rule/get_http_request_rule_frontend_responses.go b/operations/http_request_rule/get_http_request_rule_frontend_responses.go new file mode 100644 index 00000000..c69fc176 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPRequestRuleFrontendOKCode is the HTTP code returned for type GetHTTPRequestRuleFrontendOK +const GetHTTPRequestRuleFrontendOKCode int = 200 + +/* +GetHTTPRequestRuleFrontendOK Successful operation + +swagger:response getHttpRequestRuleFrontendOK +*/ +type GetHTTPRequestRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleFrontendOK creates GetHTTPRequestRuleFrontendOK with default headers values +func NewGetHTTPRequestRuleFrontendOK() *GetHTTPRequestRuleFrontendOK { + + return &GetHTTPRequestRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http request rule frontend o k response +func (o *GetHTTPRequestRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http request rule frontend o k response +func (o *GetHTTPRequestRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http request rule frontend o k response +func (o *GetHTTPRequestRuleFrontendOK) WithPayload(payload *models.HTTPRequestRule) *GetHTTPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http request rule frontend o k response +func (o *GetHTTPRequestRuleFrontendOK) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPRequestRuleFrontendNotFoundCode is the HTTP code returned for type GetHTTPRequestRuleFrontendNotFound +const GetHTTPRequestRuleFrontendNotFoundCode int = 404 + +/* +GetHTTPRequestRuleFrontendNotFound The specified resource was not found + +swagger:response getHttpRequestRuleFrontendNotFound +*/ +type GetHTTPRequestRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleFrontendNotFound creates GetHTTPRequestRuleFrontendNotFound with default headers values +func NewGetHTTPRequestRuleFrontendNotFound() *GetHTTPRequestRuleFrontendNotFound { + + return &GetHTTPRequestRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http request rule frontend not found response +func (o *GetHTTPRequestRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http request rule frontend not found response +func (o *GetHTTPRequestRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http request rule frontend not found response +func (o *GetHTTPRequestRuleFrontendNotFound) WithPayload(payload *models.Error) *GetHTTPRequestRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http request rule frontend not found response +func (o *GetHTTPRequestRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPRequestRuleFrontendDefault General Error + +swagger:response getHttpRequestRuleFrontendDefault +*/ +type GetHTTPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPRequestRuleFrontendDefault creates GetHTTPRequestRuleFrontendDefault with default headers values +func NewGetHTTPRequestRuleFrontendDefault(code int) *GetHTTPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP request rule frontend default response +func (o *GetHTTPRequestRuleFrontendDefault) WithStatusCode(code int) *GetHTTPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP request rule frontend default response +func (o *GetHTTPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP request rule frontend default response +func (o *GetHTTPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP request rule frontend default response +func (o *GetHTTPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP request rule frontend default response +func (o *GetHTTPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *GetHTTPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP request rule frontend default response +func (o *GetHTTPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/get_http_request_rule_frontend_urlbuilder.go b/operations/http_request_rule/get_http_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..4d797ca9 --- /dev/null +++ b/operations/http_request_rule/get_http_request_rule_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPRequestRuleFrontendURL generates an URL for the get HTTP request rule frontend operation +type GetHTTPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPRequestRuleFrontendURL) WithBasePath(bp string) *GetHTTPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/get_http_request_rule_parameters.go b/operations/http_request_rule/get_http_request_rule_parameters.go deleted file mode 100644 index 21326b4b..00000000 --- a/operations/http_request_rule/get_http_request_rule_parameters.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetHTTPRequestRuleParams creates a new GetHTTPRequestRuleParams object -// no default values defined in spec. -func NewGetHTTPRequestRuleParams() GetHTTPRequestRuleParams { - - return GetHTTPRequestRuleParams{} -} - -// GetHTTPRequestRuleParams contains all the bound params for the get HTTP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters getHTTPRequestRule -type GetHTTPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*HTTP Request Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetHTTPRequestRuleParams() beforehand. -func (o *GetHTTPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *GetHTTPRequestRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetHTTPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetHTTPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetHTTPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetHTTPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/http_request_rule/get_http_request_rule_responses.go b/operations/http_request_rule/get_http_request_rule_responses.go deleted file mode 100644 index ca30cc3e..00000000 --- a/operations/http_request_rule/get_http_request_rule_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetHTTPRequestRuleOKCode is the HTTP code returned for type GetHTTPRequestRuleOK -const GetHTTPRequestRuleOKCode int = 200 - -/*GetHTTPRequestRuleOK Successful operation - -swagger:response getHttpRequestRuleOK -*/ -type GetHTTPRequestRuleOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetHTTPRequestRuleOKBody `json:"body,omitempty"` -} - -// NewGetHTTPRequestRuleOK creates GetHTTPRequestRuleOK with default headers values -func NewGetHTTPRequestRuleOK() *GetHTTPRequestRuleOK { - - return &GetHTTPRequestRuleOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Http request rule o k response -func (o *GetHTTPRequestRuleOK) WithConfigurationVersion(configurationVersion int64) *GetHTTPRequestRuleOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Http request rule o k response -func (o *GetHTTPRequestRuleOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Http request rule o k response -func (o *GetHTTPRequestRuleOK) WithPayload(payload *GetHTTPRequestRuleOKBody) *GetHTTPRequestRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Http request rule o k response -func (o *GetHTTPRequestRuleOK) SetPayload(payload *GetHTTPRequestRuleOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPRequestRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetHTTPRequestRuleNotFoundCode is the HTTP code returned for type GetHTTPRequestRuleNotFound -const GetHTTPRequestRuleNotFoundCode int = 404 - -/*GetHTTPRequestRuleNotFound The specified resource was not found - -swagger:response getHttpRequestRuleNotFound -*/ -type GetHTTPRequestRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetHTTPRequestRuleNotFound creates GetHTTPRequestRuleNotFound with default headers values -func NewGetHTTPRequestRuleNotFound() *GetHTTPRequestRuleNotFound { - - return &GetHTTPRequestRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Http request rule not found response -func (o *GetHTTPRequestRuleNotFound) WithConfigurationVersion(configurationVersion int64) *GetHTTPRequestRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Http request rule not found response -func (o *GetHTTPRequestRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Http request rule not found response -func (o *GetHTTPRequestRuleNotFound) WithPayload(payload *models.Error) *GetHTTPRequestRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Http request rule not found response -func (o *GetHTTPRequestRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPRequestRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetHTTPRequestRuleDefault General Error - -swagger:response getHttpRequestRuleDefault -*/ -type GetHTTPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetHTTPRequestRuleDefault creates GetHTTPRequestRuleDefault with default headers values -func NewGetHTTPRequestRuleDefault(code int) *GetHTTPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &GetHTTPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get HTTP request rule default response -func (o *GetHTTPRequestRuleDefault) WithStatusCode(code int) *GetHTTPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get HTTP request rule default response -func (o *GetHTTPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get HTTP request rule default response -func (o *GetHTTPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *GetHTTPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get HTTP request rule default response -func (o *GetHTTPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get HTTP request rule default response -func (o *GetHTTPRequestRuleDefault) WithPayload(payload *models.Error) *GetHTTPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get HTTP request rule default response -func (o *GetHTTPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_request_rule/get_http_request_rule_urlbuilder.go b/operations/http_request_rule/get_http_request_rule_urlbuilder.go deleted file mode 100644 index d23985d1..00000000 --- a/operations/http_request_rule/get_http_request_rule_urlbuilder.go +++ /dev/null @@ -1,142 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// GetHTTPRequestRuleURL generates an URL for the get HTTP request rule operation -type GetHTTPRequestRuleURL struct { - ID int64 - - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPRequestRuleURL) WithBasePath(bp string) *GetHTTPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetHTTPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_request_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on GetHTTPRequestRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetHTTPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetHTTPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetHTTPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetHTTPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetHTTPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetHTTPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_request_rule/get_http_request_rules.go b/operations/http_request_rule/get_http_request_rules.go deleted file mode 100644 index e631796a..00000000 --- a/operations/http_request_rule/get_http_request_rules.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetHTTPRequestRulesHandlerFunc turns a function with the right signature into a get HTTP request rules handler -type GetHTTPRequestRulesHandlerFunc func(GetHTTPRequestRulesParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetHTTPRequestRulesHandlerFunc) Handle(params GetHTTPRequestRulesParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetHTTPRequestRulesHandler interface for that can handle valid get HTTP request rules params -type GetHTTPRequestRulesHandler interface { - Handle(GetHTTPRequestRulesParams, interface{}) middleware.Responder -} - -// NewGetHTTPRequestRules creates a new http.Handler for the get HTTP request rules operation -func NewGetHTTPRequestRules(ctx *middleware.Context, handler GetHTTPRequestRulesHandler) *GetHTTPRequestRules { - return &GetHTTPRequestRules{Context: ctx, Handler: handler} -} - -/*GetHTTPRequestRules swagger:route GET /services/haproxy/configuration/http_request_rules HTTPRequestRule getHttpRequestRules - -Return an array of all HTTP Request Rules - -Returns all HTTP Request Rules that are configured in specified parent. - -*/ -type GetHTTPRequestRules struct { - Context *middleware.Context - Handler GetHTTPRequestRulesHandler -} - -func (o *GetHTTPRequestRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetHTTPRequestRulesParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetHTTPRequestRulesOKBody get HTTP request rules o k body -// swagger:model GetHTTPRequestRulesOKBody -type GetHTTPRequestRulesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.HTTPRequestRules `json:"data"` -} - -// Validate validates this get HTTP request rules o k body -func (o *GetHTTPRequestRulesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetHTTPRequestRulesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getHttpRequestRulesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getHttpRequestRulesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetHTTPRequestRulesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetHTTPRequestRulesOKBody) UnmarshalBinary(b []byte) error { - var res GetHTTPRequestRulesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/http_request_rule/get_http_request_rules_parameters.go b/operations/http_request_rule/get_http_request_rules_parameters.go deleted file mode 100644 index 04e82558..00000000 --- a/operations/http_request_rule/get_http_request_rules_parameters.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetHTTPRequestRulesParams creates a new GetHTTPRequestRulesParams object -// no default values defined in spec. -func NewGetHTTPRequestRulesParams() GetHTTPRequestRulesParams { - - return GetHTTPRequestRulesParams{} -} - -// GetHTTPRequestRulesParams contains all the bound params for the get HTTP request rules operation -// typically these are obtained from a http.Request -// -// swagger:parameters getHTTPRequestRules -type GetHTTPRequestRulesParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetHTTPRequestRulesParams() beforehand. -func (o *GetHTTPRequestRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetHTTPRequestRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetHTTPRequestRulesParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetHTTPRequestRulesParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetHTTPRequestRulesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/http_request_rule/get_http_request_rules_responses.go b/operations/http_request_rule/get_http_request_rules_responses.go deleted file mode 100644 index e30ec953..00000000 --- a/operations/http_request_rule/get_http_request_rules_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetHTTPRequestRulesOKCode is the HTTP code returned for type GetHTTPRequestRulesOK -const GetHTTPRequestRulesOKCode int = 200 - -/*GetHTTPRequestRulesOK Successful operation - -swagger:response getHttpRequestRulesOK -*/ -type GetHTTPRequestRulesOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetHTTPRequestRulesOKBody `json:"body,omitempty"` -} - -// NewGetHTTPRequestRulesOK creates GetHTTPRequestRulesOK with default headers values -func NewGetHTTPRequestRulesOK() *GetHTTPRequestRulesOK { - - return &GetHTTPRequestRulesOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Http request rules o k response -func (o *GetHTTPRequestRulesOK) WithConfigurationVersion(configurationVersion int64) *GetHTTPRequestRulesOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Http request rules o k response -func (o *GetHTTPRequestRulesOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Http request rules o k response -func (o *GetHTTPRequestRulesOK) WithPayload(payload *GetHTTPRequestRulesOKBody) *GetHTTPRequestRulesOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Http request rules o k response -func (o *GetHTTPRequestRulesOK) SetPayload(payload *GetHTTPRequestRulesOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPRequestRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetHTTPRequestRulesDefault General Error - -swagger:response getHttpRequestRulesDefault -*/ -type GetHTTPRequestRulesDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetHTTPRequestRulesDefault creates GetHTTPRequestRulesDefault with default headers values -func NewGetHTTPRequestRulesDefault(code int) *GetHTTPRequestRulesDefault { - if code <= 0 { - code = 500 - } - - return &GetHTTPRequestRulesDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get HTTP request rules default response -func (o *GetHTTPRequestRulesDefault) WithStatusCode(code int) *GetHTTPRequestRulesDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get HTTP request rules default response -func (o *GetHTTPRequestRulesDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get HTTP request rules default response -func (o *GetHTTPRequestRulesDefault) WithConfigurationVersion(configurationVersion int64) *GetHTTPRequestRulesDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get HTTP request rules default response -func (o *GetHTTPRequestRulesDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get HTTP request rules default response -func (o *GetHTTPRequestRulesDefault) WithPayload(payload *models.Error) *GetHTTPRequestRulesDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get HTTP request rules default response -func (o *GetHTTPRequestRulesDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPRequestRulesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_request_rule/get_http_request_rules_urlbuilder.go b/operations/http_request_rule/get_http_request_rules_urlbuilder.go deleted file mode 100644 index 48f6a75b..00000000 --- a/operations/http_request_rule/get_http_request_rules_urlbuilder.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetHTTPRequestRulesURL generates an URL for the get HTTP request rules operation -type GetHTTPRequestRulesURL struct { - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPRequestRulesURL) WithBasePath(bp string) *GetHTTPRequestRulesURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPRequestRulesURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetHTTPRequestRulesURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_request_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetHTTPRequestRulesURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetHTTPRequestRulesURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetHTTPRequestRulesURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetHTTPRequestRulesURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetHTTPRequestRulesURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetHTTPRequestRulesURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_request_rule/replace_all_http_request_rule_backend.go b/operations/http_request_rule/replace_all_http_request_rule_backend.go new file mode 100644 index 00000000..09c00f13 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPRequestRuleBackendHandlerFunc turns a function with the right signature into a replace all HTTP request rule backend handler +type ReplaceAllHTTPRequestRuleBackendHandlerFunc func(ReplaceAllHTTPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPRequestRuleBackendHandlerFunc) Handle(params ReplaceAllHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPRequestRuleBackendHandler interface for that can handle valid replace all HTTP request rule backend params +type ReplaceAllHTTPRequestRuleBackendHandler interface { + Handle(ReplaceAllHTTPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPRequestRuleBackend creates a new http.Handler for the replace all HTTP request rule backend operation +func NewReplaceAllHTTPRequestRuleBackend(ctx *middleware.Context, handler ReplaceAllHTTPRequestRuleBackendHandler) *ReplaceAllHTTPRequestRuleBackend { + return &ReplaceAllHTTPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPRequestRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_request_rules HTTPRequestRule replaceAllHttpRequestRuleBackend + +# Replace an HTTP Request Rule list + +Replaces a whole list of HTTP Request Rules with the list given in parameter +*/ +type ReplaceAllHTTPRequestRuleBackend struct { + Context *middleware.Context + Handler ReplaceAllHTTPRequestRuleBackendHandler +} + +func (o *ReplaceAllHTTPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_backend_parameters.go b/operations/http_request_rule/replace_all_http_request_rule_backend_parameters.go new file mode 100644 index 00000000..9b266644 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPRequestRuleBackendParams creates a new ReplaceAllHTTPRequestRuleBackendParams object +// with the default values initialized. +func NewReplaceAllHTTPRequestRuleBackendParams() ReplaceAllHTTPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPRequestRuleBackendParams contains all the bound params for the replace all HTTP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPRequestRuleBackend +type ReplaceAllHTTPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPRequestRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPRequestRuleBackendParams() beforehand. +func (o *ReplaceAllHTTPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_backend_responses.go b/operations/http_request_rule/replace_all_http_request_rule_backend_responses.go new file mode 100644 index 00000000..87cebd7e --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPRequestRuleBackendOKCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleBackendOK +const ReplaceAllHTTPRequestRuleBackendOKCode int = 200 + +/* +ReplaceAllHTTPRequestRuleBackendOK All HTTP Request Rule lines replaced + +swagger:response replaceAllHttpRequestRuleBackendOK +*/ +type ReplaceAllHTTPRequestRuleBackendOK struct { + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleBackendOK creates ReplaceAllHTTPRequestRuleBackendOK with default headers values +func NewReplaceAllHTTPRequestRuleBackendOK() *ReplaceAllHTTPRequestRuleBackendOK { + + return &ReplaceAllHTTPRequestRuleBackendOK{} +} + +// WithPayload adds the payload to the replace all Http request rule backend o k response +func (o *ReplaceAllHTTPRequestRuleBackendOK) WithPayload(payload models.HTTPRequestRules) *ReplaceAllHTTPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule backend o k response +func (o *ReplaceAllHTTPRequestRuleBackendOK) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPRequestRuleBackendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleBackendAccepted +const ReplaceAllHTTPRequestRuleBackendAcceptedCode int = 202 + +/* +ReplaceAllHTTPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpRequestRuleBackendAccepted +*/ +type ReplaceAllHTTPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleBackendAccepted creates ReplaceAllHTTPRequestRuleBackendAccepted with default headers values +func NewReplaceAllHTTPRequestRuleBackendAccepted() *ReplaceAllHTTPRequestRuleBackendAccepted { + + return &ReplaceAllHTTPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http request rule backend accepted response +func (o *ReplaceAllHTTPRequestRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http request rule backend accepted response +func (o *ReplaceAllHTTPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http request rule backend accepted response +func (o *ReplaceAllHTTPRequestRuleBackendAccepted) WithPayload(payload models.HTTPRequestRules) *ReplaceAllHTTPRequestRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule backend accepted response +func (o *ReplaceAllHTTPRequestRuleBackendAccepted) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPRequestRuleBackendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleBackendBadRequest +const ReplaceAllHTTPRequestRuleBackendBadRequestCode int = 400 + +/* +ReplaceAllHTTPRequestRuleBackendBadRequest Bad request + +swagger:response replaceAllHttpRequestRuleBackendBadRequest +*/ +type ReplaceAllHTTPRequestRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleBackendBadRequest creates ReplaceAllHTTPRequestRuleBackendBadRequest with default headers values +func NewReplaceAllHTTPRequestRuleBackendBadRequest() *ReplaceAllHTTPRequestRuleBackendBadRequest { + + return &ReplaceAllHTTPRequestRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http request rule backend bad request response +func (o *ReplaceAllHTTPRequestRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPRequestRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http request rule backend bad request response +func (o *ReplaceAllHTTPRequestRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http request rule backend bad request response +func (o *ReplaceAllHTTPRequestRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPRequestRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule backend bad request response +func (o *ReplaceAllHTTPRequestRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPRequestRuleBackendDefault General Error + +swagger:response replaceAllHttpRequestRuleBackendDefault +*/ +type ReplaceAllHTTPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleBackendDefault creates ReplaceAllHTTPRequestRuleBackendDefault with default headers values +func NewReplaceAllHTTPRequestRuleBackendDefault(code int) *ReplaceAllHTTPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP request rule backend default response +func (o *ReplaceAllHTTPRequestRuleBackendDefault) WithStatusCode(code int) *ReplaceAllHTTPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP request rule backend default response +func (o *ReplaceAllHTTPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP request rule backend default response +func (o *ReplaceAllHTTPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP request rule backend default response +func (o *ReplaceAllHTTPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP request rule backend default response +func (o *ReplaceAllHTTPRequestRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP request rule backend default response +func (o *ReplaceAllHTTPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_backend_urlbuilder.go b/operations/http_request_rule/replace_all_http_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..71cbaa23 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPRequestRuleBackendURL generates an URL for the replace all HTTP request rule backend operation +type ReplaceAllHTTPRequestRuleBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPRequestRuleBackendURL) WithBasePath(bp string) *ReplaceAllHTTPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_defaults.go b/operations/http_request_rule/replace_all_http_request_rule_defaults.go new file mode 100644 index 00000000..b4411d7d --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a replace all HTTP request rule defaults handler +type ReplaceAllHTTPRequestRuleDefaultsHandlerFunc func(ReplaceAllHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPRequestRuleDefaultsHandlerFunc) Handle(params ReplaceAllHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPRequestRuleDefaultsHandler interface for that can handle valid replace all HTTP request rule defaults params +type ReplaceAllHTTPRequestRuleDefaultsHandler interface { + Handle(ReplaceAllHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPRequestRuleDefaults creates a new http.Handler for the replace all HTTP request rule defaults operation +func NewReplaceAllHTTPRequestRuleDefaults(ctx *middleware.Context, handler ReplaceAllHTTPRequestRuleDefaultsHandler) *ReplaceAllHTTPRequestRuleDefaults { + return &ReplaceAllHTTPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPRequestRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_request_rules HTTPRequestRule replaceAllHttpRequestRuleDefaults + +# Replace an HTTP Request Rule list + +Replaces a whole list of HTTP Request Rules with the list given in parameter +*/ +type ReplaceAllHTTPRequestRuleDefaults struct { + Context *middleware.Context + Handler ReplaceAllHTTPRequestRuleDefaultsHandler +} + +func (o *ReplaceAllHTTPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_defaults_parameters.go b/operations/http_request_rule/replace_all_http_request_rule_defaults_parameters.go new file mode 100644 index 00000000..74433bc2 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPRequestRuleDefaultsParams creates a new ReplaceAllHTTPRequestRuleDefaultsParams object +// with the default values initialized. +func NewReplaceAllHTTPRequestRuleDefaultsParams() ReplaceAllHTTPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPRequestRuleDefaultsParams contains all the bound params for the replace all HTTP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPRequestRuleDefaults +type ReplaceAllHTTPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPRequestRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPRequestRuleDefaultsParams() beforehand. +func (o *ReplaceAllHTTPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_defaults_responses.go b/operations/http_request_rule/replace_all_http_request_rule_defaults_responses.go new file mode 100644 index 00000000..53c3a2c7 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPRequestRuleDefaultsOKCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleDefaultsOK +const ReplaceAllHTTPRequestRuleDefaultsOKCode int = 200 + +/* +ReplaceAllHTTPRequestRuleDefaultsOK All HTTP Request Rule lines replaced + +swagger:response replaceAllHttpRequestRuleDefaultsOK +*/ +type ReplaceAllHTTPRequestRuleDefaultsOK struct { + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleDefaultsOK creates ReplaceAllHTTPRequestRuleDefaultsOK with default headers values +func NewReplaceAllHTTPRequestRuleDefaultsOK() *ReplaceAllHTTPRequestRuleDefaultsOK { + + return &ReplaceAllHTTPRequestRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Http request rule defaults o k response +func (o *ReplaceAllHTTPRequestRuleDefaultsOK) WithPayload(payload models.HTTPRequestRules) *ReplaceAllHTTPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule defaults o k response +func (o *ReplaceAllHTTPRequestRuleDefaultsOK) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleDefaultsAccepted +const ReplaceAllHTTPRequestRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceAllHTTPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpRequestRuleDefaultsAccepted +*/ +type ReplaceAllHTTPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleDefaultsAccepted creates ReplaceAllHTTPRequestRuleDefaultsAccepted with default headers values +func NewReplaceAllHTTPRequestRuleDefaultsAccepted() *ReplaceAllHTTPRequestRuleDefaultsAccepted { + + return &ReplaceAllHTTPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http request rule defaults accepted response +func (o *ReplaceAllHTTPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http request rule defaults accepted response +func (o *ReplaceAllHTTPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http request rule defaults accepted response +func (o *ReplaceAllHTTPRequestRuleDefaultsAccepted) WithPayload(payload models.HTTPRequestRules) *ReplaceAllHTTPRequestRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule defaults accepted response +func (o *ReplaceAllHTTPRequestRuleDefaultsAccepted) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPRequestRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleDefaultsBadRequest +const ReplaceAllHTTPRequestRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceAllHTTPRequestRuleDefaultsBadRequest Bad request + +swagger:response replaceAllHttpRequestRuleDefaultsBadRequest +*/ +type ReplaceAllHTTPRequestRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleDefaultsBadRequest creates ReplaceAllHTTPRequestRuleDefaultsBadRequest with default headers values +func NewReplaceAllHTTPRequestRuleDefaultsBadRequest() *ReplaceAllHTTPRequestRuleDefaultsBadRequest { + + return &ReplaceAllHTTPRequestRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http request rule defaults bad request response +func (o *ReplaceAllHTTPRequestRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPRequestRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http request rule defaults bad request response +func (o *ReplaceAllHTTPRequestRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http request rule defaults bad request response +func (o *ReplaceAllHTTPRequestRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPRequestRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule defaults bad request response +func (o *ReplaceAllHTTPRequestRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPRequestRuleDefaultsDefault General Error + +swagger:response replaceAllHttpRequestRuleDefaultsDefault +*/ +type ReplaceAllHTTPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleDefaultsDefault creates ReplaceAllHTTPRequestRuleDefaultsDefault with default headers values +func NewReplaceAllHTTPRequestRuleDefaultsDefault(code int) *ReplaceAllHTTPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP request rule defaults default response +func (o *ReplaceAllHTTPRequestRuleDefaultsDefault) WithStatusCode(code int) *ReplaceAllHTTPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP request rule defaults default response +func (o *ReplaceAllHTTPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP request rule defaults default response +func (o *ReplaceAllHTTPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP request rule defaults default response +func (o *ReplaceAllHTTPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP request rule defaults default response +func (o *ReplaceAllHTTPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP request rule defaults default response +func (o *ReplaceAllHTTPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_defaults_urlbuilder.go b/operations/http_request_rule/replace_all_http_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..436bb2c7 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPRequestRuleDefaultsURL generates an URL for the replace all HTTP request rule defaults operation +type ReplaceAllHTTPRequestRuleDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPRequestRuleDefaultsURL) WithBasePath(bp string) *ReplaceAllHTTPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_frontend.go b/operations/http_request_rule/replace_all_http_request_rule_frontend.go new file mode 100644 index 00000000..fd804c5e --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPRequestRuleFrontendHandlerFunc turns a function with the right signature into a replace all HTTP request rule frontend handler +type ReplaceAllHTTPRequestRuleFrontendHandlerFunc func(ReplaceAllHTTPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPRequestRuleFrontendHandlerFunc) Handle(params ReplaceAllHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPRequestRuleFrontendHandler interface for that can handle valid replace all HTTP request rule frontend params +type ReplaceAllHTTPRequestRuleFrontendHandler interface { + Handle(ReplaceAllHTTPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPRequestRuleFrontend creates a new http.Handler for the replace all HTTP request rule frontend operation +func NewReplaceAllHTTPRequestRuleFrontend(ctx *middleware.Context, handler ReplaceAllHTTPRequestRuleFrontendHandler) *ReplaceAllHTTPRequestRuleFrontend { + return &ReplaceAllHTTPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPRequestRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_request_rules HTTPRequestRule replaceAllHttpRequestRuleFrontend + +# Replace an HTTP Request Rule list + +Replaces a whole list of HTTP Request Rules with the list given in parameter +*/ +type ReplaceAllHTTPRequestRuleFrontend struct { + Context *middleware.Context + Handler ReplaceAllHTTPRequestRuleFrontendHandler +} + +func (o *ReplaceAllHTTPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_frontend_parameters.go b/operations/http_request_rule/replace_all_http_request_rule_frontend_parameters.go new file mode 100644 index 00000000..44460cf2 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPRequestRuleFrontendParams creates a new ReplaceAllHTTPRequestRuleFrontendParams object +// with the default values initialized. +func NewReplaceAllHTTPRequestRuleFrontendParams() ReplaceAllHTTPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPRequestRuleFrontendParams contains all the bound params for the replace all HTTP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPRequestRuleFrontend +type ReplaceAllHTTPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPRequestRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPRequestRuleFrontendParams() beforehand. +func (o *ReplaceAllHTTPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_frontend_responses.go b/operations/http_request_rule/replace_all_http_request_rule_frontend_responses.go new file mode 100644 index 00000000..68366081 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPRequestRuleFrontendOKCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleFrontendOK +const ReplaceAllHTTPRequestRuleFrontendOKCode int = 200 + +/* +ReplaceAllHTTPRequestRuleFrontendOK All HTTP Request Rule lines replaced + +swagger:response replaceAllHttpRequestRuleFrontendOK +*/ +type ReplaceAllHTTPRequestRuleFrontendOK struct { + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleFrontendOK creates ReplaceAllHTTPRequestRuleFrontendOK with default headers values +func NewReplaceAllHTTPRequestRuleFrontendOK() *ReplaceAllHTTPRequestRuleFrontendOK { + + return &ReplaceAllHTTPRequestRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace all Http request rule frontend o k response +func (o *ReplaceAllHTTPRequestRuleFrontendOK) WithPayload(payload models.HTTPRequestRules) *ReplaceAllHTTPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule frontend o k response +func (o *ReplaceAllHTTPRequestRuleFrontendOK) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPRequestRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleFrontendAccepted +const ReplaceAllHTTPRequestRuleFrontendAcceptedCode int = 202 + +/* +ReplaceAllHTTPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpRequestRuleFrontendAccepted +*/ +type ReplaceAllHTTPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleFrontendAccepted creates ReplaceAllHTTPRequestRuleFrontendAccepted with default headers values +func NewReplaceAllHTTPRequestRuleFrontendAccepted() *ReplaceAllHTTPRequestRuleFrontendAccepted { + + return &ReplaceAllHTTPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http request rule frontend accepted response +func (o *ReplaceAllHTTPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http request rule frontend accepted response +func (o *ReplaceAllHTTPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http request rule frontend accepted response +func (o *ReplaceAllHTTPRequestRuleFrontendAccepted) WithPayload(payload models.HTTPRequestRules) *ReplaceAllHTTPRequestRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule frontend accepted response +func (o *ReplaceAllHTTPRequestRuleFrontendAccepted) SetPayload(payload models.HTTPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPRequestRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPRequestRuleFrontendBadRequest +const ReplaceAllHTTPRequestRuleFrontendBadRequestCode int = 400 + +/* +ReplaceAllHTTPRequestRuleFrontendBadRequest Bad request + +swagger:response replaceAllHttpRequestRuleFrontendBadRequest +*/ +type ReplaceAllHTTPRequestRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleFrontendBadRequest creates ReplaceAllHTTPRequestRuleFrontendBadRequest with default headers values +func NewReplaceAllHTTPRequestRuleFrontendBadRequest() *ReplaceAllHTTPRequestRuleFrontendBadRequest { + + return &ReplaceAllHTTPRequestRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http request rule frontend bad request response +func (o *ReplaceAllHTTPRequestRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPRequestRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http request rule frontend bad request response +func (o *ReplaceAllHTTPRequestRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http request rule frontend bad request response +func (o *ReplaceAllHTTPRequestRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPRequestRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http request rule frontend bad request response +func (o *ReplaceAllHTTPRequestRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPRequestRuleFrontendDefault General Error + +swagger:response replaceAllHttpRequestRuleFrontendDefault +*/ +type ReplaceAllHTTPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPRequestRuleFrontendDefault creates ReplaceAllHTTPRequestRuleFrontendDefault with default headers values +func NewReplaceAllHTTPRequestRuleFrontendDefault(code int) *ReplaceAllHTTPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP request rule frontend default response +func (o *ReplaceAllHTTPRequestRuleFrontendDefault) WithStatusCode(code int) *ReplaceAllHTTPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP request rule frontend default response +func (o *ReplaceAllHTTPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP request rule frontend default response +func (o *ReplaceAllHTTPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP request rule frontend default response +func (o *ReplaceAllHTTPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP request rule frontend default response +func (o *ReplaceAllHTTPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP request rule frontend default response +func (o *ReplaceAllHTTPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/replace_all_http_request_rule_frontend_urlbuilder.go b/operations/http_request_rule/replace_all_http_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..91d6abf3 --- /dev/null +++ b/operations/http_request_rule/replace_all_http_request_rule_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPRequestRuleFrontendURL generates an URL for the replace all HTTP request rule frontend operation +type ReplaceAllHTTPRequestRuleFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPRequestRuleFrontendURL) WithBasePath(bp string) *ReplaceAllHTTPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/replace_http_request_rule.go b/operations/http_request_rule/replace_http_request_rule.go deleted file mode 100644 index 3b48a81d..00000000 --- a/operations/http_request_rule/replace_http_request_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceHTTPRequestRuleHandlerFunc turns a function with the right signature into a replace HTTP request rule handler -type ReplaceHTTPRequestRuleHandlerFunc func(ReplaceHTTPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceHTTPRequestRuleHandlerFunc) Handle(params ReplaceHTTPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceHTTPRequestRuleHandler interface for that can handle valid replace HTTP request rule params -type ReplaceHTTPRequestRuleHandler interface { - Handle(ReplaceHTTPRequestRuleParams, interface{}) middleware.Responder -} - -// NewReplaceHTTPRequestRule creates a new http.Handler for the replace HTTP request rule operation -func NewReplaceHTTPRequestRule(ctx *middleware.Context, handler ReplaceHTTPRequestRuleHandler) *ReplaceHTTPRequestRule { - return &ReplaceHTTPRequestRule{Context: ctx, Handler: handler} -} - -/*ReplaceHTTPRequestRule swagger:route PUT /services/haproxy/configuration/http_request_rules/{id} HTTPRequestRule replaceHttpRequestRule - -Replace a HTTP Request Rule - -Replaces a HTTP Request Rule configuration by it's ID in the specified parent. - -*/ -type ReplaceHTTPRequestRule struct { - Context *middleware.Context - Handler ReplaceHTTPRequestRuleHandler -} - -func (o *ReplaceHTTPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceHTTPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/http_request_rule/replace_http_request_rule_backend.go b/operations/http_request_rule/replace_http_request_rule_backend.go new file mode 100644 index 00000000..15196888 --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPRequestRuleBackendHandlerFunc turns a function with the right signature into a replace HTTP request rule backend handler +type ReplaceHTTPRequestRuleBackendHandlerFunc func(ReplaceHTTPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPRequestRuleBackendHandlerFunc) Handle(params ReplaceHTTPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPRequestRuleBackendHandler interface for that can handle valid replace HTTP request rule backend params +type ReplaceHTTPRequestRuleBackendHandler interface { + Handle(ReplaceHTTPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPRequestRuleBackend creates a new http.Handler for the replace HTTP request rule backend operation +func NewReplaceHTTPRequestRuleBackend(ctx *middleware.Context, handler ReplaceHTTPRequestRuleBackendHandler) *ReplaceHTTPRequestRuleBackend { + return &ReplaceHTTPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPRequestRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index} HTTPRequestRule replaceHttpRequestRuleBackend + +# Replace a HTTP Request Rule + +Replaces a HTTP Request Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPRequestRuleBackend struct { + Context *middleware.Context + Handler ReplaceHTTPRequestRuleBackendHandler +} + +func (o *ReplaceHTTPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/replace_http_request_rule_backend_parameters.go b/operations/http_request_rule/replace_http_request_rule_backend_parameters.go new file mode 100644 index 00000000..167200cc --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPRequestRuleBackendParams creates a new ReplaceHTTPRequestRuleBackendParams object +// with the default values initialized. +func NewReplaceHTTPRequestRuleBackendParams() ReplaceHTTPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPRequestRuleBackendParams contains all the bound params for the replace HTTP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPRequestRuleBackend +type ReplaceHTTPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPRequestRuleBackendParams() beforehand. +func (o *ReplaceHTTPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/replace_http_request_rule_backend_responses.go b/operations/http_request_rule/replace_http_request_rule_backend_responses.go new file mode 100644 index 00000000..663d443d --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPRequestRuleBackendOKCode is the HTTP code returned for type ReplaceHTTPRequestRuleBackendOK +const ReplaceHTTPRequestRuleBackendOKCode int = 200 + +/* +ReplaceHTTPRequestRuleBackendOK HTTP Request Rule replaced + +swagger:response replaceHttpRequestRuleBackendOK +*/ +type ReplaceHTTPRequestRuleBackendOK struct { + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleBackendOK creates ReplaceHTTPRequestRuleBackendOK with default headers values +func NewReplaceHTTPRequestRuleBackendOK() *ReplaceHTTPRequestRuleBackendOK { + + return &ReplaceHTTPRequestRuleBackendOK{} +} + +// WithPayload adds the payload to the replace Http request rule backend o k response +func (o *ReplaceHTTPRequestRuleBackendOK) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule backend o k response +func (o *ReplaceHTTPRequestRuleBackendOK) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleBackendAcceptedCode is the HTTP code returned for type ReplaceHTTPRequestRuleBackendAccepted +const ReplaceHTTPRequestRuleBackendAcceptedCode int = 202 + +/* +ReplaceHTTPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpRequestRuleBackendAccepted +*/ +type ReplaceHTTPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleBackendAccepted creates ReplaceHTTPRequestRuleBackendAccepted with default headers values +func NewReplaceHTTPRequestRuleBackendAccepted() *ReplaceHTTPRequestRuleBackendAccepted { + + return &ReplaceHTTPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http request rule backend accepted response +func (o *ReplaceHTTPRequestRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceHTTPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http request rule backend accepted response +func (o *ReplaceHTTPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http request rule backend accepted response +func (o *ReplaceHTTPRequestRuleBackendAccepted) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule backend accepted response +func (o *ReplaceHTTPRequestRuleBackendAccepted) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleBackendBadRequestCode is the HTTP code returned for type ReplaceHTTPRequestRuleBackendBadRequest +const ReplaceHTTPRequestRuleBackendBadRequestCode int = 400 + +/* +ReplaceHTTPRequestRuleBackendBadRequest Bad request + +swagger:response replaceHttpRequestRuleBackendBadRequest +*/ +type ReplaceHTTPRequestRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleBackendBadRequest creates ReplaceHTTPRequestRuleBackendBadRequest with default headers values +func NewReplaceHTTPRequestRuleBackendBadRequest() *ReplaceHTTPRequestRuleBackendBadRequest { + + return &ReplaceHTTPRequestRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http request rule backend bad request response +func (o *ReplaceHTTPRequestRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http request rule backend bad request response +func (o *ReplaceHTTPRequestRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http request rule backend bad request response +func (o *ReplaceHTTPRequestRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule backend bad request response +func (o *ReplaceHTTPRequestRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleBackendNotFoundCode is the HTTP code returned for type ReplaceHTTPRequestRuleBackendNotFound +const ReplaceHTTPRequestRuleBackendNotFoundCode int = 404 + +/* +ReplaceHTTPRequestRuleBackendNotFound The specified resource was not found + +swagger:response replaceHttpRequestRuleBackendNotFound +*/ +type ReplaceHTTPRequestRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleBackendNotFound creates ReplaceHTTPRequestRuleBackendNotFound with default headers values +func NewReplaceHTTPRequestRuleBackendNotFound() *ReplaceHTTPRequestRuleBackendNotFound { + + return &ReplaceHTTPRequestRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http request rule backend not found response +func (o *ReplaceHTTPRequestRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http request rule backend not found response +func (o *ReplaceHTTPRequestRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http request rule backend not found response +func (o *ReplaceHTTPRequestRuleBackendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule backend not found response +func (o *ReplaceHTTPRequestRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPRequestRuleBackendDefault General Error + +swagger:response replaceHttpRequestRuleBackendDefault +*/ +type ReplaceHTTPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleBackendDefault creates ReplaceHTTPRequestRuleBackendDefault with default headers values +func NewReplaceHTTPRequestRuleBackendDefault(code int) *ReplaceHTTPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP request rule backend default response +func (o *ReplaceHTTPRequestRuleBackendDefault) WithStatusCode(code int) *ReplaceHTTPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP request rule backend default response +func (o *ReplaceHTTPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP request rule backend default response +func (o *ReplaceHTTPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP request rule backend default response +func (o *ReplaceHTTPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP request rule backend default response +func (o *ReplaceHTTPRequestRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP request rule backend default response +func (o *ReplaceHTTPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/replace_http_request_rule_backend_urlbuilder.go b/operations/http_request_rule/replace_http_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..1cbccc97 --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPRequestRuleBackendURL generates an URL for the replace HTTP request rule backend operation +type ReplaceHTTPRequestRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPRequestRuleBackendURL) WithBasePath(bp string) *ReplaceHTTPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/replace_http_request_rule_defaults.go b/operations/http_request_rule/replace_http_request_rule_defaults.go new file mode 100644 index 00000000..fd1b501e --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a replace HTTP request rule defaults handler +type ReplaceHTTPRequestRuleDefaultsHandlerFunc func(ReplaceHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPRequestRuleDefaultsHandlerFunc) Handle(params ReplaceHTTPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPRequestRuleDefaultsHandler interface for that can handle valid replace HTTP request rule defaults params +type ReplaceHTTPRequestRuleDefaultsHandler interface { + Handle(ReplaceHTTPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPRequestRuleDefaults creates a new http.Handler for the replace HTTP request rule defaults operation +func NewReplaceHTTPRequestRuleDefaults(ctx *middleware.Context, handler ReplaceHTTPRequestRuleDefaultsHandler) *ReplaceHTTPRequestRuleDefaults { + return &ReplaceHTTPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPRequestRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index} HTTPRequestRule replaceHttpRequestRuleDefaults + +# Replace a HTTP Request Rule + +Replaces a HTTP Request Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPRequestRuleDefaults struct { + Context *middleware.Context + Handler ReplaceHTTPRequestRuleDefaultsHandler +} + +func (o *ReplaceHTTPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/replace_http_request_rule_defaults_parameters.go b/operations/http_request_rule/replace_http_request_rule_defaults_parameters.go new file mode 100644 index 00000000..4aca19cc --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPRequestRuleDefaultsParams creates a new ReplaceHTTPRequestRuleDefaultsParams object +// with the default values initialized. +func NewReplaceHTTPRequestRuleDefaultsParams() ReplaceHTTPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPRequestRuleDefaultsParams contains all the bound params for the replace HTTP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPRequestRuleDefaults +type ReplaceHTTPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPRequestRuleDefaultsParams() beforehand. +func (o *ReplaceHTTPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/replace_http_request_rule_defaults_responses.go b/operations/http_request_rule/replace_http_request_rule_defaults_responses.go new file mode 100644 index 00000000..e1c62a02 --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPRequestRuleDefaultsOKCode is the HTTP code returned for type ReplaceHTTPRequestRuleDefaultsOK +const ReplaceHTTPRequestRuleDefaultsOKCode int = 200 + +/* +ReplaceHTTPRequestRuleDefaultsOK HTTP Request Rule replaced + +swagger:response replaceHttpRequestRuleDefaultsOK +*/ +type ReplaceHTTPRequestRuleDefaultsOK struct { + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleDefaultsOK creates ReplaceHTTPRequestRuleDefaultsOK with default headers values +func NewReplaceHTTPRequestRuleDefaultsOK() *ReplaceHTTPRequestRuleDefaultsOK { + + return &ReplaceHTTPRequestRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace Http request rule defaults o k response +func (o *ReplaceHTTPRequestRuleDefaultsOK) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule defaults o k response +func (o *ReplaceHTTPRequestRuleDefaultsOK) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceHTTPRequestRuleDefaultsAccepted +const ReplaceHTTPRequestRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceHTTPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpRequestRuleDefaultsAccepted +*/ +type ReplaceHTTPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleDefaultsAccepted creates ReplaceHTTPRequestRuleDefaultsAccepted with default headers values +func NewReplaceHTTPRequestRuleDefaultsAccepted() *ReplaceHTTPRequestRuleDefaultsAccepted { + + return &ReplaceHTTPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http request rule defaults accepted response +func (o *ReplaceHTTPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceHTTPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http request rule defaults accepted response +func (o *ReplaceHTTPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http request rule defaults accepted response +func (o *ReplaceHTTPRequestRuleDefaultsAccepted) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule defaults accepted response +func (o *ReplaceHTTPRequestRuleDefaultsAccepted) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceHTTPRequestRuleDefaultsBadRequest +const ReplaceHTTPRequestRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceHTTPRequestRuleDefaultsBadRequest Bad request + +swagger:response replaceHttpRequestRuleDefaultsBadRequest +*/ +type ReplaceHTTPRequestRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleDefaultsBadRequest creates ReplaceHTTPRequestRuleDefaultsBadRequest with default headers values +func NewReplaceHTTPRequestRuleDefaultsBadRequest() *ReplaceHTTPRequestRuleDefaultsBadRequest { + + return &ReplaceHTTPRequestRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http request rule defaults bad request response +func (o *ReplaceHTTPRequestRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http request rule defaults bad request response +func (o *ReplaceHTTPRequestRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http request rule defaults bad request response +func (o *ReplaceHTTPRequestRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule defaults bad request response +func (o *ReplaceHTTPRequestRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleDefaultsNotFoundCode is the HTTP code returned for type ReplaceHTTPRequestRuleDefaultsNotFound +const ReplaceHTTPRequestRuleDefaultsNotFoundCode int = 404 + +/* +ReplaceHTTPRequestRuleDefaultsNotFound The specified resource was not found + +swagger:response replaceHttpRequestRuleDefaultsNotFound +*/ +type ReplaceHTTPRequestRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleDefaultsNotFound creates ReplaceHTTPRequestRuleDefaultsNotFound with default headers values +func NewReplaceHTTPRequestRuleDefaultsNotFound() *ReplaceHTTPRequestRuleDefaultsNotFound { + + return &ReplaceHTTPRequestRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http request rule defaults not found response +func (o *ReplaceHTTPRequestRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http request rule defaults not found response +func (o *ReplaceHTTPRequestRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http request rule defaults not found response +func (o *ReplaceHTTPRequestRuleDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule defaults not found response +func (o *ReplaceHTTPRequestRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPRequestRuleDefaultsDefault General Error + +swagger:response replaceHttpRequestRuleDefaultsDefault +*/ +type ReplaceHTTPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleDefaultsDefault creates ReplaceHTTPRequestRuleDefaultsDefault with default headers values +func NewReplaceHTTPRequestRuleDefaultsDefault(code int) *ReplaceHTTPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP request rule defaults default response +func (o *ReplaceHTTPRequestRuleDefaultsDefault) WithStatusCode(code int) *ReplaceHTTPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP request rule defaults default response +func (o *ReplaceHTTPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP request rule defaults default response +func (o *ReplaceHTTPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP request rule defaults default response +func (o *ReplaceHTTPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP request rule defaults default response +func (o *ReplaceHTTPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP request rule defaults default response +func (o *ReplaceHTTPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/replace_http_request_rule_defaults_urlbuilder.go b/operations/http_request_rule/replace_http_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..d6d3f739 --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPRequestRuleDefaultsURL generates an URL for the replace HTTP request rule defaults operation +type ReplaceHTTPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPRequestRuleDefaultsURL) WithBasePath(bp string) *ReplaceHTTPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/replace_http_request_rule_frontend.go b/operations/http_request_rule/replace_http_request_rule_frontend.go new file mode 100644 index 00000000..0098a65c --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPRequestRuleFrontendHandlerFunc turns a function with the right signature into a replace HTTP request rule frontend handler +type ReplaceHTTPRequestRuleFrontendHandlerFunc func(ReplaceHTTPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPRequestRuleFrontendHandlerFunc) Handle(params ReplaceHTTPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPRequestRuleFrontendHandler interface for that can handle valid replace HTTP request rule frontend params +type ReplaceHTTPRequestRuleFrontendHandler interface { + Handle(ReplaceHTTPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPRequestRuleFrontend creates a new http.Handler for the replace HTTP request rule frontend operation +func NewReplaceHTTPRequestRuleFrontend(ctx *middleware.Context, handler ReplaceHTTPRequestRuleFrontendHandler) *ReplaceHTTPRequestRuleFrontend { + return &ReplaceHTTPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPRequestRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index} HTTPRequestRule replaceHttpRequestRuleFrontend + +# Replace a HTTP Request Rule + +Replaces a HTTP Request Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPRequestRuleFrontend struct { + Context *middleware.Context + Handler ReplaceHTTPRequestRuleFrontendHandler +} + +func (o *ReplaceHTTPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_request_rule/replace_http_request_rule_frontend_parameters.go b/operations/http_request_rule/replace_http_request_rule_frontend_parameters.go new file mode 100644 index 00000000..e84ee71f --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPRequestRuleFrontendParams creates a new ReplaceHTTPRequestRuleFrontendParams object +// with the default values initialized. +func NewReplaceHTTPRequestRuleFrontendParams() ReplaceHTTPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPRequestRuleFrontendParams contains all the bound params for the replace HTTP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPRequestRuleFrontend +type ReplaceHTTPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPRequestRuleFrontendParams() beforehand. +func (o *ReplaceHTTPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_request_rule/replace_http_request_rule_frontend_responses.go b/operations/http_request_rule/replace_http_request_rule_frontend_responses.go new file mode 100644 index 00000000..1f93abb2 --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPRequestRuleFrontendOKCode is the HTTP code returned for type ReplaceHTTPRequestRuleFrontendOK +const ReplaceHTTPRequestRuleFrontendOKCode int = 200 + +/* +ReplaceHTTPRequestRuleFrontendOK HTTP Request Rule replaced + +swagger:response replaceHttpRequestRuleFrontendOK +*/ +type ReplaceHTTPRequestRuleFrontendOK struct { + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleFrontendOK creates ReplaceHTTPRequestRuleFrontendOK with default headers values +func NewReplaceHTTPRequestRuleFrontendOK() *ReplaceHTTPRequestRuleFrontendOK { + + return &ReplaceHTTPRequestRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace Http request rule frontend o k response +func (o *ReplaceHTTPRequestRuleFrontendOK) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule frontend o k response +func (o *ReplaceHTTPRequestRuleFrontendOK) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceHTTPRequestRuleFrontendAccepted +const ReplaceHTTPRequestRuleFrontendAcceptedCode int = 202 + +/* +ReplaceHTTPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpRequestRuleFrontendAccepted +*/ +type ReplaceHTTPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPRequestRule `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleFrontendAccepted creates ReplaceHTTPRequestRuleFrontendAccepted with default headers values +func NewReplaceHTTPRequestRuleFrontendAccepted() *ReplaceHTTPRequestRuleFrontendAccepted { + + return &ReplaceHTTPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http request rule frontend accepted response +func (o *ReplaceHTTPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceHTTPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http request rule frontend accepted response +func (o *ReplaceHTTPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http request rule frontend accepted response +func (o *ReplaceHTTPRequestRuleFrontendAccepted) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule frontend accepted response +func (o *ReplaceHTTPRequestRuleFrontendAccepted) SetPayload(payload *models.HTTPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceHTTPRequestRuleFrontendBadRequest +const ReplaceHTTPRequestRuleFrontendBadRequestCode int = 400 + +/* +ReplaceHTTPRequestRuleFrontendBadRequest Bad request + +swagger:response replaceHttpRequestRuleFrontendBadRequest +*/ +type ReplaceHTTPRequestRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleFrontendBadRequest creates ReplaceHTTPRequestRuleFrontendBadRequest with default headers values +func NewReplaceHTTPRequestRuleFrontendBadRequest() *ReplaceHTTPRequestRuleFrontendBadRequest { + + return &ReplaceHTTPRequestRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http request rule frontend bad request response +func (o *ReplaceHTTPRequestRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http request rule frontend bad request response +func (o *ReplaceHTTPRequestRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http request rule frontend bad request response +func (o *ReplaceHTTPRequestRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule frontend bad request response +func (o *ReplaceHTTPRequestRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPRequestRuleFrontendNotFoundCode is the HTTP code returned for type ReplaceHTTPRequestRuleFrontendNotFound +const ReplaceHTTPRequestRuleFrontendNotFoundCode int = 404 + +/* +ReplaceHTTPRequestRuleFrontendNotFound The specified resource was not found + +swagger:response replaceHttpRequestRuleFrontendNotFound +*/ +type ReplaceHTTPRequestRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleFrontendNotFound creates ReplaceHTTPRequestRuleFrontendNotFound with default headers values +func NewReplaceHTTPRequestRuleFrontendNotFound() *ReplaceHTTPRequestRuleFrontendNotFound { + + return &ReplaceHTTPRequestRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http request rule frontend not found response +func (o *ReplaceHTTPRequestRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http request rule frontend not found response +func (o *ReplaceHTTPRequestRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http request rule frontend not found response +func (o *ReplaceHTTPRequestRuleFrontendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http request rule frontend not found response +func (o *ReplaceHTTPRequestRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPRequestRuleFrontendDefault General Error + +swagger:response replaceHttpRequestRuleFrontendDefault +*/ +type ReplaceHTTPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPRequestRuleFrontendDefault creates ReplaceHTTPRequestRuleFrontendDefault with default headers values +func NewReplaceHTTPRequestRuleFrontendDefault(code int) *ReplaceHTTPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP request rule frontend default response +func (o *ReplaceHTTPRequestRuleFrontendDefault) WithStatusCode(code int) *ReplaceHTTPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP request rule frontend default response +func (o *ReplaceHTTPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP request rule frontend default response +func (o *ReplaceHTTPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP request rule frontend default response +func (o *ReplaceHTTPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP request rule frontend default response +func (o *ReplaceHTTPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP request rule frontend default response +func (o *ReplaceHTTPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_request_rule/replace_http_request_rule_frontend_urlbuilder.go b/operations/http_request_rule/replace_http_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..c63e1d44 --- /dev/null +++ b/operations/http_request_rule/replace_http_request_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPRequestRuleFrontendURL generates an URL for the replace HTTP request rule frontend operation +type ReplaceHTTPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPRequestRuleFrontendURL) WithBasePath(bp string) *ReplaceHTTPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_request_rule/replace_http_request_rule_parameters.go b/operations/http_request_rule/replace_http_request_rule_parameters.go deleted file mode 100644 index 11c5b5b2..00000000 --- a/operations/http_request_rule/replace_http_request_rule_parameters.go +++ /dev/null @@ -1,302 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceHTTPRequestRuleParams creates a new ReplaceHTTPRequestRuleParams object -// with the default values initialized. -func NewReplaceHTTPRequestRuleParams() ReplaceHTTPRequestRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceHTTPRequestRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceHTTPRequestRuleParams contains all the bound params for the replace HTTP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceHTTPRequestRule -type ReplaceHTTPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.HTTPRequestRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*HTTP Request Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceHTTPRequestRuleParams() beforehand. -func (o *ReplaceHTTPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.HTTPRequestRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceHTTPRequestRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceHTTPRequestRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *ReplaceHTTPRequestRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *ReplaceHTTPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *ReplaceHTTPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *ReplaceHTTPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceHTTPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceHTTPRequestRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/http_request_rule/replace_http_request_rule_responses.go b/operations/http_request_rule/replace_http_request_rule_responses.go deleted file mode 100644 index 53c619df..00000000 --- a/operations/http_request_rule/replace_http_request_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceHTTPRequestRuleOKCode is the HTTP code returned for type ReplaceHTTPRequestRuleOK -const ReplaceHTTPRequestRuleOKCode int = 200 - -/*ReplaceHTTPRequestRuleOK HTTP Request Rule replaced - -swagger:response replaceHttpRequestRuleOK -*/ -type ReplaceHTTPRequestRuleOK struct { - - /* - In: Body - */ - Payload *models.HTTPRequestRule `json:"body,omitempty"` -} - -// NewReplaceHTTPRequestRuleOK creates ReplaceHTTPRequestRuleOK with default headers values -func NewReplaceHTTPRequestRuleOK() *ReplaceHTTPRequestRuleOK { - - return &ReplaceHTTPRequestRuleOK{} -} - -// WithPayload adds the payload to the replace Http request rule o k response -func (o *ReplaceHTTPRequestRuleOK) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http request rule o k response -func (o *ReplaceHTTPRequestRuleOK) SetPayload(payload *models.HTTPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPRequestRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceHTTPRequestRuleAcceptedCode is the HTTP code returned for type ReplaceHTTPRequestRuleAccepted -const ReplaceHTTPRequestRuleAcceptedCode int = 202 - -/*ReplaceHTTPRequestRuleAccepted Configuration change accepted and reload requested - -swagger:response replaceHttpRequestRuleAccepted -*/ -type ReplaceHTTPRequestRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.HTTPRequestRule `json:"body,omitempty"` -} - -// NewReplaceHTTPRequestRuleAccepted creates ReplaceHTTPRequestRuleAccepted with default headers values -func NewReplaceHTTPRequestRuleAccepted() *ReplaceHTTPRequestRuleAccepted { - - return &ReplaceHTTPRequestRuleAccepted{} -} - -// WithReloadID adds the reloadId to the replace Http request rule accepted response -func (o *ReplaceHTTPRequestRuleAccepted) WithReloadID(reloadID string) *ReplaceHTTPRequestRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace Http request rule accepted response -func (o *ReplaceHTTPRequestRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace Http request rule accepted response -func (o *ReplaceHTTPRequestRuleAccepted) WithPayload(payload *models.HTTPRequestRule) *ReplaceHTTPRequestRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http request rule accepted response -func (o *ReplaceHTTPRequestRuleAccepted) SetPayload(payload *models.HTTPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPRequestRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceHTTPRequestRuleBadRequestCode is the HTTP code returned for type ReplaceHTTPRequestRuleBadRequest -const ReplaceHTTPRequestRuleBadRequestCode int = 400 - -/*ReplaceHTTPRequestRuleBadRequest Bad request - -swagger:response replaceHttpRequestRuleBadRequest -*/ -type ReplaceHTTPRequestRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceHTTPRequestRuleBadRequest creates ReplaceHTTPRequestRuleBadRequest with default headers values -func NewReplaceHTTPRequestRuleBadRequest() *ReplaceHTTPRequestRuleBadRequest { - - return &ReplaceHTTPRequestRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Http request rule bad request response -func (o *ReplaceHTTPRequestRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceHTTPRequestRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Http request rule bad request response -func (o *ReplaceHTTPRequestRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Http request rule bad request response -func (o *ReplaceHTTPRequestRuleBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http request rule bad request response -func (o *ReplaceHTTPRequestRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPRequestRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceHTTPRequestRuleNotFoundCode is the HTTP code returned for type ReplaceHTTPRequestRuleNotFound -const ReplaceHTTPRequestRuleNotFoundCode int = 404 - -/*ReplaceHTTPRequestRuleNotFound The specified resource was not found - -swagger:response replaceHttpRequestRuleNotFound -*/ -type ReplaceHTTPRequestRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceHTTPRequestRuleNotFound creates ReplaceHTTPRequestRuleNotFound with default headers values -func NewReplaceHTTPRequestRuleNotFound() *ReplaceHTTPRequestRuleNotFound { - - return &ReplaceHTTPRequestRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Http request rule not found response -func (o *ReplaceHTTPRequestRuleNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceHTTPRequestRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Http request rule not found response -func (o *ReplaceHTTPRequestRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Http request rule not found response -func (o *ReplaceHTTPRequestRuleNotFound) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http request rule not found response -func (o *ReplaceHTTPRequestRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPRequestRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceHTTPRequestRuleDefault General Error - -swagger:response replaceHttpRequestRuleDefault -*/ -type ReplaceHTTPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceHTTPRequestRuleDefault creates ReplaceHTTPRequestRuleDefault with default headers values -func NewReplaceHTTPRequestRuleDefault(code int) *ReplaceHTTPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceHTTPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace HTTP request rule default response -func (o *ReplaceHTTPRequestRuleDefault) WithStatusCode(code int) *ReplaceHTTPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace HTTP request rule default response -func (o *ReplaceHTTPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace HTTP request rule default response -func (o *ReplaceHTTPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceHTTPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace HTTP request rule default response -func (o *ReplaceHTTPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace HTTP request rule default response -func (o *ReplaceHTTPRequestRuleDefault) WithPayload(payload *models.Error) *ReplaceHTTPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace HTTP request rule default response -func (o *ReplaceHTTPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_request_rule/replace_http_request_rule_urlbuilder.go b/operations/http_request_rule/replace_http_request_rule_urlbuilder.go deleted file mode 100644 index f69866d4..00000000 --- a/operations/http_request_rule/replace_http_request_rule_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceHTTPRequestRuleURL generates an URL for the replace HTTP request rule operation -type ReplaceHTTPRequestRuleURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceHTTPRequestRuleURL) WithBasePath(bp string) *ReplaceHTTPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceHTTPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceHTTPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_request_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on ReplaceHTTPRequestRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceHTTPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceHTTPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceHTTPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceHTTPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceHTTPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceHTTPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_response_rule/create_http_response_rule.go b/operations/http_response_rule/create_http_response_rule.go deleted file mode 100644 index 0878e0d9..00000000 --- a/operations/http_response_rule/create_http_response_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateHTTPResponseRuleHandlerFunc turns a function with the right signature into a create HTTP response rule handler -type CreateHTTPResponseRuleHandlerFunc func(CreateHTTPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateHTTPResponseRuleHandlerFunc) Handle(params CreateHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateHTTPResponseRuleHandler interface for that can handle valid create HTTP response rule params -type CreateHTTPResponseRuleHandler interface { - Handle(CreateHTTPResponseRuleParams, interface{}) middleware.Responder -} - -// NewCreateHTTPResponseRule creates a new http.Handler for the create HTTP response rule operation -func NewCreateHTTPResponseRule(ctx *middleware.Context, handler CreateHTTPResponseRuleHandler) *CreateHTTPResponseRule { - return &CreateHTTPResponseRule{Context: ctx, Handler: handler} -} - -/*CreateHTTPResponseRule swagger:route POST /services/haproxy/configuration/http_response_rules HTTPResponseRule createHttpResponseRule - -Add a new HTTP Response Rule - -Adds a new HTTP Response Rule of the specified type in the specified parent. - -*/ -type CreateHTTPResponseRule struct { - Context *middleware.Context - Handler CreateHTTPResponseRuleHandler -} - -func (o *CreateHTTPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateHTTPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/http_response_rule/create_http_response_rule_backend.go b/operations/http_response_rule/create_http_response_rule_backend.go new file mode 100644 index 00000000..41448440 --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPResponseRuleBackendHandlerFunc turns a function with the right signature into a create HTTP response rule backend handler +type CreateHTTPResponseRuleBackendHandlerFunc func(CreateHTTPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPResponseRuleBackendHandlerFunc) Handle(params CreateHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPResponseRuleBackendHandler interface for that can handle valid create HTTP response rule backend params +type CreateHTTPResponseRuleBackendHandler interface { + Handle(CreateHTTPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPResponseRuleBackend creates a new http.Handler for the create HTTP response rule backend operation +func NewCreateHTTPResponseRuleBackend(ctx *middleware.Context, handler CreateHTTPResponseRuleBackendHandler) *CreateHTTPResponseRuleBackend { + return &CreateHTTPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPResponseRuleBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index} HTTPResponseRule createHttpResponseRuleBackend + +# Add a new HTTP Response Rule + +Adds a new HTTP Response Rule of the specified type in the specified parent. +*/ +type CreateHTTPResponseRuleBackend struct { + Context *middleware.Context + Handler CreateHTTPResponseRuleBackendHandler +} + +func (o *CreateHTTPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/create_http_response_rule_backend_parameters.go b/operations/http_response_rule/create_http_response_rule_backend_parameters.go new file mode 100644 index 00000000..ed06a582 --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPResponseRuleBackendParams creates a new CreateHTTPResponseRuleBackendParams object +// with the default values initialized. +func NewCreateHTTPResponseRuleBackendParams() CreateHTTPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPResponseRuleBackendParams contains all the bound params for the create HTTP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPResponseRuleBackend +type CreateHTTPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPResponseRuleBackendParams() beforehand. +func (o *CreateHTTPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/create_http_response_rule_backend_responses.go b/operations/http_response_rule/create_http_response_rule_backend_responses.go new file mode 100644 index 00000000..b976a663 --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPResponseRuleBackendCreatedCode is the HTTP code returned for type CreateHTTPResponseRuleBackendCreated +const CreateHTTPResponseRuleBackendCreatedCode int = 201 + +/* +CreateHTTPResponseRuleBackendCreated HTTP Response Rule created + +swagger:response createHttpResponseRuleBackendCreated +*/ +type CreateHTTPResponseRuleBackendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleBackendCreated creates CreateHTTPResponseRuleBackendCreated with default headers values +func NewCreateHTTPResponseRuleBackendCreated() *CreateHTTPResponseRuleBackendCreated { + + return &CreateHTTPResponseRuleBackendCreated{} +} + +// WithPayload adds the payload to the create Http response rule backend created response +func (o *CreateHTTPResponseRuleBackendCreated) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule backend created response +func (o *CreateHTTPResponseRuleBackendCreated) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleBackendAcceptedCode is the HTTP code returned for type CreateHTTPResponseRuleBackendAccepted +const CreateHTTPResponseRuleBackendAcceptedCode int = 202 + +/* +CreateHTTPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response createHttpResponseRuleBackendAccepted +*/ +type CreateHTTPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleBackendAccepted creates CreateHTTPResponseRuleBackendAccepted with default headers values +func NewCreateHTTPResponseRuleBackendAccepted() *CreateHTTPResponseRuleBackendAccepted { + + return &CreateHTTPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http response rule backend accepted response +func (o *CreateHTTPResponseRuleBackendAccepted) WithReloadID(reloadID string) *CreateHTTPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http response rule backend accepted response +func (o *CreateHTTPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http response rule backend accepted response +func (o *CreateHTTPResponseRuleBackendAccepted) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule backend accepted response +func (o *CreateHTTPResponseRuleBackendAccepted) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleBackendBadRequestCode is the HTTP code returned for type CreateHTTPResponseRuleBackendBadRequest +const CreateHTTPResponseRuleBackendBadRequestCode int = 400 + +/* +CreateHTTPResponseRuleBackendBadRequest Bad request + +swagger:response createHttpResponseRuleBackendBadRequest +*/ +type CreateHTTPResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleBackendBadRequest creates CreateHTTPResponseRuleBackendBadRequest with default headers values +func NewCreateHTTPResponseRuleBackendBadRequest() *CreateHTTPResponseRuleBackendBadRequest { + + return &CreateHTTPResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http response rule backend bad request response +func (o *CreateHTTPResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http response rule backend bad request response +func (o *CreateHTTPResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http response rule backend bad request response +func (o *CreateHTTPResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *CreateHTTPResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule backend bad request response +func (o *CreateHTTPResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleBackendConflictCode is the HTTP code returned for type CreateHTTPResponseRuleBackendConflict +const CreateHTTPResponseRuleBackendConflictCode int = 409 + +/* +CreateHTTPResponseRuleBackendConflict The specified resource already exists + +swagger:response createHttpResponseRuleBackendConflict +*/ +type CreateHTTPResponseRuleBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleBackendConflict creates CreateHTTPResponseRuleBackendConflict with default headers values +func NewCreateHTTPResponseRuleBackendConflict() *CreateHTTPResponseRuleBackendConflict { + + return &CreateHTTPResponseRuleBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http response rule backend conflict response +func (o *CreateHTTPResponseRuleBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http response rule backend conflict response +func (o *CreateHTTPResponseRuleBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http response rule backend conflict response +func (o *CreateHTTPResponseRuleBackendConflict) WithPayload(payload *models.Error) *CreateHTTPResponseRuleBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule backend conflict response +func (o *CreateHTTPResponseRuleBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPResponseRuleBackendDefault General Error + +swagger:response createHttpResponseRuleBackendDefault +*/ +type CreateHTTPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleBackendDefault creates CreateHTTPResponseRuleBackendDefault with default headers values +func NewCreateHTTPResponseRuleBackendDefault(code int) *CreateHTTPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP response rule backend default response +func (o *CreateHTTPResponseRuleBackendDefault) WithStatusCode(code int) *CreateHTTPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP response rule backend default response +func (o *CreateHTTPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP response rule backend default response +func (o *CreateHTTPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP response rule backend default response +func (o *CreateHTTPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP response rule backend default response +func (o *CreateHTTPResponseRuleBackendDefault) WithPayload(payload *models.Error) *CreateHTTPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP response rule backend default response +func (o *CreateHTTPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/create_http_response_rule_backend_urlbuilder.go b/operations/http_response_rule/create_http_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..07902121 --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPResponseRuleBackendURL generates an URL for the create HTTP response rule backend operation +type CreateHTTPResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPResponseRuleBackendURL) WithBasePath(bp string) *CreateHTTPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/create_http_response_rule_defaults.go b/operations/http_response_rule/create_http_response_rule_defaults.go new file mode 100644 index 00000000..00c812cb --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a create HTTP response rule defaults handler +type CreateHTTPResponseRuleDefaultsHandlerFunc func(CreateHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPResponseRuleDefaultsHandlerFunc) Handle(params CreateHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPResponseRuleDefaultsHandler interface for that can handle valid create HTTP response rule defaults params +type CreateHTTPResponseRuleDefaultsHandler interface { + Handle(CreateHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateHTTPResponseRuleDefaults creates a new http.Handler for the create HTTP response rule defaults operation +func NewCreateHTTPResponseRuleDefaults(ctx *middleware.Context, handler CreateHTTPResponseRuleDefaultsHandler) *CreateHTTPResponseRuleDefaults { + return &CreateHTTPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + CreateHTTPResponseRuleDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index} HTTPResponseRule createHttpResponseRuleDefaults + +# Add a new HTTP Response Rule + +Adds a new HTTP Response Rule of the specified type in the specified parent. +*/ +type CreateHTTPResponseRuleDefaults struct { + Context *middleware.Context + Handler CreateHTTPResponseRuleDefaultsHandler +} + +func (o *CreateHTTPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/create_http_response_rule_defaults_parameters.go b/operations/http_response_rule/create_http_response_rule_defaults_parameters.go new file mode 100644 index 00000000..d967f025 --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPResponseRuleDefaultsParams creates a new CreateHTTPResponseRuleDefaultsParams object +// with the default values initialized. +func NewCreateHTTPResponseRuleDefaultsParams() CreateHTTPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPResponseRuleDefaultsParams contains all the bound params for the create HTTP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPResponseRuleDefaults +type CreateHTTPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPResponseRuleDefaultsParams() beforehand. +func (o *CreateHTTPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/create_http_response_rule_defaults_responses.go b/operations/http_response_rule/create_http_response_rule_defaults_responses.go new file mode 100644 index 00000000..9f991732 --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPResponseRuleDefaultsCreatedCode is the HTTP code returned for type CreateHTTPResponseRuleDefaultsCreated +const CreateHTTPResponseRuleDefaultsCreatedCode int = 201 + +/* +CreateHTTPResponseRuleDefaultsCreated HTTP Response Rule created + +swagger:response createHttpResponseRuleDefaultsCreated +*/ +type CreateHTTPResponseRuleDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleDefaultsCreated creates CreateHTTPResponseRuleDefaultsCreated with default headers values +func NewCreateHTTPResponseRuleDefaultsCreated() *CreateHTTPResponseRuleDefaultsCreated { + + return &CreateHTTPResponseRuleDefaultsCreated{} +} + +// WithPayload adds the payload to the create Http response rule defaults created response +func (o *CreateHTTPResponseRuleDefaultsCreated) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule defaults created response +func (o *CreateHTTPResponseRuleDefaultsCreated) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type CreateHTTPResponseRuleDefaultsAccepted +const CreateHTTPResponseRuleDefaultsAcceptedCode int = 202 + +/* +CreateHTTPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createHttpResponseRuleDefaultsAccepted +*/ +type CreateHTTPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleDefaultsAccepted creates CreateHTTPResponseRuleDefaultsAccepted with default headers values +func NewCreateHTTPResponseRuleDefaultsAccepted() *CreateHTTPResponseRuleDefaultsAccepted { + + return &CreateHTTPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Http response rule defaults accepted response +func (o *CreateHTTPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *CreateHTTPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http response rule defaults accepted response +func (o *CreateHTTPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http response rule defaults accepted response +func (o *CreateHTTPResponseRuleDefaultsAccepted) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule defaults accepted response +func (o *CreateHTTPResponseRuleDefaultsAccepted) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleDefaultsBadRequestCode is the HTTP code returned for type CreateHTTPResponseRuleDefaultsBadRequest +const CreateHTTPResponseRuleDefaultsBadRequestCode int = 400 + +/* +CreateHTTPResponseRuleDefaultsBadRequest Bad request + +swagger:response createHttpResponseRuleDefaultsBadRequest +*/ +type CreateHTTPResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleDefaultsBadRequest creates CreateHTTPResponseRuleDefaultsBadRequest with default headers values +func NewCreateHTTPResponseRuleDefaultsBadRequest() *CreateHTTPResponseRuleDefaultsBadRequest { + + return &CreateHTTPResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http response rule defaults bad request response +func (o *CreateHTTPResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http response rule defaults bad request response +func (o *CreateHTTPResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http response rule defaults bad request response +func (o *CreateHTTPResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *CreateHTTPResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule defaults bad request response +func (o *CreateHTTPResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleDefaultsConflictCode is the HTTP code returned for type CreateHTTPResponseRuleDefaultsConflict +const CreateHTTPResponseRuleDefaultsConflictCode int = 409 + +/* +CreateHTTPResponseRuleDefaultsConflict The specified resource already exists + +swagger:response createHttpResponseRuleDefaultsConflict +*/ +type CreateHTTPResponseRuleDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleDefaultsConflict creates CreateHTTPResponseRuleDefaultsConflict with default headers values +func NewCreateHTTPResponseRuleDefaultsConflict() *CreateHTTPResponseRuleDefaultsConflict { + + return &CreateHTTPResponseRuleDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http response rule defaults conflict response +func (o *CreateHTTPResponseRuleDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http response rule defaults conflict response +func (o *CreateHTTPResponseRuleDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http response rule defaults conflict response +func (o *CreateHTTPResponseRuleDefaultsConflict) WithPayload(payload *models.Error) *CreateHTTPResponseRuleDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule defaults conflict response +func (o *CreateHTTPResponseRuleDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPResponseRuleDefaultsDefault General Error + +swagger:response createHttpResponseRuleDefaultsDefault +*/ +type CreateHTTPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleDefaultsDefault creates CreateHTTPResponseRuleDefaultsDefault with default headers values +func NewCreateHTTPResponseRuleDefaultsDefault(code int) *CreateHTTPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP response rule defaults default response +func (o *CreateHTTPResponseRuleDefaultsDefault) WithStatusCode(code int) *CreateHTTPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP response rule defaults default response +func (o *CreateHTTPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP response rule defaults default response +func (o *CreateHTTPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP response rule defaults default response +func (o *CreateHTTPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP response rule defaults default response +func (o *CreateHTTPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *CreateHTTPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP response rule defaults default response +func (o *CreateHTTPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/create_http_response_rule_defaults_urlbuilder.go b/operations/http_response_rule/create_http_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..493aa6ac --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPResponseRuleDefaultsURL generates an URL for the create HTTP response rule defaults operation +type CreateHTTPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPResponseRuleDefaultsURL) WithBasePath(bp string) *CreateHTTPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/create_http_response_rule_frontend.go b/operations/http_response_rule/create_http_response_rule_frontend.go new file mode 100644 index 00000000..7a701f4c --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateHTTPResponseRuleFrontendHandlerFunc turns a function with the right signature into a create HTTP response rule frontend handler +type CreateHTTPResponseRuleFrontendHandlerFunc func(CreateHTTPResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateHTTPResponseRuleFrontendHandlerFunc) Handle(params CreateHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateHTTPResponseRuleFrontendHandler interface for that can handle valid create HTTP response rule frontend params +type CreateHTTPResponseRuleFrontendHandler interface { + Handle(CreateHTTPResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewCreateHTTPResponseRuleFrontend creates a new http.Handler for the create HTTP response rule frontend operation +func NewCreateHTTPResponseRuleFrontend(ctx *middleware.Context, handler CreateHTTPResponseRuleFrontendHandler) *CreateHTTPResponseRuleFrontend { + return &CreateHTTPResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + CreateHTTPResponseRuleFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index} HTTPResponseRule createHttpResponseRuleFrontend + +# Add a new HTTP Response Rule + +Adds a new HTTP Response Rule of the specified type in the specified parent. +*/ +type CreateHTTPResponseRuleFrontend struct { + Context *middleware.Context + Handler CreateHTTPResponseRuleFrontendHandler +} + +func (o *CreateHTTPResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateHTTPResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/create_http_response_rule_frontend_parameters.go b/operations/http_response_rule/create_http_response_rule_frontend_parameters.go new file mode 100644 index 00000000..f700f54c --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateHTTPResponseRuleFrontendParams creates a new CreateHTTPResponseRuleFrontendParams object +// with the default values initialized. +func NewCreateHTTPResponseRuleFrontendParams() CreateHTTPResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateHTTPResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateHTTPResponseRuleFrontendParams contains all the bound params for the create HTTP response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createHTTPResponseRuleFrontend +type CreateHTTPResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateHTTPResponseRuleFrontendParams() beforehand. +func (o *CreateHTTPResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateHTTPResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateHTTPResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateHTTPResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateHTTPResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateHTTPResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateHTTPResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/create_http_response_rule_frontend_responses.go b/operations/http_response_rule/create_http_response_rule_frontend_responses.go new file mode 100644 index 00000000..b296f2d0 --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateHTTPResponseRuleFrontendCreatedCode is the HTTP code returned for type CreateHTTPResponseRuleFrontendCreated +const CreateHTTPResponseRuleFrontendCreatedCode int = 201 + +/* +CreateHTTPResponseRuleFrontendCreated HTTP Response Rule created + +swagger:response createHttpResponseRuleFrontendCreated +*/ +type CreateHTTPResponseRuleFrontendCreated struct { + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleFrontendCreated creates CreateHTTPResponseRuleFrontendCreated with default headers values +func NewCreateHTTPResponseRuleFrontendCreated() *CreateHTTPResponseRuleFrontendCreated { + + return &CreateHTTPResponseRuleFrontendCreated{} +} + +// WithPayload adds the payload to the create Http response rule frontend created response +func (o *CreateHTTPResponseRuleFrontendCreated) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule frontend created response +func (o *CreateHTTPResponseRuleFrontendCreated) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleFrontendAcceptedCode is the HTTP code returned for type CreateHTTPResponseRuleFrontendAccepted +const CreateHTTPResponseRuleFrontendAcceptedCode int = 202 + +/* +CreateHTTPResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response createHttpResponseRuleFrontendAccepted +*/ +type CreateHTTPResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleFrontendAccepted creates CreateHTTPResponseRuleFrontendAccepted with default headers values +func NewCreateHTTPResponseRuleFrontendAccepted() *CreateHTTPResponseRuleFrontendAccepted { + + return &CreateHTTPResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create Http response rule frontend accepted response +func (o *CreateHTTPResponseRuleFrontendAccepted) WithReloadID(reloadID string) *CreateHTTPResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Http response rule frontend accepted response +func (o *CreateHTTPResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Http response rule frontend accepted response +func (o *CreateHTTPResponseRuleFrontendAccepted) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule frontend accepted response +func (o *CreateHTTPResponseRuleFrontendAccepted) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleFrontendBadRequestCode is the HTTP code returned for type CreateHTTPResponseRuleFrontendBadRequest +const CreateHTTPResponseRuleFrontendBadRequestCode int = 400 + +/* +CreateHTTPResponseRuleFrontendBadRequest Bad request + +swagger:response createHttpResponseRuleFrontendBadRequest +*/ +type CreateHTTPResponseRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleFrontendBadRequest creates CreateHTTPResponseRuleFrontendBadRequest with default headers values +func NewCreateHTTPResponseRuleFrontendBadRequest() *CreateHTTPResponseRuleFrontendBadRequest { + + return &CreateHTTPResponseRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http response rule frontend bad request response +func (o *CreateHTTPResponseRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http response rule frontend bad request response +func (o *CreateHTTPResponseRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http response rule frontend bad request response +func (o *CreateHTTPResponseRuleFrontendBadRequest) WithPayload(payload *models.Error) *CreateHTTPResponseRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule frontend bad request response +func (o *CreateHTTPResponseRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateHTTPResponseRuleFrontendConflictCode is the HTTP code returned for type CreateHTTPResponseRuleFrontendConflict +const CreateHTTPResponseRuleFrontendConflictCode int = 409 + +/* +CreateHTTPResponseRuleFrontendConflict The specified resource already exists + +swagger:response createHttpResponseRuleFrontendConflict +*/ +type CreateHTTPResponseRuleFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleFrontendConflict creates CreateHTTPResponseRuleFrontendConflict with default headers values +func NewCreateHTTPResponseRuleFrontendConflict() *CreateHTTPResponseRuleFrontendConflict { + + return &CreateHTTPResponseRuleFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Http response rule frontend conflict response +func (o *CreateHTTPResponseRuleFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Http response rule frontend conflict response +func (o *CreateHTTPResponseRuleFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Http response rule frontend conflict response +func (o *CreateHTTPResponseRuleFrontendConflict) WithPayload(payload *models.Error) *CreateHTTPResponseRuleFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Http response rule frontend conflict response +func (o *CreateHTTPResponseRuleFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateHTTPResponseRuleFrontendDefault General Error + +swagger:response createHttpResponseRuleFrontendDefault +*/ +type CreateHTTPResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateHTTPResponseRuleFrontendDefault creates CreateHTTPResponseRuleFrontendDefault with default headers values +func NewCreateHTTPResponseRuleFrontendDefault(code int) *CreateHTTPResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateHTTPResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create HTTP response rule frontend default response +func (o *CreateHTTPResponseRuleFrontendDefault) WithStatusCode(code int) *CreateHTTPResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create HTTP response rule frontend default response +func (o *CreateHTTPResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create HTTP response rule frontend default response +func (o *CreateHTTPResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateHTTPResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create HTTP response rule frontend default response +func (o *CreateHTTPResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create HTTP response rule frontend default response +func (o *CreateHTTPResponseRuleFrontendDefault) WithPayload(payload *models.Error) *CreateHTTPResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create HTTP response rule frontend default response +func (o *CreateHTTPResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateHTTPResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/create_http_response_rule_frontend_urlbuilder.go b/operations/http_response_rule/create_http_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..511206ed --- /dev/null +++ b/operations/http_response_rule/create_http_response_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateHTTPResponseRuleFrontendURL generates an URL for the create HTTP response rule frontend operation +type CreateHTTPResponseRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPResponseRuleFrontendURL) WithBasePath(bp string) *CreateHTTPResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateHTTPResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateHTTPResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateHTTPResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateHTTPResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateHTTPResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateHTTPResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateHTTPResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateHTTPResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateHTTPResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateHTTPResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/create_http_response_rule_parameters.go b/operations/http_response_rule/create_http_response_rule_parameters.go deleted file mode 100644 index d9054696..00000000 --- a/operations/http_response_rule/create_http_response_rule_parameters.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateHTTPResponseRuleParams creates a new CreateHTTPResponseRuleParams object -// with the default values initialized. -func NewCreateHTTPResponseRuleParams() CreateHTTPResponseRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateHTTPResponseRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateHTTPResponseRuleParams contains all the bound params for the create HTTP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters createHTTPResponseRule -type CreateHTTPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.HTTPResponseRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateHTTPResponseRuleParams() beforehand. -func (o *CreateHTTPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.HTTPResponseRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateHTTPResponseRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateHTTPResponseRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *CreateHTTPResponseRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *CreateHTTPResponseRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *CreateHTTPResponseRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateHTTPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateHTTPResponseRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/http_response_rule/create_http_response_rule_responses.go b/operations/http_response_rule/create_http_response_rule_responses.go deleted file mode 100644 index 35c97679..00000000 --- a/operations/http_response_rule/create_http_response_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateHTTPResponseRuleCreatedCode is the HTTP code returned for type CreateHTTPResponseRuleCreated -const CreateHTTPResponseRuleCreatedCode int = 201 - -/*CreateHTTPResponseRuleCreated HTTP Response Rule created - -swagger:response createHttpResponseRuleCreated -*/ -type CreateHTTPResponseRuleCreated struct { - - /* - In: Body - */ - Payload *models.HTTPResponseRule `json:"body,omitempty"` -} - -// NewCreateHTTPResponseRuleCreated creates CreateHTTPResponseRuleCreated with default headers values -func NewCreateHTTPResponseRuleCreated() *CreateHTTPResponseRuleCreated { - - return &CreateHTTPResponseRuleCreated{} -} - -// WithPayload adds the payload to the create Http response rule created response -func (o *CreateHTTPResponseRuleCreated) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http response rule created response -func (o *CreateHTTPResponseRuleCreated) SetPayload(payload *models.HTTPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPResponseRuleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateHTTPResponseRuleAcceptedCode is the HTTP code returned for type CreateHTTPResponseRuleAccepted -const CreateHTTPResponseRuleAcceptedCode int = 202 - -/*CreateHTTPResponseRuleAccepted Configuration change accepted and reload requested - -swagger:response createHttpResponseRuleAccepted -*/ -type CreateHTTPResponseRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.HTTPResponseRule `json:"body,omitempty"` -} - -// NewCreateHTTPResponseRuleAccepted creates CreateHTTPResponseRuleAccepted with default headers values -func NewCreateHTTPResponseRuleAccepted() *CreateHTTPResponseRuleAccepted { - - return &CreateHTTPResponseRuleAccepted{} -} - -// WithReloadID adds the reloadId to the create Http response rule accepted response -func (o *CreateHTTPResponseRuleAccepted) WithReloadID(reloadID string) *CreateHTTPResponseRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create Http response rule accepted response -func (o *CreateHTTPResponseRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create Http response rule accepted response -func (o *CreateHTTPResponseRuleAccepted) WithPayload(payload *models.HTTPResponseRule) *CreateHTTPResponseRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http response rule accepted response -func (o *CreateHTTPResponseRuleAccepted) SetPayload(payload *models.HTTPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPResponseRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateHTTPResponseRuleBadRequestCode is the HTTP code returned for type CreateHTTPResponseRuleBadRequest -const CreateHTTPResponseRuleBadRequestCode int = 400 - -/*CreateHTTPResponseRuleBadRequest Bad request - -swagger:response createHttpResponseRuleBadRequest -*/ -type CreateHTTPResponseRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateHTTPResponseRuleBadRequest creates CreateHTTPResponseRuleBadRequest with default headers values -func NewCreateHTTPResponseRuleBadRequest() *CreateHTTPResponseRuleBadRequest { - - return &CreateHTTPResponseRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Http response rule bad request response -func (o *CreateHTTPResponseRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateHTTPResponseRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Http response rule bad request response -func (o *CreateHTTPResponseRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Http response rule bad request response -func (o *CreateHTTPResponseRuleBadRequest) WithPayload(payload *models.Error) *CreateHTTPResponseRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http response rule bad request response -func (o *CreateHTTPResponseRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPResponseRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateHTTPResponseRuleConflictCode is the HTTP code returned for type CreateHTTPResponseRuleConflict -const CreateHTTPResponseRuleConflictCode int = 409 - -/*CreateHTTPResponseRuleConflict The specified resource already exists - -swagger:response createHttpResponseRuleConflict -*/ -type CreateHTTPResponseRuleConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateHTTPResponseRuleConflict creates CreateHTTPResponseRuleConflict with default headers values -func NewCreateHTTPResponseRuleConflict() *CreateHTTPResponseRuleConflict { - - return &CreateHTTPResponseRuleConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Http response rule conflict response -func (o *CreateHTTPResponseRuleConflict) WithConfigurationVersion(configurationVersion int64) *CreateHTTPResponseRuleConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Http response rule conflict response -func (o *CreateHTTPResponseRuleConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Http response rule conflict response -func (o *CreateHTTPResponseRuleConflict) WithPayload(payload *models.Error) *CreateHTTPResponseRuleConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Http response rule conflict response -func (o *CreateHTTPResponseRuleConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPResponseRuleConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateHTTPResponseRuleDefault General Error - -swagger:response createHttpResponseRuleDefault -*/ -type CreateHTTPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateHTTPResponseRuleDefault creates CreateHTTPResponseRuleDefault with default headers values -func NewCreateHTTPResponseRuleDefault(code int) *CreateHTTPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &CreateHTTPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create HTTP response rule default response -func (o *CreateHTTPResponseRuleDefault) WithStatusCode(code int) *CreateHTTPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create HTTP response rule default response -func (o *CreateHTTPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create HTTP response rule default response -func (o *CreateHTTPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *CreateHTTPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create HTTP response rule default response -func (o *CreateHTTPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create HTTP response rule default response -func (o *CreateHTTPResponseRuleDefault) WithPayload(payload *models.Error) *CreateHTTPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create HTTP response rule default response -func (o *CreateHTTPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateHTTPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_response_rule/create_http_response_rule_urlbuilder.go b/operations/http_response_rule/create_http_response_rule_urlbuilder.go deleted file mode 100644 index 5a44ec92..00000000 --- a/operations/http_response_rule/create_http_response_rule_urlbuilder.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateHTTPResponseRuleURL generates an URL for the create HTTP response rule operation -type CreateHTTPResponseRuleURL struct { - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateHTTPResponseRuleURL) WithBasePath(bp string) *CreateHTTPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateHTTPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateHTTPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_response_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateHTTPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateHTTPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateHTTPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateHTTPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateHTTPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateHTTPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_response_rule/delete_http_response_rule.go b/operations/http_response_rule/delete_http_response_rule.go deleted file mode 100644 index b8880f4c..00000000 --- a/operations/http_response_rule/delete_http_response_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteHTTPResponseRuleHandlerFunc turns a function with the right signature into a delete HTTP response rule handler -type DeleteHTTPResponseRuleHandlerFunc func(DeleteHTTPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteHTTPResponseRuleHandlerFunc) Handle(params DeleteHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteHTTPResponseRuleHandler interface for that can handle valid delete HTTP response rule params -type DeleteHTTPResponseRuleHandler interface { - Handle(DeleteHTTPResponseRuleParams, interface{}) middleware.Responder -} - -// NewDeleteHTTPResponseRule creates a new http.Handler for the delete HTTP response rule operation -func NewDeleteHTTPResponseRule(ctx *middleware.Context, handler DeleteHTTPResponseRuleHandler) *DeleteHTTPResponseRule { - return &DeleteHTTPResponseRule{Context: ctx, Handler: handler} -} - -/*DeleteHTTPResponseRule swagger:route DELETE /services/haproxy/configuration/http_response_rules/{id} HTTPResponseRule deleteHttpResponseRule - -Delete a HTTP Response Rule - -Deletes a HTTP Response Rule configuration by it's ID from the specified parent. - -*/ -type DeleteHTTPResponseRule struct { - Context *middleware.Context - Handler DeleteHTTPResponseRuleHandler -} - -func (o *DeleteHTTPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteHTTPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/http_response_rule/delete_http_response_rule_backend.go b/operations/http_response_rule/delete_http_response_rule_backend.go new file mode 100644 index 00000000..bc9fbd21 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPResponseRuleBackendHandlerFunc turns a function with the right signature into a delete HTTP response rule backend handler +type DeleteHTTPResponseRuleBackendHandlerFunc func(DeleteHTTPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPResponseRuleBackendHandlerFunc) Handle(params DeleteHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPResponseRuleBackendHandler interface for that can handle valid delete HTTP response rule backend params +type DeleteHTTPResponseRuleBackendHandler interface { + Handle(DeleteHTTPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPResponseRuleBackend creates a new http.Handler for the delete HTTP response rule backend operation +func NewDeleteHTTPResponseRuleBackend(ctx *middleware.Context, handler DeleteHTTPResponseRuleBackendHandler) *DeleteHTTPResponseRuleBackend { + return &DeleteHTTPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPResponseRuleBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index} HTTPResponseRule deleteHttpResponseRuleBackend + +# Delete a HTTP Response Rule + +Deletes a HTTP Response Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPResponseRuleBackend struct { + Context *middleware.Context + Handler DeleteHTTPResponseRuleBackendHandler +} + +func (o *DeleteHTTPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/delete_http_response_rule_backend_parameters.go b/operations/http_response_rule/delete_http_response_rule_backend_parameters.go new file mode 100644 index 00000000..a038ceb2 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPResponseRuleBackendParams creates a new DeleteHTTPResponseRuleBackendParams object +// with the default values initialized. +func NewDeleteHTTPResponseRuleBackendParams() DeleteHTTPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPResponseRuleBackendParams contains all the bound params for the delete HTTP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPResponseRuleBackend +type DeleteHTTPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPResponseRuleBackendParams() beforehand. +func (o *DeleteHTTPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/delete_http_response_rule_backend_responses.go b/operations/http_response_rule/delete_http_response_rule_backend_responses.go new file mode 100644 index 00000000..ac0d1584 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPResponseRuleBackendAcceptedCode is the HTTP code returned for type DeleteHTTPResponseRuleBackendAccepted +const DeleteHTTPResponseRuleBackendAcceptedCode int = 202 + +/* +DeleteHTTPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpResponseRuleBackendAccepted +*/ +type DeleteHTTPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPResponseRuleBackendAccepted creates DeleteHTTPResponseRuleBackendAccepted with default headers values +func NewDeleteHTTPResponseRuleBackendAccepted() *DeleteHTTPResponseRuleBackendAccepted { + + return &DeleteHTTPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http response rule backend accepted response +func (o *DeleteHTTPResponseRuleBackendAccepted) WithReloadID(reloadID string) *DeleteHTTPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http response rule backend accepted response +func (o *DeleteHTTPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPResponseRuleBackendNoContentCode is the HTTP code returned for type DeleteHTTPResponseRuleBackendNoContent +const DeleteHTTPResponseRuleBackendNoContentCode int = 204 + +/* +DeleteHTTPResponseRuleBackendNoContent HTTP Response Rule deleted + +swagger:response deleteHttpResponseRuleBackendNoContent +*/ +type DeleteHTTPResponseRuleBackendNoContent struct { +} + +// NewDeleteHTTPResponseRuleBackendNoContent creates DeleteHTTPResponseRuleBackendNoContent with default headers values +func NewDeleteHTTPResponseRuleBackendNoContent() *DeleteHTTPResponseRuleBackendNoContent { + + return &DeleteHTTPResponseRuleBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPResponseRuleBackendNotFoundCode is the HTTP code returned for type DeleteHTTPResponseRuleBackendNotFound +const DeleteHTTPResponseRuleBackendNotFoundCode int = 404 + +/* +DeleteHTTPResponseRuleBackendNotFound The specified resource was not found + +swagger:response deleteHttpResponseRuleBackendNotFound +*/ +type DeleteHTTPResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPResponseRuleBackendNotFound creates DeleteHTTPResponseRuleBackendNotFound with default headers values +func NewDeleteHTTPResponseRuleBackendNotFound() *DeleteHTTPResponseRuleBackendNotFound { + + return &DeleteHTTPResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http response rule backend not found response +func (o *DeleteHTTPResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http response rule backend not found response +func (o *DeleteHTTPResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http response rule backend not found response +func (o *DeleteHTTPResponseRuleBackendNotFound) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http response rule backend not found response +func (o *DeleteHTTPResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPResponseRuleBackendDefault General Error + +swagger:response deleteHttpResponseRuleBackendDefault +*/ +type DeleteHTTPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPResponseRuleBackendDefault creates DeleteHTTPResponseRuleBackendDefault with default headers values +func NewDeleteHTTPResponseRuleBackendDefault(code int) *DeleteHTTPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP response rule backend default response +func (o *DeleteHTTPResponseRuleBackendDefault) WithStatusCode(code int) *DeleteHTTPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP response rule backend default response +func (o *DeleteHTTPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP response rule backend default response +func (o *DeleteHTTPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP response rule backend default response +func (o *DeleteHTTPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP response rule backend default response +func (o *DeleteHTTPResponseRuleBackendDefault) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP response rule backend default response +func (o *DeleteHTTPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/delete_http_response_rule_backend_urlbuilder.go b/operations/http_response_rule/delete_http_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..d5e551be --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPResponseRuleBackendURL generates an URL for the delete HTTP response rule backend operation +type DeleteHTTPResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPResponseRuleBackendURL) WithBasePath(bp string) *DeleteHTTPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/delete_http_response_rule_defaults.go b/operations/http_response_rule/delete_http_response_rule_defaults.go new file mode 100644 index 00000000..fa6af86e --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a delete HTTP response rule defaults handler +type DeleteHTTPResponseRuleDefaultsHandlerFunc func(DeleteHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPResponseRuleDefaultsHandlerFunc) Handle(params DeleteHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPResponseRuleDefaultsHandler interface for that can handle valid delete HTTP response rule defaults params +type DeleteHTTPResponseRuleDefaultsHandler interface { + Handle(DeleteHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPResponseRuleDefaults creates a new http.Handler for the delete HTTP response rule defaults operation +func NewDeleteHTTPResponseRuleDefaults(ctx *middleware.Context, handler DeleteHTTPResponseRuleDefaultsHandler) *DeleteHTTPResponseRuleDefaults { + return &DeleteHTTPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPResponseRuleDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index} HTTPResponseRule deleteHttpResponseRuleDefaults + +# Delete a HTTP Response Rule + +Deletes a HTTP Response Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPResponseRuleDefaults struct { + Context *middleware.Context + Handler DeleteHTTPResponseRuleDefaultsHandler +} + +func (o *DeleteHTTPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/delete_http_response_rule_defaults_parameters.go b/operations/http_response_rule/delete_http_response_rule_defaults_parameters.go new file mode 100644 index 00000000..5b206894 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPResponseRuleDefaultsParams creates a new DeleteHTTPResponseRuleDefaultsParams object +// with the default values initialized. +func NewDeleteHTTPResponseRuleDefaultsParams() DeleteHTTPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPResponseRuleDefaultsParams contains all the bound params for the delete HTTP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPResponseRuleDefaults +type DeleteHTTPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPResponseRuleDefaultsParams() beforehand. +func (o *DeleteHTTPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/delete_http_response_rule_defaults_responses.go b/operations/http_response_rule/delete_http_response_rule_defaults_responses.go new file mode 100644 index 00000000..05e89310 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type DeleteHTTPResponseRuleDefaultsAccepted +const DeleteHTTPResponseRuleDefaultsAcceptedCode int = 202 + +/* +DeleteHTTPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpResponseRuleDefaultsAccepted +*/ +type DeleteHTTPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPResponseRuleDefaultsAccepted creates DeleteHTTPResponseRuleDefaultsAccepted with default headers values +func NewDeleteHTTPResponseRuleDefaultsAccepted() *DeleteHTTPResponseRuleDefaultsAccepted { + + return &DeleteHTTPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http response rule defaults accepted response +func (o *DeleteHTTPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *DeleteHTTPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http response rule defaults accepted response +func (o *DeleteHTTPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPResponseRuleDefaultsNoContentCode is the HTTP code returned for type DeleteHTTPResponseRuleDefaultsNoContent +const DeleteHTTPResponseRuleDefaultsNoContentCode int = 204 + +/* +DeleteHTTPResponseRuleDefaultsNoContent HTTP Response Rule deleted + +swagger:response deleteHttpResponseRuleDefaultsNoContent +*/ +type DeleteHTTPResponseRuleDefaultsNoContent struct { +} + +// NewDeleteHTTPResponseRuleDefaultsNoContent creates DeleteHTTPResponseRuleDefaultsNoContent with default headers values +func NewDeleteHTTPResponseRuleDefaultsNoContent() *DeleteHTTPResponseRuleDefaultsNoContent { + + return &DeleteHTTPResponseRuleDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPResponseRuleDefaultsNotFoundCode is the HTTP code returned for type DeleteHTTPResponseRuleDefaultsNotFound +const DeleteHTTPResponseRuleDefaultsNotFoundCode int = 404 + +/* +DeleteHTTPResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response deleteHttpResponseRuleDefaultsNotFound +*/ +type DeleteHTTPResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPResponseRuleDefaultsNotFound creates DeleteHTTPResponseRuleDefaultsNotFound with default headers values +func NewDeleteHTTPResponseRuleDefaultsNotFound() *DeleteHTTPResponseRuleDefaultsNotFound { + + return &DeleteHTTPResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http response rule defaults not found response +func (o *DeleteHTTPResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http response rule defaults not found response +func (o *DeleteHTTPResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http response rule defaults not found response +func (o *DeleteHTTPResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http response rule defaults not found response +func (o *DeleteHTTPResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPResponseRuleDefaultsDefault General Error + +swagger:response deleteHttpResponseRuleDefaultsDefault +*/ +type DeleteHTTPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPResponseRuleDefaultsDefault creates DeleteHTTPResponseRuleDefaultsDefault with default headers values +func NewDeleteHTTPResponseRuleDefaultsDefault(code int) *DeleteHTTPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP response rule defaults default response +func (o *DeleteHTTPResponseRuleDefaultsDefault) WithStatusCode(code int) *DeleteHTTPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP response rule defaults default response +func (o *DeleteHTTPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP response rule defaults default response +func (o *DeleteHTTPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP response rule defaults default response +func (o *DeleteHTTPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP response rule defaults default response +func (o *DeleteHTTPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP response rule defaults default response +func (o *DeleteHTTPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/delete_http_response_rule_defaults_urlbuilder.go b/operations/http_response_rule/delete_http_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..1b0aba87 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPResponseRuleDefaultsURL generates an URL for the delete HTTP response rule defaults operation +type DeleteHTTPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPResponseRuleDefaultsURL) WithBasePath(bp string) *DeleteHTTPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/delete_http_response_rule_frontend.go b/operations/http_response_rule/delete_http_response_rule_frontend.go new file mode 100644 index 00000000..67dd90f8 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteHTTPResponseRuleFrontendHandlerFunc turns a function with the right signature into a delete HTTP response rule frontend handler +type DeleteHTTPResponseRuleFrontendHandlerFunc func(DeleteHTTPResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHTTPResponseRuleFrontendHandlerFunc) Handle(params DeleteHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteHTTPResponseRuleFrontendHandler interface for that can handle valid delete HTTP response rule frontend params +type DeleteHTTPResponseRuleFrontendHandler interface { + Handle(DeleteHTTPResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteHTTPResponseRuleFrontend creates a new http.Handler for the delete HTTP response rule frontend operation +func NewDeleteHTTPResponseRuleFrontend(ctx *middleware.Context, handler DeleteHTTPResponseRuleFrontendHandler) *DeleteHTTPResponseRuleFrontend { + return &DeleteHTTPResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteHTTPResponseRuleFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index} HTTPResponseRule deleteHttpResponseRuleFrontend + +# Delete a HTTP Response Rule + +Deletes a HTTP Response Rule configuration by it's index from the specified parent. +*/ +type DeleteHTTPResponseRuleFrontend struct { + Context *middleware.Context + Handler DeleteHTTPResponseRuleFrontendHandler +} + +func (o *DeleteHTTPResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteHTTPResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/delete_http_response_rule_frontend_parameters.go b/operations/http_response_rule/delete_http_response_rule_frontend_parameters.go new file mode 100644 index 00000000..ec5b77ee --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteHTTPResponseRuleFrontendParams creates a new DeleteHTTPResponseRuleFrontendParams object +// with the default values initialized. +func NewDeleteHTTPResponseRuleFrontendParams() DeleteHTTPResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteHTTPResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteHTTPResponseRuleFrontendParams contains all the bound params for the delete HTTP response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteHTTPResponseRuleFrontend +type DeleteHTTPResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteHTTPResponseRuleFrontendParams() beforehand. +func (o *DeleteHTTPResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteHTTPResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteHTTPResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteHTTPResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteHTTPResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteHTTPResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteHTTPResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/delete_http_response_rule_frontend_responses.go b/operations/http_response_rule/delete_http_response_rule_frontend_responses.go new file mode 100644 index 00000000..215ea94e --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteHTTPResponseRuleFrontendAcceptedCode is the HTTP code returned for type DeleteHTTPResponseRuleFrontendAccepted +const DeleteHTTPResponseRuleFrontendAcceptedCode int = 202 + +/* +DeleteHTTPResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteHttpResponseRuleFrontendAccepted +*/ +type DeleteHTTPResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteHTTPResponseRuleFrontendAccepted creates DeleteHTTPResponseRuleFrontendAccepted with default headers values +func NewDeleteHTTPResponseRuleFrontendAccepted() *DeleteHTTPResponseRuleFrontendAccepted { + + return &DeleteHTTPResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Http response rule frontend accepted response +func (o *DeleteHTTPResponseRuleFrontendAccepted) WithReloadID(reloadID string) *DeleteHTTPResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Http response rule frontend accepted response +func (o *DeleteHTTPResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteHTTPResponseRuleFrontendNoContentCode is the HTTP code returned for type DeleteHTTPResponseRuleFrontendNoContent +const DeleteHTTPResponseRuleFrontendNoContentCode int = 204 + +/* +DeleteHTTPResponseRuleFrontendNoContent HTTP Response Rule deleted + +swagger:response deleteHttpResponseRuleFrontendNoContent +*/ +type DeleteHTTPResponseRuleFrontendNoContent struct { +} + +// NewDeleteHTTPResponseRuleFrontendNoContent creates DeleteHTTPResponseRuleFrontendNoContent with default headers values +func NewDeleteHTTPResponseRuleFrontendNoContent() *DeleteHTTPResponseRuleFrontendNoContent { + + return &DeleteHTTPResponseRuleFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteHTTPResponseRuleFrontendNotFoundCode is the HTTP code returned for type DeleteHTTPResponseRuleFrontendNotFound +const DeleteHTTPResponseRuleFrontendNotFoundCode int = 404 + +/* +DeleteHTTPResponseRuleFrontendNotFound The specified resource was not found + +swagger:response deleteHttpResponseRuleFrontendNotFound +*/ +type DeleteHTTPResponseRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPResponseRuleFrontendNotFound creates DeleteHTTPResponseRuleFrontendNotFound with default headers values +func NewDeleteHTTPResponseRuleFrontendNotFound() *DeleteHTTPResponseRuleFrontendNotFound { + + return &DeleteHTTPResponseRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Http response rule frontend not found response +func (o *DeleteHTTPResponseRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteHTTPResponseRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Http response rule frontend not found response +func (o *DeleteHTTPResponseRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Http response rule frontend not found response +func (o *DeleteHTTPResponseRuleFrontendNotFound) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Http response rule frontend not found response +func (o *DeleteHTTPResponseRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteHTTPResponseRuleFrontendDefault General Error + +swagger:response deleteHttpResponseRuleFrontendDefault +*/ +type DeleteHTTPResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteHTTPResponseRuleFrontendDefault creates DeleteHTTPResponseRuleFrontendDefault with default headers values +func NewDeleteHTTPResponseRuleFrontendDefault(code int) *DeleteHTTPResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteHTTPResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete HTTP response rule frontend default response +func (o *DeleteHTTPResponseRuleFrontendDefault) WithStatusCode(code int) *DeleteHTTPResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete HTTP response rule frontend default response +func (o *DeleteHTTPResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete HTTP response rule frontend default response +func (o *DeleteHTTPResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteHTTPResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete HTTP response rule frontend default response +func (o *DeleteHTTPResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete HTTP response rule frontend default response +func (o *DeleteHTTPResponseRuleFrontendDefault) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete HTTP response rule frontend default response +func (o *DeleteHTTPResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteHTTPResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/delete_http_response_rule_frontend_urlbuilder.go b/operations/http_response_rule/delete_http_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..36df31b5 --- /dev/null +++ b/operations/http_response_rule/delete_http_response_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteHTTPResponseRuleFrontendURL generates an URL for the delete HTTP response rule frontend operation +type DeleteHTTPResponseRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPResponseRuleFrontendURL) WithBasePath(bp string) *DeleteHTTPResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteHTTPResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteHTTPResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteHTTPResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteHTTPResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteHTTPResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteHTTPResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteHTTPResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteHTTPResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteHTTPResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteHTTPResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/delete_http_response_rule_parameters.go b/operations/http_response_rule/delete_http_response_rule_parameters.go deleted file mode 100644 index c4b6fe61..00000000 --- a/operations/http_response_rule/delete_http_response_rule_parameters.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteHTTPResponseRuleParams creates a new DeleteHTTPResponseRuleParams object -// with the default values initialized. -func NewDeleteHTTPResponseRuleParams() DeleteHTTPResponseRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteHTTPResponseRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteHTTPResponseRuleParams contains all the bound params for the delete HTTP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteHTTPResponseRule -type DeleteHTTPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*HTTP Response Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteHTTPResponseRuleParams() beforehand. -func (o *DeleteHTTPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteHTTPResponseRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteHTTPResponseRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *DeleteHTTPResponseRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *DeleteHTTPResponseRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *DeleteHTTPResponseRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *DeleteHTTPResponseRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteHTTPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteHTTPResponseRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/http_response_rule/delete_http_response_rule_responses.go b/operations/http_response_rule/delete_http_response_rule_responses.go deleted file mode 100644 index fe52aa33..00000000 --- a/operations/http_response_rule/delete_http_response_rule_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteHTTPResponseRuleAcceptedCode is the HTTP code returned for type DeleteHTTPResponseRuleAccepted -const DeleteHTTPResponseRuleAcceptedCode int = 202 - -/*DeleteHTTPResponseRuleAccepted Configuration change accepted and reload requested - -swagger:response deleteHttpResponseRuleAccepted -*/ -type DeleteHTTPResponseRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteHTTPResponseRuleAccepted creates DeleteHTTPResponseRuleAccepted with default headers values -func NewDeleteHTTPResponseRuleAccepted() *DeleteHTTPResponseRuleAccepted { - - return &DeleteHTTPResponseRuleAccepted{} -} - -// WithReloadID adds the reloadId to the delete Http response rule accepted response -func (o *DeleteHTTPResponseRuleAccepted) WithReloadID(reloadID string) *DeleteHTTPResponseRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete Http response rule accepted response -func (o *DeleteHTTPResponseRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteHTTPResponseRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteHTTPResponseRuleNoContentCode is the HTTP code returned for type DeleteHTTPResponseRuleNoContent -const DeleteHTTPResponseRuleNoContentCode int = 204 - -/*DeleteHTTPResponseRuleNoContent HTTP Response Rule deleted - -swagger:response deleteHttpResponseRuleNoContent -*/ -type DeleteHTTPResponseRuleNoContent struct { -} - -// NewDeleteHTTPResponseRuleNoContent creates DeleteHTTPResponseRuleNoContent with default headers values -func NewDeleteHTTPResponseRuleNoContent() *DeleteHTTPResponseRuleNoContent { - - return &DeleteHTTPResponseRuleNoContent{} -} - -// WriteResponse to the client -func (o *DeleteHTTPResponseRuleNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteHTTPResponseRuleNotFoundCode is the HTTP code returned for type DeleteHTTPResponseRuleNotFound -const DeleteHTTPResponseRuleNotFoundCode int = 404 - -/*DeleteHTTPResponseRuleNotFound The specified resource was not found - -swagger:response deleteHttpResponseRuleNotFound -*/ -type DeleteHTTPResponseRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteHTTPResponseRuleNotFound creates DeleteHTTPResponseRuleNotFound with default headers values -func NewDeleteHTTPResponseRuleNotFound() *DeleteHTTPResponseRuleNotFound { - - return &DeleteHTTPResponseRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete Http response rule not found response -func (o *DeleteHTTPResponseRuleNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteHTTPResponseRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete Http response rule not found response -func (o *DeleteHTTPResponseRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete Http response rule not found response -func (o *DeleteHTTPResponseRuleNotFound) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete Http response rule not found response -func (o *DeleteHTTPResponseRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteHTTPResponseRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteHTTPResponseRuleDefault General Error - -swagger:response deleteHttpResponseRuleDefault -*/ -type DeleteHTTPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteHTTPResponseRuleDefault creates DeleteHTTPResponseRuleDefault with default headers values -func NewDeleteHTTPResponseRuleDefault(code int) *DeleteHTTPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &DeleteHTTPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete HTTP response rule default response -func (o *DeleteHTTPResponseRuleDefault) WithStatusCode(code int) *DeleteHTTPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete HTTP response rule default response -func (o *DeleteHTTPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete HTTP response rule default response -func (o *DeleteHTTPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *DeleteHTTPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete HTTP response rule default response -func (o *DeleteHTTPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete HTTP response rule default response -func (o *DeleteHTTPResponseRuleDefault) WithPayload(payload *models.Error) *DeleteHTTPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete HTTP response rule default response -func (o *DeleteHTTPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteHTTPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_response_rule/delete_http_response_rule_urlbuilder.go b/operations/http_response_rule/delete_http_response_rule_urlbuilder.go deleted file mode 100644 index 822d972a..00000000 --- a/operations/http_response_rule/delete_http_response_rule_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteHTTPResponseRuleURL generates an URL for the delete HTTP response rule operation -type DeleteHTTPResponseRuleURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteHTTPResponseRuleURL) WithBasePath(bp string) *DeleteHTTPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteHTTPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteHTTPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_response_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on DeleteHTTPResponseRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteHTTPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteHTTPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteHTTPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteHTTPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteHTTPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteHTTPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_response_rule/get_all_http_response_rule_backend.go b/operations/http_response_rule/get_all_http_response_rule_backend.go new file mode 100644 index 00000000..929a58a1 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPResponseRuleBackendHandlerFunc turns a function with the right signature into a get all HTTP response rule backend handler +type GetAllHTTPResponseRuleBackendHandlerFunc func(GetAllHTTPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPResponseRuleBackendHandlerFunc) Handle(params GetAllHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPResponseRuleBackendHandler interface for that can handle valid get all HTTP response rule backend params +type GetAllHTTPResponseRuleBackendHandler interface { + Handle(GetAllHTTPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPResponseRuleBackend creates a new http.Handler for the get all HTTP response rule backend operation +func NewGetAllHTTPResponseRuleBackend(ctx *middleware.Context, handler GetAllHTTPResponseRuleBackendHandler) *GetAllHTTPResponseRuleBackend { + return &GetAllHTTPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPResponseRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_response_rules HTTPResponseRule getAllHttpResponseRuleBackend + +# Return an array of all HTTP Response Rules + +Returns all HTTP Response Rules that are configured in specified parent. +*/ +type GetAllHTTPResponseRuleBackend struct { + Context *middleware.Context + Handler GetAllHTTPResponseRuleBackendHandler +} + +func (o *GetAllHTTPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/get_all_http_response_rule_backend_parameters.go b/operations/http_response_rule/get_all_http_response_rule_backend_parameters.go new file mode 100644 index 00000000..4f9d5de5 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPResponseRuleBackendParams creates a new GetAllHTTPResponseRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPResponseRuleBackendParams() GetAllHTTPResponseRuleBackendParams { + + return GetAllHTTPResponseRuleBackendParams{} +} + +// GetAllHTTPResponseRuleBackendParams contains all the bound params for the get all HTTP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPResponseRuleBackend +type GetAllHTTPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPResponseRuleBackendParams() beforehand. +func (o *GetAllHTTPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_response_rule/get_all_http_response_rule_backend_responses.go b/operations/http_response_rule/get_all_http_response_rule_backend_responses.go new file mode 100644 index 00000000..8dcce087 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPResponseRuleBackendOKCode is the HTTP code returned for type GetAllHTTPResponseRuleBackendOK +const GetAllHTTPResponseRuleBackendOKCode int = 200 + +/* +GetAllHTTPResponseRuleBackendOK Successful operation + +swagger:response getAllHttpResponseRuleBackendOK +*/ +type GetAllHTTPResponseRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewGetAllHTTPResponseRuleBackendOK creates GetAllHTTPResponseRuleBackendOK with default headers values +func NewGetAllHTTPResponseRuleBackendOK() *GetAllHTTPResponseRuleBackendOK { + + return &GetAllHTTPResponseRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http response rule backend o k response +func (o *GetAllHTTPResponseRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPResponseRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http response rule backend o k response +func (o *GetAllHTTPResponseRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http response rule backend o k response +func (o *GetAllHTTPResponseRuleBackendOK) WithPayload(payload models.HTTPResponseRules) *GetAllHTTPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http response rule backend o k response +func (o *GetAllHTTPResponseRuleBackendOK) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPResponseRuleBackendDefault General Error + +swagger:response getAllHttpResponseRuleBackendDefault +*/ +type GetAllHTTPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPResponseRuleBackendDefault creates GetAllHTTPResponseRuleBackendDefault with default headers values +func NewGetAllHTTPResponseRuleBackendDefault(code int) *GetAllHTTPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP response rule backend default response +func (o *GetAllHTTPResponseRuleBackendDefault) WithStatusCode(code int) *GetAllHTTPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP response rule backend default response +func (o *GetAllHTTPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP response rule backend default response +func (o *GetAllHTTPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP response rule backend default response +func (o *GetAllHTTPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP response rule backend default response +func (o *GetAllHTTPResponseRuleBackendDefault) WithPayload(payload *models.Error) *GetAllHTTPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP response rule backend default response +func (o *GetAllHTTPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/get_all_http_response_rule_backend_urlbuilder.go b/operations/http_response_rule/get_all_http_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..34f283e4 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPResponseRuleBackendURL generates an URL for the get all HTTP response rule backend operation +type GetAllHTTPResponseRuleBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPResponseRuleBackendURL) WithBasePath(bp string) *GetAllHTTPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/get_all_http_response_rule_defaults.go b/operations/http_response_rule/get_all_http_response_rule_defaults.go new file mode 100644 index 00000000..e3ef40ae --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a get all HTTP response rule defaults handler +type GetAllHTTPResponseRuleDefaultsHandlerFunc func(GetAllHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPResponseRuleDefaultsHandlerFunc) Handle(params GetAllHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPResponseRuleDefaultsHandler interface for that can handle valid get all HTTP response rule defaults params +type GetAllHTTPResponseRuleDefaultsHandler interface { + Handle(GetAllHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPResponseRuleDefaults creates a new http.Handler for the get all HTTP response rule defaults operation +func NewGetAllHTTPResponseRuleDefaults(ctx *middleware.Context, handler GetAllHTTPResponseRuleDefaultsHandler) *GetAllHTTPResponseRuleDefaults { + return &GetAllHTTPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPResponseRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_response_rules HTTPResponseRule getAllHttpResponseRuleDefaults + +# Return an array of all HTTP Response Rules + +Returns all HTTP Response Rules that are configured in specified parent. +*/ +type GetAllHTTPResponseRuleDefaults struct { + Context *middleware.Context + Handler GetAllHTTPResponseRuleDefaultsHandler +} + +func (o *GetAllHTTPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/get_all_http_response_rule_defaults_parameters.go b/operations/http_response_rule/get_all_http_response_rule_defaults_parameters.go new file mode 100644 index 00000000..085c476a --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPResponseRuleDefaultsParams creates a new GetAllHTTPResponseRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPResponseRuleDefaultsParams() GetAllHTTPResponseRuleDefaultsParams { + + return GetAllHTTPResponseRuleDefaultsParams{} +} + +// GetAllHTTPResponseRuleDefaultsParams contains all the bound params for the get all HTTP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPResponseRuleDefaults +type GetAllHTTPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPResponseRuleDefaultsParams() beforehand. +func (o *GetAllHTTPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_response_rule/get_all_http_response_rule_defaults_responses.go b/operations/http_response_rule/get_all_http_response_rule_defaults_responses.go new file mode 100644 index 00000000..71ec2f10 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPResponseRuleDefaultsOKCode is the HTTP code returned for type GetAllHTTPResponseRuleDefaultsOK +const GetAllHTTPResponseRuleDefaultsOKCode int = 200 + +/* +GetAllHTTPResponseRuleDefaultsOK Successful operation + +swagger:response getAllHttpResponseRuleDefaultsOK +*/ +type GetAllHTTPResponseRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewGetAllHTTPResponseRuleDefaultsOK creates GetAllHTTPResponseRuleDefaultsOK with default headers values +func NewGetAllHTTPResponseRuleDefaultsOK() *GetAllHTTPResponseRuleDefaultsOK { + + return &GetAllHTTPResponseRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http response rule defaults o k response +func (o *GetAllHTTPResponseRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPResponseRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http response rule defaults o k response +func (o *GetAllHTTPResponseRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http response rule defaults o k response +func (o *GetAllHTTPResponseRuleDefaultsOK) WithPayload(payload models.HTTPResponseRules) *GetAllHTTPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http response rule defaults o k response +func (o *GetAllHTTPResponseRuleDefaultsOK) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPResponseRuleDefaultsDefault General Error + +swagger:response getAllHttpResponseRuleDefaultsDefault +*/ +type GetAllHTTPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPResponseRuleDefaultsDefault creates GetAllHTTPResponseRuleDefaultsDefault with default headers values +func NewGetAllHTTPResponseRuleDefaultsDefault(code int) *GetAllHTTPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP response rule defaults default response +func (o *GetAllHTTPResponseRuleDefaultsDefault) WithStatusCode(code int) *GetAllHTTPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP response rule defaults default response +func (o *GetAllHTTPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP response rule defaults default response +func (o *GetAllHTTPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP response rule defaults default response +func (o *GetAllHTTPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP response rule defaults default response +func (o *GetAllHTTPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *GetAllHTTPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP response rule defaults default response +func (o *GetAllHTTPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/get_all_http_response_rule_defaults_urlbuilder.go b/operations/http_response_rule/get_all_http_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..4cf22af9 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPResponseRuleDefaultsURL generates an URL for the get all HTTP response rule defaults operation +type GetAllHTTPResponseRuleDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPResponseRuleDefaultsURL) WithBasePath(bp string) *GetAllHTTPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/get_all_http_response_rule_frontend.go b/operations/http_response_rule/get_all_http_response_rule_frontend.go new file mode 100644 index 00000000..94440698 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllHTTPResponseRuleFrontendHandlerFunc turns a function with the right signature into a get all HTTP response rule frontend handler +type GetAllHTTPResponseRuleFrontendHandlerFunc func(GetAllHTTPResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllHTTPResponseRuleFrontendHandlerFunc) Handle(params GetAllHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllHTTPResponseRuleFrontendHandler interface for that can handle valid get all HTTP response rule frontend params +type GetAllHTTPResponseRuleFrontendHandler interface { + Handle(GetAllHTTPResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllHTTPResponseRuleFrontend creates a new http.Handler for the get all HTTP response rule frontend operation +func NewGetAllHTTPResponseRuleFrontend(ctx *middleware.Context, handler GetAllHTTPResponseRuleFrontendHandler) *GetAllHTTPResponseRuleFrontend { + return &GetAllHTTPResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllHTTPResponseRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_response_rules HTTPResponseRule getAllHttpResponseRuleFrontend + +# Return an array of all HTTP Response Rules + +Returns all HTTP Response Rules that are configured in specified parent. +*/ +type GetAllHTTPResponseRuleFrontend struct { + Context *middleware.Context + Handler GetAllHTTPResponseRuleFrontendHandler +} + +func (o *GetAllHTTPResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllHTTPResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/get_all_http_response_rule_frontend_parameters.go b/operations/http_response_rule/get_all_http_response_rule_frontend_parameters.go new file mode 100644 index 00000000..0c4a366e --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllHTTPResponseRuleFrontendParams creates a new GetAllHTTPResponseRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllHTTPResponseRuleFrontendParams() GetAllHTTPResponseRuleFrontendParams { + + return GetAllHTTPResponseRuleFrontendParams{} +} + +// GetAllHTTPResponseRuleFrontendParams contains all the bound params for the get all HTTP response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllHTTPResponseRuleFrontend +type GetAllHTTPResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllHTTPResponseRuleFrontendParams() beforehand. +func (o *GetAllHTTPResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllHTTPResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllHTTPResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_response_rule/get_all_http_response_rule_frontend_responses.go b/operations/http_response_rule/get_all_http_response_rule_frontend_responses.go new file mode 100644 index 00000000..8b22206d --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllHTTPResponseRuleFrontendOKCode is the HTTP code returned for type GetAllHTTPResponseRuleFrontendOK +const GetAllHTTPResponseRuleFrontendOKCode int = 200 + +/* +GetAllHTTPResponseRuleFrontendOK Successful operation + +swagger:response getAllHttpResponseRuleFrontendOK +*/ +type GetAllHTTPResponseRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewGetAllHTTPResponseRuleFrontendOK creates GetAllHTTPResponseRuleFrontendOK with default headers values +func NewGetAllHTTPResponseRuleFrontendOK() *GetAllHTTPResponseRuleFrontendOK { + + return &GetAllHTTPResponseRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Http response rule frontend o k response +func (o *GetAllHTTPResponseRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllHTTPResponseRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Http response rule frontend o k response +func (o *GetAllHTTPResponseRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Http response rule frontend o k response +func (o *GetAllHTTPResponseRuleFrontendOK) WithPayload(payload models.HTTPResponseRules) *GetAllHTTPResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Http response rule frontend o k response +func (o *GetAllHTTPResponseRuleFrontendOK) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllHTTPResponseRuleFrontendDefault General Error + +swagger:response getAllHttpResponseRuleFrontendDefault +*/ +type GetAllHTTPResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllHTTPResponseRuleFrontendDefault creates GetAllHTTPResponseRuleFrontendDefault with default headers values +func NewGetAllHTTPResponseRuleFrontendDefault(code int) *GetAllHTTPResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllHTTPResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all HTTP response rule frontend default response +func (o *GetAllHTTPResponseRuleFrontendDefault) WithStatusCode(code int) *GetAllHTTPResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all HTTP response rule frontend default response +func (o *GetAllHTTPResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all HTTP response rule frontend default response +func (o *GetAllHTTPResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllHTTPResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all HTTP response rule frontend default response +func (o *GetAllHTTPResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all HTTP response rule frontend default response +func (o *GetAllHTTPResponseRuleFrontendDefault) WithPayload(payload *models.Error) *GetAllHTTPResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all HTTP response rule frontend default response +func (o *GetAllHTTPResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllHTTPResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/get_all_http_response_rule_frontend_urlbuilder.go b/operations/http_response_rule/get_all_http_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..8f58a3d8 --- /dev/null +++ b/operations/http_response_rule/get_all_http_response_rule_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllHTTPResponseRuleFrontendURL generates an URL for the get all HTTP response rule frontend operation +type GetAllHTTPResponseRuleFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPResponseRuleFrontendURL) WithBasePath(bp string) *GetAllHTTPResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllHTTPResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllHTTPResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllHTTPResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllHTTPResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllHTTPResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllHTTPResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllHTTPResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllHTTPResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllHTTPResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/get_http_response_rule.go b/operations/http_response_rule/get_http_response_rule.go deleted file mode 100644 index f7254fe2..00000000 --- a/operations/http_response_rule/get_http_response_rule.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetHTTPResponseRuleHandlerFunc turns a function with the right signature into a get HTTP response rule handler -type GetHTTPResponseRuleHandlerFunc func(GetHTTPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetHTTPResponseRuleHandlerFunc) Handle(params GetHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetHTTPResponseRuleHandler interface for that can handle valid get HTTP response rule params -type GetHTTPResponseRuleHandler interface { - Handle(GetHTTPResponseRuleParams, interface{}) middleware.Responder -} - -// NewGetHTTPResponseRule creates a new http.Handler for the get HTTP response rule operation -func NewGetHTTPResponseRule(ctx *middleware.Context, handler GetHTTPResponseRuleHandler) *GetHTTPResponseRule { - return &GetHTTPResponseRule{Context: ctx, Handler: handler} -} - -/*GetHTTPResponseRule swagger:route GET /services/haproxy/configuration/http_response_rules/{id} HTTPResponseRule getHttpResponseRule - -Return one HTTP Response Rule - -Returns one HTTP Response Rule configuration by it's ID in the specified parent. - -*/ -type GetHTTPResponseRule struct { - Context *middleware.Context - Handler GetHTTPResponseRuleHandler -} - -func (o *GetHTTPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetHTTPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetHTTPResponseRuleOKBody get HTTP response rule o k body -// swagger:model GetHTTPResponseRuleOKBody -type GetHTTPResponseRuleOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.HTTPResponseRule `json:"data,omitempty"` -} - -// Validate validates this get HTTP response rule o k body -func (o *GetHTTPResponseRuleOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetHTTPResponseRuleOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getHttpResponseRuleOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetHTTPResponseRuleOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetHTTPResponseRuleOKBody) UnmarshalBinary(b []byte) error { - var res GetHTTPResponseRuleOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/http_response_rule/get_http_response_rule_backend.go b/operations/http_response_rule/get_http_response_rule_backend.go new file mode 100644 index 00000000..db89ebff --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPResponseRuleBackendHandlerFunc turns a function with the right signature into a get HTTP response rule backend handler +type GetHTTPResponseRuleBackendHandlerFunc func(GetHTTPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPResponseRuleBackendHandlerFunc) Handle(params GetHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPResponseRuleBackendHandler interface for that can handle valid get HTTP response rule backend params +type GetHTTPResponseRuleBackendHandler interface { + Handle(GetHTTPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetHTTPResponseRuleBackend creates a new http.Handler for the get HTTP response rule backend operation +func NewGetHTTPResponseRuleBackend(ctx *middleware.Context, handler GetHTTPResponseRuleBackendHandler) *GetHTTPResponseRuleBackend { + return &GetHTTPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetHTTPResponseRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index} HTTPResponseRule getHttpResponseRuleBackend + +# Return one HTTP Response Rule + +Returns one HTTP Response Rule configuration by it's index in the specified parent. +*/ +type GetHTTPResponseRuleBackend struct { + Context *middleware.Context + Handler GetHTTPResponseRuleBackendHandler +} + +func (o *GetHTTPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/get_http_response_rule_backend_parameters.go b/operations/http_response_rule/get_http_response_rule_backend_parameters.go new file mode 100644 index 00000000..53be771f --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPResponseRuleBackendParams creates a new GetHTTPResponseRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPResponseRuleBackendParams() GetHTTPResponseRuleBackendParams { + + return GetHTTPResponseRuleBackendParams{} +} + +// GetHTTPResponseRuleBackendParams contains all the bound params for the get HTTP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPResponseRuleBackend +type GetHTTPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPResponseRuleBackendParams() beforehand. +func (o *GetHTTPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_response_rule/get_http_response_rule_backend_responses.go b/operations/http_response_rule/get_http_response_rule_backend_responses.go new file mode 100644 index 00000000..a3c957d8 --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPResponseRuleBackendOKCode is the HTTP code returned for type GetHTTPResponseRuleBackendOK +const GetHTTPResponseRuleBackendOKCode int = 200 + +/* +GetHTTPResponseRuleBackendOK Successful operation + +swagger:response getHttpResponseRuleBackendOK +*/ +type GetHTTPResponseRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleBackendOK creates GetHTTPResponseRuleBackendOK with default headers values +func NewGetHTTPResponseRuleBackendOK() *GetHTTPResponseRuleBackendOK { + + return &GetHTTPResponseRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http response rule backend o k response +func (o *GetHTTPResponseRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http response rule backend o k response +func (o *GetHTTPResponseRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http response rule backend o k response +func (o *GetHTTPResponseRuleBackendOK) WithPayload(payload *models.HTTPResponseRule) *GetHTTPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http response rule backend o k response +func (o *GetHTTPResponseRuleBackendOK) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPResponseRuleBackendNotFoundCode is the HTTP code returned for type GetHTTPResponseRuleBackendNotFound +const GetHTTPResponseRuleBackendNotFoundCode int = 404 + +/* +GetHTTPResponseRuleBackendNotFound The specified resource was not found + +swagger:response getHttpResponseRuleBackendNotFound +*/ +type GetHTTPResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleBackendNotFound creates GetHTTPResponseRuleBackendNotFound with default headers values +func NewGetHTTPResponseRuleBackendNotFound() *GetHTTPResponseRuleBackendNotFound { + + return &GetHTTPResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http response rule backend not found response +func (o *GetHTTPResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http response rule backend not found response +func (o *GetHTTPResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http response rule backend not found response +func (o *GetHTTPResponseRuleBackendNotFound) WithPayload(payload *models.Error) *GetHTTPResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http response rule backend not found response +func (o *GetHTTPResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPResponseRuleBackendDefault General Error + +swagger:response getHttpResponseRuleBackendDefault +*/ +type GetHTTPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleBackendDefault creates GetHTTPResponseRuleBackendDefault with default headers values +func NewGetHTTPResponseRuleBackendDefault(code int) *GetHTTPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP response rule backend default response +func (o *GetHTTPResponseRuleBackendDefault) WithStatusCode(code int) *GetHTTPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP response rule backend default response +func (o *GetHTTPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP response rule backend default response +func (o *GetHTTPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP response rule backend default response +func (o *GetHTTPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP response rule backend default response +func (o *GetHTTPResponseRuleBackendDefault) WithPayload(payload *models.Error) *GetHTTPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP response rule backend default response +func (o *GetHTTPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/get_http_response_rule_backend_urlbuilder.go b/operations/http_response_rule/get_http_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..8009c090 --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPResponseRuleBackendURL generates an URL for the get HTTP response rule backend operation +type GetHTTPResponseRuleBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPResponseRuleBackendURL) WithBasePath(bp string) *GetHTTPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/get_http_response_rule_defaults.go b/operations/http_response_rule/get_http_response_rule_defaults.go new file mode 100644 index 00000000..50ad5096 --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a get HTTP response rule defaults handler +type GetHTTPResponseRuleDefaultsHandlerFunc func(GetHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPResponseRuleDefaultsHandlerFunc) Handle(params GetHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPResponseRuleDefaultsHandler interface for that can handle valid get HTTP response rule defaults params +type GetHTTPResponseRuleDefaultsHandler interface { + Handle(GetHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetHTTPResponseRuleDefaults creates a new http.Handler for the get HTTP response rule defaults operation +func NewGetHTTPResponseRuleDefaults(ctx *middleware.Context, handler GetHTTPResponseRuleDefaultsHandler) *GetHTTPResponseRuleDefaults { + return &GetHTTPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetHTTPResponseRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index} HTTPResponseRule getHttpResponseRuleDefaults + +# Return one HTTP Response Rule + +Returns one HTTP Response Rule configuration by it's index in the specified parent. +*/ +type GetHTTPResponseRuleDefaults struct { + Context *middleware.Context + Handler GetHTTPResponseRuleDefaultsHandler +} + +func (o *GetHTTPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/get_http_response_rule_defaults_parameters.go b/operations/http_response_rule/get_http_response_rule_defaults_parameters.go new file mode 100644 index 00000000..c9ef817e --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPResponseRuleDefaultsParams creates a new GetHTTPResponseRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetHTTPResponseRuleDefaultsParams() GetHTTPResponseRuleDefaultsParams { + + return GetHTTPResponseRuleDefaultsParams{} +} + +// GetHTTPResponseRuleDefaultsParams contains all the bound params for the get HTTP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPResponseRuleDefaults +type GetHTTPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPResponseRuleDefaultsParams() beforehand. +func (o *GetHTTPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_response_rule/get_http_response_rule_defaults_responses.go b/operations/http_response_rule/get_http_response_rule_defaults_responses.go new file mode 100644 index 00000000..643fdd3e --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPResponseRuleDefaultsOKCode is the HTTP code returned for type GetHTTPResponseRuleDefaultsOK +const GetHTTPResponseRuleDefaultsOKCode int = 200 + +/* +GetHTTPResponseRuleDefaultsOK Successful operation + +swagger:response getHttpResponseRuleDefaultsOK +*/ +type GetHTTPResponseRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleDefaultsOK creates GetHTTPResponseRuleDefaultsOK with default headers values +func NewGetHTTPResponseRuleDefaultsOK() *GetHTTPResponseRuleDefaultsOK { + + return &GetHTTPResponseRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http response rule defaults o k response +func (o *GetHTTPResponseRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http response rule defaults o k response +func (o *GetHTTPResponseRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http response rule defaults o k response +func (o *GetHTTPResponseRuleDefaultsOK) WithPayload(payload *models.HTTPResponseRule) *GetHTTPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http response rule defaults o k response +func (o *GetHTTPResponseRuleDefaultsOK) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPResponseRuleDefaultsNotFoundCode is the HTTP code returned for type GetHTTPResponseRuleDefaultsNotFound +const GetHTTPResponseRuleDefaultsNotFoundCode int = 404 + +/* +GetHTTPResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response getHttpResponseRuleDefaultsNotFound +*/ +type GetHTTPResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleDefaultsNotFound creates GetHTTPResponseRuleDefaultsNotFound with default headers values +func NewGetHTTPResponseRuleDefaultsNotFound() *GetHTTPResponseRuleDefaultsNotFound { + + return &GetHTTPResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http response rule defaults not found response +func (o *GetHTTPResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http response rule defaults not found response +func (o *GetHTTPResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http response rule defaults not found response +func (o *GetHTTPResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *GetHTTPResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http response rule defaults not found response +func (o *GetHTTPResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPResponseRuleDefaultsDefault General Error + +swagger:response getHttpResponseRuleDefaultsDefault +*/ +type GetHTTPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleDefaultsDefault creates GetHTTPResponseRuleDefaultsDefault with default headers values +func NewGetHTTPResponseRuleDefaultsDefault(code int) *GetHTTPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP response rule defaults default response +func (o *GetHTTPResponseRuleDefaultsDefault) WithStatusCode(code int) *GetHTTPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP response rule defaults default response +func (o *GetHTTPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP response rule defaults default response +func (o *GetHTTPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP response rule defaults default response +func (o *GetHTTPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP response rule defaults default response +func (o *GetHTTPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *GetHTTPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP response rule defaults default response +func (o *GetHTTPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/get_http_response_rule_defaults_urlbuilder.go b/operations/http_response_rule/get_http_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..4202975e --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPResponseRuleDefaultsURL generates an URL for the get HTTP response rule defaults operation +type GetHTTPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPResponseRuleDefaultsURL) WithBasePath(bp string) *GetHTTPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/get_http_response_rule_frontend.go b/operations/http_response_rule/get_http_response_rule_frontend.go new file mode 100644 index 00000000..34fbf140 --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHTTPResponseRuleFrontendHandlerFunc turns a function with the right signature into a get HTTP response rule frontend handler +type GetHTTPResponseRuleFrontendHandlerFunc func(GetHTTPResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHTTPResponseRuleFrontendHandlerFunc) Handle(params GetHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetHTTPResponseRuleFrontendHandler interface for that can handle valid get HTTP response rule frontend params +type GetHTTPResponseRuleFrontendHandler interface { + Handle(GetHTTPResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetHTTPResponseRuleFrontend creates a new http.Handler for the get HTTP response rule frontend operation +func NewGetHTTPResponseRuleFrontend(ctx *middleware.Context, handler GetHTTPResponseRuleFrontendHandler) *GetHTTPResponseRuleFrontend { + return &GetHTTPResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetHTTPResponseRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index} HTTPResponseRule getHttpResponseRuleFrontend + +# Return one HTTP Response Rule + +Returns one HTTP Response Rule configuration by it's index in the specified parent. +*/ +type GetHTTPResponseRuleFrontend struct { + Context *middleware.Context + Handler GetHTTPResponseRuleFrontendHandler +} + +func (o *GetHTTPResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHTTPResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/get_http_response_rule_frontend_parameters.go b/operations/http_response_rule/get_http_response_rule_frontend_parameters.go new file mode 100644 index 00000000..6e9ee92d --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetHTTPResponseRuleFrontendParams creates a new GetHTTPResponseRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetHTTPResponseRuleFrontendParams() GetHTTPResponseRuleFrontendParams { + + return GetHTTPResponseRuleFrontendParams{} +} + +// GetHTTPResponseRuleFrontendParams contains all the bound params for the get HTTP response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getHTTPResponseRuleFrontend +type GetHTTPResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHTTPResponseRuleFrontendParams() beforehand. +func (o *GetHTTPResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetHTTPResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetHTTPResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetHTTPResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/http_response_rule/get_http_response_rule_frontend_responses.go b/operations/http_response_rule/get_http_response_rule_frontend_responses.go new file mode 100644 index 00000000..5aa4d2b3 --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetHTTPResponseRuleFrontendOKCode is the HTTP code returned for type GetHTTPResponseRuleFrontendOK +const GetHTTPResponseRuleFrontendOKCode int = 200 + +/* +GetHTTPResponseRuleFrontendOK Successful operation + +swagger:response getHttpResponseRuleFrontendOK +*/ +type GetHTTPResponseRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleFrontendOK creates GetHTTPResponseRuleFrontendOK with default headers values +func NewGetHTTPResponseRuleFrontendOK() *GetHTTPResponseRuleFrontendOK { + + return &GetHTTPResponseRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http response rule frontend o k response +func (o *GetHTTPResponseRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http response rule frontend o k response +func (o *GetHTTPResponseRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http response rule frontend o k response +func (o *GetHTTPResponseRuleFrontendOK) WithPayload(payload *models.HTTPResponseRule) *GetHTTPResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http response rule frontend o k response +func (o *GetHTTPResponseRuleFrontendOK) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetHTTPResponseRuleFrontendNotFoundCode is the HTTP code returned for type GetHTTPResponseRuleFrontendNotFound +const GetHTTPResponseRuleFrontendNotFoundCode int = 404 + +/* +GetHTTPResponseRuleFrontendNotFound The specified resource was not found + +swagger:response getHttpResponseRuleFrontendNotFound +*/ +type GetHTTPResponseRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleFrontendNotFound creates GetHTTPResponseRuleFrontendNotFound with default headers values +func NewGetHTTPResponseRuleFrontendNotFound() *GetHTTPResponseRuleFrontendNotFound { + + return &GetHTTPResponseRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Http response rule frontend not found response +func (o *GetHTTPResponseRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Http response rule frontend not found response +func (o *GetHTTPResponseRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Http response rule frontend not found response +func (o *GetHTTPResponseRuleFrontendNotFound) WithPayload(payload *models.Error) *GetHTTPResponseRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Http response rule frontend not found response +func (o *GetHTTPResponseRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetHTTPResponseRuleFrontendDefault General Error + +swagger:response getHttpResponseRuleFrontendDefault +*/ +type GetHTTPResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetHTTPResponseRuleFrontendDefault creates GetHTTPResponseRuleFrontendDefault with default headers values +func NewGetHTTPResponseRuleFrontendDefault(code int) *GetHTTPResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetHTTPResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get HTTP response rule frontend default response +func (o *GetHTTPResponseRuleFrontendDefault) WithStatusCode(code int) *GetHTTPResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get HTTP response rule frontend default response +func (o *GetHTTPResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get HTTP response rule frontend default response +func (o *GetHTTPResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetHTTPResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get HTTP response rule frontend default response +func (o *GetHTTPResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get HTTP response rule frontend default response +func (o *GetHTTPResponseRuleFrontendDefault) WithPayload(payload *models.Error) *GetHTTPResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get HTTP response rule frontend default response +func (o *GetHTTPResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHTTPResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/get_http_response_rule_frontend_urlbuilder.go b/operations/http_response_rule/get_http_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..0b5635ab --- /dev/null +++ b/operations/http_response_rule/get_http_response_rule_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetHTTPResponseRuleFrontendURL generates an URL for the get HTTP response rule frontend operation +type GetHTTPResponseRuleFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPResponseRuleFrontendURL) WithBasePath(bp string) *GetHTTPResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHTTPResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHTTPResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetHTTPResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetHTTPResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHTTPResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHTTPResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHTTPResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHTTPResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHTTPResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHTTPResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/get_http_response_rule_parameters.go b/operations/http_response_rule/get_http_response_rule_parameters.go deleted file mode 100644 index a2b8a300..00000000 --- a/operations/http_response_rule/get_http_response_rule_parameters.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetHTTPResponseRuleParams creates a new GetHTTPResponseRuleParams object -// no default values defined in spec. -func NewGetHTTPResponseRuleParams() GetHTTPResponseRuleParams { - - return GetHTTPResponseRuleParams{} -} - -// GetHTTPResponseRuleParams contains all the bound params for the get HTTP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters getHTTPResponseRule -type GetHTTPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*HTTP Response Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetHTTPResponseRuleParams() beforehand. -func (o *GetHTTPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *GetHTTPResponseRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetHTTPResponseRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetHTTPResponseRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetHTTPResponseRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetHTTPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/http_response_rule/get_http_response_rule_responses.go b/operations/http_response_rule/get_http_response_rule_responses.go deleted file mode 100644 index 0ae7d208..00000000 --- a/operations/http_response_rule/get_http_response_rule_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetHTTPResponseRuleOKCode is the HTTP code returned for type GetHTTPResponseRuleOK -const GetHTTPResponseRuleOKCode int = 200 - -/*GetHTTPResponseRuleOK Successful operation - -swagger:response getHttpResponseRuleOK -*/ -type GetHTTPResponseRuleOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetHTTPResponseRuleOKBody `json:"body,omitempty"` -} - -// NewGetHTTPResponseRuleOK creates GetHTTPResponseRuleOK with default headers values -func NewGetHTTPResponseRuleOK() *GetHTTPResponseRuleOK { - - return &GetHTTPResponseRuleOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Http response rule o k response -func (o *GetHTTPResponseRuleOK) WithConfigurationVersion(configurationVersion int64) *GetHTTPResponseRuleOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Http response rule o k response -func (o *GetHTTPResponseRuleOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Http response rule o k response -func (o *GetHTTPResponseRuleOK) WithPayload(payload *GetHTTPResponseRuleOKBody) *GetHTTPResponseRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Http response rule o k response -func (o *GetHTTPResponseRuleOK) SetPayload(payload *GetHTTPResponseRuleOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPResponseRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetHTTPResponseRuleNotFoundCode is the HTTP code returned for type GetHTTPResponseRuleNotFound -const GetHTTPResponseRuleNotFoundCode int = 404 - -/*GetHTTPResponseRuleNotFound The specified resource was not found - -swagger:response getHttpResponseRuleNotFound -*/ -type GetHTTPResponseRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetHTTPResponseRuleNotFound creates GetHTTPResponseRuleNotFound with default headers values -func NewGetHTTPResponseRuleNotFound() *GetHTTPResponseRuleNotFound { - - return &GetHTTPResponseRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Http response rule not found response -func (o *GetHTTPResponseRuleNotFound) WithConfigurationVersion(configurationVersion int64) *GetHTTPResponseRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Http response rule not found response -func (o *GetHTTPResponseRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Http response rule not found response -func (o *GetHTTPResponseRuleNotFound) WithPayload(payload *models.Error) *GetHTTPResponseRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Http response rule not found response -func (o *GetHTTPResponseRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPResponseRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetHTTPResponseRuleDefault General Error - -swagger:response getHttpResponseRuleDefault -*/ -type GetHTTPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetHTTPResponseRuleDefault creates GetHTTPResponseRuleDefault with default headers values -func NewGetHTTPResponseRuleDefault(code int) *GetHTTPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &GetHTTPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get HTTP response rule default response -func (o *GetHTTPResponseRuleDefault) WithStatusCode(code int) *GetHTTPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get HTTP response rule default response -func (o *GetHTTPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get HTTP response rule default response -func (o *GetHTTPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *GetHTTPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get HTTP response rule default response -func (o *GetHTTPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get HTTP response rule default response -func (o *GetHTTPResponseRuleDefault) WithPayload(payload *models.Error) *GetHTTPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get HTTP response rule default response -func (o *GetHTTPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_response_rule/get_http_response_rule_urlbuilder.go b/operations/http_response_rule/get_http_response_rule_urlbuilder.go deleted file mode 100644 index 40a61792..00000000 --- a/operations/http_response_rule/get_http_response_rule_urlbuilder.go +++ /dev/null @@ -1,142 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// GetHTTPResponseRuleURL generates an URL for the get HTTP response rule operation -type GetHTTPResponseRuleURL struct { - ID int64 - - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPResponseRuleURL) WithBasePath(bp string) *GetHTTPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetHTTPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_response_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on GetHTTPResponseRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetHTTPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetHTTPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetHTTPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetHTTPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetHTTPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetHTTPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_response_rule/get_http_response_rules.go b/operations/http_response_rule/get_http_response_rules.go deleted file mode 100644 index ff2fabc3..00000000 --- a/operations/http_response_rule/get_http_response_rules.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetHTTPResponseRulesHandlerFunc turns a function with the right signature into a get HTTP response rules handler -type GetHTTPResponseRulesHandlerFunc func(GetHTTPResponseRulesParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetHTTPResponseRulesHandlerFunc) Handle(params GetHTTPResponseRulesParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetHTTPResponseRulesHandler interface for that can handle valid get HTTP response rules params -type GetHTTPResponseRulesHandler interface { - Handle(GetHTTPResponseRulesParams, interface{}) middleware.Responder -} - -// NewGetHTTPResponseRules creates a new http.Handler for the get HTTP response rules operation -func NewGetHTTPResponseRules(ctx *middleware.Context, handler GetHTTPResponseRulesHandler) *GetHTTPResponseRules { - return &GetHTTPResponseRules{Context: ctx, Handler: handler} -} - -/*GetHTTPResponseRules swagger:route GET /services/haproxy/configuration/http_response_rules HTTPResponseRule getHttpResponseRules - -Return an array of all HTTP Response Rules - -Returns all HTTP Response Rules that are configured in specified parent. - -*/ -type GetHTTPResponseRules struct { - Context *middleware.Context - Handler GetHTTPResponseRulesHandler -} - -func (o *GetHTTPResponseRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetHTTPResponseRulesParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetHTTPResponseRulesOKBody get HTTP response rules o k body -// swagger:model GetHTTPResponseRulesOKBody -type GetHTTPResponseRulesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.HTTPResponseRules `json:"data"` -} - -// Validate validates this get HTTP response rules o k body -func (o *GetHTTPResponseRulesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetHTTPResponseRulesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getHttpResponseRulesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getHttpResponseRulesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetHTTPResponseRulesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetHTTPResponseRulesOKBody) UnmarshalBinary(b []byte) error { - var res GetHTTPResponseRulesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/http_response_rule/get_http_response_rules_parameters.go b/operations/http_response_rule/get_http_response_rules_parameters.go deleted file mode 100644 index 5a3bb9c0..00000000 --- a/operations/http_response_rule/get_http_response_rules_parameters.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetHTTPResponseRulesParams creates a new GetHTTPResponseRulesParams object -// no default values defined in spec. -func NewGetHTTPResponseRulesParams() GetHTTPResponseRulesParams { - - return GetHTTPResponseRulesParams{} -} - -// GetHTTPResponseRulesParams contains all the bound params for the get HTTP response rules operation -// typically these are obtained from a http.Request -// -// swagger:parameters getHTTPResponseRules -type GetHTTPResponseRulesParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetHTTPResponseRulesParams() beforehand. -func (o *GetHTTPResponseRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetHTTPResponseRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetHTTPResponseRulesParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetHTTPResponseRulesParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetHTTPResponseRulesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/http_response_rule/get_http_response_rules_responses.go b/operations/http_response_rule/get_http_response_rules_responses.go deleted file mode 100644 index 84242536..00000000 --- a/operations/http_response_rule/get_http_response_rules_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetHTTPResponseRulesOKCode is the HTTP code returned for type GetHTTPResponseRulesOK -const GetHTTPResponseRulesOKCode int = 200 - -/*GetHTTPResponseRulesOK Successful operation - -swagger:response getHttpResponseRulesOK -*/ -type GetHTTPResponseRulesOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetHTTPResponseRulesOKBody `json:"body,omitempty"` -} - -// NewGetHTTPResponseRulesOK creates GetHTTPResponseRulesOK with default headers values -func NewGetHTTPResponseRulesOK() *GetHTTPResponseRulesOK { - - return &GetHTTPResponseRulesOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Http response rules o k response -func (o *GetHTTPResponseRulesOK) WithConfigurationVersion(configurationVersion int64) *GetHTTPResponseRulesOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Http response rules o k response -func (o *GetHTTPResponseRulesOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Http response rules o k response -func (o *GetHTTPResponseRulesOK) WithPayload(payload *GetHTTPResponseRulesOKBody) *GetHTTPResponseRulesOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Http response rules o k response -func (o *GetHTTPResponseRulesOK) SetPayload(payload *GetHTTPResponseRulesOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPResponseRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetHTTPResponseRulesDefault General Error - -swagger:response getHttpResponseRulesDefault -*/ -type GetHTTPResponseRulesDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetHTTPResponseRulesDefault creates GetHTTPResponseRulesDefault with default headers values -func NewGetHTTPResponseRulesDefault(code int) *GetHTTPResponseRulesDefault { - if code <= 0 { - code = 500 - } - - return &GetHTTPResponseRulesDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get HTTP response rules default response -func (o *GetHTTPResponseRulesDefault) WithStatusCode(code int) *GetHTTPResponseRulesDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get HTTP response rules default response -func (o *GetHTTPResponseRulesDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get HTTP response rules default response -func (o *GetHTTPResponseRulesDefault) WithConfigurationVersion(configurationVersion int64) *GetHTTPResponseRulesDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get HTTP response rules default response -func (o *GetHTTPResponseRulesDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get HTTP response rules default response -func (o *GetHTTPResponseRulesDefault) WithPayload(payload *models.Error) *GetHTTPResponseRulesDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get HTTP response rules default response -func (o *GetHTTPResponseRulesDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetHTTPResponseRulesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_response_rule/get_http_response_rules_urlbuilder.go b/operations/http_response_rule/get_http_response_rules_urlbuilder.go deleted file mode 100644 index 7c7cc592..00000000 --- a/operations/http_response_rule/get_http_response_rules_urlbuilder.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetHTTPResponseRulesURL generates an URL for the get HTTP response rules operation -type GetHTTPResponseRulesURL struct { - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPResponseRulesURL) WithBasePath(bp string) *GetHTTPResponseRulesURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetHTTPResponseRulesURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetHTTPResponseRulesURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_response_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetHTTPResponseRulesURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetHTTPResponseRulesURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetHTTPResponseRulesURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetHTTPResponseRulesURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetHTTPResponseRulesURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetHTTPResponseRulesURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/http_response_rule/replace_all_http_response_rule_backend.go b/operations/http_response_rule/replace_all_http_response_rule_backend.go new file mode 100644 index 00000000..ffcf3525 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPResponseRuleBackendHandlerFunc turns a function with the right signature into a replace all HTTP response rule backend handler +type ReplaceAllHTTPResponseRuleBackendHandlerFunc func(ReplaceAllHTTPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPResponseRuleBackendHandlerFunc) Handle(params ReplaceAllHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPResponseRuleBackendHandler interface for that can handle valid replace all HTTP response rule backend params +type ReplaceAllHTTPResponseRuleBackendHandler interface { + Handle(ReplaceAllHTTPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPResponseRuleBackend creates a new http.Handler for the replace all HTTP response rule backend operation +func NewReplaceAllHTTPResponseRuleBackend(ctx *middleware.Context, handler ReplaceAllHTTPResponseRuleBackendHandler) *ReplaceAllHTTPResponseRuleBackend { + return &ReplaceAllHTTPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPResponseRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_response_rules HTTPResponseRule replaceAllHttpResponseRuleBackend + +# Replace an HTTP Response Rule list + +Replaces a whole list of HTTP Response Rules with the list given in parameter +*/ +type ReplaceAllHTTPResponseRuleBackend struct { + Context *middleware.Context + Handler ReplaceAllHTTPResponseRuleBackendHandler +} + +func (o *ReplaceAllHTTPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_backend_parameters.go b/operations/http_response_rule/replace_all_http_response_rule_backend_parameters.go new file mode 100644 index 00000000..2ed736be --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPResponseRuleBackendParams creates a new ReplaceAllHTTPResponseRuleBackendParams object +// with the default values initialized. +func NewReplaceAllHTTPResponseRuleBackendParams() ReplaceAllHTTPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPResponseRuleBackendParams contains all the bound params for the replace all HTTP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPResponseRuleBackend +type ReplaceAllHTTPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPResponseRuleBackendParams() beforehand. +func (o *ReplaceAllHTTPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_backend_responses.go b/operations/http_response_rule/replace_all_http_response_rule_backend_responses.go new file mode 100644 index 00000000..51dbe4d5 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPResponseRuleBackendOKCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleBackendOK +const ReplaceAllHTTPResponseRuleBackendOKCode int = 200 + +/* +ReplaceAllHTTPResponseRuleBackendOK All HTTP Response Rule lines replaced + +swagger:response replaceAllHttpResponseRuleBackendOK +*/ +type ReplaceAllHTTPResponseRuleBackendOK struct { + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleBackendOK creates ReplaceAllHTTPResponseRuleBackendOK with default headers values +func NewReplaceAllHTTPResponseRuleBackendOK() *ReplaceAllHTTPResponseRuleBackendOK { + + return &ReplaceAllHTTPResponseRuleBackendOK{} +} + +// WithPayload adds the payload to the replace all Http response rule backend o k response +func (o *ReplaceAllHTTPResponseRuleBackendOK) WithPayload(payload models.HTTPResponseRules) *ReplaceAllHTTPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule backend o k response +func (o *ReplaceAllHTTPResponseRuleBackendOK) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPResponseRuleBackendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleBackendAccepted +const ReplaceAllHTTPResponseRuleBackendAcceptedCode int = 202 + +/* +ReplaceAllHTTPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpResponseRuleBackendAccepted +*/ +type ReplaceAllHTTPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleBackendAccepted creates ReplaceAllHTTPResponseRuleBackendAccepted with default headers values +func NewReplaceAllHTTPResponseRuleBackendAccepted() *ReplaceAllHTTPResponseRuleBackendAccepted { + + return &ReplaceAllHTTPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http response rule backend accepted response +func (o *ReplaceAllHTTPResponseRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http response rule backend accepted response +func (o *ReplaceAllHTTPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http response rule backend accepted response +func (o *ReplaceAllHTTPResponseRuleBackendAccepted) WithPayload(payload models.HTTPResponseRules) *ReplaceAllHTTPResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule backend accepted response +func (o *ReplaceAllHTTPResponseRuleBackendAccepted) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPResponseRuleBackendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleBackendBadRequest +const ReplaceAllHTTPResponseRuleBackendBadRequestCode int = 400 + +/* +ReplaceAllHTTPResponseRuleBackendBadRequest Bad request + +swagger:response replaceAllHttpResponseRuleBackendBadRequest +*/ +type ReplaceAllHTTPResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleBackendBadRequest creates ReplaceAllHTTPResponseRuleBackendBadRequest with default headers values +func NewReplaceAllHTTPResponseRuleBackendBadRequest() *ReplaceAllHTTPResponseRuleBackendBadRequest { + + return &ReplaceAllHTTPResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http response rule backend bad request response +func (o *ReplaceAllHTTPResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http response rule backend bad request response +func (o *ReplaceAllHTTPResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http response rule backend bad request response +func (o *ReplaceAllHTTPResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule backend bad request response +func (o *ReplaceAllHTTPResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPResponseRuleBackendDefault General Error + +swagger:response replaceAllHttpResponseRuleBackendDefault +*/ +type ReplaceAllHTTPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleBackendDefault creates ReplaceAllHTTPResponseRuleBackendDefault with default headers values +func NewReplaceAllHTTPResponseRuleBackendDefault(code int) *ReplaceAllHTTPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP response rule backend default response +func (o *ReplaceAllHTTPResponseRuleBackendDefault) WithStatusCode(code int) *ReplaceAllHTTPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP response rule backend default response +func (o *ReplaceAllHTTPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP response rule backend default response +func (o *ReplaceAllHTTPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP response rule backend default response +func (o *ReplaceAllHTTPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP response rule backend default response +func (o *ReplaceAllHTTPResponseRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP response rule backend default response +func (o *ReplaceAllHTTPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_backend_urlbuilder.go b/operations/http_response_rule/replace_all_http_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..635e3eda --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPResponseRuleBackendURL generates an URL for the replace all HTTP response rule backend operation +type ReplaceAllHTTPResponseRuleBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPResponseRuleBackendURL) WithBasePath(bp string) *ReplaceAllHTTPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_defaults.go b/operations/http_response_rule/replace_all_http_response_rule_defaults.go new file mode 100644 index 00000000..e81221ef --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a replace all HTTP response rule defaults handler +type ReplaceAllHTTPResponseRuleDefaultsHandlerFunc func(ReplaceAllHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPResponseRuleDefaultsHandlerFunc) Handle(params ReplaceAllHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPResponseRuleDefaultsHandler interface for that can handle valid replace all HTTP response rule defaults params +type ReplaceAllHTTPResponseRuleDefaultsHandler interface { + Handle(ReplaceAllHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPResponseRuleDefaults creates a new http.Handler for the replace all HTTP response rule defaults operation +func NewReplaceAllHTTPResponseRuleDefaults(ctx *middleware.Context, handler ReplaceAllHTTPResponseRuleDefaultsHandler) *ReplaceAllHTTPResponseRuleDefaults { + return &ReplaceAllHTTPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPResponseRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_response_rules HTTPResponseRule replaceAllHttpResponseRuleDefaults + +# Replace an HTTP Response Rule list + +Replaces a whole list of HTTP Response Rules with the list given in parameter +*/ +type ReplaceAllHTTPResponseRuleDefaults struct { + Context *middleware.Context + Handler ReplaceAllHTTPResponseRuleDefaultsHandler +} + +func (o *ReplaceAllHTTPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_defaults_parameters.go b/operations/http_response_rule/replace_all_http_response_rule_defaults_parameters.go new file mode 100644 index 00000000..576e44e5 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPResponseRuleDefaultsParams creates a new ReplaceAllHTTPResponseRuleDefaultsParams object +// with the default values initialized. +func NewReplaceAllHTTPResponseRuleDefaultsParams() ReplaceAllHTTPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPResponseRuleDefaultsParams contains all the bound params for the replace all HTTP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPResponseRuleDefaults +type ReplaceAllHTTPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPResponseRuleDefaultsParams() beforehand. +func (o *ReplaceAllHTTPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_defaults_responses.go b/operations/http_response_rule/replace_all_http_response_rule_defaults_responses.go new file mode 100644 index 00000000..62602c04 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPResponseRuleDefaultsOKCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleDefaultsOK +const ReplaceAllHTTPResponseRuleDefaultsOKCode int = 200 + +/* +ReplaceAllHTTPResponseRuleDefaultsOK All HTTP Response Rule lines replaced + +swagger:response replaceAllHttpResponseRuleDefaultsOK +*/ +type ReplaceAllHTTPResponseRuleDefaultsOK struct { + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleDefaultsOK creates ReplaceAllHTTPResponseRuleDefaultsOK with default headers values +func NewReplaceAllHTTPResponseRuleDefaultsOK() *ReplaceAllHTTPResponseRuleDefaultsOK { + + return &ReplaceAllHTTPResponseRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Http response rule defaults o k response +func (o *ReplaceAllHTTPResponseRuleDefaultsOK) WithPayload(payload models.HTTPResponseRules) *ReplaceAllHTTPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule defaults o k response +func (o *ReplaceAllHTTPResponseRuleDefaultsOK) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleDefaultsAccepted +const ReplaceAllHTTPResponseRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceAllHTTPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpResponseRuleDefaultsAccepted +*/ +type ReplaceAllHTTPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleDefaultsAccepted creates ReplaceAllHTTPResponseRuleDefaultsAccepted with default headers values +func NewReplaceAllHTTPResponseRuleDefaultsAccepted() *ReplaceAllHTTPResponseRuleDefaultsAccepted { + + return &ReplaceAllHTTPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http response rule defaults accepted response +func (o *ReplaceAllHTTPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http response rule defaults accepted response +func (o *ReplaceAllHTTPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http response rule defaults accepted response +func (o *ReplaceAllHTTPResponseRuleDefaultsAccepted) WithPayload(payload models.HTTPResponseRules) *ReplaceAllHTTPResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule defaults accepted response +func (o *ReplaceAllHTTPResponseRuleDefaultsAccepted) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPResponseRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleDefaultsBadRequest +const ReplaceAllHTTPResponseRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceAllHTTPResponseRuleDefaultsBadRequest Bad request + +swagger:response replaceAllHttpResponseRuleDefaultsBadRequest +*/ +type ReplaceAllHTTPResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleDefaultsBadRequest creates ReplaceAllHTTPResponseRuleDefaultsBadRequest with default headers values +func NewReplaceAllHTTPResponseRuleDefaultsBadRequest() *ReplaceAllHTTPResponseRuleDefaultsBadRequest { + + return &ReplaceAllHTTPResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http response rule defaults bad request response +func (o *ReplaceAllHTTPResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http response rule defaults bad request response +func (o *ReplaceAllHTTPResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http response rule defaults bad request response +func (o *ReplaceAllHTTPResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule defaults bad request response +func (o *ReplaceAllHTTPResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPResponseRuleDefaultsDefault General Error + +swagger:response replaceAllHttpResponseRuleDefaultsDefault +*/ +type ReplaceAllHTTPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleDefaultsDefault creates ReplaceAllHTTPResponseRuleDefaultsDefault with default headers values +func NewReplaceAllHTTPResponseRuleDefaultsDefault(code int) *ReplaceAllHTTPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP response rule defaults default response +func (o *ReplaceAllHTTPResponseRuleDefaultsDefault) WithStatusCode(code int) *ReplaceAllHTTPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP response rule defaults default response +func (o *ReplaceAllHTTPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP response rule defaults default response +func (o *ReplaceAllHTTPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP response rule defaults default response +func (o *ReplaceAllHTTPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP response rule defaults default response +func (o *ReplaceAllHTTPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP response rule defaults default response +func (o *ReplaceAllHTTPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_defaults_urlbuilder.go b/operations/http_response_rule/replace_all_http_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..307173d4 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPResponseRuleDefaultsURL generates an URL for the replace all HTTP response rule defaults operation +type ReplaceAllHTTPResponseRuleDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPResponseRuleDefaultsURL) WithBasePath(bp string) *ReplaceAllHTTPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_frontend.go b/operations/http_response_rule/replace_all_http_response_rule_frontend.go new file mode 100644 index 00000000..be92aa68 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllHTTPResponseRuleFrontendHandlerFunc turns a function with the right signature into a replace all HTTP response rule frontend handler +type ReplaceAllHTTPResponseRuleFrontendHandlerFunc func(ReplaceAllHTTPResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllHTTPResponseRuleFrontendHandlerFunc) Handle(params ReplaceAllHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllHTTPResponseRuleFrontendHandler interface for that can handle valid replace all HTTP response rule frontend params +type ReplaceAllHTTPResponseRuleFrontendHandler interface { + Handle(ReplaceAllHTTPResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllHTTPResponseRuleFrontend creates a new http.Handler for the replace all HTTP response rule frontend operation +func NewReplaceAllHTTPResponseRuleFrontend(ctx *middleware.Context, handler ReplaceAllHTTPResponseRuleFrontendHandler) *ReplaceAllHTTPResponseRuleFrontend { + return &ReplaceAllHTTPResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllHTTPResponseRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_response_rules HTTPResponseRule replaceAllHttpResponseRuleFrontend + +# Replace an HTTP Response Rule list + +Replaces a whole list of HTTP Response Rules with the list given in parameter +*/ +type ReplaceAllHTTPResponseRuleFrontend struct { + Context *middleware.Context + Handler ReplaceAllHTTPResponseRuleFrontendHandler +} + +func (o *ReplaceAllHTTPResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllHTTPResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_frontend_parameters.go b/operations/http_response_rule/replace_all_http_response_rule_frontend_parameters.go new file mode 100644 index 00000000..5b117c23 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllHTTPResponseRuleFrontendParams creates a new ReplaceAllHTTPResponseRuleFrontendParams object +// with the default values initialized. +func NewReplaceAllHTTPResponseRuleFrontendParams() ReplaceAllHTTPResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllHTTPResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllHTTPResponseRuleFrontendParams contains all the bound params for the replace all HTTP response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllHTTPResponseRuleFrontend +type ReplaceAllHTTPResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.HTTPResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllHTTPResponseRuleFrontendParams() beforehand. +func (o *ReplaceAllHTTPResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllHTTPResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllHTTPResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllHTTPResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllHTTPResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllHTTPResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_frontend_responses.go b/operations/http_response_rule/replace_all_http_response_rule_frontend_responses.go new file mode 100644 index 00000000..081c226d --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllHTTPResponseRuleFrontendOKCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleFrontendOK +const ReplaceAllHTTPResponseRuleFrontendOKCode int = 200 + +/* +ReplaceAllHTTPResponseRuleFrontendOK All HTTP Response Rule lines replaced + +swagger:response replaceAllHttpResponseRuleFrontendOK +*/ +type ReplaceAllHTTPResponseRuleFrontendOK struct { + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleFrontendOK creates ReplaceAllHTTPResponseRuleFrontendOK with default headers values +func NewReplaceAllHTTPResponseRuleFrontendOK() *ReplaceAllHTTPResponseRuleFrontendOK { + + return &ReplaceAllHTTPResponseRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace all Http response rule frontend o k response +func (o *ReplaceAllHTTPResponseRuleFrontendOK) WithPayload(payload models.HTTPResponseRules) *ReplaceAllHTTPResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule frontend o k response +func (o *ReplaceAllHTTPResponseRuleFrontendOK) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPResponseRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleFrontendAccepted +const ReplaceAllHTTPResponseRuleFrontendAcceptedCode int = 202 + +/* +ReplaceAllHTTPResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllHttpResponseRuleFrontendAccepted +*/ +type ReplaceAllHTTPResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.HTTPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleFrontendAccepted creates ReplaceAllHTTPResponseRuleFrontendAccepted with default headers values +func NewReplaceAllHTTPResponseRuleFrontendAccepted() *ReplaceAllHTTPResponseRuleFrontendAccepted { + + return &ReplaceAllHTTPResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Http response rule frontend accepted response +func (o *ReplaceAllHTTPResponseRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllHTTPResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Http response rule frontend accepted response +func (o *ReplaceAllHTTPResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Http response rule frontend accepted response +func (o *ReplaceAllHTTPResponseRuleFrontendAccepted) WithPayload(payload models.HTTPResponseRules) *ReplaceAllHTTPResponseRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule frontend accepted response +func (o *ReplaceAllHTTPResponseRuleFrontendAccepted) SetPayload(payload models.HTTPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.HTTPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllHTTPResponseRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceAllHTTPResponseRuleFrontendBadRequest +const ReplaceAllHTTPResponseRuleFrontendBadRequestCode int = 400 + +/* +ReplaceAllHTTPResponseRuleFrontendBadRequest Bad request + +swagger:response replaceAllHttpResponseRuleFrontendBadRequest +*/ +type ReplaceAllHTTPResponseRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleFrontendBadRequest creates ReplaceAllHTTPResponseRuleFrontendBadRequest with default headers values +func NewReplaceAllHTTPResponseRuleFrontendBadRequest() *ReplaceAllHTTPResponseRuleFrontendBadRequest { + + return &ReplaceAllHTTPResponseRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Http response rule frontend bad request response +func (o *ReplaceAllHTTPResponseRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPResponseRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Http response rule frontend bad request response +func (o *ReplaceAllHTTPResponseRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Http response rule frontend bad request response +func (o *ReplaceAllHTTPResponseRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllHTTPResponseRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Http response rule frontend bad request response +func (o *ReplaceAllHTTPResponseRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllHTTPResponseRuleFrontendDefault General Error + +swagger:response replaceAllHttpResponseRuleFrontendDefault +*/ +type ReplaceAllHTTPResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllHTTPResponseRuleFrontendDefault creates ReplaceAllHTTPResponseRuleFrontendDefault with default headers values +func NewReplaceAllHTTPResponseRuleFrontendDefault(code int) *ReplaceAllHTTPResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllHTTPResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all HTTP response rule frontend default response +func (o *ReplaceAllHTTPResponseRuleFrontendDefault) WithStatusCode(code int) *ReplaceAllHTTPResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all HTTP response rule frontend default response +func (o *ReplaceAllHTTPResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all HTTP response rule frontend default response +func (o *ReplaceAllHTTPResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllHTTPResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all HTTP response rule frontend default response +func (o *ReplaceAllHTTPResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all HTTP response rule frontend default response +func (o *ReplaceAllHTTPResponseRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllHTTPResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all HTTP response rule frontend default response +func (o *ReplaceAllHTTPResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllHTTPResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/replace_all_http_response_rule_frontend_urlbuilder.go b/operations/http_response_rule/replace_all_http_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..79e9a0e3 --- /dev/null +++ b/operations/http_response_rule/replace_all_http_response_rule_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllHTTPResponseRuleFrontendURL generates an URL for the replace all HTTP response rule frontend operation +type ReplaceAllHTTPResponseRuleFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPResponseRuleFrontendURL) WithBasePath(bp string) *ReplaceAllHTTPResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllHTTPResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllHTTPResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllHTTPResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllHTTPResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllHTTPResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllHTTPResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllHTTPResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllHTTPResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllHTTPResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/replace_http_response_rule.go b/operations/http_response_rule/replace_http_response_rule.go deleted file mode 100644 index 05754274..00000000 --- a/operations/http_response_rule/replace_http_response_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceHTTPResponseRuleHandlerFunc turns a function with the right signature into a replace HTTP response rule handler -type ReplaceHTTPResponseRuleHandlerFunc func(ReplaceHTTPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceHTTPResponseRuleHandlerFunc) Handle(params ReplaceHTTPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceHTTPResponseRuleHandler interface for that can handle valid replace HTTP response rule params -type ReplaceHTTPResponseRuleHandler interface { - Handle(ReplaceHTTPResponseRuleParams, interface{}) middleware.Responder -} - -// NewReplaceHTTPResponseRule creates a new http.Handler for the replace HTTP response rule operation -func NewReplaceHTTPResponseRule(ctx *middleware.Context, handler ReplaceHTTPResponseRuleHandler) *ReplaceHTTPResponseRule { - return &ReplaceHTTPResponseRule{Context: ctx, Handler: handler} -} - -/*ReplaceHTTPResponseRule swagger:route PUT /services/haproxy/configuration/http_response_rules/{id} HTTPResponseRule replaceHttpResponseRule - -Replace a HTTP Response Rule - -Replaces a HTTP Response Rule configuration by it's ID in the specified parent. - -*/ -type ReplaceHTTPResponseRule struct { - Context *middleware.Context - Handler ReplaceHTTPResponseRuleHandler -} - -func (o *ReplaceHTTPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceHTTPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/http_response_rule/replace_http_response_rule_backend.go b/operations/http_response_rule/replace_http_response_rule_backend.go new file mode 100644 index 00000000..8bad65a1 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPResponseRuleBackendHandlerFunc turns a function with the right signature into a replace HTTP response rule backend handler +type ReplaceHTTPResponseRuleBackendHandlerFunc func(ReplaceHTTPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPResponseRuleBackendHandlerFunc) Handle(params ReplaceHTTPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPResponseRuleBackendHandler interface for that can handle valid replace HTTP response rule backend params +type ReplaceHTTPResponseRuleBackendHandler interface { + Handle(ReplaceHTTPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPResponseRuleBackend creates a new http.Handler for the replace HTTP response rule backend operation +func NewReplaceHTTPResponseRuleBackend(ctx *middleware.Context, handler ReplaceHTTPResponseRuleBackendHandler) *ReplaceHTTPResponseRuleBackend { + return &ReplaceHTTPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPResponseRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index} HTTPResponseRule replaceHttpResponseRuleBackend + +# Replace a HTTP Response Rule + +Replaces a HTTP Response Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPResponseRuleBackend struct { + Context *middleware.Context + Handler ReplaceHTTPResponseRuleBackendHandler +} + +func (o *ReplaceHTTPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/replace_http_response_rule_backend_parameters.go b/operations/http_response_rule/replace_http_response_rule_backend_parameters.go new file mode 100644 index 00000000..9e7b2038 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPResponseRuleBackendParams creates a new ReplaceHTTPResponseRuleBackendParams object +// with the default values initialized. +func NewReplaceHTTPResponseRuleBackendParams() ReplaceHTTPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPResponseRuleBackendParams contains all the bound params for the replace HTTP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPResponseRuleBackend +type ReplaceHTTPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPResponseRuleBackendParams() beforehand. +func (o *ReplaceHTTPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/replace_http_response_rule_backend_responses.go b/operations/http_response_rule/replace_http_response_rule_backend_responses.go new file mode 100644 index 00000000..4bddf943 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPResponseRuleBackendOKCode is the HTTP code returned for type ReplaceHTTPResponseRuleBackendOK +const ReplaceHTTPResponseRuleBackendOKCode int = 200 + +/* +ReplaceHTTPResponseRuleBackendOK HTTP Response Rule replaced + +swagger:response replaceHttpResponseRuleBackendOK +*/ +type ReplaceHTTPResponseRuleBackendOK struct { + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleBackendOK creates ReplaceHTTPResponseRuleBackendOK with default headers values +func NewReplaceHTTPResponseRuleBackendOK() *ReplaceHTTPResponseRuleBackendOK { + + return &ReplaceHTTPResponseRuleBackendOK{} +} + +// WithPayload adds the payload to the replace Http response rule backend o k response +func (o *ReplaceHTTPResponseRuleBackendOK) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule backend o k response +func (o *ReplaceHTTPResponseRuleBackendOK) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleBackendAcceptedCode is the HTTP code returned for type ReplaceHTTPResponseRuleBackendAccepted +const ReplaceHTTPResponseRuleBackendAcceptedCode int = 202 + +/* +ReplaceHTTPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpResponseRuleBackendAccepted +*/ +type ReplaceHTTPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleBackendAccepted creates ReplaceHTTPResponseRuleBackendAccepted with default headers values +func NewReplaceHTTPResponseRuleBackendAccepted() *ReplaceHTTPResponseRuleBackendAccepted { + + return &ReplaceHTTPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http response rule backend accepted response +func (o *ReplaceHTTPResponseRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceHTTPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http response rule backend accepted response +func (o *ReplaceHTTPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http response rule backend accepted response +func (o *ReplaceHTTPResponseRuleBackendAccepted) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule backend accepted response +func (o *ReplaceHTTPResponseRuleBackendAccepted) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleBackendBadRequestCode is the HTTP code returned for type ReplaceHTTPResponseRuleBackendBadRequest +const ReplaceHTTPResponseRuleBackendBadRequestCode int = 400 + +/* +ReplaceHTTPResponseRuleBackendBadRequest Bad request + +swagger:response replaceHttpResponseRuleBackendBadRequest +*/ +type ReplaceHTTPResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleBackendBadRequest creates ReplaceHTTPResponseRuleBackendBadRequest with default headers values +func NewReplaceHTTPResponseRuleBackendBadRequest() *ReplaceHTTPResponseRuleBackendBadRequest { + + return &ReplaceHTTPResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http response rule backend bad request response +func (o *ReplaceHTTPResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http response rule backend bad request response +func (o *ReplaceHTTPResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http response rule backend bad request response +func (o *ReplaceHTTPResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule backend bad request response +func (o *ReplaceHTTPResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleBackendNotFoundCode is the HTTP code returned for type ReplaceHTTPResponseRuleBackendNotFound +const ReplaceHTTPResponseRuleBackendNotFoundCode int = 404 + +/* +ReplaceHTTPResponseRuleBackendNotFound The specified resource was not found + +swagger:response replaceHttpResponseRuleBackendNotFound +*/ +type ReplaceHTTPResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleBackendNotFound creates ReplaceHTTPResponseRuleBackendNotFound with default headers values +func NewReplaceHTTPResponseRuleBackendNotFound() *ReplaceHTTPResponseRuleBackendNotFound { + + return &ReplaceHTTPResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http response rule backend not found response +func (o *ReplaceHTTPResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http response rule backend not found response +func (o *ReplaceHTTPResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http response rule backend not found response +func (o *ReplaceHTTPResponseRuleBackendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule backend not found response +func (o *ReplaceHTTPResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPResponseRuleBackendDefault General Error + +swagger:response replaceHttpResponseRuleBackendDefault +*/ +type ReplaceHTTPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleBackendDefault creates ReplaceHTTPResponseRuleBackendDefault with default headers values +func NewReplaceHTTPResponseRuleBackendDefault(code int) *ReplaceHTTPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP response rule backend default response +func (o *ReplaceHTTPResponseRuleBackendDefault) WithStatusCode(code int) *ReplaceHTTPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP response rule backend default response +func (o *ReplaceHTTPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP response rule backend default response +func (o *ReplaceHTTPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP response rule backend default response +func (o *ReplaceHTTPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP response rule backend default response +func (o *ReplaceHTTPResponseRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP response rule backend default response +func (o *ReplaceHTTPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/replace_http_response_rule_backend_urlbuilder.go b/operations/http_response_rule/replace_http_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..49d4b9a4 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPResponseRuleBackendURL generates an URL for the replace HTTP response rule backend operation +type ReplaceHTTPResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPResponseRuleBackendURL) WithBasePath(bp string) *ReplaceHTTPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/replace_http_response_rule_defaults.go b/operations/http_response_rule/replace_http_response_rule_defaults.go new file mode 100644 index 00000000..b4cef6eb --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a replace HTTP response rule defaults handler +type ReplaceHTTPResponseRuleDefaultsHandlerFunc func(ReplaceHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPResponseRuleDefaultsHandlerFunc) Handle(params ReplaceHTTPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPResponseRuleDefaultsHandler interface for that can handle valid replace HTTP response rule defaults params +type ReplaceHTTPResponseRuleDefaultsHandler interface { + Handle(ReplaceHTTPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPResponseRuleDefaults creates a new http.Handler for the replace HTTP response rule defaults operation +func NewReplaceHTTPResponseRuleDefaults(ctx *middleware.Context, handler ReplaceHTTPResponseRuleDefaultsHandler) *ReplaceHTTPResponseRuleDefaults { + return &ReplaceHTTPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPResponseRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index} HTTPResponseRule replaceHttpResponseRuleDefaults + +# Replace a HTTP Response Rule + +Replaces a HTTP Response Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPResponseRuleDefaults struct { + Context *middleware.Context + Handler ReplaceHTTPResponseRuleDefaultsHandler +} + +func (o *ReplaceHTTPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/replace_http_response_rule_defaults_parameters.go b/operations/http_response_rule/replace_http_response_rule_defaults_parameters.go new file mode 100644 index 00000000..342c5502 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPResponseRuleDefaultsParams creates a new ReplaceHTTPResponseRuleDefaultsParams object +// with the default values initialized. +func NewReplaceHTTPResponseRuleDefaultsParams() ReplaceHTTPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPResponseRuleDefaultsParams contains all the bound params for the replace HTTP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPResponseRuleDefaults +type ReplaceHTTPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPResponseRuleDefaultsParams() beforehand. +func (o *ReplaceHTTPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/replace_http_response_rule_defaults_responses.go b/operations/http_response_rule/replace_http_response_rule_defaults_responses.go new file mode 100644 index 00000000..90d02718 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPResponseRuleDefaultsOKCode is the HTTP code returned for type ReplaceHTTPResponseRuleDefaultsOK +const ReplaceHTTPResponseRuleDefaultsOKCode int = 200 + +/* +ReplaceHTTPResponseRuleDefaultsOK HTTP Response Rule replaced + +swagger:response replaceHttpResponseRuleDefaultsOK +*/ +type ReplaceHTTPResponseRuleDefaultsOK struct { + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleDefaultsOK creates ReplaceHTTPResponseRuleDefaultsOK with default headers values +func NewReplaceHTTPResponseRuleDefaultsOK() *ReplaceHTTPResponseRuleDefaultsOK { + + return &ReplaceHTTPResponseRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace Http response rule defaults o k response +func (o *ReplaceHTTPResponseRuleDefaultsOK) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule defaults o k response +func (o *ReplaceHTTPResponseRuleDefaultsOK) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceHTTPResponseRuleDefaultsAccepted +const ReplaceHTTPResponseRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceHTTPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpResponseRuleDefaultsAccepted +*/ +type ReplaceHTTPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleDefaultsAccepted creates ReplaceHTTPResponseRuleDefaultsAccepted with default headers values +func NewReplaceHTTPResponseRuleDefaultsAccepted() *ReplaceHTTPResponseRuleDefaultsAccepted { + + return &ReplaceHTTPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http response rule defaults accepted response +func (o *ReplaceHTTPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceHTTPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http response rule defaults accepted response +func (o *ReplaceHTTPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http response rule defaults accepted response +func (o *ReplaceHTTPResponseRuleDefaultsAccepted) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule defaults accepted response +func (o *ReplaceHTTPResponseRuleDefaultsAccepted) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceHTTPResponseRuleDefaultsBadRequest +const ReplaceHTTPResponseRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceHTTPResponseRuleDefaultsBadRequest Bad request + +swagger:response replaceHttpResponseRuleDefaultsBadRequest +*/ +type ReplaceHTTPResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleDefaultsBadRequest creates ReplaceHTTPResponseRuleDefaultsBadRequest with default headers values +func NewReplaceHTTPResponseRuleDefaultsBadRequest() *ReplaceHTTPResponseRuleDefaultsBadRequest { + + return &ReplaceHTTPResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http response rule defaults bad request response +func (o *ReplaceHTTPResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http response rule defaults bad request response +func (o *ReplaceHTTPResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http response rule defaults bad request response +func (o *ReplaceHTTPResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule defaults bad request response +func (o *ReplaceHTTPResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleDefaultsNotFoundCode is the HTTP code returned for type ReplaceHTTPResponseRuleDefaultsNotFound +const ReplaceHTTPResponseRuleDefaultsNotFoundCode int = 404 + +/* +ReplaceHTTPResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response replaceHttpResponseRuleDefaultsNotFound +*/ +type ReplaceHTTPResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleDefaultsNotFound creates ReplaceHTTPResponseRuleDefaultsNotFound with default headers values +func NewReplaceHTTPResponseRuleDefaultsNotFound() *ReplaceHTTPResponseRuleDefaultsNotFound { + + return &ReplaceHTTPResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http response rule defaults not found response +func (o *ReplaceHTTPResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http response rule defaults not found response +func (o *ReplaceHTTPResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http response rule defaults not found response +func (o *ReplaceHTTPResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule defaults not found response +func (o *ReplaceHTTPResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPResponseRuleDefaultsDefault General Error + +swagger:response replaceHttpResponseRuleDefaultsDefault +*/ +type ReplaceHTTPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleDefaultsDefault creates ReplaceHTTPResponseRuleDefaultsDefault with default headers values +func NewReplaceHTTPResponseRuleDefaultsDefault(code int) *ReplaceHTTPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP response rule defaults default response +func (o *ReplaceHTTPResponseRuleDefaultsDefault) WithStatusCode(code int) *ReplaceHTTPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP response rule defaults default response +func (o *ReplaceHTTPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP response rule defaults default response +func (o *ReplaceHTTPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP response rule defaults default response +func (o *ReplaceHTTPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP response rule defaults default response +func (o *ReplaceHTTPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP response rule defaults default response +func (o *ReplaceHTTPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/replace_http_response_rule_defaults_urlbuilder.go b/operations/http_response_rule/replace_http_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..cc12768c --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPResponseRuleDefaultsURL generates an URL for the replace HTTP response rule defaults operation +type ReplaceHTTPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPResponseRuleDefaultsURL) WithBasePath(bp string) *ReplaceHTTPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/replace_http_response_rule_frontend.go b/operations/http_response_rule/replace_http_response_rule_frontend.go new file mode 100644 index 00000000..5dbfb231 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceHTTPResponseRuleFrontendHandlerFunc turns a function with the right signature into a replace HTTP response rule frontend handler +type ReplaceHTTPResponseRuleFrontendHandlerFunc func(ReplaceHTTPResponseRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceHTTPResponseRuleFrontendHandlerFunc) Handle(params ReplaceHTTPResponseRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceHTTPResponseRuleFrontendHandler interface for that can handle valid replace HTTP response rule frontend params +type ReplaceHTTPResponseRuleFrontendHandler interface { + Handle(ReplaceHTTPResponseRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceHTTPResponseRuleFrontend creates a new http.Handler for the replace HTTP response rule frontend operation +func NewReplaceHTTPResponseRuleFrontend(ctx *middleware.Context, handler ReplaceHTTPResponseRuleFrontendHandler) *ReplaceHTTPResponseRuleFrontend { + return &ReplaceHTTPResponseRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceHTTPResponseRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index} HTTPResponseRule replaceHttpResponseRuleFrontend + +# Replace a HTTP Response Rule + +Replaces a HTTP Response Rule configuration by it's index in the specified parent. +*/ +type ReplaceHTTPResponseRuleFrontend struct { + Context *middleware.Context + Handler ReplaceHTTPResponseRuleFrontendHandler +} + +func (o *ReplaceHTTPResponseRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceHTTPResponseRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/http_response_rule/replace_http_response_rule_frontend_parameters.go b/operations/http_response_rule/replace_http_response_rule_frontend_parameters.go new file mode 100644 index 00000000..0cdab708 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceHTTPResponseRuleFrontendParams creates a new ReplaceHTTPResponseRuleFrontendParams object +// with the default values initialized. +func NewReplaceHTTPResponseRuleFrontendParams() ReplaceHTTPResponseRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceHTTPResponseRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceHTTPResponseRuleFrontendParams contains all the bound params for the replace HTTP response rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceHTTPResponseRuleFrontend +type ReplaceHTTPResponseRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.HTTPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*HTTP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceHTTPResponseRuleFrontendParams() beforehand. +func (o *ReplaceHTTPResponseRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.HTTPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceHTTPResponseRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceHTTPResponseRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceHTTPResponseRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceHTTPResponseRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceHTTPResponseRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceHTTPResponseRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/http_response_rule/replace_http_response_rule_frontend_responses.go b/operations/http_response_rule/replace_http_response_rule_frontend_responses.go new file mode 100644 index 00000000..18b8559f --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceHTTPResponseRuleFrontendOKCode is the HTTP code returned for type ReplaceHTTPResponseRuleFrontendOK +const ReplaceHTTPResponseRuleFrontendOKCode int = 200 + +/* +ReplaceHTTPResponseRuleFrontendOK HTTP Response Rule replaced + +swagger:response replaceHttpResponseRuleFrontendOK +*/ +type ReplaceHTTPResponseRuleFrontendOK struct { + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleFrontendOK creates ReplaceHTTPResponseRuleFrontendOK with default headers values +func NewReplaceHTTPResponseRuleFrontendOK() *ReplaceHTTPResponseRuleFrontendOK { + + return &ReplaceHTTPResponseRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace Http response rule frontend o k response +func (o *ReplaceHTTPResponseRuleFrontendOK) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule frontend o k response +func (o *ReplaceHTTPResponseRuleFrontendOK) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceHTTPResponseRuleFrontendAccepted +const ReplaceHTTPResponseRuleFrontendAcceptedCode int = 202 + +/* +ReplaceHTTPResponseRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceHttpResponseRuleFrontendAccepted +*/ +type ReplaceHTTPResponseRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.HTTPResponseRule `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleFrontendAccepted creates ReplaceHTTPResponseRuleFrontendAccepted with default headers values +func NewReplaceHTTPResponseRuleFrontendAccepted() *ReplaceHTTPResponseRuleFrontendAccepted { + + return &ReplaceHTTPResponseRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Http response rule frontend accepted response +func (o *ReplaceHTTPResponseRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceHTTPResponseRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Http response rule frontend accepted response +func (o *ReplaceHTTPResponseRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Http response rule frontend accepted response +func (o *ReplaceHTTPResponseRuleFrontendAccepted) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule frontend accepted response +func (o *ReplaceHTTPResponseRuleFrontendAccepted) SetPayload(payload *models.HTTPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceHTTPResponseRuleFrontendBadRequest +const ReplaceHTTPResponseRuleFrontendBadRequestCode int = 400 + +/* +ReplaceHTTPResponseRuleFrontendBadRequest Bad request + +swagger:response replaceHttpResponseRuleFrontendBadRequest +*/ +type ReplaceHTTPResponseRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleFrontendBadRequest creates ReplaceHTTPResponseRuleFrontendBadRequest with default headers values +func NewReplaceHTTPResponseRuleFrontendBadRequest() *ReplaceHTTPResponseRuleFrontendBadRequest { + + return &ReplaceHTTPResponseRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http response rule frontend bad request response +func (o *ReplaceHTTPResponseRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http response rule frontend bad request response +func (o *ReplaceHTTPResponseRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http response rule frontend bad request response +func (o *ReplaceHTTPResponseRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule frontend bad request response +func (o *ReplaceHTTPResponseRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceHTTPResponseRuleFrontendNotFoundCode is the HTTP code returned for type ReplaceHTTPResponseRuleFrontendNotFound +const ReplaceHTTPResponseRuleFrontendNotFoundCode int = 404 + +/* +ReplaceHTTPResponseRuleFrontendNotFound The specified resource was not found + +swagger:response replaceHttpResponseRuleFrontendNotFound +*/ +type ReplaceHTTPResponseRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleFrontendNotFound creates ReplaceHTTPResponseRuleFrontendNotFound with default headers values +func NewReplaceHTTPResponseRuleFrontendNotFound() *ReplaceHTTPResponseRuleFrontendNotFound { + + return &ReplaceHTTPResponseRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Http response rule frontend not found response +func (o *ReplaceHTTPResponseRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Http response rule frontend not found response +func (o *ReplaceHTTPResponseRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Http response rule frontend not found response +func (o *ReplaceHTTPResponseRuleFrontendNotFound) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Http response rule frontend not found response +func (o *ReplaceHTTPResponseRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceHTTPResponseRuleFrontendDefault General Error + +swagger:response replaceHttpResponseRuleFrontendDefault +*/ +type ReplaceHTTPResponseRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceHTTPResponseRuleFrontendDefault creates ReplaceHTTPResponseRuleFrontendDefault with default headers values +func NewReplaceHTTPResponseRuleFrontendDefault(code int) *ReplaceHTTPResponseRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceHTTPResponseRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace HTTP response rule frontend default response +func (o *ReplaceHTTPResponseRuleFrontendDefault) WithStatusCode(code int) *ReplaceHTTPResponseRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace HTTP response rule frontend default response +func (o *ReplaceHTTPResponseRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace HTTP response rule frontend default response +func (o *ReplaceHTTPResponseRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceHTTPResponseRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace HTTP response rule frontend default response +func (o *ReplaceHTTPResponseRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace HTTP response rule frontend default response +func (o *ReplaceHTTPResponseRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace HTTP response rule frontend default response +func (o *ReplaceHTTPResponseRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceHTTPResponseRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/http_response_rule/replace_http_response_rule_frontend_urlbuilder.go b/operations/http_response_rule/replace_http_response_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..5a9ca611 --- /dev/null +++ b/operations/http_response_rule/replace_http_response_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package http_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceHTTPResponseRuleFrontendURL generates an URL for the replace HTTP response rule frontend operation +type ReplaceHTTPResponseRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPResponseRuleFrontendURL) WithBasePath(bp string) *ReplaceHTTPResponseRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceHTTPResponseRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceHTTPResponseRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/http_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceHTTPResponseRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceHTTPResponseRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceHTTPResponseRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceHTTPResponseRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceHTTPResponseRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceHTTPResponseRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceHTTPResponseRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceHTTPResponseRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/http_response_rule/replace_http_response_rule_parameters.go b/operations/http_response_rule/replace_http_response_rule_parameters.go deleted file mode 100644 index 5122d709..00000000 --- a/operations/http_response_rule/replace_http_response_rule_parameters.go +++ /dev/null @@ -1,302 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceHTTPResponseRuleParams creates a new ReplaceHTTPResponseRuleParams object -// with the default values initialized. -func NewReplaceHTTPResponseRuleParams() ReplaceHTTPResponseRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceHTTPResponseRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceHTTPResponseRuleParams contains all the bound params for the replace HTTP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceHTTPResponseRule -type ReplaceHTTPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.HTTPResponseRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*HTTP Response Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceHTTPResponseRuleParams() beforehand. -func (o *ReplaceHTTPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.HTTPResponseRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceHTTPResponseRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceHTTPResponseRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *ReplaceHTTPResponseRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *ReplaceHTTPResponseRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *ReplaceHTTPResponseRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *ReplaceHTTPResponseRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceHTTPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceHTTPResponseRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/http_response_rule/replace_http_response_rule_responses.go b/operations/http_response_rule/replace_http_response_rule_responses.go deleted file mode 100644 index 7320cb58..00000000 --- a/operations/http_response_rule/replace_http_response_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceHTTPResponseRuleOKCode is the HTTP code returned for type ReplaceHTTPResponseRuleOK -const ReplaceHTTPResponseRuleOKCode int = 200 - -/*ReplaceHTTPResponseRuleOK HTTP Response Rule replaced - -swagger:response replaceHttpResponseRuleOK -*/ -type ReplaceHTTPResponseRuleOK struct { - - /* - In: Body - */ - Payload *models.HTTPResponseRule `json:"body,omitempty"` -} - -// NewReplaceHTTPResponseRuleOK creates ReplaceHTTPResponseRuleOK with default headers values -func NewReplaceHTTPResponseRuleOK() *ReplaceHTTPResponseRuleOK { - - return &ReplaceHTTPResponseRuleOK{} -} - -// WithPayload adds the payload to the replace Http response rule o k response -func (o *ReplaceHTTPResponseRuleOK) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http response rule o k response -func (o *ReplaceHTTPResponseRuleOK) SetPayload(payload *models.HTTPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPResponseRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceHTTPResponseRuleAcceptedCode is the HTTP code returned for type ReplaceHTTPResponseRuleAccepted -const ReplaceHTTPResponseRuleAcceptedCode int = 202 - -/*ReplaceHTTPResponseRuleAccepted Configuration change accepted and reload requested - -swagger:response replaceHttpResponseRuleAccepted -*/ -type ReplaceHTTPResponseRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.HTTPResponseRule `json:"body,omitempty"` -} - -// NewReplaceHTTPResponseRuleAccepted creates ReplaceHTTPResponseRuleAccepted with default headers values -func NewReplaceHTTPResponseRuleAccepted() *ReplaceHTTPResponseRuleAccepted { - - return &ReplaceHTTPResponseRuleAccepted{} -} - -// WithReloadID adds the reloadId to the replace Http response rule accepted response -func (o *ReplaceHTTPResponseRuleAccepted) WithReloadID(reloadID string) *ReplaceHTTPResponseRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace Http response rule accepted response -func (o *ReplaceHTTPResponseRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace Http response rule accepted response -func (o *ReplaceHTTPResponseRuleAccepted) WithPayload(payload *models.HTTPResponseRule) *ReplaceHTTPResponseRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http response rule accepted response -func (o *ReplaceHTTPResponseRuleAccepted) SetPayload(payload *models.HTTPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPResponseRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceHTTPResponseRuleBadRequestCode is the HTTP code returned for type ReplaceHTTPResponseRuleBadRequest -const ReplaceHTTPResponseRuleBadRequestCode int = 400 - -/*ReplaceHTTPResponseRuleBadRequest Bad request - -swagger:response replaceHttpResponseRuleBadRequest -*/ -type ReplaceHTTPResponseRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceHTTPResponseRuleBadRequest creates ReplaceHTTPResponseRuleBadRequest with default headers values -func NewReplaceHTTPResponseRuleBadRequest() *ReplaceHTTPResponseRuleBadRequest { - - return &ReplaceHTTPResponseRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Http response rule bad request response -func (o *ReplaceHTTPResponseRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceHTTPResponseRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Http response rule bad request response -func (o *ReplaceHTTPResponseRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Http response rule bad request response -func (o *ReplaceHTTPResponseRuleBadRequest) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http response rule bad request response -func (o *ReplaceHTTPResponseRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPResponseRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceHTTPResponseRuleNotFoundCode is the HTTP code returned for type ReplaceHTTPResponseRuleNotFound -const ReplaceHTTPResponseRuleNotFoundCode int = 404 - -/*ReplaceHTTPResponseRuleNotFound The specified resource was not found - -swagger:response replaceHttpResponseRuleNotFound -*/ -type ReplaceHTTPResponseRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceHTTPResponseRuleNotFound creates ReplaceHTTPResponseRuleNotFound with default headers values -func NewReplaceHTTPResponseRuleNotFound() *ReplaceHTTPResponseRuleNotFound { - - return &ReplaceHTTPResponseRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Http response rule not found response -func (o *ReplaceHTTPResponseRuleNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceHTTPResponseRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Http response rule not found response -func (o *ReplaceHTTPResponseRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Http response rule not found response -func (o *ReplaceHTTPResponseRuleNotFound) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Http response rule not found response -func (o *ReplaceHTTPResponseRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPResponseRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceHTTPResponseRuleDefault General Error - -swagger:response replaceHttpResponseRuleDefault -*/ -type ReplaceHTTPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceHTTPResponseRuleDefault creates ReplaceHTTPResponseRuleDefault with default headers values -func NewReplaceHTTPResponseRuleDefault(code int) *ReplaceHTTPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceHTTPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace HTTP response rule default response -func (o *ReplaceHTTPResponseRuleDefault) WithStatusCode(code int) *ReplaceHTTPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace HTTP response rule default response -func (o *ReplaceHTTPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace HTTP response rule default response -func (o *ReplaceHTTPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceHTTPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace HTTP response rule default response -func (o *ReplaceHTTPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace HTTP response rule default response -func (o *ReplaceHTTPResponseRuleDefault) WithPayload(payload *models.Error) *ReplaceHTTPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace HTTP response rule default response -func (o *ReplaceHTTPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceHTTPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/http_response_rule/replace_http_response_rule_urlbuilder.go b/operations/http_response_rule/replace_http_response_rule_urlbuilder.go deleted file mode 100644 index a7258049..00000000 --- a/operations/http_response_rule/replace_http_response_rule_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package http_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceHTTPResponseRuleURL generates an URL for the replace HTTP response rule operation -type ReplaceHTTPResponseRuleURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceHTTPResponseRuleURL) WithBasePath(bp string) *ReplaceHTTPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceHTTPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceHTTPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/http_response_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on ReplaceHTTPResponseRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceHTTPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceHTTPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceHTTPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceHTTPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceHTTPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceHTTPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/information/get_haproxy_process_info.go b/operations/information/get_haproxy_process_info.go index 5bb82270..08b8f4e4 100644 --- a/operations/information/get_haproxy_process_info.go +++ b/operations/information/get_haproxy_process_info.go @@ -23,7 +23,7 @@ package information import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetHaproxyProcessInfoHandlerFunc turns a function with the right signature into a get haproxy process info handler @@ -44,12 +44,12 @@ func NewGetHaproxyProcessInfo(ctx *middleware.Context, handler GetHaproxyProcess return &GetHaproxyProcessInfo{Context: ctx, Handler: handler} } -/*GetHaproxyProcessInfo swagger:route GET /services/haproxy/info Information getHaproxyProcessInfo +/* + GetHaproxyProcessInfo swagger:route GET /services/haproxy/runtime/info Information getHaproxyProcessInfo -Return HAProxy process information +# Return HAProxy process information Return HAProxy process information - */ type GetHaproxyProcessInfo struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetHaproxyProcessInfo struct { func (o *GetHaproxyProcessInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetHaproxyProcessInfoParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetHaproxyProcessInfo) ServeHTTP(rw http.ResponseWriter, r *http.Reques } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/information/get_haproxy_process_info_parameters.go b/operations/information/get_haproxy_process_info_parameters.go index 26279515..f4f800be 100644 --- a/operations/information/get_haproxy_process_info_parameters.go +++ b/operations/information/get_haproxy_process_info_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetHaproxyProcessInfoParams creates a new GetHaproxyProcessInfoParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetHaproxyProcessInfoParams() GetHaproxyProcessInfoParams { return GetHaproxyProcessInfoParams{} diff --git a/operations/information/get_haproxy_process_info_responses.go b/operations/information/get_haproxy_process_info_responses.go index 977e1db6..cb6be2ba 100644 --- a/operations/information/get_haproxy_process_info_responses.go +++ b/operations/information/get_haproxy_process_info_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetHaproxyProcessInfoOKCode is the HTTP code returned for type GetHaproxyProcessInfoOK const GetHaproxyProcessInfoOKCode int = 200 -/*GetHaproxyProcessInfoOK Success +/* +GetHaproxyProcessInfoOK Success swagger:response getHaproxyProcessInfoOK */ @@ -73,7 +73,8 @@ func (o *GetHaproxyProcessInfoOK) WriteResponse(rw http.ResponseWriter, producer } } -/*GetHaproxyProcessInfoDefault General Error +/* +GetHaproxyProcessInfoDefault General Error swagger:response getHaproxyProcessInfoDefault */ @@ -82,7 +83,7 @@ type GetHaproxyProcessInfoDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -113,13 +114,13 @@ func (o *GetHaproxyProcessInfoDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get haproxy process info default response -func (o *GetHaproxyProcessInfoDefault) WithConfigurationVersion(configurationVersion int64) *GetHaproxyProcessInfoDefault { +func (o *GetHaproxyProcessInfoDefault) WithConfigurationVersion(configurationVersion string) *GetHaproxyProcessInfoDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get haproxy process info default response -func (o *GetHaproxyProcessInfoDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetHaproxyProcessInfoDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -139,7 +140,7 @@ func (o *GetHaproxyProcessInfoDefault) WriteResponse(rw http.ResponseWriter, pro // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/information/get_haproxy_process_info_urlbuilder.go b/operations/information/get_haproxy_process_info_urlbuilder.go index 3784dfc0..e2510349 100644 --- a/operations/information/get_haproxy_process_info_urlbuilder.go +++ b/operations/information/get_haproxy_process_info_urlbuilder.go @@ -50,11 +50,11 @@ func (o *GetHaproxyProcessInfoURL) SetBasePath(bp string) { func (o *GetHaproxyProcessInfoURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/info" + var _path = "/services/haproxy/runtime/info" _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/information/get_info.go b/operations/information/get_info.go index 54bb3ad4..08a9b83a 100644 --- a/operations/information/get_info.go +++ b/operations/information/get_info.go @@ -23,7 +23,7 @@ package information import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetInfoHandlerFunc turns a function with the right signature into a get info handler @@ -44,12 +44,12 @@ func NewGetInfo(ctx *middleware.Context, handler GetInfoHandler) *GetInfo { return &GetInfo{Context: ctx, Handler: handler} } -/*GetInfo swagger:route GET /info Information getInfo +/* + GetInfo swagger:route GET /info Information getInfo -Return API, hardware and OS information +# Return API, hardware and OS information Return API, hardware and OS information - */ type GetInfo struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetInfo struct { func (o *GetInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetInfoParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/information/get_info_parameters.go b/operations/information/get_info_parameters.go index 751f432b..4e2594ac 100644 --- a/operations/information/get_info_parameters.go +++ b/operations/information/get_info_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetInfoParams creates a new GetInfoParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetInfoParams() GetInfoParams { return GetInfoParams{} diff --git a/operations/information/get_info_responses.go b/operations/information/get_info_responses.go index 5d98cbed..751f8ac8 100644 --- a/operations/information/get_info_responses.go +++ b/operations/information/get_info_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetInfoOKCode is the HTTP code returned for type GetInfoOK const GetInfoOKCode int = 200 -/*GetInfoOK Success +/* +GetInfoOK Success swagger:response getInfoOK */ @@ -73,7 +73,8 @@ func (o *GetInfoOK) WriteResponse(rw http.ResponseWriter, producer runtime.Produ } } -/*GetInfoDefault General Error +/* +GetInfoDefault General Error swagger:response getInfoDefault */ @@ -82,7 +83,7 @@ type GetInfoDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -113,13 +114,13 @@ func (o *GetInfoDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get info default response -func (o *GetInfoDefault) WithConfigurationVersion(configurationVersion int64) *GetInfoDefault { +func (o *GetInfoDefault) WithConfigurationVersion(configurationVersion string) *GetInfoDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get info default response -func (o *GetInfoDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetInfoDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -139,7 +140,7 @@ func (o *GetInfoDefault) WriteResponse(rw http.ResponseWriter, producer runtime. // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/information/get_info_urlbuilder.go b/operations/information/get_info_urlbuilder.go index 3f0aeee2..c1bd8756 100644 --- a/operations/information/get_info_urlbuilder.go +++ b/operations/information/get_info_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetInfoURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/log_forward/create_log_forward.go b/operations/log_forward/create_log_forward.go new file mode 100644 index 00000000..51e4266f --- /dev/null +++ b/operations/log_forward/create_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogForwardHandlerFunc turns a function with the right signature into a create log forward handler +type CreateLogForwardHandlerFunc func(CreateLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogForwardHandlerFunc) Handle(params CreateLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogForwardHandler interface for that can handle valid create log forward params +type CreateLogForwardHandler interface { + Handle(CreateLogForwardParams, interface{}) middleware.Responder +} + +// NewCreateLogForward creates a new http.Handler for the create log forward operation +func NewCreateLogForward(ctx *middleware.Context, handler CreateLogForwardHandler) *CreateLogForward { + return &CreateLogForward{Context: ctx, Handler: handler} +} + +/* + CreateLogForward swagger:route POST /services/haproxy/configuration/log_forwards LogForward createLogForward + +# Add a log forward + +Adds a new log_forward to the configuration file. +*/ +type CreateLogForward struct { + Context *middleware.Context + Handler CreateLogForwardHandler +} + +func (o *CreateLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_forward/create_log_forward_parameters.go b/operations/log_forward/create_log_forward_parameters.go new file mode 100644 index 00000000..f9fcbea3 --- /dev/null +++ b/operations/log_forward/create_log_forward_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogForwardParams creates a new CreateLogForwardParams object +// with the default values initialized. +func NewCreateLogForwardParams() CreateLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreateLogForwardParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreateLogForwardParams contains all the bound params for the create log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogForward +type CreateLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogForward + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogForwardParams() beforehand. +func (o *CreateLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogForward + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateLogForwardParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_forward/create_log_forward_responses.go b/operations/log_forward/create_log_forward_responses.go new file mode 100644 index 00000000..154fb552 --- /dev/null +++ b/operations/log_forward/create_log_forward_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogForwardCreatedCode is the HTTP code returned for type CreateLogForwardCreated +const CreateLogForwardCreatedCode int = 201 + +/* +CreateLogForwardCreated Log Forward created + +swagger:response createLogForwardCreated +*/ +type CreateLogForwardCreated struct { + + /* + In: Body + */ + Payload *models.LogForward `json:"body,omitempty"` +} + +// NewCreateLogForwardCreated creates CreateLogForwardCreated with default headers values +func NewCreateLogForwardCreated() *CreateLogForwardCreated { + + return &CreateLogForwardCreated{} +} + +// WithPayload adds the payload to the create log forward created response +func (o *CreateLogForwardCreated) WithPayload(payload *models.LogForward) *CreateLogForwardCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log forward created response +func (o *CreateLogForwardCreated) SetPayload(payload *models.LogForward) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogForwardCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogForwardAcceptedCode is the HTTP code returned for type CreateLogForwardAccepted +const CreateLogForwardAcceptedCode int = 202 + +/* +CreateLogForwardAccepted Configuration change accepted and reload requested + +swagger:response createLogForwardAccepted +*/ +type CreateLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogForward `json:"body,omitempty"` +} + +// NewCreateLogForwardAccepted creates CreateLogForwardAccepted with default headers values +func NewCreateLogForwardAccepted() *CreateLogForwardAccepted { + + return &CreateLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the create log forward accepted response +func (o *CreateLogForwardAccepted) WithReloadID(reloadID string) *CreateLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log forward accepted response +func (o *CreateLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log forward accepted response +func (o *CreateLogForwardAccepted) WithPayload(payload *models.LogForward) *CreateLogForwardAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log forward accepted response +func (o *CreateLogForwardAccepted) SetPayload(payload *models.LogForward) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogForwardBadRequestCode is the HTTP code returned for type CreateLogForwardBadRequest +const CreateLogForwardBadRequestCode int = 400 + +/* +CreateLogForwardBadRequest Bad request + +swagger:response createLogForwardBadRequest +*/ +type CreateLogForwardBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogForwardBadRequest creates CreateLogForwardBadRequest with default headers values +func NewCreateLogForwardBadRequest() *CreateLogForwardBadRequest { + + return &CreateLogForwardBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log forward bad request response +func (o *CreateLogForwardBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogForwardBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log forward bad request response +func (o *CreateLogForwardBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log forward bad request response +func (o *CreateLogForwardBadRequest) WithPayload(payload *models.Error) *CreateLogForwardBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log forward bad request response +func (o *CreateLogForwardBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogForwardBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogForwardConflictCode is the HTTP code returned for type CreateLogForwardConflict +const CreateLogForwardConflictCode int = 409 + +/* +CreateLogForwardConflict The specified resource already exists + +swagger:response createLogForwardConflict +*/ +type CreateLogForwardConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogForwardConflict creates CreateLogForwardConflict with default headers values +func NewCreateLogForwardConflict() *CreateLogForwardConflict { + + return &CreateLogForwardConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log forward conflict response +func (o *CreateLogForwardConflict) WithConfigurationVersion(configurationVersion string) *CreateLogForwardConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log forward conflict response +func (o *CreateLogForwardConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log forward conflict response +func (o *CreateLogForwardConflict) WithPayload(payload *models.Error) *CreateLogForwardConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log forward conflict response +func (o *CreateLogForwardConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogForwardConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogForwardDefault General Error + +swagger:response createLogForwardDefault +*/ +type CreateLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogForwardDefault creates CreateLogForwardDefault with default headers values +func NewCreateLogForwardDefault(code int) *CreateLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log forward default response +func (o *CreateLogForwardDefault) WithStatusCode(code int) *CreateLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log forward default response +func (o *CreateLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log forward default response +func (o *CreateLogForwardDefault) WithConfigurationVersion(configurationVersion string) *CreateLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log forward default response +func (o *CreateLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log forward default response +func (o *CreateLogForwardDefault) WithPayload(payload *models.Error) *CreateLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log forward default response +func (o *CreateLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_forward/create_log_forward_urlbuilder.go b/operations/log_forward/create_log_forward_urlbuilder.go new file mode 100644 index 00000000..203c2836 --- /dev/null +++ b/operations/log_forward/create_log_forward_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateLogForwardURL generates an URL for the create log forward operation +type CreateLogForwardURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogForwardURL) WithBasePath(bp string) *CreateLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_forward/delete_log_forward.go b/operations/log_forward/delete_log_forward.go new file mode 100644 index 00000000..b8fccea8 --- /dev/null +++ b/operations/log_forward/delete_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogForwardHandlerFunc turns a function with the right signature into a delete log forward handler +type DeleteLogForwardHandlerFunc func(DeleteLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogForwardHandlerFunc) Handle(params DeleteLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogForwardHandler interface for that can handle valid delete log forward params +type DeleteLogForwardHandler interface { + Handle(DeleteLogForwardParams, interface{}) middleware.Responder +} + +// NewDeleteLogForward creates a new http.Handler for the delete log forward operation +func NewDeleteLogForward(ctx *middleware.Context, handler DeleteLogForwardHandler) *DeleteLogForward { + return &DeleteLogForward{Context: ctx, Handler: handler} +} + +/* + DeleteLogForward swagger:route DELETE /services/haproxy/configuration/log_forwards/{name} LogForward deleteLogForward + +# Delete a log forward + +Deletes a log forward from the configuration by it's name. +*/ +type DeleteLogForward struct { + Context *middleware.Context + Handler DeleteLogForwardHandler +} + +func (o *DeleteLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_forward/delete_log_forward_parameters.go b/operations/log_forward/delete_log_forward_parameters.go new file mode 100644 index 00000000..7c5229a4 --- /dev/null +++ b/operations/log_forward/delete_log_forward_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogForwardParams creates a new DeleteLogForwardParams object +// with the default values initialized. +func NewDeleteLogForwardParams() DeleteLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogForwardParams contains all the bound params for the delete log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogForward +type DeleteLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Forward name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogForwardParams() beforehand. +func (o *DeleteLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteLogForwardParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_forward/delete_log_forward_responses.go b/operations/log_forward/delete_log_forward_responses.go new file mode 100644 index 00000000..94c5988d --- /dev/null +++ b/operations/log_forward/delete_log_forward_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogForwardAcceptedCode is the HTTP code returned for type DeleteLogForwardAccepted +const DeleteLogForwardAcceptedCode int = 202 + +/* +DeleteLogForwardAccepted Configuration change accepted and reload requested + +swagger:response deleteLogForwardAccepted +*/ +type DeleteLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogForwardAccepted creates DeleteLogForwardAccepted with default headers values +func NewDeleteLogForwardAccepted() *DeleteLogForwardAccepted { + + return &DeleteLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the delete log forward accepted response +func (o *DeleteLogForwardAccepted) WithReloadID(reloadID string) *DeleteLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log forward accepted response +func (o *DeleteLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogForwardNoContentCode is the HTTP code returned for type DeleteLogForwardNoContent +const DeleteLogForwardNoContentCode int = 204 + +/* +DeleteLogForwardNoContent Log Forward deleted + +swagger:response deleteLogForwardNoContent +*/ +type DeleteLogForwardNoContent struct { +} + +// NewDeleteLogForwardNoContent creates DeleteLogForwardNoContent with default headers values +func NewDeleteLogForwardNoContent() *DeleteLogForwardNoContent { + + return &DeleteLogForwardNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogForwardNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogForwardNotFoundCode is the HTTP code returned for type DeleteLogForwardNotFound +const DeleteLogForwardNotFoundCode int = 404 + +/* +DeleteLogForwardNotFound The specified resource was not found + +swagger:response deleteLogForwardNotFound +*/ +type DeleteLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogForwardNotFound creates DeleteLogForwardNotFound with default headers values +func NewDeleteLogForwardNotFound() *DeleteLogForwardNotFound { + + return &DeleteLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log forward not found response +func (o *DeleteLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log forward not found response +func (o *DeleteLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log forward not found response +func (o *DeleteLogForwardNotFound) WithPayload(payload *models.Error) *DeleteLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log forward not found response +func (o *DeleteLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogForwardDefault General Error + +swagger:response deleteLogForwardDefault +*/ +type DeleteLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogForwardDefault creates DeleteLogForwardDefault with default headers values +func NewDeleteLogForwardDefault(code int) *DeleteLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log forward default response +func (o *DeleteLogForwardDefault) WithStatusCode(code int) *DeleteLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log forward default response +func (o *DeleteLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log forward default response +func (o *DeleteLogForwardDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log forward default response +func (o *DeleteLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log forward default response +func (o *DeleteLogForwardDefault) WithPayload(payload *models.Error) *DeleteLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log forward default response +func (o *DeleteLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_forward/delete_log_forward_urlbuilder.go b/operations/log_forward/delete_log_forward_urlbuilder.go new file mode 100644 index 00000000..ff00b076 --- /dev/null +++ b/operations/log_forward/delete_log_forward_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogForwardURL generates an URL for the delete log forward operation +type DeleteLogForwardURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogForwardURL) WithBasePath(bp string) *DeleteLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_forward/get_log_forward.go b/operations/log_forward/get_log_forward.go new file mode 100644 index 00000000..f66b077f --- /dev/null +++ b/operations/log_forward/get_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogForwardHandlerFunc turns a function with the right signature into a get log forward handler +type GetLogForwardHandlerFunc func(GetLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogForwardHandlerFunc) Handle(params GetLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogForwardHandler interface for that can handle valid get log forward params +type GetLogForwardHandler interface { + Handle(GetLogForwardParams, interface{}) middleware.Responder +} + +// NewGetLogForward creates a new http.Handler for the get log forward operation +func NewGetLogForward(ctx *middleware.Context, handler GetLogForwardHandler) *GetLogForward { + return &GetLogForward{Context: ctx, Handler: handler} +} + +/* + GetLogForward swagger:route GET /services/haproxy/configuration/log_forwards/{name} LogForward getLogForward + +# Return a log forward + +Returns one log forward configuration by it's name. +*/ +type GetLogForward struct { + Context *middleware.Context + Handler GetLogForwardHandler +} + +func (o *GetLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_forward/get_log_forward_parameters.go b/operations/log_forward/get_log_forward_parameters.go new file mode 100644 index 00000000..ba466077 --- /dev/null +++ b/operations/log_forward/get_log_forward_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogForwardParams creates a new GetLogForwardParams object +// with the default values initialized. +func NewGetLogForwardParams() GetLogForwardParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetLogForwardParams{ + FullSection: &fullSectionDefault, + } +} + +// GetLogForwardParams contains all the bound params for the get log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogForward +type GetLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Log Forward name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogForwardParams() beforehand. +func (o *GetLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetLogForwardParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetLogForwardParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_forward/get_log_forward_responses.go b/operations/log_forward/get_log_forward_responses.go new file mode 100644 index 00000000..e8d54f3e --- /dev/null +++ b/operations/log_forward/get_log_forward_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogForwardOKCode is the HTTP code returned for type GetLogForwardOK +const GetLogForwardOKCode int = 200 + +/* +GetLogForwardOK Successful operation + +swagger:response getLogForwardOK +*/ +type GetLogForwardOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogForward `json:"body,omitempty"` +} + +// NewGetLogForwardOK creates GetLogForwardOK with default headers values +func NewGetLogForwardOK() *GetLogForwardOK { + + return &GetLogForwardOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log forward o k response +func (o *GetLogForwardOK) WithConfigurationVersion(configurationVersion string) *GetLogForwardOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log forward o k response +func (o *GetLogForwardOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log forward o k response +func (o *GetLogForwardOK) WithPayload(payload *models.LogForward) *GetLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log forward o k response +func (o *GetLogForwardOK) SetPayload(payload *models.LogForward) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogForwardNotFoundCode is the HTTP code returned for type GetLogForwardNotFound +const GetLogForwardNotFoundCode int = 404 + +/* +GetLogForwardNotFound The specified resource was not found + +swagger:response getLogForwardNotFound +*/ +type GetLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogForwardNotFound creates GetLogForwardNotFound with default headers values +func NewGetLogForwardNotFound() *GetLogForwardNotFound { + + return &GetLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log forward not found response +func (o *GetLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *GetLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log forward not found response +func (o *GetLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log forward not found response +func (o *GetLogForwardNotFound) WithPayload(payload *models.Error) *GetLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log forward not found response +func (o *GetLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogForwardDefault General Error + +swagger:response getLogForwardDefault +*/ +type GetLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogForwardDefault creates GetLogForwardDefault with default headers values +func NewGetLogForwardDefault(code int) *GetLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &GetLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log forward default response +func (o *GetLogForwardDefault) WithStatusCode(code int) *GetLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log forward default response +func (o *GetLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log forward default response +func (o *GetLogForwardDefault) WithConfigurationVersion(configurationVersion string) *GetLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log forward default response +func (o *GetLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log forward default response +func (o *GetLogForwardDefault) WithPayload(payload *models.Error) *GetLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log forward default response +func (o *GetLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_forward/get_log_forward_urlbuilder.go b/operations/log_forward/get_log_forward_urlbuilder.go new file mode 100644 index 00000000..6802d930 --- /dev/null +++ b/operations/log_forward/get_log_forward_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogForwardURL generates an URL for the get log forward operation +type GetLogForwardURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogForwardURL) WithBasePath(bp string) *GetLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_forward/get_log_forwards.go b/operations/log_forward/get_log_forwards.go new file mode 100644 index 00000000..8e62bfcd --- /dev/null +++ b/operations/log_forward/get_log_forwards.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogForwardsHandlerFunc turns a function with the right signature into a get log forwards handler +type GetLogForwardsHandlerFunc func(GetLogForwardsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogForwardsHandlerFunc) Handle(params GetLogForwardsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogForwardsHandler interface for that can handle valid get log forwards params +type GetLogForwardsHandler interface { + Handle(GetLogForwardsParams, interface{}) middleware.Responder +} + +// NewGetLogForwards creates a new http.Handler for the get log forwards operation +func NewGetLogForwards(ctx *middleware.Context, handler GetLogForwardsHandler) *GetLogForwards { + return &GetLogForwards{Context: ctx, Handler: handler} +} + +/* + GetLogForwards swagger:route GET /services/haproxy/configuration/log_forwards LogForward getLogForwards + +# Return an array of log forwards + +Returns an array of all configured log forwards. +*/ +type GetLogForwards struct { + Context *middleware.Context + Handler GetLogForwardsHandler +} + +func (o *GetLogForwards) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogForwardsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_forward/get_log_forwards_parameters.go b/operations/log_forward/get_log_forwards_parameters.go new file mode 100644 index 00000000..a74542df --- /dev/null +++ b/operations/log_forward/get_log_forwards_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogForwardsParams creates a new GetLogForwardsParams object +// with the default values initialized. +func NewGetLogForwardsParams() GetLogForwardsParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetLogForwardsParams{ + FullSection: &fullSectionDefault, + } +} + +// GetLogForwardsParams contains all the bound params for the get log forwards operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogForwards +type GetLogForwardsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogForwardsParams() beforehand. +func (o *GetLogForwardsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetLogForwardsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetLogForwardsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogForwardsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_forward/get_log_forwards_responses.go b/operations/log_forward/get_log_forwards_responses.go new file mode 100644 index 00000000..cf69f31f --- /dev/null +++ b/operations/log_forward/get_log_forwards_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogForwardsOKCode is the HTTP code returned for type GetLogForwardsOK +const GetLogForwardsOKCode int = 200 + +/* +GetLogForwardsOK Successful operation + +swagger:response getLogForwardsOK +*/ +type GetLogForwardsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogForwards `json:"body,omitempty"` +} + +// NewGetLogForwardsOK creates GetLogForwardsOK with default headers values +func NewGetLogForwardsOK() *GetLogForwardsOK { + + return &GetLogForwardsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log forwards o k response +func (o *GetLogForwardsOK) WithConfigurationVersion(configurationVersion string) *GetLogForwardsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log forwards o k response +func (o *GetLogForwardsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log forwards o k response +func (o *GetLogForwardsOK) WithPayload(payload models.LogForwards) *GetLogForwardsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log forwards o k response +func (o *GetLogForwardsOK) SetPayload(payload models.LogForwards) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogForwardsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogForwards{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetLogForwardsDefault General Error + +swagger:response getLogForwardsDefault +*/ +type GetLogForwardsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogForwardsDefault creates GetLogForwardsDefault with default headers values +func NewGetLogForwardsDefault(code int) *GetLogForwardsDefault { + if code <= 0 { + code = 500 + } + + return &GetLogForwardsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log forwards default response +func (o *GetLogForwardsDefault) WithStatusCode(code int) *GetLogForwardsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log forwards default response +func (o *GetLogForwardsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log forwards default response +func (o *GetLogForwardsDefault) WithConfigurationVersion(configurationVersion string) *GetLogForwardsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log forwards default response +func (o *GetLogForwardsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log forwards default response +func (o *GetLogForwardsDefault) WithPayload(payload *models.Error) *GetLogForwardsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log forwards default response +func (o *GetLogForwardsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogForwardsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_forward/get_log_forwards_urlbuilder.go b/operations/log_forward/get_log_forwards_urlbuilder.go new file mode 100644 index 00000000..0bd00ddc --- /dev/null +++ b/operations/log_forward/get_log_forwards_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetLogForwardsURL generates an URL for the get log forwards operation +type GetLogForwardsURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogForwardsURL) WithBasePath(bp string) *GetLogForwardsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogForwardsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogForwardsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogForwardsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogForwardsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogForwardsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogForwardsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogForwardsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogForwardsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_forward/replace_log_forward.go b/operations/log_forward/replace_log_forward.go new file mode 100644 index 00000000..1dced43d --- /dev/null +++ b/operations/log_forward/replace_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceLogForwardHandlerFunc turns a function with the right signature into a replace log forward handler +type ReplaceLogForwardHandlerFunc func(ReplaceLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceLogForwardHandlerFunc) Handle(params ReplaceLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceLogForwardHandler interface for that can handle valid replace log forward params +type ReplaceLogForwardHandler interface { + Handle(ReplaceLogForwardParams, interface{}) middleware.Responder +} + +// NewReplaceLogForward creates a new http.Handler for the replace log forward operation +func NewReplaceLogForward(ctx *middleware.Context, handler ReplaceLogForwardHandler) *ReplaceLogForward { + return &ReplaceLogForward{Context: ctx, Handler: handler} +} + +/* + ReplaceLogForward swagger:route PUT /services/haproxy/configuration/log_forwards/{name} LogForward replaceLogForward + +# Replace a log forward + +Replaces a log forward configuration by it's name. +*/ +type ReplaceLogForward struct { + Context *middleware.Context + Handler ReplaceLogForwardHandler +} + +func (o *ReplaceLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_forward/replace_log_forward_parameters.go b/operations/log_forward/replace_log_forward_parameters.go new file mode 100644 index 00000000..b9d4cdcc --- /dev/null +++ b/operations/log_forward/replace_log_forward_parameters.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceLogForwardParams creates a new ReplaceLogForwardParams object +// with the default values initialized. +func NewReplaceLogForwardParams() ReplaceLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return ReplaceLogForwardParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// ReplaceLogForwardParams contains all the bound params for the replace log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceLogForward +type ReplaceLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogForward + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Log Forward name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceLogForwardParams() beforehand. +func (o *ReplaceLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogForward + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceLogForwardParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceLogForwardParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_forward/replace_log_forward_responses.go b/operations/log_forward/replace_log_forward_responses.go new file mode 100644 index 00000000..e80f0150 --- /dev/null +++ b/operations/log_forward/replace_log_forward_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceLogForwardOKCode is the HTTP code returned for type ReplaceLogForwardOK +const ReplaceLogForwardOKCode int = 200 + +/* +ReplaceLogForwardOK Log Forward replaced + +swagger:response replaceLogForwardOK +*/ +type ReplaceLogForwardOK struct { + + /* + In: Body + */ + Payload *models.LogForward `json:"body,omitempty"` +} + +// NewReplaceLogForwardOK creates ReplaceLogForwardOK with default headers values +func NewReplaceLogForwardOK() *ReplaceLogForwardOK { + + return &ReplaceLogForwardOK{} +} + +// WithPayload adds the payload to the replace log forward o k response +func (o *ReplaceLogForwardOK) WithPayload(payload *models.LogForward) *ReplaceLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log forward o k response +func (o *ReplaceLogForwardOK) SetPayload(payload *models.LogForward) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogForwardAcceptedCode is the HTTP code returned for type ReplaceLogForwardAccepted +const ReplaceLogForwardAcceptedCode int = 202 + +/* +ReplaceLogForwardAccepted Configuration change accepted and reload requested + +swagger:response replaceLogForwardAccepted +*/ +type ReplaceLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogForward `json:"body,omitempty"` +} + +// NewReplaceLogForwardAccepted creates ReplaceLogForwardAccepted with default headers values +func NewReplaceLogForwardAccepted() *ReplaceLogForwardAccepted { + + return &ReplaceLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the replace log forward accepted response +func (o *ReplaceLogForwardAccepted) WithReloadID(reloadID string) *ReplaceLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace log forward accepted response +func (o *ReplaceLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace log forward accepted response +func (o *ReplaceLogForwardAccepted) WithPayload(payload *models.LogForward) *ReplaceLogForwardAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log forward accepted response +func (o *ReplaceLogForwardAccepted) SetPayload(payload *models.LogForward) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogForwardBadRequestCode is the HTTP code returned for type ReplaceLogForwardBadRequest +const ReplaceLogForwardBadRequestCode int = 400 + +/* +ReplaceLogForwardBadRequest Bad request + +swagger:response replaceLogForwardBadRequest +*/ +type ReplaceLogForwardBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogForwardBadRequest creates ReplaceLogForwardBadRequest with default headers values +func NewReplaceLogForwardBadRequest() *ReplaceLogForwardBadRequest { + + return &ReplaceLogForwardBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log forward bad request response +func (o *ReplaceLogForwardBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceLogForwardBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log forward bad request response +func (o *ReplaceLogForwardBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log forward bad request response +func (o *ReplaceLogForwardBadRequest) WithPayload(payload *models.Error) *ReplaceLogForwardBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log forward bad request response +func (o *ReplaceLogForwardBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogForwardBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogForwardNotFoundCode is the HTTP code returned for type ReplaceLogForwardNotFound +const ReplaceLogForwardNotFoundCode int = 404 + +/* +ReplaceLogForwardNotFound The specified resource was not found + +swagger:response replaceLogForwardNotFound +*/ +type ReplaceLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogForwardNotFound creates ReplaceLogForwardNotFound with default headers values +func NewReplaceLogForwardNotFound() *ReplaceLogForwardNotFound { + + return &ReplaceLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log forward not found response +func (o *ReplaceLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log forward not found response +func (o *ReplaceLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log forward not found response +func (o *ReplaceLogForwardNotFound) WithPayload(payload *models.Error) *ReplaceLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log forward not found response +func (o *ReplaceLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceLogForwardDefault General Error + +swagger:response replaceLogForwardDefault +*/ +type ReplaceLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogForwardDefault creates ReplaceLogForwardDefault with default headers values +func NewReplaceLogForwardDefault(code int) *ReplaceLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace log forward default response +func (o *ReplaceLogForwardDefault) WithStatusCode(code int) *ReplaceLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace log forward default response +func (o *ReplaceLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace log forward default response +func (o *ReplaceLogForwardDefault) WithConfigurationVersion(configurationVersion string) *ReplaceLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log forward default response +func (o *ReplaceLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log forward default response +func (o *ReplaceLogForwardDefault) WithPayload(payload *models.Error) *ReplaceLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log forward default response +func (o *ReplaceLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_forward/replace_log_forward_urlbuilder.go b/operations/log_forward/replace_log_forward_urlbuilder.go new file mode 100644 index 00000000..d5a61125 --- /dev/null +++ b/operations/log_forward/replace_log_forward_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_forward + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceLogForwardURL generates an URL for the replace log forward operation +type ReplaceLogForwardURL struct { + Name string + + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogForwardURL) WithBasePath(bp string) *ReplaceLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_profile/create_log_profile.go b/operations/log_profile/create_log_profile.go new file mode 100644 index 00000000..9aee48e4 --- /dev/null +++ b/operations/log_profile/create_log_profile.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogProfileHandlerFunc turns a function with the right signature into a create log profile handler +type CreateLogProfileHandlerFunc func(CreateLogProfileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogProfileHandlerFunc) Handle(params CreateLogProfileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogProfileHandler interface for that can handle valid create log profile params +type CreateLogProfileHandler interface { + Handle(CreateLogProfileParams, interface{}) middleware.Responder +} + +// NewCreateLogProfile creates a new http.Handler for the create log profile operation +func NewCreateLogProfile(ctx *middleware.Context, handler CreateLogProfileHandler) *CreateLogProfile { + return &CreateLogProfile{Context: ctx, Handler: handler} +} + +/* + CreateLogProfile swagger:route POST /services/haproxy/configuration/log_profiles LogProfile createLogProfile + +# Add a new Log Profile + +Creates a new log_profile section +*/ +type CreateLogProfile struct { + Context *middleware.Context + Handler CreateLogProfileHandler +} + +func (o *CreateLogProfile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogProfileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_profile/create_log_profile_parameters.go b/operations/log_profile/create_log_profile_parameters.go new file mode 100644 index 00000000..9f0b4941 --- /dev/null +++ b/operations/log_profile/create_log_profile_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogProfileParams creates a new CreateLogProfileParams object +// with the default values initialized. +func NewCreateLogProfileParams() CreateLogProfileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateLogProfileParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateLogProfileParams contains all the bound params for the create log profile operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogProfile +type CreateLogProfileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogProfile + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogProfileParams() beforehand. +func (o *CreateLogProfileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogProfile + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogProfileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogProfileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogProfileParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogProfileParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_profile/create_log_profile_responses.go b/operations/log_profile/create_log_profile_responses.go new file mode 100644 index 00000000..acf83f5a --- /dev/null +++ b/operations/log_profile/create_log_profile_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogProfileCreatedCode is the HTTP code returned for type CreateLogProfileCreated +const CreateLogProfileCreatedCode int = 201 + +/* +CreateLogProfileCreated Log Profile created + +swagger:response createLogProfileCreated +*/ +type CreateLogProfileCreated struct { + + /* + In: Body + */ + Payload *models.LogProfile `json:"body,omitempty"` +} + +// NewCreateLogProfileCreated creates CreateLogProfileCreated with default headers values +func NewCreateLogProfileCreated() *CreateLogProfileCreated { + + return &CreateLogProfileCreated{} +} + +// WithPayload adds the payload to the create log profile created response +func (o *CreateLogProfileCreated) WithPayload(payload *models.LogProfile) *CreateLogProfileCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log profile created response +func (o *CreateLogProfileCreated) SetPayload(payload *models.LogProfile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogProfileCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogProfileAcceptedCode is the HTTP code returned for type CreateLogProfileAccepted +const CreateLogProfileAcceptedCode int = 202 + +/* +CreateLogProfileAccepted Configuration change accepted and reload requested + +swagger:response createLogProfileAccepted +*/ +type CreateLogProfileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogProfile `json:"body,omitempty"` +} + +// NewCreateLogProfileAccepted creates CreateLogProfileAccepted with default headers values +func NewCreateLogProfileAccepted() *CreateLogProfileAccepted { + + return &CreateLogProfileAccepted{} +} + +// WithReloadID adds the reloadId to the create log profile accepted response +func (o *CreateLogProfileAccepted) WithReloadID(reloadID string) *CreateLogProfileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log profile accepted response +func (o *CreateLogProfileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log profile accepted response +func (o *CreateLogProfileAccepted) WithPayload(payload *models.LogProfile) *CreateLogProfileAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log profile accepted response +func (o *CreateLogProfileAccepted) SetPayload(payload *models.LogProfile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogProfileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogProfileBadRequestCode is the HTTP code returned for type CreateLogProfileBadRequest +const CreateLogProfileBadRequestCode int = 400 + +/* +CreateLogProfileBadRequest Bad request + +swagger:response createLogProfileBadRequest +*/ +type CreateLogProfileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogProfileBadRequest creates CreateLogProfileBadRequest with default headers values +func NewCreateLogProfileBadRequest() *CreateLogProfileBadRequest { + + return &CreateLogProfileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log profile bad request response +func (o *CreateLogProfileBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogProfileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log profile bad request response +func (o *CreateLogProfileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log profile bad request response +func (o *CreateLogProfileBadRequest) WithPayload(payload *models.Error) *CreateLogProfileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log profile bad request response +func (o *CreateLogProfileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogProfileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogProfileConflictCode is the HTTP code returned for type CreateLogProfileConflict +const CreateLogProfileConflictCode int = 409 + +/* +CreateLogProfileConflict The specified resource already exists + +swagger:response createLogProfileConflict +*/ +type CreateLogProfileConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogProfileConflict creates CreateLogProfileConflict with default headers values +func NewCreateLogProfileConflict() *CreateLogProfileConflict { + + return &CreateLogProfileConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log profile conflict response +func (o *CreateLogProfileConflict) WithConfigurationVersion(configurationVersion string) *CreateLogProfileConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log profile conflict response +func (o *CreateLogProfileConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log profile conflict response +func (o *CreateLogProfileConflict) WithPayload(payload *models.Error) *CreateLogProfileConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log profile conflict response +func (o *CreateLogProfileConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogProfileConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogProfileDefault General Error + +swagger:response createLogProfileDefault +*/ +type CreateLogProfileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogProfileDefault creates CreateLogProfileDefault with default headers values +func NewCreateLogProfileDefault(code int) *CreateLogProfileDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogProfileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log profile default response +func (o *CreateLogProfileDefault) WithStatusCode(code int) *CreateLogProfileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log profile default response +func (o *CreateLogProfileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log profile default response +func (o *CreateLogProfileDefault) WithConfigurationVersion(configurationVersion string) *CreateLogProfileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log profile default response +func (o *CreateLogProfileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log profile default response +func (o *CreateLogProfileDefault) WithPayload(payload *models.Error) *CreateLogProfileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log profile default response +func (o *CreateLogProfileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogProfileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_profile/create_log_profile_urlbuilder.go b/operations/log_profile/create_log_profile_urlbuilder.go new file mode 100644 index 00000000..8098f2fe --- /dev/null +++ b/operations/log_profile/create_log_profile_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateLogProfileURL generates an URL for the create log profile operation +type CreateLogProfileURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogProfileURL) WithBasePath(bp string) *CreateLogProfileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogProfileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogProfileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_profiles" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogProfileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogProfileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogProfileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogProfileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogProfileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogProfileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_profile/delete_log_profile.go b/operations/log_profile/delete_log_profile.go new file mode 100644 index 00000000..11c78fc7 --- /dev/null +++ b/operations/log_profile/delete_log_profile.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogProfileHandlerFunc turns a function with the right signature into a delete log profile handler +type DeleteLogProfileHandlerFunc func(DeleteLogProfileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogProfileHandlerFunc) Handle(params DeleteLogProfileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogProfileHandler interface for that can handle valid delete log profile params +type DeleteLogProfileHandler interface { + Handle(DeleteLogProfileParams, interface{}) middleware.Responder +} + +// NewDeleteLogProfile creates a new http.Handler for the delete log profile operation +func NewDeleteLogProfile(ctx *middleware.Context, handler DeleteLogProfileHandler) *DeleteLogProfile { + return &DeleteLogProfile{Context: ctx, Handler: handler} +} + +/* + DeleteLogProfile swagger:route DELETE /services/haproxy/configuration/log_profiles/{name} LogProfile deleteLogProfile + +# Delete a Log Profile + +Deletes a log_profile section from the configuration +*/ +type DeleteLogProfile struct { + Context *middleware.Context + Handler DeleteLogProfileHandler +} + +func (o *DeleteLogProfile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogProfileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_profile/delete_log_profile_parameters.go b/operations/log_profile/delete_log_profile_parameters.go new file mode 100644 index 00000000..8142fb18 --- /dev/null +++ b/operations/log_profile/delete_log_profile_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogProfileParams creates a new DeleteLogProfileParams object +// with the default values initialized. +func NewDeleteLogProfileParams() DeleteLogProfileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogProfileParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogProfileParams contains all the bound params for the delete log profile operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogProfile +type DeleteLogProfileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*log_profile name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogProfileParams() beforehand. +func (o *DeleteLogProfileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogProfileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogProfileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteLogProfileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogProfileParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogProfileParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_profile/delete_log_profile_responses.go b/operations/log_profile/delete_log_profile_responses.go new file mode 100644 index 00000000..c91458f1 --- /dev/null +++ b/operations/log_profile/delete_log_profile_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogProfileAcceptedCode is the HTTP code returned for type DeleteLogProfileAccepted +const DeleteLogProfileAcceptedCode int = 202 + +/* +DeleteLogProfileAccepted Configuration change accepted and reload requested + +swagger:response deleteLogProfileAccepted +*/ +type DeleteLogProfileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogProfileAccepted creates DeleteLogProfileAccepted with default headers values +func NewDeleteLogProfileAccepted() *DeleteLogProfileAccepted { + + return &DeleteLogProfileAccepted{} +} + +// WithReloadID adds the reloadId to the delete log profile accepted response +func (o *DeleteLogProfileAccepted) WithReloadID(reloadID string) *DeleteLogProfileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log profile accepted response +func (o *DeleteLogProfileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogProfileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogProfileNoContentCode is the HTTP code returned for type DeleteLogProfileNoContent +const DeleteLogProfileNoContentCode int = 204 + +/* +DeleteLogProfileNoContent log_profile deleted + +swagger:response deleteLogProfileNoContent +*/ +type DeleteLogProfileNoContent struct { +} + +// NewDeleteLogProfileNoContent creates DeleteLogProfileNoContent with default headers values +func NewDeleteLogProfileNoContent() *DeleteLogProfileNoContent { + + return &DeleteLogProfileNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogProfileNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogProfileNotFoundCode is the HTTP code returned for type DeleteLogProfileNotFound +const DeleteLogProfileNotFoundCode int = 404 + +/* +DeleteLogProfileNotFound The specified resource was not found + +swagger:response deleteLogProfileNotFound +*/ +type DeleteLogProfileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogProfileNotFound creates DeleteLogProfileNotFound with default headers values +func NewDeleteLogProfileNotFound() *DeleteLogProfileNotFound { + + return &DeleteLogProfileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log profile not found response +func (o *DeleteLogProfileNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogProfileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log profile not found response +func (o *DeleteLogProfileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log profile not found response +func (o *DeleteLogProfileNotFound) WithPayload(payload *models.Error) *DeleteLogProfileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log profile not found response +func (o *DeleteLogProfileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogProfileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogProfileDefault General Error + +swagger:response deleteLogProfileDefault +*/ +type DeleteLogProfileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogProfileDefault creates DeleteLogProfileDefault with default headers values +func NewDeleteLogProfileDefault(code int) *DeleteLogProfileDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogProfileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log profile default response +func (o *DeleteLogProfileDefault) WithStatusCode(code int) *DeleteLogProfileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log profile default response +func (o *DeleteLogProfileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log profile default response +func (o *DeleteLogProfileDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogProfileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log profile default response +func (o *DeleteLogProfileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log profile default response +func (o *DeleteLogProfileDefault) WithPayload(payload *models.Error) *DeleteLogProfileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log profile default response +func (o *DeleteLogProfileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogProfileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_profile/delete_log_profile_urlbuilder.go b/operations/log_profile/delete_log_profile_urlbuilder.go new file mode 100644 index 00000000..c052d423 --- /dev/null +++ b/operations/log_profile/delete_log_profile_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogProfileURL generates an URL for the delete log profile operation +type DeleteLogProfileURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogProfileURL) WithBasePath(bp string) *DeleteLogProfileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogProfileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogProfileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_profiles/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteLogProfileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogProfileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogProfileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogProfileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogProfileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogProfileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogProfileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_profile/edit_log_profile.go b/operations/log_profile/edit_log_profile.go new file mode 100644 index 00000000..6c4632a0 --- /dev/null +++ b/operations/log_profile/edit_log_profile.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// EditLogProfileHandlerFunc turns a function with the right signature into a edit log profile handler +type EditLogProfileHandlerFunc func(EditLogProfileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn EditLogProfileHandlerFunc) Handle(params EditLogProfileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// EditLogProfileHandler interface for that can handle valid edit log profile params +type EditLogProfileHandler interface { + Handle(EditLogProfileParams, interface{}) middleware.Responder +} + +// NewEditLogProfile creates a new http.Handler for the edit log profile operation +func NewEditLogProfile(ctx *middleware.Context, handler EditLogProfileHandler) *EditLogProfile { + return &EditLogProfile{Context: ctx, Handler: handler} +} + +/* + EditLogProfile swagger:route PUT /services/haproxy/configuration/log_profiles/{name} LogProfile editLogProfile + +# Modify a Log Profile + +Modifies a log_profile's configuration by its name +*/ +type EditLogProfile struct { + Context *middleware.Context + Handler EditLogProfileHandler +} + +func (o *EditLogProfile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewEditLogProfileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_profile/edit_log_profile_parameters.go b/operations/log_profile/edit_log_profile_parameters.go new file mode 100644 index 00000000..e10fb414 --- /dev/null +++ b/operations/log_profile/edit_log_profile_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewEditLogProfileParams creates a new EditLogProfileParams object +// with the default values initialized. +func NewEditLogProfileParams() EditLogProfileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return EditLogProfileParams{ + ForceReload: &forceReloadDefault, + } +} + +// EditLogProfileParams contains all the bound params for the edit log profile operation +// typically these are obtained from a http.Request +// +// swagger:parameters editLogProfile +type EditLogProfileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogProfile + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*log_profile name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewEditLogProfileParams() beforehand. +func (o *EditLogProfileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogProfile + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *EditLogProfileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewEditLogProfileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *EditLogProfileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *EditLogProfileParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *EditLogProfileParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_profile/edit_log_profile_responses.go b/operations/log_profile/edit_log_profile_responses.go new file mode 100644 index 00000000..59b9a4ef --- /dev/null +++ b/operations/log_profile/edit_log_profile_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// EditLogProfileOKCode is the HTTP code returned for type EditLogProfileOK +const EditLogProfileOKCode int = 200 + +/* +EditLogProfileOK log_profile configuration updated + +swagger:response editLogProfileOK +*/ +type EditLogProfileOK struct { + + /* + In: Body + */ + Payload *models.LogProfile `json:"body,omitempty"` +} + +// NewEditLogProfileOK creates EditLogProfileOK with default headers values +func NewEditLogProfileOK() *EditLogProfileOK { + + return &EditLogProfileOK{} +} + +// WithPayload adds the payload to the edit log profile o k response +func (o *EditLogProfileOK) WithPayload(payload *models.LogProfile) *EditLogProfileOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit log profile o k response +func (o *EditLogProfileOK) SetPayload(payload *models.LogProfile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditLogProfileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditLogProfileAcceptedCode is the HTTP code returned for type EditLogProfileAccepted +const EditLogProfileAcceptedCode int = 202 + +/* +EditLogProfileAccepted Configuration change accepted and reload requested + +swagger:response editLogProfileAccepted +*/ +type EditLogProfileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogProfile `json:"body,omitempty"` +} + +// NewEditLogProfileAccepted creates EditLogProfileAccepted with default headers values +func NewEditLogProfileAccepted() *EditLogProfileAccepted { + + return &EditLogProfileAccepted{} +} + +// WithReloadID adds the reloadId to the edit log profile accepted response +func (o *EditLogProfileAccepted) WithReloadID(reloadID string) *EditLogProfileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the edit log profile accepted response +func (o *EditLogProfileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the edit log profile accepted response +func (o *EditLogProfileAccepted) WithPayload(payload *models.LogProfile) *EditLogProfileAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit log profile accepted response +func (o *EditLogProfileAccepted) SetPayload(payload *models.LogProfile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditLogProfileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditLogProfileBadRequestCode is the HTTP code returned for type EditLogProfileBadRequest +const EditLogProfileBadRequestCode int = 400 + +/* +EditLogProfileBadRequest Bad request + +swagger:response editLogProfileBadRequest +*/ +type EditLogProfileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditLogProfileBadRequest creates EditLogProfileBadRequest with default headers values +func NewEditLogProfileBadRequest() *EditLogProfileBadRequest { + + return &EditLogProfileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit log profile bad request response +func (o *EditLogProfileBadRequest) WithConfigurationVersion(configurationVersion string) *EditLogProfileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit log profile bad request response +func (o *EditLogProfileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit log profile bad request response +func (o *EditLogProfileBadRequest) WithPayload(payload *models.Error) *EditLogProfileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit log profile bad request response +func (o *EditLogProfileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditLogProfileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditLogProfileNotFoundCode is the HTTP code returned for type EditLogProfileNotFound +const EditLogProfileNotFoundCode int = 404 + +/* +EditLogProfileNotFound The specified resource was not found + +swagger:response editLogProfileNotFound +*/ +type EditLogProfileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditLogProfileNotFound creates EditLogProfileNotFound with default headers values +func NewEditLogProfileNotFound() *EditLogProfileNotFound { + + return &EditLogProfileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit log profile not found response +func (o *EditLogProfileNotFound) WithConfigurationVersion(configurationVersion string) *EditLogProfileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit log profile not found response +func (o *EditLogProfileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit log profile not found response +func (o *EditLogProfileNotFound) WithPayload(payload *models.Error) *EditLogProfileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit log profile not found response +func (o *EditLogProfileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditLogProfileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +EditLogProfileDefault General Error + +swagger:response editLogProfileDefault +*/ +type EditLogProfileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditLogProfileDefault creates EditLogProfileDefault with default headers values +func NewEditLogProfileDefault(code int) *EditLogProfileDefault { + if code <= 0 { + code = 500 + } + + return &EditLogProfileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the edit log profile default response +func (o *EditLogProfileDefault) WithStatusCode(code int) *EditLogProfileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the edit log profile default response +func (o *EditLogProfileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the edit log profile default response +func (o *EditLogProfileDefault) WithConfigurationVersion(configurationVersion string) *EditLogProfileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit log profile default response +func (o *EditLogProfileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit log profile default response +func (o *EditLogProfileDefault) WithPayload(payload *models.Error) *EditLogProfileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit log profile default response +func (o *EditLogProfileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditLogProfileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_profile/edit_log_profile_urlbuilder.go b/operations/log_profile/edit_log_profile_urlbuilder.go new file mode 100644 index 00000000..c9e9a19c --- /dev/null +++ b/operations/log_profile/edit_log_profile_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// EditLogProfileURL generates an URL for the edit log profile operation +type EditLogProfileURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditLogProfileURL) WithBasePath(bp string) *EditLogProfileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditLogProfileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *EditLogProfileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_profiles/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on EditLogProfileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *EditLogProfileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *EditLogProfileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *EditLogProfileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on EditLogProfileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on EditLogProfileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *EditLogProfileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_profile/get_log_profile.go b/operations/log_profile/get_log_profile.go new file mode 100644 index 00000000..9810df02 --- /dev/null +++ b/operations/log_profile/get_log_profile.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogProfileHandlerFunc turns a function with the right signature into a get log profile handler +type GetLogProfileHandlerFunc func(GetLogProfileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogProfileHandlerFunc) Handle(params GetLogProfileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogProfileHandler interface for that can handle valid get log profile params +type GetLogProfileHandler interface { + Handle(GetLogProfileParams, interface{}) middleware.Responder +} + +// NewGetLogProfile creates a new http.Handler for the get log profile operation +func NewGetLogProfile(ctx *middleware.Context, handler GetLogProfileHandler) *GetLogProfile { + return &GetLogProfile{Context: ctx, Handler: handler} +} + +/* + GetLogProfile swagger:route GET /services/haproxy/configuration/log_profiles/{name} LogProfile getLogProfile + +# Return a Log Profile + +Find a log_profile section by its name +*/ +type GetLogProfile struct { + Context *middleware.Context + Handler GetLogProfileHandler +} + +func (o *GetLogProfile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogProfileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_profile/get_log_profile_parameters.go b/operations/log_profile/get_log_profile_parameters.go new file mode 100644 index 00000000..265fe4d4 --- /dev/null +++ b/operations/log_profile/get_log_profile_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetLogProfileParams creates a new GetLogProfileParams object +// +// There are no default values defined in the spec. +func NewGetLogProfileParams() GetLogProfileParams { + + return GetLogProfileParams{} +} + +// GetLogProfileParams contains all the bound params for the get log profile operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogProfile +type GetLogProfileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*log_profile name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogProfileParams() beforehand. +func (o *GetLogProfileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetLogProfileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogProfileParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_profile/get_log_profile_responses.go b/operations/log_profile/get_log_profile_responses.go new file mode 100644 index 00000000..3debfef4 --- /dev/null +++ b/operations/log_profile/get_log_profile_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogProfileOKCode is the HTTP code returned for type GetLogProfileOK +const GetLogProfileOKCode int = 200 + +/* +GetLogProfileOK Successful operation + +swagger:response getLogProfileOK +*/ +type GetLogProfileOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogProfile `json:"body,omitempty"` +} + +// NewGetLogProfileOK creates GetLogProfileOK with default headers values +func NewGetLogProfileOK() *GetLogProfileOK { + + return &GetLogProfileOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log profile o k response +func (o *GetLogProfileOK) WithConfigurationVersion(configurationVersion string) *GetLogProfileOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log profile o k response +func (o *GetLogProfileOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log profile o k response +func (o *GetLogProfileOK) WithPayload(payload *models.LogProfile) *GetLogProfileOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log profile o k response +func (o *GetLogProfileOK) SetPayload(payload *models.LogProfile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogProfileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogProfileNotFoundCode is the HTTP code returned for type GetLogProfileNotFound +const GetLogProfileNotFoundCode int = 404 + +/* +GetLogProfileNotFound The specified resource was not found + +swagger:response getLogProfileNotFound +*/ +type GetLogProfileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogProfileNotFound creates GetLogProfileNotFound with default headers values +func NewGetLogProfileNotFound() *GetLogProfileNotFound { + + return &GetLogProfileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log profile not found response +func (o *GetLogProfileNotFound) WithConfigurationVersion(configurationVersion string) *GetLogProfileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log profile not found response +func (o *GetLogProfileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log profile not found response +func (o *GetLogProfileNotFound) WithPayload(payload *models.Error) *GetLogProfileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log profile not found response +func (o *GetLogProfileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogProfileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogProfileDefault General Error + +swagger:response getLogProfileDefault +*/ +type GetLogProfileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogProfileDefault creates GetLogProfileDefault with default headers values +func NewGetLogProfileDefault(code int) *GetLogProfileDefault { + if code <= 0 { + code = 500 + } + + return &GetLogProfileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log profile default response +func (o *GetLogProfileDefault) WithStatusCode(code int) *GetLogProfileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log profile default response +func (o *GetLogProfileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log profile default response +func (o *GetLogProfileDefault) WithConfigurationVersion(configurationVersion string) *GetLogProfileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log profile default response +func (o *GetLogProfileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log profile default response +func (o *GetLogProfileDefault) WithPayload(payload *models.Error) *GetLogProfileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log profile default response +func (o *GetLogProfileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogProfileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_profile/get_log_profile_urlbuilder.go b/operations/log_profile/get_log_profile_urlbuilder.go new file mode 100644 index 00000000..b2acbeaf --- /dev/null +++ b/operations/log_profile/get_log_profile_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetLogProfileURL generates an URL for the get log profile operation +type GetLogProfileURL struct { + Name string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogProfileURL) WithBasePath(bp string) *GetLogProfileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogProfileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogProfileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_profiles/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetLogProfileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogProfileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogProfileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogProfileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogProfileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogProfileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogProfileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_profile/get_log_profiles.go b/operations/log_profile/get_log_profiles.go new file mode 100644 index 00000000..63f1086c --- /dev/null +++ b/operations/log_profile/get_log_profiles.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogProfilesHandlerFunc turns a function with the right signature into a get log profiles handler +type GetLogProfilesHandlerFunc func(GetLogProfilesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogProfilesHandlerFunc) Handle(params GetLogProfilesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogProfilesHandler interface for that can handle valid get log profiles params +type GetLogProfilesHandler interface { + Handle(GetLogProfilesParams, interface{}) middleware.Responder +} + +// NewGetLogProfiles creates a new http.Handler for the get log profiles operation +func NewGetLogProfiles(ctx *middleware.Context, handler GetLogProfilesHandler) *GetLogProfiles { + return &GetLogProfiles{Context: ctx, Handler: handler} +} + +/* + GetLogProfiles swagger:route GET /services/haproxy/configuration/log_profiles LogProfile getLogProfiles + +# Return all the Log Profiles + +Returns an array of all the configured log_profile sections in HAProxy +*/ +type GetLogProfiles struct { + Context *middleware.Context + Handler GetLogProfilesHandler +} + +func (o *GetLogProfiles) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogProfilesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_profile/get_log_profiles_parameters.go b/operations/log_profile/get_log_profiles_parameters.go new file mode 100644 index 00000000..df943ec4 --- /dev/null +++ b/operations/log_profile/get_log_profiles_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetLogProfilesParams creates a new GetLogProfilesParams object +// +// There are no default values defined in the spec. +func NewGetLogProfilesParams() GetLogProfilesParams { + + return GetLogProfilesParams{} +} + +// GetLogProfilesParams contains all the bound params for the get log profiles operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogProfiles +type GetLogProfilesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogProfilesParams() beforehand. +func (o *GetLogProfilesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogProfilesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_profile/get_log_profiles_responses.go b/operations/log_profile/get_log_profiles_responses.go new file mode 100644 index 00000000..f27e6f60 --- /dev/null +++ b/operations/log_profile/get_log_profiles_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogProfilesOKCode is the HTTP code returned for type GetLogProfilesOK +const GetLogProfilesOKCode int = 200 + +/* +GetLogProfilesOK Successful operation + +swagger:response getLogProfilesOK +*/ +type GetLogProfilesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogProfiles `json:"body,omitempty"` +} + +// NewGetLogProfilesOK creates GetLogProfilesOK with default headers values +func NewGetLogProfilesOK() *GetLogProfilesOK { + + return &GetLogProfilesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log profiles o k response +func (o *GetLogProfilesOK) WithConfigurationVersion(configurationVersion string) *GetLogProfilesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log profiles o k response +func (o *GetLogProfilesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log profiles o k response +func (o *GetLogProfilesOK) WithPayload(payload models.LogProfiles) *GetLogProfilesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log profiles o k response +func (o *GetLogProfilesOK) SetPayload(payload models.LogProfiles) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogProfilesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogProfiles{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetLogProfilesDefault General Error + +swagger:response getLogProfilesDefault +*/ +type GetLogProfilesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogProfilesDefault creates GetLogProfilesDefault with default headers values +func NewGetLogProfilesDefault(code int) *GetLogProfilesDefault { + if code <= 0 { + code = 500 + } + + return &GetLogProfilesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log profiles default response +func (o *GetLogProfilesDefault) WithStatusCode(code int) *GetLogProfilesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log profiles default response +func (o *GetLogProfilesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log profiles default response +func (o *GetLogProfilesDefault) WithConfigurationVersion(configurationVersion string) *GetLogProfilesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log profiles default response +func (o *GetLogProfilesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log profiles default response +func (o *GetLogProfilesDefault) WithPayload(payload *models.Error) *GetLogProfilesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log profiles default response +func (o *GetLogProfilesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogProfilesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_profile/get_log_profiles_urlbuilder.go b/operations/log_profile/get_log_profiles_urlbuilder.go new file mode 100644 index 00000000..c0e6e16e --- /dev/null +++ b/operations/log_profile/get_log_profiles_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_profile + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetLogProfilesURL generates an URL for the get log profiles operation +type GetLogProfilesURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogProfilesURL) WithBasePath(bp string) *GetLogProfilesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogProfilesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogProfilesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_profiles" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogProfilesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogProfilesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogProfilesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogProfilesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogProfilesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogProfilesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/create_log_target.go b/operations/log_target/create_log_target.go deleted file mode 100644 index 9d8c72f8..00000000 --- a/operations/log_target/create_log_target.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateLogTargetHandlerFunc turns a function with the right signature into a create log target handler -type CreateLogTargetHandlerFunc func(CreateLogTargetParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateLogTargetHandlerFunc) Handle(params CreateLogTargetParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateLogTargetHandler interface for that can handle valid create log target params -type CreateLogTargetHandler interface { - Handle(CreateLogTargetParams, interface{}) middleware.Responder -} - -// NewCreateLogTarget creates a new http.Handler for the create log target operation -func NewCreateLogTarget(ctx *middleware.Context, handler CreateLogTargetHandler) *CreateLogTarget { - return &CreateLogTarget{Context: ctx, Handler: handler} -} - -/*CreateLogTarget swagger:route POST /services/haproxy/configuration/log_targets LogTarget createLogTarget - -Add a new Log Target - -Adds a new Log Target of the specified type in the specified parent. - -*/ -type CreateLogTarget struct { - Context *middleware.Context - Handler CreateLogTargetHandler -} - -func (o *CreateLogTarget) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateLogTargetParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/log_target/create_log_target_backend.go b/operations/log_target/create_log_target_backend.go new file mode 100644 index 00000000..85c40f2c --- /dev/null +++ b/operations/log_target/create_log_target_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogTargetBackendHandlerFunc turns a function with the right signature into a create log target backend handler +type CreateLogTargetBackendHandlerFunc func(CreateLogTargetBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogTargetBackendHandlerFunc) Handle(params CreateLogTargetBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogTargetBackendHandler interface for that can handle valid create log target backend params +type CreateLogTargetBackendHandler interface { + Handle(CreateLogTargetBackendParams, interface{}) middleware.Responder +} + +// NewCreateLogTargetBackend creates a new http.Handler for the create log target backend operation +func NewCreateLogTargetBackend(ctx *middleware.Context, handler CreateLogTargetBackendHandler) *CreateLogTargetBackend { + return &CreateLogTargetBackend{Context: ctx, Handler: handler} +} + +/* + CreateLogTargetBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/log_targets/{index} LogTarget createLogTargetBackend + +# Add a new Log Target + +Adds a new Log Target of the specified type in the specified parent. +*/ +type CreateLogTargetBackend struct { + Context *middleware.Context + Handler CreateLogTargetBackendHandler +} + +func (o *CreateLogTargetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogTargetBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/create_log_target_backend_parameters.go b/operations/log_target/create_log_target_backend_parameters.go new file mode 100644 index 00000000..b642be2f --- /dev/null +++ b/operations/log_target/create_log_target_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogTargetBackendParams creates a new CreateLogTargetBackendParams object +// with the default values initialized. +func NewCreateLogTargetBackendParams() CreateLogTargetBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateLogTargetBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateLogTargetBackendParams contains all the bound params for the create log target backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogTargetBackend +type CreateLogTargetBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogTargetBackendParams() beforehand. +func (o *CreateLogTargetBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogTargetBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogTargetBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateLogTargetBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateLogTargetBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogTargetBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogTargetBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/create_log_target_backend_responses.go b/operations/log_target/create_log_target_backend_responses.go new file mode 100644 index 00000000..f6140f96 --- /dev/null +++ b/operations/log_target/create_log_target_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogTargetBackendCreatedCode is the HTTP code returned for type CreateLogTargetBackendCreated +const CreateLogTargetBackendCreatedCode int = 201 + +/* +CreateLogTargetBackendCreated Log Target created + +swagger:response createLogTargetBackendCreated +*/ +type CreateLogTargetBackendCreated struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetBackendCreated creates CreateLogTargetBackendCreated with default headers values +func NewCreateLogTargetBackendCreated() *CreateLogTargetBackendCreated { + + return &CreateLogTargetBackendCreated{} +} + +// WithPayload adds the payload to the create log target backend created response +func (o *CreateLogTargetBackendCreated) WithPayload(payload *models.LogTarget) *CreateLogTargetBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target backend created response +func (o *CreateLogTargetBackendCreated) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetBackendAcceptedCode is the HTTP code returned for type CreateLogTargetBackendAccepted +const CreateLogTargetBackendAcceptedCode int = 202 + +/* +CreateLogTargetBackendAccepted Configuration change accepted and reload requested + +swagger:response createLogTargetBackendAccepted +*/ +type CreateLogTargetBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetBackendAccepted creates CreateLogTargetBackendAccepted with default headers values +func NewCreateLogTargetBackendAccepted() *CreateLogTargetBackendAccepted { + + return &CreateLogTargetBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create log target backend accepted response +func (o *CreateLogTargetBackendAccepted) WithReloadID(reloadID string) *CreateLogTargetBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log target backend accepted response +func (o *CreateLogTargetBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log target backend accepted response +func (o *CreateLogTargetBackendAccepted) WithPayload(payload *models.LogTarget) *CreateLogTargetBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target backend accepted response +func (o *CreateLogTargetBackendAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetBackendBadRequestCode is the HTTP code returned for type CreateLogTargetBackendBadRequest +const CreateLogTargetBackendBadRequestCode int = 400 + +/* +CreateLogTargetBackendBadRequest Bad request + +swagger:response createLogTargetBackendBadRequest +*/ +type CreateLogTargetBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetBackendBadRequest creates CreateLogTargetBackendBadRequest with default headers values +func NewCreateLogTargetBackendBadRequest() *CreateLogTargetBackendBadRequest { + + return &CreateLogTargetBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target backend bad request response +func (o *CreateLogTargetBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogTargetBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target backend bad request response +func (o *CreateLogTargetBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target backend bad request response +func (o *CreateLogTargetBackendBadRequest) WithPayload(payload *models.Error) *CreateLogTargetBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target backend bad request response +func (o *CreateLogTargetBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetBackendConflictCode is the HTTP code returned for type CreateLogTargetBackendConflict +const CreateLogTargetBackendConflictCode int = 409 + +/* +CreateLogTargetBackendConflict The specified resource already exists + +swagger:response createLogTargetBackendConflict +*/ +type CreateLogTargetBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetBackendConflict creates CreateLogTargetBackendConflict with default headers values +func NewCreateLogTargetBackendConflict() *CreateLogTargetBackendConflict { + + return &CreateLogTargetBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target backend conflict response +func (o *CreateLogTargetBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateLogTargetBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target backend conflict response +func (o *CreateLogTargetBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target backend conflict response +func (o *CreateLogTargetBackendConflict) WithPayload(payload *models.Error) *CreateLogTargetBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target backend conflict response +func (o *CreateLogTargetBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogTargetBackendDefault General Error + +swagger:response createLogTargetBackendDefault +*/ +type CreateLogTargetBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetBackendDefault creates CreateLogTargetBackendDefault with default headers values +func NewCreateLogTargetBackendDefault(code int) *CreateLogTargetBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogTargetBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log target backend default response +func (o *CreateLogTargetBackendDefault) WithStatusCode(code int) *CreateLogTargetBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log target backend default response +func (o *CreateLogTargetBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log target backend default response +func (o *CreateLogTargetBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateLogTargetBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target backend default response +func (o *CreateLogTargetBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target backend default response +func (o *CreateLogTargetBackendDefault) WithPayload(payload *models.Error) *CreateLogTargetBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target backend default response +func (o *CreateLogTargetBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/create_log_target_backend_urlbuilder.go b/operations/log_target/create_log_target_backend_urlbuilder.go new file mode 100644 index 00000000..77d8ab60 --- /dev/null +++ b/operations/log_target/create_log_target_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateLogTargetBackendURL generates an URL for the create log target backend operation +type CreateLogTargetBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetBackendURL) WithBasePath(bp string) *CreateLogTargetBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogTargetBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateLogTargetBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateLogTargetBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogTargetBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogTargetBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogTargetBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogTargetBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogTargetBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogTargetBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/create_log_target_defaults.go b/operations/log_target/create_log_target_defaults.go new file mode 100644 index 00000000..f69a13ad --- /dev/null +++ b/operations/log_target/create_log_target_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogTargetDefaultsHandlerFunc turns a function with the right signature into a create log target defaults handler +type CreateLogTargetDefaultsHandlerFunc func(CreateLogTargetDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogTargetDefaultsHandlerFunc) Handle(params CreateLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogTargetDefaultsHandler interface for that can handle valid create log target defaults params +type CreateLogTargetDefaultsHandler interface { + Handle(CreateLogTargetDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateLogTargetDefaults creates a new http.Handler for the create log target defaults operation +func NewCreateLogTargetDefaults(ctx *middleware.Context, handler CreateLogTargetDefaultsHandler) *CreateLogTargetDefaults { + return &CreateLogTargetDefaults{Context: ctx, Handler: handler} +} + +/* + CreateLogTargetDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/log_targets/{index} LogTarget createLogTargetDefaults + +# Add a new Log Target + +Adds a new Log Target of the specified type in the specified parent. +*/ +type CreateLogTargetDefaults struct { + Context *middleware.Context + Handler CreateLogTargetDefaultsHandler +} + +func (o *CreateLogTargetDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogTargetDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/create_log_target_defaults_parameters.go b/operations/log_target/create_log_target_defaults_parameters.go new file mode 100644 index 00000000..be3778fe --- /dev/null +++ b/operations/log_target/create_log_target_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogTargetDefaultsParams creates a new CreateLogTargetDefaultsParams object +// with the default values initialized. +func NewCreateLogTargetDefaultsParams() CreateLogTargetDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateLogTargetDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateLogTargetDefaultsParams contains all the bound params for the create log target defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogTargetDefaults +type CreateLogTargetDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogTargetDefaultsParams() beforehand. +func (o *CreateLogTargetDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogTargetDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogTargetDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateLogTargetDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateLogTargetDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogTargetDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogTargetDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/create_log_target_defaults_responses.go b/operations/log_target/create_log_target_defaults_responses.go new file mode 100644 index 00000000..1954337e --- /dev/null +++ b/operations/log_target/create_log_target_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogTargetDefaultsCreatedCode is the HTTP code returned for type CreateLogTargetDefaultsCreated +const CreateLogTargetDefaultsCreatedCode int = 201 + +/* +CreateLogTargetDefaultsCreated Log Target created + +swagger:response createLogTargetDefaultsCreated +*/ +type CreateLogTargetDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetDefaultsCreated creates CreateLogTargetDefaultsCreated with default headers values +func NewCreateLogTargetDefaultsCreated() *CreateLogTargetDefaultsCreated { + + return &CreateLogTargetDefaultsCreated{} +} + +// WithPayload adds the payload to the create log target defaults created response +func (o *CreateLogTargetDefaultsCreated) WithPayload(payload *models.LogTarget) *CreateLogTargetDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target defaults created response +func (o *CreateLogTargetDefaultsCreated) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetDefaultsAcceptedCode is the HTTP code returned for type CreateLogTargetDefaultsAccepted +const CreateLogTargetDefaultsAcceptedCode int = 202 + +/* +CreateLogTargetDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createLogTargetDefaultsAccepted +*/ +type CreateLogTargetDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetDefaultsAccepted creates CreateLogTargetDefaultsAccepted with default headers values +func NewCreateLogTargetDefaultsAccepted() *CreateLogTargetDefaultsAccepted { + + return &CreateLogTargetDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create log target defaults accepted response +func (o *CreateLogTargetDefaultsAccepted) WithReloadID(reloadID string) *CreateLogTargetDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log target defaults accepted response +func (o *CreateLogTargetDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log target defaults accepted response +func (o *CreateLogTargetDefaultsAccepted) WithPayload(payload *models.LogTarget) *CreateLogTargetDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target defaults accepted response +func (o *CreateLogTargetDefaultsAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetDefaultsBadRequestCode is the HTTP code returned for type CreateLogTargetDefaultsBadRequest +const CreateLogTargetDefaultsBadRequestCode int = 400 + +/* +CreateLogTargetDefaultsBadRequest Bad request + +swagger:response createLogTargetDefaultsBadRequest +*/ +type CreateLogTargetDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetDefaultsBadRequest creates CreateLogTargetDefaultsBadRequest with default headers values +func NewCreateLogTargetDefaultsBadRequest() *CreateLogTargetDefaultsBadRequest { + + return &CreateLogTargetDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target defaults bad request response +func (o *CreateLogTargetDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogTargetDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target defaults bad request response +func (o *CreateLogTargetDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target defaults bad request response +func (o *CreateLogTargetDefaultsBadRequest) WithPayload(payload *models.Error) *CreateLogTargetDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target defaults bad request response +func (o *CreateLogTargetDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetDefaultsConflictCode is the HTTP code returned for type CreateLogTargetDefaultsConflict +const CreateLogTargetDefaultsConflictCode int = 409 + +/* +CreateLogTargetDefaultsConflict The specified resource already exists + +swagger:response createLogTargetDefaultsConflict +*/ +type CreateLogTargetDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetDefaultsConflict creates CreateLogTargetDefaultsConflict with default headers values +func NewCreateLogTargetDefaultsConflict() *CreateLogTargetDefaultsConflict { + + return &CreateLogTargetDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target defaults conflict response +func (o *CreateLogTargetDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateLogTargetDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target defaults conflict response +func (o *CreateLogTargetDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target defaults conflict response +func (o *CreateLogTargetDefaultsConflict) WithPayload(payload *models.Error) *CreateLogTargetDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target defaults conflict response +func (o *CreateLogTargetDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogTargetDefaultsDefault General Error + +swagger:response createLogTargetDefaultsDefault +*/ +type CreateLogTargetDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetDefaultsDefault creates CreateLogTargetDefaultsDefault with default headers values +func NewCreateLogTargetDefaultsDefault(code int) *CreateLogTargetDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogTargetDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log target defaults default response +func (o *CreateLogTargetDefaultsDefault) WithStatusCode(code int) *CreateLogTargetDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log target defaults default response +func (o *CreateLogTargetDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log target defaults default response +func (o *CreateLogTargetDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateLogTargetDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target defaults default response +func (o *CreateLogTargetDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target defaults default response +func (o *CreateLogTargetDefaultsDefault) WithPayload(payload *models.Error) *CreateLogTargetDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target defaults default response +func (o *CreateLogTargetDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/create_log_target_defaults_urlbuilder.go b/operations/log_target/create_log_target_defaults_urlbuilder.go new file mode 100644 index 00000000..517fa28b --- /dev/null +++ b/operations/log_target/create_log_target_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateLogTargetDefaultsURL generates an URL for the create log target defaults operation +type CreateLogTargetDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetDefaultsURL) WithBasePath(bp string) *CreateLogTargetDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogTargetDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateLogTargetDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateLogTargetDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogTargetDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogTargetDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogTargetDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogTargetDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogTargetDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogTargetDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/create_log_target_frontend.go b/operations/log_target/create_log_target_frontend.go new file mode 100644 index 00000000..cfb1d563 --- /dev/null +++ b/operations/log_target/create_log_target_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogTargetFrontendHandlerFunc turns a function with the right signature into a create log target frontend handler +type CreateLogTargetFrontendHandlerFunc func(CreateLogTargetFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogTargetFrontendHandlerFunc) Handle(params CreateLogTargetFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogTargetFrontendHandler interface for that can handle valid create log target frontend params +type CreateLogTargetFrontendHandler interface { + Handle(CreateLogTargetFrontendParams, interface{}) middleware.Responder +} + +// NewCreateLogTargetFrontend creates a new http.Handler for the create log target frontend operation +func NewCreateLogTargetFrontend(ctx *middleware.Context, handler CreateLogTargetFrontendHandler) *CreateLogTargetFrontend { + return &CreateLogTargetFrontend{Context: ctx, Handler: handler} +} + +/* + CreateLogTargetFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/log_targets/{index} LogTarget createLogTargetFrontend + +# Add a new Log Target + +Adds a new Log Target of the specified type in the specified parent. +*/ +type CreateLogTargetFrontend struct { + Context *middleware.Context + Handler CreateLogTargetFrontendHandler +} + +func (o *CreateLogTargetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogTargetFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/create_log_target_frontend_parameters.go b/operations/log_target/create_log_target_frontend_parameters.go new file mode 100644 index 00000000..a92b211e --- /dev/null +++ b/operations/log_target/create_log_target_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogTargetFrontendParams creates a new CreateLogTargetFrontendParams object +// with the default values initialized. +func NewCreateLogTargetFrontendParams() CreateLogTargetFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateLogTargetFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateLogTargetFrontendParams contains all the bound params for the create log target frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogTargetFrontend +type CreateLogTargetFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogTargetFrontendParams() beforehand. +func (o *CreateLogTargetFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogTargetFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogTargetFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateLogTargetFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateLogTargetFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogTargetFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogTargetFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/create_log_target_frontend_responses.go b/operations/log_target/create_log_target_frontend_responses.go new file mode 100644 index 00000000..fb9534ff --- /dev/null +++ b/operations/log_target/create_log_target_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogTargetFrontendCreatedCode is the HTTP code returned for type CreateLogTargetFrontendCreated +const CreateLogTargetFrontendCreatedCode int = 201 + +/* +CreateLogTargetFrontendCreated Log Target created + +swagger:response createLogTargetFrontendCreated +*/ +type CreateLogTargetFrontendCreated struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetFrontendCreated creates CreateLogTargetFrontendCreated with default headers values +func NewCreateLogTargetFrontendCreated() *CreateLogTargetFrontendCreated { + + return &CreateLogTargetFrontendCreated{} +} + +// WithPayload adds the payload to the create log target frontend created response +func (o *CreateLogTargetFrontendCreated) WithPayload(payload *models.LogTarget) *CreateLogTargetFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target frontend created response +func (o *CreateLogTargetFrontendCreated) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetFrontendAcceptedCode is the HTTP code returned for type CreateLogTargetFrontendAccepted +const CreateLogTargetFrontendAcceptedCode int = 202 + +/* +CreateLogTargetFrontendAccepted Configuration change accepted and reload requested + +swagger:response createLogTargetFrontendAccepted +*/ +type CreateLogTargetFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetFrontendAccepted creates CreateLogTargetFrontendAccepted with default headers values +func NewCreateLogTargetFrontendAccepted() *CreateLogTargetFrontendAccepted { + + return &CreateLogTargetFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create log target frontend accepted response +func (o *CreateLogTargetFrontendAccepted) WithReloadID(reloadID string) *CreateLogTargetFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log target frontend accepted response +func (o *CreateLogTargetFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log target frontend accepted response +func (o *CreateLogTargetFrontendAccepted) WithPayload(payload *models.LogTarget) *CreateLogTargetFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target frontend accepted response +func (o *CreateLogTargetFrontendAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetFrontendBadRequestCode is the HTTP code returned for type CreateLogTargetFrontendBadRequest +const CreateLogTargetFrontendBadRequestCode int = 400 + +/* +CreateLogTargetFrontendBadRequest Bad request + +swagger:response createLogTargetFrontendBadRequest +*/ +type CreateLogTargetFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetFrontendBadRequest creates CreateLogTargetFrontendBadRequest with default headers values +func NewCreateLogTargetFrontendBadRequest() *CreateLogTargetFrontendBadRequest { + + return &CreateLogTargetFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target frontend bad request response +func (o *CreateLogTargetFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogTargetFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target frontend bad request response +func (o *CreateLogTargetFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target frontend bad request response +func (o *CreateLogTargetFrontendBadRequest) WithPayload(payload *models.Error) *CreateLogTargetFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target frontend bad request response +func (o *CreateLogTargetFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetFrontendConflictCode is the HTTP code returned for type CreateLogTargetFrontendConflict +const CreateLogTargetFrontendConflictCode int = 409 + +/* +CreateLogTargetFrontendConflict The specified resource already exists + +swagger:response createLogTargetFrontendConflict +*/ +type CreateLogTargetFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetFrontendConflict creates CreateLogTargetFrontendConflict with default headers values +func NewCreateLogTargetFrontendConflict() *CreateLogTargetFrontendConflict { + + return &CreateLogTargetFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target frontend conflict response +func (o *CreateLogTargetFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateLogTargetFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target frontend conflict response +func (o *CreateLogTargetFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target frontend conflict response +func (o *CreateLogTargetFrontendConflict) WithPayload(payload *models.Error) *CreateLogTargetFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target frontend conflict response +func (o *CreateLogTargetFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogTargetFrontendDefault General Error + +swagger:response createLogTargetFrontendDefault +*/ +type CreateLogTargetFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetFrontendDefault creates CreateLogTargetFrontendDefault with default headers values +func NewCreateLogTargetFrontendDefault(code int) *CreateLogTargetFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogTargetFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log target frontend default response +func (o *CreateLogTargetFrontendDefault) WithStatusCode(code int) *CreateLogTargetFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log target frontend default response +func (o *CreateLogTargetFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log target frontend default response +func (o *CreateLogTargetFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateLogTargetFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target frontend default response +func (o *CreateLogTargetFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target frontend default response +func (o *CreateLogTargetFrontendDefault) WithPayload(payload *models.Error) *CreateLogTargetFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target frontend default response +func (o *CreateLogTargetFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/create_log_target_frontend_urlbuilder.go b/operations/log_target/create_log_target_frontend_urlbuilder.go new file mode 100644 index 00000000..ef1a4d30 --- /dev/null +++ b/operations/log_target/create_log_target_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateLogTargetFrontendURL generates an URL for the create log target frontend operation +type CreateLogTargetFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetFrontendURL) WithBasePath(bp string) *CreateLogTargetFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogTargetFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateLogTargetFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateLogTargetFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogTargetFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogTargetFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogTargetFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogTargetFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogTargetFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogTargetFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/create_log_target_global.go b/operations/log_target/create_log_target_global.go new file mode 100644 index 00000000..b3fb3248 --- /dev/null +++ b/operations/log_target/create_log_target_global.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogTargetGlobalHandlerFunc turns a function with the right signature into a create log target global handler +type CreateLogTargetGlobalHandlerFunc func(CreateLogTargetGlobalParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogTargetGlobalHandlerFunc) Handle(params CreateLogTargetGlobalParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogTargetGlobalHandler interface for that can handle valid create log target global params +type CreateLogTargetGlobalHandler interface { + Handle(CreateLogTargetGlobalParams, interface{}) middleware.Responder +} + +// NewCreateLogTargetGlobal creates a new http.Handler for the create log target global operation +func NewCreateLogTargetGlobal(ctx *middleware.Context, handler CreateLogTargetGlobalHandler) *CreateLogTargetGlobal { + return &CreateLogTargetGlobal{Context: ctx, Handler: handler} +} + +/* + CreateLogTargetGlobal swagger:route POST /services/haproxy/configuration/global/log_targets/{index} LogTarget createLogTargetGlobal + +# Add a new Log Target + +Adds a new Log Target of the specified type in the specified parent. +*/ +type CreateLogTargetGlobal struct { + Context *middleware.Context + Handler CreateLogTargetGlobalHandler +} + +func (o *CreateLogTargetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogTargetGlobalParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/create_log_target_global_parameters.go b/operations/log_target/create_log_target_global_parameters.go new file mode 100644 index 00000000..ce958962 --- /dev/null +++ b/operations/log_target/create_log_target_global_parameters.go @@ -0,0 +1,226 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogTargetGlobalParams creates a new CreateLogTargetGlobalParams object +// with the default values initialized. +func NewCreateLogTargetGlobalParams() CreateLogTargetGlobalParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateLogTargetGlobalParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateLogTargetGlobalParams contains all the bound params for the create log target global operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogTargetGlobal +type CreateLogTargetGlobalParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogTargetGlobalParams() beforehand. +func (o *CreateLogTargetGlobalParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogTargetGlobalParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogTargetGlobalParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateLogTargetGlobalParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogTargetGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogTargetGlobalParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/create_log_target_global_responses.go b/operations/log_target/create_log_target_global_responses.go new file mode 100644 index 00000000..2e3e054b --- /dev/null +++ b/operations/log_target/create_log_target_global_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogTargetGlobalCreatedCode is the HTTP code returned for type CreateLogTargetGlobalCreated +const CreateLogTargetGlobalCreatedCode int = 201 + +/* +CreateLogTargetGlobalCreated Log Target created + +swagger:response createLogTargetGlobalCreated +*/ +type CreateLogTargetGlobalCreated struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetGlobalCreated creates CreateLogTargetGlobalCreated with default headers values +func NewCreateLogTargetGlobalCreated() *CreateLogTargetGlobalCreated { + + return &CreateLogTargetGlobalCreated{} +} + +// WithPayload adds the payload to the create log target global created response +func (o *CreateLogTargetGlobalCreated) WithPayload(payload *models.LogTarget) *CreateLogTargetGlobalCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target global created response +func (o *CreateLogTargetGlobalCreated) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetGlobalCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetGlobalAcceptedCode is the HTTP code returned for type CreateLogTargetGlobalAccepted +const CreateLogTargetGlobalAcceptedCode int = 202 + +/* +CreateLogTargetGlobalAccepted Configuration change accepted and reload requested + +swagger:response createLogTargetGlobalAccepted +*/ +type CreateLogTargetGlobalAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetGlobalAccepted creates CreateLogTargetGlobalAccepted with default headers values +func NewCreateLogTargetGlobalAccepted() *CreateLogTargetGlobalAccepted { + + return &CreateLogTargetGlobalAccepted{} +} + +// WithReloadID adds the reloadId to the create log target global accepted response +func (o *CreateLogTargetGlobalAccepted) WithReloadID(reloadID string) *CreateLogTargetGlobalAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log target global accepted response +func (o *CreateLogTargetGlobalAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log target global accepted response +func (o *CreateLogTargetGlobalAccepted) WithPayload(payload *models.LogTarget) *CreateLogTargetGlobalAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target global accepted response +func (o *CreateLogTargetGlobalAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetGlobalAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetGlobalBadRequestCode is the HTTP code returned for type CreateLogTargetGlobalBadRequest +const CreateLogTargetGlobalBadRequestCode int = 400 + +/* +CreateLogTargetGlobalBadRequest Bad request + +swagger:response createLogTargetGlobalBadRequest +*/ +type CreateLogTargetGlobalBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetGlobalBadRequest creates CreateLogTargetGlobalBadRequest with default headers values +func NewCreateLogTargetGlobalBadRequest() *CreateLogTargetGlobalBadRequest { + + return &CreateLogTargetGlobalBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target global bad request response +func (o *CreateLogTargetGlobalBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogTargetGlobalBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target global bad request response +func (o *CreateLogTargetGlobalBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target global bad request response +func (o *CreateLogTargetGlobalBadRequest) WithPayload(payload *models.Error) *CreateLogTargetGlobalBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target global bad request response +func (o *CreateLogTargetGlobalBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetGlobalBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetGlobalConflictCode is the HTTP code returned for type CreateLogTargetGlobalConflict +const CreateLogTargetGlobalConflictCode int = 409 + +/* +CreateLogTargetGlobalConflict The specified resource already exists + +swagger:response createLogTargetGlobalConflict +*/ +type CreateLogTargetGlobalConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetGlobalConflict creates CreateLogTargetGlobalConflict with default headers values +func NewCreateLogTargetGlobalConflict() *CreateLogTargetGlobalConflict { + + return &CreateLogTargetGlobalConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target global conflict response +func (o *CreateLogTargetGlobalConflict) WithConfigurationVersion(configurationVersion string) *CreateLogTargetGlobalConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target global conflict response +func (o *CreateLogTargetGlobalConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target global conflict response +func (o *CreateLogTargetGlobalConflict) WithPayload(payload *models.Error) *CreateLogTargetGlobalConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target global conflict response +func (o *CreateLogTargetGlobalConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetGlobalConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogTargetGlobalDefault General Error + +swagger:response createLogTargetGlobalDefault +*/ +type CreateLogTargetGlobalDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetGlobalDefault creates CreateLogTargetGlobalDefault with default headers values +func NewCreateLogTargetGlobalDefault(code int) *CreateLogTargetGlobalDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogTargetGlobalDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log target global default response +func (o *CreateLogTargetGlobalDefault) WithStatusCode(code int) *CreateLogTargetGlobalDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log target global default response +func (o *CreateLogTargetGlobalDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log target global default response +func (o *CreateLogTargetGlobalDefault) WithConfigurationVersion(configurationVersion string) *CreateLogTargetGlobalDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target global default response +func (o *CreateLogTargetGlobalDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target global default response +func (o *CreateLogTargetGlobalDefault) WithPayload(payload *models.Error) *CreateLogTargetGlobalDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target global default response +func (o *CreateLogTargetGlobalDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetGlobalDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/create_log_target_global_urlbuilder.go b/operations/log_target/create_log_target_global_urlbuilder.go new file mode 100644 index 00000000..9e63c28c --- /dev/null +++ b/operations/log_target/create_log_target_global_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateLogTargetGlobalURL generates an URL for the create log target global operation +type CreateLogTargetGlobalURL struct { + Index int64 + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetGlobalURL) WithBasePath(bp string) *CreateLogTargetGlobalURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetGlobalURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogTargetGlobalURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/global/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateLogTargetGlobalURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogTargetGlobalURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogTargetGlobalURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogTargetGlobalURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogTargetGlobalURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogTargetGlobalURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogTargetGlobalURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/create_log_target_log_forward.go b/operations/log_target/create_log_target_log_forward.go new file mode 100644 index 00000000..6f029958 --- /dev/null +++ b/operations/log_target/create_log_target_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogTargetLogForwardHandlerFunc turns a function with the right signature into a create log target log forward handler +type CreateLogTargetLogForwardHandlerFunc func(CreateLogTargetLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogTargetLogForwardHandlerFunc) Handle(params CreateLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogTargetLogForwardHandler interface for that can handle valid create log target log forward params +type CreateLogTargetLogForwardHandler interface { + Handle(CreateLogTargetLogForwardParams, interface{}) middleware.Responder +} + +// NewCreateLogTargetLogForward creates a new http.Handler for the create log target log forward operation +func NewCreateLogTargetLogForward(ctx *middleware.Context, handler CreateLogTargetLogForwardHandler) *CreateLogTargetLogForward { + return &CreateLogTargetLogForward{Context: ctx, Handler: handler} +} + +/* + CreateLogTargetLogForward swagger:route POST /services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index} LogTarget createLogTargetLogForward + +# Add a new Log Target + +Adds a new Log Target of the specified type in the specified parent. +*/ +type CreateLogTargetLogForward struct { + Context *middleware.Context + Handler CreateLogTargetLogForwardHandler +} + +func (o *CreateLogTargetLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogTargetLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/create_log_target_log_forward_parameters.go b/operations/log_target/create_log_target_log_forward_parameters.go new file mode 100644 index 00000000..b09d6390 --- /dev/null +++ b/operations/log_target/create_log_target_log_forward_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogTargetLogForwardParams creates a new CreateLogTargetLogForwardParams object +// with the default values initialized. +func NewCreateLogTargetLogForwardParams() CreateLogTargetLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateLogTargetLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateLogTargetLogForwardParams contains all the bound params for the create log target log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogTargetLogForward +type CreateLogTargetLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogTargetLogForwardParams() beforehand. +func (o *CreateLogTargetLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogTargetLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogTargetLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateLogTargetLogForwardParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateLogTargetLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogTargetLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogTargetLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/create_log_target_log_forward_responses.go b/operations/log_target/create_log_target_log_forward_responses.go new file mode 100644 index 00000000..609921fe --- /dev/null +++ b/operations/log_target/create_log_target_log_forward_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogTargetLogForwardCreatedCode is the HTTP code returned for type CreateLogTargetLogForwardCreated +const CreateLogTargetLogForwardCreatedCode int = 201 + +/* +CreateLogTargetLogForwardCreated Log Target created + +swagger:response createLogTargetLogForwardCreated +*/ +type CreateLogTargetLogForwardCreated struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetLogForwardCreated creates CreateLogTargetLogForwardCreated with default headers values +func NewCreateLogTargetLogForwardCreated() *CreateLogTargetLogForwardCreated { + + return &CreateLogTargetLogForwardCreated{} +} + +// WithPayload adds the payload to the create log target log forward created response +func (o *CreateLogTargetLogForwardCreated) WithPayload(payload *models.LogTarget) *CreateLogTargetLogForwardCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target log forward created response +func (o *CreateLogTargetLogForwardCreated) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetLogForwardCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetLogForwardAcceptedCode is the HTTP code returned for type CreateLogTargetLogForwardAccepted +const CreateLogTargetLogForwardAcceptedCode int = 202 + +/* +CreateLogTargetLogForwardAccepted Configuration change accepted and reload requested + +swagger:response createLogTargetLogForwardAccepted +*/ +type CreateLogTargetLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetLogForwardAccepted creates CreateLogTargetLogForwardAccepted with default headers values +func NewCreateLogTargetLogForwardAccepted() *CreateLogTargetLogForwardAccepted { + + return &CreateLogTargetLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the create log target log forward accepted response +func (o *CreateLogTargetLogForwardAccepted) WithReloadID(reloadID string) *CreateLogTargetLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log target log forward accepted response +func (o *CreateLogTargetLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log target log forward accepted response +func (o *CreateLogTargetLogForwardAccepted) WithPayload(payload *models.LogTarget) *CreateLogTargetLogForwardAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target log forward accepted response +func (o *CreateLogTargetLogForwardAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetLogForwardBadRequestCode is the HTTP code returned for type CreateLogTargetLogForwardBadRequest +const CreateLogTargetLogForwardBadRequestCode int = 400 + +/* +CreateLogTargetLogForwardBadRequest Bad request + +swagger:response createLogTargetLogForwardBadRequest +*/ +type CreateLogTargetLogForwardBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetLogForwardBadRequest creates CreateLogTargetLogForwardBadRequest with default headers values +func NewCreateLogTargetLogForwardBadRequest() *CreateLogTargetLogForwardBadRequest { + + return &CreateLogTargetLogForwardBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target log forward bad request response +func (o *CreateLogTargetLogForwardBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogTargetLogForwardBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target log forward bad request response +func (o *CreateLogTargetLogForwardBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target log forward bad request response +func (o *CreateLogTargetLogForwardBadRequest) WithPayload(payload *models.Error) *CreateLogTargetLogForwardBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target log forward bad request response +func (o *CreateLogTargetLogForwardBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetLogForwardBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetLogForwardConflictCode is the HTTP code returned for type CreateLogTargetLogForwardConflict +const CreateLogTargetLogForwardConflictCode int = 409 + +/* +CreateLogTargetLogForwardConflict The specified resource already exists + +swagger:response createLogTargetLogForwardConflict +*/ +type CreateLogTargetLogForwardConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetLogForwardConflict creates CreateLogTargetLogForwardConflict with default headers values +func NewCreateLogTargetLogForwardConflict() *CreateLogTargetLogForwardConflict { + + return &CreateLogTargetLogForwardConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target log forward conflict response +func (o *CreateLogTargetLogForwardConflict) WithConfigurationVersion(configurationVersion string) *CreateLogTargetLogForwardConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target log forward conflict response +func (o *CreateLogTargetLogForwardConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target log forward conflict response +func (o *CreateLogTargetLogForwardConflict) WithPayload(payload *models.Error) *CreateLogTargetLogForwardConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target log forward conflict response +func (o *CreateLogTargetLogForwardConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetLogForwardConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogTargetLogForwardDefault General Error + +swagger:response createLogTargetLogForwardDefault +*/ +type CreateLogTargetLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetLogForwardDefault creates CreateLogTargetLogForwardDefault with default headers values +func NewCreateLogTargetLogForwardDefault(code int) *CreateLogTargetLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogTargetLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log target log forward default response +func (o *CreateLogTargetLogForwardDefault) WithStatusCode(code int) *CreateLogTargetLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log target log forward default response +func (o *CreateLogTargetLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log target log forward default response +func (o *CreateLogTargetLogForwardDefault) WithConfigurationVersion(configurationVersion string) *CreateLogTargetLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target log forward default response +func (o *CreateLogTargetLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target log forward default response +func (o *CreateLogTargetLogForwardDefault) WithPayload(payload *models.Error) *CreateLogTargetLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target log forward default response +func (o *CreateLogTargetLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/create_log_target_log_forward_urlbuilder.go b/operations/log_target/create_log_target_log_forward_urlbuilder.go new file mode 100644 index 00000000..976ac606 --- /dev/null +++ b/operations/log_target/create_log_target_log_forward_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateLogTargetLogForwardURL generates an URL for the create log target log forward operation +type CreateLogTargetLogForwardURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetLogForwardURL) WithBasePath(bp string) *CreateLogTargetLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogTargetLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateLogTargetLogForwardURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateLogTargetLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogTargetLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogTargetLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogTargetLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogTargetLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogTargetLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogTargetLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/create_log_target_parameters.go b/operations/log_target/create_log_target_parameters.go deleted file mode 100644 index 2ffbe998..00000000 --- a/operations/log_target/create_log_target_parameters.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateLogTargetParams creates a new CreateLogTargetParams object -// with the default values initialized. -func NewCreateLogTargetParams() CreateLogTargetParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateLogTargetParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateLogTargetParams contains all the bound params for the create log target operation -// typically these are obtained from a http.Request -// -// swagger:parameters createLogTarget -type CreateLogTargetParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.LogTarget - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateLogTargetParams() beforehand. -func (o *CreateLogTargetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.LogTarget - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateLogTargetParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateLogTargetParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *CreateLogTargetParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *CreateLogTargetParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *CreateLogTargetParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateLogTargetParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateLogTargetParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/log_target/create_log_target_peer.go b/operations/log_target/create_log_target_peer.go new file mode 100644 index 00000000..d6110879 --- /dev/null +++ b/operations/log_target/create_log_target_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateLogTargetPeerHandlerFunc turns a function with the right signature into a create log target peer handler +type CreateLogTargetPeerHandlerFunc func(CreateLogTargetPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateLogTargetPeerHandlerFunc) Handle(params CreateLogTargetPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateLogTargetPeerHandler interface for that can handle valid create log target peer params +type CreateLogTargetPeerHandler interface { + Handle(CreateLogTargetPeerParams, interface{}) middleware.Responder +} + +// NewCreateLogTargetPeer creates a new http.Handler for the create log target peer operation +func NewCreateLogTargetPeer(ctx *middleware.Context, handler CreateLogTargetPeerHandler) *CreateLogTargetPeer { + return &CreateLogTargetPeer{Context: ctx, Handler: handler} +} + +/* + CreateLogTargetPeer swagger:route POST /services/haproxy/configuration/peers/{parent_name}/log_targets/{index} LogTarget createLogTargetPeer + +# Add a new Log Target + +Adds a new Log Target of the specified type in the specified parent. +*/ +type CreateLogTargetPeer struct { + Context *middleware.Context + Handler CreateLogTargetPeerHandler +} + +func (o *CreateLogTargetPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateLogTargetPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/create_log_target_peer_parameters.go b/operations/log_target/create_log_target_peer_parameters.go new file mode 100644 index 00000000..df9ae9b5 --- /dev/null +++ b/operations/log_target/create_log_target_peer_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateLogTargetPeerParams creates a new CreateLogTargetPeerParams object +// with the default values initialized. +func NewCreateLogTargetPeerParams() CreateLogTargetPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateLogTargetPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateLogTargetPeerParams contains all the bound params for the create log target peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters createLogTargetPeer +type CreateLogTargetPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateLogTargetPeerParams() beforehand. +func (o *CreateLogTargetPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateLogTargetPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateLogTargetPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateLogTargetPeerParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateLogTargetPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateLogTargetPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateLogTargetPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/create_log_target_peer_responses.go b/operations/log_target/create_log_target_peer_responses.go new file mode 100644 index 00000000..1e69d308 --- /dev/null +++ b/operations/log_target/create_log_target_peer_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateLogTargetPeerCreatedCode is the HTTP code returned for type CreateLogTargetPeerCreated +const CreateLogTargetPeerCreatedCode int = 201 + +/* +CreateLogTargetPeerCreated Log Target created + +swagger:response createLogTargetPeerCreated +*/ +type CreateLogTargetPeerCreated struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetPeerCreated creates CreateLogTargetPeerCreated with default headers values +func NewCreateLogTargetPeerCreated() *CreateLogTargetPeerCreated { + + return &CreateLogTargetPeerCreated{} +} + +// WithPayload adds the payload to the create log target peer created response +func (o *CreateLogTargetPeerCreated) WithPayload(payload *models.LogTarget) *CreateLogTargetPeerCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target peer created response +func (o *CreateLogTargetPeerCreated) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetPeerCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetPeerAcceptedCode is the HTTP code returned for type CreateLogTargetPeerAccepted +const CreateLogTargetPeerAcceptedCode int = 202 + +/* +CreateLogTargetPeerAccepted Configuration change accepted and reload requested + +swagger:response createLogTargetPeerAccepted +*/ +type CreateLogTargetPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewCreateLogTargetPeerAccepted creates CreateLogTargetPeerAccepted with default headers values +func NewCreateLogTargetPeerAccepted() *CreateLogTargetPeerAccepted { + + return &CreateLogTargetPeerAccepted{} +} + +// WithReloadID adds the reloadId to the create log target peer accepted response +func (o *CreateLogTargetPeerAccepted) WithReloadID(reloadID string) *CreateLogTargetPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create log target peer accepted response +func (o *CreateLogTargetPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create log target peer accepted response +func (o *CreateLogTargetPeerAccepted) WithPayload(payload *models.LogTarget) *CreateLogTargetPeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target peer accepted response +func (o *CreateLogTargetPeerAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetPeerBadRequestCode is the HTTP code returned for type CreateLogTargetPeerBadRequest +const CreateLogTargetPeerBadRequestCode int = 400 + +/* +CreateLogTargetPeerBadRequest Bad request + +swagger:response createLogTargetPeerBadRequest +*/ +type CreateLogTargetPeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetPeerBadRequest creates CreateLogTargetPeerBadRequest with default headers values +func NewCreateLogTargetPeerBadRequest() *CreateLogTargetPeerBadRequest { + + return &CreateLogTargetPeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target peer bad request response +func (o *CreateLogTargetPeerBadRequest) WithConfigurationVersion(configurationVersion string) *CreateLogTargetPeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target peer bad request response +func (o *CreateLogTargetPeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target peer bad request response +func (o *CreateLogTargetPeerBadRequest) WithPayload(payload *models.Error) *CreateLogTargetPeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target peer bad request response +func (o *CreateLogTargetPeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetPeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateLogTargetPeerConflictCode is the HTTP code returned for type CreateLogTargetPeerConflict +const CreateLogTargetPeerConflictCode int = 409 + +/* +CreateLogTargetPeerConflict The specified resource already exists + +swagger:response createLogTargetPeerConflict +*/ +type CreateLogTargetPeerConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetPeerConflict creates CreateLogTargetPeerConflict with default headers values +func NewCreateLogTargetPeerConflict() *CreateLogTargetPeerConflict { + + return &CreateLogTargetPeerConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create log target peer conflict response +func (o *CreateLogTargetPeerConflict) WithConfigurationVersion(configurationVersion string) *CreateLogTargetPeerConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target peer conflict response +func (o *CreateLogTargetPeerConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target peer conflict response +func (o *CreateLogTargetPeerConflict) WithPayload(payload *models.Error) *CreateLogTargetPeerConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target peer conflict response +func (o *CreateLogTargetPeerConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetPeerConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateLogTargetPeerDefault General Error + +swagger:response createLogTargetPeerDefault +*/ +type CreateLogTargetPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateLogTargetPeerDefault creates CreateLogTargetPeerDefault with default headers values +func NewCreateLogTargetPeerDefault(code int) *CreateLogTargetPeerDefault { + if code <= 0 { + code = 500 + } + + return &CreateLogTargetPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create log target peer default response +func (o *CreateLogTargetPeerDefault) WithStatusCode(code int) *CreateLogTargetPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create log target peer default response +func (o *CreateLogTargetPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create log target peer default response +func (o *CreateLogTargetPeerDefault) WithConfigurationVersion(configurationVersion string) *CreateLogTargetPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create log target peer default response +func (o *CreateLogTargetPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create log target peer default response +func (o *CreateLogTargetPeerDefault) WithPayload(payload *models.Error) *CreateLogTargetPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create log target peer default response +func (o *CreateLogTargetPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateLogTargetPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/create_log_target_peer_urlbuilder.go b/operations/log_target/create_log_target_peer_urlbuilder.go new file mode 100644 index 00000000..e3c99ecd --- /dev/null +++ b/operations/log_target/create_log_target_peer_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateLogTargetPeerURL generates an URL for the create log target peer operation +type CreateLogTargetPeerURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetPeerURL) WithBasePath(bp string) *CreateLogTargetPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateLogTargetPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateLogTargetPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateLogTargetPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateLogTargetPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateLogTargetPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateLogTargetPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateLogTargetPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateLogTargetPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateLogTargetPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateLogTargetPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/create_log_target_responses.go b/operations/log_target/create_log_target_responses.go deleted file mode 100644 index ff460e96..00000000 --- a/operations/log_target/create_log_target_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateLogTargetCreatedCode is the HTTP code returned for type CreateLogTargetCreated -const CreateLogTargetCreatedCode int = 201 - -/*CreateLogTargetCreated Log Target created - -swagger:response createLogTargetCreated -*/ -type CreateLogTargetCreated struct { - - /* - In: Body - */ - Payload *models.LogTarget `json:"body,omitempty"` -} - -// NewCreateLogTargetCreated creates CreateLogTargetCreated with default headers values -func NewCreateLogTargetCreated() *CreateLogTargetCreated { - - return &CreateLogTargetCreated{} -} - -// WithPayload adds the payload to the create log target created response -func (o *CreateLogTargetCreated) WithPayload(payload *models.LogTarget) *CreateLogTargetCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create log target created response -func (o *CreateLogTargetCreated) SetPayload(payload *models.LogTarget) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateLogTargetCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateLogTargetAcceptedCode is the HTTP code returned for type CreateLogTargetAccepted -const CreateLogTargetAcceptedCode int = 202 - -/*CreateLogTargetAccepted Configuration change accepted and reload requested - -swagger:response createLogTargetAccepted -*/ -type CreateLogTargetAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.LogTarget `json:"body,omitempty"` -} - -// NewCreateLogTargetAccepted creates CreateLogTargetAccepted with default headers values -func NewCreateLogTargetAccepted() *CreateLogTargetAccepted { - - return &CreateLogTargetAccepted{} -} - -// WithReloadID adds the reloadId to the create log target accepted response -func (o *CreateLogTargetAccepted) WithReloadID(reloadID string) *CreateLogTargetAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create log target accepted response -func (o *CreateLogTargetAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create log target accepted response -func (o *CreateLogTargetAccepted) WithPayload(payload *models.LogTarget) *CreateLogTargetAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create log target accepted response -func (o *CreateLogTargetAccepted) SetPayload(payload *models.LogTarget) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateLogTargetAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateLogTargetBadRequestCode is the HTTP code returned for type CreateLogTargetBadRequest -const CreateLogTargetBadRequestCode int = 400 - -/*CreateLogTargetBadRequest Bad request - -swagger:response createLogTargetBadRequest -*/ -type CreateLogTargetBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateLogTargetBadRequest creates CreateLogTargetBadRequest with default headers values -func NewCreateLogTargetBadRequest() *CreateLogTargetBadRequest { - - return &CreateLogTargetBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create log target bad request response -func (o *CreateLogTargetBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateLogTargetBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create log target bad request response -func (o *CreateLogTargetBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create log target bad request response -func (o *CreateLogTargetBadRequest) WithPayload(payload *models.Error) *CreateLogTargetBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create log target bad request response -func (o *CreateLogTargetBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateLogTargetBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateLogTargetConflictCode is the HTTP code returned for type CreateLogTargetConflict -const CreateLogTargetConflictCode int = 409 - -/*CreateLogTargetConflict The specified resource already exists - -swagger:response createLogTargetConflict -*/ -type CreateLogTargetConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateLogTargetConflict creates CreateLogTargetConflict with default headers values -func NewCreateLogTargetConflict() *CreateLogTargetConflict { - - return &CreateLogTargetConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create log target conflict response -func (o *CreateLogTargetConflict) WithConfigurationVersion(configurationVersion int64) *CreateLogTargetConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create log target conflict response -func (o *CreateLogTargetConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create log target conflict response -func (o *CreateLogTargetConflict) WithPayload(payload *models.Error) *CreateLogTargetConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create log target conflict response -func (o *CreateLogTargetConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateLogTargetConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateLogTargetDefault General Error - -swagger:response createLogTargetDefault -*/ -type CreateLogTargetDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateLogTargetDefault creates CreateLogTargetDefault with default headers values -func NewCreateLogTargetDefault(code int) *CreateLogTargetDefault { - if code <= 0 { - code = 500 - } - - return &CreateLogTargetDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create log target default response -func (o *CreateLogTargetDefault) WithStatusCode(code int) *CreateLogTargetDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create log target default response -func (o *CreateLogTargetDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create log target default response -func (o *CreateLogTargetDefault) WithConfigurationVersion(configurationVersion int64) *CreateLogTargetDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create log target default response -func (o *CreateLogTargetDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create log target default response -func (o *CreateLogTargetDefault) WithPayload(payload *models.Error) *CreateLogTargetDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create log target default response -func (o *CreateLogTargetDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateLogTargetDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/log_target/create_log_target_urlbuilder.go b/operations/log_target/create_log_target_urlbuilder.go deleted file mode 100644 index 0e316db5..00000000 --- a/operations/log_target/create_log_target_urlbuilder.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateLogTargetURL generates an URL for the create log target operation -type CreateLogTargetURL struct { - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateLogTargetURL) WithBasePath(bp string) *CreateLogTargetURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateLogTargetURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateLogTargetURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/log_targets" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateLogTargetURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateLogTargetURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateLogTargetURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateLogTargetURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateLogTargetURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateLogTargetURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/log_target/delete_log_target.go b/operations/log_target/delete_log_target.go deleted file mode 100644 index a71abf68..00000000 --- a/operations/log_target/delete_log_target.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteLogTargetHandlerFunc turns a function with the right signature into a delete log target handler -type DeleteLogTargetHandlerFunc func(DeleteLogTargetParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteLogTargetHandlerFunc) Handle(params DeleteLogTargetParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteLogTargetHandler interface for that can handle valid delete log target params -type DeleteLogTargetHandler interface { - Handle(DeleteLogTargetParams, interface{}) middleware.Responder -} - -// NewDeleteLogTarget creates a new http.Handler for the delete log target operation -func NewDeleteLogTarget(ctx *middleware.Context, handler DeleteLogTargetHandler) *DeleteLogTarget { - return &DeleteLogTarget{Context: ctx, Handler: handler} -} - -/*DeleteLogTarget swagger:route DELETE /services/haproxy/configuration/log_targets/{id} LogTarget deleteLogTarget - -Delete a Log Target - -Deletes a Log Target configuration by it's ID from the specified parent. - -*/ -type DeleteLogTarget struct { - Context *middleware.Context - Handler DeleteLogTargetHandler -} - -func (o *DeleteLogTarget) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteLogTargetParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/log_target/delete_log_target_backend.go b/operations/log_target/delete_log_target_backend.go new file mode 100644 index 00000000..6d590da0 --- /dev/null +++ b/operations/log_target/delete_log_target_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogTargetBackendHandlerFunc turns a function with the right signature into a delete log target backend handler +type DeleteLogTargetBackendHandlerFunc func(DeleteLogTargetBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogTargetBackendHandlerFunc) Handle(params DeleteLogTargetBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogTargetBackendHandler interface for that can handle valid delete log target backend params +type DeleteLogTargetBackendHandler interface { + Handle(DeleteLogTargetBackendParams, interface{}) middleware.Responder +} + +// NewDeleteLogTargetBackend creates a new http.Handler for the delete log target backend operation +func NewDeleteLogTargetBackend(ctx *middleware.Context, handler DeleteLogTargetBackendHandler) *DeleteLogTargetBackend { + return &DeleteLogTargetBackend{Context: ctx, Handler: handler} +} + +/* + DeleteLogTargetBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/log_targets/{index} LogTarget deleteLogTargetBackend + +# Delete a Log Target + +Deletes a Log Target configuration by it's index from the specified parent. +*/ +type DeleteLogTargetBackend struct { + Context *middleware.Context + Handler DeleteLogTargetBackendHandler +} + +func (o *DeleteLogTargetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogTargetBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/delete_log_target_backend_parameters.go b/operations/log_target/delete_log_target_backend_parameters.go new file mode 100644 index 00000000..332c7854 --- /dev/null +++ b/operations/log_target/delete_log_target_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogTargetBackendParams creates a new DeleteLogTargetBackendParams object +// with the default values initialized. +func NewDeleteLogTargetBackendParams() DeleteLogTargetBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogTargetBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogTargetBackendParams contains all the bound params for the delete log target backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogTargetBackend +type DeleteLogTargetBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogTargetBackendParams() beforehand. +func (o *DeleteLogTargetBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogTargetBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogTargetBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteLogTargetBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteLogTargetBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogTargetBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogTargetBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/delete_log_target_backend_responses.go b/operations/log_target/delete_log_target_backend_responses.go new file mode 100644 index 00000000..f0b91fb9 --- /dev/null +++ b/operations/log_target/delete_log_target_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogTargetBackendAcceptedCode is the HTTP code returned for type DeleteLogTargetBackendAccepted +const DeleteLogTargetBackendAcceptedCode int = 202 + +/* +DeleteLogTargetBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteLogTargetBackendAccepted +*/ +type DeleteLogTargetBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogTargetBackendAccepted creates DeleteLogTargetBackendAccepted with default headers values +func NewDeleteLogTargetBackendAccepted() *DeleteLogTargetBackendAccepted { + + return &DeleteLogTargetBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete log target backend accepted response +func (o *DeleteLogTargetBackendAccepted) WithReloadID(reloadID string) *DeleteLogTargetBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log target backend accepted response +func (o *DeleteLogTargetBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogTargetBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogTargetBackendNoContentCode is the HTTP code returned for type DeleteLogTargetBackendNoContent +const DeleteLogTargetBackendNoContentCode int = 204 + +/* +DeleteLogTargetBackendNoContent Log Target deleted + +swagger:response deleteLogTargetBackendNoContent +*/ +type DeleteLogTargetBackendNoContent struct { +} + +// NewDeleteLogTargetBackendNoContent creates DeleteLogTargetBackendNoContent with default headers values +func NewDeleteLogTargetBackendNoContent() *DeleteLogTargetBackendNoContent { + + return &DeleteLogTargetBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogTargetBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogTargetBackendNotFoundCode is the HTTP code returned for type DeleteLogTargetBackendNotFound +const DeleteLogTargetBackendNotFoundCode int = 404 + +/* +DeleteLogTargetBackendNotFound The specified resource was not found + +swagger:response deleteLogTargetBackendNotFound +*/ +type DeleteLogTargetBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetBackendNotFound creates DeleteLogTargetBackendNotFound with default headers values +func NewDeleteLogTargetBackendNotFound() *DeleteLogTargetBackendNotFound { + + return &DeleteLogTargetBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target backend not found response +func (o *DeleteLogTargetBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target backend not found response +func (o *DeleteLogTargetBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target backend not found response +func (o *DeleteLogTargetBackendNotFound) WithPayload(payload *models.Error) *DeleteLogTargetBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target backend not found response +func (o *DeleteLogTargetBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogTargetBackendDefault General Error + +swagger:response deleteLogTargetBackendDefault +*/ +type DeleteLogTargetBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetBackendDefault creates DeleteLogTargetBackendDefault with default headers values +func NewDeleteLogTargetBackendDefault(code int) *DeleteLogTargetBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogTargetBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log target backend default response +func (o *DeleteLogTargetBackendDefault) WithStatusCode(code int) *DeleteLogTargetBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log target backend default response +func (o *DeleteLogTargetBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target backend default response +func (o *DeleteLogTargetBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target backend default response +func (o *DeleteLogTargetBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target backend default response +func (o *DeleteLogTargetBackendDefault) WithPayload(payload *models.Error) *DeleteLogTargetBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target backend default response +func (o *DeleteLogTargetBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/delete_log_target_backend_urlbuilder.go b/operations/log_target/delete_log_target_backend_urlbuilder.go new file mode 100644 index 00000000..2c68de25 --- /dev/null +++ b/operations/log_target/delete_log_target_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogTargetBackendURL generates an URL for the delete log target backend operation +type DeleteLogTargetBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetBackendURL) WithBasePath(bp string) *DeleteLogTargetBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogTargetBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteLogTargetBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteLogTargetBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogTargetBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogTargetBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogTargetBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogTargetBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogTargetBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogTargetBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/delete_log_target_defaults.go b/operations/log_target/delete_log_target_defaults.go new file mode 100644 index 00000000..269db9da --- /dev/null +++ b/operations/log_target/delete_log_target_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogTargetDefaultsHandlerFunc turns a function with the right signature into a delete log target defaults handler +type DeleteLogTargetDefaultsHandlerFunc func(DeleteLogTargetDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogTargetDefaultsHandlerFunc) Handle(params DeleteLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogTargetDefaultsHandler interface for that can handle valid delete log target defaults params +type DeleteLogTargetDefaultsHandler interface { + Handle(DeleteLogTargetDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteLogTargetDefaults creates a new http.Handler for the delete log target defaults operation +func NewDeleteLogTargetDefaults(ctx *middleware.Context, handler DeleteLogTargetDefaultsHandler) *DeleteLogTargetDefaults { + return &DeleteLogTargetDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteLogTargetDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/log_targets/{index} LogTarget deleteLogTargetDefaults + +# Delete a Log Target + +Deletes a Log Target configuration by it's index from the specified parent. +*/ +type DeleteLogTargetDefaults struct { + Context *middleware.Context + Handler DeleteLogTargetDefaultsHandler +} + +func (o *DeleteLogTargetDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogTargetDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/delete_log_target_defaults_parameters.go b/operations/log_target/delete_log_target_defaults_parameters.go new file mode 100644 index 00000000..f15f4784 --- /dev/null +++ b/operations/log_target/delete_log_target_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogTargetDefaultsParams creates a new DeleteLogTargetDefaultsParams object +// with the default values initialized. +func NewDeleteLogTargetDefaultsParams() DeleteLogTargetDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogTargetDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogTargetDefaultsParams contains all the bound params for the delete log target defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogTargetDefaults +type DeleteLogTargetDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogTargetDefaultsParams() beforehand. +func (o *DeleteLogTargetDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogTargetDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogTargetDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteLogTargetDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteLogTargetDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogTargetDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogTargetDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/delete_log_target_defaults_responses.go b/operations/log_target/delete_log_target_defaults_responses.go new file mode 100644 index 00000000..0a381d3d --- /dev/null +++ b/operations/log_target/delete_log_target_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogTargetDefaultsAcceptedCode is the HTTP code returned for type DeleteLogTargetDefaultsAccepted +const DeleteLogTargetDefaultsAcceptedCode int = 202 + +/* +DeleteLogTargetDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteLogTargetDefaultsAccepted +*/ +type DeleteLogTargetDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogTargetDefaultsAccepted creates DeleteLogTargetDefaultsAccepted with default headers values +func NewDeleteLogTargetDefaultsAccepted() *DeleteLogTargetDefaultsAccepted { + + return &DeleteLogTargetDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete log target defaults accepted response +func (o *DeleteLogTargetDefaultsAccepted) WithReloadID(reloadID string) *DeleteLogTargetDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log target defaults accepted response +func (o *DeleteLogTargetDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogTargetDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogTargetDefaultsNoContentCode is the HTTP code returned for type DeleteLogTargetDefaultsNoContent +const DeleteLogTargetDefaultsNoContentCode int = 204 + +/* +DeleteLogTargetDefaultsNoContent Log Target deleted + +swagger:response deleteLogTargetDefaultsNoContent +*/ +type DeleteLogTargetDefaultsNoContent struct { +} + +// NewDeleteLogTargetDefaultsNoContent creates DeleteLogTargetDefaultsNoContent with default headers values +func NewDeleteLogTargetDefaultsNoContent() *DeleteLogTargetDefaultsNoContent { + + return &DeleteLogTargetDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogTargetDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogTargetDefaultsNotFoundCode is the HTTP code returned for type DeleteLogTargetDefaultsNotFound +const DeleteLogTargetDefaultsNotFoundCode int = 404 + +/* +DeleteLogTargetDefaultsNotFound The specified resource was not found + +swagger:response deleteLogTargetDefaultsNotFound +*/ +type DeleteLogTargetDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetDefaultsNotFound creates DeleteLogTargetDefaultsNotFound with default headers values +func NewDeleteLogTargetDefaultsNotFound() *DeleteLogTargetDefaultsNotFound { + + return &DeleteLogTargetDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target defaults not found response +func (o *DeleteLogTargetDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target defaults not found response +func (o *DeleteLogTargetDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target defaults not found response +func (o *DeleteLogTargetDefaultsNotFound) WithPayload(payload *models.Error) *DeleteLogTargetDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target defaults not found response +func (o *DeleteLogTargetDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogTargetDefaultsDefault General Error + +swagger:response deleteLogTargetDefaultsDefault +*/ +type DeleteLogTargetDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetDefaultsDefault creates DeleteLogTargetDefaultsDefault with default headers values +func NewDeleteLogTargetDefaultsDefault(code int) *DeleteLogTargetDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogTargetDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log target defaults default response +func (o *DeleteLogTargetDefaultsDefault) WithStatusCode(code int) *DeleteLogTargetDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log target defaults default response +func (o *DeleteLogTargetDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target defaults default response +func (o *DeleteLogTargetDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target defaults default response +func (o *DeleteLogTargetDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target defaults default response +func (o *DeleteLogTargetDefaultsDefault) WithPayload(payload *models.Error) *DeleteLogTargetDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target defaults default response +func (o *DeleteLogTargetDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/delete_log_target_defaults_urlbuilder.go b/operations/log_target/delete_log_target_defaults_urlbuilder.go new file mode 100644 index 00000000..c549f589 --- /dev/null +++ b/operations/log_target/delete_log_target_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogTargetDefaultsURL generates an URL for the delete log target defaults operation +type DeleteLogTargetDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetDefaultsURL) WithBasePath(bp string) *DeleteLogTargetDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogTargetDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteLogTargetDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteLogTargetDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogTargetDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogTargetDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogTargetDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogTargetDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogTargetDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogTargetDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/delete_log_target_frontend.go b/operations/log_target/delete_log_target_frontend.go new file mode 100644 index 00000000..6520cc95 --- /dev/null +++ b/operations/log_target/delete_log_target_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogTargetFrontendHandlerFunc turns a function with the right signature into a delete log target frontend handler +type DeleteLogTargetFrontendHandlerFunc func(DeleteLogTargetFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogTargetFrontendHandlerFunc) Handle(params DeleteLogTargetFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogTargetFrontendHandler interface for that can handle valid delete log target frontend params +type DeleteLogTargetFrontendHandler interface { + Handle(DeleteLogTargetFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteLogTargetFrontend creates a new http.Handler for the delete log target frontend operation +func NewDeleteLogTargetFrontend(ctx *middleware.Context, handler DeleteLogTargetFrontendHandler) *DeleteLogTargetFrontend { + return &DeleteLogTargetFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteLogTargetFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/log_targets/{index} LogTarget deleteLogTargetFrontend + +# Delete a Log Target + +Deletes a Log Target configuration by it's index from the specified parent. +*/ +type DeleteLogTargetFrontend struct { + Context *middleware.Context + Handler DeleteLogTargetFrontendHandler +} + +func (o *DeleteLogTargetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogTargetFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/delete_log_target_frontend_parameters.go b/operations/log_target/delete_log_target_frontend_parameters.go new file mode 100644 index 00000000..3e346055 --- /dev/null +++ b/operations/log_target/delete_log_target_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogTargetFrontendParams creates a new DeleteLogTargetFrontendParams object +// with the default values initialized. +func NewDeleteLogTargetFrontendParams() DeleteLogTargetFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogTargetFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogTargetFrontendParams contains all the bound params for the delete log target frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogTargetFrontend +type DeleteLogTargetFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogTargetFrontendParams() beforehand. +func (o *DeleteLogTargetFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogTargetFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogTargetFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteLogTargetFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteLogTargetFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogTargetFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogTargetFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/delete_log_target_frontend_responses.go b/operations/log_target/delete_log_target_frontend_responses.go new file mode 100644 index 00000000..8eb2c0b7 --- /dev/null +++ b/operations/log_target/delete_log_target_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogTargetFrontendAcceptedCode is the HTTP code returned for type DeleteLogTargetFrontendAccepted +const DeleteLogTargetFrontendAcceptedCode int = 202 + +/* +DeleteLogTargetFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteLogTargetFrontendAccepted +*/ +type DeleteLogTargetFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogTargetFrontendAccepted creates DeleteLogTargetFrontendAccepted with default headers values +func NewDeleteLogTargetFrontendAccepted() *DeleteLogTargetFrontendAccepted { + + return &DeleteLogTargetFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete log target frontend accepted response +func (o *DeleteLogTargetFrontendAccepted) WithReloadID(reloadID string) *DeleteLogTargetFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log target frontend accepted response +func (o *DeleteLogTargetFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogTargetFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogTargetFrontendNoContentCode is the HTTP code returned for type DeleteLogTargetFrontendNoContent +const DeleteLogTargetFrontendNoContentCode int = 204 + +/* +DeleteLogTargetFrontendNoContent Log Target deleted + +swagger:response deleteLogTargetFrontendNoContent +*/ +type DeleteLogTargetFrontendNoContent struct { +} + +// NewDeleteLogTargetFrontendNoContent creates DeleteLogTargetFrontendNoContent with default headers values +func NewDeleteLogTargetFrontendNoContent() *DeleteLogTargetFrontendNoContent { + + return &DeleteLogTargetFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogTargetFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogTargetFrontendNotFoundCode is the HTTP code returned for type DeleteLogTargetFrontendNotFound +const DeleteLogTargetFrontendNotFoundCode int = 404 + +/* +DeleteLogTargetFrontendNotFound The specified resource was not found + +swagger:response deleteLogTargetFrontendNotFound +*/ +type DeleteLogTargetFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetFrontendNotFound creates DeleteLogTargetFrontendNotFound with default headers values +func NewDeleteLogTargetFrontendNotFound() *DeleteLogTargetFrontendNotFound { + + return &DeleteLogTargetFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target frontend not found response +func (o *DeleteLogTargetFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target frontend not found response +func (o *DeleteLogTargetFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target frontend not found response +func (o *DeleteLogTargetFrontendNotFound) WithPayload(payload *models.Error) *DeleteLogTargetFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target frontend not found response +func (o *DeleteLogTargetFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogTargetFrontendDefault General Error + +swagger:response deleteLogTargetFrontendDefault +*/ +type DeleteLogTargetFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetFrontendDefault creates DeleteLogTargetFrontendDefault with default headers values +func NewDeleteLogTargetFrontendDefault(code int) *DeleteLogTargetFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogTargetFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log target frontend default response +func (o *DeleteLogTargetFrontendDefault) WithStatusCode(code int) *DeleteLogTargetFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log target frontend default response +func (o *DeleteLogTargetFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target frontend default response +func (o *DeleteLogTargetFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target frontend default response +func (o *DeleteLogTargetFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target frontend default response +func (o *DeleteLogTargetFrontendDefault) WithPayload(payload *models.Error) *DeleteLogTargetFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target frontend default response +func (o *DeleteLogTargetFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/delete_log_target_frontend_urlbuilder.go b/operations/log_target/delete_log_target_frontend_urlbuilder.go new file mode 100644 index 00000000..7c93b4cf --- /dev/null +++ b/operations/log_target/delete_log_target_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogTargetFrontendURL generates an URL for the delete log target frontend operation +type DeleteLogTargetFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetFrontendURL) WithBasePath(bp string) *DeleteLogTargetFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogTargetFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteLogTargetFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteLogTargetFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogTargetFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogTargetFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogTargetFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogTargetFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogTargetFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogTargetFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/delete_log_target_global.go b/operations/log_target/delete_log_target_global.go new file mode 100644 index 00000000..ae28120b --- /dev/null +++ b/operations/log_target/delete_log_target_global.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogTargetGlobalHandlerFunc turns a function with the right signature into a delete log target global handler +type DeleteLogTargetGlobalHandlerFunc func(DeleteLogTargetGlobalParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogTargetGlobalHandlerFunc) Handle(params DeleteLogTargetGlobalParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogTargetGlobalHandler interface for that can handle valid delete log target global params +type DeleteLogTargetGlobalHandler interface { + Handle(DeleteLogTargetGlobalParams, interface{}) middleware.Responder +} + +// NewDeleteLogTargetGlobal creates a new http.Handler for the delete log target global operation +func NewDeleteLogTargetGlobal(ctx *middleware.Context, handler DeleteLogTargetGlobalHandler) *DeleteLogTargetGlobal { + return &DeleteLogTargetGlobal{Context: ctx, Handler: handler} +} + +/* + DeleteLogTargetGlobal swagger:route DELETE /services/haproxy/configuration/global/log_targets/{index} LogTarget deleteLogTargetGlobal + +# Delete a Log Target + +Deletes a Log Target configuration by it's index from the specified parent. +*/ +type DeleteLogTargetGlobal struct { + Context *middleware.Context + Handler DeleteLogTargetGlobalHandler +} + +func (o *DeleteLogTargetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogTargetGlobalParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/delete_log_target_global_parameters.go b/operations/log_target/delete_log_target_global_parameters.go new file mode 100644 index 00000000..76f390f4 --- /dev/null +++ b/operations/log_target/delete_log_target_global_parameters.go @@ -0,0 +1,195 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogTargetGlobalParams creates a new DeleteLogTargetGlobalParams object +// with the default values initialized. +func NewDeleteLogTargetGlobalParams() DeleteLogTargetGlobalParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogTargetGlobalParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogTargetGlobalParams contains all the bound params for the delete log target global operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogTargetGlobal +type DeleteLogTargetGlobalParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogTargetGlobalParams() beforehand. +func (o *DeleteLogTargetGlobalParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogTargetGlobalParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogTargetGlobalParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteLogTargetGlobalParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogTargetGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogTargetGlobalParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/delete_log_target_global_responses.go b/operations/log_target/delete_log_target_global_responses.go new file mode 100644 index 00000000..e5b62d59 --- /dev/null +++ b/operations/log_target/delete_log_target_global_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogTargetGlobalAcceptedCode is the HTTP code returned for type DeleteLogTargetGlobalAccepted +const DeleteLogTargetGlobalAcceptedCode int = 202 + +/* +DeleteLogTargetGlobalAccepted Configuration change accepted and reload requested + +swagger:response deleteLogTargetGlobalAccepted +*/ +type DeleteLogTargetGlobalAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogTargetGlobalAccepted creates DeleteLogTargetGlobalAccepted with default headers values +func NewDeleteLogTargetGlobalAccepted() *DeleteLogTargetGlobalAccepted { + + return &DeleteLogTargetGlobalAccepted{} +} + +// WithReloadID adds the reloadId to the delete log target global accepted response +func (o *DeleteLogTargetGlobalAccepted) WithReloadID(reloadID string) *DeleteLogTargetGlobalAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log target global accepted response +func (o *DeleteLogTargetGlobalAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogTargetGlobalAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogTargetGlobalNoContentCode is the HTTP code returned for type DeleteLogTargetGlobalNoContent +const DeleteLogTargetGlobalNoContentCode int = 204 + +/* +DeleteLogTargetGlobalNoContent Log Target deleted + +swagger:response deleteLogTargetGlobalNoContent +*/ +type DeleteLogTargetGlobalNoContent struct { +} + +// NewDeleteLogTargetGlobalNoContent creates DeleteLogTargetGlobalNoContent with default headers values +func NewDeleteLogTargetGlobalNoContent() *DeleteLogTargetGlobalNoContent { + + return &DeleteLogTargetGlobalNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogTargetGlobalNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogTargetGlobalNotFoundCode is the HTTP code returned for type DeleteLogTargetGlobalNotFound +const DeleteLogTargetGlobalNotFoundCode int = 404 + +/* +DeleteLogTargetGlobalNotFound The specified resource was not found + +swagger:response deleteLogTargetGlobalNotFound +*/ +type DeleteLogTargetGlobalNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetGlobalNotFound creates DeleteLogTargetGlobalNotFound with default headers values +func NewDeleteLogTargetGlobalNotFound() *DeleteLogTargetGlobalNotFound { + + return &DeleteLogTargetGlobalNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target global not found response +func (o *DeleteLogTargetGlobalNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetGlobalNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target global not found response +func (o *DeleteLogTargetGlobalNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target global not found response +func (o *DeleteLogTargetGlobalNotFound) WithPayload(payload *models.Error) *DeleteLogTargetGlobalNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target global not found response +func (o *DeleteLogTargetGlobalNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetGlobalNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogTargetGlobalDefault General Error + +swagger:response deleteLogTargetGlobalDefault +*/ +type DeleteLogTargetGlobalDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetGlobalDefault creates DeleteLogTargetGlobalDefault with default headers values +func NewDeleteLogTargetGlobalDefault(code int) *DeleteLogTargetGlobalDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogTargetGlobalDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log target global default response +func (o *DeleteLogTargetGlobalDefault) WithStatusCode(code int) *DeleteLogTargetGlobalDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log target global default response +func (o *DeleteLogTargetGlobalDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target global default response +func (o *DeleteLogTargetGlobalDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetGlobalDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target global default response +func (o *DeleteLogTargetGlobalDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target global default response +func (o *DeleteLogTargetGlobalDefault) WithPayload(payload *models.Error) *DeleteLogTargetGlobalDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target global default response +func (o *DeleteLogTargetGlobalDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetGlobalDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/delete_log_target_global_urlbuilder.go b/operations/log_target/delete_log_target_global_urlbuilder.go new file mode 100644 index 00000000..ecb9d960 --- /dev/null +++ b/operations/log_target/delete_log_target_global_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogTargetGlobalURL generates an URL for the delete log target global operation +type DeleteLogTargetGlobalURL struct { + Index int64 + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetGlobalURL) WithBasePath(bp string) *DeleteLogTargetGlobalURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetGlobalURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogTargetGlobalURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/global/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteLogTargetGlobalURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogTargetGlobalURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogTargetGlobalURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogTargetGlobalURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogTargetGlobalURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogTargetGlobalURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogTargetGlobalURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/delete_log_target_log_forward.go b/operations/log_target/delete_log_target_log_forward.go new file mode 100644 index 00000000..865c9c11 --- /dev/null +++ b/operations/log_target/delete_log_target_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogTargetLogForwardHandlerFunc turns a function with the right signature into a delete log target log forward handler +type DeleteLogTargetLogForwardHandlerFunc func(DeleteLogTargetLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogTargetLogForwardHandlerFunc) Handle(params DeleteLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogTargetLogForwardHandler interface for that can handle valid delete log target log forward params +type DeleteLogTargetLogForwardHandler interface { + Handle(DeleteLogTargetLogForwardParams, interface{}) middleware.Responder +} + +// NewDeleteLogTargetLogForward creates a new http.Handler for the delete log target log forward operation +func NewDeleteLogTargetLogForward(ctx *middleware.Context, handler DeleteLogTargetLogForwardHandler) *DeleteLogTargetLogForward { + return &DeleteLogTargetLogForward{Context: ctx, Handler: handler} +} + +/* + DeleteLogTargetLogForward swagger:route DELETE /services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index} LogTarget deleteLogTargetLogForward + +# Delete a Log Target + +Deletes a Log Target configuration by it's index from the specified parent. +*/ +type DeleteLogTargetLogForward struct { + Context *middleware.Context + Handler DeleteLogTargetLogForwardHandler +} + +func (o *DeleteLogTargetLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogTargetLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/delete_log_target_log_forward_parameters.go b/operations/log_target/delete_log_target_log_forward_parameters.go new file mode 100644 index 00000000..14118574 --- /dev/null +++ b/operations/log_target/delete_log_target_log_forward_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogTargetLogForwardParams creates a new DeleteLogTargetLogForwardParams object +// with the default values initialized. +func NewDeleteLogTargetLogForwardParams() DeleteLogTargetLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogTargetLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogTargetLogForwardParams contains all the bound params for the delete log target log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogTargetLogForward +type DeleteLogTargetLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogTargetLogForwardParams() beforehand. +func (o *DeleteLogTargetLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogTargetLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogTargetLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteLogTargetLogForwardParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteLogTargetLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogTargetLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogTargetLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/delete_log_target_log_forward_responses.go b/operations/log_target/delete_log_target_log_forward_responses.go new file mode 100644 index 00000000..73a6de01 --- /dev/null +++ b/operations/log_target/delete_log_target_log_forward_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogTargetLogForwardAcceptedCode is the HTTP code returned for type DeleteLogTargetLogForwardAccepted +const DeleteLogTargetLogForwardAcceptedCode int = 202 + +/* +DeleteLogTargetLogForwardAccepted Configuration change accepted and reload requested + +swagger:response deleteLogTargetLogForwardAccepted +*/ +type DeleteLogTargetLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogTargetLogForwardAccepted creates DeleteLogTargetLogForwardAccepted with default headers values +func NewDeleteLogTargetLogForwardAccepted() *DeleteLogTargetLogForwardAccepted { + + return &DeleteLogTargetLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the delete log target log forward accepted response +func (o *DeleteLogTargetLogForwardAccepted) WithReloadID(reloadID string) *DeleteLogTargetLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log target log forward accepted response +func (o *DeleteLogTargetLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogTargetLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogTargetLogForwardNoContentCode is the HTTP code returned for type DeleteLogTargetLogForwardNoContent +const DeleteLogTargetLogForwardNoContentCode int = 204 + +/* +DeleteLogTargetLogForwardNoContent Log Target deleted + +swagger:response deleteLogTargetLogForwardNoContent +*/ +type DeleteLogTargetLogForwardNoContent struct { +} + +// NewDeleteLogTargetLogForwardNoContent creates DeleteLogTargetLogForwardNoContent with default headers values +func NewDeleteLogTargetLogForwardNoContent() *DeleteLogTargetLogForwardNoContent { + + return &DeleteLogTargetLogForwardNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogTargetLogForwardNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogTargetLogForwardNotFoundCode is the HTTP code returned for type DeleteLogTargetLogForwardNotFound +const DeleteLogTargetLogForwardNotFoundCode int = 404 + +/* +DeleteLogTargetLogForwardNotFound The specified resource was not found + +swagger:response deleteLogTargetLogForwardNotFound +*/ +type DeleteLogTargetLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetLogForwardNotFound creates DeleteLogTargetLogForwardNotFound with default headers values +func NewDeleteLogTargetLogForwardNotFound() *DeleteLogTargetLogForwardNotFound { + + return &DeleteLogTargetLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target log forward not found response +func (o *DeleteLogTargetLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target log forward not found response +func (o *DeleteLogTargetLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target log forward not found response +func (o *DeleteLogTargetLogForwardNotFound) WithPayload(payload *models.Error) *DeleteLogTargetLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target log forward not found response +func (o *DeleteLogTargetLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogTargetLogForwardDefault General Error + +swagger:response deleteLogTargetLogForwardDefault +*/ +type DeleteLogTargetLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetLogForwardDefault creates DeleteLogTargetLogForwardDefault with default headers values +func NewDeleteLogTargetLogForwardDefault(code int) *DeleteLogTargetLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogTargetLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log target log forward default response +func (o *DeleteLogTargetLogForwardDefault) WithStatusCode(code int) *DeleteLogTargetLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log target log forward default response +func (o *DeleteLogTargetLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target log forward default response +func (o *DeleteLogTargetLogForwardDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target log forward default response +func (o *DeleteLogTargetLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target log forward default response +func (o *DeleteLogTargetLogForwardDefault) WithPayload(payload *models.Error) *DeleteLogTargetLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target log forward default response +func (o *DeleteLogTargetLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/delete_log_target_log_forward_urlbuilder.go b/operations/log_target/delete_log_target_log_forward_urlbuilder.go new file mode 100644 index 00000000..d7100bdf --- /dev/null +++ b/operations/log_target/delete_log_target_log_forward_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogTargetLogForwardURL generates an URL for the delete log target log forward operation +type DeleteLogTargetLogForwardURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetLogForwardURL) WithBasePath(bp string) *DeleteLogTargetLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogTargetLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteLogTargetLogForwardURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteLogTargetLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogTargetLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogTargetLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogTargetLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogTargetLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogTargetLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogTargetLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/delete_log_target_parameters.go b/operations/log_target/delete_log_target_parameters.go deleted file mode 100644 index 6be0bbe1..00000000 --- a/operations/log_target/delete_log_target_parameters.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteLogTargetParams creates a new DeleteLogTargetParams object -// with the default values initialized. -func NewDeleteLogTargetParams() DeleteLogTargetParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteLogTargetParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteLogTargetParams contains all the bound params for the delete log target operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteLogTarget -type DeleteLogTargetParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Log Target ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteLogTargetParams() beforehand. -func (o *DeleteLogTargetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteLogTargetParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteLogTargetParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *DeleteLogTargetParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *DeleteLogTargetParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *DeleteLogTargetParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *DeleteLogTargetParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteLogTargetParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteLogTargetParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/log_target/delete_log_target_peer.go b/operations/log_target/delete_log_target_peer.go new file mode 100644 index 00000000..c875b00e --- /dev/null +++ b/operations/log_target/delete_log_target_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteLogTargetPeerHandlerFunc turns a function with the right signature into a delete log target peer handler +type DeleteLogTargetPeerHandlerFunc func(DeleteLogTargetPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteLogTargetPeerHandlerFunc) Handle(params DeleteLogTargetPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteLogTargetPeerHandler interface for that can handle valid delete log target peer params +type DeleteLogTargetPeerHandler interface { + Handle(DeleteLogTargetPeerParams, interface{}) middleware.Responder +} + +// NewDeleteLogTargetPeer creates a new http.Handler for the delete log target peer operation +func NewDeleteLogTargetPeer(ctx *middleware.Context, handler DeleteLogTargetPeerHandler) *DeleteLogTargetPeer { + return &DeleteLogTargetPeer{Context: ctx, Handler: handler} +} + +/* + DeleteLogTargetPeer swagger:route DELETE /services/haproxy/configuration/peers/{parent_name}/log_targets/{index} LogTarget deleteLogTargetPeer + +# Delete a Log Target + +Deletes a Log Target configuration by it's index from the specified parent. +*/ +type DeleteLogTargetPeer struct { + Context *middleware.Context + Handler DeleteLogTargetPeerHandler +} + +func (o *DeleteLogTargetPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteLogTargetPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/delete_log_target_peer_parameters.go b/operations/log_target/delete_log_target_peer_parameters.go new file mode 100644 index 00000000..9d913948 --- /dev/null +++ b/operations/log_target/delete_log_target_peer_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteLogTargetPeerParams creates a new DeleteLogTargetPeerParams object +// with the default values initialized. +func NewDeleteLogTargetPeerParams() DeleteLogTargetPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteLogTargetPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteLogTargetPeerParams contains all the bound params for the delete log target peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteLogTargetPeer +type DeleteLogTargetPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteLogTargetPeerParams() beforehand. +func (o *DeleteLogTargetPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteLogTargetPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteLogTargetPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteLogTargetPeerParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteLogTargetPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteLogTargetPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteLogTargetPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/delete_log_target_peer_responses.go b/operations/log_target/delete_log_target_peer_responses.go new file mode 100644 index 00000000..c751fa1d --- /dev/null +++ b/operations/log_target/delete_log_target_peer_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteLogTargetPeerAcceptedCode is the HTTP code returned for type DeleteLogTargetPeerAccepted +const DeleteLogTargetPeerAcceptedCode int = 202 + +/* +DeleteLogTargetPeerAccepted Configuration change accepted and reload requested + +swagger:response deleteLogTargetPeerAccepted +*/ +type DeleteLogTargetPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteLogTargetPeerAccepted creates DeleteLogTargetPeerAccepted with default headers values +func NewDeleteLogTargetPeerAccepted() *DeleteLogTargetPeerAccepted { + + return &DeleteLogTargetPeerAccepted{} +} + +// WithReloadID adds the reloadId to the delete log target peer accepted response +func (o *DeleteLogTargetPeerAccepted) WithReloadID(reloadID string) *DeleteLogTargetPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete log target peer accepted response +func (o *DeleteLogTargetPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteLogTargetPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteLogTargetPeerNoContentCode is the HTTP code returned for type DeleteLogTargetPeerNoContent +const DeleteLogTargetPeerNoContentCode int = 204 + +/* +DeleteLogTargetPeerNoContent Log Target deleted + +swagger:response deleteLogTargetPeerNoContent +*/ +type DeleteLogTargetPeerNoContent struct { +} + +// NewDeleteLogTargetPeerNoContent creates DeleteLogTargetPeerNoContent with default headers values +func NewDeleteLogTargetPeerNoContent() *DeleteLogTargetPeerNoContent { + + return &DeleteLogTargetPeerNoContent{} +} + +// WriteResponse to the client +func (o *DeleteLogTargetPeerNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteLogTargetPeerNotFoundCode is the HTTP code returned for type DeleteLogTargetPeerNotFound +const DeleteLogTargetPeerNotFoundCode int = 404 + +/* +DeleteLogTargetPeerNotFound The specified resource was not found + +swagger:response deleteLogTargetPeerNotFound +*/ +type DeleteLogTargetPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetPeerNotFound creates DeleteLogTargetPeerNotFound with default headers values +func NewDeleteLogTargetPeerNotFound() *DeleteLogTargetPeerNotFound { + + return &DeleteLogTargetPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target peer not found response +func (o *DeleteLogTargetPeerNotFound) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target peer not found response +func (o *DeleteLogTargetPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target peer not found response +func (o *DeleteLogTargetPeerNotFound) WithPayload(payload *models.Error) *DeleteLogTargetPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target peer not found response +func (o *DeleteLogTargetPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteLogTargetPeerDefault General Error + +swagger:response deleteLogTargetPeerDefault +*/ +type DeleteLogTargetPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteLogTargetPeerDefault creates DeleteLogTargetPeerDefault with default headers values +func NewDeleteLogTargetPeerDefault(code int) *DeleteLogTargetPeerDefault { + if code <= 0 { + code = 500 + } + + return &DeleteLogTargetPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete log target peer default response +func (o *DeleteLogTargetPeerDefault) WithStatusCode(code int) *DeleteLogTargetPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete log target peer default response +func (o *DeleteLogTargetPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete log target peer default response +func (o *DeleteLogTargetPeerDefault) WithConfigurationVersion(configurationVersion string) *DeleteLogTargetPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete log target peer default response +func (o *DeleteLogTargetPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete log target peer default response +func (o *DeleteLogTargetPeerDefault) WithPayload(payload *models.Error) *DeleteLogTargetPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete log target peer default response +func (o *DeleteLogTargetPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteLogTargetPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/delete_log_target_peer_urlbuilder.go b/operations/log_target/delete_log_target_peer_urlbuilder.go new file mode 100644 index 00000000..773c6762 --- /dev/null +++ b/operations/log_target/delete_log_target_peer_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteLogTargetPeerURL generates an URL for the delete log target peer operation +type DeleteLogTargetPeerURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetPeerURL) WithBasePath(bp string) *DeleteLogTargetPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteLogTargetPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteLogTargetPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteLogTargetPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteLogTargetPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteLogTargetPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteLogTargetPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteLogTargetPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteLogTargetPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteLogTargetPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteLogTargetPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/delete_log_target_responses.go b/operations/log_target/delete_log_target_responses.go deleted file mode 100644 index aa33d5e3..00000000 --- a/operations/log_target/delete_log_target_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteLogTargetAcceptedCode is the HTTP code returned for type DeleteLogTargetAccepted -const DeleteLogTargetAcceptedCode int = 202 - -/*DeleteLogTargetAccepted Configuration change accepted and reload requested - -swagger:response deleteLogTargetAccepted -*/ -type DeleteLogTargetAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteLogTargetAccepted creates DeleteLogTargetAccepted with default headers values -func NewDeleteLogTargetAccepted() *DeleteLogTargetAccepted { - - return &DeleteLogTargetAccepted{} -} - -// WithReloadID adds the reloadId to the delete log target accepted response -func (o *DeleteLogTargetAccepted) WithReloadID(reloadID string) *DeleteLogTargetAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete log target accepted response -func (o *DeleteLogTargetAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteLogTargetAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteLogTargetNoContentCode is the HTTP code returned for type DeleteLogTargetNoContent -const DeleteLogTargetNoContentCode int = 204 - -/*DeleteLogTargetNoContent Log Target deleted - -swagger:response deleteLogTargetNoContent -*/ -type DeleteLogTargetNoContent struct { -} - -// NewDeleteLogTargetNoContent creates DeleteLogTargetNoContent with default headers values -func NewDeleteLogTargetNoContent() *DeleteLogTargetNoContent { - - return &DeleteLogTargetNoContent{} -} - -// WriteResponse to the client -func (o *DeleteLogTargetNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteLogTargetNotFoundCode is the HTTP code returned for type DeleteLogTargetNotFound -const DeleteLogTargetNotFoundCode int = 404 - -/*DeleteLogTargetNotFound The specified resource was not found - -swagger:response deleteLogTargetNotFound -*/ -type DeleteLogTargetNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteLogTargetNotFound creates DeleteLogTargetNotFound with default headers values -func NewDeleteLogTargetNotFound() *DeleteLogTargetNotFound { - - return &DeleteLogTargetNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete log target not found response -func (o *DeleteLogTargetNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteLogTargetNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete log target not found response -func (o *DeleteLogTargetNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete log target not found response -func (o *DeleteLogTargetNotFound) WithPayload(payload *models.Error) *DeleteLogTargetNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete log target not found response -func (o *DeleteLogTargetNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteLogTargetNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteLogTargetDefault General Error - -swagger:response deleteLogTargetDefault -*/ -type DeleteLogTargetDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteLogTargetDefault creates DeleteLogTargetDefault with default headers values -func NewDeleteLogTargetDefault(code int) *DeleteLogTargetDefault { - if code <= 0 { - code = 500 - } - - return &DeleteLogTargetDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete log target default response -func (o *DeleteLogTargetDefault) WithStatusCode(code int) *DeleteLogTargetDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete log target default response -func (o *DeleteLogTargetDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete log target default response -func (o *DeleteLogTargetDefault) WithConfigurationVersion(configurationVersion int64) *DeleteLogTargetDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete log target default response -func (o *DeleteLogTargetDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete log target default response -func (o *DeleteLogTargetDefault) WithPayload(payload *models.Error) *DeleteLogTargetDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete log target default response -func (o *DeleteLogTargetDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteLogTargetDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/log_target/delete_log_target_urlbuilder.go b/operations/log_target/delete_log_target_urlbuilder.go deleted file mode 100644 index 80ae06e6..00000000 --- a/operations/log_target/delete_log_target_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteLogTargetURL generates an URL for the delete log target operation -type DeleteLogTargetURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteLogTargetURL) WithBasePath(bp string) *DeleteLogTargetURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteLogTargetURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteLogTargetURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/log_targets/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on DeleteLogTargetURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteLogTargetURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteLogTargetURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteLogTargetURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteLogTargetURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteLogTargetURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteLogTargetURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/log_target/get_all_log_target_backend.go b/operations/log_target/get_all_log_target_backend.go new file mode 100644 index 00000000..fbc27bd3 --- /dev/null +++ b/operations/log_target/get_all_log_target_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllLogTargetBackendHandlerFunc turns a function with the right signature into a get all log target backend handler +type GetAllLogTargetBackendHandlerFunc func(GetAllLogTargetBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllLogTargetBackendHandlerFunc) Handle(params GetAllLogTargetBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllLogTargetBackendHandler interface for that can handle valid get all log target backend params +type GetAllLogTargetBackendHandler interface { + Handle(GetAllLogTargetBackendParams, interface{}) middleware.Responder +} + +// NewGetAllLogTargetBackend creates a new http.Handler for the get all log target backend operation +func NewGetAllLogTargetBackend(ctx *middleware.Context, handler GetAllLogTargetBackendHandler) *GetAllLogTargetBackend { + return &GetAllLogTargetBackend{Context: ctx, Handler: handler} +} + +/* + GetAllLogTargetBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/log_targets LogTarget getAllLogTargetBackend + +# Return an array of all Log Targets + +Returns all Log Targets that are configured in specified parent. +*/ +type GetAllLogTargetBackend struct { + Context *middleware.Context + Handler GetAllLogTargetBackendHandler +} + +func (o *GetAllLogTargetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllLogTargetBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_all_log_target_backend_parameters.go b/operations/log_target/get_all_log_target_backend_parameters.go new file mode 100644 index 00000000..b8a6f24c --- /dev/null +++ b/operations/log_target/get_all_log_target_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllLogTargetBackendParams creates a new GetAllLogTargetBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllLogTargetBackendParams() GetAllLogTargetBackendParams { + + return GetAllLogTargetBackendParams{} +} + +// GetAllLogTargetBackendParams contains all the bound params for the get all log target backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllLogTargetBackend +type GetAllLogTargetBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllLogTargetBackendParams() beforehand. +func (o *GetAllLogTargetBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllLogTargetBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllLogTargetBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_all_log_target_backend_responses.go b/operations/log_target/get_all_log_target_backend_responses.go new file mode 100644 index 00000000..115bc8a8 --- /dev/null +++ b/operations/log_target/get_all_log_target_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllLogTargetBackendOKCode is the HTTP code returned for type GetAllLogTargetBackendOK +const GetAllLogTargetBackendOKCode int = 200 + +/* +GetAllLogTargetBackendOK Successful operation + +swagger:response getAllLogTargetBackendOK +*/ +type GetAllLogTargetBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewGetAllLogTargetBackendOK creates GetAllLogTargetBackendOK with default headers values +func NewGetAllLogTargetBackendOK() *GetAllLogTargetBackendOK { + + return &GetAllLogTargetBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target backend o k response +func (o *GetAllLogTargetBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target backend o k response +func (o *GetAllLogTargetBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target backend o k response +func (o *GetAllLogTargetBackendOK) WithPayload(payload models.LogTargets) *GetAllLogTargetBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target backend o k response +func (o *GetAllLogTargetBackendOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllLogTargetBackendDefault General Error + +swagger:response getAllLogTargetBackendDefault +*/ +type GetAllLogTargetBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllLogTargetBackendDefault creates GetAllLogTargetBackendDefault with default headers values +func NewGetAllLogTargetBackendDefault(code int) *GetAllLogTargetBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllLogTargetBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all log target backend default response +func (o *GetAllLogTargetBackendDefault) WithStatusCode(code int) *GetAllLogTargetBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all log target backend default response +func (o *GetAllLogTargetBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target backend default response +func (o *GetAllLogTargetBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target backend default response +func (o *GetAllLogTargetBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target backend default response +func (o *GetAllLogTargetBackendDefault) WithPayload(payload *models.Error) *GetAllLogTargetBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target backend default response +func (o *GetAllLogTargetBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_all_log_target_backend_urlbuilder.go b/operations/log_target/get_all_log_target_backend_urlbuilder.go new file mode 100644 index 00000000..032cf317 --- /dev/null +++ b/operations/log_target/get_all_log_target_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllLogTargetBackendURL generates an URL for the get all log target backend operation +type GetAllLogTargetBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetBackendURL) WithBasePath(bp string) *GetAllLogTargetBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllLogTargetBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllLogTargetBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllLogTargetBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllLogTargetBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllLogTargetBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllLogTargetBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllLogTargetBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllLogTargetBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_all_log_target_defaults.go b/operations/log_target/get_all_log_target_defaults.go new file mode 100644 index 00000000..d213bb19 --- /dev/null +++ b/operations/log_target/get_all_log_target_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllLogTargetDefaultsHandlerFunc turns a function with the right signature into a get all log target defaults handler +type GetAllLogTargetDefaultsHandlerFunc func(GetAllLogTargetDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllLogTargetDefaultsHandlerFunc) Handle(params GetAllLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllLogTargetDefaultsHandler interface for that can handle valid get all log target defaults params +type GetAllLogTargetDefaultsHandler interface { + Handle(GetAllLogTargetDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllLogTargetDefaults creates a new http.Handler for the get all log target defaults operation +func NewGetAllLogTargetDefaults(ctx *middleware.Context, handler GetAllLogTargetDefaultsHandler) *GetAllLogTargetDefaults { + return &GetAllLogTargetDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllLogTargetDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/log_targets LogTarget getAllLogTargetDefaults + +# Return an array of all Log Targets + +Returns all Log Targets that are configured in specified parent. +*/ +type GetAllLogTargetDefaults struct { + Context *middleware.Context + Handler GetAllLogTargetDefaultsHandler +} + +func (o *GetAllLogTargetDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllLogTargetDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_all_log_target_defaults_parameters.go b/operations/log_target/get_all_log_target_defaults_parameters.go new file mode 100644 index 00000000..393d187d --- /dev/null +++ b/operations/log_target/get_all_log_target_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllLogTargetDefaultsParams creates a new GetAllLogTargetDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllLogTargetDefaultsParams() GetAllLogTargetDefaultsParams { + + return GetAllLogTargetDefaultsParams{} +} + +// GetAllLogTargetDefaultsParams contains all the bound params for the get all log target defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllLogTargetDefaults +type GetAllLogTargetDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllLogTargetDefaultsParams() beforehand. +func (o *GetAllLogTargetDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllLogTargetDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllLogTargetDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_all_log_target_defaults_responses.go b/operations/log_target/get_all_log_target_defaults_responses.go new file mode 100644 index 00000000..0683d3d5 --- /dev/null +++ b/operations/log_target/get_all_log_target_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllLogTargetDefaultsOKCode is the HTTP code returned for type GetAllLogTargetDefaultsOK +const GetAllLogTargetDefaultsOKCode int = 200 + +/* +GetAllLogTargetDefaultsOK Successful operation + +swagger:response getAllLogTargetDefaultsOK +*/ +type GetAllLogTargetDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewGetAllLogTargetDefaultsOK creates GetAllLogTargetDefaultsOK with default headers values +func NewGetAllLogTargetDefaultsOK() *GetAllLogTargetDefaultsOK { + + return &GetAllLogTargetDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target defaults o k response +func (o *GetAllLogTargetDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target defaults o k response +func (o *GetAllLogTargetDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target defaults o k response +func (o *GetAllLogTargetDefaultsOK) WithPayload(payload models.LogTargets) *GetAllLogTargetDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target defaults o k response +func (o *GetAllLogTargetDefaultsOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllLogTargetDefaultsDefault General Error + +swagger:response getAllLogTargetDefaultsDefault +*/ +type GetAllLogTargetDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllLogTargetDefaultsDefault creates GetAllLogTargetDefaultsDefault with default headers values +func NewGetAllLogTargetDefaultsDefault(code int) *GetAllLogTargetDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllLogTargetDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all log target defaults default response +func (o *GetAllLogTargetDefaultsDefault) WithStatusCode(code int) *GetAllLogTargetDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all log target defaults default response +func (o *GetAllLogTargetDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target defaults default response +func (o *GetAllLogTargetDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target defaults default response +func (o *GetAllLogTargetDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target defaults default response +func (o *GetAllLogTargetDefaultsDefault) WithPayload(payload *models.Error) *GetAllLogTargetDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target defaults default response +func (o *GetAllLogTargetDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_all_log_target_defaults_urlbuilder.go b/operations/log_target/get_all_log_target_defaults_urlbuilder.go new file mode 100644 index 00000000..1625eabe --- /dev/null +++ b/operations/log_target/get_all_log_target_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllLogTargetDefaultsURL generates an URL for the get all log target defaults operation +type GetAllLogTargetDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetDefaultsURL) WithBasePath(bp string) *GetAllLogTargetDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllLogTargetDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllLogTargetDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllLogTargetDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllLogTargetDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllLogTargetDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllLogTargetDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllLogTargetDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllLogTargetDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_all_log_target_frontend.go b/operations/log_target/get_all_log_target_frontend.go new file mode 100644 index 00000000..50b0db9f --- /dev/null +++ b/operations/log_target/get_all_log_target_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllLogTargetFrontendHandlerFunc turns a function with the right signature into a get all log target frontend handler +type GetAllLogTargetFrontendHandlerFunc func(GetAllLogTargetFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllLogTargetFrontendHandlerFunc) Handle(params GetAllLogTargetFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllLogTargetFrontendHandler interface for that can handle valid get all log target frontend params +type GetAllLogTargetFrontendHandler interface { + Handle(GetAllLogTargetFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllLogTargetFrontend creates a new http.Handler for the get all log target frontend operation +func NewGetAllLogTargetFrontend(ctx *middleware.Context, handler GetAllLogTargetFrontendHandler) *GetAllLogTargetFrontend { + return &GetAllLogTargetFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllLogTargetFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/log_targets LogTarget getAllLogTargetFrontend + +# Return an array of all Log Targets + +Returns all Log Targets that are configured in specified parent. +*/ +type GetAllLogTargetFrontend struct { + Context *middleware.Context + Handler GetAllLogTargetFrontendHandler +} + +func (o *GetAllLogTargetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllLogTargetFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_all_log_target_frontend_parameters.go b/operations/log_target/get_all_log_target_frontend_parameters.go new file mode 100644 index 00000000..3707ca4e --- /dev/null +++ b/operations/log_target/get_all_log_target_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllLogTargetFrontendParams creates a new GetAllLogTargetFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllLogTargetFrontendParams() GetAllLogTargetFrontendParams { + + return GetAllLogTargetFrontendParams{} +} + +// GetAllLogTargetFrontendParams contains all the bound params for the get all log target frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllLogTargetFrontend +type GetAllLogTargetFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllLogTargetFrontendParams() beforehand. +func (o *GetAllLogTargetFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllLogTargetFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllLogTargetFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_all_log_target_frontend_responses.go b/operations/log_target/get_all_log_target_frontend_responses.go new file mode 100644 index 00000000..41fcd1a5 --- /dev/null +++ b/operations/log_target/get_all_log_target_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllLogTargetFrontendOKCode is the HTTP code returned for type GetAllLogTargetFrontendOK +const GetAllLogTargetFrontendOKCode int = 200 + +/* +GetAllLogTargetFrontendOK Successful operation + +swagger:response getAllLogTargetFrontendOK +*/ +type GetAllLogTargetFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewGetAllLogTargetFrontendOK creates GetAllLogTargetFrontendOK with default headers values +func NewGetAllLogTargetFrontendOK() *GetAllLogTargetFrontendOK { + + return &GetAllLogTargetFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target frontend o k response +func (o *GetAllLogTargetFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target frontend o k response +func (o *GetAllLogTargetFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target frontend o k response +func (o *GetAllLogTargetFrontendOK) WithPayload(payload models.LogTargets) *GetAllLogTargetFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target frontend o k response +func (o *GetAllLogTargetFrontendOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllLogTargetFrontendDefault General Error + +swagger:response getAllLogTargetFrontendDefault +*/ +type GetAllLogTargetFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllLogTargetFrontendDefault creates GetAllLogTargetFrontendDefault with default headers values +func NewGetAllLogTargetFrontendDefault(code int) *GetAllLogTargetFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllLogTargetFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all log target frontend default response +func (o *GetAllLogTargetFrontendDefault) WithStatusCode(code int) *GetAllLogTargetFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all log target frontend default response +func (o *GetAllLogTargetFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target frontend default response +func (o *GetAllLogTargetFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target frontend default response +func (o *GetAllLogTargetFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target frontend default response +func (o *GetAllLogTargetFrontendDefault) WithPayload(payload *models.Error) *GetAllLogTargetFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target frontend default response +func (o *GetAllLogTargetFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_all_log_target_frontend_urlbuilder.go b/operations/log_target/get_all_log_target_frontend_urlbuilder.go new file mode 100644 index 00000000..ff43e2bc --- /dev/null +++ b/operations/log_target/get_all_log_target_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllLogTargetFrontendURL generates an URL for the get all log target frontend operation +type GetAllLogTargetFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetFrontendURL) WithBasePath(bp string) *GetAllLogTargetFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllLogTargetFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllLogTargetFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllLogTargetFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllLogTargetFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllLogTargetFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllLogTargetFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllLogTargetFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllLogTargetFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_all_log_target_global.go b/operations/log_target/get_all_log_target_global.go new file mode 100644 index 00000000..9a404076 --- /dev/null +++ b/operations/log_target/get_all_log_target_global.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllLogTargetGlobalHandlerFunc turns a function with the right signature into a get all log target global handler +type GetAllLogTargetGlobalHandlerFunc func(GetAllLogTargetGlobalParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllLogTargetGlobalHandlerFunc) Handle(params GetAllLogTargetGlobalParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllLogTargetGlobalHandler interface for that can handle valid get all log target global params +type GetAllLogTargetGlobalHandler interface { + Handle(GetAllLogTargetGlobalParams, interface{}) middleware.Responder +} + +// NewGetAllLogTargetGlobal creates a new http.Handler for the get all log target global operation +func NewGetAllLogTargetGlobal(ctx *middleware.Context, handler GetAllLogTargetGlobalHandler) *GetAllLogTargetGlobal { + return &GetAllLogTargetGlobal{Context: ctx, Handler: handler} +} + +/* + GetAllLogTargetGlobal swagger:route GET /services/haproxy/configuration/global/log_targets LogTarget getAllLogTargetGlobal + +# Return an array of all Log Targets + +Returns all Log Targets that are configured in specified parent. +*/ +type GetAllLogTargetGlobal struct { + Context *middleware.Context + Handler GetAllLogTargetGlobalHandler +} + +func (o *GetAllLogTargetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllLogTargetGlobalParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_all_log_target_global_parameters.go b/operations/log_target/get_all_log_target_global_parameters.go new file mode 100644 index 00000000..61519c11 --- /dev/null +++ b/operations/log_target/get_all_log_target_global_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllLogTargetGlobalParams creates a new GetAllLogTargetGlobalParams object +// +// There are no default values defined in the spec. +func NewGetAllLogTargetGlobalParams() GetAllLogTargetGlobalParams { + + return GetAllLogTargetGlobalParams{} +} + +// GetAllLogTargetGlobalParams contains all the bound params for the get all log target global operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllLogTargetGlobal +type GetAllLogTargetGlobalParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllLogTargetGlobalParams() beforehand. +func (o *GetAllLogTargetGlobalParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllLogTargetGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_all_log_target_global_responses.go b/operations/log_target/get_all_log_target_global_responses.go new file mode 100644 index 00000000..f2832f15 --- /dev/null +++ b/operations/log_target/get_all_log_target_global_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllLogTargetGlobalOKCode is the HTTP code returned for type GetAllLogTargetGlobalOK +const GetAllLogTargetGlobalOKCode int = 200 + +/* +GetAllLogTargetGlobalOK Successful operation + +swagger:response getAllLogTargetGlobalOK +*/ +type GetAllLogTargetGlobalOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewGetAllLogTargetGlobalOK creates GetAllLogTargetGlobalOK with default headers values +func NewGetAllLogTargetGlobalOK() *GetAllLogTargetGlobalOK { + + return &GetAllLogTargetGlobalOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target global o k response +func (o *GetAllLogTargetGlobalOK) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetGlobalOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target global o k response +func (o *GetAllLogTargetGlobalOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target global o k response +func (o *GetAllLogTargetGlobalOK) WithPayload(payload models.LogTargets) *GetAllLogTargetGlobalOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target global o k response +func (o *GetAllLogTargetGlobalOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetGlobalOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllLogTargetGlobalDefault General Error + +swagger:response getAllLogTargetGlobalDefault +*/ +type GetAllLogTargetGlobalDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllLogTargetGlobalDefault creates GetAllLogTargetGlobalDefault with default headers values +func NewGetAllLogTargetGlobalDefault(code int) *GetAllLogTargetGlobalDefault { + if code <= 0 { + code = 500 + } + + return &GetAllLogTargetGlobalDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all log target global default response +func (o *GetAllLogTargetGlobalDefault) WithStatusCode(code int) *GetAllLogTargetGlobalDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all log target global default response +func (o *GetAllLogTargetGlobalDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target global default response +func (o *GetAllLogTargetGlobalDefault) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetGlobalDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target global default response +func (o *GetAllLogTargetGlobalDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target global default response +func (o *GetAllLogTargetGlobalDefault) WithPayload(payload *models.Error) *GetAllLogTargetGlobalDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target global default response +func (o *GetAllLogTargetGlobalDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetGlobalDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_all_log_target_global_urlbuilder.go b/operations/log_target/get_all_log_target_global_urlbuilder.go new file mode 100644 index 00000000..7edc8046 --- /dev/null +++ b/operations/log_target/get_all_log_target_global_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllLogTargetGlobalURL generates an URL for the get all log target global operation +type GetAllLogTargetGlobalURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetGlobalURL) WithBasePath(bp string) *GetAllLogTargetGlobalURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetGlobalURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllLogTargetGlobalURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/global/log_targets" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllLogTargetGlobalURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllLogTargetGlobalURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllLogTargetGlobalURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllLogTargetGlobalURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllLogTargetGlobalURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllLogTargetGlobalURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_all_log_target_log_forward.go b/operations/log_target/get_all_log_target_log_forward.go new file mode 100644 index 00000000..fb0820d0 --- /dev/null +++ b/operations/log_target/get_all_log_target_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllLogTargetLogForwardHandlerFunc turns a function with the right signature into a get all log target log forward handler +type GetAllLogTargetLogForwardHandlerFunc func(GetAllLogTargetLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllLogTargetLogForwardHandlerFunc) Handle(params GetAllLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllLogTargetLogForwardHandler interface for that can handle valid get all log target log forward params +type GetAllLogTargetLogForwardHandler interface { + Handle(GetAllLogTargetLogForwardParams, interface{}) middleware.Responder +} + +// NewGetAllLogTargetLogForward creates a new http.Handler for the get all log target log forward operation +func NewGetAllLogTargetLogForward(ctx *middleware.Context, handler GetAllLogTargetLogForwardHandler) *GetAllLogTargetLogForward { + return &GetAllLogTargetLogForward{Context: ctx, Handler: handler} +} + +/* + GetAllLogTargetLogForward swagger:route GET /services/haproxy/configuration/log_forwards/{parent_name}/log_targets LogTarget getAllLogTargetLogForward + +# Return an array of all Log Targets + +Returns all Log Targets that are configured in specified parent. +*/ +type GetAllLogTargetLogForward struct { + Context *middleware.Context + Handler GetAllLogTargetLogForwardHandler +} + +func (o *GetAllLogTargetLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllLogTargetLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_all_log_target_log_forward_parameters.go b/operations/log_target/get_all_log_target_log_forward_parameters.go new file mode 100644 index 00000000..a4fa352a --- /dev/null +++ b/operations/log_target/get_all_log_target_log_forward_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllLogTargetLogForwardParams creates a new GetAllLogTargetLogForwardParams object +// +// There are no default values defined in the spec. +func NewGetAllLogTargetLogForwardParams() GetAllLogTargetLogForwardParams { + + return GetAllLogTargetLogForwardParams{} +} + +// GetAllLogTargetLogForwardParams contains all the bound params for the get all log target log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllLogTargetLogForward +type GetAllLogTargetLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllLogTargetLogForwardParams() beforehand. +func (o *GetAllLogTargetLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllLogTargetLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllLogTargetLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_all_log_target_log_forward_responses.go b/operations/log_target/get_all_log_target_log_forward_responses.go new file mode 100644 index 00000000..677343ce --- /dev/null +++ b/operations/log_target/get_all_log_target_log_forward_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllLogTargetLogForwardOKCode is the HTTP code returned for type GetAllLogTargetLogForwardOK +const GetAllLogTargetLogForwardOKCode int = 200 + +/* +GetAllLogTargetLogForwardOK Successful operation + +swagger:response getAllLogTargetLogForwardOK +*/ +type GetAllLogTargetLogForwardOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewGetAllLogTargetLogForwardOK creates GetAllLogTargetLogForwardOK with default headers values +func NewGetAllLogTargetLogForwardOK() *GetAllLogTargetLogForwardOK { + + return &GetAllLogTargetLogForwardOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target log forward o k response +func (o *GetAllLogTargetLogForwardOK) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetLogForwardOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target log forward o k response +func (o *GetAllLogTargetLogForwardOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target log forward o k response +func (o *GetAllLogTargetLogForwardOK) WithPayload(payload models.LogTargets) *GetAllLogTargetLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target log forward o k response +func (o *GetAllLogTargetLogForwardOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllLogTargetLogForwardDefault General Error + +swagger:response getAllLogTargetLogForwardDefault +*/ +type GetAllLogTargetLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllLogTargetLogForwardDefault creates GetAllLogTargetLogForwardDefault with default headers values +func NewGetAllLogTargetLogForwardDefault(code int) *GetAllLogTargetLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &GetAllLogTargetLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all log target log forward default response +func (o *GetAllLogTargetLogForwardDefault) WithStatusCode(code int) *GetAllLogTargetLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all log target log forward default response +func (o *GetAllLogTargetLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target log forward default response +func (o *GetAllLogTargetLogForwardDefault) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target log forward default response +func (o *GetAllLogTargetLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target log forward default response +func (o *GetAllLogTargetLogForwardDefault) WithPayload(payload *models.Error) *GetAllLogTargetLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target log forward default response +func (o *GetAllLogTargetLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_all_log_target_log_forward_urlbuilder.go b/operations/log_target/get_all_log_target_log_forward_urlbuilder.go new file mode 100644 index 00000000..424ac9a8 --- /dev/null +++ b/operations/log_target/get_all_log_target_log_forward_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllLogTargetLogForwardURL generates an URL for the get all log target log forward operation +type GetAllLogTargetLogForwardURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetLogForwardURL) WithBasePath(bp string) *GetAllLogTargetLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllLogTargetLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllLogTargetLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllLogTargetLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllLogTargetLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllLogTargetLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllLogTargetLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllLogTargetLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllLogTargetLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_all_log_target_peer.go b/operations/log_target/get_all_log_target_peer.go new file mode 100644 index 00000000..f0c7883c --- /dev/null +++ b/operations/log_target/get_all_log_target_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllLogTargetPeerHandlerFunc turns a function with the right signature into a get all log target peer handler +type GetAllLogTargetPeerHandlerFunc func(GetAllLogTargetPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllLogTargetPeerHandlerFunc) Handle(params GetAllLogTargetPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllLogTargetPeerHandler interface for that can handle valid get all log target peer params +type GetAllLogTargetPeerHandler interface { + Handle(GetAllLogTargetPeerParams, interface{}) middleware.Responder +} + +// NewGetAllLogTargetPeer creates a new http.Handler for the get all log target peer operation +func NewGetAllLogTargetPeer(ctx *middleware.Context, handler GetAllLogTargetPeerHandler) *GetAllLogTargetPeer { + return &GetAllLogTargetPeer{Context: ctx, Handler: handler} +} + +/* + GetAllLogTargetPeer swagger:route GET /services/haproxy/configuration/peers/{parent_name}/log_targets LogTarget getAllLogTargetPeer + +# Return an array of all Log Targets + +Returns all Log Targets that are configured in specified parent. +*/ +type GetAllLogTargetPeer struct { + Context *middleware.Context + Handler GetAllLogTargetPeerHandler +} + +func (o *GetAllLogTargetPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllLogTargetPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_all_log_target_peer_parameters.go b/operations/log_target/get_all_log_target_peer_parameters.go new file mode 100644 index 00000000..31c67090 --- /dev/null +++ b/operations/log_target/get_all_log_target_peer_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllLogTargetPeerParams creates a new GetAllLogTargetPeerParams object +// +// There are no default values defined in the spec. +func NewGetAllLogTargetPeerParams() GetAllLogTargetPeerParams { + + return GetAllLogTargetPeerParams{} +} + +// GetAllLogTargetPeerParams contains all the bound params for the get all log target peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllLogTargetPeer +type GetAllLogTargetPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllLogTargetPeerParams() beforehand. +func (o *GetAllLogTargetPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllLogTargetPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllLogTargetPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_all_log_target_peer_responses.go b/operations/log_target/get_all_log_target_peer_responses.go new file mode 100644 index 00000000..c97c6077 --- /dev/null +++ b/operations/log_target/get_all_log_target_peer_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllLogTargetPeerOKCode is the HTTP code returned for type GetAllLogTargetPeerOK +const GetAllLogTargetPeerOKCode int = 200 + +/* +GetAllLogTargetPeerOK Successful operation + +swagger:response getAllLogTargetPeerOK +*/ +type GetAllLogTargetPeerOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewGetAllLogTargetPeerOK creates GetAllLogTargetPeerOK with default headers values +func NewGetAllLogTargetPeerOK() *GetAllLogTargetPeerOK { + + return &GetAllLogTargetPeerOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target peer o k response +func (o *GetAllLogTargetPeerOK) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetPeerOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target peer o k response +func (o *GetAllLogTargetPeerOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target peer o k response +func (o *GetAllLogTargetPeerOK) WithPayload(payload models.LogTargets) *GetAllLogTargetPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target peer o k response +func (o *GetAllLogTargetPeerOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllLogTargetPeerDefault General Error + +swagger:response getAllLogTargetPeerDefault +*/ +type GetAllLogTargetPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllLogTargetPeerDefault creates GetAllLogTargetPeerDefault with default headers values +func NewGetAllLogTargetPeerDefault(code int) *GetAllLogTargetPeerDefault { + if code <= 0 { + code = 500 + } + + return &GetAllLogTargetPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all log target peer default response +func (o *GetAllLogTargetPeerDefault) WithStatusCode(code int) *GetAllLogTargetPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all log target peer default response +func (o *GetAllLogTargetPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all log target peer default response +func (o *GetAllLogTargetPeerDefault) WithConfigurationVersion(configurationVersion string) *GetAllLogTargetPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all log target peer default response +func (o *GetAllLogTargetPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all log target peer default response +func (o *GetAllLogTargetPeerDefault) WithPayload(payload *models.Error) *GetAllLogTargetPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all log target peer default response +func (o *GetAllLogTargetPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllLogTargetPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_all_log_target_peer_urlbuilder.go b/operations/log_target/get_all_log_target_peer_urlbuilder.go new file mode 100644 index 00000000..bdcd2791 --- /dev/null +++ b/operations/log_target/get_all_log_target_peer_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllLogTargetPeerURL generates an URL for the get all log target peer operation +type GetAllLogTargetPeerURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetPeerURL) WithBasePath(bp string) *GetAllLogTargetPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllLogTargetPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllLogTargetPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllLogTargetPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllLogTargetPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllLogTargetPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllLogTargetPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllLogTargetPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllLogTargetPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllLogTargetPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_log_target.go b/operations/log_target/get_log_target.go deleted file mode 100644 index b2709d79..00000000 --- a/operations/log_target/get_log_target.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetLogTargetHandlerFunc turns a function with the right signature into a get log target handler -type GetLogTargetHandlerFunc func(GetLogTargetParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetLogTargetHandlerFunc) Handle(params GetLogTargetParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetLogTargetHandler interface for that can handle valid get log target params -type GetLogTargetHandler interface { - Handle(GetLogTargetParams, interface{}) middleware.Responder -} - -// NewGetLogTarget creates a new http.Handler for the get log target operation -func NewGetLogTarget(ctx *middleware.Context, handler GetLogTargetHandler) *GetLogTarget { - return &GetLogTarget{Context: ctx, Handler: handler} -} - -/*GetLogTarget swagger:route GET /services/haproxy/configuration/log_targets/{id} LogTarget getLogTarget - -Return one Log Target - -Returns one Log Target configuration by it's ID in the specified parent. - -*/ -type GetLogTarget struct { - Context *middleware.Context - Handler GetLogTargetHandler -} - -func (o *GetLogTarget) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetLogTargetParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetLogTargetOKBody get log target o k body -// swagger:model GetLogTargetOKBody -type GetLogTargetOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.LogTarget `json:"data,omitempty"` -} - -// Validate validates this get log target o k body -func (o *GetLogTargetOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetLogTargetOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getLogTargetOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetLogTargetOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetLogTargetOKBody) UnmarshalBinary(b []byte) error { - var res GetLogTargetOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/log_target/get_log_target_backend.go b/operations/log_target/get_log_target_backend.go new file mode 100644 index 00000000..0b52dac4 --- /dev/null +++ b/operations/log_target/get_log_target_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogTargetBackendHandlerFunc turns a function with the right signature into a get log target backend handler +type GetLogTargetBackendHandlerFunc func(GetLogTargetBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogTargetBackendHandlerFunc) Handle(params GetLogTargetBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogTargetBackendHandler interface for that can handle valid get log target backend params +type GetLogTargetBackendHandler interface { + Handle(GetLogTargetBackendParams, interface{}) middleware.Responder +} + +// NewGetLogTargetBackend creates a new http.Handler for the get log target backend operation +func NewGetLogTargetBackend(ctx *middleware.Context, handler GetLogTargetBackendHandler) *GetLogTargetBackend { + return &GetLogTargetBackend{Context: ctx, Handler: handler} +} + +/* + GetLogTargetBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/log_targets/{index} LogTarget getLogTargetBackend + +# Return one Log Target + +Returns one Log Target configuration by it's index in the specified parent. +*/ +type GetLogTargetBackend struct { + Context *middleware.Context + Handler GetLogTargetBackendHandler +} + +func (o *GetLogTargetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogTargetBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_log_target_backend_parameters.go b/operations/log_target/get_log_target_backend_parameters.go new file mode 100644 index 00000000..01ea6552 --- /dev/null +++ b/operations/log_target/get_log_target_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogTargetBackendParams creates a new GetLogTargetBackendParams object +// +// There are no default values defined in the spec. +func NewGetLogTargetBackendParams() GetLogTargetBackendParams { + + return GetLogTargetBackendParams{} +} + +// GetLogTargetBackendParams contains all the bound params for the get log target backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogTargetBackend +type GetLogTargetBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogTargetBackendParams() beforehand. +func (o *GetLogTargetBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetLogTargetBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetLogTargetBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogTargetBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_log_target_backend_responses.go b/operations/log_target/get_log_target_backend_responses.go new file mode 100644 index 00000000..dec4047c --- /dev/null +++ b/operations/log_target/get_log_target_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogTargetBackendOKCode is the HTTP code returned for type GetLogTargetBackendOK +const GetLogTargetBackendOKCode int = 200 + +/* +GetLogTargetBackendOK Successful operation + +swagger:response getLogTargetBackendOK +*/ +type GetLogTargetBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewGetLogTargetBackendOK creates GetLogTargetBackendOK with default headers values +func NewGetLogTargetBackendOK() *GetLogTargetBackendOK { + + return &GetLogTargetBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target backend o k response +func (o *GetLogTargetBackendOK) WithConfigurationVersion(configurationVersion string) *GetLogTargetBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target backend o k response +func (o *GetLogTargetBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target backend o k response +func (o *GetLogTargetBackendOK) WithPayload(payload *models.LogTarget) *GetLogTargetBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target backend o k response +func (o *GetLogTargetBackendOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogTargetBackendNotFoundCode is the HTTP code returned for type GetLogTargetBackendNotFound +const GetLogTargetBackendNotFoundCode int = 404 + +/* +GetLogTargetBackendNotFound The specified resource was not found + +swagger:response getLogTargetBackendNotFound +*/ +type GetLogTargetBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetBackendNotFound creates GetLogTargetBackendNotFound with default headers values +func NewGetLogTargetBackendNotFound() *GetLogTargetBackendNotFound { + + return &GetLogTargetBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target backend not found response +func (o *GetLogTargetBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetLogTargetBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target backend not found response +func (o *GetLogTargetBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target backend not found response +func (o *GetLogTargetBackendNotFound) WithPayload(payload *models.Error) *GetLogTargetBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target backend not found response +func (o *GetLogTargetBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogTargetBackendDefault General Error + +swagger:response getLogTargetBackendDefault +*/ +type GetLogTargetBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetBackendDefault creates GetLogTargetBackendDefault with default headers values +func NewGetLogTargetBackendDefault(code int) *GetLogTargetBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetLogTargetBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log target backend default response +func (o *GetLogTargetBackendDefault) WithStatusCode(code int) *GetLogTargetBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log target backend default response +func (o *GetLogTargetBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log target backend default response +func (o *GetLogTargetBackendDefault) WithConfigurationVersion(configurationVersion string) *GetLogTargetBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target backend default response +func (o *GetLogTargetBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target backend default response +func (o *GetLogTargetBackendDefault) WithPayload(payload *models.Error) *GetLogTargetBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target backend default response +func (o *GetLogTargetBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_log_target_backend_urlbuilder.go b/operations/log_target/get_log_target_backend_urlbuilder.go new file mode 100644 index 00000000..6ddab662 --- /dev/null +++ b/operations/log_target/get_log_target_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogTargetBackendURL generates an URL for the get log target backend operation +type GetLogTargetBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetBackendURL) WithBasePath(bp string) *GetLogTargetBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogTargetBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetLogTargetBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetLogTargetBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogTargetBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogTargetBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogTargetBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogTargetBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogTargetBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogTargetBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_log_target_defaults.go b/operations/log_target/get_log_target_defaults.go new file mode 100644 index 00000000..b03e998f --- /dev/null +++ b/operations/log_target/get_log_target_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogTargetDefaultsHandlerFunc turns a function with the right signature into a get log target defaults handler +type GetLogTargetDefaultsHandlerFunc func(GetLogTargetDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogTargetDefaultsHandlerFunc) Handle(params GetLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogTargetDefaultsHandler interface for that can handle valid get log target defaults params +type GetLogTargetDefaultsHandler interface { + Handle(GetLogTargetDefaultsParams, interface{}) middleware.Responder +} + +// NewGetLogTargetDefaults creates a new http.Handler for the get log target defaults operation +func NewGetLogTargetDefaults(ctx *middleware.Context, handler GetLogTargetDefaultsHandler) *GetLogTargetDefaults { + return &GetLogTargetDefaults{Context: ctx, Handler: handler} +} + +/* + GetLogTargetDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/log_targets/{index} LogTarget getLogTargetDefaults + +# Return one Log Target + +Returns one Log Target configuration by it's index in the specified parent. +*/ +type GetLogTargetDefaults struct { + Context *middleware.Context + Handler GetLogTargetDefaultsHandler +} + +func (o *GetLogTargetDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogTargetDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_log_target_defaults_parameters.go b/operations/log_target/get_log_target_defaults_parameters.go new file mode 100644 index 00000000..f47aaa88 --- /dev/null +++ b/operations/log_target/get_log_target_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogTargetDefaultsParams creates a new GetLogTargetDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetLogTargetDefaultsParams() GetLogTargetDefaultsParams { + + return GetLogTargetDefaultsParams{} +} + +// GetLogTargetDefaultsParams contains all the bound params for the get log target defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogTargetDefaults +type GetLogTargetDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogTargetDefaultsParams() beforehand. +func (o *GetLogTargetDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetLogTargetDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetLogTargetDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogTargetDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_log_target_defaults_responses.go b/operations/log_target/get_log_target_defaults_responses.go new file mode 100644 index 00000000..d8e63913 --- /dev/null +++ b/operations/log_target/get_log_target_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogTargetDefaultsOKCode is the HTTP code returned for type GetLogTargetDefaultsOK +const GetLogTargetDefaultsOKCode int = 200 + +/* +GetLogTargetDefaultsOK Successful operation + +swagger:response getLogTargetDefaultsOK +*/ +type GetLogTargetDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewGetLogTargetDefaultsOK creates GetLogTargetDefaultsOK with default headers values +func NewGetLogTargetDefaultsOK() *GetLogTargetDefaultsOK { + + return &GetLogTargetDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target defaults o k response +func (o *GetLogTargetDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetLogTargetDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target defaults o k response +func (o *GetLogTargetDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target defaults o k response +func (o *GetLogTargetDefaultsOK) WithPayload(payload *models.LogTarget) *GetLogTargetDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target defaults o k response +func (o *GetLogTargetDefaultsOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogTargetDefaultsNotFoundCode is the HTTP code returned for type GetLogTargetDefaultsNotFound +const GetLogTargetDefaultsNotFoundCode int = 404 + +/* +GetLogTargetDefaultsNotFound The specified resource was not found + +swagger:response getLogTargetDefaultsNotFound +*/ +type GetLogTargetDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetDefaultsNotFound creates GetLogTargetDefaultsNotFound with default headers values +func NewGetLogTargetDefaultsNotFound() *GetLogTargetDefaultsNotFound { + + return &GetLogTargetDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target defaults not found response +func (o *GetLogTargetDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetLogTargetDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target defaults not found response +func (o *GetLogTargetDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target defaults not found response +func (o *GetLogTargetDefaultsNotFound) WithPayload(payload *models.Error) *GetLogTargetDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target defaults not found response +func (o *GetLogTargetDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogTargetDefaultsDefault General Error + +swagger:response getLogTargetDefaultsDefault +*/ +type GetLogTargetDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetDefaultsDefault creates GetLogTargetDefaultsDefault with default headers values +func NewGetLogTargetDefaultsDefault(code int) *GetLogTargetDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetLogTargetDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log target defaults default response +func (o *GetLogTargetDefaultsDefault) WithStatusCode(code int) *GetLogTargetDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log target defaults default response +func (o *GetLogTargetDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log target defaults default response +func (o *GetLogTargetDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetLogTargetDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target defaults default response +func (o *GetLogTargetDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target defaults default response +func (o *GetLogTargetDefaultsDefault) WithPayload(payload *models.Error) *GetLogTargetDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target defaults default response +func (o *GetLogTargetDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_log_target_defaults_urlbuilder.go b/operations/log_target/get_log_target_defaults_urlbuilder.go new file mode 100644 index 00000000..ddd1320e --- /dev/null +++ b/operations/log_target/get_log_target_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogTargetDefaultsURL generates an URL for the get log target defaults operation +type GetLogTargetDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetDefaultsURL) WithBasePath(bp string) *GetLogTargetDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogTargetDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetLogTargetDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetLogTargetDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogTargetDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogTargetDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogTargetDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogTargetDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogTargetDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogTargetDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_log_target_frontend.go b/operations/log_target/get_log_target_frontend.go new file mode 100644 index 00000000..2de86a44 --- /dev/null +++ b/operations/log_target/get_log_target_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogTargetFrontendHandlerFunc turns a function with the right signature into a get log target frontend handler +type GetLogTargetFrontendHandlerFunc func(GetLogTargetFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogTargetFrontendHandlerFunc) Handle(params GetLogTargetFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogTargetFrontendHandler interface for that can handle valid get log target frontend params +type GetLogTargetFrontendHandler interface { + Handle(GetLogTargetFrontendParams, interface{}) middleware.Responder +} + +// NewGetLogTargetFrontend creates a new http.Handler for the get log target frontend operation +func NewGetLogTargetFrontend(ctx *middleware.Context, handler GetLogTargetFrontendHandler) *GetLogTargetFrontend { + return &GetLogTargetFrontend{Context: ctx, Handler: handler} +} + +/* + GetLogTargetFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/log_targets/{index} LogTarget getLogTargetFrontend + +# Return one Log Target + +Returns one Log Target configuration by it's index in the specified parent. +*/ +type GetLogTargetFrontend struct { + Context *middleware.Context + Handler GetLogTargetFrontendHandler +} + +func (o *GetLogTargetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogTargetFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_log_target_frontend_parameters.go b/operations/log_target/get_log_target_frontend_parameters.go new file mode 100644 index 00000000..31412579 --- /dev/null +++ b/operations/log_target/get_log_target_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogTargetFrontendParams creates a new GetLogTargetFrontendParams object +// +// There are no default values defined in the spec. +func NewGetLogTargetFrontendParams() GetLogTargetFrontendParams { + + return GetLogTargetFrontendParams{} +} + +// GetLogTargetFrontendParams contains all the bound params for the get log target frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogTargetFrontend +type GetLogTargetFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogTargetFrontendParams() beforehand. +func (o *GetLogTargetFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetLogTargetFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetLogTargetFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogTargetFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_log_target_frontend_responses.go b/operations/log_target/get_log_target_frontend_responses.go new file mode 100644 index 00000000..aebf7e91 --- /dev/null +++ b/operations/log_target/get_log_target_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogTargetFrontendOKCode is the HTTP code returned for type GetLogTargetFrontendOK +const GetLogTargetFrontendOKCode int = 200 + +/* +GetLogTargetFrontendOK Successful operation + +swagger:response getLogTargetFrontendOK +*/ +type GetLogTargetFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewGetLogTargetFrontendOK creates GetLogTargetFrontendOK with default headers values +func NewGetLogTargetFrontendOK() *GetLogTargetFrontendOK { + + return &GetLogTargetFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target frontend o k response +func (o *GetLogTargetFrontendOK) WithConfigurationVersion(configurationVersion string) *GetLogTargetFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target frontend o k response +func (o *GetLogTargetFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target frontend o k response +func (o *GetLogTargetFrontendOK) WithPayload(payload *models.LogTarget) *GetLogTargetFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target frontend o k response +func (o *GetLogTargetFrontendOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogTargetFrontendNotFoundCode is the HTTP code returned for type GetLogTargetFrontendNotFound +const GetLogTargetFrontendNotFoundCode int = 404 + +/* +GetLogTargetFrontendNotFound The specified resource was not found + +swagger:response getLogTargetFrontendNotFound +*/ +type GetLogTargetFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetFrontendNotFound creates GetLogTargetFrontendNotFound with default headers values +func NewGetLogTargetFrontendNotFound() *GetLogTargetFrontendNotFound { + + return &GetLogTargetFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target frontend not found response +func (o *GetLogTargetFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetLogTargetFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target frontend not found response +func (o *GetLogTargetFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target frontend not found response +func (o *GetLogTargetFrontendNotFound) WithPayload(payload *models.Error) *GetLogTargetFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target frontend not found response +func (o *GetLogTargetFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogTargetFrontendDefault General Error + +swagger:response getLogTargetFrontendDefault +*/ +type GetLogTargetFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetFrontendDefault creates GetLogTargetFrontendDefault with default headers values +func NewGetLogTargetFrontendDefault(code int) *GetLogTargetFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetLogTargetFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log target frontend default response +func (o *GetLogTargetFrontendDefault) WithStatusCode(code int) *GetLogTargetFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log target frontend default response +func (o *GetLogTargetFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log target frontend default response +func (o *GetLogTargetFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetLogTargetFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target frontend default response +func (o *GetLogTargetFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target frontend default response +func (o *GetLogTargetFrontendDefault) WithPayload(payload *models.Error) *GetLogTargetFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target frontend default response +func (o *GetLogTargetFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_log_target_frontend_urlbuilder.go b/operations/log_target/get_log_target_frontend_urlbuilder.go new file mode 100644 index 00000000..557e8498 --- /dev/null +++ b/operations/log_target/get_log_target_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogTargetFrontendURL generates an URL for the get log target frontend operation +type GetLogTargetFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetFrontendURL) WithBasePath(bp string) *GetLogTargetFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogTargetFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetLogTargetFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetLogTargetFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogTargetFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogTargetFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogTargetFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogTargetFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogTargetFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogTargetFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_log_target_global.go b/operations/log_target/get_log_target_global.go new file mode 100644 index 00000000..10a993f4 --- /dev/null +++ b/operations/log_target/get_log_target_global.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogTargetGlobalHandlerFunc turns a function with the right signature into a get log target global handler +type GetLogTargetGlobalHandlerFunc func(GetLogTargetGlobalParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogTargetGlobalHandlerFunc) Handle(params GetLogTargetGlobalParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogTargetGlobalHandler interface for that can handle valid get log target global params +type GetLogTargetGlobalHandler interface { + Handle(GetLogTargetGlobalParams, interface{}) middleware.Responder +} + +// NewGetLogTargetGlobal creates a new http.Handler for the get log target global operation +func NewGetLogTargetGlobal(ctx *middleware.Context, handler GetLogTargetGlobalHandler) *GetLogTargetGlobal { + return &GetLogTargetGlobal{Context: ctx, Handler: handler} +} + +/* + GetLogTargetGlobal swagger:route GET /services/haproxy/configuration/global/log_targets/{index} LogTarget getLogTargetGlobal + +# Return one Log Target + +Returns one Log Target configuration by it's index in the specified parent. +*/ +type GetLogTargetGlobal struct { + Context *middleware.Context + Handler GetLogTargetGlobalHandler +} + +func (o *GetLogTargetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogTargetGlobalParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_log_target_global_parameters.go b/operations/log_target/get_log_target_global_parameters.go new file mode 100644 index 00000000..21fb6066 --- /dev/null +++ b/operations/log_target/get_log_target_global_parameters.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogTargetGlobalParams creates a new GetLogTargetGlobalParams object +// +// There are no default values defined in the spec. +func NewGetLogTargetGlobalParams() GetLogTargetGlobalParams { + + return GetLogTargetGlobalParams{} +} + +// GetLogTargetGlobalParams contains all the bound params for the get log target global operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogTargetGlobal +type GetLogTargetGlobalParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogTargetGlobalParams() beforehand. +func (o *GetLogTargetGlobalParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetLogTargetGlobalParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogTargetGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_log_target_global_responses.go b/operations/log_target/get_log_target_global_responses.go new file mode 100644 index 00000000..ecafeb76 --- /dev/null +++ b/operations/log_target/get_log_target_global_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogTargetGlobalOKCode is the HTTP code returned for type GetLogTargetGlobalOK +const GetLogTargetGlobalOKCode int = 200 + +/* +GetLogTargetGlobalOK Successful operation + +swagger:response getLogTargetGlobalOK +*/ +type GetLogTargetGlobalOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewGetLogTargetGlobalOK creates GetLogTargetGlobalOK with default headers values +func NewGetLogTargetGlobalOK() *GetLogTargetGlobalOK { + + return &GetLogTargetGlobalOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target global o k response +func (o *GetLogTargetGlobalOK) WithConfigurationVersion(configurationVersion string) *GetLogTargetGlobalOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target global o k response +func (o *GetLogTargetGlobalOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target global o k response +func (o *GetLogTargetGlobalOK) WithPayload(payload *models.LogTarget) *GetLogTargetGlobalOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target global o k response +func (o *GetLogTargetGlobalOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetGlobalOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogTargetGlobalNotFoundCode is the HTTP code returned for type GetLogTargetGlobalNotFound +const GetLogTargetGlobalNotFoundCode int = 404 + +/* +GetLogTargetGlobalNotFound The specified resource was not found + +swagger:response getLogTargetGlobalNotFound +*/ +type GetLogTargetGlobalNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetGlobalNotFound creates GetLogTargetGlobalNotFound with default headers values +func NewGetLogTargetGlobalNotFound() *GetLogTargetGlobalNotFound { + + return &GetLogTargetGlobalNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target global not found response +func (o *GetLogTargetGlobalNotFound) WithConfigurationVersion(configurationVersion string) *GetLogTargetGlobalNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target global not found response +func (o *GetLogTargetGlobalNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target global not found response +func (o *GetLogTargetGlobalNotFound) WithPayload(payload *models.Error) *GetLogTargetGlobalNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target global not found response +func (o *GetLogTargetGlobalNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetGlobalNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogTargetGlobalDefault General Error + +swagger:response getLogTargetGlobalDefault +*/ +type GetLogTargetGlobalDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetGlobalDefault creates GetLogTargetGlobalDefault with default headers values +func NewGetLogTargetGlobalDefault(code int) *GetLogTargetGlobalDefault { + if code <= 0 { + code = 500 + } + + return &GetLogTargetGlobalDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log target global default response +func (o *GetLogTargetGlobalDefault) WithStatusCode(code int) *GetLogTargetGlobalDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log target global default response +func (o *GetLogTargetGlobalDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log target global default response +func (o *GetLogTargetGlobalDefault) WithConfigurationVersion(configurationVersion string) *GetLogTargetGlobalDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target global default response +func (o *GetLogTargetGlobalDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target global default response +func (o *GetLogTargetGlobalDefault) WithPayload(payload *models.Error) *GetLogTargetGlobalDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target global default response +func (o *GetLogTargetGlobalDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetGlobalDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_log_target_global_urlbuilder.go b/operations/log_target/get_log_target_global_urlbuilder.go new file mode 100644 index 00000000..79dd9ab7 --- /dev/null +++ b/operations/log_target/get_log_target_global_urlbuilder.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogTargetGlobalURL generates an URL for the get log target global operation +type GetLogTargetGlobalURL struct { + Index int64 + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetGlobalURL) WithBasePath(bp string) *GetLogTargetGlobalURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetGlobalURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogTargetGlobalURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/global/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetLogTargetGlobalURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogTargetGlobalURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogTargetGlobalURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogTargetGlobalURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogTargetGlobalURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogTargetGlobalURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogTargetGlobalURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_log_target_log_forward.go b/operations/log_target/get_log_target_log_forward.go new file mode 100644 index 00000000..f1414aed --- /dev/null +++ b/operations/log_target/get_log_target_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogTargetLogForwardHandlerFunc turns a function with the right signature into a get log target log forward handler +type GetLogTargetLogForwardHandlerFunc func(GetLogTargetLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogTargetLogForwardHandlerFunc) Handle(params GetLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogTargetLogForwardHandler interface for that can handle valid get log target log forward params +type GetLogTargetLogForwardHandler interface { + Handle(GetLogTargetLogForwardParams, interface{}) middleware.Responder +} + +// NewGetLogTargetLogForward creates a new http.Handler for the get log target log forward operation +func NewGetLogTargetLogForward(ctx *middleware.Context, handler GetLogTargetLogForwardHandler) *GetLogTargetLogForward { + return &GetLogTargetLogForward{Context: ctx, Handler: handler} +} + +/* + GetLogTargetLogForward swagger:route GET /services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index} LogTarget getLogTargetLogForward + +# Return one Log Target + +Returns one Log Target configuration by it's index in the specified parent. +*/ +type GetLogTargetLogForward struct { + Context *middleware.Context + Handler GetLogTargetLogForwardHandler +} + +func (o *GetLogTargetLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogTargetLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_log_target_log_forward_parameters.go b/operations/log_target/get_log_target_log_forward_parameters.go new file mode 100644 index 00000000..dfcc8f30 --- /dev/null +++ b/operations/log_target/get_log_target_log_forward_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogTargetLogForwardParams creates a new GetLogTargetLogForwardParams object +// +// There are no default values defined in the spec. +func NewGetLogTargetLogForwardParams() GetLogTargetLogForwardParams { + + return GetLogTargetLogForwardParams{} +} + +// GetLogTargetLogForwardParams contains all the bound params for the get log target log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogTargetLogForward +type GetLogTargetLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogTargetLogForwardParams() beforehand. +func (o *GetLogTargetLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetLogTargetLogForwardParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetLogTargetLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogTargetLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_log_target_log_forward_responses.go b/operations/log_target/get_log_target_log_forward_responses.go new file mode 100644 index 00000000..7ee4c0bc --- /dev/null +++ b/operations/log_target/get_log_target_log_forward_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogTargetLogForwardOKCode is the HTTP code returned for type GetLogTargetLogForwardOK +const GetLogTargetLogForwardOKCode int = 200 + +/* +GetLogTargetLogForwardOK Successful operation + +swagger:response getLogTargetLogForwardOK +*/ +type GetLogTargetLogForwardOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewGetLogTargetLogForwardOK creates GetLogTargetLogForwardOK with default headers values +func NewGetLogTargetLogForwardOK() *GetLogTargetLogForwardOK { + + return &GetLogTargetLogForwardOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target log forward o k response +func (o *GetLogTargetLogForwardOK) WithConfigurationVersion(configurationVersion string) *GetLogTargetLogForwardOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target log forward o k response +func (o *GetLogTargetLogForwardOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target log forward o k response +func (o *GetLogTargetLogForwardOK) WithPayload(payload *models.LogTarget) *GetLogTargetLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target log forward o k response +func (o *GetLogTargetLogForwardOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogTargetLogForwardNotFoundCode is the HTTP code returned for type GetLogTargetLogForwardNotFound +const GetLogTargetLogForwardNotFoundCode int = 404 + +/* +GetLogTargetLogForwardNotFound The specified resource was not found + +swagger:response getLogTargetLogForwardNotFound +*/ +type GetLogTargetLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetLogForwardNotFound creates GetLogTargetLogForwardNotFound with default headers values +func NewGetLogTargetLogForwardNotFound() *GetLogTargetLogForwardNotFound { + + return &GetLogTargetLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target log forward not found response +func (o *GetLogTargetLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *GetLogTargetLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target log forward not found response +func (o *GetLogTargetLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target log forward not found response +func (o *GetLogTargetLogForwardNotFound) WithPayload(payload *models.Error) *GetLogTargetLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target log forward not found response +func (o *GetLogTargetLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogTargetLogForwardDefault General Error + +swagger:response getLogTargetLogForwardDefault +*/ +type GetLogTargetLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetLogForwardDefault creates GetLogTargetLogForwardDefault with default headers values +func NewGetLogTargetLogForwardDefault(code int) *GetLogTargetLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &GetLogTargetLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log target log forward default response +func (o *GetLogTargetLogForwardDefault) WithStatusCode(code int) *GetLogTargetLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log target log forward default response +func (o *GetLogTargetLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log target log forward default response +func (o *GetLogTargetLogForwardDefault) WithConfigurationVersion(configurationVersion string) *GetLogTargetLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target log forward default response +func (o *GetLogTargetLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target log forward default response +func (o *GetLogTargetLogForwardDefault) WithPayload(payload *models.Error) *GetLogTargetLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target log forward default response +func (o *GetLogTargetLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_log_target_log_forward_urlbuilder.go b/operations/log_target/get_log_target_log_forward_urlbuilder.go new file mode 100644 index 00000000..0473dc86 --- /dev/null +++ b/operations/log_target/get_log_target_log_forward_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogTargetLogForwardURL generates an URL for the get log target log forward operation +type GetLogTargetLogForwardURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetLogForwardURL) WithBasePath(bp string) *GetLogTargetLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogTargetLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetLogTargetLogForwardURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetLogTargetLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogTargetLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogTargetLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogTargetLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogTargetLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogTargetLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogTargetLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_log_target_parameters.go b/operations/log_target/get_log_target_parameters.go deleted file mode 100644 index d9106729..00000000 --- a/operations/log_target/get_log_target_parameters.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetLogTargetParams creates a new GetLogTargetParams object -// no default values defined in spec. -func NewGetLogTargetParams() GetLogTargetParams { - - return GetLogTargetParams{} -} - -// GetLogTargetParams contains all the bound params for the get log target operation -// typically these are obtained from a http.Request -// -// swagger:parameters getLogTarget -type GetLogTargetParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Log Target ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetLogTargetParams() beforehand. -func (o *GetLogTargetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *GetLogTargetParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetLogTargetParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetLogTargetParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetLogTargetParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetLogTargetParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/log_target/get_log_target_peer.go b/operations/log_target/get_log_target_peer.go new file mode 100644 index 00000000..1808a0ed --- /dev/null +++ b/operations/log_target/get_log_target_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetLogTargetPeerHandlerFunc turns a function with the right signature into a get log target peer handler +type GetLogTargetPeerHandlerFunc func(GetLogTargetPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetLogTargetPeerHandlerFunc) Handle(params GetLogTargetPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetLogTargetPeerHandler interface for that can handle valid get log target peer params +type GetLogTargetPeerHandler interface { + Handle(GetLogTargetPeerParams, interface{}) middleware.Responder +} + +// NewGetLogTargetPeer creates a new http.Handler for the get log target peer operation +func NewGetLogTargetPeer(ctx *middleware.Context, handler GetLogTargetPeerHandler) *GetLogTargetPeer { + return &GetLogTargetPeer{Context: ctx, Handler: handler} +} + +/* + GetLogTargetPeer swagger:route GET /services/haproxy/configuration/peers/{parent_name}/log_targets/{index} LogTarget getLogTargetPeer + +# Return one Log Target + +Returns one Log Target configuration by it's index in the specified parent. +*/ +type GetLogTargetPeer struct { + Context *middleware.Context + Handler GetLogTargetPeerHandler +} + +func (o *GetLogTargetPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetLogTargetPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/get_log_target_peer_parameters.go b/operations/log_target/get_log_target_peer_parameters.go new file mode 100644 index 00000000..27d9a7a4 --- /dev/null +++ b/operations/log_target/get_log_target_peer_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetLogTargetPeerParams creates a new GetLogTargetPeerParams object +// +// There are no default values defined in the spec. +func NewGetLogTargetPeerParams() GetLogTargetPeerParams { + + return GetLogTargetPeerParams{} +} + +// GetLogTargetPeerParams contains all the bound params for the get log target peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters getLogTargetPeer +type GetLogTargetPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetLogTargetPeerParams() beforehand. +func (o *GetLogTargetPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetLogTargetPeerParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetLogTargetPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetLogTargetPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/log_target/get_log_target_peer_responses.go b/operations/log_target/get_log_target_peer_responses.go new file mode 100644 index 00000000..6dcf5186 --- /dev/null +++ b/operations/log_target/get_log_target_peer_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetLogTargetPeerOKCode is the HTTP code returned for type GetLogTargetPeerOK +const GetLogTargetPeerOKCode int = 200 + +/* +GetLogTargetPeerOK Successful operation + +swagger:response getLogTargetPeerOK +*/ +type GetLogTargetPeerOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewGetLogTargetPeerOK creates GetLogTargetPeerOK with default headers values +func NewGetLogTargetPeerOK() *GetLogTargetPeerOK { + + return &GetLogTargetPeerOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target peer o k response +func (o *GetLogTargetPeerOK) WithConfigurationVersion(configurationVersion string) *GetLogTargetPeerOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target peer o k response +func (o *GetLogTargetPeerOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target peer o k response +func (o *GetLogTargetPeerOK) WithPayload(payload *models.LogTarget) *GetLogTargetPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target peer o k response +func (o *GetLogTargetPeerOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetLogTargetPeerNotFoundCode is the HTTP code returned for type GetLogTargetPeerNotFound +const GetLogTargetPeerNotFoundCode int = 404 + +/* +GetLogTargetPeerNotFound The specified resource was not found + +swagger:response getLogTargetPeerNotFound +*/ +type GetLogTargetPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetPeerNotFound creates GetLogTargetPeerNotFound with default headers values +func NewGetLogTargetPeerNotFound() *GetLogTargetPeerNotFound { + + return &GetLogTargetPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get log target peer not found response +func (o *GetLogTargetPeerNotFound) WithConfigurationVersion(configurationVersion string) *GetLogTargetPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target peer not found response +func (o *GetLogTargetPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target peer not found response +func (o *GetLogTargetPeerNotFound) WithPayload(payload *models.Error) *GetLogTargetPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target peer not found response +func (o *GetLogTargetPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetLogTargetPeerDefault General Error + +swagger:response getLogTargetPeerDefault +*/ +type GetLogTargetPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetLogTargetPeerDefault creates GetLogTargetPeerDefault with default headers values +func NewGetLogTargetPeerDefault(code int) *GetLogTargetPeerDefault { + if code <= 0 { + code = 500 + } + + return &GetLogTargetPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get log target peer default response +func (o *GetLogTargetPeerDefault) WithStatusCode(code int) *GetLogTargetPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get log target peer default response +func (o *GetLogTargetPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get log target peer default response +func (o *GetLogTargetPeerDefault) WithConfigurationVersion(configurationVersion string) *GetLogTargetPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get log target peer default response +func (o *GetLogTargetPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get log target peer default response +func (o *GetLogTargetPeerDefault) WithPayload(payload *models.Error) *GetLogTargetPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get log target peer default response +func (o *GetLogTargetPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetLogTargetPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/get_log_target_peer_urlbuilder.go b/operations/log_target/get_log_target_peer_urlbuilder.go new file mode 100644 index 00000000..02979f73 --- /dev/null +++ b/operations/log_target/get_log_target_peer_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetLogTargetPeerURL generates an URL for the get log target peer operation +type GetLogTargetPeerURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetPeerURL) WithBasePath(bp string) *GetLogTargetPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetLogTargetPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetLogTargetPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetLogTargetPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetLogTargetPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetLogTargetPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetLogTargetPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetLogTargetPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetLogTargetPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetLogTargetPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetLogTargetPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/get_log_target_responses.go b/operations/log_target/get_log_target_responses.go deleted file mode 100644 index 0af9be61..00000000 --- a/operations/log_target/get_log_target_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetLogTargetOKCode is the HTTP code returned for type GetLogTargetOK -const GetLogTargetOKCode int = 200 - -/*GetLogTargetOK Successful operation - -swagger:response getLogTargetOK -*/ -type GetLogTargetOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetLogTargetOKBody `json:"body,omitempty"` -} - -// NewGetLogTargetOK creates GetLogTargetOK with default headers values -func NewGetLogTargetOK() *GetLogTargetOK { - - return &GetLogTargetOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get log target o k response -func (o *GetLogTargetOK) WithConfigurationVersion(configurationVersion int64) *GetLogTargetOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get log target o k response -func (o *GetLogTargetOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get log target o k response -func (o *GetLogTargetOK) WithPayload(payload *GetLogTargetOKBody) *GetLogTargetOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get log target o k response -func (o *GetLogTargetOK) SetPayload(payload *GetLogTargetOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetLogTargetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetLogTargetNotFoundCode is the HTTP code returned for type GetLogTargetNotFound -const GetLogTargetNotFoundCode int = 404 - -/*GetLogTargetNotFound The specified resource was not found - -swagger:response getLogTargetNotFound -*/ -type GetLogTargetNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetLogTargetNotFound creates GetLogTargetNotFound with default headers values -func NewGetLogTargetNotFound() *GetLogTargetNotFound { - - return &GetLogTargetNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get log target not found response -func (o *GetLogTargetNotFound) WithConfigurationVersion(configurationVersion int64) *GetLogTargetNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get log target not found response -func (o *GetLogTargetNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get log target not found response -func (o *GetLogTargetNotFound) WithPayload(payload *models.Error) *GetLogTargetNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get log target not found response -func (o *GetLogTargetNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetLogTargetNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetLogTargetDefault General Error - -swagger:response getLogTargetDefault -*/ -type GetLogTargetDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetLogTargetDefault creates GetLogTargetDefault with default headers values -func NewGetLogTargetDefault(code int) *GetLogTargetDefault { - if code <= 0 { - code = 500 - } - - return &GetLogTargetDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get log target default response -func (o *GetLogTargetDefault) WithStatusCode(code int) *GetLogTargetDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get log target default response -func (o *GetLogTargetDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get log target default response -func (o *GetLogTargetDefault) WithConfigurationVersion(configurationVersion int64) *GetLogTargetDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get log target default response -func (o *GetLogTargetDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get log target default response -func (o *GetLogTargetDefault) WithPayload(payload *models.Error) *GetLogTargetDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get log target default response -func (o *GetLogTargetDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetLogTargetDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/log_target/get_log_target_urlbuilder.go b/operations/log_target/get_log_target_urlbuilder.go deleted file mode 100644 index 0a5b0b73..00000000 --- a/operations/log_target/get_log_target_urlbuilder.go +++ /dev/null @@ -1,142 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// GetLogTargetURL generates an URL for the get log target operation -type GetLogTargetURL struct { - ID int64 - - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetLogTargetURL) WithBasePath(bp string) *GetLogTargetURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetLogTargetURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetLogTargetURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/log_targets/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on GetLogTargetURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetLogTargetURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetLogTargetURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetLogTargetURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetLogTargetURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetLogTargetURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetLogTargetURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/log_target/get_log_targets.go b/operations/log_target/get_log_targets.go deleted file mode 100644 index 3c56c730..00000000 --- a/operations/log_target/get_log_targets.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetLogTargetsHandlerFunc turns a function with the right signature into a get log targets handler -type GetLogTargetsHandlerFunc func(GetLogTargetsParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetLogTargetsHandlerFunc) Handle(params GetLogTargetsParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetLogTargetsHandler interface for that can handle valid get log targets params -type GetLogTargetsHandler interface { - Handle(GetLogTargetsParams, interface{}) middleware.Responder -} - -// NewGetLogTargets creates a new http.Handler for the get log targets operation -func NewGetLogTargets(ctx *middleware.Context, handler GetLogTargetsHandler) *GetLogTargets { - return &GetLogTargets{Context: ctx, Handler: handler} -} - -/*GetLogTargets swagger:route GET /services/haproxy/configuration/log_targets LogTarget getLogTargets - -Return an array of all Log Targets - -Returns all Log Targets that are configured in specified parent. - -*/ -type GetLogTargets struct { - Context *middleware.Context - Handler GetLogTargetsHandler -} - -func (o *GetLogTargets) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetLogTargetsParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetLogTargetsOKBody get log targets o k body -// swagger:model GetLogTargetsOKBody -type GetLogTargetsOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.LogTargets `json:"data"` -} - -// Validate validates this get log targets o k body -func (o *GetLogTargetsOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetLogTargetsOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getLogTargetsOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getLogTargetsOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetLogTargetsOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetLogTargetsOKBody) UnmarshalBinary(b []byte) error { - var res GetLogTargetsOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/log_target/get_log_targets_parameters.go b/operations/log_target/get_log_targets_parameters.go deleted file mode 100644 index bbd14580..00000000 --- a/operations/log_target/get_log_targets_parameters.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetLogTargetsParams creates a new GetLogTargetsParams object -// no default values defined in spec. -func NewGetLogTargetsParams() GetLogTargetsParams { - - return GetLogTargetsParams{} -} - -// GetLogTargetsParams contains all the bound params for the get log targets operation -// typically these are obtained from a http.Request -// -// swagger:parameters getLogTargets -type GetLogTargetsParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetLogTargetsParams() beforehand. -func (o *GetLogTargetsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetLogTargetsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetLogTargetsParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetLogTargetsParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetLogTargetsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/log_target/get_log_targets_responses.go b/operations/log_target/get_log_targets_responses.go deleted file mode 100644 index 7d81d6c0..00000000 --- a/operations/log_target/get_log_targets_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetLogTargetsOKCode is the HTTP code returned for type GetLogTargetsOK -const GetLogTargetsOKCode int = 200 - -/*GetLogTargetsOK Successful operation - -swagger:response getLogTargetsOK -*/ -type GetLogTargetsOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetLogTargetsOKBody `json:"body,omitempty"` -} - -// NewGetLogTargetsOK creates GetLogTargetsOK with default headers values -func NewGetLogTargetsOK() *GetLogTargetsOK { - - return &GetLogTargetsOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get log targets o k response -func (o *GetLogTargetsOK) WithConfigurationVersion(configurationVersion int64) *GetLogTargetsOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get log targets o k response -func (o *GetLogTargetsOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get log targets o k response -func (o *GetLogTargetsOK) WithPayload(payload *GetLogTargetsOKBody) *GetLogTargetsOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get log targets o k response -func (o *GetLogTargetsOK) SetPayload(payload *GetLogTargetsOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetLogTargetsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetLogTargetsDefault General Error - -swagger:response getLogTargetsDefault -*/ -type GetLogTargetsDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetLogTargetsDefault creates GetLogTargetsDefault with default headers values -func NewGetLogTargetsDefault(code int) *GetLogTargetsDefault { - if code <= 0 { - code = 500 - } - - return &GetLogTargetsDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get log targets default response -func (o *GetLogTargetsDefault) WithStatusCode(code int) *GetLogTargetsDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get log targets default response -func (o *GetLogTargetsDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get log targets default response -func (o *GetLogTargetsDefault) WithConfigurationVersion(configurationVersion int64) *GetLogTargetsDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get log targets default response -func (o *GetLogTargetsDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get log targets default response -func (o *GetLogTargetsDefault) WithPayload(payload *models.Error) *GetLogTargetsDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get log targets default response -func (o *GetLogTargetsDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetLogTargetsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/log_target/get_log_targets_urlbuilder.go b/operations/log_target/get_log_targets_urlbuilder.go deleted file mode 100644 index f590fda0..00000000 --- a/operations/log_target/get_log_targets_urlbuilder.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetLogTargetsURL generates an URL for the get log targets operation -type GetLogTargetsURL struct { - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetLogTargetsURL) WithBasePath(bp string) *GetLogTargetsURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetLogTargetsURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetLogTargetsURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/log_targets" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetLogTargetsURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetLogTargetsURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetLogTargetsURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetLogTargetsURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetLogTargetsURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetLogTargetsURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/log_target/replace_all_log_target_backend.go b/operations/log_target/replace_all_log_target_backend.go new file mode 100644 index 00000000..4b6eebd2 --- /dev/null +++ b/operations/log_target/replace_all_log_target_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllLogTargetBackendHandlerFunc turns a function with the right signature into a replace all log target backend handler +type ReplaceAllLogTargetBackendHandlerFunc func(ReplaceAllLogTargetBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllLogTargetBackendHandlerFunc) Handle(params ReplaceAllLogTargetBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllLogTargetBackendHandler interface for that can handle valid replace all log target backend params +type ReplaceAllLogTargetBackendHandler interface { + Handle(ReplaceAllLogTargetBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllLogTargetBackend creates a new http.Handler for the replace all log target backend operation +func NewReplaceAllLogTargetBackend(ctx *middleware.Context, handler ReplaceAllLogTargetBackendHandler) *ReplaceAllLogTargetBackend { + return &ReplaceAllLogTargetBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllLogTargetBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/log_targets LogTarget replaceAllLogTargetBackend + +# Replace a Log Target list + +Replaces a whole list of Log Targets with the list given in parameter +*/ +type ReplaceAllLogTargetBackend struct { + Context *middleware.Context + Handler ReplaceAllLogTargetBackendHandler +} + +func (o *ReplaceAllLogTargetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllLogTargetBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_all_log_target_backend_parameters.go b/operations/log_target/replace_all_log_target_backend_parameters.go new file mode 100644 index 00000000..ef4dd2f2 --- /dev/null +++ b/operations/log_target/replace_all_log_target_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllLogTargetBackendParams creates a new ReplaceAllLogTargetBackendParams object +// with the default values initialized. +func NewReplaceAllLogTargetBackendParams() ReplaceAllLogTargetBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllLogTargetBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllLogTargetBackendParams contains all the bound params for the replace all log target backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllLogTargetBackend +type ReplaceAllLogTargetBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.LogTargets + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllLogTargetBackendParams() beforehand. +func (o *ReplaceAllLogTargetBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTargets + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllLogTargetBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllLogTargetBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllLogTargetBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllLogTargetBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllLogTargetBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_all_log_target_backend_responses.go b/operations/log_target/replace_all_log_target_backend_responses.go new file mode 100644 index 00000000..fbbc6cd1 --- /dev/null +++ b/operations/log_target/replace_all_log_target_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllLogTargetBackendOKCode is the HTTP code returned for type ReplaceAllLogTargetBackendOK +const ReplaceAllLogTargetBackendOKCode int = 200 + +/* +ReplaceAllLogTargetBackendOK All Log Target lines replaced + +swagger:response replaceAllLogTargetBackendOK +*/ +type ReplaceAllLogTargetBackendOK struct { + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetBackendOK creates ReplaceAllLogTargetBackendOK with default headers values +func NewReplaceAllLogTargetBackendOK() *ReplaceAllLogTargetBackendOK { + + return &ReplaceAllLogTargetBackendOK{} +} + +// WithPayload adds the payload to the replace all log target backend o k response +func (o *ReplaceAllLogTargetBackendOK) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target backend o k response +func (o *ReplaceAllLogTargetBackendOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetBackendAcceptedCode is the HTTP code returned for type ReplaceAllLogTargetBackendAccepted +const ReplaceAllLogTargetBackendAcceptedCode int = 202 + +/* +ReplaceAllLogTargetBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllLogTargetBackendAccepted +*/ +type ReplaceAllLogTargetBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetBackendAccepted creates ReplaceAllLogTargetBackendAccepted with default headers values +func NewReplaceAllLogTargetBackendAccepted() *ReplaceAllLogTargetBackendAccepted { + + return &ReplaceAllLogTargetBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all log target backend accepted response +func (o *ReplaceAllLogTargetBackendAccepted) WithReloadID(reloadID string) *ReplaceAllLogTargetBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all log target backend accepted response +func (o *ReplaceAllLogTargetBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all log target backend accepted response +func (o *ReplaceAllLogTargetBackendAccepted) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target backend accepted response +func (o *ReplaceAllLogTargetBackendAccepted) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetBackendBadRequestCode is the HTTP code returned for type ReplaceAllLogTargetBackendBadRequest +const ReplaceAllLogTargetBackendBadRequestCode int = 400 + +/* +ReplaceAllLogTargetBackendBadRequest Bad request + +swagger:response replaceAllLogTargetBackendBadRequest +*/ +type ReplaceAllLogTargetBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetBackendBadRequest creates ReplaceAllLogTargetBackendBadRequest with default headers values +func NewReplaceAllLogTargetBackendBadRequest() *ReplaceAllLogTargetBackendBadRequest { + + return &ReplaceAllLogTargetBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target backend bad request response +func (o *ReplaceAllLogTargetBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target backend bad request response +func (o *ReplaceAllLogTargetBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target backend bad request response +func (o *ReplaceAllLogTargetBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllLogTargetBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target backend bad request response +func (o *ReplaceAllLogTargetBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllLogTargetBackendDefault General Error + +swagger:response replaceAllLogTargetBackendDefault +*/ +type ReplaceAllLogTargetBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetBackendDefault creates ReplaceAllLogTargetBackendDefault with default headers values +func NewReplaceAllLogTargetBackendDefault(code int) *ReplaceAllLogTargetBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllLogTargetBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all log target backend default response +func (o *ReplaceAllLogTargetBackendDefault) WithStatusCode(code int) *ReplaceAllLogTargetBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all log target backend default response +func (o *ReplaceAllLogTargetBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target backend default response +func (o *ReplaceAllLogTargetBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target backend default response +func (o *ReplaceAllLogTargetBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target backend default response +func (o *ReplaceAllLogTargetBackendDefault) WithPayload(payload *models.Error) *ReplaceAllLogTargetBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target backend default response +func (o *ReplaceAllLogTargetBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_all_log_target_backend_urlbuilder.go b/operations/log_target/replace_all_log_target_backend_urlbuilder.go new file mode 100644 index 00000000..a8d1ba75 --- /dev/null +++ b/operations/log_target/replace_all_log_target_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllLogTargetBackendURL generates an URL for the replace all log target backend operation +type ReplaceAllLogTargetBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetBackendURL) WithBasePath(bp string) *ReplaceAllLogTargetBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllLogTargetBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllLogTargetBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllLogTargetBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllLogTargetBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllLogTargetBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllLogTargetBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllLogTargetBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllLogTargetBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_all_log_target_defaults.go b/operations/log_target/replace_all_log_target_defaults.go new file mode 100644 index 00000000..efa3728b --- /dev/null +++ b/operations/log_target/replace_all_log_target_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllLogTargetDefaultsHandlerFunc turns a function with the right signature into a replace all log target defaults handler +type ReplaceAllLogTargetDefaultsHandlerFunc func(ReplaceAllLogTargetDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllLogTargetDefaultsHandlerFunc) Handle(params ReplaceAllLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllLogTargetDefaultsHandler interface for that can handle valid replace all log target defaults params +type ReplaceAllLogTargetDefaultsHandler interface { + Handle(ReplaceAllLogTargetDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllLogTargetDefaults creates a new http.Handler for the replace all log target defaults operation +func NewReplaceAllLogTargetDefaults(ctx *middleware.Context, handler ReplaceAllLogTargetDefaultsHandler) *ReplaceAllLogTargetDefaults { + return &ReplaceAllLogTargetDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllLogTargetDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/log_targets LogTarget replaceAllLogTargetDefaults + +# Replace a Log Target list + +Replaces a whole list of Log Targets with the list given in parameter +*/ +type ReplaceAllLogTargetDefaults struct { + Context *middleware.Context + Handler ReplaceAllLogTargetDefaultsHandler +} + +func (o *ReplaceAllLogTargetDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllLogTargetDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_all_log_target_defaults_parameters.go b/operations/log_target/replace_all_log_target_defaults_parameters.go new file mode 100644 index 00000000..3a5c341a --- /dev/null +++ b/operations/log_target/replace_all_log_target_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllLogTargetDefaultsParams creates a new ReplaceAllLogTargetDefaultsParams object +// with the default values initialized. +func NewReplaceAllLogTargetDefaultsParams() ReplaceAllLogTargetDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllLogTargetDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllLogTargetDefaultsParams contains all the bound params for the replace all log target defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllLogTargetDefaults +type ReplaceAllLogTargetDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.LogTargets + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllLogTargetDefaultsParams() beforehand. +func (o *ReplaceAllLogTargetDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTargets + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllLogTargetDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllLogTargetDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllLogTargetDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllLogTargetDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllLogTargetDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_all_log_target_defaults_responses.go b/operations/log_target/replace_all_log_target_defaults_responses.go new file mode 100644 index 00000000..a4c088b9 --- /dev/null +++ b/operations/log_target/replace_all_log_target_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllLogTargetDefaultsOKCode is the HTTP code returned for type ReplaceAllLogTargetDefaultsOK +const ReplaceAllLogTargetDefaultsOKCode int = 200 + +/* +ReplaceAllLogTargetDefaultsOK All Log Target lines replaced + +swagger:response replaceAllLogTargetDefaultsOK +*/ +type ReplaceAllLogTargetDefaultsOK struct { + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetDefaultsOK creates ReplaceAllLogTargetDefaultsOK with default headers values +func NewReplaceAllLogTargetDefaultsOK() *ReplaceAllLogTargetDefaultsOK { + + return &ReplaceAllLogTargetDefaultsOK{} +} + +// WithPayload adds the payload to the replace all log target defaults o k response +func (o *ReplaceAllLogTargetDefaultsOK) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target defaults o k response +func (o *ReplaceAllLogTargetDefaultsOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllLogTargetDefaultsAccepted +const ReplaceAllLogTargetDefaultsAcceptedCode int = 202 + +/* +ReplaceAllLogTargetDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllLogTargetDefaultsAccepted +*/ +type ReplaceAllLogTargetDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetDefaultsAccepted creates ReplaceAllLogTargetDefaultsAccepted with default headers values +func NewReplaceAllLogTargetDefaultsAccepted() *ReplaceAllLogTargetDefaultsAccepted { + + return &ReplaceAllLogTargetDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all log target defaults accepted response +func (o *ReplaceAllLogTargetDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllLogTargetDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all log target defaults accepted response +func (o *ReplaceAllLogTargetDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all log target defaults accepted response +func (o *ReplaceAllLogTargetDefaultsAccepted) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target defaults accepted response +func (o *ReplaceAllLogTargetDefaultsAccepted) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllLogTargetDefaultsBadRequest +const ReplaceAllLogTargetDefaultsBadRequestCode int = 400 + +/* +ReplaceAllLogTargetDefaultsBadRequest Bad request + +swagger:response replaceAllLogTargetDefaultsBadRequest +*/ +type ReplaceAllLogTargetDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetDefaultsBadRequest creates ReplaceAllLogTargetDefaultsBadRequest with default headers values +func NewReplaceAllLogTargetDefaultsBadRequest() *ReplaceAllLogTargetDefaultsBadRequest { + + return &ReplaceAllLogTargetDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target defaults bad request response +func (o *ReplaceAllLogTargetDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target defaults bad request response +func (o *ReplaceAllLogTargetDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target defaults bad request response +func (o *ReplaceAllLogTargetDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllLogTargetDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target defaults bad request response +func (o *ReplaceAllLogTargetDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllLogTargetDefaultsDefault General Error + +swagger:response replaceAllLogTargetDefaultsDefault +*/ +type ReplaceAllLogTargetDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetDefaultsDefault creates ReplaceAllLogTargetDefaultsDefault with default headers values +func NewReplaceAllLogTargetDefaultsDefault(code int) *ReplaceAllLogTargetDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllLogTargetDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all log target defaults default response +func (o *ReplaceAllLogTargetDefaultsDefault) WithStatusCode(code int) *ReplaceAllLogTargetDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all log target defaults default response +func (o *ReplaceAllLogTargetDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target defaults default response +func (o *ReplaceAllLogTargetDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target defaults default response +func (o *ReplaceAllLogTargetDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target defaults default response +func (o *ReplaceAllLogTargetDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllLogTargetDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target defaults default response +func (o *ReplaceAllLogTargetDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_all_log_target_defaults_urlbuilder.go b/operations/log_target/replace_all_log_target_defaults_urlbuilder.go new file mode 100644 index 00000000..cb10eba2 --- /dev/null +++ b/operations/log_target/replace_all_log_target_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllLogTargetDefaultsURL generates an URL for the replace all log target defaults operation +type ReplaceAllLogTargetDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetDefaultsURL) WithBasePath(bp string) *ReplaceAllLogTargetDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllLogTargetDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllLogTargetDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllLogTargetDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllLogTargetDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllLogTargetDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllLogTargetDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllLogTargetDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllLogTargetDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_all_log_target_frontend.go b/operations/log_target/replace_all_log_target_frontend.go new file mode 100644 index 00000000..5c9c5cfe --- /dev/null +++ b/operations/log_target/replace_all_log_target_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllLogTargetFrontendHandlerFunc turns a function with the right signature into a replace all log target frontend handler +type ReplaceAllLogTargetFrontendHandlerFunc func(ReplaceAllLogTargetFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllLogTargetFrontendHandlerFunc) Handle(params ReplaceAllLogTargetFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllLogTargetFrontendHandler interface for that can handle valid replace all log target frontend params +type ReplaceAllLogTargetFrontendHandler interface { + Handle(ReplaceAllLogTargetFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllLogTargetFrontend creates a new http.Handler for the replace all log target frontend operation +func NewReplaceAllLogTargetFrontend(ctx *middleware.Context, handler ReplaceAllLogTargetFrontendHandler) *ReplaceAllLogTargetFrontend { + return &ReplaceAllLogTargetFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllLogTargetFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/log_targets LogTarget replaceAllLogTargetFrontend + +# Replace a Log Target list + +Replaces a whole list of Log Targets with the list given in parameter +*/ +type ReplaceAllLogTargetFrontend struct { + Context *middleware.Context + Handler ReplaceAllLogTargetFrontendHandler +} + +func (o *ReplaceAllLogTargetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllLogTargetFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_all_log_target_frontend_parameters.go b/operations/log_target/replace_all_log_target_frontend_parameters.go new file mode 100644 index 00000000..f0d87f43 --- /dev/null +++ b/operations/log_target/replace_all_log_target_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllLogTargetFrontendParams creates a new ReplaceAllLogTargetFrontendParams object +// with the default values initialized. +func NewReplaceAllLogTargetFrontendParams() ReplaceAllLogTargetFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllLogTargetFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllLogTargetFrontendParams contains all the bound params for the replace all log target frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllLogTargetFrontend +type ReplaceAllLogTargetFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.LogTargets + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllLogTargetFrontendParams() beforehand. +func (o *ReplaceAllLogTargetFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTargets + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllLogTargetFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllLogTargetFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllLogTargetFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllLogTargetFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllLogTargetFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_all_log_target_frontend_responses.go b/operations/log_target/replace_all_log_target_frontend_responses.go new file mode 100644 index 00000000..b866bdb1 --- /dev/null +++ b/operations/log_target/replace_all_log_target_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllLogTargetFrontendOKCode is the HTTP code returned for type ReplaceAllLogTargetFrontendOK +const ReplaceAllLogTargetFrontendOKCode int = 200 + +/* +ReplaceAllLogTargetFrontendOK All Log Target lines replaced + +swagger:response replaceAllLogTargetFrontendOK +*/ +type ReplaceAllLogTargetFrontendOK struct { + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetFrontendOK creates ReplaceAllLogTargetFrontendOK with default headers values +func NewReplaceAllLogTargetFrontendOK() *ReplaceAllLogTargetFrontendOK { + + return &ReplaceAllLogTargetFrontendOK{} +} + +// WithPayload adds the payload to the replace all log target frontend o k response +func (o *ReplaceAllLogTargetFrontendOK) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target frontend o k response +func (o *ReplaceAllLogTargetFrontendOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetFrontendAcceptedCode is the HTTP code returned for type ReplaceAllLogTargetFrontendAccepted +const ReplaceAllLogTargetFrontendAcceptedCode int = 202 + +/* +ReplaceAllLogTargetFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllLogTargetFrontendAccepted +*/ +type ReplaceAllLogTargetFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetFrontendAccepted creates ReplaceAllLogTargetFrontendAccepted with default headers values +func NewReplaceAllLogTargetFrontendAccepted() *ReplaceAllLogTargetFrontendAccepted { + + return &ReplaceAllLogTargetFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all log target frontend accepted response +func (o *ReplaceAllLogTargetFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllLogTargetFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all log target frontend accepted response +func (o *ReplaceAllLogTargetFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all log target frontend accepted response +func (o *ReplaceAllLogTargetFrontendAccepted) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target frontend accepted response +func (o *ReplaceAllLogTargetFrontendAccepted) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetFrontendBadRequestCode is the HTTP code returned for type ReplaceAllLogTargetFrontendBadRequest +const ReplaceAllLogTargetFrontendBadRequestCode int = 400 + +/* +ReplaceAllLogTargetFrontendBadRequest Bad request + +swagger:response replaceAllLogTargetFrontendBadRequest +*/ +type ReplaceAllLogTargetFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetFrontendBadRequest creates ReplaceAllLogTargetFrontendBadRequest with default headers values +func NewReplaceAllLogTargetFrontendBadRequest() *ReplaceAllLogTargetFrontendBadRequest { + + return &ReplaceAllLogTargetFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target frontend bad request response +func (o *ReplaceAllLogTargetFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target frontend bad request response +func (o *ReplaceAllLogTargetFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target frontend bad request response +func (o *ReplaceAllLogTargetFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllLogTargetFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target frontend bad request response +func (o *ReplaceAllLogTargetFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllLogTargetFrontendDefault General Error + +swagger:response replaceAllLogTargetFrontendDefault +*/ +type ReplaceAllLogTargetFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetFrontendDefault creates ReplaceAllLogTargetFrontendDefault with default headers values +func NewReplaceAllLogTargetFrontendDefault(code int) *ReplaceAllLogTargetFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllLogTargetFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all log target frontend default response +func (o *ReplaceAllLogTargetFrontendDefault) WithStatusCode(code int) *ReplaceAllLogTargetFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all log target frontend default response +func (o *ReplaceAllLogTargetFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target frontend default response +func (o *ReplaceAllLogTargetFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target frontend default response +func (o *ReplaceAllLogTargetFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target frontend default response +func (o *ReplaceAllLogTargetFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllLogTargetFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target frontend default response +func (o *ReplaceAllLogTargetFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_all_log_target_frontend_urlbuilder.go b/operations/log_target/replace_all_log_target_frontend_urlbuilder.go new file mode 100644 index 00000000..2ed116d6 --- /dev/null +++ b/operations/log_target/replace_all_log_target_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllLogTargetFrontendURL generates an URL for the replace all log target frontend operation +type ReplaceAllLogTargetFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetFrontendURL) WithBasePath(bp string) *ReplaceAllLogTargetFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllLogTargetFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllLogTargetFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllLogTargetFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllLogTargetFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllLogTargetFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllLogTargetFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllLogTargetFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllLogTargetFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_all_log_target_global.go b/operations/log_target/replace_all_log_target_global.go new file mode 100644 index 00000000..35b19617 --- /dev/null +++ b/operations/log_target/replace_all_log_target_global.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllLogTargetGlobalHandlerFunc turns a function with the right signature into a replace all log target global handler +type ReplaceAllLogTargetGlobalHandlerFunc func(ReplaceAllLogTargetGlobalParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllLogTargetGlobalHandlerFunc) Handle(params ReplaceAllLogTargetGlobalParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllLogTargetGlobalHandler interface for that can handle valid replace all log target global params +type ReplaceAllLogTargetGlobalHandler interface { + Handle(ReplaceAllLogTargetGlobalParams, interface{}) middleware.Responder +} + +// NewReplaceAllLogTargetGlobal creates a new http.Handler for the replace all log target global operation +func NewReplaceAllLogTargetGlobal(ctx *middleware.Context, handler ReplaceAllLogTargetGlobalHandler) *ReplaceAllLogTargetGlobal { + return &ReplaceAllLogTargetGlobal{Context: ctx, Handler: handler} +} + +/* + ReplaceAllLogTargetGlobal swagger:route PUT /services/haproxy/configuration/global/log_targets LogTarget replaceAllLogTargetGlobal + +# Replace a Log Target list + +Replaces a whole list of Log Targets with the list given in parameter +*/ +type ReplaceAllLogTargetGlobal struct { + Context *middleware.Context + Handler ReplaceAllLogTargetGlobalHandler +} + +func (o *ReplaceAllLogTargetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllLogTargetGlobalParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_all_log_target_global_parameters.go b/operations/log_target/replace_all_log_target_global_parameters.go new file mode 100644 index 00000000..557b6d9e --- /dev/null +++ b/operations/log_target/replace_all_log_target_global_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllLogTargetGlobalParams creates a new ReplaceAllLogTargetGlobalParams object +// with the default values initialized. +func NewReplaceAllLogTargetGlobalParams() ReplaceAllLogTargetGlobalParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllLogTargetGlobalParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllLogTargetGlobalParams contains all the bound params for the replace all log target global operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllLogTargetGlobal +type ReplaceAllLogTargetGlobalParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.LogTargets + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllLogTargetGlobalParams() beforehand. +func (o *ReplaceAllLogTargetGlobalParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTargets + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllLogTargetGlobalParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllLogTargetGlobalParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllLogTargetGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllLogTargetGlobalParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_all_log_target_global_responses.go b/operations/log_target/replace_all_log_target_global_responses.go new file mode 100644 index 00000000..3f3a3c61 --- /dev/null +++ b/operations/log_target/replace_all_log_target_global_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllLogTargetGlobalOKCode is the HTTP code returned for type ReplaceAllLogTargetGlobalOK +const ReplaceAllLogTargetGlobalOKCode int = 200 + +/* +ReplaceAllLogTargetGlobalOK All Log Target lines replaced + +swagger:response replaceAllLogTargetGlobalOK +*/ +type ReplaceAllLogTargetGlobalOK struct { + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetGlobalOK creates ReplaceAllLogTargetGlobalOK with default headers values +func NewReplaceAllLogTargetGlobalOK() *ReplaceAllLogTargetGlobalOK { + + return &ReplaceAllLogTargetGlobalOK{} +} + +// WithPayload adds the payload to the replace all log target global o k response +func (o *ReplaceAllLogTargetGlobalOK) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetGlobalOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target global o k response +func (o *ReplaceAllLogTargetGlobalOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetGlobalOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetGlobalAcceptedCode is the HTTP code returned for type ReplaceAllLogTargetGlobalAccepted +const ReplaceAllLogTargetGlobalAcceptedCode int = 202 + +/* +ReplaceAllLogTargetGlobalAccepted Configuration change accepted and reload requested + +swagger:response replaceAllLogTargetGlobalAccepted +*/ +type ReplaceAllLogTargetGlobalAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetGlobalAccepted creates ReplaceAllLogTargetGlobalAccepted with default headers values +func NewReplaceAllLogTargetGlobalAccepted() *ReplaceAllLogTargetGlobalAccepted { + + return &ReplaceAllLogTargetGlobalAccepted{} +} + +// WithReloadID adds the reloadId to the replace all log target global accepted response +func (o *ReplaceAllLogTargetGlobalAccepted) WithReloadID(reloadID string) *ReplaceAllLogTargetGlobalAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all log target global accepted response +func (o *ReplaceAllLogTargetGlobalAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all log target global accepted response +func (o *ReplaceAllLogTargetGlobalAccepted) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetGlobalAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target global accepted response +func (o *ReplaceAllLogTargetGlobalAccepted) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetGlobalAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetGlobalBadRequestCode is the HTTP code returned for type ReplaceAllLogTargetGlobalBadRequest +const ReplaceAllLogTargetGlobalBadRequestCode int = 400 + +/* +ReplaceAllLogTargetGlobalBadRequest Bad request + +swagger:response replaceAllLogTargetGlobalBadRequest +*/ +type ReplaceAllLogTargetGlobalBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetGlobalBadRequest creates ReplaceAllLogTargetGlobalBadRequest with default headers values +func NewReplaceAllLogTargetGlobalBadRequest() *ReplaceAllLogTargetGlobalBadRequest { + + return &ReplaceAllLogTargetGlobalBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target global bad request response +func (o *ReplaceAllLogTargetGlobalBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetGlobalBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target global bad request response +func (o *ReplaceAllLogTargetGlobalBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target global bad request response +func (o *ReplaceAllLogTargetGlobalBadRequest) WithPayload(payload *models.Error) *ReplaceAllLogTargetGlobalBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target global bad request response +func (o *ReplaceAllLogTargetGlobalBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetGlobalBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllLogTargetGlobalDefault General Error + +swagger:response replaceAllLogTargetGlobalDefault +*/ +type ReplaceAllLogTargetGlobalDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetGlobalDefault creates ReplaceAllLogTargetGlobalDefault with default headers values +func NewReplaceAllLogTargetGlobalDefault(code int) *ReplaceAllLogTargetGlobalDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllLogTargetGlobalDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all log target global default response +func (o *ReplaceAllLogTargetGlobalDefault) WithStatusCode(code int) *ReplaceAllLogTargetGlobalDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all log target global default response +func (o *ReplaceAllLogTargetGlobalDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target global default response +func (o *ReplaceAllLogTargetGlobalDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetGlobalDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target global default response +func (o *ReplaceAllLogTargetGlobalDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target global default response +func (o *ReplaceAllLogTargetGlobalDefault) WithPayload(payload *models.Error) *ReplaceAllLogTargetGlobalDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target global default response +func (o *ReplaceAllLogTargetGlobalDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetGlobalDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_all_log_target_global_urlbuilder.go b/operations/log_target/replace_all_log_target_global_urlbuilder.go new file mode 100644 index 00000000..d621cf4d --- /dev/null +++ b/operations/log_target/replace_all_log_target_global_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ReplaceAllLogTargetGlobalURL generates an URL for the replace all log target global operation +type ReplaceAllLogTargetGlobalURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetGlobalURL) WithBasePath(bp string) *ReplaceAllLogTargetGlobalURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetGlobalURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllLogTargetGlobalURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/global/log_targets" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllLogTargetGlobalURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllLogTargetGlobalURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllLogTargetGlobalURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllLogTargetGlobalURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllLogTargetGlobalURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllLogTargetGlobalURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_all_log_target_log_forward.go b/operations/log_target/replace_all_log_target_log_forward.go new file mode 100644 index 00000000..7cd739a1 --- /dev/null +++ b/operations/log_target/replace_all_log_target_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllLogTargetLogForwardHandlerFunc turns a function with the right signature into a replace all log target log forward handler +type ReplaceAllLogTargetLogForwardHandlerFunc func(ReplaceAllLogTargetLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllLogTargetLogForwardHandlerFunc) Handle(params ReplaceAllLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllLogTargetLogForwardHandler interface for that can handle valid replace all log target log forward params +type ReplaceAllLogTargetLogForwardHandler interface { + Handle(ReplaceAllLogTargetLogForwardParams, interface{}) middleware.Responder +} + +// NewReplaceAllLogTargetLogForward creates a new http.Handler for the replace all log target log forward operation +func NewReplaceAllLogTargetLogForward(ctx *middleware.Context, handler ReplaceAllLogTargetLogForwardHandler) *ReplaceAllLogTargetLogForward { + return &ReplaceAllLogTargetLogForward{Context: ctx, Handler: handler} +} + +/* + ReplaceAllLogTargetLogForward swagger:route PUT /services/haproxy/configuration/log_forwards/{parent_name}/log_targets LogTarget replaceAllLogTargetLogForward + +# Replace a Log Target list + +Replaces a whole list of Log Targets with the list given in parameter +*/ +type ReplaceAllLogTargetLogForward struct { + Context *middleware.Context + Handler ReplaceAllLogTargetLogForwardHandler +} + +func (o *ReplaceAllLogTargetLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllLogTargetLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_all_log_target_log_forward_parameters.go b/operations/log_target/replace_all_log_target_log_forward_parameters.go new file mode 100644 index 00000000..39b16410 --- /dev/null +++ b/operations/log_target/replace_all_log_target_log_forward_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllLogTargetLogForwardParams creates a new ReplaceAllLogTargetLogForwardParams object +// with the default values initialized. +func NewReplaceAllLogTargetLogForwardParams() ReplaceAllLogTargetLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllLogTargetLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllLogTargetLogForwardParams contains all the bound params for the replace all log target log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllLogTargetLogForward +type ReplaceAllLogTargetLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.LogTargets + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllLogTargetLogForwardParams() beforehand. +func (o *ReplaceAllLogTargetLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTargets + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllLogTargetLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllLogTargetLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllLogTargetLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllLogTargetLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllLogTargetLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_all_log_target_log_forward_responses.go b/operations/log_target/replace_all_log_target_log_forward_responses.go new file mode 100644 index 00000000..689e8aad --- /dev/null +++ b/operations/log_target/replace_all_log_target_log_forward_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllLogTargetLogForwardOKCode is the HTTP code returned for type ReplaceAllLogTargetLogForwardOK +const ReplaceAllLogTargetLogForwardOKCode int = 200 + +/* +ReplaceAllLogTargetLogForwardOK All Log Target lines replaced + +swagger:response replaceAllLogTargetLogForwardOK +*/ +type ReplaceAllLogTargetLogForwardOK struct { + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetLogForwardOK creates ReplaceAllLogTargetLogForwardOK with default headers values +func NewReplaceAllLogTargetLogForwardOK() *ReplaceAllLogTargetLogForwardOK { + + return &ReplaceAllLogTargetLogForwardOK{} +} + +// WithPayload adds the payload to the replace all log target log forward o k response +func (o *ReplaceAllLogTargetLogForwardOK) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target log forward o k response +func (o *ReplaceAllLogTargetLogForwardOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetLogForwardAcceptedCode is the HTTP code returned for type ReplaceAllLogTargetLogForwardAccepted +const ReplaceAllLogTargetLogForwardAcceptedCode int = 202 + +/* +ReplaceAllLogTargetLogForwardAccepted Configuration change accepted and reload requested + +swagger:response replaceAllLogTargetLogForwardAccepted +*/ +type ReplaceAllLogTargetLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetLogForwardAccepted creates ReplaceAllLogTargetLogForwardAccepted with default headers values +func NewReplaceAllLogTargetLogForwardAccepted() *ReplaceAllLogTargetLogForwardAccepted { + + return &ReplaceAllLogTargetLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the replace all log target log forward accepted response +func (o *ReplaceAllLogTargetLogForwardAccepted) WithReloadID(reloadID string) *ReplaceAllLogTargetLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all log target log forward accepted response +func (o *ReplaceAllLogTargetLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all log target log forward accepted response +func (o *ReplaceAllLogTargetLogForwardAccepted) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetLogForwardAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target log forward accepted response +func (o *ReplaceAllLogTargetLogForwardAccepted) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetLogForwardBadRequestCode is the HTTP code returned for type ReplaceAllLogTargetLogForwardBadRequest +const ReplaceAllLogTargetLogForwardBadRequestCode int = 400 + +/* +ReplaceAllLogTargetLogForwardBadRequest Bad request + +swagger:response replaceAllLogTargetLogForwardBadRequest +*/ +type ReplaceAllLogTargetLogForwardBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetLogForwardBadRequest creates ReplaceAllLogTargetLogForwardBadRequest with default headers values +func NewReplaceAllLogTargetLogForwardBadRequest() *ReplaceAllLogTargetLogForwardBadRequest { + + return &ReplaceAllLogTargetLogForwardBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target log forward bad request response +func (o *ReplaceAllLogTargetLogForwardBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetLogForwardBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target log forward bad request response +func (o *ReplaceAllLogTargetLogForwardBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target log forward bad request response +func (o *ReplaceAllLogTargetLogForwardBadRequest) WithPayload(payload *models.Error) *ReplaceAllLogTargetLogForwardBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target log forward bad request response +func (o *ReplaceAllLogTargetLogForwardBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetLogForwardBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllLogTargetLogForwardDefault General Error + +swagger:response replaceAllLogTargetLogForwardDefault +*/ +type ReplaceAllLogTargetLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetLogForwardDefault creates ReplaceAllLogTargetLogForwardDefault with default headers values +func NewReplaceAllLogTargetLogForwardDefault(code int) *ReplaceAllLogTargetLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllLogTargetLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all log target log forward default response +func (o *ReplaceAllLogTargetLogForwardDefault) WithStatusCode(code int) *ReplaceAllLogTargetLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all log target log forward default response +func (o *ReplaceAllLogTargetLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target log forward default response +func (o *ReplaceAllLogTargetLogForwardDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target log forward default response +func (o *ReplaceAllLogTargetLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target log forward default response +func (o *ReplaceAllLogTargetLogForwardDefault) WithPayload(payload *models.Error) *ReplaceAllLogTargetLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target log forward default response +func (o *ReplaceAllLogTargetLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_all_log_target_log_forward_urlbuilder.go b/operations/log_target/replace_all_log_target_log_forward_urlbuilder.go new file mode 100644 index 00000000..b98359a1 --- /dev/null +++ b/operations/log_target/replace_all_log_target_log_forward_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllLogTargetLogForwardURL generates an URL for the replace all log target log forward operation +type ReplaceAllLogTargetLogForwardURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetLogForwardURL) WithBasePath(bp string) *ReplaceAllLogTargetLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllLogTargetLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllLogTargetLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllLogTargetLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllLogTargetLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllLogTargetLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllLogTargetLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllLogTargetLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllLogTargetLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_all_log_target_peer.go b/operations/log_target/replace_all_log_target_peer.go new file mode 100644 index 00000000..584fb739 --- /dev/null +++ b/operations/log_target/replace_all_log_target_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllLogTargetPeerHandlerFunc turns a function with the right signature into a replace all log target peer handler +type ReplaceAllLogTargetPeerHandlerFunc func(ReplaceAllLogTargetPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllLogTargetPeerHandlerFunc) Handle(params ReplaceAllLogTargetPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllLogTargetPeerHandler interface for that can handle valid replace all log target peer params +type ReplaceAllLogTargetPeerHandler interface { + Handle(ReplaceAllLogTargetPeerParams, interface{}) middleware.Responder +} + +// NewReplaceAllLogTargetPeer creates a new http.Handler for the replace all log target peer operation +func NewReplaceAllLogTargetPeer(ctx *middleware.Context, handler ReplaceAllLogTargetPeerHandler) *ReplaceAllLogTargetPeer { + return &ReplaceAllLogTargetPeer{Context: ctx, Handler: handler} +} + +/* + ReplaceAllLogTargetPeer swagger:route PUT /services/haproxy/configuration/peers/{parent_name}/log_targets LogTarget replaceAllLogTargetPeer + +# Replace a Log Target list + +Replaces a whole list of Log Targets with the list given in parameter +*/ +type ReplaceAllLogTargetPeer struct { + Context *middleware.Context + Handler ReplaceAllLogTargetPeerHandler +} + +func (o *ReplaceAllLogTargetPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllLogTargetPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_all_log_target_peer_parameters.go b/operations/log_target/replace_all_log_target_peer_parameters.go new file mode 100644 index 00000000..c5ae7f2e --- /dev/null +++ b/operations/log_target/replace_all_log_target_peer_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllLogTargetPeerParams creates a new ReplaceAllLogTargetPeerParams object +// with the default values initialized. +func NewReplaceAllLogTargetPeerParams() ReplaceAllLogTargetPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllLogTargetPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllLogTargetPeerParams contains all the bound params for the replace all log target peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllLogTargetPeer +type ReplaceAllLogTargetPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.LogTargets + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllLogTargetPeerParams() beforehand. +func (o *ReplaceAllLogTargetPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTargets + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllLogTargetPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllLogTargetPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllLogTargetPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllLogTargetPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllLogTargetPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_all_log_target_peer_responses.go b/operations/log_target/replace_all_log_target_peer_responses.go new file mode 100644 index 00000000..e88bef9a --- /dev/null +++ b/operations/log_target/replace_all_log_target_peer_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllLogTargetPeerOKCode is the HTTP code returned for type ReplaceAllLogTargetPeerOK +const ReplaceAllLogTargetPeerOKCode int = 200 + +/* +ReplaceAllLogTargetPeerOK All Log Target lines replaced + +swagger:response replaceAllLogTargetPeerOK +*/ +type ReplaceAllLogTargetPeerOK struct { + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetPeerOK creates ReplaceAllLogTargetPeerOK with default headers values +func NewReplaceAllLogTargetPeerOK() *ReplaceAllLogTargetPeerOK { + + return &ReplaceAllLogTargetPeerOK{} +} + +// WithPayload adds the payload to the replace all log target peer o k response +func (o *ReplaceAllLogTargetPeerOK) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target peer o k response +func (o *ReplaceAllLogTargetPeerOK) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetPeerAcceptedCode is the HTTP code returned for type ReplaceAllLogTargetPeerAccepted +const ReplaceAllLogTargetPeerAcceptedCode int = 202 + +/* +ReplaceAllLogTargetPeerAccepted Configuration change accepted and reload requested + +swagger:response replaceAllLogTargetPeerAccepted +*/ +type ReplaceAllLogTargetPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.LogTargets `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetPeerAccepted creates ReplaceAllLogTargetPeerAccepted with default headers values +func NewReplaceAllLogTargetPeerAccepted() *ReplaceAllLogTargetPeerAccepted { + + return &ReplaceAllLogTargetPeerAccepted{} +} + +// WithReloadID adds the reloadId to the replace all log target peer accepted response +func (o *ReplaceAllLogTargetPeerAccepted) WithReloadID(reloadID string) *ReplaceAllLogTargetPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all log target peer accepted response +func (o *ReplaceAllLogTargetPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all log target peer accepted response +func (o *ReplaceAllLogTargetPeerAccepted) WithPayload(payload models.LogTargets) *ReplaceAllLogTargetPeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target peer accepted response +func (o *ReplaceAllLogTargetPeerAccepted) SetPayload(payload models.LogTargets) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.LogTargets{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllLogTargetPeerBadRequestCode is the HTTP code returned for type ReplaceAllLogTargetPeerBadRequest +const ReplaceAllLogTargetPeerBadRequestCode int = 400 + +/* +ReplaceAllLogTargetPeerBadRequest Bad request + +swagger:response replaceAllLogTargetPeerBadRequest +*/ +type ReplaceAllLogTargetPeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetPeerBadRequest creates ReplaceAllLogTargetPeerBadRequest with default headers values +func NewReplaceAllLogTargetPeerBadRequest() *ReplaceAllLogTargetPeerBadRequest { + + return &ReplaceAllLogTargetPeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target peer bad request response +func (o *ReplaceAllLogTargetPeerBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetPeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target peer bad request response +func (o *ReplaceAllLogTargetPeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target peer bad request response +func (o *ReplaceAllLogTargetPeerBadRequest) WithPayload(payload *models.Error) *ReplaceAllLogTargetPeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target peer bad request response +func (o *ReplaceAllLogTargetPeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetPeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllLogTargetPeerDefault General Error + +swagger:response replaceAllLogTargetPeerDefault +*/ +type ReplaceAllLogTargetPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllLogTargetPeerDefault creates ReplaceAllLogTargetPeerDefault with default headers values +func NewReplaceAllLogTargetPeerDefault(code int) *ReplaceAllLogTargetPeerDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllLogTargetPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all log target peer default response +func (o *ReplaceAllLogTargetPeerDefault) WithStatusCode(code int) *ReplaceAllLogTargetPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all log target peer default response +func (o *ReplaceAllLogTargetPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all log target peer default response +func (o *ReplaceAllLogTargetPeerDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllLogTargetPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all log target peer default response +func (o *ReplaceAllLogTargetPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all log target peer default response +func (o *ReplaceAllLogTargetPeerDefault) WithPayload(payload *models.Error) *ReplaceAllLogTargetPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all log target peer default response +func (o *ReplaceAllLogTargetPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllLogTargetPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_all_log_target_peer_urlbuilder.go b/operations/log_target/replace_all_log_target_peer_urlbuilder.go new file mode 100644 index 00000000..f9e4c53b --- /dev/null +++ b/operations/log_target/replace_all_log_target_peer_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllLogTargetPeerURL generates an URL for the replace all log target peer operation +type ReplaceAllLogTargetPeerURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetPeerURL) WithBasePath(bp string) *ReplaceAllLogTargetPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllLogTargetPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllLogTargetPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/log_targets" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllLogTargetPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllLogTargetPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllLogTargetPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllLogTargetPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllLogTargetPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllLogTargetPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllLogTargetPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_log_target.go b/operations/log_target/replace_log_target.go deleted file mode 100644 index cb11b7d4..00000000 --- a/operations/log_target/replace_log_target.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceLogTargetHandlerFunc turns a function with the right signature into a replace log target handler -type ReplaceLogTargetHandlerFunc func(ReplaceLogTargetParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceLogTargetHandlerFunc) Handle(params ReplaceLogTargetParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceLogTargetHandler interface for that can handle valid replace log target params -type ReplaceLogTargetHandler interface { - Handle(ReplaceLogTargetParams, interface{}) middleware.Responder -} - -// NewReplaceLogTarget creates a new http.Handler for the replace log target operation -func NewReplaceLogTarget(ctx *middleware.Context, handler ReplaceLogTargetHandler) *ReplaceLogTarget { - return &ReplaceLogTarget{Context: ctx, Handler: handler} -} - -/*ReplaceLogTarget swagger:route PUT /services/haproxy/configuration/log_targets/{id} LogTarget replaceLogTarget - -Replace a Log Target - -Replaces a Log Target configuration by it's ID in the specified parent. - -*/ -type ReplaceLogTarget struct { - Context *middleware.Context - Handler ReplaceLogTargetHandler -} - -func (o *ReplaceLogTarget) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceLogTargetParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/log_target/replace_log_target_backend.go b/operations/log_target/replace_log_target_backend.go new file mode 100644 index 00000000..37285f70 --- /dev/null +++ b/operations/log_target/replace_log_target_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceLogTargetBackendHandlerFunc turns a function with the right signature into a replace log target backend handler +type ReplaceLogTargetBackendHandlerFunc func(ReplaceLogTargetBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceLogTargetBackendHandlerFunc) Handle(params ReplaceLogTargetBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceLogTargetBackendHandler interface for that can handle valid replace log target backend params +type ReplaceLogTargetBackendHandler interface { + Handle(ReplaceLogTargetBackendParams, interface{}) middleware.Responder +} + +// NewReplaceLogTargetBackend creates a new http.Handler for the replace log target backend operation +func NewReplaceLogTargetBackend(ctx *middleware.Context, handler ReplaceLogTargetBackendHandler) *ReplaceLogTargetBackend { + return &ReplaceLogTargetBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceLogTargetBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/log_targets/{index} LogTarget replaceLogTargetBackend + +# Replace a Log Target + +Replaces a Log Target configuration by it's index in the specified parent. +*/ +type ReplaceLogTargetBackend struct { + Context *middleware.Context + Handler ReplaceLogTargetBackendHandler +} + +func (o *ReplaceLogTargetBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceLogTargetBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_log_target_backend_parameters.go b/operations/log_target/replace_log_target_backend_parameters.go new file mode 100644 index 00000000..41bc5ff0 --- /dev/null +++ b/operations/log_target/replace_log_target_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceLogTargetBackendParams creates a new ReplaceLogTargetBackendParams object +// with the default values initialized. +func NewReplaceLogTargetBackendParams() ReplaceLogTargetBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceLogTargetBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceLogTargetBackendParams contains all the bound params for the replace log target backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceLogTargetBackend +type ReplaceLogTargetBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceLogTargetBackendParams() beforehand. +func (o *ReplaceLogTargetBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceLogTargetBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogTargetBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceLogTargetBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceLogTargetBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceLogTargetBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceLogTargetBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_log_target_backend_responses.go b/operations/log_target/replace_log_target_backend_responses.go new file mode 100644 index 00000000..8aa2455c --- /dev/null +++ b/operations/log_target/replace_log_target_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceLogTargetBackendOKCode is the HTTP code returned for type ReplaceLogTargetBackendOK +const ReplaceLogTargetBackendOKCode int = 200 + +/* +ReplaceLogTargetBackendOK Log Target replaced + +swagger:response replaceLogTargetBackendOK +*/ +type ReplaceLogTargetBackendOK struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetBackendOK creates ReplaceLogTargetBackendOK with default headers values +func NewReplaceLogTargetBackendOK() *ReplaceLogTargetBackendOK { + + return &ReplaceLogTargetBackendOK{} +} + +// WithPayload adds the payload to the replace log target backend o k response +func (o *ReplaceLogTargetBackendOK) WithPayload(payload *models.LogTarget) *ReplaceLogTargetBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target backend o k response +func (o *ReplaceLogTargetBackendOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetBackendAcceptedCode is the HTTP code returned for type ReplaceLogTargetBackendAccepted +const ReplaceLogTargetBackendAcceptedCode int = 202 + +/* +ReplaceLogTargetBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceLogTargetBackendAccepted +*/ +type ReplaceLogTargetBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetBackendAccepted creates ReplaceLogTargetBackendAccepted with default headers values +func NewReplaceLogTargetBackendAccepted() *ReplaceLogTargetBackendAccepted { + + return &ReplaceLogTargetBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace log target backend accepted response +func (o *ReplaceLogTargetBackendAccepted) WithReloadID(reloadID string) *ReplaceLogTargetBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace log target backend accepted response +func (o *ReplaceLogTargetBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace log target backend accepted response +func (o *ReplaceLogTargetBackendAccepted) WithPayload(payload *models.LogTarget) *ReplaceLogTargetBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target backend accepted response +func (o *ReplaceLogTargetBackendAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetBackendBadRequestCode is the HTTP code returned for type ReplaceLogTargetBackendBadRequest +const ReplaceLogTargetBackendBadRequestCode int = 400 + +/* +ReplaceLogTargetBackendBadRequest Bad request + +swagger:response replaceLogTargetBackendBadRequest +*/ +type ReplaceLogTargetBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetBackendBadRequest creates ReplaceLogTargetBackendBadRequest with default headers values +func NewReplaceLogTargetBackendBadRequest() *ReplaceLogTargetBackendBadRequest { + + return &ReplaceLogTargetBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target backend bad request response +func (o *ReplaceLogTargetBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target backend bad request response +func (o *ReplaceLogTargetBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target backend bad request response +func (o *ReplaceLogTargetBackendBadRequest) WithPayload(payload *models.Error) *ReplaceLogTargetBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target backend bad request response +func (o *ReplaceLogTargetBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetBackendNotFoundCode is the HTTP code returned for type ReplaceLogTargetBackendNotFound +const ReplaceLogTargetBackendNotFoundCode int = 404 + +/* +ReplaceLogTargetBackendNotFound The specified resource was not found + +swagger:response replaceLogTargetBackendNotFound +*/ +type ReplaceLogTargetBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetBackendNotFound creates ReplaceLogTargetBackendNotFound with default headers values +func NewReplaceLogTargetBackendNotFound() *ReplaceLogTargetBackendNotFound { + + return &ReplaceLogTargetBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target backend not found response +func (o *ReplaceLogTargetBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target backend not found response +func (o *ReplaceLogTargetBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target backend not found response +func (o *ReplaceLogTargetBackendNotFound) WithPayload(payload *models.Error) *ReplaceLogTargetBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target backend not found response +func (o *ReplaceLogTargetBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceLogTargetBackendDefault General Error + +swagger:response replaceLogTargetBackendDefault +*/ +type ReplaceLogTargetBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetBackendDefault creates ReplaceLogTargetBackendDefault with default headers values +func NewReplaceLogTargetBackendDefault(code int) *ReplaceLogTargetBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceLogTargetBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace log target backend default response +func (o *ReplaceLogTargetBackendDefault) WithStatusCode(code int) *ReplaceLogTargetBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace log target backend default response +func (o *ReplaceLogTargetBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target backend default response +func (o *ReplaceLogTargetBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target backend default response +func (o *ReplaceLogTargetBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target backend default response +func (o *ReplaceLogTargetBackendDefault) WithPayload(payload *models.Error) *ReplaceLogTargetBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target backend default response +func (o *ReplaceLogTargetBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_log_target_backend_urlbuilder.go b/operations/log_target/replace_log_target_backend_urlbuilder.go new file mode 100644 index 00000000..d33879da --- /dev/null +++ b/operations/log_target/replace_log_target_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceLogTargetBackendURL generates an URL for the replace log target backend operation +type ReplaceLogTargetBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetBackendURL) WithBasePath(bp string) *ReplaceLogTargetBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceLogTargetBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceLogTargetBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceLogTargetBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceLogTargetBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceLogTargetBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceLogTargetBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceLogTargetBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceLogTargetBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceLogTargetBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_log_target_defaults.go b/operations/log_target/replace_log_target_defaults.go new file mode 100644 index 00000000..2804786c --- /dev/null +++ b/operations/log_target/replace_log_target_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceLogTargetDefaultsHandlerFunc turns a function with the right signature into a replace log target defaults handler +type ReplaceLogTargetDefaultsHandlerFunc func(ReplaceLogTargetDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceLogTargetDefaultsHandlerFunc) Handle(params ReplaceLogTargetDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceLogTargetDefaultsHandler interface for that can handle valid replace log target defaults params +type ReplaceLogTargetDefaultsHandler interface { + Handle(ReplaceLogTargetDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceLogTargetDefaults creates a new http.Handler for the replace log target defaults operation +func NewReplaceLogTargetDefaults(ctx *middleware.Context, handler ReplaceLogTargetDefaultsHandler) *ReplaceLogTargetDefaults { + return &ReplaceLogTargetDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceLogTargetDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/log_targets/{index} LogTarget replaceLogTargetDefaults + +# Replace a Log Target + +Replaces a Log Target configuration by it's index in the specified parent. +*/ +type ReplaceLogTargetDefaults struct { + Context *middleware.Context + Handler ReplaceLogTargetDefaultsHandler +} + +func (o *ReplaceLogTargetDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceLogTargetDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_log_target_defaults_parameters.go b/operations/log_target/replace_log_target_defaults_parameters.go new file mode 100644 index 00000000..4236fbdb --- /dev/null +++ b/operations/log_target/replace_log_target_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceLogTargetDefaultsParams creates a new ReplaceLogTargetDefaultsParams object +// with the default values initialized. +func NewReplaceLogTargetDefaultsParams() ReplaceLogTargetDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceLogTargetDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceLogTargetDefaultsParams contains all the bound params for the replace log target defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceLogTargetDefaults +type ReplaceLogTargetDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceLogTargetDefaultsParams() beforehand. +func (o *ReplaceLogTargetDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceLogTargetDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogTargetDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceLogTargetDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceLogTargetDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceLogTargetDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceLogTargetDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_log_target_defaults_responses.go b/operations/log_target/replace_log_target_defaults_responses.go new file mode 100644 index 00000000..001b0112 --- /dev/null +++ b/operations/log_target/replace_log_target_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceLogTargetDefaultsOKCode is the HTTP code returned for type ReplaceLogTargetDefaultsOK +const ReplaceLogTargetDefaultsOKCode int = 200 + +/* +ReplaceLogTargetDefaultsOK Log Target replaced + +swagger:response replaceLogTargetDefaultsOK +*/ +type ReplaceLogTargetDefaultsOK struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetDefaultsOK creates ReplaceLogTargetDefaultsOK with default headers values +func NewReplaceLogTargetDefaultsOK() *ReplaceLogTargetDefaultsOK { + + return &ReplaceLogTargetDefaultsOK{} +} + +// WithPayload adds the payload to the replace log target defaults o k response +func (o *ReplaceLogTargetDefaultsOK) WithPayload(payload *models.LogTarget) *ReplaceLogTargetDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target defaults o k response +func (o *ReplaceLogTargetDefaultsOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetDefaultsAcceptedCode is the HTTP code returned for type ReplaceLogTargetDefaultsAccepted +const ReplaceLogTargetDefaultsAcceptedCode int = 202 + +/* +ReplaceLogTargetDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceLogTargetDefaultsAccepted +*/ +type ReplaceLogTargetDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetDefaultsAccepted creates ReplaceLogTargetDefaultsAccepted with default headers values +func NewReplaceLogTargetDefaultsAccepted() *ReplaceLogTargetDefaultsAccepted { + + return &ReplaceLogTargetDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace log target defaults accepted response +func (o *ReplaceLogTargetDefaultsAccepted) WithReloadID(reloadID string) *ReplaceLogTargetDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace log target defaults accepted response +func (o *ReplaceLogTargetDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace log target defaults accepted response +func (o *ReplaceLogTargetDefaultsAccepted) WithPayload(payload *models.LogTarget) *ReplaceLogTargetDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target defaults accepted response +func (o *ReplaceLogTargetDefaultsAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetDefaultsBadRequestCode is the HTTP code returned for type ReplaceLogTargetDefaultsBadRequest +const ReplaceLogTargetDefaultsBadRequestCode int = 400 + +/* +ReplaceLogTargetDefaultsBadRequest Bad request + +swagger:response replaceLogTargetDefaultsBadRequest +*/ +type ReplaceLogTargetDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetDefaultsBadRequest creates ReplaceLogTargetDefaultsBadRequest with default headers values +func NewReplaceLogTargetDefaultsBadRequest() *ReplaceLogTargetDefaultsBadRequest { + + return &ReplaceLogTargetDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target defaults bad request response +func (o *ReplaceLogTargetDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target defaults bad request response +func (o *ReplaceLogTargetDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target defaults bad request response +func (o *ReplaceLogTargetDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceLogTargetDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target defaults bad request response +func (o *ReplaceLogTargetDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetDefaultsNotFoundCode is the HTTP code returned for type ReplaceLogTargetDefaultsNotFound +const ReplaceLogTargetDefaultsNotFoundCode int = 404 + +/* +ReplaceLogTargetDefaultsNotFound The specified resource was not found + +swagger:response replaceLogTargetDefaultsNotFound +*/ +type ReplaceLogTargetDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetDefaultsNotFound creates ReplaceLogTargetDefaultsNotFound with default headers values +func NewReplaceLogTargetDefaultsNotFound() *ReplaceLogTargetDefaultsNotFound { + + return &ReplaceLogTargetDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target defaults not found response +func (o *ReplaceLogTargetDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target defaults not found response +func (o *ReplaceLogTargetDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target defaults not found response +func (o *ReplaceLogTargetDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceLogTargetDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target defaults not found response +func (o *ReplaceLogTargetDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceLogTargetDefaultsDefault General Error + +swagger:response replaceLogTargetDefaultsDefault +*/ +type ReplaceLogTargetDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetDefaultsDefault creates ReplaceLogTargetDefaultsDefault with default headers values +func NewReplaceLogTargetDefaultsDefault(code int) *ReplaceLogTargetDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceLogTargetDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace log target defaults default response +func (o *ReplaceLogTargetDefaultsDefault) WithStatusCode(code int) *ReplaceLogTargetDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace log target defaults default response +func (o *ReplaceLogTargetDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target defaults default response +func (o *ReplaceLogTargetDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target defaults default response +func (o *ReplaceLogTargetDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target defaults default response +func (o *ReplaceLogTargetDefaultsDefault) WithPayload(payload *models.Error) *ReplaceLogTargetDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target defaults default response +func (o *ReplaceLogTargetDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_log_target_defaults_urlbuilder.go b/operations/log_target/replace_log_target_defaults_urlbuilder.go new file mode 100644 index 00000000..c5031d3a --- /dev/null +++ b/operations/log_target/replace_log_target_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceLogTargetDefaultsURL generates an URL for the replace log target defaults operation +type ReplaceLogTargetDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetDefaultsURL) WithBasePath(bp string) *ReplaceLogTargetDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceLogTargetDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceLogTargetDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceLogTargetDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceLogTargetDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceLogTargetDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceLogTargetDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceLogTargetDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceLogTargetDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceLogTargetDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_log_target_frontend.go b/operations/log_target/replace_log_target_frontend.go new file mode 100644 index 00000000..c3c0bed4 --- /dev/null +++ b/operations/log_target/replace_log_target_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceLogTargetFrontendHandlerFunc turns a function with the right signature into a replace log target frontend handler +type ReplaceLogTargetFrontendHandlerFunc func(ReplaceLogTargetFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceLogTargetFrontendHandlerFunc) Handle(params ReplaceLogTargetFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceLogTargetFrontendHandler interface for that can handle valid replace log target frontend params +type ReplaceLogTargetFrontendHandler interface { + Handle(ReplaceLogTargetFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceLogTargetFrontend creates a new http.Handler for the replace log target frontend operation +func NewReplaceLogTargetFrontend(ctx *middleware.Context, handler ReplaceLogTargetFrontendHandler) *ReplaceLogTargetFrontend { + return &ReplaceLogTargetFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceLogTargetFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/log_targets/{index} LogTarget replaceLogTargetFrontend + +# Replace a Log Target + +Replaces a Log Target configuration by it's index in the specified parent. +*/ +type ReplaceLogTargetFrontend struct { + Context *middleware.Context + Handler ReplaceLogTargetFrontendHandler +} + +func (o *ReplaceLogTargetFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceLogTargetFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_log_target_frontend_parameters.go b/operations/log_target/replace_log_target_frontend_parameters.go new file mode 100644 index 00000000..f67f2b9e --- /dev/null +++ b/operations/log_target/replace_log_target_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceLogTargetFrontendParams creates a new ReplaceLogTargetFrontendParams object +// with the default values initialized. +func NewReplaceLogTargetFrontendParams() ReplaceLogTargetFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceLogTargetFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceLogTargetFrontendParams contains all the bound params for the replace log target frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceLogTargetFrontend +type ReplaceLogTargetFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceLogTargetFrontendParams() beforehand. +func (o *ReplaceLogTargetFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceLogTargetFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogTargetFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceLogTargetFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceLogTargetFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceLogTargetFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceLogTargetFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_log_target_frontend_responses.go b/operations/log_target/replace_log_target_frontend_responses.go new file mode 100644 index 00000000..18a784e8 --- /dev/null +++ b/operations/log_target/replace_log_target_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceLogTargetFrontendOKCode is the HTTP code returned for type ReplaceLogTargetFrontendOK +const ReplaceLogTargetFrontendOKCode int = 200 + +/* +ReplaceLogTargetFrontendOK Log Target replaced + +swagger:response replaceLogTargetFrontendOK +*/ +type ReplaceLogTargetFrontendOK struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetFrontendOK creates ReplaceLogTargetFrontendOK with default headers values +func NewReplaceLogTargetFrontendOK() *ReplaceLogTargetFrontendOK { + + return &ReplaceLogTargetFrontendOK{} +} + +// WithPayload adds the payload to the replace log target frontend o k response +func (o *ReplaceLogTargetFrontendOK) WithPayload(payload *models.LogTarget) *ReplaceLogTargetFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target frontend o k response +func (o *ReplaceLogTargetFrontendOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetFrontendAcceptedCode is the HTTP code returned for type ReplaceLogTargetFrontendAccepted +const ReplaceLogTargetFrontendAcceptedCode int = 202 + +/* +ReplaceLogTargetFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceLogTargetFrontendAccepted +*/ +type ReplaceLogTargetFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetFrontendAccepted creates ReplaceLogTargetFrontendAccepted with default headers values +func NewReplaceLogTargetFrontendAccepted() *ReplaceLogTargetFrontendAccepted { + + return &ReplaceLogTargetFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace log target frontend accepted response +func (o *ReplaceLogTargetFrontendAccepted) WithReloadID(reloadID string) *ReplaceLogTargetFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace log target frontend accepted response +func (o *ReplaceLogTargetFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace log target frontend accepted response +func (o *ReplaceLogTargetFrontendAccepted) WithPayload(payload *models.LogTarget) *ReplaceLogTargetFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target frontend accepted response +func (o *ReplaceLogTargetFrontendAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetFrontendBadRequestCode is the HTTP code returned for type ReplaceLogTargetFrontendBadRequest +const ReplaceLogTargetFrontendBadRequestCode int = 400 + +/* +ReplaceLogTargetFrontendBadRequest Bad request + +swagger:response replaceLogTargetFrontendBadRequest +*/ +type ReplaceLogTargetFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetFrontendBadRequest creates ReplaceLogTargetFrontendBadRequest with default headers values +func NewReplaceLogTargetFrontendBadRequest() *ReplaceLogTargetFrontendBadRequest { + + return &ReplaceLogTargetFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target frontend bad request response +func (o *ReplaceLogTargetFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target frontend bad request response +func (o *ReplaceLogTargetFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target frontend bad request response +func (o *ReplaceLogTargetFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceLogTargetFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target frontend bad request response +func (o *ReplaceLogTargetFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetFrontendNotFoundCode is the HTTP code returned for type ReplaceLogTargetFrontendNotFound +const ReplaceLogTargetFrontendNotFoundCode int = 404 + +/* +ReplaceLogTargetFrontendNotFound The specified resource was not found + +swagger:response replaceLogTargetFrontendNotFound +*/ +type ReplaceLogTargetFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetFrontendNotFound creates ReplaceLogTargetFrontendNotFound with default headers values +func NewReplaceLogTargetFrontendNotFound() *ReplaceLogTargetFrontendNotFound { + + return &ReplaceLogTargetFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target frontend not found response +func (o *ReplaceLogTargetFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target frontend not found response +func (o *ReplaceLogTargetFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target frontend not found response +func (o *ReplaceLogTargetFrontendNotFound) WithPayload(payload *models.Error) *ReplaceLogTargetFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target frontend not found response +func (o *ReplaceLogTargetFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceLogTargetFrontendDefault General Error + +swagger:response replaceLogTargetFrontendDefault +*/ +type ReplaceLogTargetFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetFrontendDefault creates ReplaceLogTargetFrontendDefault with default headers values +func NewReplaceLogTargetFrontendDefault(code int) *ReplaceLogTargetFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceLogTargetFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace log target frontend default response +func (o *ReplaceLogTargetFrontendDefault) WithStatusCode(code int) *ReplaceLogTargetFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace log target frontend default response +func (o *ReplaceLogTargetFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target frontend default response +func (o *ReplaceLogTargetFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target frontend default response +func (o *ReplaceLogTargetFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target frontend default response +func (o *ReplaceLogTargetFrontendDefault) WithPayload(payload *models.Error) *ReplaceLogTargetFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target frontend default response +func (o *ReplaceLogTargetFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_log_target_frontend_urlbuilder.go b/operations/log_target/replace_log_target_frontend_urlbuilder.go new file mode 100644 index 00000000..3b977b00 --- /dev/null +++ b/operations/log_target/replace_log_target_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceLogTargetFrontendURL generates an URL for the replace log target frontend operation +type ReplaceLogTargetFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetFrontendURL) WithBasePath(bp string) *ReplaceLogTargetFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceLogTargetFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceLogTargetFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceLogTargetFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceLogTargetFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceLogTargetFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceLogTargetFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceLogTargetFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceLogTargetFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceLogTargetFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_log_target_global.go b/operations/log_target/replace_log_target_global.go new file mode 100644 index 00000000..b7816b8c --- /dev/null +++ b/operations/log_target/replace_log_target_global.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceLogTargetGlobalHandlerFunc turns a function with the right signature into a replace log target global handler +type ReplaceLogTargetGlobalHandlerFunc func(ReplaceLogTargetGlobalParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceLogTargetGlobalHandlerFunc) Handle(params ReplaceLogTargetGlobalParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceLogTargetGlobalHandler interface for that can handle valid replace log target global params +type ReplaceLogTargetGlobalHandler interface { + Handle(ReplaceLogTargetGlobalParams, interface{}) middleware.Responder +} + +// NewReplaceLogTargetGlobal creates a new http.Handler for the replace log target global operation +func NewReplaceLogTargetGlobal(ctx *middleware.Context, handler ReplaceLogTargetGlobalHandler) *ReplaceLogTargetGlobal { + return &ReplaceLogTargetGlobal{Context: ctx, Handler: handler} +} + +/* + ReplaceLogTargetGlobal swagger:route PUT /services/haproxy/configuration/global/log_targets/{index} LogTarget replaceLogTargetGlobal + +# Replace a Log Target + +Replaces a Log Target configuration by it's index in the specified parent. +*/ +type ReplaceLogTargetGlobal struct { + Context *middleware.Context + Handler ReplaceLogTargetGlobalHandler +} + +func (o *ReplaceLogTargetGlobal) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceLogTargetGlobalParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_log_target_global_parameters.go b/operations/log_target/replace_log_target_global_parameters.go new file mode 100644 index 00000000..70c7dcfe --- /dev/null +++ b/operations/log_target/replace_log_target_global_parameters.go @@ -0,0 +1,226 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceLogTargetGlobalParams creates a new ReplaceLogTargetGlobalParams object +// with the default values initialized. +func NewReplaceLogTargetGlobalParams() ReplaceLogTargetGlobalParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceLogTargetGlobalParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceLogTargetGlobalParams contains all the bound params for the replace log target global operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceLogTargetGlobal +type ReplaceLogTargetGlobalParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceLogTargetGlobalParams() beforehand. +func (o *ReplaceLogTargetGlobalParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceLogTargetGlobalParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogTargetGlobalParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceLogTargetGlobalParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceLogTargetGlobalParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceLogTargetGlobalParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_log_target_global_responses.go b/operations/log_target/replace_log_target_global_responses.go new file mode 100644 index 00000000..a7d94906 --- /dev/null +++ b/operations/log_target/replace_log_target_global_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceLogTargetGlobalOKCode is the HTTP code returned for type ReplaceLogTargetGlobalOK +const ReplaceLogTargetGlobalOKCode int = 200 + +/* +ReplaceLogTargetGlobalOK Log Target replaced + +swagger:response replaceLogTargetGlobalOK +*/ +type ReplaceLogTargetGlobalOK struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetGlobalOK creates ReplaceLogTargetGlobalOK with default headers values +func NewReplaceLogTargetGlobalOK() *ReplaceLogTargetGlobalOK { + + return &ReplaceLogTargetGlobalOK{} +} + +// WithPayload adds the payload to the replace log target global o k response +func (o *ReplaceLogTargetGlobalOK) WithPayload(payload *models.LogTarget) *ReplaceLogTargetGlobalOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target global o k response +func (o *ReplaceLogTargetGlobalOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetGlobalOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetGlobalAcceptedCode is the HTTP code returned for type ReplaceLogTargetGlobalAccepted +const ReplaceLogTargetGlobalAcceptedCode int = 202 + +/* +ReplaceLogTargetGlobalAccepted Configuration change accepted and reload requested + +swagger:response replaceLogTargetGlobalAccepted +*/ +type ReplaceLogTargetGlobalAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetGlobalAccepted creates ReplaceLogTargetGlobalAccepted with default headers values +func NewReplaceLogTargetGlobalAccepted() *ReplaceLogTargetGlobalAccepted { + + return &ReplaceLogTargetGlobalAccepted{} +} + +// WithReloadID adds the reloadId to the replace log target global accepted response +func (o *ReplaceLogTargetGlobalAccepted) WithReloadID(reloadID string) *ReplaceLogTargetGlobalAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace log target global accepted response +func (o *ReplaceLogTargetGlobalAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace log target global accepted response +func (o *ReplaceLogTargetGlobalAccepted) WithPayload(payload *models.LogTarget) *ReplaceLogTargetGlobalAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target global accepted response +func (o *ReplaceLogTargetGlobalAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetGlobalAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetGlobalBadRequestCode is the HTTP code returned for type ReplaceLogTargetGlobalBadRequest +const ReplaceLogTargetGlobalBadRequestCode int = 400 + +/* +ReplaceLogTargetGlobalBadRequest Bad request + +swagger:response replaceLogTargetGlobalBadRequest +*/ +type ReplaceLogTargetGlobalBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetGlobalBadRequest creates ReplaceLogTargetGlobalBadRequest with default headers values +func NewReplaceLogTargetGlobalBadRequest() *ReplaceLogTargetGlobalBadRequest { + + return &ReplaceLogTargetGlobalBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target global bad request response +func (o *ReplaceLogTargetGlobalBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetGlobalBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target global bad request response +func (o *ReplaceLogTargetGlobalBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target global bad request response +func (o *ReplaceLogTargetGlobalBadRequest) WithPayload(payload *models.Error) *ReplaceLogTargetGlobalBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target global bad request response +func (o *ReplaceLogTargetGlobalBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetGlobalBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetGlobalNotFoundCode is the HTTP code returned for type ReplaceLogTargetGlobalNotFound +const ReplaceLogTargetGlobalNotFoundCode int = 404 + +/* +ReplaceLogTargetGlobalNotFound The specified resource was not found + +swagger:response replaceLogTargetGlobalNotFound +*/ +type ReplaceLogTargetGlobalNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetGlobalNotFound creates ReplaceLogTargetGlobalNotFound with default headers values +func NewReplaceLogTargetGlobalNotFound() *ReplaceLogTargetGlobalNotFound { + + return &ReplaceLogTargetGlobalNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target global not found response +func (o *ReplaceLogTargetGlobalNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetGlobalNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target global not found response +func (o *ReplaceLogTargetGlobalNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target global not found response +func (o *ReplaceLogTargetGlobalNotFound) WithPayload(payload *models.Error) *ReplaceLogTargetGlobalNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target global not found response +func (o *ReplaceLogTargetGlobalNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetGlobalNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceLogTargetGlobalDefault General Error + +swagger:response replaceLogTargetGlobalDefault +*/ +type ReplaceLogTargetGlobalDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetGlobalDefault creates ReplaceLogTargetGlobalDefault with default headers values +func NewReplaceLogTargetGlobalDefault(code int) *ReplaceLogTargetGlobalDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceLogTargetGlobalDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace log target global default response +func (o *ReplaceLogTargetGlobalDefault) WithStatusCode(code int) *ReplaceLogTargetGlobalDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace log target global default response +func (o *ReplaceLogTargetGlobalDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target global default response +func (o *ReplaceLogTargetGlobalDefault) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetGlobalDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target global default response +func (o *ReplaceLogTargetGlobalDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target global default response +func (o *ReplaceLogTargetGlobalDefault) WithPayload(payload *models.Error) *ReplaceLogTargetGlobalDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target global default response +func (o *ReplaceLogTargetGlobalDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetGlobalDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_log_target_global_urlbuilder.go b/operations/log_target/replace_log_target_global_urlbuilder.go new file mode 100644 index 00000000..4d94a870 --- /dev/null +++ b/operations/log_target/replace_log_target_global_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceLogTargetGlobalURL generates an URL for the replace log target global operation +type ReplaceLogTargetGlobalURL struct { + Index int64 + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetGlobalURL) WithBasePath(bp string) *ReplaceLogTargetGlobalURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetGlobalURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceLogTargetGlobalURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/global/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceLogTargetGlobalURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceLogTargetGlobalURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceLogTargetGlobalURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceLogTargetGlobalURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceLogTargetGlobalURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceLogTargetGlobalURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceLogTargetGlobalURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_log_target_log_forward.go b/operations/log_target/replace_log_target_log_forward.go new file mode 100644 index 00000000..e8276e28 --- /dev/null +++ b/operations/log_target/replace_log_target_log_forward.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceLogTargetLogForwardHandlerFunc turns a function with the right signature into a replace log target log forward handler +type ReplaceLogTargetLogForwardHandlerFunc func(ReplaceLogTargetLogForwardParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceLogTargetLogForwardHandlerFunc) Handle(params ReplaceLogTargetLogForwardParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceLogTargetLogForwardHandler interface for that can handle valid replace log target log forward params +type ReplaceLogTargetLogForwardHandler interface { + Handle(ReplaceLogTargetLogForwardParams, interface{}) middleware.Responder +} + +// NewReplaceLogTargetLogForward creates a new http.Handler for the replace log target log forward operation +func NewReplaceLogTargetLogForward(ctx *middleware.Context, handler ReplaceLogTargetLogForwardHandler) *ReplaceLogTargetLogForward { + return &ReplaceLogTargetLogForward{Context: ctx, Handler: handler} +} + +/* + ReplaceLogTargetLogForward swagger:route PUT /services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index} LogTarget replaceLogTargetLogForward + +# Replace a Log Target + +Replaces a Log Target configuration by it's index in the specified parent. +*/ +type ReplaceLogTargetLogForward struct { + Context *middleware.Context + Handler ReplaceLogTargetLogForwardHandler +} + +func (o *ReplaceLogTargetLogForward) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceLogTargetLogForwardParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_log_target_log_forward_parameters.go b/operations/log_target/replace_log_target_log_forward_parameters.go new file mode 100644 index 00000000..6cf285b4 --- /dev/null +++ b/operations/log_target/replace_log_target_log_forward_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceLogTargetLogForwardParams creates a new ReplaceLogTargetLogForwardParams object +// with the default values initialized. +func NewReplaceLogTargetLogForwardParams() ReplaceLogTargetLogForwardParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceLogTargetLogForwardParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceLogTargetLogForwardParams contains all the bound params for the replace log target log forward operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceLogTargetLogForward +type ReplaceLogTargetLogForwardParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceLogTargetLogForwardParams() beforehand. +func (o *ReplaceLogTargetLogForwardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceLogTargetLogForwardParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogTargetLogForwardParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceLogTargetLogForwardParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceLogTargetLogForwardParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceLogTargetLogForwardParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceLogTargetLogForwardParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_log_target_log_forward_responses.go b/operations/log_target/replace_log_target_log_forward_responses.go new file mode 100644 index 00000000..4c714d0a --- /dev/null +++ b/operations/log_target/replace_log_target_log_forward_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceLogTargetLogForwardOKCode is the HTTP code returned for type ReplaceLogTargetLogForwardOK +const ReplaceLogTargetLogForwardOKCode int = 200 + +/* +ReplaceLogTargetLogForwardOK Log Target replaced + +swagger:response replaceLogTargetLogForwardOK +*/ +type ReplaceLogTargetLogForwardOK struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetLogForwardOK creates ReplaceLogTargetLogForwardOK with default headers values +func NewReplaceLogTargetLogForwardOK() *ReplaceLogTargetLogForwardOK { + + return &ReplaceLogTargetLogForwardOK{} +} + +// WithPayload adds the payload to the replace log target log forward o k response +func (o *ReplaceLogTargetLogForwardOK) WithPayload(payload *models.LogTarget) *ReplaceLogTargetLogForwardOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target log forward o k response +func (o *ReplaceLogTargetLogForwardOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetLogForwardOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetLogForwardAcceptedCode is the HTTP code returned for type ReplaceLogTargetLogForwardAccepted +const ReplaceLogTargetLogForwardAcceptedCode int = 202 + +/* +ReplaceLogTargetLogForwardAccepted Configuration change accepted and reload requested + +swagger:response replaceLogTargetLogForwardAccepted +*/ +type ReplaceLogTargetLogForwardAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetLogForwardAccepted creates ReplaceLogTargetLogForwardAccepted with default headers values +func NewReplaceLogTargetLogForwardAccepted() *ReplaceLogTargetLogForwardAccepted { + + return &ReplaceLogTargetLogForwardAccepted{} +} + +// WithReloadID adds the reloadId to the replace log target log forward accepted response +func (o *ReplaceLogTargetLogForwardAccepted) WithReloadID(reloadID string) *ReplaceLogTargetLogForwardAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace log target log forward accepted response +func (o *ReplaceLogTargetLogForwardAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace log target log forward accepted response +func (o *ReplaceLogTargetLogForwardAccepted) WithPayload(payload *models.LogTarget) *ReplaceLogTargetLogForwardAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target log forward accepted response +func (o *ReplaceLogTargetLogForwardAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetLogForwardAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetLogForwardBadRequestCode is the HTTP code returned for type ReplaceLogTargetLogForwardBadRequest +const ReplaceLogTargetLogForwardBadRequestCode int = 400 + +/* +ReplaceLogTargetLogForwardBadRequest Bad request + +swagger:response replaceLogTargetLogForwardBadRequest +*/ +type ReplaceLogTargetLogForwardBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetLogForwardBadRequest creates ReplaceLogTargetLogForwardBadRequest with default headers values +func NewReplaceLogTargetLogForwardBadRequest() *ReplaceLogTargetLogForwardBadRequest { + + return &ReplaceLogTargetLogForwardBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target log forward bad request response +func (o *ReplaceLogTargetLogForwardBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetLogForwardBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target log forward bad request response +func (o *ReplaceLogTargetLogForwardBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target log forward bad request response +func (o *ReplaceLogTargetLogForwardBadRequest) WithPayload(payload *models.Error) *ReplaceLogTargetLogForwardBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target log forward bad request response +func (o *ReplaceLogTargetLogForwardBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetLogForwardBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetLogForwardNotFoundCode is the HTTP code returned for type ReplaceLogTargetLogForwardNotFound +const ReplaceLogTargetLogForwardNotFoundCode int = 404 + +/* +ReplaceLogTargetLogForwardNotFound The specified resource was not found + +swagger:response replaceLogTargetLogForwardNotFound +*/ +type ReplaceLogTargetLogForwardNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetLogForwardNotFound creates ReplaceLogTargetLogForwardNotFound with default headers values +func NewReplaceLogTargetLogForwardNotFound() *ReplaceLogTargetLogForwardNotFound { + + return &ReplaceLogTargetLogForwardNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target log forward not found response +func (o *ReplaceLogTargetLogForwardNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetLogForwardNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target log forward not found response +func (o *ReplaceLogTargetLogForwardNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target log forward not found response +func (o *ReplaceLogTargetLogForwardNotFound) WithPayload(payload *models.Error) *ReplaceLogTargetLogForwardNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target log forward not found response +func (o *ReplaceLogTargetLogForwardNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetLogForwardNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceLogTargetLogForwardDefault General Error + +swagger:response replaceLogTargetLogForwardDefault +*/ +type ReplaceLogTargetLogForwardDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetLogForwardDefault creates ReplaceLogTargetLogForwardDefault with default headers values +func NewReplaceLogTargetLogForwardDefault(code int) *ReplaceLogTargetLogForwardDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceLogTargetLogForwardDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace log target log forward default response +func (o *ReplaceLogTargetLogForwardDefault) WithStatusCode(code int) *ReplaceLogTargetLogForwardDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace log target log forward default response +func (o *ReplaceLogTargetLogForwardDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target log forward default response +func (o *ReplaceLogTargetLogForwardDefault) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetLogForwardDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target log forward default response +func (o *ReplaceLogTargetLogForwardDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target log forward default response +func (o *ReplaceLogTargetLogForwardDefault) WithPayload(payload *models.Error) *ReplaceLogTargetLogForwardDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target log forward default response +func (o *ReplaceLogTargetLogForwardDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetLogForwardDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_log_target_log_forward_urlbuilder.go b/operations/log_target/replace_log_target_log_forward_urlbuilder.go new file mode 100644 index 00000000..b10352f0 --- /dev/null +++ b/operations/log_target/replace_log_target_log_forward_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceLogTargetLogForwardURL generates an URL for the replace log target log forward operation +type ReplaceLogTargetLogForwardURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetLogForwardURL) WithBasePath(bp string) *ReplaceLogTargetLogForwardURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetLogForwardURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceLogTargetLogForwardURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/log_forwards/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceLogTargetLogForwardURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceLogTargetLogForwardURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceLogTargetLogForwardURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceLogTargetLogForwardURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceLogTargetLogForwardURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceLogTargetLogForwardURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceLogTargetLogForwardURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceLogTargetLogForwardURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_log_target_parameters.go b/operations/log_target/replace_log_target_parameters.go deleted file mode 100644 index f19740b2..00000000 --- a/operations/log_target/replace_log_target_parameters.go +++ /dev/null @@ -1,302 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceLogTargetParams creates a new ReplaceLogTargetParams object -// with the default values initialized. -func NewReplaceLogTargetParams() ReplaceLogTargetParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceLogTargetParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceLogTargetParams contains all the bound params for the replace log target operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceLogTarget -type ReplaceLogTargetParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.LogTarget - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Log Target ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceLogTargetParams() beforehand. -func (o *ReplaceLogTargetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.LogTarget - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceLogTargetParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceLogTargetParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *ReplaceLogTargetParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *ReplaceLogTargetParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *ReplaceLogTargetParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *ReplaceLogTargetParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceLogTargetParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceLogTargetParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/log_target/replace_log_target_peer.go b/operations/log_target/replace_log_target_peer.go new file mode 100644 index 00000000..3c4d9287 --- /dev/null +++ b/operations/log_target/replace_log_target_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceLogTargetPeerHandlerFunc turns a function with the right signature into a replace log target peer handler +type ReplaceLogTargetPeerHandlerFunc func(ReplaceLogTargetPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceLogTargetPeerHandlerFunc) Handle(params ReplaceLogTargetPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceLogTargetPeerHandler interface for that can handle valid replace log target peer params +type ReplaceLogTargetPeerHandler interface { + Handle(ReplaceLogTargetPeerParams, interface{}) middleware.Responder +} + +// NewReplaceLogTargetPeer creates a new http.Handler for the replace log target peer operation +func NewReplaceLogTargetPeer(ctx *middleware.Context, handler ReplaceLogTargetPeerHandler) *ReplaceLogTargetPeer { + return &ReplaceLogTargetPeer{Context: ctx, Handler: handler} +} + +/* + ReplaceLogTargetPeer swagger:route PUT /services/haproxy/configuration/peers/{parent_name}/log_targets/{index} LogTarget replaceLogTargetPeer + +# Replace a Log Target + +Replaces a Log Target configuration by it's index in the specified parent. +*/ +type ReplaceLogTargetPeer struct { + Context *middleware.Context + Handler ReplaceLogTargetPeerHandler +} + +func (o *ReplaceLogTargetPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceLogTargetPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/log_target/replace_log_target_peer_parameters.go b/operations/log_target/replace_log_target_peer_parameters.go new file mode 100644 index 00000000..1814733a --- /dev/null +++ b/operations/log_target/replace_log_target_peer_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceLogTargetPeerParams creates a new ReplaceLogTargetPeerParams object +// with the default values initialized. +func NewReplaceLogTargetPeerParams() ReplaceLogTargetPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceLogTargetPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceLogTargetPeerParams contains all the bound params for the replace log target peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceLogTargetPeer +type ReplaceLogTargetPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.LogTarget + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Log Target Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceLogTargetPeerParams() beforehand. +func (o *ReplaceLogTargetPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.LogTarget + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceLogTargetPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceLogTargetPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceLogTargetPeerParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceLogTargetPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceLogTargetPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceLogTargetPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/log_target/replace_log_target_peer_responses.go b/operations/log_target/replace_log_target_peer_responses.go new file mode 100644 index 00000000..2b2e2690 --- /dev/null +++ b/operations/log_target/replace_log_target_peer_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceLogTargetPeerOKCode is the HTTP code returned for type ReplaceLogTargetPeerOK +const ReplaceLogTargetPeerOKCode int = 200 + +/* +ReplaceLogTargetPeerOK Log Target replaced + +swagger:response replaceLogTargetPeerOK +*/ +type ReplaceLogTargetPeerOK struct { + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetPeerOK creates ReplaceLogTargetPeerOK with default headers values +func NewReplaceLogTargetPeerOK() *ReplaceLogTargetPeerOK { + + return &ReplaceLogTargetPeerOK{} +} + +// WithPayload adds the payload to the replace log target peer o k response +func (o *ReplaceLogTargetPeerOK) WithPayload(payload *models.LogTarget) *ReplaceLogTargetPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target peer o k response +func (o *ReplaceLogTargetPeerOK) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetPeerAcceptedCode is the HTTP code returned for type ReplaceLogTargetPeerAccepted +const ReplaceLogTargetPeerAcceptedCode int = 202 + +/* +ReplaceLogTargetPeerAccepted Configuration change accepted and reload requested + +swagger:response replaceLogTargetPeerAccepted +*/ +type ReplaceLogTargetPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.LogTarget `json:"body,omitempty"` +} + +// NewReplaceLogTargetPeerAccepted creates ReplaceLogTargetPeerAccepted with default headers values +func NewReplaceLogTargetPeerAccepted() *ReplaceLogTargetPeerAccepted { + + return &ReplaceLogTargetPeerAccepted{} +} + +// WithReloadID adds the reloadId to the replace log target peer accepted response +func (o *ReplaceLogTargetPeerAccepted) WithReloadID(reloadID string) *ReplaceLogTargetPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace log target peer accepted response +func (o *ReplaceLogTargetPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace log target peer accepted response +func (o *ReplaceLogTargetPeerAccepted) WithPayload(payload *models.LogTarget) *ReplaceLogTargetPeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target peer accepted response +func (o *ReplaceLogTargetPeerAccepted) SetPayload(payload *models.LogTarget) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetPeerBadRequestCode is the HTTP code returned for type ReplaceLogTargetPeerBadRequest +const ReplaceLogTargetPeerBadRequestCode int = 400 + +/* +ReplaceLogTargetPeerBadRequest Bad request + +swagger:response replaceLogTargetPeerBadRequest +*/ +type ReplaceLogTargetPeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetPeerBadRequest creates ReplaceLogTargetPeerBadRequest with default headers values +func NewReplaceLogTargetPeerBadRequest() *ReplaceLogTargetPeerBadRequest { + + return &ReplaceLogTargetPeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target peer bad request response +func (o *ReplaceLogTargetPeerBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetPeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target peer bad request response +func (o *ReplaceLogTargetPeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target peer bad request response +func (o *ReplaceLogTargetPeerBadRequest) WithPayload(payload *models.Error) *ReplaceLogTargetPeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target peer bad request response +func (o *ReplaceLogTargetPeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetPeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceLogTargetPeerNotFoundCode is the HTTP code returned for type ReplaceLogTargetPeerNotFound +const ReplaceLogTargetPeerNotFoundCode int = 404 + +/* +ReplaceLogTargetPeerNotFound The specified resource was not found + +swagger:response replaceLogTargetPeerNotFound +*/ +type ReplaceLogTargetPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetPeerNotFound creates ReplaceLogTargetPeerNotFound with default headers values +func NewReplaceLogTargetPeerNotFound() *ReplaceLogTargetPeerNotFound { + + return &ReplaceLogTargetPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target peer not found response +func (o *ReplaceLogTargetPeerNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target peer not found response +func (o *ReplaceLogTargetPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target peer not found response +func (o *ReplaceLogTargetPeerNotFound) WithPayload(payload *models.Error) *ReplaceLogTargetPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target peer not found response +func (o *ReplaceLogTargetPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceLogTargetPeerDefault General Error + +swagger:response replaceLogTargetPeerDefault +*/ +type ReplaceLogTargetPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceLogTargetPeerDefault creates ReplaceLogTargetPeerDefault with default headers values +func NewReplaceLogTargetPeerDefault(code int) *ReplaceLogTargetPeerDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceLogTargetPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace log target peer default response +func (o *ReplaceLogTargetPeerDefault) WithStatusCode(code int) *ReplaceLogTargetPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace log target peer default response +func (o *ReplaceLogTargetPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace log target peer default response +func (o *ReplaceLogTargetPeerDefault) WithConfigurationVersion(configurationVersion string) *ReplaceLogTargetPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace log target peer default response +func (o *ReplaceLogTargetPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace log target peer default response +func (o *ReplaceLogTargetPeerDefault) WithPayload(payload *models.Error) *ReplaceLogTargetPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace log target peer default response +func (o *ReplaceLogTargetPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceLogTargetPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/log_target/replace_log_target_peer_urlbuilder.go b/operations/log_target/replace_log_target_peer_urlbuilder.go new file mode 100644 index 00000000..180950cb --- /dev/null +++ b/operations/log_target/replace_log_target_peer_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package log_target + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceLogTargetPeerURL generates an URL for the replace log target peer operation +type ReplaceLogTargetPeerURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetPeerURL) WithBasePath(bp string) *ReplaceLogTargetPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceLogTargetPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceLogTargetPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/log_targets/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceLogTargetPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceLogTargetPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceLogTargetPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceLogTargetPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceLogTargetPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceLogTargetPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceLogTargetPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceLogTargetPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/log_target/replace_log_target_responses.go b/operations/log_target/replace_log_target_responses.go deleted file mode 100644 index a29b5944..00000000 --- a/operations/log_target/replace_log_target_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceLogTargetOKCode is the HTTP code returned for type ReplaceLogTargetOK -const ReplaceLogTargetOKCode int = 200 - -/*ReplaceLogTargetOK Log Target replaced - -swagger:response replaceLogTargetOK -*/ -type ReplaceLogTargetOK struct { - - /* - In: Body - */ - Payload *models.LogTarget `json:"body,omitempty"` -} - -// NewReplaceLogTargetOK creates ReplaceLogTargetOK with default headers values -func NewReplaceLogTargetOK() *ReplaceLogTargetOK { - - return &ReplaceLogTargetOK{} -} - -// WithPayload adds the payload to the replace log target o k response -func (o *ReplaceLogTargetOK) WithPayload(payload *models.LogTarget) *ReplaceLogTargetOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace log target o k response -func (o *ReplaceLogTargetOK) SetPayload(payload *models.LogTarget) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceLogTargetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceLogTargetAcceptedCode is the HTTP code returned for type ReplaceLogTargetAccepted -const ReplaceLogTargetAcceptedCode int = 202 - -/*ReplaceLogTargetAccepted Configuration change accepted and reload requested - -swagger:response replaceLogTargetAccepted -*/ -type ReplaceLogTargetAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.LogTarget `json:"body,omitempty"` -} - -// NewReplaceLogTargetAccepted creates ReplaceLogTargetAccepted with default headers values -func NewReplaceLogTargetAccepted() *ReplaceLogTargetAccepted { - - return &ReplaceLogTargetAccepted{} -} - -// WithReloadID adds the reloadId to the replace log target accepted response -func (o *ReplaceLogTargetAccepted) WithReloadID(reloadID string) *ReplaceLogTargetAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace log target accepted response -func (o *ReplaceLogTargetAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace log target accepted response -func (o *ReplaceLogTargetAccepted) WithPayload(payload *models.LogTarget) *ReplaceLogTargetAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace log target accepted response -func (o *ReplaceLogTargetAccepted) SetPayload(payload *models.LogTarget) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceLogTargetAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceLogTargetBadRequestCode is the HTTP code returned for type ReplaceLogTargetBadRequest -const ReplaceLogTargetBadRequestCode int = 400 - -/*ReplaceLogTargetBadRequest Bad request - -swagger:response replaceLogTargetBadRequest -*/ -type ReplaceLogTargetBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceLogTargetBadRequest creates ReplaceLogTargetBadRequest with default headers values -func NewReplaceLogTargetBadRequest() *ReplaceLogTargetBadRequest { - - return &ReplaceLogTargetBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace log target bad request response -func (o *ReplaceLogTargetBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceLogTargetBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace log target bad request response -func (o *ReplaceLogTargetBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace log target bad request response -func (o *ReplaceLogTargetBadRequest) WithPayload(payload *models.Error) *ReplaceLogTargetBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace log target bad request response -func (o *ReplaceLogTargetBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceLogTargetBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceLogTargetNotFoundCode is the HTTP code returned for type ReplaceLogTargetNotFound -const ReplaceLogTargetNotFoundCode int = 404 - -/*ReplaceLogTargetNotFound The specified resource was not found - -swagger:response replaceLogTargetNotFound -*/ -type ReplaceLogTargetNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceLogTargetNotFound creates ReplaceLogTargetNotFound with default headers values -func NewReplaceLogTargetNotFound() *ReplaceLogTargetNotFound { - - return &ReplaceLogTargetNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace log target not found response -func (o *ReplaceLogTargetNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceLogTargetNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace log target not found response -func (o *ReplaceLogTargetNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace log target not found response -func (o *ReplaceLogTargetNotFound) WithPayload(payload *models.Error) *ReplaceLogTargetNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace log target not found response -func (o *ReplaceLogTargetNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceLogTargetNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceLogTargetDefault General Error - -swagger:response replaceLogTargetDefault -*/ -type ReplaceLogTargetDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceLogTargetDefault creates ReplaceLogTargetDefault with default headers values -func NewReplaceLogTargetDefault(code int) *ReplaceLogTargetDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceLogTargetDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace log target default response -func (o *ReplaceLogTargetDefault) WithStatusCode(code int) *ReplaceLogTargetDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace log target default response -func (o *ReplaceLogTargetDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace log target default response -func (o *ReplaceLogTargetDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceLogTargetDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace log target default response -func (o *ReplaceLogTargetDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace log target default response -func (o *ReplaceLogTargetDefault) WithPayload(payload *models.Error) *ReplaceLogTargetDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace log target default response -func (o *ReplaceLogTargetDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceLogTargetDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/log_target/replace_log_target_urlbuilder.go b/operations/log_target/replace_log_target_urlbuilder.go deleted file mode 100644 index 170c8107..00000000 --- a/operations/log_target/replace_log_target_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package log_target - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceLogTargetURL generates an URL for the replace log target operation -type ReplaceLogTargetURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceLogTargetURL) WithBasePath(bp string) *ReplaceLogTargetURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceLogTargetURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceLogTargetURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/log_targets/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on ReplaceLogTargetURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceLogTargetURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceLogTargetURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceLogTargetURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceLogTargetURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceLogTargetURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceLogTargetURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/mailer_entry/create_mailer_entry.go b/operations/mailer_entry/create_mailer_entry.go new file mode 100644 index 00000000..615e693d --- /dev/null +++ b/operations/mailer_entry/create_mailer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateMailerEntryHandlerFunc turns a function with the right signature into a create mailer entry handler +type CreateMailerEntryHandlerFunc func(CreateMailerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateMailerEntryHandlerFunc) Handle(params CreateMailerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateMailerEntryHandler interface for that can handle valid create mailer entry params +type CreateMailerEntryHandler interface { + Handle(CreateMailerEntryParams, interface{}) middleware.Responder +} + +// NewCreateMailerEntry creates a new http.Handler for the create mailer entry operation +func NewCreateMailerEntry(ctx *middleware.Context, handler CreateMailerEntryHandler) *CreateMailerEntry { + return &CreateMailerEntry{Context: ctx, Handler: handler} +} + +/* + CreateMailerEntry swagger:route POST /services/haproxy/configuration/mailer_entries MailerEntry createMailerEntry + +Add a new mailer_entry + +Adds a new mailer entry to the specified mailers section in the configuration file. +*/ +type CreateMailerEntry struct { + Context *middleware.Context + Handler CreateMailerEntryHandler +} + +func (o *CreateMailerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateMailerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailer_entry/create_mailer_entry_parameters.go b/operations/mailer_entry/create_mailer_entry_parameters.go new file mode 100644 index 00000000..677b9217 --- /dev/null +++ b/operations/mailer_entry/create_mailer_entry_parameters.go @@ -0,0 +1,229 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateMailerEntryParams creates a new CreateMailerEntryParams object +// with the default values initialized. +func NewCreateMailerEntryParams() CreateMailerEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateMailerEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateMailerEntryParams contains all the bound params for the create mailer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters createMailerEntry +type CreateMailerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.MailerEntry + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent mailers section name + Required: true + In: query + */ + MailersSection string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateMailerEntryParams() beforehand. +func (o *CreateMailerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.MailerEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qMailersSection, qhkMailersSection, _ := qs.GetOK("mailers_section") + if err := o.bindMailersSection(qMailersSection, qhkMailersSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateMailerEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateMailerEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindMailersSection binds and validates parameter MailersSection from query. +func (o *CreateMailerEntryParams) bindMailersSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("mailers_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("mailers_section", "query", raw); err != nil { + return err + } + o.MailersSection = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateMailerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateMailerEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/mailer_entry/create_mailer_entry_responses.go b/operations/mailer_entry/create_mailer_entry_responses.go new file mode 100644 index 00000000..a33d0bc5 --- /dev/null +++ b/operations/mailer_entry/create_mailer_entry_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateMailerEntryCreatedCode is the HTTP code returned for type CreateMailerEntryCreated +const CreateMailerEntryCreatedCode int = 201 + +/* +CreateMailerEntryCreated MailerEntry created + +swagger:response createMailerEntryCreated +*/ +type CreateMailerEntryCreated struct { + + /* + In: Body + */ + Payload *models.MailerEntry `json:"body,omitempty"` +} + +// NewCreateMailerEntryCreated creates CreateMailerEntryCreated with default headers values +func NewCreateMailerEntryCreated() *CreateMailerEntryCreated { + + return &CreateMailerEntryCreated{} +} + +// WithPayload adds the payload to the create mailer entry created response +func (o *CreateMailerEntryCreated) WithPayload(payload *models.MailerEntry) *CreateMailerEntryCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailer entry created response +func (o *CreateMailerEntryCreated) SetPayload(payload *models.MailerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailerEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateMailerEntryAcceptedCode is the HTTP code returned for type CreateMailerEntryAccepted +const CreateMailerEntryAcceptedCode int = 202 + +/* +CreateMailerEntryAccepted Configuration change accepted and reload requested + +swagger:response createMailerEntryAccepted +*/ +type CreateMailerEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.MailerEntry `json:"body,omitempty"` +} + +// NewCreateMailerEntryAccepted creates CreateMailerEntryAccepted with default headers values +func NewCreateMailerEntryAccepted() *CreateMailerEntryAccepted { + + return &CreateMailerEntryAccepted{} +} + +// WithReloadID adds the reloadId to the create mailer entry accepted response +func (o *CreateMailerEntryAccepted) WithReloadID(reloadID string) *CreateMailerEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create mailer entry accepted response +func (o *CreateMailerEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create mailer entry accepted response +func (o *CreateMailerEntryAccepted) WithPayload(payload *models.MailerEntry) *CreateMailerEntryAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailer entry accepted response +func (o *CreateMailerEntryAccepted) SetPayload(payload *models.MailerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailerEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateMailerEntryBadRequestCode is the HTTP code returned for type CreateMailerEntryBadRequest +const CreateMailerEntryBadRequestCode int = 400 + +/* +CreateMailerEntryBadRequest Bad request + +swagger:response createMailerEntryBadRequest +*/ +type CreateMailerEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateMailerEntryBadRequest creates CreateMailerEntryBadRequest with default headers values +func NewCreateMailerEntryBadRequest() *CreateMailerEntryBadRequest { + + return &CreateMailerEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create mailer entry bad request response +func (o *CreateMailerEntryBadRequest) WithConfigurationVersion(configurationVersion string) *CreateMailerEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create mailer entry bad request response +func (o *CreateMailerEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create mailer entry bad request response +func (o *CreateMailerEntryBadRequest) WithPayload(payload *models.Error) *CreateMailerEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailer entry bad request response +func (o *CreateMailerEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailerEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateMailerEntryConflictCode is the HTTP code returned for type CreateMailerEntryConflict +const CreateMailerEntryConflictCode int = 409 + +/* +CreateMailerEntryConflict The specified resource already exists + +swagger:response createMailerEntryConflict +*/ +type CreateMailerEntryConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateMailerEntryConflict creates CreateMailerEntryConflict with default headers values +func NewCreateMailerEntryConflict() *CreateMailerEntryConflict { + + return &CreateMailerEntryConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create mailer entry conflict response +func (o *CreateMailerEntryConflict) WithConfigurationVersion(configurationVersion string) *CreateMailerEntryConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create mailer entry conflict response +func (o *CreateMailerEntryConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create mailer entry conflict response +func (o *CreateMailerEntryConflict) WithPayload(payload *models.Error) *CreateMailerEntryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailer entry conflict response +func (o *CreateMailerEntryConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailerEntryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateMailerEntryDefault General Error + +swagger:response createMailerEntryDefault +*/ +type CreateMailerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateMailerEntryDefault creates CreateMailerEntryDefault with default headers values +func NewCreateMailerEntryDefault(code int) *CreateMailerEntryDefault { + if code <= 0 { + code = 500 + } + + return &CreateMailerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create mailer entry default response +func (o *CreateMailerEntryDefault) WithStatusCode(code int) *CreateMailerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create mailer entry default response +func (o *CreateMailerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create mailer entry default response +func (o *CreateMailerEntryDefault) WithConfigurationVersion(configurationVersion string) *CreateMailerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create mailer entry default response +func (o *CreateMailerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create mailer entry default response +func (o *CreateMailerEntryDefault) WithPayload(payload *models.Error) *CreateMailerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailer entry default response +func (o *CreateMailerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailer_entry/create_mailer_entry_urlbuilder.go b/operations/mailer_entry/create_mailer_entry_urlbuilder.go new file mode 100644 index 00000000..43de58e5 --- /dev/null +++ b/operations/mailer_entry/create_mailer_entry_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateMailerEntryURL generates an URL for the create mailer entry operation +type CreateMailerEntryURL struct { + ForceReload *bool + MailersSection string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateMailerEntryURL) WithBasePath(bp string) *CreateMailerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateMailerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateMailerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailer_entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + mailersSectionQ := o.MailersSection + if mailersSectionQ != "" { + qs.Set("mailers_section", mailersSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateMailerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateMailerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateMailerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateMailerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateMailerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateMailerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailer_entry/delete_mailer_entry.go b/operations/mailer_entry/delete_mailer_entry.go new file mode 100644 index 00000000..cc140eae --- /dev/null +++ b/operations/mailer_entry/delete_mailer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteMailerEntryHandlerFunc turns a function with the right signature into a delete mailer entry handler +type DeleteMailerEntryHandlerFunc func(DeleteMailerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteMailerEntryHandlerFunc) Handle(params DeleteMailerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteMailerEntryHandler interface for that can handle valid delete mailer entry params +type DeleteMailerEntryHandler interface { + Handle(DeleteMailerEntryParams, interface{}) middleware.Responder +} + +// NewDeleteMailerEntry creates a new http.Handler for the delete mailer entry operation +func NewDeleteMailerEntry(ctx *middleware.Context, handler DeleteMailerEntryHandler) *DeleteMailerEntry { + return &DeleteMailerEntry{Context: ctx, Handler: handler} +} + +/* + DeleteMailerEntry swagger:route DELETE /services/haproxy/configuration/mailer_entries/{name} MailerEntry deleteMailerEntry + +Delete a mailer_entry + +Deletes a mailer entry configuration by it's name in the specified mailers section. +*/ +type DeleteMailerEntry struct { + Context *middleware.Context + Handler DeleteMailerEntryHandler +} + +func (o *DeleteMailerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteMailerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailer_entry/delete_mailer_entry_parameters.go b/operations/mailer_entry/delete_mailer_entry_parameters.go new file mode 100644 index 00000000..4d159376 --- /dev/null +++ b/operations/mailer_entry/delete_mailer_entry_parameters.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteMailerEntryParams creates a new DeleteMailerEntryParams object +// with the default values initialized. +func NewDeleteMailerEntryParams() DeleteMailerEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteMailerEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteMailerEntryParams contains all the bound params for the delete mailer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteMailerEntry +type DeleteMailerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent mailers section name + Required: true + In: query + */ + MailersSection string + /*MailerEntry name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteMailerEntryParams() beforehand. +func (o *DeleteMailerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qMailersSection, qhkMailersSection, _ := qs.GetOK("mailers_section") + if err := o.bindMailersSection(qMailersSection, qhkMailersSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteMailerEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteMailerEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindMailersSection binds and validates parameter MailersSection from query. +func (o *DeleteMailerEntryParams) bindMailersSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("mailers_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("mailers_section", "query", raw); err != nil { + return err + } + o.MailersSection = raw + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteMailerEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteMailerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteMailerEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/mailer_entry/delete_mailer_entry_responses.go b/operations/mailer_entry/delete_mailer_entry_responses.go new file mode 100644 index 00000000..a148a3aa --- /dev/null +++ b/operations/mailer_entry/delete_mailer_entry_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteMailerEntryAcceptedCode is the HTTP code returned for type DeleteMailerEntryAccepted +const DeleteMailerEntryAcceptedCode int = 202 + +/* +DeleteMailerEntryAccepted Configuration change accepted and reload requested + +swagger:response deleteMailerEntryAccepted +*/ +type DeleteMailerEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteMailerEntryAccepted creates DeleteMailerEntryAccepted with default headers values +func NewDeleteMailerEntryAccepted() *DeleteMailerEntryAccepted { + + return &DeleteMailerEntryAccepted{} +} + +// WithReloadID adds the reloadId to the delete mailer entry accepted response +func (o *DeleteMailerEntryAccepted) WithReloadID(reloadID string) *DeleteMailerEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete mailer entry accepted response +func (o *DeleteMailerEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteMailerEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteMailerEntryNoContentCode is the HTTP code returned for type DeleteMailerEntryNoContent +const DeleteMailerEntryNoContentCode int = 204 + +/* +DeleteMailerEntryNoContent MailerEntry deleted + +swagger:response deleteMailerEntryNoContent +*/ +type DeleteMailerEntryNoContent struct { +} + +// NewDeleteMailerEntryNoContent creates DeleteMailerEntryNoContent with default headers values +func NewDeleteMailerEntryNoContent() *DeleteMailerEntryNoContent { + + return &DeleteMailerEntryNoContent{} +} + +// WriteResponse to the client +func (o *DeleteMailerEntryNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteMailerEntryNotFoundCode is the HTTP code returned for type DeleteMailerEntryNotFound +const DeleteMailerEntryNotFoundCode int = 404 + +/* +DeleteMailerEntryNotFound The specified resource was not found + +swagger:response deleteMailerEntryNotFound +*/ +type DeleteMailerEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteMailerEntryNotFound creates DeleteMailerEntryNotFound with default headers values +func NewDeleteMailerEntryNotFound() *DeleteMailerEntryNotFound { + + return &DeleteMailerEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete mailer entry not found response +func (o *DeleteMailerEntryNotFound) WithConfigurationVersion(configurationVersion string) *DeleteMailerEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete mailer entry not found response +func (o *DeleteMailerEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete mailer entry not found response +func (o *DeleteMailerEntryNotFound) WithPayload(payload *models.Error) *DeleteMailerEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete mailer entry not found response +func (o *DeleteMailerEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteMailerEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteMailerEntryDefault General Error + +swagger:response deleteMailerEntryDefault +*/ +type DeleteMailerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteMailerEntryDefault creates DeleteMailerEntryDefault with default headers values +func NewDeleteMailerEntryDefault(code int) *DeleteMailerEntryDefault { + if code <= 0 { + code = 500 + } + + return &DeleteMailerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete mailer entry default response +func (o *DeleteMailerEntryDefault) WithStatusCode(code int) *DeleteMailerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete mailer entry default response +func (o *DeleteMailerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete mailer entry default response +func (o *DeleteMailerEntryDefault) WithConfigurationVersion(configurationVersion string) *DeleteMailerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete mailer entry default response +func (o *DeleteMailerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete mailer entry default response +func (o *DeleteMailerEntryDefault) WithPayload(payload *models.Error) *DeleteMailerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete mailer entry default response +func (o *DeleteMailerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteMailerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailer_entry/delete_mailer_entry_urlbuilder.go b/operations/mailer_entry/delete_mailer_entry_urlbuilder.go new file mode 100644 index 00000000..27c8c66d --- /dev/null +++ b/operations/mailer_entry/delete_mailer_entry_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteMailerEntryURL generates an URL for the delete mailer entry operation +type DeleteMailerEntryURL struct { + Name string + + ForceReload *bool + MailersSection string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteMailerEntryURL) WithBasePath(bp string) *DeleteMailerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteMailerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteMailerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailer_entries/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteMailerEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + mailersSectionQ := o.MailersSection + if mailersSectionQ != "" { + qs.Set("mailers_section", mailersSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteMailerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteMailerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteMailerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteMailerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteMailerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteMailerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailer_entry/get_mailer_entries.go b/operations/mailer_entry/get_mailer_entries.go new file mode 100644 index 00000000..e540ba96 --- /dev/null +++ b/operations/mailer_entry/get_mailer_entries.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetMailerEntriesHandlerFunc turns a function with the right signature into a get mailer entries handler +type GetMailerEntriesHandlerFunc func(GetMailerEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetMailerEntriesHandlerFunc) Handle(params GetMailerEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetMailerEntriesHandler interface for that can handle valid get mailer entries params +type GetMailerEntriesHandler interface { + Handle(GetMailerEntriesParams, interface{}) middleware.Responder +} + +// NewGetMailerEntries creates a new http.Handler for the get mailer entries operation +func NewGetMailerEntries(ctx *middleware.Context, handler GetMailerEntriesHandler) *GetMailerEntries { + return &GetMailerEntries{Context: ctx, Handler: handler} +} + +/* + GetMailerEntries swagger:route GET /services/haproxy/configuration/mailer_entries MailerEntry getMailerEntries + +Return an array of mailer_entries + +Returns an array of all the mailer_entries configured in the specified mailers section. +*/ +type GetMailerEntries struct { + Context *middleware.Context + Handler GetMailerEntriesHandler +} + +func (o *GetMailerEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetMailerEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailer_entry/get_mailer_entries_parameters.go b/operations/mailer_entry/get_mailer_entries_parameters.go new file mode 100644 index 00000000..dc8105bb --- /dev/null +++ b/operations/mailer_entry/get_mailer_entries_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetMailerEntriesParams creates a new GetMailerEntriesParams object +// +// There are no default values defined in the spec. +func NewGetMailerEntriesParams() GetMailerEntriesParams { + + return GetMailerEntriesParams{} +} + +// GetMailerEntriesParams contains all the bound params for the get mailer entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters getMailerEntries +type GetMailerEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent mailers section name + Required: true + In: query + */ + MailersSection string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetMailerEntriesParams() beforehand. +func (o *GetMailerEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qMailersSection, qhkMailersSection, _ := qs.GetOK("mailers_section") + if err := o.bindMailersSection(qMailersSection, qhkMailersSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindMailersSection binds and validates parameter MailersSection from query. +func (o *GetMailerEntriesParams) bindMailersSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("mailers_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("mailers_section", "query", raw); err != nil { + return err + } + o.MailersSection = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetMailerEntriesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/mailer_entry/get_mailer_entries_responses.go b/operations/mailer_entry/get_mailer_entries_responses.go new file mode 100644 index 00000000..88ed2818 --- /dev/null +++ b/operations/mailer_entry/get_mailer_entries_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetMailerEntriesOKCode is the HTTP code returned for type GetMailerEntriesOK +const GetMailerEntriesOKCode int = 200 + +/* +GetMailerEntriesOK Successful operation + +swagger:response getMailerEntriesOK +*/ +type GetMailerEntriesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.MailerEntries `json:"body,omitempty"` +} + +// NewGetMailerEntriesOK creates GetMailerEntriesOK with default headers values +func NewGetMailerEntriesOK() *GetMailerEntriesOK { + + return &GetMailerEntriesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get mailer entries o k response +func (o *GetMailerEntriesOK) WithConfigurationVersion(configurationVersion string) *GetMailerEntriesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailer entries o k response +func (o *GetMailerEntriesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailer entries o k response +func (o *GetMailerEntriesOK) WithPayload(payload models.MailerEntries) *GetMailerEntriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailer entries o k response +func (o *GetMailerEntriesOK) SetPayload(payload models.MailerEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailerEntriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.MailerEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetMailerEntriesDefault General Error + +swagger:response getMailerEntriesDefault +*/ +type GetMailerEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetMailerEntriesDefault creates GetMailerEntriesDefault with default headers values +func NewGetMailerEntriesDefault(code int) *GetMailerEntriesDefault { + if code <= 0 { + code = 500 + } + + return &GetMailerEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get mailer entries default response +func (o *GetMailerEntriesDefault) WithStatusCode(code int) *GetMailerEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get mailer entries default response +func (o *GetMailerEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get mailer entries default response +func (o *GetMailerEntriesDefault) WithConfigurationVersion(configurationVersion string) *GetMailerEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailer entries default response +func (o *GetMailerEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailer entries default response +func (o *GetMailerEntriesDefault) WithPayload(payload *models.Error) *GetMailerEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailer entries default response +func (o *GetMailerEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailerEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailer_entry/get_mailer_entries_urlbuilder.go b/operations/mailer_entry/get_mailer_entries_urlbuilder.go new file mode 100644 index 00000000..4cf696ce --- /dev/null +++ b/operations/mailer_entry/get_mailer_entries_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetMailerEntriesURL generates an URL for the get mailer entries operation +type GetMailerEntriesURL struct { + MailersSection string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailerEntriesURL) WithBasePath(bp string) *GetMailerEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailerEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetMailerEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailer_entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + mailersSectionQ := o.MailersSection + if mailersSectionQ != "" { + qs.Set("mailers_section", mailersSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetMailerEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetMailerEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetMailerEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetMailerEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetMailerEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetMailerEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailer_entry/get_mailer_entry.go b/operations/mailer_entry/get_mailer_entry.go new file mode 100644 index 00000000..5dd89522 --- /dev/null +++ b/operations/mailer_entry/get_mailer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetMailerEntryHandlerFunc turns a function with the right signature into a get mailer entry handler +type GetMailerEntryHandlerFunc func(GetMailerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetMailerEntryHandlerFunc) Handle(params GetMailerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetMailerEntryHandler interface for that can handle valid get mailer entry params +type GetMailerEntryHandler interface { + Handle(GetMailerEntryParams, interface{}) middleware.Responder +} + +// NewGetMailerEntry creates a new http.Handler for the get mailer entry operation +func NewGetMailerEntry(ctx *middleware.Context, handler GetMailerEntryHandler) *GetMailerEntry { + return &GetMailerEntry{Context: ctx, Handler: handler} +} + +/* + GetMailerEntry swagger:route GET /services/haproxy/configuration/mailer_entries/{name} MailerEntry getMailerEntry + +Return one mailer_entry + +Returns one mailer_entry configuration by it's name in the specified mailers section. +*/ +type GetMailerEntry struct { + Context *middleware.Context + Handler GetMailerEntryHandler +} + +func (o *GetMailerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetMailerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailer_entry/get_mailer_entry_parameters.go b/operations/mailer_entry/get_mailer_entry_parameters.go new file mode 100644 index 00000000..a7d60ca3 --- /dev/null +++ b/operations/mailer_entry/get_mailer_entry_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetMailerEntryParams creates a new GetMailerEntryParams object +// +// There are no default values defined in the spec. +func NewGetMailerEntryParams() GetMailerEntryParams { + + return GetMailerEntryParams{} +} + +// GetMailerEntryParams contains all the bound params for the get mailer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters getMailerEntry +type GetMailerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent mailers name + Required: true + In: query + */ + MailersSection string + /*MailerEntry name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetMailerEntryParams() beforehand. +func (o *GetMailerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qMailersSection, qhkMailersSection, _ := qs.GetOK("mailers_section") + if err := o.bindMailersSection(qMailersSection, qhkMailersSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindMailersSection binds and validates parameter MailersSection from query. +func (o *GetMailerEntryParams) bindMailersSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("mailers_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("mailers_section", "query", raw); err != nil { + return err + } + o.MailersSection = raw + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetMailerEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetMailerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/mailer_entry/get_mailer_entry_responses.go b/operations/mailer_entry/get_mailer_entry_responses.go new file mode 100644 index 00000000..393169c8 --- /dev/null +++ b/operations/mailer_entry/get_mailer_entry_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetMailerEntryOKCode is the HTTP code returned for type GetMailerEntryOK +const GetMailerEntryOKCode int = 200 + +/* +GetMailerEntryOK Successful operation + +swagger:response getMailerEntryOK +*/ +type GetMailerEntryOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.MailerEntry `json:"body,omitempty"` +} + +// NewGetMailerEntryOK creates GetMailerEntryOK with default headers values +func NewGetMailerEntryOK() *GetMailerEntryOK { + + return &GetMailerEntryOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get mailer entry o k response +func (o *GetMailerEntryOK) WithConfigurationVersion(configurationVersion string) *GetMailerEntryOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailer entry o k response +func (o *GetMailerEntryOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailer entry o k response +func (o *GetMailerEntryOK) WithPayload(payload *models.MailerEntry) *GetMailerEntryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailer entry o k response +func (o *GetMailerEntryOK) SetPayload(payload *models.MailerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailerEntryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetMailerEntryNotFoundCode is the HTTP code returned for type GetMailerEntryNotFound +const GetMailerEntryNotFoundCode int = 404 + +/* +GetMailerEntryNotFound The specified resource already exists + +swagger:response getMailerEntryNotFound +*/ +type GetMailerEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetMailerEntryNotFound creates GetMailerEntryNotFound with default headers values +func NewGetMailerEntryNotFound() *GetMailerEntryNotFound { + + return &GetMailerEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get mailer entry not found response +func (o *GetMailerEntryNotFound) WithConfigurationVersion(configurationVersion string) *GetMailerEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailer entry not found response +func (o *GetMailerEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailer entry not found response +func (o *GetMailerEntryNotFound) WithPayload(payload *models.Error) *GetMailerEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailer entry not found response +func (o *GetMailerEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailerEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetMailerEntryDefault General Error + +swagger:response getMailerEntryDefault +*/ +type GetMailerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetMailerEntryDefault creates GetMailerEntryDefault with default headers values +func NewGetMailerEntryDefault(code int) *GetMailerEntryDefault { + if code <= 0 { + code = 500 + } + + return &GetMailerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get mailer entry default response +func (o *GetMailerEntryDefault) WithStatusCode(code int) *GetMailerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get mailer entry default response +func (o *GetMailerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get mailer entry default response +func (o *GetMailerEntryDefault) WithConfigurationVersion(configurationVersion string) *GetMailerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailer entry default response +func (o *GetMailerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailer entry default response +func (o *GetMailerEntryDefault) WithPayload(payload *models.Error) *GetMailerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailer entry default response +func (o *GetMailerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailer_entry/get_mailer_entry_urlbuilder.go b/operations/mailer_entry/get_mailer_entry_urlbuilder.go new file mode 100644 index 00000000..d19c9ca4 --- /dev/null +++ b/operations/mailer_entry/get_mailer_entry_urlbuilder.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetMailerEntryURL generates an URL for the get mailer entry operation +type GetMailerEntryURL struct { + Name string + + MailersSection string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailerEntryURL) WithBasePath(bp string) *GetMailerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetMailerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailer_entries/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetMailerEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + mailersSectionQ := o.MailersSection + if mailersSectionQ != "" { + qs.Set("mailers_section", mailersSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetMailerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetMailerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetMailerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetMailerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetMailerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetMailerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailer_entry/replace_mailer_entry.go b/operations/mailer_entry/replace_mailer_entry.go new file mode 100644 index 00000000..f9adec72 --- /dev/null +++ b/operations/mailer_entry/replace_mailer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceMailerEntryHandlerFunc turns a function with the right signature into a replace mailer entry handler +type ReplaceMailerEntryHandlerFunc func(ReplaceMailerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceMailerEntryHandlerFunc) Handle(params ReplaceMailerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceMailerEntryHandler interface for that can handle valid replace mailer entry params +type ReplaceMailerEntryHandler interface { + Handle(ReplaceMailerEntryParams, interface{}) middleware.Responder +} + +// NewReplaceMailerEntry creates a new http.Handler for the replace mailer entry operation +func NewReplaceMailerEntry(ctx *middleware.Context, handler ReplaceMailerEntryHandler) *ReplaceMailerEntry { + return &ReplaceMailerEntry{Context: ctx, Handler: handler} +} + +/* + ReplaceMailerEntry swagger:route PUT /services/haproxy/configuration/mailer_entries/{name} MailerEntry replaceMailerEntry + +Replace a mailer_entry + +Replaces a mailer entry configuration by it's name in the specified mailers section. +*/ +type ReplaceMailerEntry struct { + Context *middleware.Context + Handler ReplaceMailerEntryHandler +} + +func (o *ReplaceMailerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceMailerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailer_entry/replace_mailer_entry_parameters.go b/operations/mailer_entry/replace_mailer_entry_parameters.go new file mode 100644 index 00000000..eef48741 --- /dev/null +++ b/operations/mailer_entry/replace_mailer_entry_parameters.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceMailerEntryParams creates a new ReplaceMailerEntryParams object +// with the default values initialized. +func NewReplaceMailerEntryParams() ReplaceMailerEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceMailerEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceMailerEntryParams contains all the bound params for the replace mailer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceMailerEntry +type ReplaceMailerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.MailerEntry + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent mailers section name + Required: true + In: query + */ + MailersSection string + /*MailerEntry name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceMailerEntryParams() beforehand. +func (o *ReplaceMailerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.MailerEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qMailersSection, qhkMailersSection, _ := qs.GetOK("mailers_section") + if err := o.bindMailersSection(qMailersSection, qhkMailersSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceMailerEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceMailerEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindMailersSection binds and validates parameter MailersSection from query. +func (o *ReplaceMailerEntryParams) bindMailersSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("mailers_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("mailers_section", "query", raw); err != nil { + return err + } + o.MailersSection = raw + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceMailerEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceMailerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceMailerEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/mailer_entry/replace_mailer_entry_responses.go b/operations/mailer_entry/replace_mailer_entry_responses.go new file mode 100644 index 00000000..8b4092f5 --- /dev/null +++ b/operations/mailer_entry/replace_mailer_entry_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceMailerEntryOKCode is the HTTP code returned for type ReplaceMailerEntryOK +const ReplaceMailerEntryOKCode int = 200 + +/* +ReplaceMailerEntryOK MailerEntry replaced + +swagger:response replaceMailerEntryOK +*/ +type ReplaceMailerEntryOK struct { + + /* + In: Body + */ + Payload *models.MailerEntry `json:"body,omitempty"` +} + +// NewReplaceMailerEntryOK creates ReplaceMailerEntryOK with default headers values +func NewReplaceMailerEntryOK() *ReplaceMailerEntryOK { + + return &ReplaceMailerEntryOK{} +} + +// WithPayload adds the payload to the replace mailer entry o k response +func (o *ReplaceMailerEntryOK) WithPayload(payload *models.MailerEntry) *ReplaceMailerEntryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace mailer entry o k response +func (o *ReplaceMailerEntryOK) SetPayload(payload *models.MailerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceMailerEntryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceMailerEntryAcceptedCode is the HTTP code returned for type ReplaceMailerEntryAccepted +const ReplaceMailerEntryAcceptedCode int = 202 + +/* +ReplaceMailerEntryAccepted Configuration change accepted and reload requested + +swagger:response replaceMailerEntryAccepted +*/ +type ReplaceMailerEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.MailerEntry `json:"body,omitempty"` +} + +// NewReplaceMailerEntryAccepted creates ReplaceMailerEntryAccepted with default headers values +func NewReplaceMailerEntryAccepted() *ReplaceMailerEntryAccepted { + + return &ReplaceMailerEntryAccepted{} +} + +// WithReloadID adds the reloadId to the replace mailer entry accepted response +func (o *ReplaceMailerEntryAccepted) WithReloadID(reloadID string) *ReplaceMailerEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace mailer entry accepted response +func (o *ReplaceMailerEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace mailer entry accepted response +func (o *ReplaceMailerEntryAccepted) WithPayload(payload *models.MailerEntry) *ReplaceMailerEntryAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace mailer entry accepted response +func (o *ReplaceMailerEntryAccepted) SetPayload(payload *models.MailerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceMailerEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceMailerEntryBadRequestCode is the HTTP code returned for type ReplaceMailerEntryBadRequest +const ReplaceMailerEntryBadRequestCode int = 400 + +/* +ReplaceMailerEntryBadRequest Bad request + +swagger:response replaceMailerEntryBadRequest +*/ +type ReplaceMailerEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceMailerEntryBadRequest creates ReplaceMailerEntryBadRequest with default headers values +func NewReplaceMailerEntryBadRequest() *ReplaceMailerEntryBadRequest { + + return &ReplaceMailerEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace mailer entry bad request response +func (o *ReplaceMailerEntryBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceMailerEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace mailer entry bad request response +func (o *ReplaceMailerEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace mailer entry bad request response +func (o *ReplaceMailerEntryBadRequest) WithPayload(payload *models.Error) *ReplaceMailerEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace mailer entry bad request response +func (o *ReplaceMailerEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceMailerEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceMailerEntryNotFoundCode is the HTTP code returned for type ReplaceMailerEntryNotFound +const ReplaceMailerEntryNotFoundCode int = 404 + +/* +ReplaceMailerEntryNotFound The specified resource was not found + +swagger:response replaceMailerEntryNotFound +*/ +type ReplaceMailerEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceMailerEntryNotFound creates ReplaceMailerEntryNotFound with default headers values +func NewReplaceMailerEntryNotFound() *ReplaceMailerEntryNotFound { + + return &ReplaceMailerEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace mailer entry not found response +func (o *ReplaceMailerEntryNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceMailerEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace mailer entry not found response +func (o *ReplaceMailerEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace mailer entry not found response +func (o *ReplaceMailerEntryNotFound) WithPayload(payload *models.Error) *ReplaceMailerEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace mailer entry not found response +func (o *ReplaceMailerEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceMailerEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceMailerEntryDefault General Error + +swagger:response replaceMailerEntryDefault +*/ +type ReplaceMailerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceMailerEntryDefault creates ReplaceMailerEntryDefault with default headers values +func NewReplaceMailerEntryDefault(code int) *ReplaceMailerEntryDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceMailerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace mailer entry default response +func (o *ReplaceMailerEntryDefault) WithStatusCode(code int) *ReplaceMailerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace mailer entry default response +func (o *ReplaceMailerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace mailer entry default response +func (o *ReplaceMailerEntryDefault) WithConfigurationVersion(configurationVersion string) *ReplaceMailerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace mailer entry default response +func (o *ReplaceMailerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace mailer entry default response +func (o *ReplaceMailerEntryDefault) WithPayload(payload *models.Error) *ReplaceMailerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace mailer entry default response +func (o *ReplaceMailerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceMailerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailer_entry/replace_mailer_entry_urlbuilder.go b/operations/mailer_entry/replace_mailer_entry_urlbuilder.go new file mode 100644 index 00000000..7619a4bf --- /dev/null +++ b/operations/mailer_entry/replace_mailer_entry_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceMailerEntryURL generates an URL for the replace mailer entry operation +type ReplaceMailerEntryURL struct { + Name string + + ForceReload *bool + MailersSection string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceMailerEntryURL) WithBasePath(bp string) *ReplaceMailerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceMailerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceMailerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailer_entries/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceMailerEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + mailersSectionQ := o.MailersSection + if mailersSectionQ != "" { + qs.Set("mailers_section", mailersSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceMailerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceMailerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceMailerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceMailerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceMailerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceMailerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailers/create_mailers_section.go b/operations/mailers/create_mailers_section.go new file mode 100644 index 00000000..4b7e825a --- /dev/null +++ b/operations/mailers/create_mailers_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateMailersSectionHandlerFunc turns a function with the right signature into a create mailers section handler +type CreateMailersSectionHandlerFunc func(CreateMailersSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateMailersSectionHandlerFunc) Handle(params CreateMailersSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateMailersSectionHandler interface for that can handle valid create mailers section params +type CreateMailersSectionHandler interface { + Handle(CreateMailersSectionParams, interface{}) middleware.Responder +} + +// NewCreateMailersSection creates a new http.Handler for the create mailers section operation +func NewCreateMailersSection(ctx *middleware.Context, handler CreateMailersSectionHandler) *CreateMailersSection { + return &CreateMailersSection{Context: ctx, Handler: handler} +} + +/* + CreateMailersSection swagger:route POST /services/haproxy/configuration/mailers_section Mailers createMailersSection + +# Add a new Mailers section + +Creates a new empty Mailers section +*/ +type CreateMailersSection struct { + Context *middleware.Context + Handler CreateMailersSectionHandler +} + +func (o *CreateMailersSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateMailersSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailers/create_mailers_section_parameters.go b/operations/mailers/create_mailers_section_parameters.go new file mode 100644 index 00000000..f72584ec --- /dev/null +++ b/operations/mailers/create_mailers_section_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateMailersSectionParams creates a new CreateMailersSectionParams object +// with the default values initialized. +func NewCreateMailersSectionParams() CreateMailersSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreateMailersSectionParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreateMailersSectionParams contains all the bound params for the create mailers section operation +// typically these are obtained from a http.Request +// +// swagger:parameters createMailersSection +type CreateMailersSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.MailersSection + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateMailersSectionParams() beforehand. +func (o *CreateMailersSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.MailersSection + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateMailersSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateMailersSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateMailersSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateMailersSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateMailersSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateMailersSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/mailers/create_mailers_section_responses.go b/operations/mailers/create_mailers_section_responses.go new file mode 100644 index 00000000..5721ff83 --- /dev/null +++ b/operations/mailers/create_mailers_section_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateMailersSectionCreatedCode is the HTTP code returned for type CreateMailersSectionCreated +const CreateMailersSectionCreatedCode int = 201 + +/* +CreateMailersSectionCreated Mailers created + +swagger:response createMailersSectionCreated +*/ +type CreateMailersSectionCreated struct { + + /* + In: Body + */ + Payload *models.MailersSection `json:"body,omitempty"` +} + +// NewCreateMailersSectionCreated creates CreateMailersSectionCreated with default headers values +func NewCreateMailersSectionCreated() *CreateMailersSectionCreated { + + return &CreateMailersSectionCreated{} +} + +// WithPayload adds the payload to the create mailers section created response +func (o *CreateMailersSectionCreated) WithPayload(payload *models.MailersSection) *CreateMailersSectionCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailers section created response +func (o *CreateMailersSectionCreated) SetPayload(payload *models.MailersSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailersSectionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateMailersSectionAcceptedCode is the HTTP code returned for type CreateMailersSectionAccepted +const CreateMailersSectionAcceptedCode int = 202 + +/* +CreateMailersSectionAccepted Configuration change accepted and reload requested + +swagger:response createMailersSectionAccepted +*/ +type CreateMailersSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.MailersSection `json:"body,omitempty"` +} + +// NewCreateMailersSectionAccepted creates CreateMailersSectionAccepted with default headers values +func NewCreateMailersSectionAccepted() *CreateMailersSectionAccepted { + + return &CreateMailersSectionAccepted{} +} + +// WithReloadID adds the reloadId to the create mailers section accepted response +func (o *CreateMailersSectionAccepted) WithReloadID(reloadID string) *CreateMailersSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create mailers section accepted response +func (o *CreateMailersSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create mailers section accepted response +func (o *CreateMailersSectionAccepted) WithPayload(payload *models.MailersSection) *CreateMailersSectionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailers section accepted response +func (o *CreateMailersSectionAccepted) SetPayload(payload *models.MailersSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailersSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateMailersSectionBadRequestCode is the HTTP code returned for type CreateMailersSectionBadRequest +const CreateMailersSectionBadRequestCode int = 400 + +/* +CreateMailersSectionBadRequest Bad request + +swagger:response createMailersSectionBadRequest +*/ +type CreateMailersSectionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateMailersSectionBadRequest creates CreateMailersSectionBadRequest with default headers values +func NewCreateMailersSectionBadRequest() *CreateMailersSectionBadRequest { + + return &CreateMailersSectionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create mailers section bad request response +func (o *CreateMailersSectionBadRequest) WithConfigurationVersion(configurationVersion string) *CreateMailersSectionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create mailers section bad request response +func (o *CreateMailersSectionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create mailers section bad request response +func (o *CreateMailersSectionBadRequest) WithPayload(payload *models.Error) *CreateMailersSectionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailers section bad request response +func (o *CreateMailersSectionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailersSectionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateMailersSectionConflictCode is the HTTP code returned for type CreateMailersSectionConflict +const CreateMailersSectionConflictCode int = 409 + +/* +CreateMailersSectionConflict The specified resource already exists + +swagger:response createMailersSectionConflict +*/ +type CreateMailersSectionConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateMailersSectionConflict creates CreateMailersSectionConflict with default headers values +func NewCreateMailersSectionConflict() *CreateMailersSectionConflict { + + return &CreateMailersSectionConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create mailers section conflict response +func (o *CreateMailersSectionConflict) WithConfigurationVersion(configurationVersion string) *CreateMailersSectionConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create mailers section conflict response +func (o *CreateMailersSectionConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create mailers section conflict response +func (o *CreateMailersSectionConflict) WithPayload(payload *models.Error) *CreateMailersSectionConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailers section conflict response +func (o *CreateMailersSectionConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailersSectionConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateMailersSectionDefault General Error + +swagger:response createMailersSectionDefault +*/ +type CreateMailersSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateMailersSectionDefault creates CreateMailersSectionDefault with default headers values +func NewCreateMailersSectionDefault(code int) *CreateMailersSectionDefault { + if code <= 0 { + code = 500 + } + + return &CreateMailersSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create mailers section default response +func (o *CreateMailersSectionDefault) WithStatusCode(code int) *CreateMailersSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create mailers section default response +func (o *CreateMailersSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create mailers section default response +func (o *CreateMailersSectionDefault) WithConfigurationVersion(configurationVersion string) *CreateMailersSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create mailers section default response +func (o *CreateMailersSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create mailers section default response +func (o *CreateMailersSectionDefault) WithPayload(payload *models.Error) *CreateMailersSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create mailers section default response +func (o *CreateMailersSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateMailersSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailers/create_mailers_section_urlbuilder.go b/operations/mailers/create_mailers_section_urlbuilder.go new file mode 100644 index 00000000..99143bae --- /dev/null +++ b/operations/mailers/create_mailers_section_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateMailersSectionURL generates an URL for the create mailers section operation +type CreateMailersSectionURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateMailersSectionURL) WithBasePath(bp string) *CreateMailersSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateMailersSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateMailersSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailers_section" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateMailersSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateMailersSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateMailersSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateMailersSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateMailersSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateMailersSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailers/delete_mailers_section.go b/operations/mailers/delete_mailers_section.go new file mode 100644 index 00000000..27751a0e --- /dev/null +++ b/operations/mailers/delete_mailers_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteMailersSectionHandlerFunc turns a function with the right signature into a delete mailers section handler +type DeleteMailersSectionHandlerFunc func(DeleteMailersSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteMailersSectionHandlerFunc) Handle(params DeleteMailersSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteMailersSectionHandler interface for that can handle valid delete mailers section params +type DeleteMailersSectionHandler interface { + Handle(DeleteMailersSectionParams, interface{}) middleware.Responder +} + +// NewDeleteMailersSection creates a new http.Handler for the delete mailers section operation +func NewDeleteMailersSection(ctx *middleware.Context, handler DeleteMailersSectionHandler) *DeleteMailersSection { + return &DeleteMailersSection{Context: ctx, Handler: handler} +} + +/* + DeleteMailersSection swagger:route DELETE /services/haproxy/configuration/mailers_section/{name} Mailers deleteMailersSection + +# Delete a Mailers section + +Deletes a mailers from the configuration by it's name. +*/ +type DeleteMailersSection struct { + Context *middleware.Context + Handler DeleteMailersSectionHandler +} + +func (o *DeleteMailersSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteMailersSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailers/delete_mailers_section_parameters.go b/operations/mailers/delete_mailers_section_parameters.go new file mode 100644 index 00000000..3a74652d --- /dev/null +++ b/operations/mailers/delete_mailers_section_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteMailersSectionParams creates a new DeleteMailersSectionParams object +// with the default values initialized. +func NewDeleteMailersSectionParams() DeleteMailersSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteMailersSectionParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteMailersSectionParams contains all the bound params for the delete mailers section operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteMailersSection +type DeleteMailersSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Mailers name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteMailersSectionParams() beforehand. +func (o *DeleteMailersSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteMailersSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteMailersSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteMailersSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteMailersSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteMailersSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/mailers/delete_mailers_section_responses.go b/operations/mailers/delete_mailers_section_responses.go new file mode 100644 index 00000000..36a8629a --- /dev/null +++ b/operations/mailers/delete_mailers_section_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteMailersSectionAcceptedCode is the HTTP code returned for type DeleteMailersSectionAccepted +const DeleteMailersSectionAcceptedCode int = 202 + +/* +DeleteMailersSectionAccepted Configuration change accepted and reload requested + +swagger:response deleteMailersSectionAccepted +*/ +type DeleteMailersSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteMailersSectionAccepted creates DeleteMailersSectionAccepted with default headers values +func NewDeleteMailersSectionAccepted() *DeleteMailersSectionAccepted { + + return &DeleteMailersSectionAccepted{} +} + +// WithReloadID adds the reloadId to the delete mailers section accepted response +func (o *DeleteMailersSectionAccepted) WithReloadID(reloadID string) *DeleteMailersSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete mailers section accepted response +func (o *DeleteMailersSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteMailersSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteMailersSectionNoContentCode is the HTTP code returned for type DeleteMailersSectionNoContent +const DeleteMailersSectionNoContentCode int = 204 + +/* +DeleteMailersSectionNoContent Mailers deleted + +swagger:response deleteMailersSectionNoContent +*/ +type DeleteMailersSectionNoContent struct { +} + +// NewDeleteMailersSectionNoContent creates DeleteMailersSectionNoContent with default headers values +func NewDeleteMailersSectionNoContent() *DeleteMailersSectionNoContent { + + return &DeleteMailersSectionNoContent{} +} + +// WriteResponse to the client +func (o *DeleteMailersSectionNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteMailersSectionNotFoundCode is the HTTP code returned for type DeleteMailersSectionNotFound +const DeleteMailersSectionNotFoundCode int = 404 + +/* +DeleteMailersSectionNotFound The specified resource was not found + +swagger:response deleteMailersSectionNotFound +*/ +type DeleteMailersSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteMailersSectionNotFound creates DeleteMailersSectionNotFound with default headers values +func NewDeleteMailersSectionNotFound() *DeleteMailersSectionNotFound { + + return &DeleteMailersSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete mailers section not found response +func (o *DeleteMailersSectionNotFound) WithConfigurationVersion(configurationVersion string) *DeleteMailersSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete mailers section not found response +func (o *DeleteMailersSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete mailers section not found response +func (o *DeleteMailersSectionNotFound) WithPayload(payload *models.Error) *DeleteMailersSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete mailers section not found response +func (o *DeleteMailersSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteMailersSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteMailersSectionDefault General Error + +swagger:response deleteMailersSectionDefault +*/ +type DeleteMailersSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteMailersSectionDefault creates DeleteMailersSectionDefault with default headers values +func NewDeleteMailersSectionDefault(code int) *DeleteMailersSectionDefault { + if code <= 0 { + code = 500 + } + + return &DeleteMailersSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete mailers section default response +func (o *DeleteMailersSectionDefault) WithStatusCode(code int) *DeleteMailersSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete mailers section default response +func (o *DeleteMailersSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete mailers section default response +func (o *DeleteMailersSectionDefault) WithConfigurationVersion(configurationVersion string) *DeleteMailersSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete mailers section default response +func (o *DeleteMailersSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete mailers section default response +func (o *DeleteMailersSectionDefault) WithPayload(payload *models.Error) *DeleteMailersSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete mailers section default response +func (o *DeleteMailersSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteMailersSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailers/delete_mailers_section_urlbuilder.go b/operations/mailers/delete_mailers_section_urlbuilder.go new file mode 100644 index 00000000..e76c1149 --- /dev/null +++ b/operations/mailers/delete_mailers_section_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteMailersSectionURL generates an URL for the delete mailers section operation +type DeleteMailersSectionURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteMailersSectionURL) WithBasePath(bp string) *DeleteMailersSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteMailersSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteMailersSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailers_section/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteMailersSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteMailersSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteMailersSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteMailersSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteMailersSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteMailersSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteMailersSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailers/edit_mailers_section.go b/operations/mailers/edit_mailers_section.go new file mode 100644 index 00000000..fa5a54b7 --- /dev/null +++ b/operations/mailers/edit_mailers_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// EditMailersSectionHandlerFunc turns a function with the right signature into a edit mailers section handler +type EditMailersSectionHandlerFunc func(EditMailersSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn EditMailersSectionHandlerFunc) Handle(params EditMailersSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// EditMailersSectionHandler interface for that can handle valid edit mailers section params +type EditMailersSectionHandler interface { + Handle(EditMailersSectionParams, interface{}) middleware.Responder +} + +// NewEditMailersSection creates a new http.Handler for the edit mailers section operation +func NewEditMailersSection(ctx *middleware.Context, handler EditMailersSectionHandler) *EditMailersSection { + return &EditMailersSection{Context: ctx, Handler: handler} +} + +/* + EditMailersSection swagger:route PUT /services/haproxy/configuration/mailers_section/{name} Mailers editMailersSection + +# Modify a Mailers section + +Modifies a mailers configuration by it's name. +*/ +type EditMailersSection struct { + Context *middleware.Context + Handler EditMailersSectionHandler +} + +func (o *EditMailersSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewEditMailersSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailers/edit_mailers_section_parameters.go b/operations/mailers/edit_mailers_section_parameters.go new file mode 100644 index 00000000..c03d0724 --- /dev/null +++ b/operations/mailers/edit_mailers_section_parameters.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewEditMailersSectionParams creates a new EditMailersSectionParams object +// with the default values initialized. +func NewEditMailersSectionParams() EditMailersSectionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return EditMailersSectionParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// EditMailersSectionParams contains all the bound params for the edit mailers section operation +// typically these are obtained from a http.Request +// +// swagger:parameters editMailersSection +type EditMailersSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.MailersSection + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Mailers name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewEditMailersSectionParams() beforehand. +func (o *EditMailersSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.MailersSection + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *EditMailersSectionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewEditMailersSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *EditMailersSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewEditMailersSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *EditMailersSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *EditMailersSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *EditMailersSectionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/mailers/edit_mailers_section_responses.go b/operations/mailers/edit_mailers_section_responses.go new file mode 100644 index 00000000..15e15c5a --- /dev/null +++ b/operations/mailers/edit_mailers_section_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// EditMailersSectionOKCode is the HTTP code returned for type EditMailersSectionOK +const EditMailersSectionOKCode int = 200 + +/* +EditMailersSectionOK Mailers configuration updated + +swagger:response editMailersSectionOK +*/ +type EditMailersSectionOK struct { + + /* + In: Body + */ + Payload *models.MailersSection `json:"body,omitempty"` +} + +// NewEditMailersSectionOK creates EditMailersSectionOK with default headers values +func NewEditMailersSectionOK() *EditMailersSectionOK { + + return &EditMailersSectionOK{} +} + +// WithPayload adds the payload to the edit mailers section o k response +func (o *EditMailersSectionOK) WithPayload(payload *models.MailersSection) *EditMailersSectionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit mailers section o k response +func (o *EditMailersSectionOK) SetPayload(payload *models.MailersSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditMailersSectionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditMailersSectionAcceptedCode is the HTTP code returned for type EditMailersSectionAccepted +const EditMailersSectionAcceptedCode int = 202 + +/* +EditMailersSectionAccepted Configuration change accepted and reload requested + +swagger:response editMailersSectionAccepted +*/ +type EditMailersSectionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.MailersSection `json:"body,omitempty"` +} + +// NewEditMailersSectionAccepted creates EditMailersSectionAccepted with default headers values +func NewEditMailersSectionAccepted() *EditMailersSectionAccepted { + + return &EditMailersSectionAccepted{} +} + +// WithReloadID adds the reloadId to the edit mailers section accepted response +func (o *EditMailersSectionAccepted) WithReloadID(reloadID string) *EditMailersSectionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the edit mailers section accepted response +func (o *EditMailersSectionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the edit mailers section accepted response +func (o *EditMailersSectionAccepted) WithPayload(payload *models.MailersSection) *EditMailersSectionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit mailers section accepted response +func (o *EditMailersSectionAccepted) SetPayload(payload *models.MailersSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditMailersSectionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditMailersSectionBadRequestCode is the HTTP code returned for type EditMailersSectionBadRequest +const EditMailersSectionBadRequestCode int = 400 + +/* +EditMailersSectionBadRequest Bad request + +swagger:response editMailersSectionBadRequest +*/ +type EditMailersSectionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditMailersSectionBadRequest creates EditMailersSectionBadRequest with default headers values +func NewEditMailersSectionBadRequest() *EditMailersSectionBadRequest { + + return &EditMailersSectionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit mailers section bad request response +func (o *EditMailersSectionBadRequest) WithConfigurationVersion(configurationVersion string) *EditMailersSectionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit mailers section bad request response +func (o *EditMailersSectionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit mailers section bad request response +func (o *EditMailersSectionBadRequest) WithPayload(payload *models.Error) *EditMailersSectionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit mailers section bad request response +func (o *EditMailersSectionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditMailersSectionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// EditMailersSectionNotFoundCode is the HTTP code returned for type EditMailersSectionNotFound +const EditMailersSectionNotFoundCode int = 404 + +/* +EditMailersSectionNotFound The specified resource was not found + +swagger:response editMailersSectionNotFound +*/ +type EditMailersSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditMailersSectionNotFound creates EditMailersSectionNotFound with default headers values +func NewEditMailersSectionNotFound() *EditMailersSectionNotFound { + + return &EditMailersSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the edit mailers section not found response +func (o *EditMailersSectionNotFound) WithConfigurationVersion(configurationVersion string) *EditMailersSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit mailers section not found response +func (o *EditMailersSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit mailers section not found response +func (o *EditMailersSectionNotFound) WithPayload(payload *models.Error) *EditMailersSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit mailers section not found response +func (o *EditMailersSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditMailersSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +EditMailersSectionDefault General Error + +swagger:response editMailersSectionDefault +*/ +type EditMailersSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewEditMailersSectionDefault creates EditMailersSectionDefault with default headers values +func NewEditMailersSectionDefault(code int) *EditMailersSectionDefault { + if code <= 0 { + code = 500 + } + + return &EditMailersSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the edit mailers section default response +func (o *EditMailersSectionDefault) WithStatusCode(code int) *EditMailersSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the edit mailers section default response +func (o *EditMailersSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the edit mailers section default response +func (o *EditMailersSectionDefault) WithConfigurationVersion(configurationVersion string) *EditMailersSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the edit mailers section default response +func (o *EditMailersSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the edit mailers section default response +func (o *EditMailersSectionDefault) WithPayload(payload *models.Error) *EditMailersSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the edit mailers section default response +func (o *EditMailersSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *EditMailersSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailers/edit_mailers_section_urlbuilder.go b/operations/mailers/edit_mailers_section_urlbuilder.go new file mode 100644 index 00000000..c643bff5 --- /dev/null +++ b/operations/mailers/edit_mailers_section_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// EditMailersSectionURL generates an URL for the edit mailers section operation +type EditMailersSectionURL struct { + Name string + + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditMailersSectionURL) WithBasePath(bp string) *EditMailersSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *EditMailersSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *EditMailersSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailers_section/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on EditMailersSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *EditMailersSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *EditMailersSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *EditMailersSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on EditMailersSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on EditMailersSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *EditMailersSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailers/get_mailers_section.go b/operations/mailers/get_mailers_section.go new file mode 100644 index 00000000..9c2b2d22 --- /dev/null +++ b/operations/mailers/get_mailers_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetMailersSectionHandlerFunc turns a function with the right signature into a get mailers section handler +type GetMailersSectionHandlerFunc func(GetMailersSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetMailersSectionHandlerFunc) Handle(params GetMailersSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetMailersSectionHandler interface for that can handle valid get mailers section params +type GetMailersSectionHandler interface { + Handle(GetMailersSectionParams, interface{}) middleware.Responder +} + +// NewGetMailersSection creates a new http.Handler for the get mailers section operation +func NewGetMailersSection(ctx *middleware.Context, handler GetMailersSectionHandler) *GetMailersSection { + return &GetMailersSection{Context: ctx, Handler: handler} +} + +/* + GetMailersSection swagger:route GET /services/haproxy/configuration/mailers_section/{name} Mailers getMailersSection + +# Return a Mailers section + +Returns one mailers configuration by it's name. +*/ +type GetMailersSection struct { + Context *middleware.Context + Handler GetMailersSectionHandler +} + +func (o *GetMailersSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetMailersSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailers/get_mailers_section_parameters.go b/operations/mailers/get_mailers_section_parameters.go new file mode 100644 index 00000000..5fccba80 --- /dev/null +++ b/operations/mailers/get_mailers_section_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetMailersSectionParams creates a new GetMailersSectionParams object +// with the default values initialized. +func NewGetMailersSectionParams() GetMailersSectionParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetMailersSectionParams{ + FullSection: &fullSectionDefault, + } +} + +// GetMailersSectionParams contains all the bound params for the get mailers section operation +// typically these are obtained from a http.Request +// +// swagger:parameters getMailersSection +type GetMailersSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Mailers name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetMailersSectionParams() beforehand. +func (o *GetMailersSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetMailersSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetMailersSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetMailersSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetMailersSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/mailers/get_mailers_section_responses.go b/operations/mailers/get_mailers_section_responses.go new file mode 100644 index 00000000..2b00592b --- /dev/null +++ b/operations/mailers/get_mailers_section_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetMailersSectionOKCode is the HTTP code returned for type GetMailersSectionOK +const GetMailersSectionOKCode int = 200 + +/* +GetMailersSectionOK Successful operation + +swagger:response getMailersSectionOK +*/ +type GetMailersSectionOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.MailersSection `json:"body,omitempty"` +} + +// NewGetMailersSectionOK creates GetMailersSectionOK with default headers values +func NewGetMailersSectionOK() *GetMailersSectionOK { + + return &GetMailersSectionOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get mailers section o k response +func (o *GetMailersSectionOK) WithConfigurationVersion(configurationVersion string) *GetMailersSectionOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailers section o k response +func (o *GetMailersSectionOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailers section o k response +func (o *GetMailersSectionOK) WithPayload(payload *models.MailersSection) *GetMailersSectionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailers section o k response +func (o *GetMailersSectionOK) SetPayload(payload *models.MailersSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailersSectionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetMailersSectionNotFoundCode is the HTTP code returned for type GetMailersSectionNotFound +const GetMailersSectionNotFoundCode int = 404 + +/* +GetMailersSectionNotFound The specified resource was not found + +swagger:response getMailersSectionNotFound +*/ +type GetMailersSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetMailersSectionNotFound creates GetMailersSectionNotFound with default headers values +func NewGetMailersSectionNotFound() *GetMailersSectionNotFound { + + return &GetMailersSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get mailers section not found response +func (o *GetMailersSectionNotFound) WithConfigurationVersion(configurationVersion string) *GetMailersSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailers section not found response +func (o *GetMailersSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailers section not found response +func (o *GetMailersSectionNotFound) WithPayload(payload *models.Error) *GetMailersSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailers section not found response +func (o *GetMailersSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailersSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetMailersSectionDefault General Error + +swagger:response getMailersSectionDefault +*/ +type GetMailersSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetMailersSectionDefault creates GetMailersSectionDefault with default headers values +func NewGetMailersSectionDefault(code int) *GetMailersSectionDefault { + if code <= 0 { + code = 500 + } + + return &GetMailersSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get mailers section default response +func (o *GetMailersSectionDefault) WithStatusCode(code int) *GetMailersSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get mailers section default response +func (o *GetMailersSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get mailers section default response +func (o *GetMailersSectionDefault) WithConfigurationVersion(configurationVersion string) *GetMailersSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailers section default response +func (o *GetMailersSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailers section default response +func (o *GetMailersSectionDefault) WithPayload(payload *models.Error) *GetMailersSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailers section default response +func (o *GetMailersSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailersSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailers/get_mailers_section_urlbuilder.go b/operations/mailers/get_mailers_section_urlbuilder.go new file mode 100644 index 00000000..6918f6d1 --- /dev/null +++ b/operations/mailers/get_mailers_section_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetMailersSectionURL generates an URL for the get mailers section operation +type GetMailersSectionURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailersSectionURL) WithBasePath(bp string) *GetMailersSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailersSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetMailersSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailers_section/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetMailersSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetMailersSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetMailersSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetMailersSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetMailersSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetMailersSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetMailersSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/mailers/get_mailers_sections.go b/operations/mailers/get_mailers_sections.go new file mode 100644 index 00000000..cad4a625 --- /dev/null +++ b/operations/mailers/get_mailers_sections.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetMailersSectionsHandlerFunc turns a function with the right signature into a get mailers sections handler +type GetMailersSectionsHandlerFunc func(GetMailersSectionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetMailersSectionsHandlerFunc) Handle(params GetMailersSectionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetMailersSectionsHandler interface for that can handle valid get mailers sections params +type GetMailersSectionsHandler interface { + Handle(GetMailersSectionsParams, interface{}) middleware.Responder +} + +// NewGetMailersSections creates a new http.Handler for the get mailers sections operation +func NewGetMailersSections(ctx *middleware.Context, handler GetMailersSectionsHandler) *GetMailersSections { + return &GetMailersSections{Context: ctx, Handler: handler} +} + +/* + GetMailersSections swagger:route GET /services/haproxy/configuration/mailers_section Mailers getMailersSections + +# Return an array of mailers sections + +Returns an array of all the configured mailers in HAProxy +*/ +type GetMailersSections struct { + Context *middleware.Context + Handler GetMailersSectionsHandler +} + +func (o *GetMailersSections) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetMailersSectionsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/mailers/get_mailers_sections_parameters.go b/operations/mailers/get_mailers_sections_parameters.go new file mode 100644 index 00000000..dfe5eda3 --- /dev/null +++ b/operations/mailers/get_mailers_sections_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetMailersSectionsParams creates a new GetMailersSectionsParams object +// with the default values initialized. +func NewGetMailersSectionsParams() GetMailersSectionsParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetMailersSectionsParams{ + FullSection: &fullSectionDefault, + } +} + +// GetMailersSectionsParams contains all the bound params for the get mailers sections operation +// typically these are obtained from a http.Request +// +// swagger:parameters getMailersSections +type GetMailersSectionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetMailersSectionsParams() beforehand. +func (o *GetMailersSectionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetMailersSectionsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetMailersSectionsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetMailersSectionsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/mailers/get_mailers_sections_responses.go b/operations/mailers/get_mailers_sections_responses.go new file mode 100644 index 00000000..4512ee1d --- /dev/null +++ b/operations/mailers/get_mailers_sections_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetMailersSectionsOKCode is the HTTP code returned for type GetMailersSectionsOK +const GetMailersSectionsOKCode int = 200 + +/* +GetMailersSectionsOK Successful operation + +swagger:response getMailersSectionsOK +*/ +type GetMailersSectionsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.MailersSections `json:"body,omitempty"` +} + +// NewGetMailersSectionsOK creates GetMailersSectionsOK with default headers values +func NewGetMailersSectionsOK() *GetMailersSectionsOK { + + return &GetMailersSectionsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get mailers sections o k response +func (o *GetMailersSectionsOK) WithConfigurationVersion(configurationVersion string) *GetMailersSectionsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailers sections o k response +func (o *GetMailersSectionsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailers sections o k response +func (o *GetMailersSectionsOK) WithPayload(payload models.MailersSections) *GetMailersSectionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailers sections o k response +func (o *GetMailersSectionsOK) SetPayload(payload models.MailersSections) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailersSectionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.MailersSections{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetMailersSectionsDefault General Error + +swagger:response getMailersSectionsDefault +*/ +type GetMailersSectionsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetMailersSectionsDefault creates GetMailersSectionsDefault with default headers values +func NewGetMailersSectionsDefault(code int) *GetMailersSectionsDefault { + if code <= 0 { + code = 500 + } + + return &GetMailersSectionsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get mailers sections default response +func (o *GetMailersSectionsDefault) WithStatusCode(code int) *GetMailersSectionsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get mailers sections default response +func (o *GetMailersSectionsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get mailers sections default response +func (o *GetMailersSectionsDefault) WithConfigurationVersion(configurationVersion string) *GetMailersSectionsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get mailers sections default response +func (o *GetMailersSectionsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get mailers sections default response +func (o *GetMailersSectionsDefault) WithPayload(payload *models.Error) *GetMailersSectionsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get mailers sections default response +func (o *GetMailersSectionsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetMailersSectionsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/mailers/get_mailers_sections_urlbuilder.go b/operations/mailers/get_mailers_sections_urlbuilder.go new file mode 100644 index 00000000..c4ec692a --- /dev/null +++ b/operations/mailers/get_mailers_sections_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package mailers + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetMailersSectionsURL generates an URL for the get mailers sections operation +type GetMailersSectionsURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailersSectionsURL) WithBasePath(bp string) *GetMailersSectionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetMailersSectionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetMailersSectionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/mailers_section" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetMailersSectionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetMailersSectionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetMailersSectionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetMailersSectionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetMailersSectionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetMailersSectionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/add_map_entry.go b/operations/maps/add_map_entry.go new file mode 100644 index 00000000..bada29fb --- /dev/null +++ b/operations/maps/add_map_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddMapEntryHandlerFunc turns a function with the right signature into a add map entry handler +type AddMapEntryHandlerFunc func(AddMapEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddMapEntryHandlerFunc) Handle(params AddMapEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddMapEntryHandler interface for that can handle valid add map entry params +type AddMapEntryHandler interface { + Handle(AddMapEntryParams, interface{}) middleware.Responder +} + +// NewAddMapEntry creates a new http.Handler for the add map entry operation +func NewAddMapEntry(ctx *middleware.Context, handler AddMapEntryHandler) *AddMapEntry { + return &AddMapEntry{Context: ctx, Handler: handler} +} + +/* + AddMapEntry swagger:route POST /services/haproxy/runtime/maps/{parent_name}/entries Maps addMapEntry + +# Adds an entry into the map file + +Adds an entry into the map file. +*/ +type AddMapEntry struct { + Context *middleware.Context + Handler AddMapEntryHandler +} + +func (o *AddMapEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewAddMapEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/add_map_entry_parameters.go b/operations/maps/add_map_entry_parameters.go new file mode 100644 index 00000000..42fe282f --- /dev/null +++ b/operations/maps/add_map_entry_parameters.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewAddMapEntryParams creates a new AddMapEntryParams object +// with the default values initialized. +func NewAddMapEntryParams() AddMapEntryParams { + + var ( + // initialize parameters with default values + + forceSyncDefault = bool(false) + ) + + return AddMapEntryParams{ + ForceSync: &forceSyncDefault, + } +} + +// AddMapEntryParams contains all the bound params for the add map entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters addMapEntry +type AddMapEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.MapEntry + /*If true, immediately syncs changes to disk + In: query + Default: false + */ + ForceSync *bool + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddMapEntryParams() beforehand. +func (o *AddMapEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.MapEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceSync, qhkForceSync, _ := qs.GetOK("force_sync") + if err := o.bindForceSync(qForceSync, qhkForceSync, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceSync binds and validates parameter ForceSync from query. +func (o *AddMapEntryParams) bindForceSync(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewAddMapEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_sync", "query", "bool", raw) + } + o.ForceSync = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *AddMapEntryParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/maps/add_map_entry_responses.go b/operations/maps/add_map_entry_responses.go new file mode 100644 index 00000000..bba69c70 --- /dev/null +++ b/operations/maps/add_map_entry_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// AddMapEntryCreatedCode is the HTTP code returned for type AddMapEntryCreated +const AddMapEntryCreatedCode int = 201 + +/* +AddMapEntryCreated Map entry created + +swagger:response addMapEntryCreated +*/ +type AddMapEntryCreated struct { + + /* + In: Body + */ + Payload *models.MapEntry `json:"body,omitempty"` +} + +// NewAddMapEntryCreated creates AddMapEntryCreated with default headers values +func NewAddMapEntryCreated() *AddMapEntryCreated { + + return &AddMapEntryCreated{} +} + +// WithPayload adds the payload to the add map entry created response +func (o *AddMapEntryCreated) WithPayload(payload *models.MapEntry) *AddMapEntryCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add map entry created response +func (o *AddMapEntryCreated) SetPayload(payload *models.MapEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddMapEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddMapEntryBadRequestCode is the HTTP code returned for type AddMapEntryBadRequest +const AddMapEntryBadRequestCode int = 400 + +/* +AddMapEntryBadRequest Bad request + +swagger:response addMapEntryBadRequest +*/ +type AddMapEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddMapEntryBadRequest creates AddMapEntryBadRequest with default headers values +func NewAddMapEntryBadRequest() *AddMapEntryBadRequest { + + return &AddMapEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the add map entry bad request response +func (o *AddMapEntryBadRequest) WithConfigurationVersion(configurationVersion string) *AddMapEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add map entry bad request response +func (o *AddMapEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add map entry bad request response +func (o *AddMapEntryBadRequest) WithPayload(payload *models.Error) *AddMapEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add map entry bad request response +func (o *AddMapEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddMapEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddMapEntryConflictCode is the HTTP code returned for type AddMapEntryConflict +const AddMapEntryConflictCode int = 409 + +/* +AddMapEntryConflict The specified resource already exists + +swagger:response addMapEntryConflict +*/ +type AddMapEntryConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddMapEntryConflict creates AddMapEntryConflict with default headers values +func NewAddMapEntryConflict() *AddMapEntryConflict { + + return &AddMapEntryConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the add map entry conflict response +func (o *AddMapEntryConflict) WithConfigurationVersion(configurationVersion string) *AddMapEntryConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add map entry conflict response +func (o *AddMapEntryConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add map entry conflict response +func (o *AddMapEntryConflict) WithPayload(payload *models.Error) *AddMapEntryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add map entry conflict response +func (o *AddMapEntryConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddMapEntryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +AddMapEntryDefault General Error + +swagger:response addMapEntryDefault +*/ +type AddMapEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddMapEntryDefault creates AddMapEntryDefault with default headers values +func NewAddMapEntryDefault(code int) *AddMapEntryDefault { + if code <= 0 { + code = 500 + } + + return &AddMapEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the add map entry default response +func (o *AddMapEntryDefault) WithStatusCode(code int) *AddMapEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the add map entry default response +func (o *AddMapEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the add map entry default response +func (o *AddMapEntryDefault) WithConfigurationVersion(configurationVersion string) *AddMapEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add map entry default response +func (o *AddMapEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add map entry default response +func (o *AddMapEntryDefault) WithPayload(payload *models.Error) *AddMapEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add map entry default response +func (o *AddMapEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddMapEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/add_map_entry_urlbuilder.go b/operations/maps/add_map_entry_urlbuilder.go new file mode 100644 index 00000000..0bcd4474 --- /dev/null +++ b/operations/maps/add_map_entry_urlbuilder.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// AddMapEntryURL generates an URL for the add map entry operation +type AddMapEntryURL struct { + ParentName string + + ForceSync *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddMapEntryURL) WithBasePath(bp string) *AddMapEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddMapEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddMapEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{parent_name}/entries" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on AddMapEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceSyncQ string + if o.ForceSync != nil { + forceSyncQ = swag.FormatBool(*o.ForceSync) + } + if forceSyncQ != "" { + qs.Set("force_sync", forceSyncQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddMapEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddMapEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddMapEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddMapEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddMapEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddMapEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/add_payload_runtime_map.go b/operations/maps/add_payload_runtime_map.go new file mode 100644 index 00000000..314bc7fb --- /dev/null +++ b/operations/maps/add_payload_runtime_map.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddPayloadRuntimeMapHandlerFunc turns a function with the right signature into a add payload runtime map handler +type AddPayloadRuntimeMapHandlerFunc func(AddPayloadRuntimeMapParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddPayloadRuntimeMapHandlerFunc) Handle(params AddPayloadRuntimeMapParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddPayloadRuntimeMapHandler interface for that can handle valid add payload runtime map params +type AddPayloadRuntimeMapHandler interface { + Handle(AddPayloadRuntimeMapParams, interface{}) middleware.Responder +} + +// NewAddPayloadRuntimeMap creates a new http.Handler for the add payload runtime map operation +func NewAddPayloadRuntimeMap(ctx *middleware.Context, handler AddPayloadRuntimeMapHandler) *AddPayloadRuntimeMap { + return &AddPayloadRuntimeMap{Context: ctx, Handler: handler} +} + +/* + AddPayloadRuntimeMap swagger:route PUT /services/haproxy/runtime/maps/{name} Maps addPayloadRuntimeMap + +# Add a new map payload + +Adds a new map payload. +*/ +type AddPayloadRuntimeMap struct { + Context *middleware.Context + Handler AddPayloadRuntimeMapHandler +} + +func (o *AddPayloadRuntimeMap) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewAddPayloadRuntimeMapParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/add_payload_runtime_map_parameters.go b/operations/maps/add_payload_runtime_map_parameters.go new file mode 100644 index 00000000..3d7600f5 --- /dev/null +++ b/operations/maps/add_payload_runtime_map_parameters.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewAddPayloadRuntimeMapParams creates a new AddPayloadRuntimeMapParams object +// with the default values initialized. +func NewAddPayloadRuntimeMapParams() AddPayloadRuntimeMapParams { + + var ( + // initialize parameters with default values + + forceSyncDefault = bool(false) + ) + + return AddPayloadRuntimeMapParams{ + ForceSync: &forceSyncDefault, + } +} + +// AddPayloadRuntimeMapParams contains all the bound params for the add payload runtime map operation +// typically these are obtained from a http.Request +// +// swagger:parameters addPayloadRuntimeMap +type AddPayloadRuntimeMapParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.MapEntries + /*If true, immediately syncs changes to disk + In: query + Default: false + */ + ForceSync *bool + /*Map file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddPayloadRuntimeMapParams() beforehand. +func (o *AddPayloadRuntimeMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.MapEntries + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceSync, qhkForceSync, _ := qs.GetOK("force_sync") + if err := o.bindForceSync(qForceSync, qhkForceSync, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceSync binds and validates parameter ForceSync from query. +func (o *AddPayloadRuntimeMapParams) bindForceSync(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewAddPayloadRuntimeMapParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_sync", "query", "bool", raw) + } + o.ForceSync = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *AddPayloadRuntimeMapParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/maps/add_payload_runtime_map_responses.go b/operations/maps/add_payload_runtime_map_responses.go new file mode 100644 index 00000000..0c3bad5f --- /dev/null +++ b/operations/maps/add_payload_runtime_map_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// AddPayloadRuntimeMapCreatedCode is the HTTP code returned for type AddPayloadRuntimeMapCreated +const AddPayloadRuntimeMapCreatedCode int = 201 + +/* +AddPayloadRuntimeMapCreated Map payload added + +swagger:response addPayloadRuntimeMapCreated +*/ +type AddPayloadRuntimeMapCreated struct { + + /* + In: Body + */ + Payload models.MapEntries `json:"body,omitempty"` +} + +// NewAddPayloadRuntimeMapCreated creates AddPayloadRuntimeMapCreated with default headers values +func NewAddPayloadRuntimeMapCreated() *AddPayloadRuntimeMapCreated { + + return &AddPayloadRuntimeMapCreated{} +} + +// WithPayload adds the payload to the add payload runtime map created response +func (o *AddPayloadRuntimeMapCreated) WithPayload(payload models.MapEntries) *AddPayloadRuntimeMapCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add payload runtime map created response +func (o *AddPayloadRuntimeMapCreated) SetPayload(payload models.MapEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddPayloadRuntimeMapCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.MapEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// AddPayloadRuntimeMapBadRequestCode is the HTTP code returned for type AddPayloadRuntimeMapBadRequest +const AddPayloadRuntimeMapBadRequestCode int = 400 + +/* +AddPayloadRuntimeMapBadRequest Bad request + +swagger:response addPayloadRuntimeMapBadRequest +*/ +type AddPayloadRuntimeMapBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddPayloadRuntimeMapBadRequest creates AddPayloadRuntimeMapBadRequest with default headers values +func NewAddPayloadRuntimeMapBadRequest() *AddPayloadRuntimeMapBadRequest { + + return &AddPayloadRuntimeMapBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the add payload runtime map bad request response +func (o *AddPayloadRuntimeMapBadRequest) WithConfigurationVersion(configurationVersion string) *AddPayloadRuntimeMapBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add payload runtime map bad request response +func (o *AddPayloadRuntimeMapBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add payload runtime map bad request response +func (o *AddPayloadRuntimeMapBadRequest) WithPayload(payload *models.Error) *AddPayloadRuntimeMapBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add payload runtime map bad request response +func (o *AddPayloadRuntimeMapBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddPayloadRuntimeMapBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +AddPayloadRuntimeMapDefault General Error + +swagger:response addPayloadRuntimeMapDefault +*/ +type AddPayloadRuntimeMapDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddPayloadRuntimeMapDefault creates AddPayloadRuntimeMapDefault with default headers values +func NewAddPayloadRuntimeMapDefault(code int) *AddPayloadRuntimeMapDefault { + if code <= 0 { + code = 500 + } + + return &AddPayloadRuntimeMapDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the add payload runtime map default response +func (o *AddPayloadRuntimeMapDefault) WithStatusCode(code int) *AddPayloadRuntimeMapDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the add payload runtime map default response +func (o *AddPayloadRuntimeMapDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the add payload runtime map default response +func (o *AddPayloadRuntimeMapDefault) WithConfigurationVersion(configurationVersion string) *AddPayloadRuntimeMapDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add payload runtime map default response +func (o *AddPayloadRuntimeMapDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add payload runtime map default response +func (o *AddPayloadRuntimeMapDefault) WithPayload(payload *models.Error) *AddPayloadRuntimeMapDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add payload runtime map default response +func (o *AddPayloadRuntimeMapDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddPayloadRuntimeMapDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/add_payload_runtime_map_urlbuilder.go b/operations/maps/add_payload_runtime_map_urlbuilder.go new file mode 100644 index 00000000..d06e8b56 --- /dev/null +++ b/operations/maps/add_payload_runtime_map_urlbuilder.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// AddPayloadRuntimeMapURL generates an URL for the add payload runtime map operation +type AddPayloadRuntimeMapURL struct { + Name string + + ForceSync *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddPayloadRuntimeMapURL) WithBasePath(bp string) *AddPayloadRuntimeMapURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddPayloadRuntimeMapURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddPayloadRuntimeMapURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on AddPayloadRuntimeMapURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceSyncQ string + if o.ForceSync != nil { + forceSyncQ = swag.FormatBool(*o.ForceSync) + } + if forceSyncQ != "" { + qs.Set("force_sync", forceSyncQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddPayloadRuntimeMapURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddPayloadRuntimeMapURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddPayloadRuntimeMapURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddPayloadRuntimeMapURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddPayloadRuntimeMapURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddPayloadRuntimeMapURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/clear_runtime_map.go b/operations/maps/clear_runtime_map.go new file mode 100644 index 00000000..f7a1dcab --- /dev/null +++ b/operations/maps/clear_runtime_map.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ClearRuntimeMapHandlerFunc turns a function with the right signature into a clear runtime map handler +type ClearRuntimeMapHandlerFunc func(ClearRuntimeMapParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ClearRuntimeMapHandlerFunc) Handle(params ClearRuntimeMapParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ClearRuntimeMapHandler interface for that can handle valid clear runtime map params +type ClearRuntimeMapHandler interface { + Handle(ClearRuntimeMapParams, interface{}) middleware.Responder +} + +// NewClearRuntimeMap creates a new http.Handler for the clear runtime map operation +func NewClearRuntimeMap(ctx *middleware.Context, handler ClearRuntimeMapHandler) *ClearRuntimeMap { + return &ClearRuntimeMap{Context: ctx, Handler: handler} +} + +/* + ClearRuntimeMap swagger:route DELETE /services/haproxy/runtime/maps/{name} Maps clearRuntimeMap + +# Remove all map entries from the map file + +Remove all map entries from the map file. +*/ +type ClearRuntimeMap struct { + Context *middleware.Context + Handler ClearRuntimeMapHandler +} + +func (o *ClearRuntimeMap) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewClearRuntimeMapParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/clear_runtime_map_parameters.go b/operations/maps/clear_runtime_map_parameters.go new file mode 100644 index 00000000..f7ff5e02 --- /dev/null +++ b/operations/maps/clear_runtime_map_parameters.go @@ -0,0 +1,163 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewClearRuntimeMapParams creates a new ClearRuntimeMapParams object +// with the default values initialized. +func NewClearRuntimeMapParams() ClearRuntimeMapParams { + + var ( + // initialize parameters with default values + + forceSyncDefault = bool(false) + ) + + return ClearRuntimeMapParams{ + ForceSync: &forceSyncDefault, + } +} + +// ClearRuntimeMapParams contains all the bound params for the clear runtime map operation +// typically these are obtained from a http.Request +// +// swagger:parameters clearRuntimeMap +type ClearRuntimeMapParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If true, deletes file from disk + In: query + */ + ForceDelete *bool + /*If true, immediately syncs changes to disk + In: query + Default: false + */ + ForceSync *bool + /*Map file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewClearRuntimeMapParams() beforehand. +func (o *ClearRuntimeMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceDelete, qhkForceDelete, _ := qs.GetOK("forceDelete") + if err := o.bindForceDelete(qForceDelete, qhkForceDelete, route.Formats); err != nil { + res = append(res, err) + } + + qForceSync, qhkForceSync, _ := qs.GetOK("force_sync") + if err := o.bindForceSync(qForceSync, qhkForceSync, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceDelete binds and validates parameter ForceDelete from query. +func (o *ClearRuntimeMapParams) bindForceDelete(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("forceDelete", "query", "bool", raw) + } + o.ForceDelete = &value + + return nil +} + +// bindForceSync binds and validates parameter ForceSync from query. +func (o *ClearRuntimeMapParams) bindForceSync(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewClearRuntimeMapParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_sync", "query", "bool", raw) + } + o.ForceSync = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ClearRuntimeMapParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/maps/clear_runtime_map_responses.go b/operations/maps/clear_runtime_map_responses.go new file mode 100644 index 00000000..2f571c5c --- /dev/null +++ b/operations/maps/clear_runtime_map_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ClearRuntimeMapNoContentCode is the HTTP code returned for type ClearRuntimeMapNoContent +const ClearRuntimeMapNoContentCode int = 204 + +/* +ClearRuntimeMapNoContent All map entries deleted + +swagger:response clearRuntimeMapNoContent +*/ +type ClearRuntimeMapNoContent struct { +} + +// NewClearRuntimeMapNoContent creates ClearRuntimeMapNoContent with default headers values +func NewClearRuntimeMapNoContent() *ClearRuntimeMapNoContent { + + return &ClearRuntimeMapNoContent{} +} + +// WriteResponse to the client +func (o *ClearRuntimeMapNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// ClearRuntimeMapNotFoundCode is the HTTP code returned for type ClearRuntimeMapNotFound +const ClearRuntimeMapNotFoundCode int = 404 + +/* +ClearRuntimeMapNotFound The specified resource was not found + +swagger:response clearRuntimeMapNotFound +*/ +type ClearRuntimeMapNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewClearRuntimeMapNotFound creates ClearRuntimeMapNotFound with default headers values +func NewClearRuntimeMapNotFound() *ClearRuntimeMapNotFound { + + return &ClearRuntimeMapNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the clear runtime map not found response +func (o *ClearRuntimeMapNotFound) WithConfigurationVersion(configurationVersion string) *ClearRuntimeMapNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the clear runtime map not found response +func (o *ClearRuntimeMapNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the clear runtime map not found response +func (o *ClearRuntimeMapNotFound) WithPayload(payload *models.Error) *ClearRuntimeMapNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the clear runtime map not found response +func (o *ClearRuntimeMapNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ClearRuntimeMapNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ClearRuntimeMapDefault General Error + +swagger:response clearRuntimeMapDefault +*/ +type ClearRuntimeMapDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewClearRuntimeMapDefault creates ClearRuntimeMapDefault with default headers values +func NewClearRuntimeMapDefault(code int) *ClearRuntimeMapDefault { + if code <= 0 { + code = 500 + } + + return &ClearRuntimeMapDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the clear runtime map default response +func (o *ClearRuntimeMapDefault) WithStatusCode(code int) *ClearRuntimeMapDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the clear runtime map default response +func (o *ClearRuntimeMapDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the clear runtime map default response +func (o *ClearRuntimeMapDefault) WithConfigurationVersion(configurationVersion string) *ClearRuntimeMapDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the clear runtime map default response +func (o *ClearRuntimeMapDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the clear runtime map default response +func (o *ClearRuntimeMapDefault) WithPayload(payload *models.Error) *ClearRuntimeMapDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the clear runtime map default response +func (o *ClearRuntimeMapDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ClearRuntimeMapDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/clear_runtime_map_urlbuilder.go b/operations/maps/clear_runtime_map_urlbuilder.go new file mode 100644 index 00000000..91b4982d --- /dev/null +++ b/operations/maps/clear_runtime_map_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ClearRuntimeMapURL generates an URL for the clear runtime map operation +type ClearRuntimeMapURL struct { + Name string + + ForceDelete *bool + ForceSync *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ClearRuntimeMapURL) WithBasePath(bp string) *ClearRuntimeMapURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ClearRuntimeMapURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ClearRuntimeMapURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ClearRuntimeMapURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceDeleteQ string + if o.ForceDelete != nil { + forceDeleteQ = swag.FormatBool(*o.ForceDelete) + } + if forceDeleteQ != "" { + qs.Set("forceDelete", forceDeleteQ) + } + + var forceSyncQ string + if o.ForceSync != nil { + forceSyncQ = swag.FormatBool(*o.ForceSync) + } + if forceSyncQ != "" { + qs.Set("force_sync", forceSyncQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ClearRuntimeMapURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ClearRuntimeMapURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ClearRuntimeMapURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ClearRuntimeMapURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ClearRuntimeMapURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ClearRuntimeMapURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/delete_runtime_map_entry.go b/operations/maps/delete_runtime_map_entry.go new file mode 100644 index 00000000..1575f312 --- /dev/null +++ b/operations/maps/delete_runtime_map_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRuntimeMapEntryHandlerFunc turns a function with the right signature into a delete runtime map entry handler +type DeleteRuntimeMapEntryHandlerFunc func(DeleteRuntimeMapEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRuntimeMapEntryHandlerFunc) Handle(params DeleteRuntimeMapEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRuntimeMapEntryHandler interface for that can handle valid delete runtime map entry params +type DeleteRuntimeMapEntryHandler interface { + Handle(DeleteRuntimeMapEntryParams, interface{}) middleware.Responder +} + +// NewDeleteRuntimeMapEntry creates a new http.Handler for the delete runtime map entry operation +func NewDeleteRuntimeMapEntry(ctx *middleware.Context, handler DeleteRuntimeMapEntryHandler) *DeleteRuntimeMapEntry { + return &DeleteRuntimeMapEntry{Context: ctx, Handler: handler} +} + +/* + DeleteRuntimeMapEntry swagger:route DELETE /services/haproxy/runtime/maps/{parent_name}/entries/{id} Maps deleteRuntimeMapEntry + +# Deletes all the map entries from the map by its id + +Delete all the map entries from the map by its id. +*/ +type DeleteRuntimeMapEntry struct { + Context *middleware.Context + Handler DeleteRuntimeMapEntryHandler +} + +func (o *DeleteRuntimeMapEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteRuntimeMapEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/delete_runtime_map_entry_parameters.go b/operations/maps/delete_runtime_map_entry_parameters.go new file mode 100644 index 00000000..bc360d5d --- /dev/null +++ b/operations/maps/delete_runtime_map_entry_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteRuntimeMapEntryParams creates a new DeleteRuntimeMapEntryParams object +// with the default values initialized. +func NewDeleteRuntimeMapEntryParams() DeleteRuntimeMapEntryParams { + + var ( + // initialize parameters with default values + + forceSyncDefault = bool(false) + ) + + return DeleteRuntimeMapEntryParams{ + ForceSync: &forceSyncDefault, + } +} + +// DeleteRuntimeMapEntryParams contains all the bound params for the delete runtime map entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteRuntimeMapEntry +type DeleteRuntimeMapEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If true, immediately syncs changes to disk + In: query + Default: false + */ + ForceSync *bool + /*Map id + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRuntimeMapEntryParams() beforehand. +func (o *DeleteRuntimeMapEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceSync, qhkForceSync, _ := qs.GetOK("force_sync") + if err := o.bindForceSync(qForceSync, qhkForceSync, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceSync binds and validates parameter ForceSync from query. +func (o *DeleteRuntimeMapEntryParams) bindForceSync(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteRuntimeMapEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_sync", "query", "bool", raw) + } + o.ForceSync = &value + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteRuntimeMapEntryParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteRuntimeMapEntryParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/maps/delete_runtime_map_entry_responses.go b/operations/maps/delete_runtime_map_entry_responses.go new file mode 100644 index 00000000..7d891c69 --- /dev/null +++ b/operations/maps/delete_runtime_map_entry_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteRuntimeMapEntryNoContentCode is the HTTP code returned for type DeleteRuntimeMapEntryNoContent +const DeleteRuntimeMapEntryNoContentCode int = 204 + +/* +DeleteRuntimeMapEntryNoContent Map key/value deleted + +swagger:response deleteRuntimeMapEntryNoContent +*/ +type DeleteRuntimeMapEntryNoContent struct { +} + +// NewDeleteRuntimeMapEntryNoContent creates DeleteRuntimeMapEntryNoContent with default headers values +func NewDeleteRuntimeMapEntryNoContent() *DeleteRuntimeMapEntryNoContent { + + return &DeleteRuntimeMapEntryNoContent{} +} + +// WriteResponse to the client +func (o *DeleteRuntimeMapEntryNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteRuntimeMapEntryNotFoundCode is the HTTP code returned for type DeleteRuntimeMapEntryNotFound +const DeleteRuntimeMapEntryNotFoundCode int = 404 + +/* +DeleteRuntimeMapEntryNotFound The specified resource was not found + +swagger:response deleteRuntimeMapEntryNotFound +*/ +type DeleteRuntimeMapEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteRuntimeMapEntryNotFound creates DeleteRuntimeMapEntryNotFound with default headers values +func NewDeleteRuntimeMapEntryNotFound() *DeleteRuntimeMapEntryNotFound { + + return &DeleteRuntimeMapEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete runtime map entry not found response +func (o *DeleteRuntimeMapEntryNotFound) WithConfigurationVersion(configurationVersion string) *DeleteRuntimeMapEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete runtime map entry not found response +func (o *DeleteRuntimeMapEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete runtime map entry not found response +func (o *DeleteRuntimeMapEntryNotFound) WithPayload(payload *models.Error) *DeleteRuntimeMapEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete runtime map entry not found response +func (o *DeleteRuntimeMapEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRuntimeMapEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteRuntimeMapEntryDefault General Error + +swagger:response deleteRuntimeMapEntryDefault +*/ +type DeleteRuntimeMapEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteRuntimeMapEntryDefault creates DeleteRuntimeMapEntryDefault with default headers values +func NewDeleteRuntimeMapEntryDefault(code int) *DeleteRuntimeMapEntryDefault { + if code <= 0 { + code = 500 + } + + return &DeleteRuntimeMapEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete runtime map entry default response +func (o *DeleteRuntimeMapEntryDefault) WithStatusCode(code int) *DeleteRuntimeMapEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete runtime map entry default response +func (o *DeleteRuntimeMapEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete runtime map entry default response +func (o *DeleteRuntimeMapEntryDefault) WithConfigurationVersion(configurationVersion string) *DeleteRuntimeMapEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete runtime map entry default response +func (o *DeleteRuntimeMapEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete runtime map entry default response +func (o *DeleteRuntimeMapEntryDefault) WithPayload(payload *models.Error) *DeleteRuntimeMapEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete runtime map entry default response +func (o *DeleteRuntimeMapEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRuntimeMapEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/delete_runtime_map_entry_urlbuilder.go b/operations/maps/delete_runtime_map_entry_urlbuilder.go new file mode 100644 index 00000000..aeeea40e --- /dev/null +++ b/operations/maps/delete_runtime_map_entry_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteRuntimeMapEntryURL generates an URL for the delete runtime map entry operation +type DeleteRuntimeMapEntryURL struct { + ID string + ParentName string + + ForceSync *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRuntimeMapEntryURL) WithBasePath(bp string) *DeleteRuntimeMapEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRuntimeMapEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRuntimeMapEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{parent_name}/entries/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteRuntimeMapEntryURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteRuntimeMapEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceSyncQ string + if o.ForceSync != nil { + forceSyncQ = swag.FormatBool(*o.ForceSync) + } + if forceSyncQ != "" { + qs.Set("force_sync", forceSyncQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRuntimeMapEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRuntimeMapEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRuntimeMapEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRuntimeMapEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRuntimeMapEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRuntimeMapEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/get_all_runtime_map_files.go b/operations/maps/get_all_runtime_map_files.go new file mode 100644 index 00000000..49908536 --- /dev/null +++ b/operations/maps/get_all_runtime_map_files.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllRuntimeMapFilesHandlerFunc turns a function with the right signature into a get all runtime map files handler +type GetAllRuntimeMapFilesHandlerFunc func(GetAllRuntimeMapFilesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllRuntimeMapFilesHandlerFunc) Handle(params GetAllRuntimeMapFilesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllRuntimeMapFilesHandler interface for that can handle valid get all runtime map files params +type GetAllRuntimeMapFilesHandler interface { + Handle(GetAllRuntimeMapFilesParams, interface{}) middleware.Responder +} + +// NewGetAllRuntimeMapFiles creates a new http.Handler for the get all runtime map files operation +func NewGetAllRuntimeMapFiles(ctx *middleware.Context, handler GetAllRuntimeMapFilesHandler) *GetAllRuntimeMapFiles { + return &GetAllRuntimeMapFiles{Context: ctx, Handler: handler} +} + +/* + GetAllRuntimeMapFiles swagger:route GET /services/haproxy/runtime/maps Maps getAllRuntimeMapFiles + +# Return runtime map files + +Returns runtime map files. +*/ +type GetAllRuntimeMapFiles struct { + Context *middleware.Context + Handler GetAllRuntimeMapFilesHandler +} + +func (o *GetAllRuntimeMapFiles) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllRuntimeMapFilesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/get_all_runtime_map_files_parameters.go b/operations/maps/get_all_runtime_map_files_parameters.go new file mode 100644 index 00000000..ee72d0ce --- /dev/null +++ b/operations/maps/get_all_runtime_map_files_parameters.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetAllRuntimeMapFilesParams creates a new GetAllRuntimeMapFilesParams object +// with the default values initialized. +func NewGetAllRuntimeMapFilesParams() GetAllRuntimeMapFilesParams { + + var ( + // initialize parameters with default values + + includeUnmanagedDefault = bool(false) + ) + + return GetAllRuntimeMapFilesParams{ + IncludeUnmanaged: &includeUnmanagedDefault, + } +} + +// GetAllRuntimeMapFilesParams contains all the bound params for the get all runtime map files operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllRuntimeMapFiles +type GetAllRuntimeMapFilesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If true, also show unmanaged map files loaded in haproxy + In: query + Default: false + */ + IncludeUnmanaged *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllRuntimeMapFilesParams() beforehand. +func (o *GetAllRuntimeMapFilesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qIncludeUnmanaged, qhkIncludeUnmanaged, _ := qs.GetOK("include_unmanaged") + if err := o.bindIncludeUnmanaged(qIncludeUnmanaged, qhkIncludeUnmanaged, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIncludeUnmanaged binds and validates parameter IncludeUnmanaged from query. +func (o *GetAllRuntimeMapFilesParams) bindIncludeUnmanaged(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetAllRuntimeMapFilesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("include_unmanaged", "query", "bool", raw) + } + o.IncludeUnmanaged = &value + + return nil +} diff --git a/operations/maps/get_all_runtime_map_files_responses.go b/operations/maps/get_all_runtime_map_files_responses.go new file mode 100644 index 00000000..c4a94ae2 --- /dev/null +++ b/operations/maps/get_all_runtime_map_files_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllRuntimeMapFilesOKCode is the HTTP code returned for type GetAllRuntimeMapFilesOK +const GetAllRuntimeMapFilesOKCode int = 200 + +/* +GetAllRuntimeMapFilesOK Successful operation + +swagger:response getAllRuntimeMapFilesOK +*/ +type GetAllRuntimeMapFilesOK struct { + + /* + In: Body + */ + Payload models.Maps `json:"body,omitempty"` +} + +// NewGetAllRuntimeMapFilesOK creates GetAllRuntimeMapFilesOK with default headers values +func NewGetAllRuntimeMapFilesOK() *GetAllRuntimeMapFilesOK { + + return &GetAllRuntimeMapFilesOK{} +} + +// WithPayload adds the payload to the get all runtime map files o k response +func (o *GetAllRuntimeMapFilesOK) WithPayload(payload models.Maps) *GetAllRuntimeMapFilesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all runtime map files o k response +func (o *GetAllRuntimeMapFilesOK) SetPayload(payload models.Maps) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllRuntimeMapFilesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Maps{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAllRuntimeMapFilesNotFoundCode is the HTTP code returned for type GetAllRuntimeMapFilesNotFound +const GetAllRuntimeMapFilesNotFoundCode int = 404 + +/* +GetAllRuntimeMapFilesNotFound The specified resource was not found + +swagger:response getAllRuntimeMapFilesNotFound +*/ +type GetAllRuntimeMapFilesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllRuntimeMapFilesNotFound creates GetAllRuntimeMapFilesNotFound with default headers values +func NewGetAllRuntimeMapFilesNotFound() *GetAllRuntimeMapFilesNotFound { + + return &GetAllRuntimeMapFilesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all runtime map files not found response +func (o *GetAllRuntimeMapFilesNotFound) WithConfigurationVersion(configurationVersion string) *GetAllRuntimeMapFilesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all runtime map files not found response +func (o *GetAllRuntimeMapFilesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all runtime map files not found response +func (o *GetAllRuntimeMapFilesNotFound) WithPayload(payload *models.Error) *GetAllRuntimeMapFilesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all runtime map files not found response +func (o *GetAllRuntimeMapFilesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllRuntimeMapFilesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAllRuntimeMapFilesDefault General Error + +swagger:response getAllRuntimeMapFilesDefault +*/ +type GetAllRuntimeMapFilesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllRuntimeMapFilesDefault creates GetAllRuntimeMapFilesDefault with default headers values +func NewGetAllRuntimeMapFilesDefault(code int) *GetAllRuntimeMapFilesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllRuntimeMapFilesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all runtime map files default response +func (o *GetAllRuntimeMapFilesDefault) WithStatusCode(code int) *GetAllRuntimeMapFilesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all runtime map files default response +func (o *GetAllRuntimeMapFilesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all runtime map files default response +func (o *GetAllRuntimeMapFilesDefault) WithConfigurationVersion(configurationVersion string) *GetAllRuntimeMapFilesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all runtime map files default response +func (o *GetAllRuntimeMapFilesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all runtime map files default response +func (o *GetAllRuntimeMapFilesDefault) WithPayload(payload *models.Error) *GetAllRuntimeMapFilesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all runtime map files default response +func (o *GetAllRuntimeMapFilesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllRuntimeMapFilesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/get_all_runtime_map_files_urlbuilder.go b/operations/maps/get_all_runtime_map_files_urlbuilder.go new file mode 100644 index 00000000..cb1ff251 --- /dev/null +++ b/operations/maps/get_all_runtime_map_files_urlbuilder.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetAllRuntimeMapFilesURL generates an URL for the get all runtime map files operation +type GetAllRuntimeMapFilesURL struct { + IncludeUnmanaged *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllRuntimeMapFilesURL) WithBasePath(bp string) *GetAllRuntimeMapFilesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllRuntimeMapFilesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllRuntimeMapFilesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var includeUnmanagedQ string + if o.IncludeUnmanaged != nil { + includeUnmanagedQ = swag.FormatBool(*o.IncludeUnmanaged) + } + if includeUnmanagedQ != "" { + qs.Set("include_unmanaged", includeUnmanagedQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllRuntimeMapFilesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllRuntimeMapFilesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllRuntimeMapFilesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllRuntimeMapFilesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllRuntimeMapFilesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllRuntimeMapFilesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/get_one_runtime_map.go b/operations/maps/get_one_runtime_map.go new file mode 100644 index 00000000..941e6fa0 --- /dev/null +++ b/operations/maps/get_one_runtime_map.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetOneRuntimeMapHandlerFunc turns a function with the right signature into a get one runtime map handler +type GetOneRuntimeMapHandlerFunc func(GetOneRuntimeMapParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetOneRuntimeMapHandlerFunc) Handle(params GetOneRuntimeMapParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetOneRuntimeMapHandler interface for that can handle valid get one runtime map params +type GetOneRuntimeMapHandler interface { + Handle(GetOneRuntimeMapParams, interface{}) middleware.Responder +} + +// NewGetOneRuntimeMap creates a new http.Handler for the get one runtime map operation +func NewGetOneRuntimeMap(ctx *middleware.Context, handler GetOneRuntimeMapHandler) *GetOneRuntimeMap { + return &GetOneRuntimeMap{Context: ctx, Handler: handler} +} + +/* + GetOneRuntimeMap swagger:route GET /services/haproxy/runtime/maps/{name} Maps getOneRuntimeMap + +# Return one runtime map file + +Returns one runtime map file. +*/ +type GetOneRuntimeMap struct { + Context *middleware.Context + Handler GetOneRuntimeMapHandler +} + +func (o *GetOneRuntimeMap) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetOneRuntimeMapParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/get_one_runtime_map_parameters.go b/operations/maps/get_one_runtime_map_parameters.go new file mode 100644 index 00000000..3805121e --- /dev/null +++ b/operations/maps/get_one_runtime_map_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetOneRuntimeMapParams creates a new GetOneRuntimeMapParams object +// +// There are no default values defined in the spec. +func NewGetOneRuntimeMapParams() GetOneRuntimeMapParams { + + return GetOneRuntimeMapParams{} +} + +// GetOneRuntimeMapParams contains all the bound params for the get one runtime map operation +// typically these are obtained from a http.Request +// +// swagger:parameters getOneRuntimeMap +type GetOneRuntimeMapParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Map file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetOneRuntimeMapParams() beforehand. +func (o *GetOneRuntimeMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetOneRuntimeMapParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/maps/get_one_runtime_map_responses.go b/operations/maps/get_one_runtime_map_responses.go new file mode 100644 index 00000000..6aff1597 --- /dev/null +++ b/operations/maps/get_one_runtime_map_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetOneRuntimeMapOKCode is the HTTP code returned for type GetOneRuntimeMapOK +const GetOneRuntimeMapOKCode int = 200 + +/* +GetOneRuntimeMapOK Successful operation + +swagger:response getOneRuntimeMapOK +*/ +type GetOneRuntimeMapOK struct { + + /* + In: Body + */ + Payload *models.Map `json:"body,omitempty"` +} + +// NewGetOneRuntimeMapOK creates GetOneRuntimeMapOK with default headers values +func NewGetOneRuntimeMapOK() *GetOneRuntimeMapOK { + + return &GetOneRuntimeMapOK{} +} + +// WithPayload adds the payload to the get one runtime map o k response +func (o *GetOneRuntimeMapOK) WithPayload(payload *models.Map) *GetOneRuntimeMapOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one runtime map o k response +func (o *GetOneRuntimeMapOK) SetPayload(payload *models.Map) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneRuntimeMapOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetOneRuntimeMapNotFoundCode is the HTTP code returned for type GetOneRuntimeMapNotFound +const GetOneRuntimeMapNotFoundCode int = 404 + +/* +GetOneRuntimeMapNotFound The specified resource was not found + +swagger:response getOneRuntimeMapNotFound +*/ +type GetOneRuntimeMapNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneRuntimeMapNotFound creates GetOneRuntimeMapNotFound with default headers values +func NewGetOneRuntimeMapNotFound() *GetOneRuntimeMapNotFound { + + return &GetOneRuntimeMapNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get one runtime map not found response +func (o *GetOneRuntimeMapNotFound) WithConfigurationVersion(configurationVersion string) *GetOneRuntimeMapNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one runtime map not found response +func (o *GetOneRuntimeMapNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one runtime map not found response +func (o *GetOneRuntimeMapNotFound) WithPayload(payload *models.Error) *GetOneRuntimeMapNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one runtime map not found response +func (o *GetOneRuntimeMapNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneRuntimeMapNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetOneRuntimeMapDefault General Error + +swagger:response getOneRuntimeMapDefault +*/ +type GetOneRuntimeMapDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneRuntimeMapDefault creates GetOneRuntimeMapDefault with default headers values +func NewGetOneRuntimeMapDefault(code int) *GetOneRuntimeMapDefault { + if code <= 0 { + code = 500 + } + + return &GetOneRuntimeMapDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get one runtime map default response +func (o *GetOneRuntimeMapDefault) WithStatusCode(code int) *GetOneRuntimeMapDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get one runtime map default response +func (o *GetOneRuntimeMapDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get one runtime map default response +func (o *GetOneRuntimeMapDefault) WithConfigurationVersion(configurationVersion string) *GetOneRuntimeMapDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one runtime map default response +func (o *GetOneRuntimeMapDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one runtime map default response +func (o *GetOneRuntimeMapDefault) WithPayload(payload *models.Error) *GetOneRuntimeMapDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one runtime map default response +func (o *GetOneRuntimeMapDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneRuntimeMapDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/get_one_runtime_map_urlbuilder.go b/operations/maps/get_one_runtime_map_urlbuilder.go new file mode 100644 index 00000000..74cc1b6a --- /dev/null +++ b/operations/maps/get_one_runtime_map_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetOneRuntimeMapURL generates an URL for the get one runtime map operation +type GetOneRuntimeMapURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneRuntimeMapURL) WithBasePath(bp string) *GetOneRuntimeMapURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneRuntimeMapURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetOneRuntimeMapURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetOneRuntimeMapURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetOneRuntimeMapURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetOneRuntimeMapURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetOneRuntimeMapURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetOneRuntimeMapURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetOneRuntimeMapURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetOneRuntimeMapURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/get_runtime_map_entry.go b/operations/maps/get_runtime_map_entry.go new file mode 100644 index 00000000..f985515c --- /dev/null +++ b/operations/maps/get_runtime_map_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRuntimeMapEntryHandlerFunc turns a function with the right signature into a get runtime map entry handler +type GetRuntimeMapEntryHandlerFunc func(GetRuntimeMapEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRuntimeMapEntryHandlerFunc) Handle(params GetRuntimeMapEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRuntimeMapEntryHandler interface for that can handle valid get runtime map entry params +type GetRuntimeMapEntryHandler interface { + Handle(GetRuntimeMapEntryParams, interface{}) middleware.Responder +} + +// NewGetRuntimeMapEntry creates a new http.Handler for the get runtime map entry operation +func NewGetRuntimeMapEntry(ctx *middleware.Context, handler GetRuntimeMapEntryHandler) *GetRuntimeMapEntry { + return &GetRuntimeMapEntry{Context: ctx, Handler: handler} +} + +/* + GetRuntimeMapEntry swagger:route GET /services/haproxy/runtime/maps/{parent_name}/entries/{id} Maps getRuntimeMapEntry + +# Return one map runtime setting + +Returns one map runtime setting by it's id. +*/ +type GetRuntimeMapEntry struct { + Context *middleware.Context + Handler GetRuntimeMapEntryHandler +} + +func (o *GetRuntimeMapEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetRuntimeMapEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/get_runtime_map_entry_parameters.go b/operations/maps/get_runtime_map_entry_parameters.go new file mode 100644 index 00000000..99f67a04 --- /dev/null +++ b/operations/maps/get_runtime_map_entry_parameters.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetRuntimeMapEntryParams creates a new GetRuntimeMapEntryParams object +// +// There are no default values defined in the spec. +func NewGetRuntimeMapEntryParams() GetRuntimeMapEntryParams { + + return GetRuntimeMapEntryParams{} +} + +// GetRuntimeMapEntryParams contains all the bound params for the get runtime map entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRuntimeMapEntry +type GetRuntimeMapEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Map id + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRuntimeMapEntryParams() beforehand. +func (o *GetRuntimeMapEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetRuntimeMapEntryParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetRuntimeMapEntryParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/maps/get_runtime_map_entry_responses.go b/operations/maps/get_runtime_map_entry_responses.go new file mode 100644 index 00000000..db5b1992 --- /dev/null +++ b/operations/maps/get_runtime_map_entry_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetRuntimeMapEntryOKCode is the HTTP code returned for type GetRuntimeMapEntryOK +const GetRuntimeMapEntryOKCode int = 200 + +/* +GetRuntimeMapEntryOK Successful operation + +swagger:response getRuntimeMapEntryOK +*/ +type GetRuntimeMapEntryOK struct { + + /* + In: Body + */ + Payload *models.MapEntry `json:"body,omitempty"` +} + +// NewGetRuntimeMapEntryOK creates GetRuntimeMapEntryOK with default headers values +func NewGetRuntimeMapEntryOK() *GetRuntimeMapEntryOK { + + return &GetRuntimeMapEntryOK{} +} + +// WithPayload adds the payload to the get runtime map entry o k response +func (o *GetRuntimeMapEntryOK) WithPayload(payload *models.MapEntry) *GetRuntimeMapEntryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime map entry o k response +func (o *GetRuntimeMapEntryOK) SetPayload(payload *models.MapEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeMapEntryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRuntimeMapEntryNotFoundCode is the HTTP code returned for type GetRuntimeMapEntryNotFound +const GetRuntimeMapEntryNotFoundCode int = 404 + +/* +GetRuntimeMapEntryNotFound The specified resource was not found + +swagger:response getRuntimeMapEntryNotFound +*/ +type GetRuntimeMapEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRuntimeMapEntryNotFound creates GetRuntimeMapEntryNotFound with default headers values +func NewGetRuntimeMapEntryNotFound() *GetRuntimeMapEntryNotFound { + + return &GetRuntimeMapEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get runtime map entry not found response +func (o *GetRuntimeMapEntryNotFound) WithConfigurationVersion(configurationVersion string) *GetRuntimeMapEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get runtime map entry not found response +func (o *GetRuntimeMapEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get runtime map entry not found response +func (o *GetRuntimeMapEntryNotFound) WithPayload(payload *models.Error) *GetRuntimeMapEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime map entry not found response +func (o *GetRuntimeMapEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeMapEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetRuntimeMapEntryDefault General Error + +swagger:response getRuntimeMapEntryDefault +*/ +type GetRuntimeMapEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRuntimeMapEntryDefault creates GetRuntimeMapEntryDefault with default headers values +func NewGetRuntimeMapEntryDefault(code int) *GetRuntimeMapEntryDefault { + if code <= 0 { + code = 500 + } + + return &GetRuntimeMapEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get runtime map entry default response +func (o *GetRuntimeMapEntryDefault) WithStatusCode(code int) *GetRuntimeMapEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get runtime map entry default response +func (o *GetRuntimeMapEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get runtime map entry default response +func (o *GetRuntimeMapEntryDefault) WithConfigurationVersion(configurationVersion string) *GetRuntimeMapEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get runtime map entry default response +func (o *GetRuntimeMapEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get runtime map entry default response +func (o *GetRuntimeMapEntryDefault) WithPayload(payload *models.Error) *GetRuntimeMapEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime map entry default response +func (o *GetRuntimeMapEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeMapEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/get_runtime_map_entry_urlbuilder.go b/operations/maps/get_runtime_map_entry_urlbuilder.go new file mode 100644 index 00000000..0fba709b --- /dev/null +++ b/operations/maps/get_runtime_map_entry_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetRuntimeMapEntryURL generates an URL for the get runtime map entry operation +type GetRuntimeMapEntryURL struct { + ID string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRuntimeMapEntryURL) WithBasePath(bp string) *GetRuntimeMapEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRuntimeMapEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRuntimeMapEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{parent_name}/entries/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetRuntimeMapEntryURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetRuntimeMapEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRuntimeMapEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRuntimeMapEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRuntimeMapEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRuntimeMapEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRuntimeMapEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRuntimeMapEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/replace_runtime_map_entry.go b/operations/maps/replace_runtime_map_entry.go new file mode 100644 index 00000000..9cfcca94 --- /dev/null +++ b/operations/maps/replace_runtime_map_entry.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ReplaceRuntimeMapEntryHandlerFunc turns a function with the right signature into a replace runtime map entry handler +type ReplaceRuntimeMapEntryHandlerFunc func(ReplaceRuntimeMapEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceRuntimeMapEntryHandlerFunc) Handle(params ReplaceRuntimeMapEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceRuntimeMapEntryHandler interface for that can handle valid replace runtime map entry params +type ReplaceRuntimeMapEntryHandler interface { + Handle(ReplaceRuntimeMapEntryParams, interface{}) middleware.Responder +} + +// NewReplaceRuntimeMapEntry creates a new http.Handler for the replace runtime map entry operation +func NewReplaceRuntimeMapEntry(ctx *middleware.Context, handler ReplaceRuntimeMapEntryHandler) *ReplaceRuntimeMapEntry { + return &ReplaceRuntimeMapEntry{Context: ctx, Handler: handler} +} + +/* + ReplaceRuntimeMapEntry swagger:route PUT /services/haproxy/runtime/maps/{parent_name}/entries/{id} Maps replaceRuntimeMapEntry + +# Replace the value corresponding to each id in a map + +Replaces the value corresponding to each id in a map. +*/ +type ReplaceRuntimeMapEntry struct { + Context *middleware.Context + Handler ReplaceRuntimeMapEntryHandler +} + +func (o *ReplaceRuntimeMapEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceRuntimeMapEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// ReplaceRuntimeMapEntryBody replace runtime map entry body +// +// swagger:model ReplaceRuntimeMapEntryBody +type ReplaceRuntimeMapEntryBody struct { + + // Map value + // Required: true + Value *string `json:"value"` +} + +// Validate validates this replace runtime map entry body +func (o *ReplaceRuntimeMapEntryBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateValue(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ReplaceRuntimeMapEntryBody) validateValue(formats strfmt.Registry) error { + + if err := validate.Required("data"+"."+"value", "body", o.Value); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this replace runtime map entry body based on context it is used +func (o *ReplaceRuntimeMapEntryBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ReplaceRuntimeMapEntryBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ReplaceRuntimeMapEntryBody) UnmarshalBinary(b []byte) error { + var res ReplaceRuntimeMapEntryBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/operations/maps/replace_runtime_map_entry_parameters.go b/operations/maps/replace_runtime_map_entry_parameters.go new file mode 100644 index 00000000..2c6d3eeb --- /dev/null +++ b/operations/maps/replace_runtime_map_entry_parameters.go @@ -0,0 +1,184 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewReplaceRuntimeMapEntryParams creates a new ReplaceRuntimeMapEntryParams object +// with the default values initialized. +func NewReplaceRuntimeMapEntryParams() ReplaceRuntimeMapEntryParams { + + var ( + // initialize parameters with default values + + forceSyncDefault = bool(false) + ) + + return ReplaceRuntimeMapEntryParams{ + ForceSync: &forceSyncDefault, + } +} + +// ReplaceRuntimeMapEntryParams contains all the bound params for the replace runtime map entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceRuntimeMapEntry +type ReplaceRuntimeMapEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data ReplaceRuntimeMapEntryBody + /*If true, immediately syncs changes to disk + In: query + Default: false + */ + ForceSync *bool + /*Map id + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceRuntimeMapEntryParams() beforehand. +func (o *ReplaceRuntimeMapEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body ReplaceRuntimeMapEntryBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceSync, qhkForceSync, _ := qs.GetOK("force_sync") + if err := o.bindForceSync(qForceSync, qhkForceSync, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceSync binds and validates parameter ForceSync from query. +func (o *ReplaceRuntimeMapEntryParams) bindForceSync(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceRuntimeMapEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_sync", "query", "bool", raw) + } + o.ForceSync = &value + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ReplaceRuntimeMapEntryParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceRuntimeMapEntryParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/maps/replace_runtime_map_entry_responses.go b/operations/maps/replace_runtime_map_entry_responses.go new file mode 100644 index 00000000..9856c8f3 --- /dev/null +++ b/operations/maps/replace_runtime_map_entry_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceRuntimeMapEntryOKCode is the HTTP code returned for type ReplaceRuntimeMapEntryOK +const ReplaceRuntimeMapEntryOKCode int = 200 + +/* +ReplaceRuntimeMapEntryOK Map value replaced + +swagger:response replaceRuntimeMapEntryOK +*/ +type ReplaceRuntimeMapEntryOK struct { + + /* + In: Body + */ + Payload *models.MapEntry `json:"body,omitempty"` +} + +// NewReplaceRuntimeMapEntryOK creates ReplaceRuntimeMapEntryOK with default headers values +func NewReplaceRuntimeMapEntryOK() *ReplaceRuntimeMapEntryOK { + + return &ReplaceRuntimeMapEntryOK{} +} + +// WithPayload adds the payload to the replace runtime map entry o k response +func (o *ReplaceRuntimeMapEntryOK) WithPayload(payload *models.MapEntry) *ReplaceRuntimeMapEntryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime map entry o k response +func (o *ReplaceRuntimeMapEntryOK) SetPayload(payload *models.MapEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeMapEntryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceRuntimeMapEntryBadRequestCode is the HTTP code returned for type ReplaceRuntimeMapEntryBadRequest +const ReplaceRuntimeMapEntryBadRequestCode int = 400 + +/* +ReplaceRuntimeMapEntryBadRequest Bad request + +swagger:response replaceRuntimeMapEntryBadRequest +*/ +type ReplaceRuntimeMapEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRuntimeMapEntryBadRequest creates ReplaceRuntimeMapEntryBadRequest with default headers values +func NewReplaceRuntimeMapEntryBadRequest() *ReplaceRuntimeMapEntryBadRequest { + + return &ReplaceRuntimeMapEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace runtime map entry bad request response +func (o *ReplaceRuntimeMapEntryBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceRuntimeMapEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace runtime map entry bad request response +func (o *ReplaceRuntimeMapEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace runtime map entry bad request response +func (o *ReplaceRuntimeMapEntryBadRequest) WithPayload(payload *models.Error) *ReplaceRuntimeMapEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime map entry bad request response +func (o *ReplaceRuntimeMapEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeMapEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceRuntimeMapEntryNotFoundCode is the HTTP code returned for type ReplaceRuntimeMapEntryNotFound +const ReplaceRuntimeMapEntryNotFoundCode int = 404 + +/* +ReplaceRuntimeMapEntryNotFound The specified resource was not found + +swagger:response replaceRuntimeMapEntryNotFound +*/ +type ReplaceRuntimeMapEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRuntimeMapEntryNotFound creates ReplaceRuntimeMapEntryNotFound with default headers values +func NewReplaceRuntimeMapEntryNotFound() *ReplaceRuntimeMapEntryNotFound { + + return &ReplaceRuntimeMapEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace runtime map entry not found response +func (o *ReplaceRuntimeMapEntryNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceRuntimeMapEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace runtime map entry not found response +func (o *ReplaceRuntimeMapEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace runtime map entry not found response +func (o *ReplaceRuntimeMapEntryNotFound) WithPayload(payload *models.Error) *ReplaceRuntimeMapEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime map entry not found response +func (o *ReplaceRuntimeMapEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeMapEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceRuntimeMapEntryDefault General Error + +swagger:response replaceRuntimeMapEntryDefault +*/ +type ReplaceRuntimeMapEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRuntimeMapEntryDefault creates ReplaceRuntimeMapEntryDefault with default headers values +func NewReplaceRuntimeMapEntryDefault(code int) *ReplaceRuntimeMapEntryDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceRuntimeMapEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace runtime map entry default response +func (o *ReplaceRuntimeMapEntryDefault) WithStatusCode(code int) *ReplaceRuntimeMapEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace runtime map entry default response +func (o *ReplaceRuntimeMapEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace runtime map entry default response +func (o *ReplaceRuntimeMapEntryDefault) WithConfigurationVersion(configurationVersion string) *ReplaceRuntimeMapEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace runtime map entry default response +func (o *ReplaceRuntimeMapEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace runtime map entry default response +func (o *ReplaceRuntimeMapEntryDefault) WithPayload(payload *models.Error) *ReplaceRuntimeMapEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime map entry default response +func (o *ReplaceRuntimeMapEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeMapEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/replace_runtime_map_entry_urlbuilder.go b/operations/maps/replace_runtime_map_entry_urlbuilder.go new file mode 100644 index 00000000..bb8839fa --- /dev/null +++ b/operations/maps/replace_runtime_map_entry_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceRuntimeMapEntryURL generates an URL for the replace runtime map entry operation +type ReplaceRuntimeMapEntryURL struct { + ID string + ParentName string + + ForceSync *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceRuntimeMapEntryURL) WithBasePath(bp string) *ReplaceRuntimeMapEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceRuntimeMapEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceRuntimeMapEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{parent_name}/entries/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ReplaceRuntimeMapEntryURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceRuntimeMapEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceSyncQ string + if o.ForceSync != nil { + forceSyncQ = swag.FormatBool(*o.ForceSync) + } + if forceSyncQ != "" { + qs.Set("force_sync", forceSyncQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceRuntimeMapEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceRuntimeMapEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceRuntimeMapEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceRuntimeMapEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceRuntimeMapEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceRuntimeMapEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/maps/show_runtime_map.go b/operations/maps/show_runtime_map.go new file mode 100644 index 00000000..87284e75 --- /dev/null +++ b/operations/maps/show_runtime_map.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ShowRuntimeMapHandlerFunc turns a function with the right signature into a show runtime map handler +type ShowRuntimeMapHandlerFunc func(ShowRuntimeMapParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ShowRuntimeMapHandlerFunc) Handle(params ShowRuntimeMapParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ShowRuntimeMapHandler interface for that can handle valid show runtime map params +type ShowRuntimeMapHandler interface { + Handle(ShowRuntimeMapParams, interface{}) middleware.Responder +} + +// NewShowRuntimeMap creates a new http.Handler for the show runtime map operation +func NewShowRuntimeMap(ctx *middleware.Context, handler ShowRuntimeMapHandler) *ShowRuntimeMap { + return &ShowRuntimeMap{Context: ctx, Handler: handler} +} + +/* + ShowRuntimeMap swagger:route GET /services/haproxy/runtime/maps/{parent_name}/entries Maps showRuntimeMap + +# Return one map runtime entries + +Returns an array of all entries in a given runtime map file. +*/ +type ShowRuntimeMap struct { + Context *middleware.Context + Handler ShowRuntimeMapHandler +} + +func (o *ShowRuntimeMap) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewShowRuntimeMapParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/maps/show_runtime_map_parameters.go b/operations/maps/show_runtime_map_parameters.go new file mode 100644 index 00000000..1448e28b --- /dev/null +++ b/operations/maps/show_runtime_map_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewShowRuntimeMapParams creates a new ShowRuntimeMapParams object +// +// There are no default values defined in the spec. +func NewShowRuntimeMapParams() ShowRuntimeMapParams { + + return ShowRuntimeMapParams{} +} + +// ShowRuntimeMapParams contains all the bound params for the show runtime map operation +// typically these are obtained from a http.Request +// +// swagger:parameters showRuntimeMap +type ShowRuntimeMapParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewShowRuntimeMapParams() beforehand. +func (o *ShowRuntimeMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ShowRuntimeMapParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/maps/show_runtime_map_responses.go b/operations/maps/show_runtime_map_responses.go new file mode 100644 index 00000000..e1fb0d34 --- /dev/null +++ b/operations/maps/show_runtime_map_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ShowRuntimeMapOKCode is the HTTP code returned for type ShowRuntimeMapOK +const ShowRuntimeMapOKCode int = 200 + +/* +ShowRuntimeMapOK Successful operation + +swagger:response showRuntimeMapOK +*/ +type ShowRuntimeMapOK struct { + + /* + In: Body + */ + Payload models.MapEntries `json:"body,omitempty"` +} + +// NewShowRuntimeMapOK creates ShowRuntimeMapOK with default headers values +func NewShowRuntimeMapOK() *ShowRuntimeMapOK { + + return &ShowRuntimeMapOK{} +} + +// WithPayload adds the payload to the show runtime map o k response +func (o *ShowRuntimeMapOK) WithPayload(payload models.MapEntries) *ShowRuntimeMapOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the show runtime map o k response +func (o *ShowRuntimeMapOK) SetPayload(payload models.MapEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ShowRuntimeMapOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.MapEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ShowRuntimeMapNotFoundCode is the HTTP code returned for type ShowRuntimeMapNotFound +const ShowRuntimeMapNotFoundCode int = 404 + +/* +ShowRuntimeMapNotFound The specified resource was not found + +swagger:response showRuntimeMapNotFound +*/ +type ShowRuntimeMapNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewShowRuntimeMapNotFound creates ShowRuntimeMapNotFound with default headers values +func NewShowRuntimeMapNotFound() *ShowRuntimeMapNotFound { + + return &ShowRuntimeMapNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the show runtime map not found response +func (o *ShowRuntimeMapNotFound) WithConfigurationVersion(configurationVersion string) *ShowRuntimeMapNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the show runtime map not found response +func (o *ShowRuntimeMapNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the show runtime map not found response +func (o *ShowRuntimeMapNotFound) WithPayload(payload *models.Error) *ShowRuntimeMapNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the show runtime map not found response +func (o *ShowRuntimeMapNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ShowRuntimeMapNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ShowRuntimeMapDefault General Error + +swagger:response showRuntimeMapDefault +*/ +type ShowRuntimeMapDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewShowRuntimeMapDefault creates ShowRuntimeMapDefault with default headers values +func NewShowRuntimeMapDefault(code int) *ShowRuntimeMapDefault { + if code <= 0 { + code = 500 + } + + return &ShowRuntimeMapDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the show runtime map default response +func (o *ShowRuntimeMapDefault) WithStatusCode(code int) *ShowRuntimeMapDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the show runtime map default response +func (o *ShowRuntimeMapDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the show runtime map default response +func (o *ShowRuntimeMapDefault) WithConfigurationVersion(configurationVersion string) *ShowRuntimeMapDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the show runtime map default response +func (o *ShowRuntimeMapDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the show runtime map default response +func (o *ShowRuntimeMapDefault) WithPayload(payload *models.Error) *ShowRuntimeMapDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the show runtime map default response +func (o *ShowRuntimeMapDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ShowRuntimeMapDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/maps/show_runtime_map_urlbuilder.go b/operations/maps/show_runtime_map_urlbuilder.go new file mode 100644 index 00000000..cf7628d8 --- /dev/null +++ b/operations/maps/show_runtime_map_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package maps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ShowRuntimeMapURL generates an URL for the show runtime map operation +type ShowRuntimeMapURL struct { + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ShowRuntimeMapURL) WithBasePath(bp string) *ShowRuntimeMapURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ShowRuntimeMapURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ShowRuntimeMapURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/maps/{parent_name}/entries" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ShowRuntimeMapURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ShowRuntimeMapURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ShowRuntimeMapURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ShowRuntimeMapURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ShowRuntimeMapURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ShowRuntimeMapURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ShowRuntimeMapURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/nameserver/create_nameserver.go b/operations/nameserver/create_nameserver.go new file mode 100644 index 00000000..022a1093 --- /dev/null +++ b/operations/nameserver/create_nameserver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateNameserverHandlerFunc turns a function with the right signature into a create nameserver handler +type CreateNameserverHandlerFunc func(CreateNameserverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateNameserverHandlerFunc) Handle(params CreateNameserverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateNameserverHandler interface for that can handle valid create nameserver params +type CreateNameserverHandler interface { + Handle(CreateNameserverParams, interface{}) middleware.Responder +} + +// NewCreateNameserver creates a new http.Handler for the create nameserver operation +func NewCreateNameserver(ctx *middleware.Context, handler CreateNameserverHandler) *CreateNameserver { + return &CreateNameserver{Context: ctx, Handler: handler} +} + +/* + CreateNameserver swagger:route POST /services/haproxy/configuration/nameservers Nameserver createNameserver + +# Add a nameserver + +Adds a new nameserver to the resolvers section. +*/ +type CreateNameserver struct { + Context *middleware.Context + Handler CreateNameserverHandler +} + +func (o *CreateNameserver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateNameserverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/nameserver/create_nameserver_parameters.go b/operations/nameserver/create_nameserver_parameters.go new file mode 100644 index 00000000..f22446f2 --- /dev/null +++ b/operations/nameserver/create_nameserver_parameters.go @@ -0,0 +1,229 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateNameserverParams creates a new CreateNameserverParams object +// with the default values initialized. +func NewCreateNameserverParams() CreateNameserverParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateNameserverParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateNameserverParams contains all the bound params for the create nameserver operation +// typically these are obtained from a http.Request +// +// swagger:parameters createNameserver +type CreateNameserverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Nameserver + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent resolver name + Required: true + In: query + */ + Resolver string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateNameserverParams() beforehand. +func (o *CreateNameserverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Nameserver + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qResolver, qhkResolver, _ := qs.GetOK("resolver") + if err := o.bindResolver(qResolver, qhkResolver, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateNameserverParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateNameserverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindResolver binds and validates parameter Resolver from query. +func (o *CreateNameserverParams) bindResolver(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("resolver", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("resolver", "query", raw); err != nil { + return err + } + o.Resolver = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateNameserverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateNameserverParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/nameserver/create_nameserver_responses.go b/operations/nameserver/create_nameserver_responses.go new file mode 100644 index 00000000..578b89c4 --- /dev/null +++ b/operations/nameserver/create_nameserver_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateNameserverCreatedCode is the HTTP code returned for type CreateNameserverCreated +const CreateNameserverCreatedCode int = 201 + +/* +CreateNameserverCreated Nameserver created + +swagger:response createNameserverCreated +*/ +type CreateNameserverCreated struct { + + /* + In: Body + */ + Payload *models.Nameserver `json:"body,omitempty"` +} + +// NewCreateNameserverCreated creates CreateNameserverCreated with default headers values +func NewCreateNameserverCreated() *CreateNameserverCreated { + + return &CreateNameserverCreated{} +} + +// WithPayload adds the payload to the create nameserver created response +func (o *CreateNameserverCreated) WithPayload(payload *models.Nameserver) *CreateNameserverCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create nameserver created response +func (o *CreateNameserverCreated) SetPayload(payload *models.Nameserver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateNameserverCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateNameserverAcceptedCode is the HTTP code returned for type CreateNameserverAccepted +const CreateNameserverAcceptedCode int = 202 + +/* +CreateNameserverAccepted Configuration change accepted and reload requested + +swagger:response createNameserverAccepted +*/ +type CreateNameserverAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Nameserver `json:"body,omitempty"` +} + +// NewCreateNameserverAccepted creates CreateNameserverAccepted with default headers values +func NewCreateNameserverAccepted() *CreateNameserverAccepted { + + return &CreateNameserverAccepted{} +} + +// WithReloadID adds the reloadId to the create nameserver accepted response +func (o *CreateNameserverAccepted) WithReloadID(reloadID string) *CreateNameserverAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create nameserver accepted response +func (o *CreateNameserverAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create nameserver accepted response +func (o *CreateNameserverAccepted) WithPayload(payload *models.Nameserver) *CreateNameserverAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create nameserver accepted response +func (o *CreateNameserverAccepted) SetPayload(payload *models.Nameserver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateNameserverAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateNameserverBadRequestCode is the HTTP code returned for type CreateNameserverBadRequest +const CreateNameserverBadRequestCode int = 400 + +/* +CreateNameserverBadRequest Bad request + +swagger:response createNameserverBadRequest +*/ +type CreateNameserverBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateNameserverBadRequest creates CreateNameserverBadRequest with default headers values +func NewCreateNameserverBadRequest() *CreateNameserverBadRequest { + + return &CreateNameserverBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create nameserver bad request response +func (o *CreateNameserverBadRequest) WithConfigurationVersion(configurationVersion string) *CreateNameserverBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create nameserver bad request response +func (o *CreateNameserverBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create nameserver bad request response +func (o *CreateNameserverBadRequest) WithPayload(payload *models.Error) *CreateNameserverBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create nameserver bad request response +func (o *CreateNameserverBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateNameserverBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateNameserverConflictCode is the HTTP code returned for type CreateNameserverConflict +const CreateNameserverConflictCode int = 409 + +/* +CreateNameserverConflict The specified resource already exists + +swagger:response createNameserverConflict +*/ +type CreateNameserverConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateNameserverConflict creates CreateNameserverConflict with default headers values +func NewCreateNameserverConflict() *CreateNameserverConflict { + + return &CreateNameserverConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create nameserver conflict response +func (o *CreateNameserverConflict) WithConfigurationVersion(configurationVersion string) *CreateNameserverConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create nameserver conflict response +func (o *CreateNameserverConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create nameserver conflict response +func (o *CreateNameserverConflict) WithPayload(payload *models.Error) *CreateNameserverConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create nameserver conflict response +func (o *CreateNameserverConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateNameserverConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateNameserverDefault General Error + +swagger:response createNameserverDefault +*/ +type CreateNameserverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateNameserverDefault creates CreateNameserverDefault with default headers values +func NewCreateNameserverDefault(code int) *CreateNameserverDefault { + if code <= 0 { + code = 500 + } + + return &CreateNameserverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create nameserver default response +func (o *CreateNameserverDefault) WithStatusCode(code int) *CreateNameserverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create nameserver default response +func (o *CreateNameserverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create nameserver default response +func (o *CreateNameserverDefault) WithConfigurationVersion(configurationVersion string) *CreateNameserverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create nameserver default response +func (o *CreateNameserverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create nameserver default response +func (o *CreateNameserverDefault) WithPayload(payload *models.Error) *CreateNameserverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create nameserver default response +func (o *CreateNameserverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateNameserverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/nameserver/create_nameserver_urlbuilder.go b/operations/nameserver/create_nameserver_urlbuilder.go new file mode 100644 index 00000000..97618cba --- /dev/null +++ b/operations/nameserver/create_nameserver_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateNameserverURL generates an URL for the create nameserver operation +type CreateNameserverURL struct { + ForceReload *bool + Resolver string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateNameserverURL) WithBasePath(bp string) *CreateNameserverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateNameserverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateNameserverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/nameservers" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + resolverQ := o.Resolver + if resolverQ != "" { + qs.Set("resolver", resolverQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateNameserverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateNameserverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateNameserverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateNameserverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateNameserverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateNameserverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/nameserver/delete_nameserver.go b/operations/nameserver/delete_nameserver.go new file mode 100644 index 00000000..076fad3f --- /dev/null +++ b/operations/nameserver/delete_nameserver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteNameserverHandlerFunc turns a function with the right signature into a delete nameserver handler +type DeleteNameserverHandlerFunc func(DeleteNameserverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteNameserverHandlerFunc) Handle(params DeleteNameserverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteNameserverHandler interface for that can handle valid delete nameserver params +type DeleteNameserverHandler interface { + Handle(DeleteNameserverParams, interface{}) middleware.Responder +} + +// NewDeleteNameserver creates a new http.Handler for the delete nameserver operation +func NewDeleteNameserver(ctx *middleware.Context, handler DeleteNameserverHandler) *DeleteNameserver { + return &DeleteNameserver{Context: ctx, Handler: handler} +} + +/* + DeleteNameserver swagger:route DELETE /services/haproxy/configuration/nameservers/{name} Nameserver deleteNameserver + +# Delete a nameserver + +Deletes a nameserver from the resolvers section by it's name. +*/ +type DeleteNameserver struct { + Context *middleware.Context + Handler DeleteNameserverHandler +} + +func (o *DeleteNameserver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteNameserverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/nameserver/delete_nameserver_parameters.go b/operations/nameserver/delete_nameserver_parameters.go new file mode 100644 index 00000000..94410ce1 --- /dev/null +++ b/operations/nameserver/delete_nameserver_parameters.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteNameserverParams creates a new DeleteNameserverParams object +// with the default values initialized. +func NewDeleteNameserverParams() DeleteNameserverParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteNameserverParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteNameserverParams contains all the bound params for the delete nameserver operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteNameserver +type DeleteNameserverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Nameserver name + Required: true + In: path + */ + Name string + /*Parent resolver name + Required: true + In: query + */ + Resolver string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteNameserverParams() beforehand. +func (o *DeleteNameserverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qResolver, qhkResolver, _ := qs.GetOK("resolver") + if err := o.bindResolver(qResolver, qhkResolver, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteNameserverParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteNameserverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteNameserverParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindResolver binds and validates parameter Resolver from query. +func (o *DeleteNameserverParams) bindResolver(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("resolver", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("resolver", "query", raw); err != nil { + return err + } + o.Resolver = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteNameserverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteNameserverParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/nameserver/delete_nameserver_responses.go b/operations/nameserver/delete_nameserver_responses.go new file mode 100644 index 00000000..58cf3bc8 --- /dev/null +++ b/operations/nameserver/delete_nameserver_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteNameserverAcceptedCode is the HTTP code returned for type DeleteNameserverAccepted +const DeleteNameserverAcceptedCode int = 202 + +/* +DeleteNameserverAccepted Configuration change accepted and reload requested + +swagger:response deleteNameserverAccepted +*/ +type DeleteNameserverAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteNameserverAccepted creates DeleteNameserverAccepted with default headers values +func NewDeleteNameserverAccepted() *DeleteNameserverAccepted { + + return &DeleteNameserverAccepted{} +} + +// WithReloadID adds the reloadId to the delete nameserver accepted response +func (o *DeleteNameserverAccepted) WithReloadID(reloadID string) *DeleteNameserverAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete nameserver accepted response +func (o *DeleteNameserverAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteNameserverAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteNameserverNoContentCode is the HTTP code returned for type DeleteNameserverNoContent +const DeleteNameserverNoContentCode int = 204 + +/* +DeleteNameserverNoContent Nameserver deleted + +swagger:response deleteNameserverNoContent +*/ +type DeleteNameserverNoContent struct { +} + +// NewDeleteNameserverNoContent creates DeleteNameserverNoContent with default headers values +func NewDeleteNameserverNoContent() *DeleteNameserverNoContent { + + return &DeleteNameserverNoContent{} +} + +// WriteResponse to the client +func (o *DeleteNameserverNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteNameserverNotFoundCode is the HTTP code returned for type DeleteNameserverNotFound +const DeleteNameserverNotFoundCode int = 404 + +/* +DeleteNameserverNotFound The specified resource was not found + +swagger:response deleteNameserverNotFound +*/ +type DeleteNameserverNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteNameserverNotFound creates DeleteNameserverNotFound with default headers values +func NewDeleteNameserverNotFound() *DeleteNameserverNotFound { + + return &DeleteNameserverNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete nameserver not found response +func (o *DeleteNameserverNotFound) WithConfigurationVersion(configurationVersion string) *DeleteNameserverNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete nameserver not found response +func (o *DeleteNameserverNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete nameserver not found response +func (o *DeleteNameserverNotFound) WithPayload(payload *models.Error) *DeleteNameserverNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete nameserver not found response +func (o *DeleteNameserverNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteNameserverNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteNameserverDefault General Error + +swagger:response deleteNameserverDefault +*/ +type DeleteNameserverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteNameserverDefault creates DeleteNameserverDefault with default headers values +func NewDeleteNameserverDefault(code int) *DeleteNameserverDefault { + if code <= 0 { + code = 500 + } + + return &DeleteNameserverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete nameserver default response +func (o *DeleteNameserverDefault) WithStatusCode(code int) *DeleteNameserverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete nameserver default response +func (o *DeleteNameserverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete nameserver default response +func (o *DeleteNameserverDefault) WithConfigurationVersion(configurationVersion string) *DeleteNameserverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete nameserver default response +func (o *DeleteNameserverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete nameserver default response +func (o *DeleteNameserverDefault) WithPayload(payload *models.Error) *DeleteNameserverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete nameserver default response +func (o *DeleteNameserverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteNameserverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/nameserver/delete_nameserver_urlbuilder.go b/operations/nameserver/delete_nameserver_urlbuilder.go new file mode 100644 index 00000000..d07831fb --- /dev/null +++ b/operations/nameserver/delete_nameserver_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteNameserverURL generates an URL for the delete nameserver operation +type DeleteNameserverURL struct { + Name string + + ForceReload *bool + Resolver string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteNameserverURL) WithBasePath(bp string) *DeleteNameserverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteNameserverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteNameserverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/nameservers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteNameserverURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + resolverQ := o.Resolver + if resolverQ != "" { + qs.Set("resolver", resolverQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteNameserverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteNameserverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteNameserverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteNameserverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteNameserverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteNameserverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/nameserver/get_nameserver.go b/operations/nameserver/get_nameserver.go new file mode 100644 index 00000000..33a2bc4e --- /dev/null +++ b/operations/nameserver/get_nameserver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetNameserverHandlerFunc turns a function with the right signature into a get nameserver handler +type GetNameserverHandlerFunc func(GetNameserverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetNameserverHandlerFunc) Handle(params GetNameserverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetNameserverHandler interface for that can handle valid get nameserver params +type GetNameserverHandler interface { + Handle(GetNameserverParams, interface{}) middleware.Responder +} + +// NewGetNameserver creates a new http.Handler for the get nameserver operation +func NewGetNameserver(ctx *middleware.Context, handler GetNameserverHandler) *GetNameserver { + return &GetNameserver{Context: ctx, Handler: handler} +} + +/* + GetNameserver swagger:route GET /services/haproxy/configuration/nameservers/{name} Nameserver getNameserver + +# Return a nameserver + +Returns one nameserver configuration by it's name. +*/ +type GetNameserver struct { + Context *middleware.Context + Handler GetNameserverHandler +} + +func (o *GetNameserver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetNameserverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/nameserver/get_nameserver_parameters.go b/operations/nameserver/get_nameserver_parameters.go new file mode 100644 index 00000000..5cf71aa1 --- /dev/null +++ b/operations/nameserver/get_nameserver_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetNameserverParams creates a new GetNameserverParams object +// +// There are no default values defined in the spec. +func NewGetNameserverParams() GetNameserverParams { + + return GetNameserverParams{} +} + +// GetNameserverParams contains all the bound params for the get nameserver operation +// typically these are obtained from a http.Request +// +// swagger:parameters getNameserver +type GetNameserverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Nameserver name + Required: true + In: path + */ + Name string + /*Parent resolver name + Required: true + In: query + */ + Resolver string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetNameserverParams() beforehand. +func (o *GetNameserverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qResolver, qhkResolver, _ := qs.GetOK("resolver") + if err := o.bindResolver(qResolver, qhkResolver, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetNameserverParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindResolver binds and validates parameter Resolver from query. +func (o *GetNameserverParams) bindResolver(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("resolver", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("resolver", "query", raw); err != nil { + return err + } + o.Resolver = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetNameserverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/nameserver/get_nameserver_responses.go b/operations/nameserver/get_nameserver_responses.go new file mode 100644 index 00000000..ef36ee41 --- /dev/null +++ b/operations/nameserver/get_nameserver_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetNameserverOKCode is the HTTP code returned for type GetNameserverOK +const GetNameserverOKCode int = 200 + +/* +GetNameserverOK Successful operation + +swagger:response getNameserverOK +*/ +type GetNameserverOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Nameserver `json:"body,omitempty"` +} + +// NewGetNameserverOK creates GetNameserverOK with default headers values +func NewGetNameserverOK() *GetNameserverOK { + + return &GetNameserverOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get nameserver o k response +func (o *GetNameserverOK) WithConfigurationVersion(configurationVersion string) *GetNameserverOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get nameserver o k response +func (o *GetNameserverOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get nameserver o k response +func (o *GetNameserverOK) WithPayload(payload *models.Nameserver) *GetNameserverOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get nameserver o k response +func (o *GetNameserverOK) SetPayload(payload *models.Nameserver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetNameserverOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetNameserverNotFoundCode is the HTTP code returned for type GetNameserverNotFound +const GetNameserverNotFoundCode int = 404 + +/* +GetNameserverNotFound The specified resource was not found + +swagger:response getNameserverNotFound +*/ +type GetNameserverNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetNameserverNotFound creates GetNameserverNotFound with default headers values +func NewGetNameserverNotFound() *GetNameserverNotFound { + + return &GetNameserverNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get nameserver not found response +func (o *GetNameserverNotFound) WithConfigurationVersion(configurationVersion string) *GetNameserverNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get nameserver not found response +func (o *GetNameserverNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get nameserver not found response +func (o *GetNameserverNotFound) WithPayload(payload *models.Error) *GetNameserverNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get nameserver not found response +func (o *GetNameserverNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetNameserverNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetNameserverDefault General Error + +swagger:response getNameserverDefault +*/ +type GetNameserverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetNameserverDefault creates GetNameserverDefault with default headers values +func NewGetNameserverDefault(code int) *GetNameserverDefault { + if code <= 0 { + code = 500 + } + + return &GetNameserverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get nameserver default response +func (o *GetNameserverDefault) WithStatusCode(code int) *GetNameserverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get nameserver default response +func (o *GetNameserverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get nameserver default response +func (o *GetNameserverDefault) WithConfigurationVersion(configurationVersion string) *GetNameserverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get nameserver default response +func (o *GetNameserverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get nameserver default response +func (o *GetNameserverDefault) WithPayload(payload *models.Error) *GetNameserverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get nameserver default response +func (o *GetNameserverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetNameserverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/nameserver/get_nameserver_urlbuilder.go b/operations/nameserver/get_nameserver_urlbuilder.go new file mode 100644 index 00000000..110d1373 --- /dev/null +++ b/operations/nameserver/get_nameserver_urlbuilder.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetNameserverURL generates an URL for the get nameserver operation +type GetNameserverURL struct { + Name string + + Resolver string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetNameserverURL) WithBasePath(bp string) *GetNameserverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetNameserverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetNameserverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/nameservers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetNameserverURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + resolverQ := o.Resolver + if resolverQ != "" { + qs.Set("resolver", resolverQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetNameserverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetNameserverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetNameserverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetNameserverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetNameserverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetNameserverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/nameserver/get_nameservers.go b/operations/nameserver/get_nameservers.go new file mode 100644 index 00000000..96879795 --- /dev/null +++ b/operations/nameserver/get_nameservers.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetNameserversHandlerFunc turns a function with the right signature into a get nameservers handler +type GetNameserversHandlerFunc func(GetNameserversParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetNameserversHandlerFunc) Handle(params GetNameserversParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetNameserversHandler interface for that can handle valid get nameservers params +type GetNameserversHandler interface { + Handle(GetNameserversParams, interface{}) middleware.Responder +} + +// NewGetNameservers creates a new http.Handler for the get nameservers operation +func NewGetNameservers(ctx *middleware.Context, handler GetNameserversHandler) *GetNameservers { + return &GetNameservers{Context: ctx, Handler: handler} +} + +/* + GetNameservers swagger:route GET /services/haproxy/configuration/nameservers Nameserver getNameservers + +# Return an array of nameservers + +Returns an array of all configured nameservers. +*/ +type GetNameservers struct { + Context *middleware.Context + Handler GetNameserversHandler +} + +func (o *GetNameservers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetNameserversParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/nameserver/get_nameservers_parameters.go b/operations/nameserver/get_nameservers_parameters.go new file mode 100644 index 00000000..b36d3ec0 --- /dev/null +++ b/operations/nameserver/get_nameservers_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetNameserversParams creates a new GetNameserversParams object +// +// There are no default values defined in the spec. +func NewGetNameserversParams() GetNameserversParams { + + return GetNameserversParams{} +} + +// GetNameserversParams contains all the bound params for the get nameservers operation +// typically these are obtained from a http.Request +// +// swagger:parameters getNameservers +type GetNameserversParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent resolver name + Required: true + In: query + */ + Resolver string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetNameserversParams() beforehand. +func (o *GetNameserversParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qResolver, qhkResolver, _ := qs.GetOK("resolver") + if err := o.bindResolver(qResolver, qhkResolver, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindResolver binds and validates parameter Resolver from query. +func (o *GetNameserversParams) bindResolver(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("resolver", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("resolver", "query", raw); err != nil { + return err + } + o.Resolver = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetNameserversParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/nameserver/get_nameservers_responses.go b/operations/nameserver/get_nameservers_responses.go new file mode 100644 index 00000000..8624ee69 --- /dev/null +++ b/operations/nameserver/get_nameservers_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetNameserversOKCode is the HTTP code returned for type GetNameserversOK +const GetNameserversOKCode int = 200 + +/* +GetNameserversOK Successful operation + +swagger:response getNameserversOK +*/ +type GetNameserversOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Nameservers `json:"body,omitempty"` +} + +// NewGetNameserversOK creates GetNameserversOK with default headers values +func NewGetNameserversOK() *GetNameserversOK { + + return &GetNameserversOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get nameservers o k response +func (o *GetNameserversOK) WithConfigurationVersion(configurationVersion string) *GetNameserversOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get nameservers o k response +func (o *GetNameserversOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get nameservers o k response +func (o *GetNameserversOK) WithPayload(payload models.Nameservers) *GetNameserversOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get nameservers o k response +func (o *GetNameserversOK) SetPayload(payload models.Nameservers) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetNameserversOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Nameservers{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetNameserversDefault General Error + +swagger:response getNameserversDefault +*/ +type GetNameserversDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetNameserversDefault creates GetNameserversDefault with default headers values +func NewGetNameserversDefault(code int) *GetNameserversDefault { + if code <= 0 { + code = 500 + } + + return &GetNameserversDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get nameservers default response +func (o *GetNameserversDefault) WithStatusCode(code int) *GetNameserversDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get nameservers default response +func (o *GetNameserversDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get nameservers default response +func (o *GetNameserversDefault) WithConfigurationVersion(configurationVersion string) *GetNameserversDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get nameservers default response +func (o *GetNameserversDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get nameservers default response +func (o *GetNameserversDefault) WithPayload(payload *models.Error) *GetNameserversDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get nameservers default response +func (o *GetNameserversDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetNameserversDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/nameserver/get_nameservers_urlbuilder.go b/operations/nameserver/get_nameservers_urlbuilder.go new file mode 100644 index 00000000..3f243048 --- /dev/null +++ b/operations/nameserver/get_nameservers_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetNameserversURL generates an URL for the get nameservers operation +type GetNameserversURL struct { + Resolver string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetNameserversURL) WithBasePath(bp string) *GetNameserversURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetNameserversURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetNameserversURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/nameservers" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + resolverQ := o.Resolver + if resolverQ != "" { + qs.Set("resolver", resolverQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetNameserversURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetNameserversURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetNameserversURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetNameserversURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetNameserversURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetNameserversURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/nameserver/replace_nameserver.go b/operations/nameserver/replace_nameserver.go new file mode 100644 index 00000000..4b4de18b --- /dev/null +++ b/operations/nameserver/replace_nameserver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceNameserverHandlerFunc turns a function with the right signature into a replace nameserver handler +type ReplaceNameserverHandlerFunc func(ReplaceNameserverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceNameserverHandlerFunc) Handle(params ReplaceNameserverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceNameserverHandler interface for that can handle valid replace nameserver params +type ReplaceNameserverHandler interface { + Handle(ReplaceNameserverParams, interface{}) middleware.Responder +} + +// NewReplaceNameserver creates a new http.Handler for the replace nameserver operation +func NewReplaceNameserver(ctx *middleware.Context, handler ReplaceNameserverHandler) *ReplaceNameserver { + return &ReplaceNameserver{Context: ctx, Handler: handler} +} + +/* + ReplaceNameserver swagger:route PUT /services/haproxy/configuration/nameservers/{name} Nameserver replaceNameserver + +# Replace a nameserver + +Replaces a nameserver configuration by it's name. +*/ +type ReplaceNameserver struct { + Context *middleware.Context + Handler ReplaceNameserverHandler +} + +func (o *ReplaceNameserver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceNameserverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/nameserver/replace_nameserver_parameters.go b/operations/nameserver/replace_nameserver_parameters.go new file mode 100644 index 00000000..e182434f --- /dev/null +++ b/operations/nameserver/replace_nameserver_parameters.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceNameserverParams creates a new ReplaceNameserverParams object +// with the default values initialized. +func NewReplaceNameserverParams() ReplaceNameserverParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceNameserverParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceNameserverParams contains all the bound params for the replace nameserver operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceNameserver +type ReplaceNameserverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Nameserver + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Nameserver name + Required: true + In: path + */ + Name string + /*Parent resolver name + Required: true + In: query + */ + Resolver string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceNameserverParams() beforehand. +func (o *ReplaceNameserverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Nameserver + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qResolver, qhkResolver, _ := qs.GetOK("resolver") + if err := o.bindResolver(qResolver, qhkResolver, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceNameserverParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceNameserverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceNameserverParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindResolver binds and validates parameter Resolver from query. +func (o *ReplaceNameserverParams) bindResolver(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("resolver", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("resolver", "query", raw); err != nil { + return err + } + o.Resolver = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceNameserverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceNameserverParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/nameserver/replace_nameserver_responses.go b/operations/nameserver/replace_nameserver_responses.go new file mode 100644 index 00000000..16236cff --- /dev/null +++ b/operations/nameserver/replace_nameserver_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceNameserverOKCode is the HTTP code returned for type ReplaceNameserverOK +const ReplaceNameserverOKCode int = 200 + +/* +ReplaceNameserverOK Nameserver replaced + +swagger:response replaceNameserverOK +*/ +type ReplaceNameserverOK struct { + + /* + In: Body + */ + Payload *models.Nameserver `json:"body,omitempty"` +} + +// NewReplaceNameserverOK creates ReplaceNameserverOK with default headers values +func NewReplaceNameserverOK() *ReplaceNameserverOK { + + return &ReplaceNameserverOK{} +} + +// WithPayload adds the payload to the replace nameserver o k response +func (o *ReplaceNameserverOK) WithPayload(payload *models.Nameserver) *ReplaceNameserverOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace nameserver o k response +func (o *ReplaceNameserverOK) SetPayload(payload *models.Nameserver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceNameserverOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceNameserverAcceptedCode is the HTTP code returned for type ReplaceNameserverAccepted +const ReplaceNameserverAcceptedCode int = 202 + +/* +ReplaceNameserverAccepted Configuration change accepted and reload requested + +swagger:response replaceNameserverAccepted +*/ +type ReplaceNameserverAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Nameserver `json:"body,omitempty"` +} + +// NewReplaceNameserverAccepted creates ReplaceNameserverAccepted with default headers values +func NewReplaceNameserverAccepted() *ReplaceNameserverAccepted { + + return &ReplaceNameserverAccepted{} +} + +// WithReloadID adds the reloadId to the replace nameserver accepted response +func (o *ReplaceNameserverAccepted) WithReloadID(reloadID string) *ReplaceNameserverAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace nameserver accepted response +func (o *ReplaceNameserverAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace nameserver accepted response +func (o *ReplaceNameserverAccepted) WithPayload(payload *models.Nameserver) *ReplaceNameserverAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace nameserver accepted response +func (o *ReplaceNameserverAccepted) SetPayload(payload *models.Nameserver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceNameserverAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceNameserverBadRequestCode is the HTTP code returned for type ReplaceNameserverBadRequest +const ReplaceNameserverBadRequestCode int = 400 + +/* +ReplaceNameserverBadRequest Bad request + +swagger:response replaceNameserverBadRequest +*/ +type ReplaceNameserverBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceNameserverBadRequest creates ReplaceNameserverBadRequest with default headers values +func NewReplaceNameserverBadRequest() *ReplaceNameserverBadRequest { + + return &ReplaceNameserverBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace nameserver bad request response +func (o *ReplaceNameserverBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceNameserverBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace nameserver bad request response +func (o *ReplaceNameserverBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace nameserver bad request response +func (o *ReplaceNameserverBadRequest) WithPayload(payload *models.Error) *ReplaceNameserverBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace nameserver bad request response +func (o *ReplaceNameserverBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceNameserverBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceNameserverNotFoundCode is the HTTP code returned for type ReplaceNameserverNotFound +const ReplaceNameserverNotFoundCode int = 404 + +/* +ReplaceNameserverNotFound The specified resource was not found + +swagger:response replaceNameserverNotFound +*/ +type ReplaceNameserverNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceNameserverNotFound creates ReplaceNameserverNotFound with default headers values +func NewReplaceNameserverNotFound() *ReplaceNameserverNotFound { + + return &ReplaceNameserverNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace nameserver not found response +func (o *ReplaceNameserverNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceNameserverNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace nameserver not found response +func (o *ReplaceNameserverNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace nameserver not found response +func (o *ReplaceNameserverNotFound) WithPayload(payload *models.Error) *ReplaceNameserverNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace nameserver not found response +func (o *ReplaceNameserverNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceNameserverNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceNameserverDefault General Error + +swagger:response replaceNameserverDefault +*/ +type ReplaceNameserverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceNameserverDefault creates ReplaceNameserverDefault with default headers values +func NewReplaceNameserverDefault(code int) *ReplaceNameserverDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceNameserverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace nameserver default response +func (o *ReplaceNameserverDefault) WithStatusCode(code int) *ReplaceNameserverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace nameserver default response +func (o *ReplaceNameserverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace nameserver default response +func (o *ReplaceNameserverDefault) WithConfigurationVersion(configurationVersion string) *ReplaceNameserverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace nameserver default response +func (o *ReplaceNameserverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace nameserver default response +func (o *ReplaceNameserverDefault) WithPayload(payload *models.Error) *ReplaceNameserverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace nameserver default response +func (o *ReplaceNameserverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceNameserverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/nameserver/replace_nameserver_urlbuilder.go b/operations/nameserver/replace_nameserver_urlbuilder.go new file mode 100644 index 00000000..00e24f90 --- /dev/null +++ b/operations/nameserver/replace_nameserver_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package nameserver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceNameserverURL generates an URL for the replace nameserver operation +type ReplaceNameserverURL struct { + Name string + + ForceReload *bool + Resolver string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceNameserverURL) WithBasePath(bp string) *ReplaceNameserverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceNameserverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceNameserverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/nameservers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceNameserverURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + resolverQ := o.Resolver + if resolverQ != "" { + qs.Set("resolver", resolverQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceNameserverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceNameserverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceNameserverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceNameserverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceNameserverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceNameserverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer/create_peer.go b/operations/peer/create_peer.go new file mode 100644 index 00000000..3d12e587 --- /dev/null +++ b/operations/peer/create_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreatePeerHandlerFunc turns a function with the right signature into a create peer handler +type CreatePeerHandlerFunc func(CreatePeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreatePeerHandlerFunc) Handle(params CreatePeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreatePeerHandler interface for that can handle valid create peer params +type CreatePeerHandler interface { + Handle(CreatePeerParams, interface{}) middleware.Responder +} + +// NewCreatePeer creates a new http.Handler for the create peer operation +func NewCreatePeer(ctx *middleware.Context, handler CreatePeerHandler) *CreatePeer { + return &CreatePeer{Context: ctx, Handler: handler} +} + +/* + CreatePeer swagger:route POST /services/haproxy/configuration/peer_section Peer createPeer + +# Add a peer + +Adds a new peer to the configuration file. +*/ +type CreatePeer struct { + Context *middleware.Context + Handler CreatePeerHandler +} + +func (o *CreatePeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreatePeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer/create_peer_parameters.go b/operations/peer/create_peer_parameters.go new file mode 100644 index 00000000..9af3c92a --- /dev/null +++ b/operations/peer/create_peer_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreatePeerParams creates a new CreatePeerParams object +// with the default values initialized. +func NewCreatePeerParams() CreatePeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreatePeerParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreatePeerParams contains all the bound params for the create peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters createPeer +type CreatePeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.PeerSection + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreatePeerParams() beforehand. +func (o *CreatePeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.PeerSection + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreatePeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreatePeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreatePeerParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreatePeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreatePeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreatePeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/peer/create_peer_responses.go b/operations/peer/create_peer_responses.go new file mode 100644 index 00000000..4c8641f9 --- /dev/null +++ b/operations/peer/create_peer_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreatePeerCreatedCode is the HTTP code returned for type CreatePeerCreated +const CreatePeerCreatedCode int = 201 + +/* +CreatePeerCreated Peer created + +swagger:response createPeerCreated +*/ +type CreatePeerCreated struct { + + /* + In: Body + */ + Payload *models.PeerSection `json:"body,omitempty"` +} + +// NewCreatePeerCreated creates CreatePeerCreated with default headers values +func NewCreatePeerCreated() *CreatePeerCreated { + + return &CreatePeerCreated{} +} + +// WithPayload adds the payload to the create peer created response +func (o *CreatePeerCreated) WithPayload(payload *models.PeerSection) *CreatePeerCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer created response +func (o *CreatePeerCreated) SetPayload(payload *models.PeerSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePeerAcceptedCode is the HTTP code returned for type CreatePeerAccepted +const CreatePeerAcceptedCode int = 202 + +/* +CreatePeerAccepted Configuration change accepted and reload requested + +swagger:response createPeerAccepted +*/ +type CreatePeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.PeerSection `json:"body,omitempty"` +} + +// NewCreatePeerAccepted creates CreatePeerAccepted with default headers values +func NewCreatePeerAccepted() *CreatePeerAccepted { + + return &CreatePeerAccepted{} +} + +// WithReloadID adds the reloadId to the create peer accepted response +func (o *CreatePeerAccepted) WithReloadID(reloadID string) *CreatePeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create peer accepted response +func (o *CreatePeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create peer accepted response +func (o *CreatePeerAccepted) WithPayload(payload *models.PeerSection) *CreatePeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer accepted response +func (o *CreatePeerAccepted) SetPayload(payload *models.PeerSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePeerBadRequestCode is the HTTP code returned for type CreatePeerBadRequest +const CreatePeerBadRequestCode int = 400 + +/* +CreatePeerBadRequest Bad request + +swagger:response createPeerBadRequest +*/ +type CreatePeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreatePeerBadRequest creates CreatePeerBadRequest with default headers values +func NewCreatePeerBadRequest() *CreatePeerBadRequest { + + return &CreatePeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create peer bad request response +func (o *CreatePeerBadRequest) WithConfigurationVersion(configurationVersion string) *CreatePeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create peer bad request response +func (o *CreatePeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create peer bad request response +func (o *CreatePeerBadRequest) WithPayload(payload *models.Error) *CreatePeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer bad request response +func (o *CreatePeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePeerConflictCode is the HTTP code returned for type CreatePeerConflict +const CreatePeerConflictCode int = 409 + +/* +CreatePeerConflict The specified resource already exists + +swagger:response createPeerConflict +*/ +type CreatePeerConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreatePeerConflict creates CreatePeerConflict with default headers values +func NewCreatePeerConflict() *CreatePeerConflict { + + return &CreatePeerConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create peer conflict response +func (o *CreatePeerConflict) WithConfigurationVersion(configurationVersion string) *CreatePeerConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create peer conflict response +func (o *CreatePeerConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create peer conflict response +func (o *CreatePeerConflict) WithPayload(payload *models.Error) *CreatePeerConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer conflict response +func (o *CreatePeerConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreatePeerDefault General Error + +swagger:response createPeerDefault +*/ +type CreatePeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreatePeerDefault creates CreatePeerDefault with default headers values +func NewCreatePeerDefault(code int) *CreatePeerDefault { + if code <= 0 { + code = 500 + } + + return &CreatePeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create peer default response +func (o *CreatePeerDefault) WithStatusCode(code int) *CreatePeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create peer default response +func (o *CreatePeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create peer default response +func (o *CreatePeerDefault) WithConfigurationVersion(configurationVersion string) *CreatePeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create peer default response +func (o *CreatePeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create peer default response +func (o *CreatePeerDefault) WithPayload(payload *models.Error) *CreatePeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer default response +func (o *CreatePeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer/create_peer_urlbuilder.go b/operations/peer/create_peer_urlbuilder.go new file mode 100644 index 00000000..89273e7d --- /dev/null +++ b/operations/peer/create_peer_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreatePeerURL generates an URL for the create peer operation +type CreatePeerURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePeerURL) WithBasePath(bp string) *CreatePeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreatePeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_section" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreatePeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreatePeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreatePeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreatePeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreatePeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreatePeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer/delete_peer.go b/operations/peer/delete_peer.go new file mode 100644 index 00000000..fdc3b5f3 --- /dev/null +++ b/operations/peer/delete_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeletePeerHandlerFunc turns a function with the right signature into a delete peer handler +type DeletePeerHandlerFunc func(DeletePeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeletePeerHandlerFunc) Handle(params DeletePeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeletePeerHandler interface for that can handle valid delete peer params +type DeletePeerHandler interface { + Handle(DeletePeerParams, interface{}) middleware.Responder +} + +// NewDeletePeer creates a new http.Handler for the delete peer operation +func NewDeletePeer(ctx *middleware.Context, handler DeletePeerHandler) *DeletePeer { + return &DeletePeer{Context: ctx, Handler: handler} +} + +/* + DeletePeer swagger:route DELETE /services/haproxy/configuration/peer_section/{name} Peer deletePeer + +# Delete a peer + +Deletes a peer from the configuration by it's name. +*/ +type DeletePeer struct { + Context *middleware.Context + Handler DeletePeerHandler +} + +func (o *DeletePeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeletePeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer/delete_peer_parameters.go b/operations/peer/delete_peer_parameters.go new file mode 100644 index 00000000..3a662ce4 --- /dev/null +++ b/operations/peer/delete_peer_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeletePeerParams creates a new DeletePeerParams object +// with the default values initialized. +func NewDeletePeerParams() DeletePeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeletePeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeletePeerParams contains all the bound params for the delete peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters deletePeer +type DeletePeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Peer name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeletePeerParams() beforehand. +func (o *DeletePeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeletePeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeletePeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeletePeerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeletePeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeletePeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/peer/delete_peer_responses.go b/operations/peer/delete_peer_responses.go new file mode 100644 index 00000000..4533e2f0 --- /dev/null +++ b/operations/peer/delete_peer_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeletePeerAcceptedCode is the HTTP code returned for type DeletePeerAccepted +const DeletePeerAcceptedCode int = 202 + +/* +DeletePeerAccepted Configuration change accepted and reload requested + +swagger:response deletePeerAccepted +*/ +type DeletePeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeletePeerAccepted creates DeletePeerAccepted with default headers values +func NewDeletePeerAccepted() *DeletePeerAccepted { + + return &DeletePeerAccepted{} +} + +// WithReloadID adds the reloadId to the delete peer accepted response +func (o *DeletePeerAccepted) WithReloadID(reloadID string) *DeletePeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete peer accepted response +func (o *DeletePeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeletePeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeletePeerNoContentCode is the HTTP code returned for type DeletePeerNoContent +const DeletePeerNoContentCode int = 204 + +/* +DeletePeerNoContent Peer deleted + +swagger:response deletePeerNoContent +*/ +type DeletePeerNoContent struct { +} + +// NewDeletePeerNoContent creates DeletePeerNoContent with default headers values +func NewDeletePeerNoContent() *DeletePeerNoContent { + + return &DeletePeerNoContent{} +} + +// WriteResponse to the client +func (o *DeletePeerNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeletePeerNotFoundCode is the HTTP code returned for type DeletePeerNotFound +const DeletePeerNotFoundCode int = 404 + +/* +DeletePeerNotFound The specified resource was not found + +swagger:response deletePeerNotFound +*/ +type DeletePeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeletePeerNotFound creates DeletePeerNotFound with default headers values +func NewDeletePeerNotFound() *DeletePeerNotFound { + + return &DeletePeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete peer not found response +func (o *DeletePeerNotFound) WithConfigurationVersion(configurationVersion string) *DeletePeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete peer not found response +func (o *DeletePeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete peer not found response +func (o *DeletePeerNotFound) WithPayload(payload *models.Error) *DeletePeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete peer not found response +func (o *DeletePeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeletePeerDefault General Error + +swagger:response deletePeerDefault +*/ +type DeletePeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeletePeerDefault creates DeletePeerDefault with default headers values +func NewDeletePeerDefault(code int) *DeletePeerDefault { + if code <= 0 { + code = 500 + } + + return &DeletePeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete peer default response +func (o *DeletePeerDefault) WithStatusCode(code int) *DeletePeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete peer default response +func (o *DeletePeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete peer default response +func (o *DeletePeerDefault) WithConfigurationVersion(configurationVersion string) *DeletePeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete peer default response +func (o *DeletePeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete peer default response +func (o *DeletePeerDefault) WithPayload(payload *models.Error) *DeletePeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete peer default response +func (o *DeletePeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer/delete_peer_urlbuilder.go b/operations/peer/delete_peer_urlbuilder.go new file mode 100644 index 00000000..61f64999 --- /dev/null +++ b/operations/peer/delete_peer_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeletePeerURL generates an URL for the delete peer operation +type DeletePeerURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeletePeerURL) WithBasePath(bp string) *DeletePeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeletePeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeletePeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_section/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeletePeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeletePeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeletePeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeletePeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeletePeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeletePeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeletePeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer/get_peer_section.go b/operations/peer/get_peer_section.go new file mode 100644 index 00000000..0fcdb191 --- /dev/null +++ b/operations/peer/get_peer_section.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPeerSectionHandlerFunc turns a function with the right signature into a get peer section handler +type GetPeerSectionHandlerFunc func(GetPeerSectionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPeerSectionHandlerFunc) Handle(params GetPeerSectionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPeerSectionHandler interface for that can handle valid get peer section params +type GetPeerSectionHandler interface { + Handle(GetPeerSectionParams, interface{}) middleware.Responder +} + +// NewGetPeerSection creates a new http.Handler for the get peer section operation +func NewGetPeerSection(ctx *middleware.Context, handler GetPeerSectionHandler) *GetPeerSection { + return &GetPeerSection{Context: ctx, Handler: handler} +} + +/* + GetPeerSection swagger:route GET /services/haproxy/configuration/peer_section/{name} Peer getPeerSection + +# Return a peer + +Returns one peer configuration by it's name. +*/ +type GetPeerSection struct { + Context *middleware.Context + Handler GetPeerSectionHandler +} + +func (o *GetPeerSection) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetPeerSectionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer/get_peer_section_parameters.go b/operations/peer/get_peer_section_parameters.go new file mode 100644 index 00000000..65e70ee4 --- /dev/null +++ b/operations/peer/get_peer_section_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetPeerSectionParams creates a new GetPeerSectionParams object +// with the default values initialized. +func NewGetPeerSectionParams() GetPeerSectionParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetPeerSectionParams{ + FullSection: &fullSectionDefault, + } +} + +// GetPeerSectionParams contains all the bound params for the get peer section operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPeerSection +type GetPeerSectionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Peer name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPeerSectionParams() beforehand. +func (o *GetPeerSectionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetPeerSectionParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetPeerSectionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetPeerSectionParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetPeerSectionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/peer/get_peer_section_responses.go b/operations/peer/get_peer_section_responses.go new file mode 100644 index 00000000..13e60338 --- /dev/null +++ b/operations/peer/get_peer_section_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetPeerSectionOKCode is the HTTP code returned for type GetPeerSectionOK +const GetPeerSectionOKCode int = 200 + +/* +GetPeerSectionOK Successful operation + +swagger:response getPeerSectionOK +*/ +type GetPeerSectionOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.PeerSection `json:"body,omitempty"` +} + +// NewGetPeerSectionOK creates GetPeerSectionOK with default headers values +func NewGetPeerSectionOK() *GetPeerSectionOK { + + return &GetPeerSectionOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get peer section o k response +func (o *GetPeerSectionOK) WithConfigurationVersion(configurationVersion string) *GetPeerSectionOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer section o k response +func (o *GetPeerSectionOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer section o k response +func (o *GetPeerSectionOK) WithPayload(payload *models.PeerSection) *GetPeerSectionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer section o k response +func (o *GetPeerSectionOK) SetPayload(payload *models.PeerSection) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerSectionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPeerSectionNotFoundCode is the HTTP code returned for type GetPeerSectionNotFound +const GetPeerSectionNotFoundCode int = 404 + +/* +GetPeerSectionNotFound The specified resource was not found + +swagger:response getPeerSectionNotFound +*/ +type GetPeerSectionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetPeerSectionNotFound creates GetPeerSectionNotFound with default headers values +func NewGetPeerSectionNotFound() *GetPeerSectionNotFound { + + return &GetPeerSectionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get peer section not found response +func (o *GetPeerSectionNotFound) WithConfigurationVersion(configurationVersion string) *GetPeerSectionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer section not found response +func (o *GetPeerSectionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer section not found response +func (o *GetPeerSectionNotFound) WithPayload(payload *models.Error) *GetPeerSectionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer section not found response +func (o *GetPeerSectionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerSectionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetPeerSectionDefault General Error + +swagger:response getPeerSectionDefault +*/ +type GetPeerSectionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetPeerSectionDefault creates GetPeerSectionDefault with default headers values +func NewGetPeerSectionDefault(code int) *GetPeerSectionDefault { + if code <= 0 { + code = 500 + } + + return &GetPeerSectionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get peer section default response +func (o *GetPeerSectionDefault) WithStatusCode(code int) *GetPeerSectionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get peer section default response +func (o *GetPeerSectionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get peer section default response +func (o *GetPeerSectionDefault) WithConfigurationVersion(configurationVersion string) *GetPeerSectionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer section default response +func (o *GetPeerSectionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer section default response +func (o *GetPeerSectionDefault) WithPayload(payload *models.Error) *GetPeerSectionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer section default response +func (o *GetPeerSectionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerSectionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer/get_peer_section_urlbuilder.go b/operations/peer/get_peer_section_urlbuilder.go new file mode 100644 index 00000000..71148d32 --- /dev/null +++ b/operations/peer/get_peer_section_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetPeerSectionURL generates an URL for the get peer section operation +type GetPeerSectionURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerSectionURL) WithBasePath(bp string) *GetPeerSectionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerSectionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPeerSectionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_section/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetPeerSectionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPeerSectionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPeerSectionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPeerSectionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPeerSectionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPeerSectionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPeerSectionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer/get_peer_sections.go b/operations/peer/get_peer_sections.go new file mode 100644 index 00000000..e7345051 --- /dev/null +++ b/operations/peer/get_peer_sections.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPeerSectionsHandlerFunc turns a function with the right signature into a get peer sections handler +type GetPeerSectionsHandlerFunc func(GetPeerSectionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPeerSectionsHandlerFunc) Handle(params GetPeerSectionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPeerSectionsHandler interface for that can handle valid get peer sections params +type GetPeerSectionsHandler interface { + Handle(GetPeerSectionsParams, interface{}) middleware.Responder +} + +// NewGetPeerSections creates a new http.Handler for the get peer sections operation +func NewGetPeerSections(ctx *middleware.Context, handler GetPeerSectionsHandler) *GetPeerSections { + return &GetPeerSections{Context: ctx, Handler: handler} +} + +/* + GetPeerSections swagger:route GET /services/haproxy/configuration/peer_section Peer getPeerSections + +Return an array of peer_section + +Returns an array of all configured peer_section. +*/ +type GetPeerSections struct { + Context *middleware.Context + Handler GetPeerSectionsHandler +} + +func (o *GetPeerSections) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetPeerSectionsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer/get_peer_sections_parameters.go b/operations/peer/get_peer_sections_parameters.go new file mode 100644 index 00000000..2ba328de --- /dev/null +++ b/operations/peer/get_peer_sections_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetPeerSectionsParams creates a new GetPeerSectionsParams object +// with the default values initialized. +func NewGetPeerSectionsParams() GetPeerSectionsParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetPeerSectionsParams{ + FullSection: &fullSectionDefault, + } +} + +// GetPeerSectionsParams contains all the bound params for the get peer sections operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPeerSections +type GetPeerSectionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPeerSectionsParams() beforehand. +func (o *GetPeerSectionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetPeerSectionsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetPeerSectionsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetPeerSectionsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/peer/get_peer_sections_responses.go b/operations/peer/get_peer_sections_responses.go new file mode 100644 index 00000000..6338d761 --- /dev/null +++ b/operations/peer/get_peer_sections_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetPeerSectionsOKCode is the HTTP code returned for type GetPeerSectionsOK +const GetPeerSectionsOKCode int = 200 + +/* +GetPeerSectionsOK Successful operation + +swagger:response getPeerSectionsOK +*/ +type GetPeerSectionsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.PeerSections `json:"body,omitempty"` +} + +// NewGetPeerSectionsOK creates GetPeerSectionsOK with default headers values +func NewGetPeerSectionsOK() *GetPeerSectionsOK { + + return &GetPeerSectionsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get peer sections o k response +func (o *GetPeerSectionsOK) WithConfigurationVersion(configurationVersion string) *GetPeerSectionsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer sections o k response +func (o *GetPeerSectionsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer sections o k response +func (o *GetPeerSectionsOK) WithPayload(payload models.PeerSections) *GetPeerSectionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer sections o k response +func (o *GetPeerSectionsOK) SetPayload(payload models.PeerSections) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerSectionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.PeerSections{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetPeerSectionsDefault General Error + +swagger:response getPeerSectionsDefault +*/ +type GetPeerSectionsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetPeerSectionsDefault creates GetPeerSectionsDefault with default headers values +func NewGetPeerSectionsDefault(code int) *GetPeerSectionsDefault { + if code <= 0 { + code = 500 + } + + return &GetPeerSectionsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get peer sections default response +func (o *GetPeerSectionsDefault) WithStatusCode(code int) *GetPeerSectionsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get peer sections default response +func (o *GetPeerSectionsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get peer sections default response +func (o *GetPeerSectionsDefault) WithConfigurationVersion(configurationVersion string) *GetPeerSectionsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer sections default response +func (o *GetPeerSectionsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer sections default response +func (o *GetPeerSectionsDefault) WithPayload(payload *models.Error) *GetPeerSectionsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer sections default response +func (o *GetPeerSectionsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerSectionsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer/get_peer_sections_urlbuilder.go b/operations/peer/get_peer_sections_urlbuilder.go new file mode 100644 index 00000000..13facf8f --- /dev/null +++ b/operations/peer/get_peer_sections_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetPeerSectionsURL generates an URL for the get peer sections operation +type GetPeerSectionsURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerSectionsURL) WithBasePath(bp string) *GetPeerSectionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerSectionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPeerSectionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_section" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPeerSectionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPeerSectionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPeerSectionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPeerSectionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPeerSectionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPeerSectionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer_entry/create_peer_entry.go b/operations/peer_entry/create_peer_entry.go new file mode 100644 index 00000000..b6ba37b2 --- /dev/null +++ b/operations/peer_entry/create_peer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreatePeerEntryHandlerFunc turns a function with the right signature into a create peer entry handler +type CreatePeerEntryHandlerFunc func(CreatePeerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreatePeerEntryHandlerFunc) Handle(params CreatePeerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreatePeerEntryHandler interface for that can handle valid create peer entry params +type CreatePeerEntryHandler interface { + Handle(CreatePeerEntryParams, interface{}) middleware.Responder +} + +// NewCreatePeerEntry creates a new http.Handler for the create peer entry operation +func NewCreatePeerEntry(ctx *middleware.Context, handler CreatePeerEntryHandler) *CreatePeerEntry { + return &CreatePeerEntry{Context: ctx, Handler: handler} +} + +/* + CreatePeerEntry swagger:route POST /services/haproxy/configuration/peer_entries PeerEntry createPeerEntry + +Add a new peer_entry + +Adds a new peer entry in the specified peer section in the configuration file. +*/ +type CreatePeerEntry struct { + Context *middleware.Context + Handler CreatePeerEntryHandler +} + +func (o *CreatePeerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreatePeerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer_entry/create_peer_entry_parameters.go b/operations/peer_entry/create_peer_entry_parameters.go new file mode 100644 index 00000000..bc3fae24 --- /dev/null +++ b/operations/peer_entry/create_peer_entry_parameters.go @@ -0,0 +1,229 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreatePeerEntryParams creates a new CreatePeerEntryParams object +// with the default values initialized. +func NewCreatePeerEntryParams() CreatePeerEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreatePeerEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreatePeerEntryParams contains all the bound params for the create peer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters createPeerEntry +type CreatePeerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.PeerEntry + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent peer section name + Required: true + In: query + */ + PeerSection string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreatePeerEntryParams() beforehand. +func (o *CreatePeerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.PeerEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qPeerSection, qhkPeerSection, _ := qs.GetOK("peer_section") + if err := o.bindPeerSection(qPeerSection, qhkPeerSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreatePeerEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreatePeerEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindPeerSection binds and validates parameter PeerSection from query. +func (o *CreatePeerEntryParams) bindPeerSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("peer_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("peer_section", "query", raw); err != nil { + return err + } + o.PeerSection = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreatePeerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreatePeerEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/peer_entry/create_peer_entry_responses.go b/operations/peer_entry/create_peer_entry_responses.go new file mode 100644 index 00000000..cdf33d77 --- /dev/null +++ b/operations/peer_entry/create_peer_entry_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreatePeerEntryCreatedCode is the HTTP code returned for type CreatePeerEntryCreated +const CreatePeerEntryCreatedCode int = 201 + +/* +CreatePeerEntryCreated PeerEntry created + +swagger:response createPeerEntryCreated +*/ +type CreatePeerEntryCreated struct { + + /* + In: Body + */ + Payload *models.PeerEntry `json:"body,omitempty"` +} + +// NewCreatePeerEntryCreated creates CreatePeerEntryCreated with default headers values +func NewCreatePeerEntryCreated() *CreatePeerEntryCreated { + + return &CreatePeerEntryCreated{} +} + +// WithPayload adds the payload to the create peer entry created response +func (o *CreatePeerEntryCreated) WithPayload(payload *models.PeerEntry) *CreatePeerEntryCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer entry created response +func (o *CreatePeerEntryCreated) SetPayload(payload *models.PeerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePeerEntryAcceptedCode is the HTTP code returned for type CreatePeerEntryAccepted +const CreatePeerEntryAcceptedCode int = 202 + +/* +CreatePeerEntryAccepted Configuration change accepted and reload requested + +swagger:response createPeerEntryAccepted +*/ +type CreatePeerEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.PeerEntry `json:"body,omitempty"` +} + +// NewCreatePeerEntryAccepted creates CreatePeerEntryAccepted with default headers values +func NewCreatePeerEntryAccepted() *CreatePeerEntryAccepted { + + return &CreatePeerEntryAccepted{} +} + +// WithReloadID adds the reloadId to the create peer entry accepted response +func (o *CreatePeerEntryAccepted) WithReloadID(reloadID string) *CreatePeerEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create peer entry accepted response +func (o *CreatePeerEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create peer entry accepted response +func (o *CreatePeerEntryAccepted) WithPayload(payload *models.PeerEntry) *CreatePeerEntryAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer entry accepted response +func (o *CreatePeerEntryAccepted) SetPayload(payload *models.PeerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePeerEntryBadRequestCode is the HTTP code returned for type CreatePeerEntryBadRequest +const CreatePeerEntryBadRequestCode int = 400 + +/* +CreatePeerEntryBadRequest Bad request + +swagger:response createPeerEntryBadRequest +*/ +type CreatePeerEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreatePeerEntryBadRequest creates CreatePeerEntryBadRequest with default headers values +func NewCreatePeerEntryBadRequest() *CreatePeerEntryBadRequest { + + return &CreatePeerEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create peer entry bad request response +func (o *CreatePeerEntryBadRequest) WithConfigurationVersion(configurationVersion string) *CreatePeerEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create peer entry bad request response +func (o *CreatePeerEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create peer entry bad request response +func (o *CreatePeerEntryBadRequest) WithPayload(payload *models.Error) *CreatePeerEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer entry bad request response +func (o *CreatePeerEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreatePeerEntryConflictCode is the HTTP code returned for type CreatePeerEntryConflict +const CreatePeerEntryConflictCode int = 409 + +/* +CreatePeerEntryConflict The specified resource already exists + +swagger:response createPeerEntryConflict +*/ +type CreatePeerEntryConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreatePeerEntryConflict creates CreatePeerEntryConflict with default headers values +func NewCreatePeerEntryConflict() *CreatePeerEntryConflict { + + return &CreatePeerEntryConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create peer entry conflict response +func (o *CreatePeerEntryConflict) WithConfigurationVersion(configurationVersion string) *CreatePeerEntryConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create peer entry conflict response +func (o *CreatePeerEntryConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create peer entry conflict response +func (o *CreatePeerEntryConflict) WithPayload(payload *models.Error) *CreatePeerEntryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer entry conflict response +func (o *CreatePeerEntryConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerEntryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreatePeerEntryDefault General Error + +swagger:response createPeerEntryDefault +*/ +type CreatePeerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreatePeerEntryDefault creates CreatePeerEntryDefault with default headers values +func NewCreatePeerEntryDefault(code int) *CreatePeerEntryDefault { + if code <= 0 { + code = 500 + } + + return &CreatePeerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create peer entry default response +func (o *CreatePeerEntryDefault) WithStatusCode(code int) *CreatePeerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create peer entry default response +func (o *CreatePeerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create peer entry default response +func (o *CreatePeerEntryDefault) WithConfigurationVersion(configurationVersion string) *CreatePeerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create peer entry default response +func (o *CreatePeerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create peer entry default response +func (o *CreatePeerEntryDefault) WithPayload(payload *models.Error) *CreatePeerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create peer entry default response +func (o *CreatePeerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreatePeerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer_entry/create_peer_entry_urlbuilder.go b/operations/peer_entry/create_peer_entry_urlbuilder.go new file mode 100644 index 00000000..15feff03 --- /dev/null +++ b/operations/peer_entry/create_peer_entry_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreatePeerEntryURL generates an URL for the create peer entry operation +type CreatePeerEntryURL struct { + ForceReload *bool + PeerSection string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePeerEntryURL) WithBasePath(bp string) *CreatePeerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreatePeerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreatePeerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + peerSectionQ := o.PeerSection + if peerSectionQ != "" { + qs.Set("peer_section", peerSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreatePeerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreatePeerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreatePeerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreatePeerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreatePeerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreatePeerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer_entry/delete_peer_entry.go b/operations/peer_entry/delete_peer_entry.go new file mode 100644 index 00000000..63b67c60 --- /dev/null +++ b/operations/peer_entry/delete_peer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeletePeerEntryHandlerFunc turns a function with the right signature into a delete peer entry handler +type DeletePeerEntryHandlerFunc func(DeletePeerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeletePeerEntryHandlerFunc) Handle(params DeletePeerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeletePeerEntryHandler interface for that can handle valid delete peer entry params +type DeletePeerEntryHandler interface { + Handle(DeletePeerEntryParams, interface{}) middleware.Responder +} + +// NewDeletePeerEntry creates a new http.Handler for the delete peer entry operation +func NewDeletePeerEntry(ctx *middleware.Context, handler DeletePeerEntryHandler) *DeletePeerEntry { + return &DeletePeerEntry{Context: ctx, Handler: handler} +} + +/* + DeletePeerEntry swagger:route DELETE /services/haproxy/configuration/peer_entries/{name} PeerEntry deletePeerEntry + +Delete a peer_entry + +Deletes a peer entry configuration by it's name in the specified peer section. +*/ +type DeletePeerEntry struct { + Context *middleware.Context + Handler DeletePeerEntryHandler +} + +func (o *DeletePeerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeletePeerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer_entry/delete_peer_entry_parameters.go b/operations/peer_entry/delete_peer_entry_parameters.go new file mode 100644 index 00000000..b74618a5 --- /dev/null +++ b/operations/peer_entry/delete_peer_entry_parameters.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeletePeerEntryParams creates a new DeletePeerEntryParams object +// with the default values initialized. +func NewDeletePeerEntryParams() DeletePeerEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeletePeerEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeletePeerEntryParams contains all the bound params for the delete peer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters deletePeerEntry +type DeletePeerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*PeerEntry name + Required: true + In: path + */ + Name string + /*Parent peers name + Required: true + In: query + */ + PeerSection string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeletePeerEntryParams() beforehand. +func (o *DeletePeerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qPeerSection, qhkPeerSection, _ := qs.GetOK("peer_section") + if err := o.bindPeerSection(qPeerSection, qhkPeerSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeletePeerEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeletePeerEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeletePeerEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindPeerSection binds and validates parameter PeerSection from query. +func (o *DeletePeerEntryParams) bindPeerSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("peer_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("peer_section", "query", raw); err != nil { + return err + } + o.PeerSection = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeletePeerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeletePeerEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/peer_entry/delete_peer_entry_responses.go b/operations/peer_entry/delete_peer_entry_responses.go new file mode 100644 index 00000000..4711ffed --- /dev/null +++ b/operations/peer_entry/delete_peer_entry_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeletePeerEntryAcceptedCode is the HTTP code returned for type DeletePeerEntryAccepted +const DeletePeerEntryAcceptedCode int = 202 + +/* +DeletePeerEntryAccepted Configuration change accepted and reload requested + +swagger:response deletePeerEntryAccepted +*/ +type DeletePeerEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeletePeerEntryAccepted creates DeletePeerEntryAccepted with default headers values +func NewDeletePeerEntryAccepted() *DeletePeerEntryAccepted { + + return &DeletePeerEntryAccepted{} +} + +// WithReloadID adds the reloadId to the delete peer entry accepted response +func (o *DeletePeerEntryAccepted) WithReloadID(reloadID string) *DeletePeerEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete peer entry accepted response +func (o *DeletePeerEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeletePeerEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeletePeerEntryNoContentCode is the HTTP code returned for type DeletePeerEntryNoContent +const DeletePeerEntryNoContentCode int = 204 + +/* +DeletePeerEntryNoContent PeerEntry deleted + +swagger:response deletePeerEntryNoContent +*/ +type DeletePeerEntryNoContent struct { +} + +// NewDeletePeerEntryNoContent creates DeletePeerEntryNoContent with default headers values +func NewDeletePeerEntryNoContent() *DeletePeerEntryNoContent { + + return &DeletePeerEntryNoContent{} +} + +// WriteResponse to the client +func (o *DeletePeerEntryNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeletePeerEntryNotFoundCode is the HTTP code returned for type DeletePeerEntryNotFound +const DeletePeerEntryNotFoundCode int = 404 + +/* +DeletePeerEntryNotFound The specified resource was not found + +swagger:response deletePeerEntryNotFound +*/ +type DeletePeerEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeletePeerEntryNotFound creates DeletePeerEntryNotFound with default headers values +func NewDeletePeerEntryNotFound() *DeletePeerEntryNotFound { + + return &DeletePeerEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete peer entry not found response +func (o *DeletePeerEntryNotFound) WithConfigurationVersion(configurationVersion string) *DeletePeerEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete peer entry not found response +func (o *DeletePeerEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete peer entry not found response +func (o *DeletePeerEntryNotFound) WithPayload(payload *models.Error) *DeletePeerEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete peer entry not found response +func (o *DeletePeerEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePeerEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeletePeerEntryDefault General Error + +swagger:response deletePeerEntryDefault +*/ +type DeletePeerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeletePeerEntryDefault creates DeletePeerEntryDefault with default headers values +func NewDeletePeerEntryDefault(code int) *DeletePeerEntryDefault { + if code <= 0 { + code = 500 + } + + return &DeletePeerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete peer entry default response +func (o *DeletePeerEntryDefault) WithStatusCode(code int) *DeletePeerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete peer entry default response +func (o *DeletePeerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete peer entry default response +func (o *DeletePeerEntryDefault) WithConfigurationVersion(configurationVersion string) *DeletePeerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete peer entry default response +func (o *DeletePeerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete peer entry default response +func (o *DeletePeerEntryDefault) WithPayload(payload *models.Error) *DeletePeerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete peer entry default response +func (o *DeletePeerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeletePeerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer_entry/delete_peer_entry_urlbuilder.go b/operations/peer_entry/delete_peer_entry_urlbuilder.go new file mode 100644 index 00000000..5f7f0bbc --- /dev/null +++ b/operations/peer_entry/delete_peer_entry_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeletePeerEntryURL generates an URL for the delete peer entry operation +type DeletePeerEntryURL struct { + Name string + + ForceReload *bool + PeerSection string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeletePeerEntryURL) WithBasePath(bp string) *DeletePeerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeletePeerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeletePeerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_entries/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeletePeerEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + peerSectionQ := o.PeerSection + if peerSectionQ != "" { + qs.Set("peer_section", peerSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeletePeerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeletePeerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeletePeerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeletePeerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeletePeerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeletePeerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer_entry/get_peer_entries.go b/operations/peer_entry/get_peer_entries.go new file mode 100644 index 00000000..320689cb --- /dev/null +++ b/operations/peer_entry/get_peer_entries.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPeerEntriesHandlerFunc turns a function with the right signature into a get peer entries handler +type GetPeerEntriesHandlerFunc func(GetPeerEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPeerEntriesHandlerFunc) Handle(params GetPeerEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPeerEntriesHandler interface for that can handle valid get peer entries params +type GetPeerEntriesHandler interface { + Handle(GetPeerEntriesParams, interface{}) middleware.Responder +} + +// NewGetPeerEntries creates a new http.Handler for the get peer entries operation +func NewGetPeerEntries(ctx *middleware.Context, handler GetPeerEntriesHandler) *GetPeerEntries { + return &GetPeerEntries{Context: ctx, Handler: handler} +} + +/* + GetPeerEntries swagger:route GET /services/haproxy/configuration/peer_entries PeerEntry getPeerEntries + +Return an array of peer_entries + +Returns an array of all peer_entries that are configured in specified peer section. +*/ +type GetPeerEntries struct { + Context *middleware.Context + Handler GetPeerEntriesHandler +} + +func (o *GetPeerEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetPeerEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer_entry/get_peer_entries_parameters.go b/operations/peer_entry/get_peer_entries_parameters.go new file mode 100644 index 00000000..5789fa60 --- /dev/null +++ b/operations/peer_entry/get_peer_entries_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetPeerEntriesParams creates a new GetPeerEntriesParams object +// +// There are no default values defined in the spec. +func NewGetPeerEntriesParams() GetPeerEntriesParams { + + return GetPeerEntriesParams{} +} + +// GetPeerEntriesParams contains all the bound params for the get peer entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPeerEntries +type GetPeerEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent peer section name + Required: true + In: query + */ + PeerSection string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPeerEntriesParams() beforehand. +func (o *GetPeerEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qPeerSection, qhkPeerSection, _ := qs.GetOK("peer_section") + if err := o.bindPeerSection(qPeerSection, qhkPeerSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindPeerSection binds and validates parameter PeerSection from query. +func (o *GetPeerEntriesParams) bindPeerSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("peer_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("peer_section", "query", raw); err != nil { + return err + } + o.PeerSection = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetPeerEntriesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/peer_entry/get_peer_entries_responses.go b/operations/peer_entry/get_peer_entries_responses.go new file mode 100644 index 00000000..abae23aa --- /dev/null +++ b/operations/peer_entry/get_peer_entries_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetPeerEntriesOKCode is the HTTP code returned for type GetPeerEntriesOK +const GetPeerEntriesOKCode int = 200 + +/* +GetPeerEntriesOK Successful operation + +swagger:response getPeerEntriesOK +*/ +type GetPeerEntriesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.PeerEntries `json:"body,omitempty"` +} + +// NewGetPeerEntriesOK creates GetPeerEntriesOK with default headers values +func NewGetPeerEntriesOK() *GetPeerEntriesOK { + + return &GetPeerEntriesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get peer entries o k response +func (o *GetPeerEntriesOK) WithConfigurationVersion(configurationVersion string) *GetPeerEntriesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer entries o k response +func (o *GetPeerEntriesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer entries o k response +func (o *GetPeerEntriesOK) WithPayload(payload models.PeerEntries) *GetPeerEntriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer entries o k response +func (o *GetPeerEntriesOK) SetPayload(payload models.PeerEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerEntriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.PeerEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetPeerEntriesDefault General Error + +swagger:response getPeerEntriesDefault +*/ +type GetPeerEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetPeerEntriesDefault creates GetPeerEntriesDefault with default headers values +func NewGetPeerEntriesDefault(code int) *GetPeerEntriesDefault { + if code <= 0 { + code = 500 + } + + return &GetPeerEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get peer entries default response +func (o *GetPeerEntriesDefault) WithStatusCode(code int) *GetPeerEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get peer entries default response +func (o *GetPeerEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get peer entries default response +func (o *GetPeerEntriesDefault) WithConfigurationVersion(configurationVersion string) *GetPeerEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer entries default response +func (o *GetPeerEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer entries default response +func (o *GetPeerEntriesDefault) WithPayload(payload *models.Error) *GetPeerEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer entries default response +func (o *GetPeerEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer_entry/get_peer_entries_urlbuilder.go b/operations/peer_entry/get_peer_entries_urlbuilder.go new file mode 100644 index 00000000..301a0adb --- /dev/null +++ b/operations/peer_entry/get_peer_entries_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetPeerEntriesURL generates an URL for the get peer entries operation +type GetPeerEntriesURL struct { + PeerSection string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerEntriesURL) WithBasePath(bp string) *GetPeerEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPeerEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + peerSectionQ := o.PeerSection + if peerSectionQ != "" { + qs.Set("peer_section", peerSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPeerEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPeerEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPeerEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPeerEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPeerEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPeerEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer_entry/get_peer_entry.go b/operations/peer_entry/get_peer_entry.go new file mode 100644 index 00000000..8cdc97ee --- /dev/null +++ b/operations/peer_entry/get_peer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetPeerEntryHandlerFunc turns a function with the right signature into a get peer entry handler +type GetPeerEntryHandlerFunc func(GetPeerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetPeerEntryHandlerFunc) Handle(params GetPeerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetPeerEntryHandler interface for that can handle valid get peer entry params +type GetPeerEntryHandler interface { + Handle(GetPeerEntryParams, interface{}) middleware.Responder +} + +// NewGetPeerEntry creates a new http.Handler for the get peer entry operation +func NewGetPeerEntry(ctx *middleware.Context, handler GetPeerEntryHandler) *GetPeerEntry { + return &GetPeerEntry{Context: ctx, Handler: handler} +} + +/* + GetPeerEntry swagger:route GET /services/haproxy/configuration/peer_entries/{name} PeerEntry getPeerEntry + +Return one peer_entry + +Returns one peer_entry configuration by it's name in the specified peer section. +*/ +type GetPeerEntry struct { + Context *middleware.Context + Handler GetPeerEntryHandler +} + +func (o *GetPeerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetPeerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer_entry/get_peer_entry_parameters.go b/operations/peer_entry/get_peer_entry_parameters.go new file mode 100644 index 00000000..142a4a67 --- /dev/null +++ b/operations/peer_entry/get_peer_entry_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetPeerEntryParams creates a new GetPeerEntryParams object +// +// There are no default values defined in the spec. +func NewGetPeerEntryParams() GetPeerEntryParams { + + return GetPeerEntryParams{} +} + +// GetPeerEntryParams contains all the bound params for the get peer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPeerEntry +type GetPeerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*PeerEntry name + Required: true + In: path + */ + Name string + /*Parent peers name + Required: true + In: query + */ + PeerSection string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetPeerEntryParams() beforehand. +func (o *GetPeerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qPeerSection, qhkPeerSection, _ := qs.GetOK("peer_section") + if err := o.bindPeerSection(qPeerSection, qhkPeerSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetPeerEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindPeerSection binds and validates parameter PeerSection from query. +func (o *GetPeerEntryParams) bindPeerSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("peer_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("peer_section", "query", raw); err != nil { + return err + } + o.PeerSection = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetPeerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/peer_entry/get_peer_entry_responses.go b/operations/peer_entry/get_peer_entry_responses.go new file mode 100644 index 00000000..1f68dd2f --- /dev/null +++ b/operations/peer_entry/get_peer_entry_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetPeerEntryOKCode is the HTTP code returned for type GetPeerEntryOK +const GetPeerEntryOKCode int = 200 + +/* +GetPeerEntryOK Successful operation + +swagger:response getPeerEntryOK +*/ +type GetPeerEntryOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.PeerEntry `json:"body,omitempty"` +} + +// NewGetPeerEntryOK creates GetPeerEntryOK with default headers values +func NewGetPeerEntryOK() *GetPeerEntryOK { + + return &GetPeerEntryOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get peer entry o k response +func (o *GetPeerEntryOK) WithConfigurationVersion(configurationVersion string) *GetPeerEntryOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer entry o k response +func (o *GetPeerEntryOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer entry o k response +func (o *GetPeerEntryOK) WithPayload(payload *models.PeerEntry) *GetPeerEntryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer entry o k response +func (o *GetPeerEntryOK) SetPayload(payload *models.PeerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerEntryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetPeerEntryNotFoundCode is the HTTP code returned for type GetPeerEntryNotFound +const GetPeerEntryNotFoundCode int = 404 + +/* +GetPeerEntryNotFound The specified resource already exists + +swagger:response getPeerEntryNotFound +*/ +type GetPeerEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetPeerEntryNotFound creates GetPeerEntryNotFound with default headers values +func NewGetPeerEntryNotFound() *GetPeerEntryNotFound { + + return &GetPeerEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get peer entry not found response +func (o *GetPeerEntryNotFound) WithConfigurationVersion(configurationVersion string) *GetPeerEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer entry not found response +func (o *GetPeerEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer entry not found response +func (o *GetPeerEntryNotFound) WithPayload(payload *models.Error) *GetPeerEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer entry not found response +func (o *GetPeerEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetPeerEntryDefault General Error + +swagger:response getPeerEntryDefault +*/ +type GetPeerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetPeerEntryDefault creates GetPeerEntryDefault with default headers values +func NewGetPeerEntryDefault(code int) *GetPeerEntryDefault { + if code <= 0 { + code = 500 + } + + return &GetPeerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get peer entry default response +func (o *GetPeerEntryDefault) WithStatusCode(code int) *GetPeerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get peer entry default response +func (o *GetPeerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get peer entry default response +func (o *GetPeerEntryDefault) WithConfigurationVersion(configurationVersion string) *GetPeerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get peer entry default response +func (o *GetPeerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get peer entry default response +func (o *GetPeerEntryDefault) WithPayload(payload *models.Error) *GetPeerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get peer entry default response +func (o *GetPeerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetPeerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer_entry/get_peer_entry_urlbuilder.go b/operations/peer_entry/get_peer_entry_urlbuilder.go new file mode 100644 index 00000000..0f1f0ab0 --- /dev/null +++ b/operations/peer_entry/get_peer_entry_urlbuilder.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetPeerEntryURL generates an URL for the get peer entry operation +type GetPeerEntryURL struct { + Name string + + PeerSection string + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerEntryURL) WithBasePath(bp string) *GetPeerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetPeerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetPeerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_entries/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetPeerEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + peerSectionQ := o.PeerSection + if peerSectionQ != "" { + qs.Set("peer_section", peerSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetPeerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetPeerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetPeerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetPeerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetPeerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetPeerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/peer_entry/replace_peer_entry.go b/operations/peer_entry/replace_peer_entry.go new file mode 100644 index 00000000..7eb4fb68 --- /dev/null +++ b/operations/peer_entry/replace_peer_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplacePeerEntryHandlerFunc turns a function with the right signature into a replace peer entry handler +type ReplacePeerEntryHandlerFunc func(ReplacePeerEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplacePeerEntryHandlerFunc) Handle(params ReplacePeerEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplacePeerEntryHandler interface for that can handle valid replace peer entry params +type ReplacePeerEntryHandler interface { + Handle(ReplacePeerEntryParams, interface{}) middleware.Responder +} + +// NewReplacePeerEntry creates a new http.Handler for the replace peer entry operation +func NewReplacePeerEntry(ctx *middleware.Context, handler ReplacePeerEntryHandler) *ReplacePeerEntry { + return &ReplacePeerEntry{Context: ctx, Handler: handler} +} + +/* + ReplacePeerEntry swagger:route PUT /services/haproxy/configuration/peer_entries/{name} PeerEntry replacePeerEntry + +Replace a peer_entry + +Replaces a peer entry configuration by it's name in the specified peer section. +*/ +type ReplacePeerEntry struct { + Context *middleware.Context + Handler ReplacePeerEntryHandler +} + +func (o *ReplacePeerEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplacePeerEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/peer_entry/replace_peer_entry_parameters.go b/operations/peer_entry/replace_peer_entry_parameters.go new file mode 100644 index 00000000..401d8a98 --- /dev/null +++ b/operations/peer_entry/replace_peer_entry_parameters.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplacePeerEntryParams creates a new ReplacePeerEntryParams object +// with the default values initialized. +func NewReplacePeerEntryParams() ReplacePeerEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplacePeerEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplacePeerEntryParams contains all the bound params for the replace peer entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters replacePeerEntry +type ReplacePeerEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.PeerEntry + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*PeerEntry name + Required: true + In: path + */ + Name string + /*Parent peers name + Required: true + In: query + */ + PeerSection string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplacePeerEntryParams() beforehand. +func (o *ReplacePeerEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.PeerEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qPeerSection, qhkPeerSection, _ := qs.GetOK("peer_section") + if err := o.bindPeerSection(qPeerSection, qhkPeerSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplacePeerEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplacePeerEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplacePeerEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindPeerSection binds and validates parameter PeerSection from query. +func (o *ReplacePeerEntryParams) bindPeerSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("peer_section", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("peer_section", "query", raw); err != nil { + return err + } + o.PeerSection = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplacePeerEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplacePeerEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/peer_entry/replace_peer_entry_responses.go b/operations/peer_entry/replace_peer_entry_responses.go new file mode 100644 index 00000000..849eba1d --- /dev/null +++ b/operations/peer_entry/replace_peer_entry_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplacePeerEntryOKCode is the HTTP code returned for type ReplacePeerEntryOK +const ReplacePeerEntryOKCode int = 200 + +/* +ReplacePeerEntryOK PeerEntry replaced + +swagger:response replacePeerEntryOK +*/ +type ReplacePeerEntryOK struct { + + /* + In: Body + */ + Payload *models.PeerEntry `json:"body,omitempty"` +} + +// NewReplacePeerEntryOK creates ReplacePeerEntryOK with default headers values +func NewReplacePeerEntryOK() *ReplacePeerEntryOK { + + return &ReplacePeerEntryOK{} +} + +// WithPayload adds the payload to the replace peer entry o k response +func (o *ReplacePeerEntryOK) WithPayload(payload *models.PeerEntry) *ReplacePeerEntryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace peer entry o k response +func (o *ReplacePeerEntryOK) SetPayload(payload *models.PeerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplacePeerEntryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplacePeerEntryAcceptedCode is the HTTP code returned for type ReplacePeerEntryAccepted +const ReplacePeerEntryAcceptedCode int = 202 + +/* +ReplacePeerEntryAccepted Configuration change accepted and reload requested + +swagger:response replacePeerEntryAccepted +*/ +type ReplacePeerEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.PeerEntry `json:"body,omitempty"` +} + +// NewReplacePeerEntryAccepted creates ReplacePeerEntryAccepted with default headers values +func NewReplacePeerEntryAccepted() *ReplacePeerEntryAccepted { + + return &ReplacePeerEntryAccepted{} +} + +// WithReloadID adds the reloadId to the replace peer entry accepted response +func (o *ReplacePeerEntryAccepted) WithReloadID(reloadID string) *ReplacePeerEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace peer entry accepted response +func (o *ReplacePeerEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace peer entry accepted response +func (o *ReplacePeerEntryAccepted) WithPayload(payload *models.PeerEntry) *ReplacePeerEntryAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace peer entry accepted response +func (o *ReplacePeerEntryAccepted) SetPayload(payload *models.PeerEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplacePeerEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplacePeerEntryBadRequestCode is the HTTP code returned for type ReplacePeerEntryBadRequest +const ReplacePeerEntryBadRequestCode int = 400 + +/* +ReplacePeerEntryBadRequest Bad request + +swagger:response replacePeerEntryBadRequest +*/ +type ReplacePeerEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplacePeerEntryBadRequest creates ReplacePeerEntryBadRequest with default headers values +func NewReplacePeerEntryBadRequest() *ReplacePeerEntryBadRequest { + + return &ReplacePeerEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace peer entry bad request response +func (o *ReplacePeerEntryBadRequest) WithConfigurationVersion(configurationVersion string) *ReplacePeerEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace peer entry bad request response +func (o *ReplacePeerEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace peer entry bad request response +func (o *ReplacePeerEntryBadRequest) WithPayload(payload *models.Error) *ReplacePeerEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace peer entry bad request response +func (o *ReplacePeerEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplacePeerEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplacePeerEntryNotFoundCode is the HTTP code returned for type ReplacePeerEntryNotFound +const ReplacePeerEntryNotFoundCode int = 404 + +/* +ReplacePeerEntryNotFound The specified resource was not found + +swagger:response replacePeerEntryNotFound +*/ +type ReplacePeerEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplacePeerEntryNotFound creates ReplacePeerEntryNotFound with default headers values +func NewReplacePeerEntryNotFound() *ReplacePeerEntryNotFound { + + return &ReplacePeerEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace peer entry not found response +func (o *ReplacePeerEntryNotFound) WithConfigurationVersion(configurationVersion string) *ReplacePeerEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace peer entry not found response +func (o *ReplacePeerEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace peer entry not found response +func (o *ReplacePeerEntryNotFound) WithPayload(payload *models.Error) *ReplacePeerEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace peer entry not found response +func (o *ReplacePeerEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplacePeerEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplacePeerEntryDefault General Error + +swagger:response replacePeerEntryDefault +*/ +type ReplacePeerEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplacePeerEntryDefault creates ReplacePeerEntryDefault with default headers values +func NewReplacePeerEntryDefault(code int) *ReplacePeerEntryDefault { + if code <= 0 { + code = 500 + } + + return &ReplacePeerEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace peer entry default response +func (o *ReplacePeerEntryDefault) WithStatusCode(code int) *ReplacePeerEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace peer entry default response +func (o *ReplacePeerEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace peer entry default response +func (o *ReplacePeerEntryDefault) WithConfigurationVersion(configurationVersion string) *ReplacePeerEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace peer entry default response +func (o *ReplacePeerEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace peer entry default response +func (o *ReplacePeerEntryDefault) WithPayload(payload *models.Error) *ReplacePeerEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace peer entry default response +func (o *ReplacePeerEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplacePeerEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/peer_entry/replace_peer_entry_urlbuilder.go b/operations/peer_entry/replace_peer_entry_urlbuilder.go new file mode 100644 index 00000000..6687009b --- /dev/null +++ b/operations/peer_entry/replace_peer_entry_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package peer_entry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplacePeerEntryURL generates an URL for the replace peer entry operation +type ReplacePeerEntryURL struct { + Name string + + ForceReload *bool + PeerSection string + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplacePeerEntryURL) WithBasePath(bp string) *ReplacePeerEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplacePeerEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplacePeerEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peer_entries/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplacePeerEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + peerSectionQ := o.PeerSection + if peerSectionQ != "" { + qs.Set("peer_section", peerSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplacePeerEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplacePeerEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplacePeerEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplacePeerEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplacePeerEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplacePeerEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/process_manager/create_program.go b/operations/process_manager/create_program.go new file mode 100644 index 00000000..cc971cde --- /dev/null +++ b/operations/process_manager/create_program.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateProgramHandlerFunc turns a function with the right signature into a create program handler +type CreateProgramHandlerFunc func(CreateProgramParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateProgramHandlerFunc) Handle(params CreateProgramParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateProgramHandler interface for that can handle valid create program params +type CreateProgramHandler interface { + Handle(CreateProgramParams, interface{}) middleware.Responder +} + +// NewCreateProgram creates a new http.Handler for the create program operation +func NewCreateProgram(ctx *middleware.Context, handler CreateProgramHandler) *CreateProgram { + return &CreateProgram{Context: ctx, Handler: handler} +} + +/* + CreateProgram swagger:route POST /services/haproxy/configuration/programs ProcessManager createProgram + +# Add a program + +Adds a new program to the process-manager configuration file. +*/ +type CreateProgram struct { + Context *middleware.Context + Handler CreateProgramHandler +} + +func (o *CreateProgram) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateProgramParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/process_manager/create_program_parameters.go b/operations/process_manager/create_program_parameters.go new file mode 100644 index 00000000..d8c28ebd --- /dev/null +++ b/operations/process_manager/create_program_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateProgramParams creates a new CreateProgramParams object +// with the default values initialized. +func NewCreateProgramParams() CreateProgramParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateProgramParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateProgramParams contains all the bound params for the create program operation +// typically these are obtained from a http.Request +// +// swagger:parameters createProgram +type CreateProgramParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Program + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateProgramParams() beforehand. +func (o *CreateProgramParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Program + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateProgramParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateProgramParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateProgramParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateProgramParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/process_manager/create_program_responses.go b/operations/process_manager/create_program_responses.go new file mode 100644 index 00000000..73f767bd --- /dev/null +++ b/operations/process_manager/create_program_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateProgramCreatedCode is the HTTP code returned for type CreateProgramCreated +const CreateProgramCreatedCode int = 201 + +/* +CreateProgramCreated Program created + +swagger:response createProgramCreated +*/ +type CreateProgramCreated struct { + + /* + In: Body + */ + Payload *models.Program `json:"body,omitempty"` +} + +// NewCreateProgramCreated creates CreateProgramCreated with default headers values +func NewCreateProgramCreated() *CreateProgramCreated { + + return &CreateProgramCreated{} +} + +// WithPayload adds the payload to the create program created response +func (o *CreateProgramCreated) WithPayload(payload *models.Program) *CreateProgramCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create program created response +func (o *CreateProgramCreated) SetPayload(payload *models.Program) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProgramCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProgramAcceptedCode is the HTTP code returned for type CreateProgramAccepted +const CreateProgramAcceptedCode int = 202 + +/* +CreateProgramAccepted Configuration change accepted and reload requested + +swagger:response createProgramAccepted +*/ +type CreateProgramAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Program `json:"body,omitempty"` +} + +// NewCreateProgramAccepted creates CreateProgramAccepted with default headers values +func NewCreateProgramAccepted() *CreateProgramAccepted { + + return &CreateProgramAccepted{} +} + +// WithReloadID adds the reloadId to the create program accepted response +func (o *CreateProgramAccepted) WithReloadID(reloadID string) *CreateProgramAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create program accepted response +func (o *CreateProgramAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create program accepted response +func (o *CreateProgramAccepted) WithPayload(payload *models.Program) *CreateProgramAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create program accepted response +func (o *CreateProgramAccepted) SetPayload(payload *models.Program) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProgramAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProgramBadRequestCode is the HTTP code returned for type CreateProgramBadRequest +const CreateProgramBadRequestCode int = 400 + +/* +CreateProgramBadRequest Bad request + +swagger:response createProgramBadRequest +*/ +type CreateProgramBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateProgramBadRequest creates CreateProgramBadRequest with default headers values +func NewCreateProgramBadRequest() *CreateProgramBadRequest { + + return &CreateProgramBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create program bad request response +func (o *CreateProgramBadRequest) WithConfigurationVersion(configurationVersion string) *CreateProgramBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create program bad request response +func (o *CreateProgramBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create program bad request response +func (o *CreateProgramBadRequest) WithPayload(payload *models.Error) *CreateProgramBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create program bad request response +func (o *CreateProgramBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProgramBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateProgramConflictCode is the HTTP code returned for type CreateProgramConflict +const CreateProgramConflictCode int = 409 + +/* +CreateProgramConflict The specified resource already exists + +swagger:response createProgramConflict +*/ +type CreateProgramConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateProgramConflict creates CreateProgramConflict with default headers values +func NewCreateProgramConflict() *CreateProgramConflict { + + return &CreateProgramConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create program conflict response +func (o *CreateProgramConflict) WithConfigurationVersion(configurationVersion string) *CreateProgramConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create program conflict response +func (o *CreateProgramConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create program conflict response +func (o *CreateProgramConflict) WithPayload(payload *models.Error) *CreateProgramConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create program conflict response +func (o *CreateProgramConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProgramConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateProgramDefault General Error + +swagger:response createProgramDefault +*/ +type CreateProgramDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateProgramDefault creates CreateProgramDefault with default headers values +func NewCreateProgramDefault(code int) *CreateProgramDefault { + if code <= 0 { + code = 500 + } + + return &CreateProgramDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create program default response +func (o *CreateProgramDefault) WithStatusCode(code int) *CreateProgramDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create program default response +func (o *CreateProgramDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create program default response +func (o *CreateProgramDefault) WithConfigurationVersion(configurationVersion string) *CreateProgramDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create program default response +func (o *CreateProgramDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create program default response +func (o *CreateProgramDefault) WithPayload(payload *models.Error) *CreateProgramDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create program default response +func (o *CreateProgramDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateProgramDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/process_manager/create_program_urlbuilder.go b/operations/process_manager/create_program_urlbuilder.go new file mode 100644 index 00000000..d321c588 --- /dev/null +++ b/operations/process_manager/create_program_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateProgramURL generates an URL for the create program operation +type CreateProgramURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateProgramURL) WithBasePath(bp string) *CreateProgramURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateProgramURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateProgramURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/programs" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateProgramURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateProgramURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateProgramURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateProgramURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateProgramURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateProgramURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/process_manager/delete_program.go b/operations/process_manager/delete_program.go new file mode 100644 index 00000000..f1062db8 --- /dev/null +++ b/operations/process_manager/delete_program.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteProgramHandlerFunc turns a function with the right signature into a delete program handler +type DeleteProgramHandlerFunc func(DeleteProgramParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteProgramHandlerFunc) Handle(params DeleteProgramParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteProgramHandler interface for that can handle valid delete program params +type DeleteProgramHandler interface { + Handle(DeleteProgramParams, interface{}) middleware.Responder +} + +// NewDeleteProgram creates a new http.Handler for the delete program operation +func NewDeleteProgram(ctx *middleware.Context, handler DeleteProgramHandler) *DeleteProgram { + return &DeleteProgram{Context: ctx, Handler: handler} +} + +/* + DeleteProgram swagger:route DELETE /services/haproxy/configuration/programs/{name} ProcessManager deleteProgram + +# Delete a program + +Deletes a program from the process-manager configuration file by its name. +*/ +type DeleteProgram struct { + Context *middleware.Context + Handler DeleteProgramHandler +} + +func (o *DeleteProgram) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteProgramParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/process_manager/delete_program_parameters.go b/operations/process_manager/delete_program_parameters.go new file mode 100644 index 00000000..92292d93 --- /dev/null +++ b/operations/process_manager/delete_program_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteProgramParams creates a new DeleteProgramParams object +// with the default values initialized. +func NewDeleteProgramParams() DeleteProgramParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteProgramParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteProgramParams contains all the bound params for the delete program operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteProgram +type DeleteProgramParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Program name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteProgramParams() beforehand. +func (o *DeleteProgramParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteProgramParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteProgramParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteProgramParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteProgramParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteProgramParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/process_manager/delete_program_responses.go b/operations/process_manager/delete_program_responses.go new file mode 100644 index 00000000..c72bd61a --- /dev/null +++ b/operations/process_manager/delete_program_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteProgramAcceptedCode is the HTTP code returned for type DeleteProgramAccepted +const DeleteProgramAcceptedCode int = 202 + +/* +DeleteProgramAccepted Configuration change accepted and reload requested + +swagger:response deleteProgramAccepted +*/ +type DeleteProgramAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteProgramAccepted creates DeleteProgramAccepted with default headers values +func NewDeleteProgramAccepted() *DeleteProgramAccepted { + + return &DeleteProgramAccepted{} +} + +// WithReloadID adds the reloadId to the delete program accepted response +func (o *DeleteProgramAccepted) WithReloadID(reloadID string) *DeleteProgramAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete program accepted response +func (o *DeleteProgramAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteProgramAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteProgramNoContentCode is the HTTP code returned for type DeleteProgramNoContent +const DeleteProgramNoContentCode int = 204 + +/* +DeleteProgramNoContent Program deleted + +swagger:response deleteProgramNoContent +*/ +type DeleteProgramNoContent struct { +} + +// NewDeleteProgramNoContent creates DeleteProgramNoContent with default headers values +func NewDeleteProgramNoContent() *DeleteProgramNoContent { + + return &DeleteProgramNoContent{} +} + +// WriteResponse to the client +func (o *DeleteProgramNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteProgramNotFoundCode is the HTTP code returned for type DeleteProgramNotFound +const DeleteProgramNotFoundCode int = 404 + +/* +DeleteProgramNotFound The specified resource was not found + +swagger:response deleteProgramNotFound +*/ +type DeleteProgramNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteProgramNotFound creates DeleteProgramNotFound with default headers values +func NewDeleteProgramNotFound() *DeleteProgramNotFound { + + return &DeleteProgramNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete program not found response +func (o *DeleteProgramNotFound) WithConfigurationVersion(configurationVersion string) *DeleteProgramNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete program not found response +func (o *DeleteProgramNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete program not found response +func (o *DeleteProgramNotFound) WithPayload(payload *models.Error) *DeleteProgramNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete program not found response +func (o *DeleteProgramNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProgramNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteProgramDefault General Error + +swagger:response deleteProgramDefault +*/ +type DeleteProgramDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteProgramDefault creates DeleteProgramDefault with default headers values +func NewDeleteProgramDefault(code int) *DeleteProgramDefault { + if code <= 0 { + code = 500 + } + + return &DeleteProgramDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete program default response +func (o *DeleteProgramDefault) WithStatusCode(code int) *DeleteProgramDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete program default response +func (o *DeleteProgramDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete program default response +func (o *DeleteProgramDefault) WithConfigurationVersion(configurationVersion string) *DeleteProgramDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete program default response +func (o *DeleteProgramDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete program default response +func (o *DeleteProgramDefault) WithPayload(payload *models.Error) *DeleteProgramDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete program default response +func (o *DeleteProgramDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteProgramDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/process_manager/delete_program_urlbuilder.go b/operations/process_manager/delete_program_urlbuilder.go new file mode 100644 index 00000000..359024da --- /dev/null +++ b/operations/process_manager/delete_program_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteProgramURL generates an URL for the delete program operation +type DeleteProgramURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProgramURL) WithBasePath(bp string) *DeleteProgramURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteProgramURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteProgramURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/programs/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteProgramURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteProgramURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteProgramURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteProgramURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteProgramURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteProgramURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteProgramURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/process_manager/get_program.go b/operations/process_manager/get_program.go new file mode 100644 index 00000000..b9a8fd81 --- /dev/null +++ b/operations/process_manager/get_program.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetProgramHandlerFunc turns a function with the right signature into a get program handler +type GetProgramHandlerFunc func(GetProgramParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetProgramHandlerFunc) Handle(params GetProgramParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetProgramHandler interface for that can handle valid get program params +type GetProgramHandler interface { + Handle(GetProgramParams, interface{}) middleware.Responder +} + +// NewGetProgram creates a new http.Handler for the get program operation +func NewGetProgram(ctx *middleware.Context, handler GetProgramHandler) *GetProgram { + return &GetProgram{Context: ctx, Handler: handler} +} + +/* + GetProgram swagger:route GET /services/haproxy/configuration/programs/{name} ProcessManager getProgram + +# Return a program + +Returns one program by its name from the process-manager configuration file. +*/ +type GetProgram struct { + Context *middleware.Context + Handler GetProgramHandler +} + +func (o *GetProgram) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetProgramParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/process_manager/get_program_parameters.go b/operations/process_manager/get_program_parameters.go new file mode 100644 index 00000000..6fb555e0 --- /dev/null +++ b/operations/process_manager/get_program_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetProgramParams creates a new GetProgramParams object +// +// There are no default values defined in the spec. +func NewGetProgramParams() GetProgramParams { + + return GetProgramParams{} +} + +// GetProgramParams contains all the bound params for the get program operation +// typically these are obtained from a http.Request +// +// swagger:parameters getProgram +type GetProgramParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Program name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetProgramParams() beforehand. +func (o *GetProgramParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetProgramParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetProgramParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/process_manager/get_program_responses.go b/operations/process_manager/get_program_responses.go new file mode 100644 index 00000000..ad2515da --- /dev/null +++ b/operations/process_manager/get_program_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetProgramOKCode is the HTTP code returned for type GetProgramOK +const GetProgramOKCode int = 200 + +/* +GetProgramOK Successful operation + +swagger:response getProgramOK +*/ +type GetProgramOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Program `json:"body,omitempty"` +} + +// NewGetProgramOK creates GetProgramOK with default headers values +func NewGetProgramOK() *GetProgramOK { + + return &GetProgramOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get program o k response +func (o *GetProgramOK) WithConfigurationVersion(configurationVersion string) *GetProgramOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get program o k response +func (o *GetProgramOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get program o k response +func (o *GetProgramOK) WithPayload(payload *models.Program) *GetProgramOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get program o k response +func (o *GetProgramOK) SetPayload(payload *models.Program) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProgramOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetProgramNotFoundCode is the HTTP code returned for type GetProgramNotFound +const GetProgramNotFoundCode int = 404 + +/* +GetProgramNotFound The specified resource was not found + +swagger:response getProgramNotFound +*/ +type GetProgramNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetProgramNotFound creates GetProgramNotFound with default headers values +func NewGetProgramNotFound() *GetProgramNotFound { + + return &GetProgramNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get program not found response +func (o *GetProgramNotFound) WithConfigurationVersion(configurationVersion string) *GetProgramNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get program not found response +func (o *GetProgramNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get program not found response +func (o *GetProgramNotFound) WithPayload(payload *models.Error) *GetProgramNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get program not found response +func (o *GetProgramNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProgramNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetProgramDefault General Error + +swagger:response getProgramDefault +*/ +type GetProgramDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetProgramDefault creates GetProgramDefault with default headers values +func NewGetProgramDefault(code int) *GetProgramDefault { + if code <= 0 { + code = 500 + } + + return &GetProgramDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get program default response +func (o *GetProgramDefault) WithStatusCode(code int) *GetProgramDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get program default response +func (o *GetProgramDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get program default response +func (o *GetProgramDefault) WithConfigurationVersion(configurationVersion string) *GetProgramDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get program default response +func (o *GetProgramDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get program default response +func (o *GetProgramDefault) WithPayload(payload *models.Error) *GetProgramDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get program default response +func (o *GetProgramDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProgramDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/process_manager/get_program_urlbuilder.go b/operations/process_manager/get_program_urlbuilder.go new file mode 100644 index 00000000..63cdb011 --- /dev/null +++ b/operations/process_manager/get_program_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetProgramURL generates an URL for the get program operation +type GetProgramURL struct { + Name string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProgramURL) WithBasePath(bp string) *GetProgramURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProgramURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetProgramURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/programs/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetProgramURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetProgramURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetProgramURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetProgramURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetProgramURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetProgramURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetProgramURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/process_manager/get_programs.go b/operations/process_manager/get_programs.go new file mode 100644 index 00000000..a0d3060f --- /dev/null +++ b/operations/process_manager/get_programs.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetProgramsHandlerFunc turns a function with the right signature into a get programs handler +type GetProgramsHandlerFunc func(GetProgramsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetProgramsHandlerFunc) Handle(params GetProgramsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetProgramsHandler interface for that can handle valid get programs params +type GetProgramsHandler interface { + Handle(GetProgramsParams, interface{}) middleware.Responder +} + +// NewGetPrograms creates a new http.Handler for the get programs operation +func NewGetPrograms(ctx *middleware.Context, handler GetProgramsHandler) *GetPrograms { + return &GetPrograms{Context: ctx, Handler: handler} +} + +/* + GetPrograms swagger:route GET /services/haproxy/configuration/programs ProcessManager getPrograms + +# Return an array of programs + +Returns an array of all configured programs in the process-manager configuration file. +*/ +type GetPrograms struct { + Context *middleware.Context + Handler GetProgramsHandler +} + +func (o *GetPrograms) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetProgramsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/process_manager/get_programs_parameters.go b/operations/process_manager/get_programs_parameters.go new file mode 100644 index 00000000..53a720af --- /dev/null +++ b/operations/process_manager/get_programs_parameters.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetProgramsParams creates a new GetProgramsParams object +// +// There are no default values defined in the spec. +func NewGetProgramsParams() GetProgramsParams { + + return GetProgramsParams{} +} + +// GetProgramsParams contains all the bound params for the get programs operation +// typically these are obtained from a http.Request +// +// swagger:parameters getPrograms +type GetProgramsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetProgramsParams() beforehand. +func (o *GetProgramsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetProgramsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/process_manager/get_programs_responses.go b/operations/process_manager/get_programs_responses.go new file mode 100644 index 00000000..ed800e78 --- /dev/null +++ b/operations/process_manager/get_programs_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetProgramsOKCode is the HTTP code returned for type GetProgramsOK +const GetProgramsOKCode int = 200 + +/* +GetProgramsOK Successful operation + +swagger:response getProgramsOK +*/ +type GetProgramsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Programs `json:"body,omitempty"` +} + +// NewGetProgramsOK creates GetProgramsOK with default headers values +func NewGetProgramsOK() *GetProgramsOK { + + return &GetProgramsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get programs o k response +func (o *GetProgramsOK) WithConfigurationVersion(configurationVersion string) *GetProgramsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get programs o k response +func (o *GetProgramsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get programs o k response +func (o *GetProgramsOK) WithPayload(payload models.Programs) *GetProgramsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get programs o k response +func (o *GetProgramsOK) SetPayload(payload models.Programs) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProgramsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Programs{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetProgramsDefault General Error + +swagger:response getProgramsDefault +*/ +type GetProgramsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetProgramsDefault creates GetProgramsDefault with default headers values +func NewGetProgramsDefault(code int) *GetProgramsDefault { + if code <= 0 { + code = 500 + } + + return &GetProgramsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get programs default response +func (o *GetProgramsDefault) WithStatusCode(code int) *GetProgramsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get programs default response +func (o *GetProgramsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get programs default response +func (o *GetProgramsDefault) WithConfigurationVersion(configurationVersion string) *GetProgramsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get programs default response +func (o *GetProgramsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get programs default response +func (o *GetProgramsDefault) WithPayload(payload *models.Error) *GetProgramsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get programs default response +func (o *GetProgramsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetProgramsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/process_manager/get_programs_urlbuilder.go b/operations/process_manager/get_programs_urlbuilder.go new file mode 100644 index 00000000..0ccc1c41 --- /dev/null +++ b/operations/process_manager/get_programs_urlbuilder.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetProgramsURL generates an URL for the get programs operation +type GetProgramsURL struct { + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProgramsURL) WithBasePath(bp string) *GetProgramsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetProgramsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetProgramsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/programs" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetProgramsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetProgramsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetProgramsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetProgramsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetProgramsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetProgramsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/process_manager/replace_program.go b/operations/process_manager/replace_program.go new file mode 100644 index 00000000..3b5aaff9 --- /dev/null +++ b/operations/process_manager/replace_program.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceProgramHandlerFunc turns a function with the right signature into a replace program handler +type ReplaceProgramHandlerFunc func(ReplaceProgramParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceProgramHandlerFunc) Handle(params ReplaceProgramParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceProgramHandler interface for that can handle valid replace program params +type ReplaceProgramHandler interface { + Handle(ReplaceProgramParams, interface{}) middleware.Responder +} + +// NewReplaceProgram creates a new http.Handler for the replace program operation +func NewReplaceProgram(ctx *middleware.Context, handler ReplaceProgramHandler) *ReplaceProgram { + return &ReplaceProgram{Context: ctx, Handler: handler} +} + +/* + ReplaceProgram swagger:route PUT /services/haproxy/configuration/programs/{name} ProcessManager replaceProgram + +# Replace a program + +Replaces a program from the process-manager configuration by its name. +*/ +type ReplaceProgram struct { + Context *middleware.Context + Handler ReplaceProgramHandler +} + +func (o *ReplaceProgram) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceProgramParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/process_manager/replace_program_parameters.go b/operations/process_manager/replace_program_parameters.go new file mode 100644 index 00000000..cfd4ae0d --- /dev/null +++ b/operations/process_manager/replace_program_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceProgramParams creates a new ReplaceProgramParams object +// with the default values initialized. +func NewReplaceProgramParams() ReplaceProgramParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceProgramParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceProgramParams contains all the bound params for the replace program operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceProgram +type ReplaceProgramParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Program + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Program name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceProgramParams() beforehand. +func (o *ReplaceProgramParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Program + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceProgramParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceProgramParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceProgramParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceProgramParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceProgramParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/process_manager/replace_program_responses.go b/operations/process_manager/replace_program_responses.go new file mode 100644 index 00000000..8a9bb163 --- /dev/null +++ b/operations/process_manager/replace_program_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceProgramOKCode is the HTTP code returned for type ReplaceProgramOK +const ReplaceProgramOKCode int = 200 + +/* +ReplaceProgramOK Program replaced + +swagger:response replaceProgramOK +*/ +type ReplaceProgramOK struct { + + /* + In: Body + */ + Payload *models.Program `json:"body,omitempty"` +} + +// NewReplaceProgramOK creates ReplaceProgramOK with default headers values +func NewReplaceProgramOK() *ReplaceProgramOK { + + return &ReplaceProgramOK{} +} + +// WithPayload adds the payload to the replace program o k response +func (o *ReplaceProgramOK) WithPayload(payload *models.Program) *ReplaceProgramOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace program o k response +func (o *ReplaceProgramOK) SetPayload(payload *models.Program) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceProgramOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceProgramAcceptedCode is the HTTP code returned for type ReplaceProgramAccepted +const ReplaceProgramAcceptedCode int = 202 + +/* +ReplaceProgramAccepted Configuration change accepted and reload requested + +swagger:response replaceProgramAccepted +*/ +type ReplaceProgramAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Program `json:"body,omitempty"` +} + +// NewReplaceProgramAccepted creates ReplaceProgramAccepted with default headers values +func NewReplaceProgramAccepted() *ReplaceProgramAccepted { + + return &ReplaceProgramAccepted{} +} + +// WithReloadID adds the reloadId to the replace program accepted response +func (o *ReplaceProgramAccepted) WithReloadID(reloadID string) *ReplaceProgramAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace program accepted response +func (o *ReplaceProgramAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace program accepted response +func (o *ReplaceProgramAccepted) WithPayload(payload *models.Program) *ReplaceProgramAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace program accepted response +func (o *ReplaceProgramAccepted) SetPayload(payload *models.Program) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceProgramAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceProgramBadRequestCode is the HTTP code returned for type ReplaceProgramBadRequest +const ReplaceProgramBadRequestCode int = 400 + +/* +ReplaceProgramBadRequest Bad request + +swagger:response replaceProgramBadRequest +*/ +type ReplaceProgramBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceProgramBadRequest creates ReplaceProgramBadRequest with default headers values +func NewReplaceProgramBadRequest() *ReplaceProgramBadRequest { + + return &ReplaceProgramBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace program bad request response +func (o *ReplaceProgramBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceProgramBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace program bad request response +func (o *ReplaceProgramBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace program bad request response +func (o *ReplaceProgramBadRequest) WithPayload(payload *models.Error) *ReplaceProgramBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace program bad request response +func (o *ReplaceProgramBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceProgramBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceProgramNotFoundCode is the HTTP code returned for type ReplaceProgramNotFound +const ReplaceProgramNotFoundCode int = 404 + +/* +ReplaceProgramNotFound The specified resource was not found + +swagger:response replaceProgramNotFound +*/ +type ReplaceProgramNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceProgramNotFound creates ReplaceProgramNotFound with default headers values +func NewReplaceProgramNotFound() *ReplaceProgramNotFound { + + return &ReplaceProgramNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace program not found response +func (o *ReplaceProgramNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceProgramNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace program not found response +func (o *ReplaceProgramNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace program not found response +func (o *ReplaceProgramNotFound) WithPayload(payload *models.Error) *ReplaceProgramNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace program not found response +func (o *ReplaceProgramNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceProgramNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceProgramDefault General Error + +swagger:response replaceProgramDefault +*/ +type ReplaceProgramDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceProgramDefault creates ReplaceProgramDefault with default headers values +func NewReplaceProgramDefault(code int) *ReplaceProgramDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceProgramDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace program default response +func (o *ReplaceProgramDefault) WithStatusCode(code int) *ReplaceProgramDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace program default response +func (o *ReplaceProgramDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace program default response +func (o *ReplaceProgramDefault) WithConfigurationVersion(configurationVersion string) *ReplaceProgramDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace program default response +func (o *ReplaceProgramDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace program default response +func (o *ReplaceProgramDefault) WithPayload(payload *models.Error) *ReplaceProgramDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace program default response +func (o *ReplaceProgramDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceProgramDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/process_manager/replace_program_urlbuilder.go b/operations/process_manager/replace_program_urlbuilder.go new file mode 100644 index 00000000..09ba4217 --- /dev/null +++ b/operations/process_manager/replace_program_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package process_manager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceProgramURL generates an URL for the replace program operation +type ReplaceProgramURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceProgramURL) WithBasePath(bp string) *ReplaceProgramURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceProgramURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceProgramURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/programs/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceProgramURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceProgramURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceProgramURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceProgramURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceProgramURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceProgramURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceProgramURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_defaults.go b/operations/quic_initial_rule/create_quic_initial_rule_defaults.go new file mode 100644 index 00000000..47f12fa1 --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateQUICInitialRuleDefaultsHandlerFunc turns a function with the right signature into a create QUIC initial rule defaults handler +type CreateQUICInitialRuleDefaultsHandlerFunc func(CreateQUICInitialRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateQUICInitialRuleDefaultsHandlerFunc) Handle(params CreateQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateQUICInitialRuleDefaultsHandler interface for that can handle valid create QUIC initial rule defaults params +type CreateQUICInitialRuleDefaultsHandler interface { + Handle(CreateQUICInitialRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateQUICInitialRuleDefaults creates a new http.Handler for the create QUIC initial rule defaults operation +func NewCreateQUICInitialRuleDefaults(ctx *middleware.Context, handler CreateQUICInitialRuleDefaultsHandler) *CreateQUICInitialRuleDefaults { + return &CreateQUICInitialRuleDefaults{Context: ctx, Handler: handler} +} + +/* + CreateQUICInitialRuleDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index} QUICInitialRule createQuicInitialRuleDefaults + +# Add a new QUIC Initial Rule + +Adds a new QUIC Initial Rule of the specified type in the specified parent. +*/ +type CreateQUICInitialRuleDefaults struct { + Context *middleware.Context + Handler CreateQUICInitialRuleDefaultsHandler +} + +func (o *CreateQUICInitialRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateQUICInitialRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_defaults_parameters.go b/operations/quic_initial_rule/create_quic_initial_rule_defaults_parameters.go new file mode 100644 index 00000000..c43e6439 --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateQUICInitialRuleDefaultsParams creates a new CreateQUICInitialRuleDefaultsParams object +// with the default values initialized. +func NewCreateQUICInitialRuleDefaultsParams() CreateQUICInitialRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateQUICInitialRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateQUICInitialRuleDefaultsParams contains all the bound params for the create QUIC initial rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createQUICInitialRuleDefaults +type CreateQUICInitialRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.QUICInitialRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateQUICInitialRuleDefaultsParams() beforehand. +func (o *CreateQUICInitialRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.QUICInitialRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateQUICInitialRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateQUICInitialRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateQUICInitialRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateQUICInitialRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateQUICInitialRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateQUICInitialRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_defaults_responses.go b/operations/quic_initial_rule/create_quic_initial_rule_defaults_responses.go new file mode 100644 index 00000000..71e046d2 --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateQUICInitialRuleDefaultsCreatedCode is the HTTP code returned for type CreateQUICInitialRuleDefaultsCreated +const CreateQUICInitialRuleDefaultsCreatedCode int = 201 + +/* +CreateQUICInitialRuleDefaultsCreated HTTP Response Rule created + +swagger:response createQuicInitialRuleDefaultsCreated +*/ +type CreateQUICInitialRuleDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleDefaultsCreated creates CreateQUICInitialRuleDefaultsCreated with default headers values +func NewCreateQUICInitialRuleDefaultsCreated() *CreateQUICInitialRuleDefaultsCreated { + + return &CreateQUICInitialRuleDefaultsCreated{} +} + +// WithPayload adds the payload to the create Quic initial rule defaults created response +func (o *CreateQUICInitialRuleDefaultsCreated) WithPayload(payload *models.QUICInitialRule) *CreateQUICInitialRuleDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule defaults created response +func (o *CreateQUICInitialRuleDefaultsCreated) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateQUICInitialRuleDefaultsAcceptedCode is the HTTP code returned for type CreateQUICInitialRuleDefaultsAccepted +const CreateQUICInitialRuleDefaultsAcceptedCode int = 202 + +/* +CreateQUICInitialRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createQuicInitialRuleDefaultsAccepted +*/ +type CreateQUICInitialRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleDefaultsAccepted creates CreateQUICInitialRuleDefaultsAccepted with default headers values +func NewCreateQUICInitialRuleDefaultsAccepted() *CreateQUICInitialRuleDefaultsAccepted { + + return &CreateQUICInitialRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Quic initial rule defaults accepted response +func (o *CreateQUICInitialRuleDefaultsAccepted) WithReloadID(reloadID string) *CreateQUICInitialRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Quic initial rule defaults accepted response +func (o *CreateQUICInitialRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Quic initial rule defaults accepted response +func (o *CreateQUICInitialRuleDefaultsAccepted) WithPayload(payload *models.QUICInitialRule) *CreateQUICInitialRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule defaults accepted response +func (o *CreateQUICInitialRuleDefaultsAccepted) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateQUICInitialRuleDefaultsBadRequestCode is the HTTP code returned for type CreateQUICInitialRuleDefaultsBadRequest +const CreateQUICInitialRuleDefaultsBadRequestCode int = 400 + +/* +CreateQUICInitialRuleDefaultsBadRequest Bad request + +swagger:response createQuicInitialRuleDefaultsBadRequest +*/ +type CreateQUICInitialRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleDefaultsBadRequest creates CreateQUICInitialRuleDefaultsBadRequest with default headers values +func NewCreateQUICInitialRuleDefaultsBadRequest() *CreateQUICInitialRuleDefaultsBadRequest { + + return &CreateQUICInitialRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Quic initial rule defaults bad request response +func (o *CreateQUICInitialRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateQUICInitialRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Quic initial rule defaults bad request response +func (o *CreateQUICInitialRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Quic initial rule defaults bad request response +func (o *CreateQUICInitialRuleDefaultsBadRequest) WithPayload(payload *models.Error) *CreateQUICInitialRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule defaults bad request response +func (o *CreateQUICInitialRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateQUICInitialRuleDefaultsConflictCode is the HTTP code returned for type CreateQUICInitialRuleDefaultsConflict +const CreateQUICInitialRuleDefaultsConflictCode int = 409 + +/* +CreateQUICInitialRuleDefaultsConflict The specified resource already exists + +swagger:response createQuicInitialRuleDefaultsConflict +*/ +type CreateQUICInitialRuleDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleDefaultsConflict creates CreateQUICInitialRuleDefaultsConflict with default headers values +func NewCreateQUICInitialRuleDefaultsConflict() *CreateQUICInitialRuleDefaultsConflict { + + return &CreateQUICInitialRuleDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Quic initial rule defaults conflict response +func (o *CreateQUICInitialRuleDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateQUICInitialRuleDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Quic initial rule defaults conflict response +func (o *CreateQUICInitialRuleDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Quic initial rule defaults conflict response +func (o *CreateQUICInitialRuleDefaultsConflict) WithPayload(payload *models.Error) *CreateQUICInitialRuleDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule defaults conflict response +func (o *CreateQUICInitialRuleDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateQUICInitialRuleDefaultsDefault General Error + +swagger:response createQuicInitialRuleDefaultsDefault +*/ +type CreateQUICInitialRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleDefaultsDefault creates CreateQUICInitialRuleDefaultsDefault with default headers values +func NewCreateQUICInitialRuleDefaultsDefault(code int) *CreateQUICInitialRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateQUICInitialRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create QUIC initial rule defaults default response +func (o *CreateQUICInitialRuleDefaultsDefault) WithStatusCode(code int) *CreateQUICInitialRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create QUIC initial rule defaults default response +func (o *CreateQUICInitialRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create QUIC initial rule defaults default response +func (o *CreateQUICInitialRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateQUICInitialRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create QUIC initial rule defaults default response +func (o *CreateQUICInitialRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create QUIC initial rule defaults default response +func (o *CreateQUICInitialRuleDefaultsDefault) WithPayload(payload *models.Error) *CreateQUICInitialRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create QUIC initial rule defaults default response +func (o *CreateQUICInitialRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_defaults_urlbuilder.go b/operations/quic_initial_rule/create_quic_initial_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..92b40b7d --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateQUICInitialRuleDefaultsURL generates an URL for the create QUIC initial rule defaults operation +type CreateQUICInitialRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateQUICInitialRuleDefaultsURL) WithBasePath(bp string) *CreateQUICInitialRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateQUICInitialRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateQUICInitialRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateQUICInitialRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateQUICInitialRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateQUICInitialRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateQUICInitialRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateQUICInitialRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateQUICInitialRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateQUICInitialRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateQUICInitialRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_frontend.go b/operations/quic_initial_rule/create_quic_initial_rule_frontend.go new file mode 100644 index 00000000..162c1624 --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateQUICInitialRuleFrontendHandlerFunc turns a function with the right signature into a create QUIC initial rule frontend handler +type CreateQUICInitialRuleFrontendHandlerFunc func(CreateQUICInitialRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateQUICInitialRuleFrontendHandlerFunc) Handle(params CreateQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateQUICInitialRuleFrontendHandler interface for that can handle valid create QUIC initial rule frontend params +type CreateQUICInitialRuleFrontendHandler interface { + Handle(CreateQUICInitialRuleFrontendParams, interface{}) middleware.Responder +} + +// NewCreateQUICInitialRuleFrontend creates a new http.Handler for the create QUIC initial rule frontend operation +func NewCreateQUICInitialRuleFrontend(ctx *middleware.Context, handler CreateQUICInitialRuleFrontendHandler) *CreateQUICInitialRuleFrontend { + return &CreateQUICInitialRuleFrontend{Context: ctx, Handler: handler} +} + +/* + CreateQUICInitialRuleFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index} QUICInitialRule createQuicInitialRuleFrontend + +# Add a new QUIC Initial Rule + +Adds a new QUIC Initial Rule of the specified type in the specified parent. +*/ +type CreateQUICInitialRuleFrontend struct { + Context *middleware.Context + Handler CreateQUICInitialRuleFrontendHandler +} + +func (o *CreateQUICInitialRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateQUICInitialRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_frontend_parameters.go b/operations/quic_initial_rule/create_quic_initial_rule_frontend_parameters.go new file mode 100644 index 00000000..54bc1a59 --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateQUICInitialRuleFrontendParams creates a new CreateQUICInitialRuleFrontendParams object +// with the default values initialized. +func NewCreateQUICInitialRuleFrontendParams() CreateQUICInitialRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateQUICInitialRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateQUICInitialRuleFrontendParams contains all the bound params for the create QUIC initial rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createQUICInitialRuleFrontend +type CreateQUICInitialRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.QUICInitialRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateQUICInitialRuleFrontendParams() beforehand. +func (o *CreateQUICInitialRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.QUICInitialRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateQUICInitialRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateQUICInitialRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateQUICInitialRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateQUICInitialRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateQUICInitialRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateQUICInitialRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_frontend_responses.go b/operations/quic_initial_rule/create_quic_initial_rule_frontend_responses.go new file mode 100644 index 00000000..2dca652f --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateQUICInitialRuleFrontendCreatedCode is the HTTP code returned for type CreateQUICInitialRuleFrontendCreated +const CreateQUICInitialRuleFrontendCreatedCode int = 201 + +/* +CreateQUICInitialRuleFrontendCreated HTTP Response Rule created + +swagger:response createQuicInitialRuleFrontendCreated +*/ +type CreateQUICInitialRuleFrontendCreated struct { + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleFrontendCreated creates CreateQUICInitialRuleFrontendCreated with default headers values +func NewCreateQUICInitialRuleFrontendCreated() *CreateQUICInitialRuleFrontendCreated { + + return &CreateQUICInitialRuleFrontendCreated{} +} + +// WithPayload adds the payload to the create Quic initial rule frontend created response +func (o *CreateQUICInitialRuleFrontendCreated) WithPayload(payload *models.QUICInitialRule) *CreateQUICInitialRuleFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule frontend created response +func (o *CreateQUICInitialRuleFrontendCreated) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateQUICInitialRuleFrontendAcceptedCode is the HTTP code returned for type CreateQUICInitialRuleFrontendAccepted +const CreateQUICInitialRuleFrontendAcceptedCode int = 202 + +/* +CreateQUICInitialRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response createQuicInitialRuleFrontendAccepted +*/ +type CreateQUICInitialRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleFrontendAccepted creates CreateQUICInitialRuleFrontendAccepted with default headers values +func NewCreateQUICInitialRuleFrontendAccepted() *CreateQUICInitialRuleFrontendAccepted { + + return &CreateQUICInitialRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create Quic initial rule frontend accepted response +func (o *CreateQUICInitialRuleFrontendAccepted) WithReloadID(reloadID string) *CreateQUICInitialRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Quic initial rule frontend accepted response +func (o *CreateQUICInitialRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Quic initial rule frontend accepted response +func (o *CreateQUICInitialRuleFrontendAccepted) WithPayload(payload *models.QUICInitialRule) *CreateQUICInitialRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule frontend accepted response +func (o *CreateQUICInitialRuleFrontendAccepted) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateQUICInitialRuleFrontendBadRequestCode is the HTTP code returned for type CreateQUICInitialRuleFrontendBadRequest +const CreateQUICInitialRuleFrontendBadRequestCode int = 400 + +/* +CreateQUICInitialRuleFrontendBadRequest Bad request + +swagger:response createQuicInitialRuleFrontendBadRequest +*/ +type CreateQUICInitialRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleFrontendBadRequest creates CreateQUICInitialRuleFrontendBadRequest with default headers values +func NewCreateQUICInitialRuleFrontendBadRequest() *CreateQUICInitialRuleFrontendBadRequest { + + return &CreateQUICInitialRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Quic initial rule frontend bad request response +func (o *CreateQUICInitialRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateQUICInitialRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Quic initial rule frontend bad request response +func (o *CreateQUICInitialRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Quic initial rule frontend bad request response +func (o *CreateQUICInitialRuleFrontendBadRequest) WithPayload(payload *models.Error) *CreateQUICInitialRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule frontend bad request response +func (o *CreateQUICInitialRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateQUICInitialRuleFrontendConflictCode is the HTTP code returned for type CreateQUICInitialRuleFrontendConflict +const CreateQUICInitialRuleFrontendConflictCode int = 409 + +/* +CreateQUICInitialRuleFrontendConflict The specified resource already exists + +swagger:response createQuicInitialRuleFrontendConflict +*/ +type CreateQUICInitialRuleFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleFrontendConflict creates CreateQUICInitialRuleFrontendConflict with default headers values +func NewCreateQUICInitialRuleFrontendConflict() *CreateQUICInitialRuleFrontendConflict { + + return &CreateQUICInitialRuleFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Quic initial rule frontend conflict response +func (o *CreateQUICInitialRuleFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateQUICInitialRuleFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Quic initial rule frontend conflict response +func (o *CreateQUICInitialRuleFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Quic initial rule frontend conflict response +func (o *CreateQUICInitialRuleFrontendConflict) WithPayload(payload *models.Error) *CreateQUICInitialRuleFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Quic initial rule frontend conflict response +func (o *CreateQUICInitialRuleFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateQUICInitialRuleFrontendDefault General Error + +swagger:response createQuicInitialRuleFrontendDefault +*/ +type CreateQUICInitialRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateQUICInitialRuleFrontendDefault creates CreateQUICInitialRuleFrontendDefault with default headers values +func NewCreateQUICInitialRuleFrontendDefault(code int) *CreateQUICInitialRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateQUICInitialRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create QUIC initial rule frontend default response +func (o *CreateQUICInitialRuleFrontendDefault) WithStatusCode(code int) *CreateQUICInitialRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create QUIC initial rule frontend default response +func (o *CreateQUICInitialRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create QUIC initial rule frontend default response +func (o *CreateQUICInitialRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateQUICInitialRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create QUIC initial rule frontend default response +func (o *CreateQUICInitialRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create QUIC initial rule frontend default response +func (o *CreateQUICInitialRuleFrontendDefault) WithPayload(payload *models.Error) *CreateQUICInitialRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create QUIC initial rule frontend default response +func (o *CreateQUICInitialRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateQUICInitialRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/create_quic_initial_rule_frontend_urlbuilder.go b/operations/quic_initial_rule/create_quic_initial_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..ca846214 --- /dev/null +++ b/operations/quic_initial_rule/create_quic_initial_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateQUICInitialRuleFrontendURL generates an URL for the create QUIC initial rule frontend operation +type CreateQUICInitialRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateQUICInitialRuleFrontendURL) WithBasePath(bp string) *CreateQUICInitialRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateQUICInitialRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateQUICInitialRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateQUICInitialRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateQUICInitialRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateQUICInitialRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateQUICInitialRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateQUICInitialRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateQUICInitialRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateQUICInitialRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateQUICInitialRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_defaults.go b/operations/quic_initial_rule/delete_quic_initial_rule_defaults.go new file mode 100644 index 00000000..2605b2bd --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteQUICInitialRuleDefaultsHandlerFunc turns a function with the right signature into a delete QUIC initial rule defaults handler +type DeleteQUICInitialRuleDefaultsHandlerFunc func(DeleteQUICInitialRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteQUICInitialRuleDefaultsHandlerFunc) Handle(params DeleteQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteQUICInitialRuleDefaultsHandler interface for that can handle valid delete QUIC initial rule defaults params +type DeleteQUICInitialRuleDefaultsHandler interface { + Handle(DeleteQUICInitialRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteQUICInitialRuleDefaults creates a new http.Handler for the delete QUIC initial rule defaults operation +func NewDeleteQUICInitialRuleDefaults(ctx *middleware.Context, handler DeleteQUICInitialRuleDefaultsHandler) *DeleteQUICInitialRuleDefaults { + return &DeleteQUICInitialRuleDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteQUICInitialRuleDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index} QUICInitialRule deleteQuicInitialRuleDefaults + +# Delete a QUIC Initial Rule + +Deletes a QUIC Initial Rule configuration by it's index from the specified parent. +*/ +type DeleteQUICInitialRuleDefaults struct { + Context *middleware.Context + Handler DeleteQUICInitialRuleDefaultsHandler +} + +func (o *DeleteQUICInitialRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteQUICInitialRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_defaults_parameters.go b/operations/quic_initial_rule/delete_quic_initial_rule_defaults_parameters.go new file mode 100644 index 00000000..64dbb979 --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteQUICInitialRuleDefaultsParams creates a new DeleteQUICInitialRuleDefaultsParams object +// with the default values initialized. +func NewDeleteQUICInitialRuleDefaultsParams() DeleteQUICInitialRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteQUICInitialRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteQUICInitialRuleDefaultsParams contains all the bound params for the delete QUIC initial rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteQUICInitialRuleDefaults +type DeleteQUICInitialRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteQUICInitialRuleDefaultsParams() beforehand. +func (o *DeleteQUICInitialRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteQUICInitialRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteQUICInitialRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteQUICInitialRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteQUICInitialRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteQUICInitialRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteQUICInitialRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_defaults_responses.go b/operations/quic_initial_rule/delete_quic_initial_rule_defaults_responses.go new file mode 100644 index 00000000..71609dbf --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteQUICInitialRuleDefaultsAcceptedCode is the HTTP code returned for type DeleteQUICInitialRuleDefaultsAccepted +const DeleteQUICInitialRuleDefaultsAcceptedCode int = 202 + +/* +DeleteQUICInitialRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteQuicInitialRuleDefaultsAccepted +*/ +type DeleteQUICInitialRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteQUICInitialRuleDefaultsAccepted creates DeleteQUICInitialRuleDefaultsAccepted with default headers values +func NewDeleteQUICInitialRuleDefaultsAccepted() *DeleteQUICInitialRuleDefaultsAccepted { + + return &DeleteQUICInitialRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Quic initial rule defaults accepted response +func (o *DeleteQUICInitialRuleDefaultsAccepted) WithReloadID(reloadID string) *DeleteQUICInitialRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Quic initial rule defaults accepted response +func (o *DeleteQUICInitialRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteQUICInitialRuleDefaultsNoContentCode is the HTTP code returned for type DeleteQUICInitialRuleDefaultsNoContent +const DeleteQUICInitialRuleDefaultsNoContentCode int = 204 + +/* +DeleteQUICInitialRuleDefaultsNoContent QUIC Initial Rule deleted + +swagger:response deleteQuicInitialRuleDefaultsNoContent +*/ +type DeleteQUICInitialRuleDefaultsNoContent struct { +} + +// NewDeleteQUICInitialRuleDefaultsNoContent creates DeleteQUICInitialRuleDefaultsNoContent with default headers values +func NewDeleteQUICInitialRuleDefaultsNoContent() *DeleteQUICInitialRuleDefaultsNoContent { + + return &DeleteQUICInitialRuleDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteQUICInitialRuleDefaultsNotFoundCode is the HTTP code returned for type DeleteQUICInitialRuleDefaultsNotFound +const DeleteQUICInitialRuleDefaultsNotFoundCode int = 404 + +/* +DeleteQUICInitialRuleDefaultsNotFound The specified resource was not found + +swagger:response deleteQuicInitialRuleDefaultsNotFound +*/ +type DeleteQUICInitialRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteQUICInitialRuleDefaultsNotFound creates DeleteQUICInitialRuleDefaultsNotFound with default headers values +func NewDeleteQUICInitialRuleDefaultsNotFound() *DeleteQUICInitialRuleDefaultsNotFound { + + return &DeleteQUICInitialRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Quic initial rule defaults not found response +func (o *DeleteQUICInitialRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteQUICInitialRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Quic initial rule defaults not found response +func (o *DeleteQUICInitialRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Quic initial rule defaults not found response +func (o *DeleteQUICInitialRuleDefaultsNotFound) WithPayload(payload *models.Error) *DeleteQUICInitialRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Quic initial rule defaults not found response +func (o *DeleteQUICInitialRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteQUICInitialRuleDefaultsDefault General Error + +swagger:response deleteQuicInitialRuleDefaultsDefault +*/ +type DeleteQUICInitialRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteQUICInitialRuleDefaultsDefault creates DeleteQUICInitialRuleDefaultsDefault with default headers values +func NewDeleteQUICInitialRuleDefaultsDefault(code int) *DeleteQUICInitialRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteQUICInitialRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete QUIC initial rule defaults default response +func (o *DeleteQUICInitialRuleDefaultsDefault) WithStatusCode(code int) *DeleteQUICInitialRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete QUIC initial rule defaults default response +func (o *DeleteQUICInitialRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete QUIC initial rule defaults default response +func (o *DeleteQUICInitialRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteQUICInitialRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete QUIC initial rule defaults default response +func (o *DeleteQUICInitialRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete QUIC initial rule defaults default response +func (o *DeleteQUICInitialRuleDefaultsDefault) WithPayload(payload *models.Error) *DeleteQUICInitialRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete QUIC initial rule defaults default response +func (o *DeleteQUICInitialRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_defaults_urlbuilder.go b/operations/quic_initial_rule/delete_quic_initial_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..d6ed58f1 --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteQUICInitialRuleDefaultsURL generates an URL for the delete QUIC initial rule defaults operation +type DeleteQUICInitialRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteQUICInitialRuleDefaultsURL) WithBasePath(bp string) *DeleteQUICInitialRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteQUICInitialRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteQUICInitialRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteQUICInitialRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteQUICInitialRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteQUICInitialRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteQUICInitialRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteQUICInitialRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteQUICInitialRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteQUICInitialRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteQUICInitialRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_frontend.go b/operations/quic_initial_rule/delete_quic_initial_rule_frontend.go new file mode 100644 index 00000000..68b24fe9 --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteQUICInitialRuleFrontendHandlerFunc turns a function with the right signature into a delete QUIC initial rule frontend handler +type DeleteQUICInitialRuleFrontendHandlerFunc func(DeleteQUICInitialRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteQUICInitialRuleFrontendHandlerFunc) Handle(params DeleteQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteQUICInitialRuleFrontendHandler interface for that can handle valid delete QUIC initial rule frontend params +type DeleteQUICInitialRuleFrontendHandler interface { + Handle(DeleteQUICInitialRuleFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteQUICInitialRuleFrontend creates a new http.Handler for the delete QUIC initial rule frontend operation +func NewDeleteQUICInitialRuleFrontend(ctx *middleware.Context, handler DeleteQUICInitialRuleFrontendHandler) *DeleteQUICInitialRuleFrontend { + return &DeleteQUICInitialRuleFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteQUICInitialRuleFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index} QUICInitialRule deleteQuicInitialRuleFrontend + +# Delete a QUIC Initial Rule + +Deletes a QUIC Initial Rule configuration by it's index from the specified parent. +*/ +type DeleteQUICInitialRuleFrontend struct { + Context *middleware.Context + Handler DeleteQUICInitialRuleFrontendHandler +} + +func (o *DeleteQUICInitialRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteQUICInitialRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_frontend_parameters.go b/operations/quic_initial_rule/delete_quic_initial_rule_frontend_parameters.go new file mode 100644 index 00000000..ce8f2e4e --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteQUICInitialRuleFrontendParams creates a new DeleteQUICInitialRuleFrontendParams object +// with the default values initialized. +func NewDeleteQUICInitialRuleFrontendParams() DeleteQUICInitialRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteQUICInitialRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteQUICInitialRuleFrontendParams contains all the bound params for the delete QUIC initial rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteQUICInitialRuleFrontend +type DeleteQUICInitialRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteQUICInitialRuleFrontendParams() beforehand. +func (o *DeleteQUICInitialRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteQUICInitialRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteQUICInitialRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteQUICInitialRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteQUICInitialRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteQUICInitialRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteQUICInitialRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_frontend_responses.go b/operations/quic_initial_rule/delete_quic_initial_rule_frontend_responses.go new file mode 100644 index 00000000..6f040334 --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteQUICInitialRuleFrontendAcceptedCode is the HTTP code returned for type DeleteQUICInitialRuleFrontendAccepted +const DeleteQUICInitialRuleFrontendAcceptedCode int = 202 + +/* +DeleteQUICInitialRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteQuicInitialRuleFrontendAccepted +*/ +type DeleteQUICInitialRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteQUICInitialRuleFrontendAccepted creates DeleteQUICInitialRuleFrontendAccepted with default headers values +func NewDeleteQUICInitialRuleFrontendAccepted() *DeleteQUICInitialRuleFrontendAccepted { + + return &DeleteQUICInitialRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Quic initial rule frontend accepted response +func (o *DeleteQUICInitialRuleFrontendAccepted) WithReloadID(reloadID string) *DeleteQUICInitialRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Quic initial rule frontend accepted response +func (o *DeleteQUICInitialRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteQUICInitialRuleFrontendNoContentCode is the HTTP code returned for type DeleteQUICInitialRuleFrontendNoContent +const DeleteQUICInitialRuleFrontendNoContentCode int = 204 + +/* +DeleteQUICInitialRuleFrontendNoContent QUIC Initial Rule deleted + +swagger:response deleteQuicInitialRuleFrontendNoContent +*/ +type DeleteQUICInitialRuleFrontendNoContent struct { +} + +// NewDeleteQUICInitialRuleFrontendNoContent creates DeleteQUICInitialRuleFrontendNoContent with default headers values +func NewDeleteQUICInitialRuleFrontendNoContent() *DeleteQUICInitialRuleFrontendNoContent { + + return &DeleteQUICInitialRuleFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteQUICInitialRuleFrontendNotFoundCode is the HTTP code returned for type DeleteQUICInitialRuleFrontendNotFound +const DeleteQUICInitialRuleFrontendNotFoundCode int = 404 + +/* +DeleteQUICInitialRuleFrontendNotFound The specified resource was not found + +swagger:response deleteQuicInitialRuleFrontendNotFound +*/ +type DeleteQUICInitialRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteQUICInitialRuleFrontendNotFound creates DeleteQUICInitialRuleFrontendNotFound with default headers values +func NewDeleteQUICInitialRuleFrontendNotFound() *DeleteQUICInitialRuleFrontendNotFound { + + return &DeleteQUICInitialRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Quic initial rule frontend not found response +func (o *DeleteQUICInitialRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteQUICInitialRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Quic initial rule frontend not found response +func (o *DeleteQUICInitialRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Quic initial rule frontend not found response +func (o *DeleteQUICInitialRuleFrontendNotFound) WithPayload(payload *models.Error) *DeleteQUICInitialRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Quic initial rule frontend not found response +func (o *DeleteQUICInitialRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteQUICInitialRuleFrontendDefault General Error + +swagger:response deleteQuicInitialRuleFrontendDefault +*/ +type DeleteQUICInitialRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteQUICInitialRuleFrontendDefault creates DeleteQUICInitialRuleFrontendDefault with default headers values +func NewDeleteQUICInitialRuleFrontendDefault(code int) *DeleteQUICInitialRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteQUICInitialRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete QUIC initial rule frontend default response +func (o *DeleteQUICInitialRuleFrontendDefault) WithStatusCode(code int) *DeleteQUICInitialRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete QUIC initial rule frontend default response +func (o *DeleteQUICInitialRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete QUIC initial rule frontend default response +func (o *DeleteQUICInitialRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteQUICInitialRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete QUIC initial rule frontend default response +func (o *DeleteQUICInitialRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete QUIC initial rule frontend default response +func (o *DeleteQUICInitialRuleFrontendDefault) WithPayload(payload *models.Error) *DeleteQUICInitialRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete QUIC initial rule frontend default response +func (o *DeleteQUICInitialRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteQUICInitialRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/delete_quic_initial_rule_frontend_urlbuilder.go b/operations/quic_initial_rule/delete_quic_initial_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..74446309 --- /dev/null +++ b/operations/quic_initial_rule/delete_quic_initial_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteQUICInitialRuleFrontendURL generates an URL for the delete QUIC initial rule frontend operation +type DeleteQUICInitialRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteQUICInitialRuleFrontendURL) WithBasePath(bp string) *DeleteQUICInitialRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteQUICInitialRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteQUICInitialRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteQUICInitialRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteQUICInitialRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteQUICInitialRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteQUICInitialRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteQUICInitialRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteQUICInitialRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteQUICInitialRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteQUICInitialRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_defaults.go b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults.go new file mode 100644 index 00000000..0d117685 --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllQUICInitialRuleDefaultsHandlerFunc turns a function with the right signature into a get all QUIC initial rule defaults handler +type GetAllQUICInitialRuleDefaultsHandlerFunc func(GetAllQUICInitialRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllQUICInitialRuleDefaultsHandlerFunc) Handle(params GetAllQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllQUICInitialRuleDefaultsHandler interface for that can handle valid get all QUIC initial rule defaults params +type GetAllQUICInitialRuleDefaultsHandler interface { + Handle(GetAllQUICInitialRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllQUICInitialRuleDefaults creates a new http.Handler for the get all QUIC initial rule defaults operation +func NewGetAllQUICInitialRuleDefaults(ctx *middleware.Context, handler GetAllQUICInitialRuleDefaultsHandler) *GetAllQUICInitialRuleDefaults { + return &GetAllQUICInitialRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllQUICInitialRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules QUICInitialRule getAllQuicInitialRuleDefaults + +# Return an array of all QUIC Initial rules + +Returns all QUIC Initial rules that are configured in specified parent. +*/ +type GetAllQUICInitialRuleDefaults struct { + Context *middleware.Context + Handler GetAllQUICInitialRuleDefaultsHandler +} + +func (o *GetAllQUICInitialRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllQUICInitialRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_parameters.go b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_parameters.go new file mode 100644 index 00000000..6e65f062 --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllQUICInitialRuleDefaultsParams creates a new GetAllQUICInitialRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllQUICInitialRuleDefaultsParams() GetAllQUICInitialRuleDefaultsParams { + + return GetAllQUICInitialRuleDefaultsParams{} +} + +// GetAllQUICInitialRuleDefaultsParams contains all the bound params for the get all QUIC initial rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllQUICInitialRuleDefaults +type GetAllQUICInitialRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllQUICInitialRuleDefaultsParams() beforehand. +func (o *GetAllQUICInitialRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllQUICInitialRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllQUICInitialRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_responses.go b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_responses.go new file mode 100644 index 00000000..a27ad73a --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllQUICInitialRuleDefaultsOKCode is the HTTP code returned for type GetAllQUICInitialRuleDefaultsOK +const GetAllQUICInitialRuleDefaultsOKCode int = 200 + +/* +GetAllQUICInitialRuleDefaultsOK Successful operation + +swagger:response getAllQuicInitialRuleDefaultsOK +*/ +type GetAllQUICInitialRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.QUICInitialRules `json:"body,omitempty"` +} + +// NewGetAllQUICInitialRuleDefaultsOK creates GetAllQUICInitialRuleDefaultsOK with default headers values +func NewGetAllQUICInitialRuleDefaultsOK() *GetAllQUICInitialRuleDefaultsOK { + + return &GetAllQUICInitialRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Quic initial rule defaults o k response +func (o *GetAllQUICInitialRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllQUICInitialRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Quic initial rule defaults o k response +func (o *GetAllQUICInitialRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Quic initial rule defaults o k response +func (o *GetAllQUICInitialRuleDefaultsOK) WithPayload(payload models.QUICInitialRules) *GetAllQUICInitialRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Quic initial rule defaults o k response +func (o *GetAllQUICInitialRuleDefaultsOK) SetPayload(payload models.QUICInitialRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllQUICInitialRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.QUICInitialRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllQUICInitialRuleDefaultsDefault General Error + +swagger:response getAllQuicInitialRuleDefaultsDefault +*/ +type GetAllQUICInitialRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllQUICInitialRuleDefaultsDefault creates GetAllQUICInitialRuleDefaultsDefault with default headers values +func NewGetAllQUICInitialRuleDefaultsDefault(code int) *GetAllQUICInitialRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllQUICInitialRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all QUIC initial rule defaults default response +func (o *GetAllQUICInitialRuleDefaultsDefault) WithStatusCode(code int) *GetAllQUICInitialRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all QUIC initial rule defaults default response +func (o *GetAllQUICInitialRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all QUIC initial rule defaults default response +func (o *GetAllQUICInitialRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllQUICInitialRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all QUIC initial rule defaults default response +func (o *GetAllQUICInitialRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all QUIC initial rule defaults default response +func (o *GetAllQUICInitialRuleDefaultsDefault) WithPayload(payload *models.Error) *GetAllQUICInitialRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all QUIC initial rule defaults default response +func (o *GetAllQUICInitialRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllQUICInitialRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_urlbuilder.go b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..55b84b9e --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllQUICInitialRuleDefaultsURL generates an URL for the get all QUIC initial rule defaults operation +type GetAllQUICInitialRuleDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllQUICInitialRuleDefaultsURL) WithBasePath(bp string) *GetAllQUICInitialRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllQUICInitialRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllQUICInitialRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllQUICInitialRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllQUICInitialRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllQUICInitialRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllQUICInitialRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllQUICInitialRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllQUICInitialRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllQUICInitialRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_frontend.go b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend.go new file mode 100644 index 00000000..41e5357d --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllQUICInitialRuleFrontendHandlerFunc turns a function with the right signature into a get all QUIC initial rule frontend handler +type GetAllQUICInitialRuleFrontendHandlerFunc func(GetAllQUICInitialRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllQUICInitialRuleFrontendHandlerFunc) Handle(params GetAllQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllQUICInitialRuleFrontendHandler interface for that can handle valid get all QUIC initial rule frontend params +type GetAllQUICInitialRuleFrontendHandler interface { + Handle(GetAllQUICInitialRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllQUICInitialRuleFrontend creates a new http.Handler for the get all QUIC initial rule frontend operation +func NewGetAllQUICInitialRuleFrontend(ctx *middleware.Context, handler GetAllQUICInitialRuleFrontendHandler) *GetAllQUICInitialRuleFrontend { + return &GetAllQUICInitialRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllQUICInitialRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules QUICInitialRule getAllQuicInitialRuleFrontend + +# Return an array of all QUIC Initial rules + +Returns all QUIC Initial rules that are configured in specified parent. +*/ +type GetAllQUICInitialRuleFrontend struct { + Context *middleware.Context + Handler GetAllQUICInitialRuleFrontendHandler +} + +func (o *GetAllQUICInitialRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllQUICInitialRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_parameters.go b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_parameters.go new file mode 100644 index 00000000..c170f28f --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllQUICInitialRuleFrontendParams creates a new GetAllQUICInitialRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllQUICInitialRuleFrontendParams() GetAllQUICInitialRuleFrontendParams { + + return GetAllQUICInitialRuleFrontendParams{} +} + +// GetAllQUICInitialRuleFrontendParams contains all the bound params for the get all QUIC initial rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllQUICInitialRuleFrontend +type GetAllQUICInitialRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllQUICInitialRuleFrontendParams() beforehand. +func (o *GetAllQUICInitialRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllQUICInitialRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllQUICInitialRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_responses.go b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_responses.go new file mode 100644 index 00000000..51b2eaac --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllQUICInitialRuleFrontendOKCode is the HTTP code returned for type GetAllQUICInitialRuleFrontendOK +const GetAllQUICInitialRuleFrontendOKCode int = 200 + +/* +GetAllQUICInitialRuleFrontendOK Successful operation + +swagger:response getAllQuicInitialRuleFrontendOK +*/ +type GetAllQUICInitialRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.QUICInitialRules `json:"body,omitempty"` +} + +// NewGetAllQUICInitialRuleFrontendOK creates GetAllQUICInitialRuleFrontendOK with default headers values +func NewGetAllQUICInitialRuleFrontendOK() *GetAllQUICInitialRuleFrontendOK { + + return &GetAllQUICInitialRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Quic initial rule frontend o k response +func (o *GetAllQUICInitialRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllQUICInitialRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Quic initial rule frontend o k response +func (o *GetAllQUICInitialRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Quic initial rule frontend o k response +func (o *GetAllQUICInitialRuleFrontendOK) WithPayload(payload models.QUICInitialRules) *GetAllQUICInitialRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Quic initial rule frontend o k response +func (o *GetAllQUICInitialRuleFrontendOK) SetPayload(payload models.QUICInitialRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllQUICInitialRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.QUICInitialRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllQUICInitialRuleFrontendDefault General Error + +swagger:response getAllQuicInitialRuleFrontendDefault +*/ +type GetAllQUICInitialRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllQUICInitialRuleFrontendDefault creates GetAllQUICInitialRuleFrontendDefault with default headers values +func NewGetAllQUICInitialRuleFrontendDefault(code int) *GetAllQUICInitialRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllQUICInitialRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all QUIC initial rule frontend default response +func (o *GetAllQUICInitialRuleFrontendDefault) WithStatusCode(code int) *GetAllQUICInitialRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all QUIC initial rule frontend default response +func (o *GetAllQUICInitialRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all QUIC initial rule frontend default response +func (o *GetAllQUICInitialRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllQUICInitialRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all QUIC initial rule frontend default response +func (o *GetAllQUICInitialRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all QUIC initial rule frontend default response +func (o *GetAllQUICInitialRuleFrontendDefault) WithPayload(payload *models.Error) *GetAllQUICInitialRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all QUIC initial rule frontend default response +func (o *GetAllQUICInitialRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllQUICInitialRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_urlbuilder.go b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..4f46b047 --- /dev/null +++ b/operations/quic_initial_rule/get_all_quic_initial_rule_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllQUICInitialRuleFrontendURL generates an URL for the get all QUIC initial rule frontend operation +type GetAllQUICInitialRuleFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllQUICInitialRuleFrontendURL) WithBasePath(bp string) *GetAllQUICInitialRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllQUICInitialRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllQUICInitialRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllQUICInitialRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllQUICInitialRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllQUICInitialRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllQUICInitialRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllQUICInitialRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllQUICInitialRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllQUICInitialRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_defaults.go b/operations/quic_initial_rule/get_quic_initial_rule_defaults.go new file mode 100644 index 00000000..47e68c5a --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetQUICInitialRuleDefaultsHandlerFunc turns a function with the right signature into a get QUIC initial rule defaults handler +type GetQUICInitialRuleDefaultsHandlerFunc func(GetQUICInitialRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetQUICInitialRuleDefaultsHandlerFunc) Handle(params GetQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetQUICInitialRuleDefaultsHandler interface for that can handle valid get QUIC initial rule defaults params +type GetQUICInitialRuleDefaultsHandler interface { + Handle(GetQUICInitialRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetQUICInitialRuleDefaults creates a new http.Handler for the get QUIC initial rule defaults operation +func NewGetQUICInitialRuleDefaults(ctx *middleware.Context, handler GetQUICInitialRuleDefaultsHandler) *GetQUICInitialRuleDefaults { + return &GetQUICInitialRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetQUICInitialRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index} QUICInitialRule getQuicInitialRuleDefaults + +# Return one QUIC Initial Rule + +Returns one QUIC Initial Rule configuration by it's index in the specified parent. +*/ +type GetQUICInitialRuleDefaults struct { + Context *middleware.Context + Handler GetQUICInitialRuleDefaultsHandler +} + +func (o *GetQUICInitialRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetQUICInitialRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_defaults_parameters.go b/operations/quic_initial_rule/get_quic_initial_rule_defaults_parameters.go new file mode 100644 index 00000000..ce1a92c5 --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetQUICInitialRuleDefaultsParams creates a new GetQUICInitialRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetQUICInitialRuleDefaultsParams() GetQUICInitialRuleDefaultsParams { + + return GetQUICInitialRuleDefaultsParams{} +} + +// GetQUICInitialRuleDefaultsParams contains all the bound params for the get QUIC initial rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getQUICInitialRuleDefaults +type GetQUICInitialRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetQUICInitialRuleDefaultsParams() beforehand. +func (o *GetQUICInitialRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetQUICInitialRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetQUICInitialRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetQUICInitialRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_defaults_responses.go b/operations/quic_initial_rule/get_quic_initial_rule_defaults_responses.go new file mode 100644 index 00000000..73b676ee --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetQUICInitialRuleDefaultsOKCode is the HTTP code returned for type GetQUICInitialRuleDefaultsOK +const GetQUICInitialRuleDefaultsOKCode int = 200 + +/* +GetQUICInitialRuleDefaultsOK Successful operation + +swagger:response getQuicInitialRuleDefaultsOK +*/ +type GetQUICInitialRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewGetQUICInitialRuleDefaultsOK creates GetQUICInitialRuleDefaultsOK with default headers values +func NewGetQUICInitialRuleDefaultsOK() *GetQUICInitialRuleDefaultsOK { + + return &GetQUICInitialRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Quic initial rule defaults o k response +func (o *GetQUICInitialRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetQUICInitialRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Quic initial rule defaults o k response +func (o *GetQUICInitialRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Quic initial rule defaults o k response +func (o *GetQUICInitialRuleDefaultsOK) WithPayload(payload *models.QUICInitialRule) *GetQUICInitialRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Quic initial rule defaults o k response +func (o *GetQUICInitialRuleDefaultsOK) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQUICInitialRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetQUICInitialRuleDefaultsNotFoundCode is the HTTP code returned for type GetQUICInitialRuleDefaultsNotFound +const GetQUICInitialRuleDefaultsNotFoundCode int = 404 + +/* +GetQUICInitialRuleDefaultsNotFound The specified resource was not found + +swagger:response getQuicInitialRuleDefaultsNotFound +*/ +type GetQUICInitialRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetQUICInitialRuleDefaultsNotFound creates GetQUICInitialRuleDefaultsNotFound with default headers values +func NewGetQUICInitialRuleDefaultsNotFound() *GetQUICInitialRuleDefaultsNotFound { + + return &GetQUICInitialRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Quic initial rule defaults not found response +func (o *GetQUICInitialRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetQUICInitialRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Quic initial rule defaults not found response +func (o *GetQUICInitialRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Quic initial rule defaults not found response +func (o *GetQUICInitialRuleDefaultsNotFound) WithPayload(payload *models.Error) *GetQUICInitialRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Quic initial rule defaults not found response +func (o *GetQUICInitialRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQUICInitialRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetQUICInitialRuleDefaultsDefault General Error + +swagger:response getQuicInitialRuleDefaultsDefault +*/ +type GetQUICInitialRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetQUICInitialRuleDefaultsDefault creates GetQUICInitialRuleDefaultsDefault with default headers values +func NewGetQUICInitialRuleDefaultsDefault(code int) *GetQUICInitialRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetQUICInitialRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get QUIC initial rule defaults default response +func (o *GetQUICInitialRuleDefaultsDefault) WithStatusCode(code int) *GetQUICInitialRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get QUIC initial rule defaults default response +func (o *GetQUICInitialRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get QUIC initial rule defaults default response +func (o *GetQUICInitialRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetQUICInitialRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get QUIC initial rule defaults default response +func (o *GetQUICInitialRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get QUIC initial rule defaults default response +func (o *GetQUICInitialRuleDefaultsDefault) WithPayload(payload *models.Error) *GetQUICInitialRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get QUIC initial rule defaults default response +func (o *GetQUICInitialRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQUICInitialRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_defaults_urlbuilder.go b/operations/quic_initial_rule/get_quic_initial_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..4df678c8 --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetQUICInitialRuleDefaultsURL generates an URL for the get QUIC initial rule defaults operation +type GetQUICInitialRuleDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetQUICInitialRuleDefaultsURL) WithBasePath(bp string) *GetQUICInitialRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetQUICInitialRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetQUICInitialRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetQUICInitialRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetQUICInitialRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetQUICInitialRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetQUICInitialRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetQUICInitialRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetQUICInitialRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetQUICInitialRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetQUICInitialRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_frontend.go b/operations/quic_initial_rule/get_quic_initial_rule_frontend.go new file mode 100644 index 00000000..f6b7fb02 --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetQUICInitialRuleFrontendHandlerFunc turns a function with the right signature into a get QUIC initial rule frontend handler +type GetQUICInitialRuleFrontendHandlerFunc func(GetQUICInitialRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetQUICInitialRuleFrontendHandlerFunc) Handle(params GetQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetQUICInitialRuleFrontendHandler interface for that can handle valid get QUIC initial rule frontend params +type GetQUICInitialRuleFrontendHandler interface { + Handle(GetQUICInitialRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetQUICInitialRuleFrontend creates a new http.Handler for the get QUIC initial rule frontend operation +func NewGetQUICInitialRuleFrontend(ctx *middleware.Context, handler GetQUICInitialRuleFrontendHandler) *GetQUICInitialRuleFrontend { + return &GetQUICInitialRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetQUICInitialRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index} QUICInitialRule getQuicInitialRuleFrontend + +# Return one QUIC Initial Rule + +Returns one QUIC Initial Rule configuration by it's index in the specified parent. +*/ +type GetQUICInitialRuleFrontend struct { + Context *middleware.Context + Handler GetQUICInitialRuleFrontendHandler +} + +func (o *GetQUICInitialRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetQUICInitialRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_frontend_parameters.go b/operations/quic_initial_rule/get_quic_initial_rule_frontend_parameters.go new file mode 100644 index 00000000..23e63f55 --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetQUICInitialRuleFrontendParams creates a new GetQUICInitialRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetQUICInitialRuleFrontendParams() GetQUICInitialRuleFrontendParams { + + return GetQUICInitialRuleFrontendParams{} +} + +// GetQUICInitialRuleFrontendParams contains all the bound params for the get QUIC initial rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getQUICInitialRuleFrontend +type GetQUICInitialRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetQUICInitialRuleFrontendParams() beforehand. +func (o *GetQUICInitialRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetQUICInitialRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetQUICInitialRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetQUICInitialRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_frontend_responses.go b/operations/quic_initial_rule/get_quic_initial_rule_frontend_responses.go new file mode 100644 index 00000000..a2d3e292 --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetQUICInitialRuleFrontendOKCode is the HTTP code returned for type GetQUICInitialRuleFrontendOK +const GetQUICInitialRuleFrontendOKCode int = 200 + +/* +GetQUICInitialRuleFrontendOK Successful operation + +swagger:response getQuicInitialRuleFrontendOK +*/ +type GetQUICInitialRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewGetQUICInitialRuleFrontendOK creates GetQUICInitialRuleFrontendOK with default headers values +func NewGetQUICInitialRuleFrontendOK() *GetQUICInitialRuleFrontendOK { + + return &GetQUICInitialRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Quic initial rule frontend o k response +func (o *GetQUICInitialRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetQUICInitialRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Quic initial rule frontend o k response +func (o *GetQUICInitialRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Quic initial rule frontend o k response +func (o *GetQUICInitialRuleFrontendOK) WithPayload(payload *models.QUICInitialRule) *GetQUICInitialRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Quic initial rule frontend o k response +func (o *GetQUICInitialRuleFrontendOK) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQUICInitialRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetQUICInitialRuleFrontendNotFoundCode is the HTTP code returned for type GetQUICInitialRuleFrontendNotFound +const GetQUICInitialRuleFrontendNotFoundCode int = 404 + +/* +GetQUICInitialRuleFrontendNotFound The specified resource was not found + +swagger:response getQuicInitialRuleFrontendNotFound +*/ +type GetQUICInitialRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetQUICInitialRuleFrontendNotFound creates GetQUICInitialRuleFrontendNotFound with default headers values +func NewGetQUICInitialRuleFrontendNotFound() *GetQUICInitialRuleFrontendNotFound { + + return &GetQUICInitialRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Quic initial rule frontend not found response +func (o *GetQUICInitialRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetQUICInitialRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Quic initial rule frontend not found response +func (o *GetQUICInitialRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Quic initial rule frontend not found response +func (o *GetQUICInitialRuleFrontendNotFound) WithPayload(payload *models.Error) *GetQUICInitialRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Quic initial rule frontend not found response +func (o *GetQUICInitialRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQUICInitialRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetQUICInitialRuleFrontendDefault General Error + +swagger:response getQuicInitialRuleFrontendDefault +*/ +type GetQUICInitialRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetQUICInitialRuleFrontendDefault creates GetQUICInitialRuleFrontendDefault with default headers values +func NewGetQUICInitialRuleFrontendDefault(code int) *GetQUICInitialRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetQUICInitialRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get QUIC initial rule frontend default response +func (o *GetQUICInitialRuleFrontendDefault) WithStatusCode(code int) *GetQUICInitialRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get QUIC initial rule frontend default response +func (o *GetQUICInitialRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get QUIC initial rule frontend default response +func (o *GetQUICInitialRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetQUICInitialRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get QUIC initial rule frontend default response +func (o *GetQUICInitialRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get QUIC initial rule frontend default response +func (o *GetQUICInitialRuleFrontendDefault) WithPayload(payload *models.Error) *GetQUICInitialRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get QUIC initial rule frontend default response +func (o *GetQUICInitialRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetQUICInitialRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/get_quic_initial_rule_frontend_urlbuilder.go b/operations/quic_initial_rule/get_quic_initial_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..75fdae7f --- /dev/null +++ b/operations/quic_initial_rule/get_quic_initial_rule_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetQUICInitialRuleFrontendURL generates an URL for the get QUIC initial rule frontend operation +type GetQUICInitialRuleFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetQUICInitialRuleFrontendURL) WithBasePath(bp string) *GetQUICInitialRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetQUICInitialRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetQUICInitialRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetQUICInitialRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetQUICInitialRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetQUICInitialRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetQUICInitialRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetQUICInitialRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetQUICInitialRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetQUICInitialRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetQUICInitialRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults.go new file mode 100644 index 00000000..073f695d --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllQUICInitialRuleDefaultsHandlerFunc turns a function with the right signature into a replace all QUIC initial rule defaults handler +type ReplaceAllQUICInitialRuleDefaultsHandlerFunc func(ReplaceAllQUICInitialRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllQUICInitialRuleDefaultsHandlerFunc) Handle(params ReplaceAllQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllQUICInitialRuleDefaultsHandler interface for that can handle valid replace all QUIC initial rule defaults params +type ReplaceAllQUICInitialRuleDefaultsHandler interface { + Handle(ReplaceAllQUICInitialRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllQUICInitialRuleDefaults creates a new http.Handler for the replace all QUIC initial rule defaults operation +func NewReplaceAllQUICInitialRuleDefaults(ctx *middleware.Context, handler ReplaceAllQUICInitialRuleDefaultsHandler) *ReplaceAllQUICInitialRuleDefaults { + return &ReplaceAllQUICInitialRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllQUICInitialRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules QUICInitialRule replaceAllQuicInitialRuleDefaults + +# Replace an QUIC Initial rules list + +Replaces a whole list of QUIC Initial rules with the list given in parameter +*/ +type ReplaceAllQUICInitialRuleDefaults struct { + Context *middleware.Context + Handler ReplaceAllQUICInitialRuleDefaultsHandler +} + +func (o *ReplaceAllQUICInitialRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllQUICInitialRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_parameters.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_parameters.go new file mode 100644 index 00000000..f20ec7f3 --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllQUICInitialRuleDefaultsParams creates a new ReplaceAllQUICInitialRuleDefaultsParams object +// with the default values initialized. +func NewReplaceAllQUICInitialRuleDefaultsParams() ReplaceAllQUICInitialRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllQUICInitialRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllQUICInitialRuleDefaultsParams contains all the bound params for the replace all QUIC initial rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllQUICInitialRuleDefaults +type ReplaceAllQUICInitialRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.QUICInitialRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllQUICInitialRuleDefaultsParams() beforehand. +func (o *ReplaceAllQUICInitialRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.QUICInitialRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllQUICInitialRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllQUICInitialRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllQUICInitialRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllQUICInitialRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllQUICInitialRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_responses.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_responses.go new file mode 100644 index 00000000..995b2816 --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllQUICInitialRuleDefaultsOKCode is the HTTP code returned for type ReplaceAllQUICInitialRuleDefaultsOK +const ReplaceAllQUICInitialRuleDefaultsOKCode int = 200 + +/* +ReplaceAllQUICInitialRuleDefaultsOK All TTP After Response Rules lines replaced + +swagger:response replaceAllQuicInitialRuleDefaultsOK +*/ +type ReplaceAllQUICInitialRuleDefaultsOK struct { + + /* + In: Body + */ + Payload models.QUICInitialRules `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleDefaultsOK creates ReplaceAllQUICInitialRuleDefaultsOK with default headers values +func NewReplaceAllQUICInitialRuleDefaultsOK() *ReplaceAllQUICInitialRuleDefaultsOK { + + return &ReplaceAllQUICInitialRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Quic initial rule defaults o k response +func (o *ReplaceAllQUICInitialRuleDefaultsOK) WithPayload(payload models.QUICInitialRules) *ReplaceAllQUICInitialRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Quic initial rule defaults o k response +func (o *ReplaceAllQUICInitialRuleDefaultsOK) SetPayload(payload models.QUICInitialRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.QUICInitialRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllQUICInitialRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllQUICInitialRuleDefaultsAccepted +const ReplaceAllQUICInitialRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceAllQUICInitialRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllQuicInitialRuleDefaultsAccepted +*/ +type ReplaceAllQUICInitialRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.QUICInitialRules `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleDefaultsAccepted creates ReplaceAllQUICInitialRuleDefaultsAccepted with default headers values +func NewReplaceAllQUICInitialRuleDefaultsAccepted() *ReplaceAllQUICInitialRuleDefaultsAccepted { + + return &ReplaceAllQUICInitialRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Quic initial rule defaults accepted response +func (o *ReplaceAllQUICInitialRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllQUICInitialRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Quic initial rule defaults accepted response +func (o *ReplaceAllQUICInitialRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Quic initial rule defaults accepted response +func (o *ReplaceAllQUICInitialRuleDefaultsAccepted) WithPayload(payload models.QUICInitialRules) *ReplaceAllQUICInitialRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Quic initial rule defaults accepted response +func (o *ReplaceAllQUICInitialRuleDefaultsAccepted) SetPayload(payload models.QUICInitialRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.QUICInitialRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllQUICInitialRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllQUICInitialRuleDefaultsBadRequest +const ReplaceAllQUICInitialRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceAllQUICInitialRuleDefaultsBadRequest Bad request + +swagger:response replaceAllQuicInitialRuleDefaultsBadRequest +*/ +type ReplaceAllQUICInitialRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleDefaultsBadRequest creates ReplaceAllQUICInitialRuleDefaultsBadRequest with default headers values +func NewReplaceAllQUICInitialRuleDefaultsBadRequest() *ReplaceAllQUICInitialRuleDefaultsBadRequest { + + return &ReplaceAllQUICInitialRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Quic initial rule defaults bad request response +func (o *ReplaceAllQUICInitialRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllQUICInitialRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Quic initial rule defaults bad request response +func (o *ReplaceAllQUICInitialRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Quic initial rule defaults bad request response +func (o *ReplaceAllQUICInitialRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllQUICInitialRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Quic initial rule defaults bad request response +func (o *ReplaceAllQUICInitialRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllQUICInitialRuleDefaultsDefault General Error + +swagger:response replaceAllQuicInitialRuleDefaultsDefault +*/ +type ReplaceAllQUICInitialRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleDefaultsDefault creates ReplaceAllQUICInitialRuleDefaultsDefault with default headers values +func NewReplaceAllQUICInitialRuleDefaultsDefault(code int) *ReplaceAllQUICInitialRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllQUICInitialRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all QUIC initial rule defaults default response +func (o *ReplaceAllQUICInitialRuleDefaultsDefault) WithStatusCode(code int) *ReplaceAllQUICInitialRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all QUIC initial rule defaults default response +func (o *ReplaceAllQUICInitialRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all QUIC initial rule defaults default response +func (o *ReplaceAllQUICInitialRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllQUICInitialRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all QUIC initial rule defaults default response +func (o *ReplaceAllQUICInitialRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all QUIC initial rule defaults default response +func (o *ReplaceAllQUICInitialRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllQUICInitialRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all QUIC initial rule defaults default response +func (o *ReplaceAllQUICInitialRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_urlbuilder.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..efcffd87 --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllQUICInitialRuleDefaultsURL generates an URL for the replace all QUIC initial rule defaults operation +type ReplaceAllQUICInitialRuleDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllQUICInitialRuleDefaultsURL) WithBasePath(bp string) *ReplaceAllQUICInitialRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllQUICInitialRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllQUICInitialRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllQUICInitialRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllQUICInitialRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllQUICInitialRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllQUICInitialRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllQUICInitialRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllQUICInitialRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllQUICInitialRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend.go new file mode 100644 index 00000000..45c79cf9 --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllQUICInitialRuleFrontendHandlerFunc turns a function with the right signature into a replace all QUIC initial rule frontend handler +type ReplaceAllQUICInitialRuleFrontendHandlerFunc func(ReplaceAllQUICInitialRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllQUICInitialRuleFrontendHandlerFunc) Handle(params ReplaceAllQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllQUICInitialRuleFrontendHandler interface for that can handle valid replace all QUIC initial rule frontend params +type ReplaceAllQUICInitialRuleFrontendHandler interface { + Handle(ReplaceAllQUICInitialRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllQUICInitialRuleFrontend creates a new http.Handler for the replace all QUIC initial rule frontend operation +func NewReplaceAllQUICInitialRuleFrontend(ctx *middleware.Context, handler ReplaceAllQUICInitialRuleFrontendHandler) *ReplaceAllQUICInitialRuleFrontend { + return &ReplaceAllQUICInitialRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllQUICInitialRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules QUICInitialRule replaceAllQuicInitialRuleFrontend + +# Replace an QUIC Initial rules list + +Replaces a whole list of QUIC Initial rules with the list given in parameter +*/ +type ReplaceAllQUICInitialRuleFrontend struct { + Context *middleware.Context + Handler ReplaceAllQUICInitialRuleFrontendHandler +} + +func (o *ReplaceAllQUICInitialRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllQUICInitialRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_parameters.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_parameters.go new file mode 100644 index 00000000..f79b9fca --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllQUICInitialRuleFrontendParams creates a new ReplaceAllQUICInitialRuleFrontendParams object +// with the default values initialized. +func NewReplaceAllQUICInitialRuleFrontendParams() ReplaceAllQUICInitialRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllQUICInitialRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllQUICInitialRuleFrontendParams contains all the bound params for the replace all QUIC initial rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllQUICInitialRuleFrontend +type ReplaceAllQUICInitialRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.QUICInitialRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllQUICInitialRuleFrontendParams() beforehand. +func (o *ReplaceAllQUICInitialRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.QUICInitialRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllQUICInitialRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllQUICInitialRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllQUICInitialRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllQUICInitialRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllQUICInitialRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_responses.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_responses.go new file mode 100644 index 00000000..d7da4873 --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllQUICInitialRuleFrontendOKCode is the HTTP code returned for type ReplaceAllQUICInitialRuleFrontendOK +const ReplaceAllQUICInitialRuleFrontendOKCode int = 200 + +/* +ReplaceAllQUICInitialRuleFrontendOK All TTP After Response Rules lines replaced + +swagger:response replaceAllQuicInitialRuleFrontendOK +*/ +type ReplaceAllQUICInitialRuleFrontendOK struct { + + /* + In: Body + */ + Payload models.QUICInitialRules `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleFrontendOK creates ReplaceAllQUICInitialRuleFrontendOK with default headers values +func NewReplaceAllQUICInitialRuleFrontendOK() *ReplaceAllQUICInitialRuleFrontendOK { + + return &ReplaceAllQUICInitialRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace all Quic initial rule frontend o k response +func (o *ReplaceAllQUICInitialRuleFrontendOK) WithPayload(payload models.QUICInitialRules) *ReplaceAllQUICInitialRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Quic initial rule frontend o k response +func (o *ReplaceAllQUICInitialRuleFrontendOK) SetPayload(payload models.QUICInitialRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.QUICInitialRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllQUICInitialRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceAllQUICInitialRuleFrontendAccepted +const ReplaceAllQUICInitialRuleFrontendAcceptedCode int = 202 + +/* +ReplaceAllQUICInitialRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllQuicInitialRuleFrontendAccepted +*/ +type ReplaceAllQUICInitialRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.QUICInitialRules `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleFrontendAccepted creates ReplaceAllQUICInitialRuleFrontendAccepted with default headers values +func NewReplaceAllQUICInitialRuleFrontendAccepted() *ReplaceAllQUICInitialRuleFrontendAccepted { + + return &ReplaceAllQUICInitialRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Quic initial rule frontend accepted response +func (o *ReplaceAllQUICInitialRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllQUICInitialRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Quic initial rule frontend accepted response +func (o *ReplaceAllQUICInitialRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Quic initial rule frontend accepted response +func (o *ReplaceAllQUICInitialRuleFrontendAccepted) WithPayload(payload models.QUICInitialRules) *ReplaceAllQUICInitialRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Quic initial rule frontend accepted response +func (o *ReplaceAllQUICInitialRuleFrontendAccepted) SetPayload(payload models.QUICInitialRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.QUICInitialRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllQUICInitialRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceAllQUICInitialRuleFrontendBadRequest +const ReplaceAllQUICInitialRuleFrontendBadRequestCode int = 400 + +/* +ReplaceAllQUICInitialRuleFrontendBadRequest Bad request + +swagger:response replaceAllQuicInitialRuleFrontendBadRequest +*/ +type ReplaceAllQUICInitialRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleFrontendBadRequest creates ReplaceAllQUICInitialRuleFrontendBadRequest with default headers values +func NewReplaceAllQUICInitialRuleFrontendBadRequest() *ReplaceAllQUICInitialRuleFrontendBadRequest { + + return &ReplaceAllQUICInitialRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Quic initial rule frontend bad request response +func (o *ReplaceAllQUICInitialRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllQUICInitialRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Quic initial rule frontend bad request response +func (o *ReplaceAllQUICInitialRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Quic initial rule frontend bad request response +func (o *ReplaceAllQUICInitialRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllQUICInitialRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Quic initial rule frontend bad request response +func (o *ReplaceAllQUICInitialRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllQUICInitialRuleFrontendDefault General Error + +swagger:response replaceAllQuicInitialRuleFrontendDefault +*/ +type ReplaceAllQUICInitialRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllQUICInitialRuleFrontendDefault creates ReplaceAllQUICInitialRuleFrontendDefault with default headers values +func NewReplaceAllQUICInitialRuleFrontendDefault(code int) *ReplaceAllQUICInitialRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllQUICInitialRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all QUIC initial rule frontend default response +func (o *ReplaceAllQUICInitialRuleFrontendDefault) WithStatusCode(code int) *ReplaceAllQUICInitialRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all QUIC initial rule frontend default response +func (o *ReplaceAllQUICInitialRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all QUIC initial rule frontend default response +func (o *ReplaceAllQUICInitialRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllQUICInitialRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all QUIC initial rule frontend default response +func (o *ReplaceAllQUICInitialRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all QUIC initial rule frontend default response +func (o *ReplaceAllQUICInitialRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllQUICInitialRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all QUIC initial rule frontend default response +func (o *ReplaceAllQUICInitialRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllQUICInitialRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_urlbuilder.go b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..efd6e300 --- /dev/null +++ b/operations/quic_initial_rule/replace_all_quic_initial_rule_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllQUICInitialRuleFrontendURL generates an URL for the replace all QUIC initial rule frontend operation +type ReplaceAllQUICInitialRuleFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllQUICInitialRuleFrontendURL) WithBasePath(bp string) *ReplaceAllQUICInitialRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllQUICInitialRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllQUICInitialRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllQUICInitialRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllQUICInitialRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllQUICInitialRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllQUICInitialRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllQUICInitialRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllQUICInitialRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllQUICInitialRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_defaults.go b/operations/quic_initial_rule/replace_quic_initial_rule_defaults.go new file mode 100644 index 00000000..bc0582e9 --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceQUICInitialRuleDefaultsHandlerFunc turns a function with the right signature into a replace QUIC initial rule defaults handler +type ReplaceQUICInitialRuleDefaultsHandlerFunc func(ReplaceQUICInitialRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceQUICInitialRuleDefaultsHandlerFunc) Handle(params ReplaceQUICInitialRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceQUICInitialRuleDefaultsHandler interface for that can handle valid replace QUIC initial rule defaults params +type ReplaceQUICInitialRuleDefaultsHandler interface { + Handle(ReplaceQUICInitialRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceQUICInitialRuleDefaults creates a new http.Handler for the replace QUIC initial rule defaults operation +func NewReplaceQUICInitialRuleDefaults(ctx *middleware.Context, handler ReplaceQUICInitialRuleDefaultsHandler) *ReplaceQUICInitialRuleDefaults { + return &ReplaceQUICInitialRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceQUICInitialRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index} QUICInitialRule replaceQuicInitialRuleDefaults + +# Replace a QUIC Initial Rule + +Replaces a QUIC Initial Rule configuration by it's index in the specified parent. +*/ +type ReplaceQUICInitialRuleDefaults struct { + Context *middleware.Context + Handler ReplaceQUICInitialRuleDefaultsHandler +} + +func (o *ReplaceQUICInitialRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceQUICInitialRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_defaults_parameters.go b/operations/quic_initial_rule/replace_quic_initial_rule_defaults_parameters.go new file mode 100644 index 00000000..b75eb5ec --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceQUICInitialRuleDefaultsParams creates a new ReplaceQUICInitialRuleDefaultsParams object +// with the default values initialized. +func NewReplaceQUICInitialRuleDefaultsParams() ReplaceQUICInitialRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceQUICInitialRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceQUICInitialRuleDefaultsParams contains all the bound params for the replace QUIC initial rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceQUICInitialRuleDefaults +type ReplaceQUICInitialRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.QUICInitialRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceQUICInitialRuleDefaultsParams() beforehand. +func (o *ReplaceQUICInitialRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.QUICInitialRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceQUICInitialRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceQUICInitialRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceQUICInitialRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceQUICInitialRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceQUICInitialRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceQUICInitialRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_defaults_responses.go b/operations/quic_initial_rule/replace_quic_initial_rule_defaults_responses.go new file mode 100644 index 00000000..0cc5661d --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceQUICInitialRuleDefaultsOKCode is the HTTP code returned for type ReplaceQUICInitialRuleDefaultsOK +const ReplaceQUICInitialRuleDefaultsOKCode int = 200 + +/* +ReplaceQUICInitialRuleDefaultsOK QUIC Initial Rule replaced + +swagger:response replaceQuicInitialRuleDefaultsOK +*/ +type ReplaceQUICInitialRuleDefaultsOK struct { + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleDefaultsOK creates ReplaceQUICInitialRuleDefaultsOK with default headers values +func NewReplaceQUICInitialRuleDefaultsOK() *ReplaceQUICInitialRuleDefaultsOK { + + return &ReplaceQUICInitialRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace Quic initial rule defaults o k response +func (o *ReplaceQUICInitialRuleDefaultsOK) WithPayload(payload *models.QUICInitialRule) *ReplaceQUICInitialRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule defaults o k response +func (o *ReplaceQUICInitialRuleDefaultsOK) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceQUICInitialRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceQUICInitialRuleDefaultsAccepted +const ReplaceQUICInitialRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceQUICInitialRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceQuicInitialRuleDefaultsAccepted +*/ +type ReplaceQUICInitialRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleDefaultsAccepted creates ReplaceQUICInitialRuleDefaultsAccepted with default headers values +func NewReplaceQUICInitialRuleDefaultsAccepted() *ReplaceQUICInitialRuleDefaultsAccepted { + + return &ReplaceQUICInitialRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Quic initial rule defaults accepted response +func (o *ReplaceQUICInitialRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceQUICInitialRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Quic initial rule defaults accepted response +func (o *ReplaceQUICInitialRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Quic initial rule defaults accepted response +func (o *ReplaceQUICInitialRuleDefaultsAccepted) WithPayload(payload *models.QUICInitialRule) *ReplaceQUICInitialRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule defaults accepted response +func (o *ReplaceQUICInitialRuleDefaultsAccepted) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceQUICInitialRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceQUICInitialRuleDefaultsBadRequest +const ReplaceQUICInitialRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceQUICInitialRuleDefaultsBadRequest Bad request + +swagger:response replaceQuicInitialRuleDefaultsBadRequest +*/ +type ReplaceQUICInitialRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleDefaultsBadRequest creates ReplaceQUICInitialRuleDefaultsBadRequest with default headers values +func NewReplaceQUICInitialRuleDefaultsBadRequest() *ReplaceQUICInitialRuleDefaultsBadRequest { + + return &ReplaceQUICInitialRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Quic initial rule defaults bad request response +func (o *ReplaceQUICInitialRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceQUICInitialRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Quic initial rule defaults bad request response +func (o *ReplaceQUICInitialRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Quic initial rule defaults bad request response +func (o *ReplaceQUICInitialRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceQUICInitialRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule defaults bad request response +func (o *ReplaceQUICInitialRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceQUICInitialRuleDefaultsNotFoundCode is the HTTP code returned for type ReplaceQUICInitialRuleDefaultsNotFound +const ReplaceQUICInitialRuleDefaultsNotFoundCode int = 404 + +/* +ReplaceQUICInitialRuleDefaultsNotFound The specified resource was not found + +swagger:response replaceQuicInitialRuleDefaultsNotFound +*/ +type ReplaceQUICInitialRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleDefaultsNotFound creates ReplaceQUICInitialRuleDefaultsNotFound with default headers values +func NewReplaceQUICInitialRuleDefaultsNotFound() *ReplaceQUICInitialRuleDefaultsNotFound { + + return &ReplaceQUICInitialRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Quic initial rule defaults not found response +func (o *ReplaceQUICInitialRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceQUICInitialRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Quic initial rule defaults not found response +func (o *ReplaceQUICInitialRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Quic initial rule defaults not found response +func (o *ReplaceQUICInitialRuleDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceQUICInitialRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule defaults not found response +func (o *ReplaceQUICInitialRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceQUICInitialRuleDefaultsDefault General Error + +swagger:response replaceQuicInitialRuleDefaultsDefault +*/ +type ReplaceQUICInitialRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleDefaultsDefault creates ReplaceQUICInitialRuleDefaultsDefault with default headers values +func NewReplaceQUICInitialRuleDefaultsDefault(code int) *ReplaceQUICInitialRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceQUICInitialRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace QUIC initial rule defaults default response +func (o *ReplaceQUICInitialRuleDefaultsDefault) WithStatusCode(code int) *ReplaceQUICInitialRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace QUIC initial rule defaults default response +func (o *ReplaceQUICInitialRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace QUIC initial rule defaults default response +func (o *ReplaceQUICInitialRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceQUICInitialRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace QUIC initial rule defaults default response +func (o *ReplaceQUICInitialRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace QUIC initial rule defaults default response +func (o *ReplaceQUICInitialRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceQUICInitialRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace QUIC initial rule defaults default response +func (o *ReplaceQUICInitialRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_defaults_urlbuilder.go b/operations/quic_initial_rule/replace_quic_initial_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..b4211dbf --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceQUICInitialRuleDefaultsURL generates an URL for the replace QUIC initial rule defaults operation +type ReplaceQUICInitialRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceQUICInitialRuleDefaultsURL) WithBasePath(bp string) *ReplaceQUICInitialRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceQUICInitialRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceQUICInitialRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceQUICInitialRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceQUICInitialRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceQUICInitialRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceQUICInitialRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceQUICInitialRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceQUICInitialRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceQUICInitialRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceQUICInitialRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_frontend.go b/operations/quic_initial_rule/replace_quic_initial_rule_frontend.go new file mode 100644 index 00000000..8a986a08 --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceQUICInitialRuleFrontendHandlerFunc turns a function with the right signature into a replace QUIC initial rule frontend handler +type ReplaceQUICInitialRuleFrontendHandlerFunc func(ReplaceQUICInitialRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceQUICInitialRuleFrontendHandlerFunc) Handle(params ReplaceQUICInitialRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceQUICInitialRuleFrontendHandler interface for that can handle valid replace QUIC initial rule frontend params +type ReplaceQUICInitialRuleFrontendHandler interface { + Handle(ReplaceQUICInitialRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceQUICInitialRuleFrontend creates a new http.Handler for the replace QUIC initial rule frontend operation +func NewReplaceQUICInitialRuleFrontend(ctx *middleware.Context, handler ReplaceQUICInitialRuleFrontendHandler) *ReplaceQUICInitialRuleFrontend { + return &ReplaceQUICInitialRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceQUICInitialRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index} QUICInitialRule replaceQuicInitialRuleFrontend + +# Replace a QUIC Initial Rule + +Replaces a QUIC Initial Rule configuration by it's index in the specified parent. +*/ +type ReplaceQUICInitialRuleFrontend struct { + Context *middleware.Context + Handler ReplaceQUICInitialRuleFrontendHandler +} + +func (o *ReplaceQUICInitialRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceQUICInitialRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_frontend_parameters.go b/operations/quic_initial_rule/replace_quic_initial_rule_frontend_parameters.go new file mode 100644 index 00000000..fc787cc3 --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceQUICInitialRuleFrontendParams creates a new ReplaceQUICInitialRuleFrontendParams object +// with the default values initialized. +func NewReplaceQUICInitialRuleFrontendParams() ReplaceQUICInitialRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceQUICInitialRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceQUICInitialRuleFrontendParams contains all the bound params for the replace QUIC initial rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceQUICInitialRuleFrontend +type ReplaceQUICInitialRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.QUICInitialRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*QUIC Initial Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceQUICInitialRuleFrontendParams() beforehand. +func (o *ReplaceQUICInitialRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.QUICInitialRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceQUICInitialRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceQUICInitialRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceQUICInitialRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceQUICInitialRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceQUICInitialRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceQUICInitialRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_frontend_responses.go b/operations/quic_initial_rule/replace_quic_initial_rule_frontend_responses.go new file mode 100644 index 00000000..bc0440cd --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceQUICInitialRuleFrontendOKCode is the HTTP code returned for type ReplaceQUICInitialRuleFrontendOK +const ReplaceQUICInitialRuleFrontendOKCode int = 200 + +/* +ReplaceQUICInitialRuleFrontendOK QUIC Initial Rule replaced + +swagger:response replaceQuicInitialRuleFrontendOK +*/ +type ReplaceQUICInitialRuleFrontendOK struct { + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleFrontendOK creates ReplaceQUICInitialRuleFrontendOK with default headers values +func NewReplaceQUICInitialRuleFrontendOK() *ReplaceQUICInitialRuleFrontendOK { + + return &ReplaceQUICInitialRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace Quic initial rule frontend o k response +func (o *ReplaceQUICInitialRuleFrontendOK) WithPayload(payload *models.QUICInitialRule) *ReplaceQUICInitialRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule frontend o k response +func (o *ReplaceQUICInitialRuleFrontendOK) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceQUICInitialRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceQUICInitialRuleFrontendAccepted +const ReplaceQUICInitialRuleFrontendAcceptedCode int = 202 + +/* +ReplaceQUICInitialRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceQuicInitialRuleFrontendAccepted +*/ +type ReplaceQUICInitialRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.QUICInitialRule `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleFrontendAccepted creates ReplaceQUICInitialRuleFrontendAccepted with default headers values +func NewReplaceQUICInitialRuleFrontendAccepted() *ReplaceQUICInitialRuleFrontendAccepted { + + return &ReplaceQUICInitialRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Quic initial rule frontend accepted response +func (o *ReplaceQUICInitialRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceQUICInitialRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Quic initial rule frontend accepted response +func (o *ReplaceQUICInitialRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Quic initial rule frontend accepted response +func (o *ReplaceQUICInitialRuleFrontendAccepted) WithPayload(payload *models.QUICInitialRule) *ReplaceQUICInitialRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule frontend accepted response +func (o *ReplaceQUICInitialRuleFrontendAccepted) SetPayload(payload *models.QUICInitialRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceQUICInitialRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceQUICInitialRuleFrontendBadRequest +const ReplaceQUICInitialRuleFrontendBadRequestCode int = 400 + +/* +ReplaceQUICInitialRuleFrontendBadRequest Bad request + +swagger:response replaceQuicInitialRuleFrontendBadRequest +*/ +type ReplaceQUICInitialRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleFrontendBadRequest creates ReplaceQUICInitialRuleFrontendBadRequest with default headers values +func NewReplaceQUICInitialRuleFrontendBadRequest() *ReplaceQUICInitialRuleFrontendBadRequest { + + return &ReplaceQUICInitialRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Quic initial rule frontend bad request response +func (o *ReplaceQUICInitialRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceQUICInitialRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Quic initial rule frontend bad request response +func (o *ReplaceQUICInitialRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Quic initial rule frontend bad request response +func (o *ReplaceQUICInitialRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceQUICInitialRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule frontend bad request response +func (o *ReplaceQUICInitialRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceQUICInitialRuleFrontendNotFoundCode is the HTTP code returned for type ReplaceQUICInitialRuleFrontendNotFound +const ReplaceQUICInitialRuleFrontendNotFoundCode int = 404 + +/* +ReplaceQUICInitialRuleFrontendNotFound The specified resource was not found + +swagger:response replaceQuicInitialRuleFrontendNotFound +*/ +type ReplaceQUICInitialRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleFrontendNotFound creates ReplaceQUICInitialRuleFrontendNotFound with default headers values +func NewReplaceQUICInitialRuleFrontendNotFound() *ReplaceQUICInitialRuleFrontendNotFound { + + return &ReplaceQUICInitialRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Quic initial rule frontend not found response +func (o *ReplaceQUICInitialRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceQUICInitialRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Quic initial rule frontend not found response +func (o *ReplaceQUICInitialRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Quic initial rule frontend not found response +func (o *ReplaceQUICInitialRuleFrontendNotFound) WithPayload(payload *models.Error) *ReplaceQUICInitialRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Quic initial rule frontend not found response +func (o *ReplaceQUICInitialRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceQUICInitialRuleFrontendDefault General Error + +swagger:response replaceQuicInitialRuleFrontendDefault +*/ +type ReplaceQUICInitialRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceQUICInitialRuleFrontendDefault creates ReplaceQUICInitialRuleFrontendDefault with default headers values +func NewReplaceQUICInitialRuleFrontendDefault(code int) *ReplaceQUICInitialRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceQUICInitialRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace QUIC initial rule frontend default response +func (o *ReplaceQUICInitialRuleFrontendDefault) WithStatusCode(code int) *ReplaceQUICInitialRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace QUIC initial rule frontend default response +func (o *ReplaceQUICInitialRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace QUIC initial rule frontend default response +func (o *ReplaceQUICInitialRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceQUICInitialRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace QUIC initial rule frontend default response +func (o *ReplaceQUICInitialRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace QUIC initial rule frontend default response +func (o *ReplaceQUICInitialRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceQUICInitialRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace QUIC initial rule frontend default response +func (o *ReplaceQUICInitialRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceQUICInitialRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/quic_initial_rule/replace_quic_initial_rule_frontend_urlbuilder.go b/operations/quic_initial_rule/replace_quic_initial_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..f1c0e21a --- /dev/null +++ b/operations/quic_initial_rule/replace_quic_initial_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package quic_initial_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceQUICInitialRuleFrontendURL generates an URL for the replace QUIC initial rule frontend operation +type ReplaceQUICInitialRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceQUICInitialRuleFrontendURL) WithBasePath(bp string) *ReplaceQUICInitialRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceQUICInitialRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceQUICInitialRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/quic_initial_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceQUICInitialRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceQUICInitialRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceQUICInitialRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceQUICInitialRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceQUICInitialRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceQUICInitialRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceQUICInitialRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceQUICInitialRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/reloads/get_reload.go b/operations/reloads/get_reload.go index bbd954d7..61401e83 100644 --- a/operations/reloads/get_reload.go +++ b/operations/reloads/get_reload.go @@ -23,7 +23,7 @@ package reloads import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetReloadHandlerFunc turns a function with the right signature into a get reload handler @@ -44,12 +44,12 @@ func NewGetReload(ctx *middleware.Context, handler GetReloadHandler) *GetReload return &GetReload{Context: ctx, Handler: handler} } -/*GetReload swagger:route GET /services/haproxy/reloads/{id} Reloads getReload +/* + GetReload swagger:route GET /services/haproxy/reloads/{id} Reloads getReload -Return one HAProxy reload status +# Return one HAProxy reload status Returns one HAProxy reload status. - */ type GetReload struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetReload struct { func (o *GetReload) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetReloadParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetReload) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/reloads/get_reload_parameters.go b/operations/reloads/get_reload_parameters.go index 6cfb4998..bf3393fc 100644 --- a/operations/reloads/get_reload_parameters.go +++ b/operations/reloads/get_reload_parameters.go @@ -25,13 +25,13 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewGetReloadParams creates a new GetReloadParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetReloadParams() GetReloadParams { return GetReloadParams{} @@ -67,7 +67,6 @@ func (o *GetReloadParams) BindRequest(r *http.Request, route *middleware.Matched if err := o.bindID(rID, rhkID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -83,7 +82,6 @@ func (o *GetReloadParams) bindID(rawData []string, hasKey bool, formats strfmt.R // Required: true // Parameter is provided by construction from the route - o.ID = raw if err := o.validateID(formats); err != nil { diff --git a/operations/reloads/get_reload_responses.go b/operations/reloads/get_reload_responses.go index 2b683396..b517beae 100644 --- a/operations/reloads/get_reload_responses.go +++ b/operations/reloads/get_reload_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetReloadOKCode is the HTTP code returned for type GetReloadOK const GetReloadOKCode int = 200 -/*GetReloadOK Successful operation +/* +GetReloadOK Successful operation swagger:response getReloadOK */ @@ -76,7 +76,8 @@ func (o *GetReloadOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pro // GetReloadNotFoundCode is the HTTP code returned for type GetReloadNotFound const GetReloadNotFoundCode int = 404 -/*GetReloadNotFound The specified resource was not found +/* +GetReloadNotFound The specified resource was not found swagger:response getReloadNotFound */ @@ -84,7 +85,7 @@ type GetReloadNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -99,13 +100,13 @@ func NewGetReloadNotFound() *GetReloadNotFound { } // WithConfigurationVersion adds the configurationVersion to the get reload not found response -func (o *GetReloadNotFound) WithConfigurationVersion(configurationVersion int64) *GetReloadNotFound { +func (o *GetReloadNotFound) WithConfigurationVersion(configurationVersion string) *GetReloadNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get reload not found response -func (o *GetReloadNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetReloadNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -125,7 +126,7 @@ func (o *GetReloadNotFound) WriteResponse(rw http.ResponseWriter, producer runti // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -139,7 +140,8 @@ func (o *GetReloadNotFound) WriteResponse(rw http.ResponseWriter, producer runti } } -/*GetReloadDefault General Error +/* +GetReloadDefault General Error swagger:response getReloadDefault */ @@ -148,7 +150,7 @@ type GetReloadDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -179,13 +181,13 @@ func (o *GetReloadDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get reload default response -func (o *GetReloadDefault) WithConfigurationVersion(configurationVersion int64) *GetReloadDefault { +func (o *GetReloadDefault) WithConfigurationVersion(configurationVersion string) *GetReloadDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get reload default response -func (o *GetReloadDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetReloadDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -205,7 +207,7 @@ func (o *GetReloadDefault) WriteResponse(rw http.ResponseWriter, producer runtim // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/reloads/get_reload_urlbuilder.go b/operations/reloads/get_reload_urlbuilder.go index 2fbac31c..54dc0f0e 100644 --- a/operations/reloads/get_reload_urlbuilder.go +++ b/operations/reloads/get_reload_urlbuilder.go @@ -66,7 +66,7 @@ func (o *GetReloadURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/reloads/get_reloads.go b/operations/reloads/get_reloads.go index 7856e0e9..8151af9d 100644 --- a/operations/reloads/get_reloads.go +++ b/operations/reloads/get_reloads.go @@ -23,7 +23,7 @@ package reloads import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetReloadsHandlerFunc turns a function with the right signature into a get reloads handler @@ -44,12 +44,12 @@ func NewGetReloads(ctx *middleware.Context, handler GetReloadsHandler) *GetReloa return &GetReloads{Context: ctx, Handler: handler} } -/*GetReloads swagger:route GET /services/haproxy/reloads Reloads getReloads +/* + GetReloads swagger:route GET /services/haproxy/reloads Reloads getReloads Return list of HAProxy Reloads. Returns a list of HAProxy reloads. - */ type GetReloads struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetReloads struct { func (o *GetReloads) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetReloadsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetReloads) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/reloads/get_reloads_parameters.go b/operations/reloads/get_reloads_parameters.go index 8517fd57..677d27d8 100644 --- a/operations/reloads/get_reloads_parameters.go +++ b/operations/reloads/get_reloads_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetReloadsParams creates a new GetReloadsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetReloadsParams() GetReloadsParams { return GetReloadsParams{} diff --git a/operations/reloads/get_reloads_responses.go b/operations/reloads/get_reloads_responses.go index 38e90bb4..5db1e148 100644 --- a/operations/reloads/get_reloads_responses.go +++ b/operations/reloads/get_reloads_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetReloadsOKCode is the HTTP code returned for type GetReloadsOK const GetReloadsOKCode int = 200 -/*GetReloadsOK Success +/* +GetReloadsOK Success swagger:response getReloadsOK */ @@ -76,7 +76,8 @@ func (o *GetReloadsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pr } } -/*GetReloadsDefault General Error +/* +GetReloadsDefault General Error swagger:response getReloadsDefault */ @@ -85,7 +86,7 @@ type GetReloadsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -116,13 +117,13 @@ func (o *GetReloadsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get reloads default response -func (o *GetReloadsDefault) WithConfigurationVersion(configurationVersion int64) *GetReloadsDefault { +func (o *GetReloadsDefault) WithConfigurationVersion(configurationVersion string) *GetReloadsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get reloads default response -func (o *GetReloadsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetReloadsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -142,7 +143,7 @@ func (o *GetReloadsDefault) WriteResponse(rw http.ResponseWriter, producer runti // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/reloads/get_reloads_urlbuilder.go b/operations/reloads/get_reloads_urlbuilder.go index dc762c15..80c592e4 100644 --- a/operations/reloads/get_reloads_urlbuilder.go +++ b/operations/reloads/get_reloads_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetReloadsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/resolver/create_resolver.go b/operations/resolver/create_resolver.go new file mode 100644 index 00000000..c0dd9538 --- /dev/null +++ b/operations/resolver/create_resolver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateResolverHandlerFunc turns a function with the right signature into a create resolver handler +type CreateResolverHandlerFunc func(CreateResolverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateResolverHandlerFunc) Handle(params CreateResolverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateResolverHandler interface for that can handle valid create resolver params +type CreateResolverHandler interface { + Handle(CreateResolverParams, interface{}) middleware.Responder +} + +// NewCreateResolver creates a new http.Handler for the create resolver operation +func NewCreateResolver(ctx *middleware.Context, handler CreateResolverHandler) *CreateResolver { + return &CreateResolver{Context: ctx, Handler: handler} +} + +/* + CreateResolver swagger:route POST /services/haproxy/configuration/resolvers Resolver createResolver + +# Add a resolver + +Adds a new resolver section to the configuration file. +*/ +type CreateResolver struct { + Context *middleware.Context + Handler CreateResolverHandler +} + +func (o *CreateResolver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateResolverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/resolver/create_resolver_parameters.go b/operations/resolver/create_resolver_parameters.go new file mode 100644 index 00000000..50970553 --- /dev/null +++ b/operations/resolver/create_resolver_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateResolverParams creates a new CreateResolverParams object +// with the default values initialized. +func NewCreateResolverParams() CreateResolverParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreateResolverParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreateResolverParams contains all the bound params for the create resolver operation +// typically these are obtained from a http.Request +// +// swagger:parameters createResolver +type CreateResolverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Resolver + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateResolverParams() beforehand. +func (o *CreateResolverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Resolver + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateResolverParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateResolverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateResolverParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateResolverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateResolverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateResolverParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/resolver/create_resolver_responses.go b/operations/resolver/create_resolver_responses.go new file mode 100644 index 00000000..bf10b333 --- /dev/null +++ b/operations/resolver/create_resolver_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateResolverCreatedCode is the HTTP code returned for type CreateResolverCreated +const CreateResolverCreatedCode int = 201 + +/* +CreateResolverCreated Resolver created + +swagger:response createResolverCreated +*/ +type CreateResolverCreated struct { + + /* + In: Body + */ + Payload *models.Resolver `json:"body,omitempty"` +} + +// NewCreateResolverCreated creates CreateResolverCreated with default headers values +func NewCreateResolverCreated() *CreateResolverCreated { + + return &CreateResolverCreated{} +} + +// WithPayload adds the payload to the create resolver created response +func (o *CreateResolverCreated) WithPayload(payload *models.Resolver) *CreateResolverCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create resolver created response +func (o *CreateResolverCreated) SetPayload(payload *models.Resolver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateResolverCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateResolverAcceptedCode is the HTTP code returned for type CreateResolverAccepted +const CreateResolverAcceptedCode int = 202 + +/* +CreateResolverAccepted Configuration change accepted and reload requested + +swagger:response createResolverAccepted +*/ +type CreateResolverAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Resolver `json:"body,omitempty"` +} + +// NewCreateResolverAccepted creates CreateResolverAccepted with default headers values +func NewCreateResolverAccepted() *CreateResolverAccepted { + + return &CreateResolverAccepted{} +} + +// WithReloadID adds the reloadId to the create resolver accepted response +func (o *CreateResolverAccepted) WithReloadID(reloadID string) *CreateResolverAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create resolver accepted response +func (o *CreateResolverAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create resolver accepted response +func (o *CreateResolverAccepted) WithPayload(payload *models.Resolver) *CreateResolverAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create resolver accepted response +func (o *CreateResolverAccepted) SetPayload(payload *models.Resolver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateResolverAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateResolverBadRequestCode is the HTTP code returned for type CreateResolverBadRequest +const CreateResolverBadRequestCode int = 400 + +/* +CreateResolverBadRequest Bad request + +swagger:response createResolverBadRequest +*/ +type CreateResolverBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateResolverBadRequest creates CreateResolverBadRequest with default headers values +func NewCreateResolverBadRequest() *CreateResolverBadRequest { + + return &CreateResolverBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create resolver bad request response +func (o *CreateResolverBadRequest) WithConfigurationVersion(configurationVersion string) *CreateResolverBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create resolver bad request response +func (o *CreateResolverBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create resolver bad request response +func (o *CreateResolverBadRequest) WithPayload(payload *models.Error) *CreateResolverBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create resolver bad request response +func (o *CreateResolverBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateResolverBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateResolverConflictCode is the HTTP code returned for type CreateResolverConflict +const CreateResolverConflictCode int = 409 + +/* +CreateResolverConflict The specified resource already exists + +swagger:response createResolverConflict +*/ +type CreateResolverConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateResolverConflict creates CreateResolverConflict with default headers values +func NewCreateResolverConflict() *CreateResolverConflict { + + return &CreateResolverConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create resolver conflict response +func (o *CreateResolverConflict) WithConfigurationVersion(configurationVersion string) *CreateResolverConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create resolver conflict response +func (o *CreateResolverConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create resolver conflict response +func (o *CreateResolverConflict) WithPayload(payload *models.Error) *CreateResolverConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create resolver conflict response +func (o *CreateResolverConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateResolverConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateResolverDefault General Error + +swagger:response createResolverDefault +*/ +type CreateResolverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateResolverDefault creates CreateResolverDefault with default headers values +func NewCreateResolverDefault(code int) *CreateResolverDefault { + if code <= 0 { + code = 500 + } + + return &CreateResolverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create resolver default response +func (o *CreateResolverDefault) WithStatusCode(code int) *CreateResolverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create resolver default response +func (o *CreateResolverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create resolver default response +func (o *CreateResolverDefault) WithConfigurationVersion(configurationVersion string) *CreateResolverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create resolver default response +func (o *CreateResolverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create resolver default response +func (o *CreateResolverDefault) WithPayload(payload *models.Error) *CreateResolverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create resolver default response +func (o *CreateResolverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateResolverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/resolver/create_resolver_urlbuilder.go b/operations/resolver/create_resolver_urlbuilder.go new file mode 100644 index 00000000..f90853a4 --- /dev/null +++ b/operations/resolver/create_resolver_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateResolverURL generates an URL for the create resolver operation +type CreateResolverURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateResolverURL) WithBasePath(bp string) *CreateResolverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateResolverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateResolverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/resolvers" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateResolverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateResolverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateResolverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateResolverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateResolverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateResolverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/resolver/delete_resolver.go b/operations/resolver/delete_resolver.go new file mode 100644 index 00000000..f58b004f --- /dev/null +++ b/operations/resolver/delete_resolver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteResolverHandlerFunc turns a function with the right signature into a delete resolver handler +type DeleteResolverHandlerFunc func(DeleteResolverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteResolverHandlerFunc) Handle(params DeleteResolverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteResolverHandler interface for that can handle valid delete resolver params +type DeleteResolverHandler interface { + Handle(DeleteResolverParams, interface{}) middleware.Responder +} + +// NewDeleteResolver creates a new http.Handler for the delete resolver operation +func NewDeleteResolver(ctx *middleware.Context, handler DeleteResolverHandler) *DeleteResolver { + return &DeleteResolver{Context: ctx, Handler: handler} +} + +/* + DeleteResolver swagger:route DELETE /services/haproxy/configuration/resolvers/{name} Resolver deleteResolver + +# Delete a resolver + +Deletes a resolver from the configuration by it's name. +*/ +type DeleteResolver struct { + Context *middleware.Context + Handler DeleteResolverHandler +} + +func (o *DeleteResolver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteResolverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/resolver/delete_resolver_parameters.go b/operations/resolver/delete_resolver_parameters.go new file mode 100644 index 00000000..175324a4 --- /dev/null +++ b/operations/resolver/delete_resolver_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteResolverParams creates a new DeleteResolverParams object +// with the default values initialized. +func NewDeleteResolverParams() DeleteResolverParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteResolverParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteResolverParams contains all the bound params for the delete resolver operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteResolver +type DeleteResolverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Resolver name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteResolverParams() beforehand. +func (o *DeleteResolverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteResolverParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteResolverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteResolverParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteResolverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteResolverParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/resolver/delete_resolver_responses.go b/operations/resolver/delete_resolver_responses.go new file mode 100644 index 00000000..0404f81d --- /dev/null +++ b/operations/resolver/delete_resolver_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteResolverAcceptedCode is the HTTP code returned for type DeleteResolverAccepted +const DeleteResolverAcceptedCode int = 202 + +/* +DeleteResolverAccepted Configuration change accepted and reload requested + +swagger:response deleteResolverAccepted +*/ +type DeleteResolverAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteResolverAccepted creates DeleteResolverAccepted with default headers values +func NewDeleteResolverAccepted() *DeleteResolverAccepted { + + return &DeleteResolverAccepted{} +} + +// WithReloadID adds the reloadId to the delete resolver accepted response +func (o *DeleteResolverAccepted) WithReloadID(reloadID string) *DeleteResolverAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete resolver accepted response +func (o *DeleteResolverAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteResolverAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteResolverNoContentCode is the HTTP code returned for type DeleteResolverNoContent +const DeleteResolverNoContentCode int = 204 + +/* +DeleteResolverNoContent Resolver deleted + +swagger:response deleteResolverNoContent +*/ +type DeleteResolverNoContent struct { +} + +// NewDeleteResolverNoContent creates DeleteResolverNoContent with default headers values +func NewDeleteResolverNoContent() *DeleteResolverNoContent { + + return &DeleteResolverNoContent{} +} + +// WriteResponse to the client +func (o *DeleteResolverNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteResolverNotFoundCode is the HTTP code returned for type DeleteResolverNotFound +const DeleteResolverNotFoundCode int = 404 + +/* +DeleteResolverNotFound The specified resource was not found + +swagger:response deleteResolverNotFound +*/ +type DeleteResolverNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteResolverNotFound creates DeleteResolverNotFound with default headers values +func NewDeleteResolverNotFound() *DeleteResolverNotFound { + + return &DeleteResolverNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete resolver not found response +func (o *DeleteResolverNotFound) WithConfigurationVersion(configurationVersion string) *DeleteResolverNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete resolver not found response +func (o *DeleteResolverNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete resolver not found response +func (o *DeleteResolverNotFound) WithPayload(payload *models.Error) *DeleteResolverNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete resolver not found response +func (o *DeleteResolverNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteResolverNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteResolverDefault General Error + +swagger:response deleteResolverDefault +*/ +type DeleteResolverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteResolverDefault creates DeleteResolverDefault with default headers values +func NewDeleteResolverDefault(code int) *DeleteResolverDefault { + if code <= 0 { + code = 500 + } + + return &DeleteResolverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete resolver default response +func (o *DeleteResolverDefault) WithStatusCode(code int) *DeleteResolverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete resolver default response +func (o *DeleteResolverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete resolver default response +func (o *DeleteResolverDefault) WithConfigurationVersion(configurationVersion string) *DeleteResolverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete resolver default response +func (o *DeleteResolverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete resolver default response +func (o *DeleteResolverDefault) WithPayload(payload *models.Error) *DeleteResolverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete resolver default response +func (o *DeleteResolverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteResolverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/resolver/delete_resolver_urlbuilder.go b/operations/resolver/delete_resolver_urlbuilder.go new file mode 100644 index 00000000..83caa6da --- /dev/null +++ b/operations/resolver/delete_resolver_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteResolverURL generates an URL for the delete resolver operation +type DeleteResolverURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteResolverURL) WithBasePath(bp string) *DeleteResolverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteResolverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteResolverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/resolvers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteResolverURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteResolverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteResolverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteResolverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteResolverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteResolverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteResolverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/resolver/get_resolver.go b/operations/resolver/get_resolver.go new file mode 100644 index 00000000..08605344 --- /dev/null +++ b/operations/resolver/get_resolver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetResolverHandlerFunc turns a function with the right signature into a get resolver handler +type GetResolverHandlerFunc func(GetResolverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetResolverHandlerFunc) Handle(params GetResolverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetResolverHandler interface for that can handle valid get resolver params +type GetResolverHandler interface { + Handle(GetResolverParams, interface{}) middleware.Responder +} + +// NewGetResolver creates a new http.Handler for the get resolver operation +func NewGetResolver(ctx *middleware.Context, handler GetResolverHandler) *GetResolver { + return &GetResolver{Context: ctx, Handler: handler} +} + +/* + GetResolver swagger:route GET /services/haproxy/configuration/resolvers/{name} Resolver getResolver + +# Return a resolver + +Returns one resolver section configuration by it's name. +*/ +type GetResolver struct { + Context *middleware.Context + Handler GetResolverHandler +} + +func (o *GetResolver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetResolverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/resolver/get_resolver_parameters.go b/operations/resolver/get_resolver_parameters.go new file mode 100644 index 00000000..16448d51 --- /dev/null +++ b/operations/resolver/get_resolver_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetResolverParams creates a new GetResolverParams object +// with the default values initialized. +func NewGetResolverParams() GetResolverParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetResolverParams{ + FullSection: &fullSectionDefault, + } +} + +// GetResolverParams contains all the bound params for the get resolver operation +// typically these are obtained from a http.Request +// +// swagger:parameters getResolver +type GetResolverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Resolver name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetResolverParams() beforehand. +func (o *GetResolverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetResolverParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetResolverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetResolverParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetResolverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/resolver/get_resolver_responses.go b/operations/resolver/get_resolver_responses.go new file mode 100644 index 00000000..69ef0588 --- /dev/null +++ b/operations/resolver/get_resolver_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetResolverOKCode is the HTTP code returned for type GetResolverOK +const GetResolverOKCode int = 200 + +/* +GetResolverOK Successful operation + +swagger:response getResolverOK +*/ +type GetResolverOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Resolver `json:"body,omitempty"` +} + +// NewGetResolverOK creates GetResolverOK with default headers values +func NewGetResolverOK() *GetResolverOK { + + return &GetResolverOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get resolver o k response +func (o *GetResolverOK) WithConfigurationVersion(configurationVersion string) *GetResolverOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get resolver o k response +func (o *GetResolverOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get resolver o k response +func (o *GetResolverOK) WithPayload(payload *models.Resolver) *GetResolverOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get resolver o k response +func (o *GetResolverOK) SetPayload(payload *models.Resolver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetResolverOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetResolverNotFoundCode is the HTTP code returned for type GetResolverNotFound +const GetResolverNotFoundCode int = 404 + +/* +GetResolverNotFound The specified resource was not found + +swagger:response getResolverNotFound +*/ +type GetResolverNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetResolverNotFound creates GetResolverNotFound with default headers values +func NewGetResolverNotFound() *GetResolverNotFound { + + return &GetResolverNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get resolver not found response +func (o *GetResolverNotFound) WithConfigurationVersion(configurationVersion string) *GetResolverNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get resolver not found response +func (o *GetResolverNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get resolver not found response +func (o *GetResolverNotFound) WithPayload(payload *models.Error) *GetResolverNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get resolver not found response +func (o *GetResolverNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetResolverNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetResolverDefault General Error + +swagger:response getResolverDefault +*/ +type GetResolverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetResolverDefault creates GetResolverDefault with default headers values +func NewGetResolverDefault(code int) *GetResolverDefault { + if code <= 0 { + code = 500 + } + + return &GetResolverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get resolver default response +func (o *GetResolverDefault) WithStatusCode(code int) *GetResolverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get resolver default response +func (o *GetResolverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get resolver default response +func (o *GetResolverDefault) WithConfigurationVersion(configurationVersion string) *GetResolverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get resolver default response +func (o *GetResolverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get resolver default response +func (o *GetResolverDefault) WithPayload(payload *models.Error) *GetResolverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get resolver default response +func (o *GetResolverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetResolverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/resolver/get_resolver_urlbuilder.go b/operations/resolver/get_resolver_urlbuilder.go new file mode 100644 index 00000000..233c5178 --- /dev/null +++ b/operations/resolver/get_resolver_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetResolverURL generates an URL for the get resolver operation +type GetResolverURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetResolverURL) WithBasePath(bp string) *GetResolverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetResolverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetResolverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/resolvers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetResolverURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetResolverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetResolverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetResolverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetResolverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetResolverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetResolverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/resolver/get_resolvers.go b/operations/resolver/get_resolvers.go new file mode 100644 index 00000000..c808345c --- /dev/null +++ b/operations/resolver/get_resolvers.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetResolversHandlerFunc turns a function with the right signature into a get resolvers handler +type GetResolversHandlerFunc func(GetResolversParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetResolversHandlerFunc) Handle(params GetResolversParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetResolversHandler interface for that can handle valid get resolvers params +type GetResolversHandler interface { + Handle(GetResolversParams, interface{}) middleware.Responder +} + +// NewGetResolvers creates a new http.Handler for the get resolvers operation +func NewGetResolvers(ctx *middleware.Context, handler GetResolversHandler) *GetResolvers { + return &GetResolvers{Context: ctx, Handler: handler} +} + +/* + GetResolvers swagger:route GET /services/haproxy/configuration/resolvers Resolver getResolvers + +# Return an array of resolvers + +Returns an array of all configured resolvers. +*/ +type GetResolvers struct { + Context *middleware.Context + Handler GetResolversHandler +} + +func (o *GetResolvers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetResolversParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/resolver/get_resolvers_parameters.go b/operations/resolver/get_resolvers_parameters.go new file mode 100644 index 00000000..df1cb244 --- /dev/null +++ b/operations/resolver/get_resolvers_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetResolversParams creates a new GetResolversParams object +// with the default values initialized. +func NewGetResolversParams() GetResolversParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetResolversParams{ + FullSection: &fullSectionDefault, + } +} + +// GetResolversParams contains all the bound params for the get resolvers operation +// typically these are obtained from a http.Request +// +// swagger:parameters getResolvers +type GetResolversParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetResolversParams() beforehand. +func (o *GetResolversParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetResolversParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetResolversParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetResolversParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/resolver/get_resolvers_responses.go b/operations/resolver/get_resolvers_responses.go new file mode 100644 index 00000000..2f114fb7 --- /dev/null +++ b/operations/resolver/get_resolvers_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetResolversOKCode is the HTTP code returned for type GetResolversOK +const GetResolversOKCode int = 200 + +/* +GetResolversOK Successful operation + +swagger:response getResolversOK +*/ +type GetResolversOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Resolvers `json:"body,omitempty"` +} + +// NewGetResolversOK creates GetResolversOK with default headers values +func NewGetResolversOK() *GetResolversOK { + + return &GetResolversOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get resolvers o k response +func (o *GetResolversOK) WithConfigurationVersion(configurationVersion string) *GetResolversOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get resolvers o k response +func (o *GetResolversOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get resolvers o k response +func (o *GetResolversOK) WithPayload(payload models.Resolvers) *GetResolversOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get resolvers o k response +func (o *GetResolversOK) SetPayload(payload models.Resolvers) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetResolversOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Resolvers{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetResolversDefault General Error + +swagger:response getResolversDefault +*/ +type GetResolversDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetResolversDefault creates GetResolversDefault with default headers values +func NewGetResolversDefault(code int) *GetResolversDefault { + if code <= 0 { + code = 500 + } + + return &GetResolversDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get resolvers default response +func (o *GetResolversDefault) WithStatusCode(code int) *GetResolversDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get resolvers default response +func (o *GetResolversDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get resolvers default response +func (o *GetResolversDefault) WithConfigurationVersion(configurationVersion string) *GetResolversDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get resolvers default response +func (o *GetResolversDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get resolvers default response +func (o *GetResolversDefault) WithPayload(payload *models.Error) *GetResolversDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get resolvers default response +func (o *GetResolversDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetResolversDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/resolver/get_resolvers_urlbuilder.go b/operations/resolver/get_resolvers_urlbuilder.go new file mode 100644 index 00000000..ac57da6e --- /dev/null +++ b/operations/resolver/get_resolvers_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetResolversURL generates an URL for the get resolvers operation +type GetResolversURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetResolversURL) WithBasePath(bp string) *GetResolversURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetResolversURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetResolversURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/resolvers" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetResolversURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetResolversURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetResolversURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetResolversURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetResolversURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetResolversURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/resolver/replace_resolver.go b/operations/resolver/replace_resolver.go new file mode 100644 index 00000000..342b1793 --- /dev/null +++ b/operations/resolver/replace_resolver.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceResolverHandlerFunc turns a function with the right signature into a replace resolver handler +type ReplaceResolverHandlerFunc func(ReplaceResolverParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceResolverHandlerFunc) Handle(params ReplaceResolverParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceResolverHandler interface for that can handle valid replace resolver params +type ReplaceResolverHandler interface { + Handle(ReplaceResolverParams, interface{}) middleware.Responder +} + +// NewReplaceResolver creates a new http.Handler for the replace resolver operation +func NewReplaceResolver(ctx *middleware.Context, handler ReplaceResolverHandler) *ReplaceResolver { + return &ReplaceResolver{Context: ctx, Handler: handler} +} + +/* + ReplaceResolver swagger:route PUT /services/haproxy/configuration/resolvers/{name} Resolver replaceResolver + +# Replace a resolver + +Replaces a resolver configuration by it's name. +*/ +type ReplaceResolver struct { + Context *middleware.Context + Handler ReplaceResolverHandler +} + +func (o *ReplaceResolver) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceResolverParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/resolver/replace_resolver_parameters.go b/operations/resolver/replace_resolver_parameters.go new file mode 100644 index 00000000..73ddeb16 --- /dev/null +++ b/operations/resolver/replace_resolver_parameters.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceResolverParams creates a new ReplaceResolverParams object +// with the default values initialized. +func NewReplaceResolverParams() ReplaceResolverParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return ReplaceResolverParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// ReplaceResolverParams contains all the bound params for the replace resolver operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceResolver +type ReplaceResolverParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Resolver + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Resolver name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceResolverParams() beforehand. +func (o *ReplaceResolverParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Resolver + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceResolverParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceResolverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceResolverParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceResolverParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceResolverParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceResolverParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceResolverParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/resolver/replace_resolver_responses.go b/operations/resolver/replace_resolver_responses.go new file mode 100644 index 00000000..e08cfbba --- /dev/null +++ b/operations/resolver/replace_resolver_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceResolverOKCode is the HTTP code returned for type ReplaceResolverOK +const ReplaceResolverOKCode int = 200 + +/* +ReplaceResolverOK Resolver replaced + +swagger:response replaceResolverOK +*/ +type ReplaceResolverOK struct { + + /* + In: Body + */ + Payload *models.Resolver `json:"body,omitempty"` +} + +// NewReplaceResolverOK creates ReplaceResolverOK with default headers values +func NewReplaceResolverOK() *ReplaceResolverOK { + + return &ReplaceResolverOK{} +} + +// WithPayload adds the payload to the replace resolver o k response +func (o *ReplaceResolverOK) WithPayload(payload *models.Resolver) *ReplaceResolverOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace resolver o k response +func (o *ReplaceResolverOK) SetPayload(payload *models.Resolver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceResolverOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceResolverAcceptedCode is the HTTP code returned for type ReplaceResolverAccepted +const ReplaceResolverAcceptedCode int = 202 + +/* +ReplaceResolverAccepted Configuration change accepted and reload requested + +swagger:response replaceResolverAccepted +*/ +type ReplaceResolverAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Resolver `json:"body,omitempty"` +} + +// NewReplaceResolverAccepted creates ReplaceResolverAccepted with default headers values +func NewReplaceResolverAccepted() *ReplaceResolverAccepted { + + return &ReplaceResolverAccepted{} +} + +// WithReloadID adds the reloadId to the replace resolver accepted response +func (o *ReplaceResolverAccepted) WithReloadID(reloadID string) *ReplaceResolverAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace resolver accepted response +func (o *ReplaceResolverAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace resolver accepted response +func (o *ReplaceResolverAccepted) WithPayload(payload *models.Resolver) *ReplaceResolverAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace resolver accepted response +func (o *ReplaceResolverAccepted) SetPayload(payload *models.Resolver) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceResolverAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceResolverBadRequestCode is the HTTP code returned for type ReplaceResolverBadRequest +const ReplaceResolverBadRequestCode int = 400 + +/* +ReplaceResolverBadRequest Bad request + +swagger:response replaceResolverBadRequest +*/ +type ReplaceResolverBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceResolverBadRequest creates ReplaceResolverBadRequest with default headers values +func NewReplaceResolverBadRequest() *ReplaceResolverBadRequest { + + return &ReplaceResolverBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace resolver bad request response +func (o *ReplaceResolverBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceResolverBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace resolver bad request response +func (o *ReplaceResolverBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace resolver bad request response +func (o *ReplaceResolverBadRequest) WithPayload(payload *models.Error) *ReplaceResolverBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace resolver bad request response +func (o *ReplaceResolverBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceResolverBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceResolverNotFoundCode is the HTTP code returned for type ReplaceResolverNotFound +const ReplaceResolverNotFoundCode int = 404 + +/* +ReplaceResolverNotFound The specified resource was not found + +swagger:response replaceResolverNotFound +*/ +type ReplaceResolverNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceResolverNotFound creates ReplaceResolverNotFound with default headers values +func NewReplaceResolverNotFound() *ReplaceResolverNotFound { + + return &ReplaceResolverNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace resolver not found response +func (o *ReplaceResolverNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceResolverNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace resolver not found response +func (o *ReplaceResolverNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace resolver not found response +func (o *ReplaceResolverNotFound) WithPayload(payload *models.Error) *ReplaceResolverNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace resolver not found response +func (o *ReplaceResolverNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceResolverNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceResolverDefault General Error + +swagger:response replaceResolverDefault +*/ +type ReplaceResolverDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceResolverDefault creates ReplaceResolverDefault with default headers values +func NewReplaceResolverDefault(code int) *ReplaceResolverDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceResolverDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace resolver default response +func (o *ReplaceResolverDefault) WithStatusCode(code int) *ReplaceResolverDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace resolver default response +func (o *ReplaceResolverDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace resolver default response +func (o *ReplaceResolverDefault) WithConfigurationVersion(configurationVersion string) *ReplaceResolverDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace resolver default response +func (o *ReplaceResolverDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace resolver default response +func (o *ReplaceResolverDefault) WithPayload(payload *models.Error) *ReplaceResolverDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace resolver default response +func (o *ReplaceResolverDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceResolverDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/resolver/replace_resolver_urlbuilder.go b/operations/resolver/replace_resolver_urlbuilder.go new file mode 100644 index 00000000..14dfdc97 --- /dev/null +++ b/operations/resolver/replace_resolver_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resolver + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceResolverURL generates an URL for the replace resolver operation +type ReplaceResolverURL struct { + Name string + + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceResolverURL) WithBasePath(bp string) *ReplaceResolverURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceResolverURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceResolverURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/resolvers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceResolverURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceResolverURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceResolverURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceResolverURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceResolverURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceResolverURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceResolverURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/ring/create_ring.go b/operations/ring/create_ring.go new file mode 100644 index 00000000..55dd5bca --- /dev/null +++ b/operations/ring/create_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateRingHandlerFunc turns a function with the right signature into a create ring handler +type CreateRingHandlerFunc func(CreateRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateRingHandlerFunc) Handle(params CreateRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateRingHandler interface for that can handle valid create ring params +type CreateRingHandler interface { + Handle(CreateRingParams, interface{}) middleware.Responder +} + +// NewCreateRing creates a new http.Handler for the create ring operation +func NewCreateRing(ctx *middleware.Context, handler CreateRingHandler) *CreateRing { + return &CreateRing{Context: ctx, Handler: handler} +} + +/* + CreateRing swagger:route POST /services/haproxy/configuration/rings Ring createRing + +# Add a ring + +Adds a new ring to the configuration file. +*/ +type CreateRing struct { + Context *middleware.Context + Handler CreateRingHandler +} + +func (o *CreateRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/ring/create_ring_parameters.go b/operations/ring/create_ring_parameters.go new file mode 100644 index 00000000..5580841f --- /dev/null +++ b/operations/ring/create_ring_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateRingParams creates a new CreateRingParams object +// with the default values initialized. +func NewCreateRingParams() CreateRingParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreateRingParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreateRingParams contains all the bound params for the create ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters createRing +type CreateRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Ring + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateRingParams() beforehand. +func (o *CreateRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Ring + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateRingParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateRingParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateRingParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/ring/create_ring_responses.go b/operations/ring/create_ring_responses.go new file mode 100644 index 00000000..e87270af --- /dev/null +++ b/operations/ring/create_ring_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateRingCreatedCode is the HTTP code returned for type CreateRingCreated +const CreateRingCreatedCode int = 201 + +/* +CreateRingCreated Ring created + +swagger:response createRingCreated +*/ +type CreateRingCreated struct { + + /* + In: Body + */ + Payload *models.Ring `json:"body,omitempty"` +} + +// NewCreateRingCreated creates CreateRingCreated with default headers values +func NewCreateRingCreated() *CreateRingCreated { + + return &CreateRingCreated{} +} + +// WithPayload adds the payload to the create ring created response +func (o *CreateRingCreated) WithPayload(payload *models.Ring) *CreateRingCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ring created response +func (o *CreateRingCreated) SetPayload(payload *models.Ring) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRingCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRingAcceptedCode is the HTTP code returned for type CreateRingAccepted +const CreateRingAcceptedCode int = 202 + +/* +CreateRingAccepted Configuration change accepted and reload requested + +swagger:response createRingAccepted +*/ +type CreateRingAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Ring `json:"body,omitempty"` +} + +// NewCreateRingAccepted creates CreateRingAccepted with default headers values +func NewCreateRingAccepted() *CreateRingAccepted { + + return &CreateRingAccepted{} +} + +// WithReloadID adds the reloadId to the create ring accepted response +func (o *CreateRingAccepted) WithReloadID(reloadID string) *CreateRingAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create ring accepted response +func (o *CreateRingAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create ring accepted response +func (o *CreateRingAccepted) WithPayload(payload *models.Ring) *CreateRingAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ring accepted response +func (o *CreateRingAccepted) SetPayload(payload *models.Ring) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRingAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRingBadRequestCode is the HTTP code returned for type CreateRingBadRequest +const CreateRingBadRequestCode int = 400 + +/* +CreateRingBadRequest Bad request + +swagger:response createRingBadRequest +*/ +type CreateRingBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateRingBadRequest creates CreateRingBadRequest with default headers values +func NewCreateRingBadRequest() *CreateRingBadRequest { + + return &CreateRingBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create ring bad request response +func (o *CreateRingBadRequest) WithConfigurationVersion(configurationVersion string) *CreateRingBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create ring bad request response +func (o *CreateRingBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create ring bad request response +func (o *CreateRingBadRequest) WithPayload(payload *models.Error) *CreateRingBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ring bad request response +func (o *CreateRingBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRingBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateRingConflictCode is the HTTP code returned for type CreateRingConflict +const CreateRingConflictCode int = 409 + +/* +CreateRingConflict The specified resource already exists + +swagger:response createRingConflict +*/ +type CreateRingConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateRingConflict creates CreateRingConflict with default headers values +func NewCreateRingConflict() *CreateRingConflict { + + return &CreateRingConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create ring conflict response +func (o *CreateRingConflict) WithConfigurationVersion(configurationVersion string) *CreateRingConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create ring conflict response +func (o *CreateRingConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create ring conflict response +func (o *CreateRingConflict) WithPayload(payload *models.Error) *CreateRingConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ring conflict response +func (o *CreateRingConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRingConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateRingDefault General Error + +swagger:response createRingDefault +*/ +type CreateRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateRingDefault creates CreateRingDefault with default headers values +func NewCreateRingDefault(code int) *CreateRingDefault { + if code <= 0 { + code = 500 + } + + return &CreateRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create ring default response +func (o *CreateRingDefault) WithStatusCode(code int) *CreateRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create ring default response +func (o *CreateRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create ring default response +func (o *CreateRingDefault) WithConfigurationVersion(configurationVersion string) *CreateRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create ring default response +func (o *CreateRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create ring default response +func (o *CreateRingDefault) WithPayload(payload *models.Error) *CreateRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ring default response +func (o *CreateRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/ring/create_ring_urlbuilder.go b/operations/ring/create_ring_urlbuilder.go new file mode 100644 index 00000000..6897eb4d --- /dev/null +++ b/operations/ring/create_ring_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateRingURL generates an URL for the create ring operation +type CreateRingURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRingURL) WithBasePath(bp string) *CreateRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/ring/delete_ring.go b/operations/ring/delete_ring.go new file mode 100644 index 00000000..4baeeb3e --- /dev/null +++ b/operations/ring/delete_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRingHandlerFunc turns a function with the right signature into a delete ring handler +type DeleteRingHandlerFunc func(DeleteRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRingHandlerFunc) Handle(params DeleteRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRingHandler interface for that can handle valid delete ring params +type DeleteRingHandler interface { + Handle(DeleteRingParams, interface{}) middleware.Responder +} + +// NewDeleteRing creates a new http.Handler for the delete ring operation +func NewDeleteRing(ctx *middleware.Context, handler DeleteRingHandler) *DeleteRing { + return &DeleteRing{Context: ctx, Handler: handler} +} + +/* + DeleteRing swagger:route DELETE /services/haproxy/configuration/rings/{name} Ring deleteRing + +# Delete a ring + +Deletes a ring from the configuration by it's name. +*/ +type DeleteRing struct { + Context *middleware.Context + Handler DeleteRingHandler +} + +func (o *DeleteRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/ring/delete_ring_parameters.go b/operations/ring/delete_ring_parameters.go new file mode 100644 index 00000000..e26d812c --- /dev/null +++ b/operations/ring/delete_ring_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteRingParams creates a new DeleteRingParams object +// with the default values initialized. +func NewDeleteRingParams() DeleteRingParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteRingParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteRingParams contains all the bound params for the delete ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteRing +type DeleteRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Ring name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRingParams() beforehand. +func (o *DeleteRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteRingParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteRingParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteRingParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/ring/delete_ring_responses.go b/operations/ring/delete_ring_responses.go new file mode 100644 index 00000000..1eba0a88 --- /dev/null +++ b/operations/ring/delete_ring_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteRingAcceptedCode is the HTTP code returned for type DeleteRingAccepted +const DeleteRingAcceptedCode int = 202 + +/* +DeleteRingAccepted Configuration change accepted and reload requested + +swagger:response deleteRingAccepted +*/ +type DeleteRingAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteRingAccepted creates DeleteRingAccepted with default headers values +func NewDeleteRingAccepted() *DeleteRingAccepted { + + return &DeleteRingAccepted{} +} + +// WithReloadID adds the reloadId to the delete ring accepted response +func (o *DeleteRingAccepted) WithReloadID(reloadID string) *DeleteRingAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete ring accepted response +func (o *DeleteRingAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteRingAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteRingNoContentCode is the HTTP code returned for type DeleteRingNoContent +const DeleteRingNoContentCode int = 204 + +/* +DeleteRingNoContent Ring deleted + +swagger:response deleteRingNoContent +*/ +type DeleteRingNoContent struct { +} + +// NewDeleteRingNoContent creates DeleteRingNoContent with default headers values +func NewDeleteRingNoContent() *DeleteRingNoContent { + + return &DeleteRingNoContent{} +} + +// WriteResponse to the client +func (o *DeleteRingNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteRingNotFoundCode is the HTTP code returned for type DeleteRingNotFound +const DeleteRingNotFoundCode int = 404 + +/* +DeleteRingNotFound The specified resource was not found + +swagger:response deleteRingNotFound +*/ +type DeleteRingNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteRingNotFound creates DeleteRingNotFound with default headers values +func NewDeleteRingNotFound() *DeleteRingNotFound { + + return &DeleteRingNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete ring not found response +func (o *DeleteRingNotFound) WithConfigurationVersion(configurationVersion string) *DeleteRingNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete ring not found response +func (o *DeleteRingNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete ring not found response +func (o *DeleteRingNotFound) WithPayload(payload *models.Error) *DeleteRingNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete ring not found response +func (o *DeleteRingNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRingNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteRingDefault General Error + +swagger:response deleteRingDefault +*/ +type DeleteRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteRingDefault creates DeleteRingDefault with default headers values +func NewDeleteRingDefault(code int) *DeleteRingDefault { + if code <= 0 { + code = 500 + } + + return &DeleteRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete ring default response +func (o *DeleteRingDefault) WithStatusCode(code int) *DeleteRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete ring default response +func (o *DeleteRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete ring default response +func (o *DeleteRingDefault) WithConfigurationVersion(configurationVersion string) *DeleteRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete ring default response +func (o *DeleteRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete ring default response +func (o *DeleteRingDefault) WithPayload(payload *models.Error) *DeleteRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete ring default response +func (o *DeleteRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/ring/delete_ring_urlbuilder.go b/operations/ring/delete_ring_urlbuilder.go new file mode 100644 index 00000000..bd1def2f --- /dev/null +++ b/operations/ring/delete_ring_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteRingURL generates an URL for the delete ring operation +type DeleteRingURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRingURL) WithBasePath(bp string) *DeleteRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/ring/get_ring.go b/operations/ring/get_ring.go new file mode 100644 index 00000000..0a20122d --- /dev/null +++ b/operations/ring/get_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRingHandlerFunc turns a function with the right signature into a get ring handler +type GetRingHandlerFunc func(GetRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRingHandlerFunc) Handle(params GetRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRingHandler interface for that can handle valid get ring params +type GetRingHandler interface { + Handle(GetRingParams, interface{}) middleware.Responder +} + +// NewGetRing creates a new http.Handler for the get ring operation +func NewGetRing(ctx *middleware.Context, handler GetRingHandler) *GetRing { + return &GetRing{Context: ctx, Handler: handler} +} + +/* + GetRing swagger:route GET /services/haproxy/configuration/rings/{name} Ring getRing + +# Return a ring + +Returns one ring configuration by it's name. +*/ +type GetRing struct { + Context *middleware.Context + Handler GetRingHandler +} + +func (o *GetRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/ring/get_ring_parameters.go b/operations/ring/get_ring_parameters.go new file mode 100644 index 00000000..b77e59b7 --- /dev/null +++ b/operations/ring/get_ring_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetRingParams creates a new GetRingParams object +// with the default values initialized. +func NewGetRingParams() GetRingParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetRingParams{ + FullSection: &fullSectionDefault, + } +} + +// GetRingParams contains all the bound params for the get ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRing +type GetRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Ring name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRingParams() beforehand. +func (o *GetRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetRingParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetRingParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/ring/get_ring_responses.go b/operations/ring/get_ring_responses.go new file mode 100644 index 00000000..82669dc7 --- /dev/null +++ b/operations/ring/get_ring_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetRingOKCode is the HTTP code returned for type GetRingOK +const GetRingOKCode int = 200 + +/* +GetRingOK Successful operation + +swagger:response getRingOK +*/ +type GetRingOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Ring `json:"body,omitempty"` +} + +// NewGetRingOK creates GetRingOK with default headers values +func NewGetRingOK() *GetRingOK { + + return &GetRingOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get ring o k response +func (o *GetRingOK) WithConfigurationVersion(configurationVersion string) *GetRingOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get ring o k response +func (o *GetRingOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get ring o k response +func (o *GetRingOK) WithPayload(payload *models.Ring) *GetRingOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ring o k response +func (o *GetRingOK) SetPayload(payload *models.Ring) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRingNotFoundCode is the HTTP code returned for type GetRingNotFound +const GetRingNotFoundCode int = 404 + +/* +GetRingNotFound The specified resource was not found + +swagger:response getRingNotFound +*/ +type GetRingNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRingNotFound creates GetRingNotFound with default headers values +func NewGetRingNotFound() *GetRingNotFound { + + return &GetRingNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get ring not found response +func (o *GetRingNotFound) WithConfigurationVersion(configurationVersion string) *GetRingNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get ring not found response +func (o *GetRingNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get ring not found response +func (o *GetRingNotFound) WithPayload(payload *models.Error) *GetRingNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ring not found response +func (o *GetRingNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRingNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetRingDefault General Error + +swagger:response getRingDefault +*/ +type GetRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRingDefault creates GetRingDefault with default headers values +func NewGetRingDefault(code int) *GetRingDefault { + if code <= 0 { + code = 500 + } + + return &GetRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get ring default response +func (o *GetRingDefault) WithStatusCode(code int) *GetRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get ring default response +func (o *GetRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get ring default response +func (o *GetRingDefault) WithConfigurationVersion(configurationVersion string) *GetRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get ring default response +func (o *GetRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get ring default response +func (o *GetRingDefault) WithPayload(payload *models.Error) *GetRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ring default response +func (o *GetRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/ring/get_ring_urlbuilder.go b/operations/ring/get_ring_urlbuilder.go new file mode 100644 index 00000000..ce712eb2 --- /dev/null +++ b/operations/ring/get_ring_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetRingURL generates an URL for the get ring operation +type GetRingURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRingURL) WithBasePath(bp string) *GetRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/ring/get_rings.go b/operations/ring/get_rings.go new file mode 100644 index 00000000..d810ebe7 --- /dev/null +++ b/operations/ring/get_rings.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRingsHandlerFunc turns a function with the right signature into a get rings handler +type GetRingsHandlerFunc func(GetRingsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRingsHandlerFunc) Handle(params GetRingsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRingsHandler interface for that can handle valid get rings params +type GetRingsHandler interface { + Handle(GetRingsParams, interface{}) middleware.Responder +} + +// NewGetRings creates a new http.Handler for the get rings operation +func NewGetRings(ctx *middleware.Context, handler GetRingsHandler) *GetRings { + return &GetRings{Context: ctx, Handler: handler} +} + +/* + GetRings swagger:route GET /services/haproxy/configuration/rings Ring getRings + +# Return an array of rings + +Returns an array of all configured rings. +*/ +type GetRings struct { + Context *middleware.Context + Handler GetRingsHandler +} + +func (o *GetRings) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetRingsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/ring/get_rings_parameters.go b/operations/ring/get_rings_parameters.go new file mode 100644 index 00000000..d88df8ab --- /dev/null +++ b/operations/ring/get_rings_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetRingsParams creates a new GetRingsParams object +// with the default values initialized. +func NewGetRingsParams() GetRingsParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetRingsParams{ + FullSection: &fullSectionDefault, + } +} + +// GetRingsParams contains all the bound params for the get rings operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRings +type GetRingsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRingsParams() beforehand. +func (o *GetRingsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetRingsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetRingsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetRingsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/ring/get_rings_responses.go b/operations/ring/get_rings_responses.go new file mode 100644 index 00000000..64315331 --- /dev/null +++ b/operations/ring/get_rings_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetRingsOKCode is the HTTP code returned for type GetRingsOK +const GetRingsOKCode int = 200 + +/* +GetRingsOK Successful operation + +swagger:response getRingsOK +*/ +type GetRingsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Rings `json:"body,omitempty"` +} + +// NewGetRingsOK creates GetRingsOK with default headers values +func NewGetRingsOK() *GetRingsOK { + + return &GetRingsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get rings o k response +func (o *GetRingsOK) WithConfigurationVersion(configurationVersion string) *GetRingsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get rings o k response +func (o *GetRingsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get rings o k response +func (o *GetRingsOK) WithPayload(payload models.Rings) *GetRingsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get rings o k response +func (o *GetRingsOK) SetPayload(payload models.Rings) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRingsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Rings{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetRingsDefault General Error + +swagger:response getRingsDefault +*/ +type GetRingsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRingsDefault creates GetRingsDefault with default headers values +func NewGetRingsDefault(code int) *GetRingsDefault { + if code <= 0 { + code = 500 + } + + return &GetRingsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get rings default response +func (o *GetRingsDefault) WithStatusCode(code int) *GetRingsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get rings default response +func (o *GetRingsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get rings default response +func (o *GetRingsDefault) WithConfigurationVersion(configurationVersion string) *GetRingsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get rings default response +func (o *GetRingsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get rings default response +func (o *GetRingsDefault) WithPayload(payload *models.Error) *GetRingsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get rings default response +func (o *GetRingsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRingsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/ring/get_rings_urlbuilder.go b/operations/ring/get_rings_urlbuilder.go new file mode 100644 index 00000000..ba3e87d0 --- /dev/null +++ b/operations/ring/get_rings_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetRingsURL generates an URL for the get rings operation +type GetRingsURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRingsURL) WithBasePath(bp string) *GetRingsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRingsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRingsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRingsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRingsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRingsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRingsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRingsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRingsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/ring/replace_ring.go b/operations/ring/replace_ring.go new file mode 100644 index 00000000..1845648b --- /dev/null +++ b/operations/ring/replace_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceRingHandlerFunc turns a function with the right signature into a replace ring handler +type ReplaceRingHandlerFunc func(ReplaceRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceRingHandlerFunc) Handle(params ReplaceRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceRingHandler interface for that can handle valid replace ring params +type ReplaceRingHandler interface { + Handle(ReplaceRingParams, interface{}) middleware.Responder +} + +// NewReplaceRing creates a new http.Handler for the replace ring operation +func NewReplaceRing(ctx *middleware.Context, handler ReplaceRingHandler) *ReplaceRing { + return &ReplaceRing{Context: ctx, Handler: handler} +} + +/* + ReplaceRing swagger:route PUT /services/haproxy/configuration/rings/{name} Ring replaceRing + +# Replace a ring + +Replaces a ring configuration by it's name. +*/ +type ReplaceRing struct { + Context *middleware.Context + Handler ReplaceRingHandler +} + +func (o *ReplaceRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/ring/replace_ring_parameters.go b/operations/ring/replace_ring_parameters.go new file mode 100644 index 00000000..6586289f --- /dev/null +++ b/operations/ring/replace_ring_parameters.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceRingParams creates a new ReplaceRingParams object +// with the default values initialized. +func NewReplaceRingParams() ReplaceRingParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return ReplaceRingParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// ReplaceRingParams contains all the bound params for the replace ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceRing +type ReplaceRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Ring + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Ring name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceRingParams() beforehand. +func (o *ReplaceRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Ring + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceRingParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceRingParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceRingParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceRingParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/ring/replace_ring_responses.go b/operations/ring/replace_ring_responses.go new file mode 100644 index 00000000..6ea5b533 --- /dev/null +++ b/operations/ring/replace_ring_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceRingOKCode is the HTTP code returned for type ReplaceRingOK +const ReplaceRingOKCode int = 200 + +/* +ReplaceRingOK Ring replaced + +swagger:response replaceRingOK +*/ +type ReplaceRingOK struct { + + /* + In: Body + */ + Payload *models.Ring `json:"body,omitempty"` +} + +// NewReplaceRingOK creates ReplaceRingOK with default headers values +func NewReplaceRingOK() *ReplaceRingOK { + + return &ReplaceRingOK{} +} + +// WithPayload adds the payload to the replace ring o k response +func (o *ReplaceRingOK) WithPayload(payload *models.Ring) *ReplaceRingOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace ring o k response +func (o *ReplaceRingOK) SetPayload(payload *models.Ring) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceRingAcceptedCode is the HTTP code returned for type ReplaceRingAccepted +const ReplaceRingAcceptedCode int = 202 + +/* +ReplaceRingAccepted Configuration change accepted and reload requested + +swagger:response replaceRingAccepted +*/ +type ReplaceRingAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Ring `json:"body,omitempty"` +} + +// NewReplaceRingAccepted creates ReplaceRingAccepted with default headers values +func NewReplaceRingAccepted() *ReplaceRingAccepted { + + return &ReplaceRingAccepted{} +} + +// WithReloadID adds the reloadId to the replace ring accepted response +func (o *ReplaceRingAccepted) WithReloadID(reloadID string) *ReplaceRingAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace ring accepted response +func (o *ReplaceRingAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace ring accepted response +func (o *ReplaceRingAccepted) WithPayload(payload *models.Ring) *ReplaceRingAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace ring accepted response +func (o *ReplaceRingAccepted) SetPayload(payload *models.Ring) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRingAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceRingBadRequestCode is the HTTP code returned for type ReplaceRingBadRequest +const ReplaceRingBadRequestCode int = 400 + +/* +ReplaceRingBadRequest Bad request + +swagger:response replaceRingBadRequest +*/ +type ReplaceRingBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRingBadRequest creates ReplaceRingBadRequest with default headers values +func NewReplaceRingBadRequest() *ReplaceRingBadRequest { + + return &ReplaceRingBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace ring bad request response +func (o *ReplaceRingBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceRingBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace ring bad request response +func (o *ReplaceRingBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace ring bad request response +func (o *ReplaceRingBadRequest) WithPayload(payload *models.Error) *ReplaceRingBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace ring bad request response +func (o *ReplaceRingBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRingBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceRingNotFoundCode is the HTTP code returned for type ReplaceRingNotFound +const ReplaceRingNotFoundCode int = 404 + +/* +ReplaceRingNotFound The specified resource was not found + +swagger:response replaceRingNotFound +*/ +type ReplaceRingNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRingNotFound creates ReplaceRingNotFound with default headers values +func NewReplaceRingNotFound() *ReplaceRingNotFound { + + return &ReplaceRingNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace ring not found response +func (o *ReplaceRingNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceRingNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace ring not found response +func (o *ReplaceRingNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace ring not found response +func (o *ReplaceRingNotFound) WithPayload(payload *models.Error) *ReplaceRingNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace ring not found response +func (o *ReplaceRingNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRingNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceRingDefault General Error + +swagger:response replaceRingDefault +*/ +type ReplaceRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRingDefault creates ReplaceRingDefault with default headers values +func NewReplaceRingDefault(code int) *ReplaceRingDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace ring default response +func (o *ReplaceRingDefault) WithStatusCode(code int) *ReplaceRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace ring default response +func (o *ReplaceRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace ring default response +func (o *ReplaceRingDefault) WithConfigurationVersion(configurationVersion string) *ReplaceRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace ring default response +func (o *ReplaceRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace ring default response +func (o *ReplaceRingDefault) WithPayload(payload *models.Error) *ReplaceRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace ring default response +func (o *ReplaceRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/ring/replace_ring_urlbuilder.go b/operations/ring/replace_ring_urlbuilder.go new file mode 100644 index 00000000..53a8be87 --- /dev/null +++ b/operations/ring/replace_ring_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package ring + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceRingURL generates an URL for the replace ring operation +type ReplaceRingURL struct { + Name string + + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceRingURL) WithBasePath(bp string) *ReplaceRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_front_use/create_s_s_l_front_use.go b/operations/s_s_l_front_use/create_s_s_l_front_use.go new file mode 100644 index 00000000..f7955843 --- /dev/null +++ b/operations/s_s_l_front_use/create_s_s_l_front_use.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateSSLFrontUseHandlerFunc turns a function with the right signature into a create s s l front use handler +type CreateSSLFrontUseHandlerFunc func(CreateSSLFrontUseParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateSSLFrontUseHandlerFunc) Handle(params CreateSSLFrontUseParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateSSLFrontUseHandler interface for that can handle valid create s s l front use params +type CreateSSLFrontUseHandler interface { + Handle(CreateSSLFrontUseParams, interface{}) middleware.Responder +} + +// NewCreateSSLFrontUse creates a new http.Handler for the create s s l front use operation +func NewCreateSSLFrontUse(ctx *middleware.Context, handler CreateSSLFrontUseHandler) *CreateSSLFrontUse { + return &CreateSSLFrontUse{Context: ctx, Handler: handler} +} + +/* + CreateSSLFrontUse swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses SSLFrontUse createSSLFrontUse + +# Add a new SSLFrontUse + +Adds a new SSLFrontUse in the specified frontend in the configuration file. +*/ +type CreateSSLFrontUse struct { + Context *middleware.Context + Handler CreateSSLFrontUseHandler +} + +func (o *CreateSSLFrontUse) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateSSLFrontUseParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_front_use/create_s_s_l_front_use_parameters.go b/operations/s_s_l_front_use/create_s_s_l_front_use_parameters.go new file mode 100644 index 00000000..56ab506d --- /dev/null +++ b/operations/s_s_l_front_use/create_s_s_l_front_use_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateSSLFrontUseParams creates a new CreateSSLFrontUseParams object +// with the default values initialized. +func NewCreateSSLFrontUseParams() CreateSSLFrontUseParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateSSLFrontUseParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateSSLFrontUseParams contains all the bound params for the create s s l front use operation +// typically these are obtained from a http.Request +// +// swagger:parameters createSSLFrontUse +type CreateSSLFrontUseParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SSLFrontUse + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateSSLFrontUseParams() beforehand. +func (o *CreateSSLFrontUseParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SSLFrontUse + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateSSLFrontUseParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateSSLFrontUseParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateSSLFrontUseParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateSSLFrontUseParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateSSLFrontUseParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/s_s_l_front_use/create_s_s_l_front_use_responses.go b/operations/s_s_l_front_use/create_s_s_l_front_use_responses.go new file mode 100644 index 00000000..06abccf1 --- /dev/null +++ b/operations/s_s_l_front_use/create_s_s_l_front_use_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateSSLFrontUseCreatedCode is the HTTP code returned for type CreateSSLFrontUseCreated +const CreateSSLFrontUseCreatedCode int = 201 + +/* +CreateSSLFrontUseCreated SSLFrontUse created + +swagger:response createSSLFrontUseCreated +*/ +type CreateSSLFrontUseCreated struct { + + /* + In: Body + */ + Payload *models.SSLFrontUse `json:"body,omitempty"` +} + +// NewCreateSSLFrontUseCreated creates CreateSSLFrontUseCreated with default headers values +func NewCreateSSLFrontUseCreated() *CreateSSLFrontUseCreated { + + return &CreateSSLFrontUseCreated{} +} + +// WithPayload adds the payload to the create s s l front use created response +func (o *CreateSSLFrontUseCreated) WithPayload(payload *models.SSLFrontUse) *CreateSSLFrontUseCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create s s l front use created response +func (o *CreateSSLFrontUseCreated) SetPayload(payload *models.SSLFrontUse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSSLFrontUseCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSSLFrontUseAcceptedCode is the HTTP code returned for type CreateSSLFrontUseAccepted +const CreateSSLFrontUseAcceptedCode int = 202 + +/* +CreateSSLFrontUseAccepted Configuration change accepted and reload requested + +swagger:response createSSLFrontUseAccepted +*/ +type CreateSSLFrontUseAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.SSLFrontUse `json:"body,omitempty"` +} + +// NewCreateSSLFrontUseAccepted creates CreateSSLFrontUseAccepted with default headers values +func NewCreateSSLFrontUseAccepted() *CreateSSLFrontUseAccepted { + + return &CreateSSLFrontUseAccepted{} +} + +// WithReloadID adds the reloadId to the create s s l front use accepted response +func (o *CreateSSLFrontUseAccepted) WithReloadID(reloadID string) *CreateSSLFrontUseAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create s s l front use accepted response +func (o *CreateSSLFrontUseAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create s s l front use accepted response +func (o *CreateSSLFrontUseAccepted) WithPayload(payload *models.SSLFrontUse) *CreateSSLFrontUseAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create s s l front use accepted response +func (o *CreateSSLFrontUseAccepted) SetPayload(payload *models.SSLFrontUse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSSLFrontUseAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSSLFrontUseBadRequestCode is the HTTP code returned for type CreateSSLFrontUseBadRequest +const CreateSSLFrontUseBadRequestCode int = 400 + +/* +CreateSSLFrontUseBadRequest Bad request + +swagger:response createSSLFrontUseBadRequest +*/ +type CreateSSLFrontUseBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSSLFrontUseBadRequest creates CreateSSLFrontUseBadRequest with default headers values +func NewCreateSSLFrontUseBadRequest() *CreateSSLFrontUseBadRequest { + + return &CreateSSLFrontUseBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create s s l front use bad request response +func (o *CreateSSLFrontUseBadRequest) WithConfigurationVersion(configurationVersion string) *CreateSSLFrontUseBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create s s l front use bad request response +func (o *CreateSSLFrontUseBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create s s l front use bad request response +func (o *CreateSSLFrontUseBadRequest) WithPayload(payload *models.Error) *CreateSSLFrontUseBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create s s l front use bad request response +func (o *CreateSSLFrontUseBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSSLFrontUseBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSSLFrontUseConflictCode is the HTTP code returned for type CreateSSLFrontUseConflict +const CreateSSLFrontUseConflictCode int = 409 + +/* +CreateSSLFrontUseConflict The specified resource already exists + +swagger:response createSSLFrontUseConflict +*/ +type CreateSSLFrontUseConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSSLFrontUseConflict creates CreateSSLFrontUseConflict with default headers values +func NewCreateSSLFrontUseConflict() *CreateSSLFrontUseConflict { + + return &CreateSSLFrontUseConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create s s l front use conflict response +func (o *CreateSSLFrontUseConflict) WithConfigurationVersion(configurationVersion string) *CreateSSLFrontUseConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create s s l front use conflict response +func (o *CreateSSLFrontUseConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create s s l front use conflict response +func (o *CreateSSLFrontUseConflict) WithPayload(payload *models.Error) *CreateSSLFrontUseConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create s s l front use conflict response +func (o *CreateSSLFrontUseConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSSLFrontUseConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateSSLFrontUseDefault General Error + +swagger:response createSSLFrontUseDefault +*/ +type CreateSSLFrontUseDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSSLFrontUseDefault creates CreateSSLFrontUseDefault with default headers values +func NewCreateSSLFrontUseDefault(code int) *CreateSSLFrontUseDefault { + if code <= 0 { + code = 500 + } + + return &CreateSSLFrontUseDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create s s l front use default response +func (o *CreateSSLFrontUseDefault) WithStatusCode(code int) *CreateSSLFrontUseDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create s s l front use default response +func (o *CreateSSLFrontUseDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create s s l front use default response +func (o *CreateSSLFrontUseDefault) WithConfigurationVersion(configurationVersion string) *CreateSSLFrontUseDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create s s l front use default response +func (o *CreateSSLFrontUseDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create s s l front use default response +func (o *CreateSSLFrontUseDefault) WithPayload(payload *models.Error) *CreateSSLFrontUseDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create s s l front use default response +func (o *CreateSSLFrontUseDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSSLFrontUseDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_front_use/create_s_s_l_front_use_urlbuilder.go b/operations/s_s_l_front_use/create_s_s_l_front_use_urlbuilder.go new file mode 100644 index 00000000..d4a553a2 --- /dev/null +++ b/operations/s_s_l_front_use/create_s_s_l_front_use_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateSSLFrontUseURL generates an URL for the create s s l front use operation +type CreateSSLFrontUseURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSSLFrontUseURL) WithBasePath(bp string) *CreateSSLFrontUseURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSSLFrontUseURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateSSLFrontUseURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateSSLFrontUseURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateSSLFrontUseURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateSSLFrontUseURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateSSLFrontUseURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateSSLFrontUseURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateSSLFrontUseURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateSSLFrontUseURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_front_use/delete_s_s_l_front_use.go b/operations/s_s_l_front_use/delete_s_s_l_front_use.go new file mode 100644 index 00000000..fbad73e6 --- /dev/null +++ b/operations/s_s_l_front_use/delete_s_s_l_front_use.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteSSLFrontUseHandlerFunc turns a function with the right signature into a delete s s l front use handler +type DeleteSSLFrontUseHandlerFunc func(DeleteSSLFrontUseParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteSSLFrontUseHandlerFunc) Handle(params DeleteSSLFrontUseParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteSSLFrontUseHandler interface for that can handle valid delete s s l front use params +type DeleteSSLFrontUseHandler interface { + Handle(DeleteSSLFrontUseParams, interface{}) middleware.Responder +} + +// NewDeleteSSLFrontUse creates a new http.Handler for the delete s s l front use operation +func NewDeleteSSLFrontUse(ctx *middleware.Context, handler DeleteSSLFrontUseHandler) *DeleteSSLFrontUse { + return &DeleteSSLFrontUse{Context: ctx, Handler: handler} +} + +/* + DeleteSSLFrontUse swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index} SSLFrontUse deleteSSLFrontUse + +# Delete an SSLFrontUse + +Deletes an SSLFrontUse configuration by its index in the specified frontend. +*/ +type DeleteSSLFrontUse struct { + Context *middleware.Context + Handler DeleteSSLFrontUseHandler +} + +func (o *DeleteSSLFrontUse) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteSSLFrontUseParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_front_use/delete_s_s_l_front_use_parameters.go b/operations/s_s_l_front_use/delete_s_s_l_front_use_parameters.go new file mode 100644 index 00000000..afa39255 --- /dev/null +++ b/operations/s_s_l_front_use/delete_s_s_l_front_use_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteSSLFrontUseParams creates a new DeleteSSLFrontUseParams object +// with the default values initialized. +func NewDeleteSSLFrontUseParams() DeleteSSLFrontUseParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteSSLFrontUseParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteSSLFrontUseParams contains all the bound params for the delete s s l front use operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteSSLFrontUse +type DeleteSSLFrontUseParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*SSLFrontUse index (zero-based) + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteSSLFrontUseParams() beforehand. +func (o *DeleteSSLFrontUseParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteSSLFrontUseParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteSSLFrontUseParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteSSLFrontUseParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteSSLFrontUseParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteSSLFrontUseParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteSSLFrontUseParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/s_s_l_front_use/delete_s_s_l_front_use_responses.go b/operations/s_s_l_front_use/delete_s_s_l_front_use_responses.go new file mode 100644 index 00000000..85e0115c --- /dev/null +++ b/operations/s_s_l_front_use/delete_s_s_l_front_use_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteSSLFrontUseAcceptedCode is the HTTP code returned for type DeleteSSLFrontUseAccepted +const DeleteSSLFrontUseAcceptedCode int = 202 + +/* +DeleteSSLFrontUseAccepted Configuration change accepted and reload requested + +swagger:response deleteSSLFrontUseAccepted +*/ +type DeleteSSLFrontUseAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteSSLFrontUseAccepted creates DeleteSSLFrontUseAccepted with default headers values +func NewDeleteSSLFrontUseAccepted() *DeleteSSLFrontUseAccepted { + + return &DeleteSSLFrontUseAccepted{} +} + +// WithReloadID adds the reloadId to the delete s s l front use accepted response +func (o *DeleteSSLFrontUseAccepted) WithReloadID(reloadID string) *DeleteSSLFrontUseAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete s s l front use accepted response +func (o *DeleteSSLFrontUseAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteSSLFrontUseAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteSSLFrontUseNoContentCode is the HTTP code returned for type DeleteSSLFrontUseNoContent +const DeleteSSLFrontUseNoContentCode int = 204 + +/* +DeleteSSLFrontUseNoContent SSLFrontUse deleted + +swagger:response deleteSSLFrontUseNoContent +*/ +type DeleteSSLFrontUseNoContent struct { +} + +// NewDeleteSSLFrontUseNoContent creates DeleteSSLFrontUseNoContent with default headers values +func NewDeleteSSLFrontUseNoContent() *DeleteSSLFrontUseNoContent { + + return &DeleteSSLFrontUseNoContent{} +} + +// WriteResponse to the client +func (o *DeleteSSLFrontUseNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteSSLFrontUseNotFoundCode is the HTTP code returned for type DeleteSSLFrontUseNotFound +const DeleteSSLFrontUseNotFoundCode int = 404 + +/* +DeleteSSLFrontUseNotFound The specified resource was not found + +swagger:response deleteSSLFrontUseNotFound +*/ +type DeleteSSLFrontUseNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSSLFrontUseNotFound creates DeleteSSLFrontUseNotFound with default headers values +func NewDeleteSSLFrontUseNotFound() *DeleteSSLFrontUseNotFound { + + return &DeleteSSLFrontUseNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete s s l front use not found response +func (o *DeleteSSLFrontUseNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSSLFrontUseNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete s s l front use not found response +func (o *DeleteSSLFrontUseNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete s s l front use not found response +func (o *DeleteSSLFrontUseNotFound) WithPayload(payload *models.Error) *DeleteSSLFrontUseNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete s s l front use not found response +func (o *DeleteSSLFrontUseNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSSLFrontUseNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteSSLFrontUseDefault General Error + +swagger:response deleteSSLFrontUseDefault +*/ +type DeleteSSLFrontUseDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSSLFrontUseDefault creates DeleteSSLFrontUseDefault with default headers values +func NewDeleteSSLFrontUseDefault(code int) *DeleteSSLFrontUseDefault { + if code <= 0 { + code = 500 + } + + return &DeleteSSLFrontUseDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete s s l front use default response +func (o *DeleteSSLFrontUseDefault) WithStatusCode(code int) *DeleteSSLFrontUseDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete s s l front use default response +func (o *DeleteSSLFrontUseDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete s s l front use default response +func (o *DeleteSSLFrontUseDefault) WithConfigurationVersion(configurationVersion string) *DeleteSSLFrontUseDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete s s l front use default response +func (o *DeleteSSLFrontUseDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete s s l front use default response +func (o *DeleteSSLFrontUseDefault) WithPayload(payload *models.Error) *DeleteSSLFrontUseDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete s s l front use default response +func (o *DeleteSSLFrontUseDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSSLFrontUseDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_front_use/delete_s_s_l_front_use_urlbuilder.go b/operations/s_s_l_front_use/delete_s_s_l_front_use_urlbuilder.go new file mode 100644 index 00000000..cc4a6ad6 --- /dev/null +++ b/operations/s_s_l_front_use/delete_s_s_l_front_use_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteSSLFrontUseURL generates an URL for the delete s s l front use operation +type DeleteSSLFrontUseURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSSLFrontUseURL) WithBasePath(bp string) *DeleteSSLFrontUseURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSSLFrontUseURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteSSLFrontUseURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteSSLFrontUseURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteSSLFrontUseURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteSSLFrontUseURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteSSLFrontUseURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteSSLFrontUseURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteSSLFrontUseURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteSSLFrontUseURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteSSLFrontUseURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_front_use/get_all_s_s_l_front_uses.go b/operations/s_s_l_front_use/get_all_s_s_l_front_uses.go new file mode 100644 index 00000000..23785594 --- /dev/null +++ b/operations/s_s_l_front_use/get_all_s_s_l_front_uses.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllSSLFrontUsesHandlerFunc turns a function with the right signature into a get all s s l front uses handler +type GetAllSSLFrontUsesHandlerFunc func(GetAllSSLFrontUsesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllSSLFrontUsesHandlerFunc) Handle(params GetAllSSLFrontUsesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllSSLFrontUsesHandler interface for that can handle valid get all s s l front uses params +type GetAllSSLFrontUsesHandler interface { + Handle(GetAllSSLFrontUsesParams, interface{}) middleware.Responder +} + +// NewGetAllSSLFrontUses creates a new http.Handler for the get all s s l front uses operation +func NewGetAllSSLFrontUses(ctx *middleware.Context, handler GetAllSSLFrontUsesHandler) *GetAllSSLFrontUses { + return &GetAllSSLFrontUses{Context: ctx, Handler: handler} +} + +/* + GetAllSSLFrontUses swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses SSLFrontUse getAllSSLFrontUses + +# Return an array of SSLFrontUses + +Returns an array of all SSLFrontUses that are configured in specified frontend. +*/ +type GetAllSSLFrontUses struct { + Context *middleware.Context + Handler GetAllSSLFrontUsesHandler +} + +func (o *GetAllSSLFrontUses) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllSSLFrontUsesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_front_use/get_all_s_s_l_front_uses_parameters.go b/operations/s_s_l_front_use/get_all_s_s_l_front_uses_parameters.go new file mode 100644 index 00000000..523398b6 --- /dev/null +++ b/operations/s_s_l_front_use/get_all_s_s_l_front_uses_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllSSLFrontUsesParams creates a new GetAllSSLFrontUsesParams object +// +// There are no default values defined in the spec. +func NewGetAllSSLFrontUsesParams() GetAllSSLFrontUsesParams { + + return GetAllSSLFrontUsesParams{} +} + +// GetAllSSLFrontUsesParams contains all the bound params for the get all s s l front uses operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllSSLFrontUses +type GetAllSSLFrontUsesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllSSLFrontUsesParams() beforehand. +func (o *GetAllSSLFrontUsesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllSSLFrontUsesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllSSLFrontUsesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/s_s_l_front_use/get_all_s_s_l_front_uses_responses.go b/operations/s_s_l_front_use/get_all_s_s_l_front_uses_responses.go new file mode 100644 index 00000000..16e00b6f --- /dev/null +++ b/operations/s_s_l_front_use/get_all_s_s_l_front_uses_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllSSLFrontUsesOKCode is the HTTP code returned for type GetAllSSLFrontUsesOK +const GetAllSSLFrontUsesOKCode int = 200 + +/* +GetAllSSLFrontUsesOK Successful operation + +swagger:response getAllSSLFrontUsesOK +*/ +type GetAllSSLFrontUsesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.SSLFrontUses `json:"body,omitempty"` +} + +// NewGetAllSSLFrontUsesOK creates GetAllSSLFrontUsesOK with default headers values +func NewGetAllSSLFrontUsesOK() *GetAllSSLFrontUsesOK { + + return &GetAllSSLFrontUsesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all s s l front uses o k response +func (o *GetAllSSLFrontUsesOK) WithConfigurationVersion(configurationVersion string) *GetAllSSLFrontUsesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all s s l front uses o k response +func (o *GetAllSSLFrontUsesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all s s l front uses o k response +func (o *GetAllSSLFrontUsesOK) WithPayload(payload models.SSLFrontUses) *GetAllSSLFrontUsesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all s s l front uses o k response +func (o *GetAllSSLFrontUsesOK) SetPayload(payload models.SSLFrontUses) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSSLFrontUsesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SSLFrontUses{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllSSLFrontUsesDefault General Error + +swagger:response getAllSSLFrontUsesDefault +*/ +type GetAllSSLFrontUsesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSSLFrontUsesDefault creates GetAllSSLFrontUsesDefault with default headers values +func NewGetAllSSLFrontUsesDefault(code int) *GetAllSSLFrontUsesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllSSLFrontUsesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all s s l front uses default response +func (o *GetAllSSLFrontUsesDefault) WithStatusCode(code int) *GetAllSSLFrontUsesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all s s l front uses default response +func (o *GetAllSSLFrontUsesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all s s l front uses default response +func (o *GetAllSSLFrontUsesDefault) WithConfigurationVersion(configurationVersion string) *GetAllSSLFrontUsesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all s s l front uses default response +func (o *GetAllSSLFrontUsesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all s s l front uses default response +func (o *GetAllSSLFrontUsesDefault) WithPayload(payload *models.Error) *GetAllSSLFrontUsesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all s s l front uses default response +func (o *GetAllSSLFrontUsesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSSLFrontUsesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_front_use/get_all_s_s_l_front_uses_urlbuilder.go b/operations/s_s_l_front_use/get_all_s_s_l_front_uses_urlbuilder.go new file mode 100644 index 00000000..b472655d --- /dev/null +++ b/operations/s_s_l_front_use/get_all_s_s_l_front_uses_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllSSLFrontUsesURL generates an URL for the get all s s l front uses operation +type GetAllSSLFrontUsesURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSSLFrontUsesURL) WithBasePath(bp string) *GetAllSSLFrontUsesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSSLFrontUsesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllSSLFrontUsesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllSSLFrontUsesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllSSLFrontUsesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllSSLFrontUsesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllSSLFrontUsesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllSSLFrontUsesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllSSLFrontUsesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllSSLFrontUsesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_front_use/get_s_s_l_front_use.go b/operations/s_s_l_front_use/get_s_s_l_front_use.go new file mode 100644 index 00000000..0872eb2b --- /dev/null +++ b/operations/s_s_l_front_use/get_s_s_l_front_use.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSSLFrontUseHandlerFunc turns a function with the right signature into a get s s l front use handler +type GetSSLFrontUseHandlerFunc func(GetSSLFrontUseParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSSLFrontUseHandlerFunc) Handle(params GetSSLFrontUseParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSSLFrontUseHandler interface for that can handle valid get s s l front use params +type GetSSLFrontUseHandler interface { + Handle(GetSSLFrontUseParams, interface{}) middleware.Responder +} + +// NewGetSSLFrontUse creates a new http.Handler for the get s s l front use operation +func NewGetSSLFrontUse(ctx *middleware.Context, handler GetSSLFrontUseHandler) *GetSSLFrontUse { + return &GetSSLFrontUse{Context: ctx, Handler: handler} +} + +/* + GetSSLFrontUse swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index} SSLFrontUse getSSLFrontUse + +# Return one SSLFrontUse + +Returns one SSLFrontUse configuration by its index in the specified frontend. +*/ +type GetSSLFrontUse struct { + Context *middleware.Context + Handler GetSSLFrontUseHandler +} + +func (o *GetSSLFrontUse) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSSLFrontUseParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_front_use/get_s_s_l_front_use_parameters.go b/operations/s_s_l_front_use/get_s_s_l_front_use_parameters.go new file mode 100644 index 00000000..06688e6a --- /dev/null +++ b/operations/s_s_l_front_use/get_s_s_l_front_use_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetSSLFrontUseParams creates a new GetSSLFrontUseParams object +// +// There are no default values defined in the spec. +func NewGetSSLFrontUseParams() GetSSLFrontUseParams { + + return GetSSLFrontUseParams{} +} + +// GetSSLFrontUseParams contains all the bound params for the get s s l front use operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSSLFrontUse +type GetSSLFrontUseParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSLFrontUse index (zero-based) + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSSLFrontUseParams() beforehand. +func (o *GetSSLFrontUseParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetSSLFrontUseParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetSSLFrontUseParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetSSLFrontUseParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/s_s_l_front_use/get_s_s_l_front_use_responses.go b/operations/s_s_l_front_use/get_s_s_l_front_use_responses.go new file mode 100644 index 00000000..e5e4fa6a --- /dev/null +++ b/operations/s_s_l_front_use/get_s_s_l_front_use_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSSLFrontUseOKCode is the HTTP code returned for type GetSSLFrontUseOK +const GetSSLFrontUseOKCode int = 200 + +/* +GetSSLFrontUseOK Successful operation + +swagger:response getSSLFrontUseOK +*/ +type GetSSLFrontUseOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.SSLFrontUse `json:"body,omitempty"` +} + +// NewGetSSLFrontUseOK creates GetSSLFrontUseOK with default headers values +func NewGetSSLFrontUseOK() *GetSSLFrontUseOK { + + return &GetSSLFrontUseOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get s s l front use o k response +func (o *GetSSLFrontUseOK) WithConfigurationVersion(configurationVersion string) *GetSSLFrontUseOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get s s l front use o k response +func (o *GetSSLFrontUseOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get s s l front use o k response +func (o *GetSSLFrontUseOK) WithPayload(payload *models.SSLFrontUse) *GetSSLFrontUseOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get s s l front use o k response +func (o *GetSSLFrontUseOK) SetPayload(payload *models.SSLFrontUse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSSLFrontUseOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSSLFrontUseNotFoundCode is the HTTP code returned for type GetSSLFrontUseNotFound +const GetSSLFrontUseNotFoundCode int = 404 + +/* +GetSSLFrontUseNotFound The specified resource already exists + +swagger:response getSSLFrontUseNotFound +*/ +type GetSSLFrontUseNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSSLFrontUseNotFound creates GetSSLFrontUseNotFound with default headers values +func NewGetSSLFrontUseNotFound() *GetSSLFrontUseNotFound { + + return &GetSSLFrontUseNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get s s l front use not found response +func (o *GetSSLFrontUseNotFound) WithConfigurationVersion(configurationVersion string) *GetSSLFrontUseNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get s s l front use not found response +func (o *GetSSLFrontUseNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get s s l front use not found response +func (o *GetSSLFrontUseNotFound) WithPayload(payload *models.Error) *GetSSLFrontUseNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get s s l front use not found response +func (o *GetSSLFrontUseNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSSLFrontUseNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetSSLFrontUseDefault General Error + +swagger:response getSSLFrontUseDefault +*/ +type GetSSLFrontUseDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSSLFrontUseDefault creates GetSSLFrontUseDefault with default headers values +func NewGetSSLFrontUseDefault(code int) *GetSSLFrontUseDefault { + if code <= 0 { + code = 500 + } + + return &GetSSLFrontUseDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get s s l front use default response +func (o *GetSSLFrontUseDefault) WithStatusCode(code int) *GetSSLFrontUseDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get s s l front use default response +func (o *GetSSLFrontUseDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get s s l front use default response +func (o *GetSSLFrontUseDefault) WithConfigurationVersion(configurationVersion string) *GetSSLFrontUseDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get s s l front use default response +func (o *GetSSLFrontUseDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get s s l front use default response +func (o *GetSSLFrontUseDefault) WithPayload(payload *models.Error) *GetSSLFrontUseDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get s s l front use default response +func (o *GetSSLFrontUseDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSSLFrontUseDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_front_use/get_s_s_l_front_use_urlbuilder.go b/operations/s_s_l_front_use/get_s_s_l_front_use_urlbuilder.go new file mode 100644 index 00000000..2762fcac --- /dev/null +++ b/operations/s_s_l_front_use/get_s_s_l_front_use_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetSSLFrontUseURL generates an URL for the get s s l front use operation +type GetSSLFrontUseURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSSLFrontUseURL) WithBasePath(bp string) *GetSSLFrontUseURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSSLFrontUseURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSSLFrontUseURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetSSLFrontUseURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetSSLFrontUseURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSSLFrontUseURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSSLFrontUseURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSSLFrontUseURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSSLFrontUseURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSSLFrontUseURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSSLFrontUseURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_front_use/replace_s_s_l_front_use.go b/operations/s_s_l_front_use/replace_s_s_l_front_use.go new file mode 100644 index 00000000..55ade515 --- /dev/null +++ b/operations/s_s_l_front_use/replace_s_s_l_front_use.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceSSLFrontUseHandlerFunc turns a function with the right signature into a replace s s l front use handler +type ReplaceSSLFrontUseHandlerFunc func(ReplaceSSLFrontUseParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceSSLFrontUseHandlerFunc) Handle(params ReplaceSSLFrontUseParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceSSLFrontUseHandler interface for that can handle valid replace s s l front use params +type ReplaceSSLFrontUseHandler interface { + Handle(ReplaceSSLFrontUseParams, interface{}) middleware.Responder +} + +// NewReplaceSSLFrontUse creates a new http.Handler for the replace s s l front use operation +func NewReplaceSSLFrontUse(ctx *middleware.Context, handler ReplaceSSLFrontUseHandler) *ReplaceSSLFrontUse { + return &ReplaceSSLFrontUse{Context: ctx, Handler: handler} +} + +/* + ReplaceSSLFrontUse swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index} SSLFrontUse replaceSSLFrontUse + +# Replace an SSLFrontUse + +Replaces an SSLFrontUse configuration by its index in the specified frontend. +*/ +type ReplaceSSLFrontUse struct { + Context *middleware.Context + Handler ReplaceSSLFrontUseHandler +} + +func (o *ReplaceSSLFrontUse) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceSSLFrontUseParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_front_use/replace_s_s_l_front_use_parameters.go b/operations/s_s_l_front_use/replace_s_s_l_front_use_parameters.go new file mode 100644 index 00000000..a7633591 --- /dev/null +++ b/operations/s_s_l_front_use/replace_s_s_l_front_use_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceSSLFrontUseParams creates a new ReplaceSSLFrontUseParams object +// with the default values initialized. +func NewReplaceSSLFrontUseParams() ReplaceSSLFrontUseParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceSSLFrontUseParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceSSLFrontUseParams contains all the bound params for the replace s s l front use operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceSSLFrontUse +type ReplaceSSLFrontUseParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SSLFrontUse + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*SSLFrontUse index (zero-based) + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceSSLFrontUseParams() beforehand. +func (o *ReplaceSSLFrontUseParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SSLFrontUse + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceSSLFrontUseParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceSSLFrontUseParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceSSLFrontUseParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceSSLFrontUseParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceSSLFrontUseParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceSSLFrontUseParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/s_s_l_front_use/replace_s_s_l_front_use_responses.go b/operations/s_s_l_front_use/replace_s_s_l_front_use_responses.go new file mode 100644 index 00000000..6c1e5b5c --- /dev/null +++ b/operations/s_s_l_front_use/replace_s_s_l_front_use_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceSSLFrontUseOKCode is the HTTP code returned for type ReplaceSSLFrontUseOK +const ReplaceSSLFrontUseOKCode int = 200 + +/* +ReplaceSSLFrontUseOK SSLFrontUse replaced + +swagger:response replaceSSLFrontUseOK +*/ +type ReplaceSSLFrontUseOK struct { + + /* + In: Body + */ + Payload *models.SSLFrontUse `json:"body,omitempty"` +} + +// NewReplaceSSLFrontUseOK creates ReplaceSSLFrontUseOK with default headers values +func NewReplaceSSLFrontUseOK() *ReplaceSSLFrontUseOK { + + return &ReplaceSSLFrontUseOK{} +} + +// WithPayload adds the payload to the replace s s l front use o k response +func (o *ReplaceSSLFrontUseOK) WithPayload(payload *models.SSLFrontUse) *ReplaceSSLFrontUseOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace s s l front use o k response +func (o *ReplaceSSLFrontUseOK) SetPayload(payload *models.SSLFrontUse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSSLFrontUseOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSSLFrontUseAcceptedCode is the HTTP code returned for type ReplaceSSLFrontUseAccepted +const ReplaceSSLFrontUseAcceptedCode int = 202 + +/* +ReplaceSSLFrontUseAccepted Configuration change accepted and reload requested + +swagger:response replaceSSLFrontUseAccepted +*/ +type ReplaceSSLFrontUseAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.SSLFrontUse `json:"body,omitempty"` +} + +// NewReplaceSSLFrontUseAccepted creates ReplaceSSLFrontUseAccepted with default headers values +func NewReplaceSSLFrontUseAccepted() *ReplaceSSLFrontUseAccepted { + + return &ReplaceSSLFrontUseAccepted{} +} + +// WithReloadID adds the reloadId to the replace s s l front use accepted response +func (o *ReplaceSSLFrontUseAccepted) WithReloadID(reloadID string) *ReplaceSSLFrontUseAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace s s l front use accepted response +func (o *ReplaceSSLFrontUseAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace s s l front use accepted response +func (o *ReplaceSSLFrontUseAccepted) WithPayload(payload *models.SSLFrontUse) *ReplaceSSLFrontUseAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace s s l front use accepted response +func (o *ReplaceSSLFrontUseAccepted) SetPayload(payload *models.SSLFrontUse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSSLFrontUseAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSSLFrontUseBadRequestCode is the HTTP code returned for type ReplaceSSLFrontUseBadRequest +const ReplaceSSLFrontUseBadRequestCode int = 400 + +/* +ReplaceSSLFrontUseBadRequest Bad request + +swagger:response replaceSSLFrontUseBadRequest +*/ +type ReplaceSSLFrontUseBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSSLFrontUseBadRequest creates ReplaceSSLFrontUseBadRequest with default headers values +func NewReplaceSSLFrontUseBadRequest() *ReplaceSSLFrontUseBadRequest { + + return &ReplaceSSLFrontUseBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace s s l front use bad request response +func (o *ReplaceSSLFrontUseBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceSSLFrontUseBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace s s l front use bad request response +func (o *ReplaceSSLFrontUseBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace s s l front use bad request response +func (o *ReplaceSSLFrontUseBadRequest) WithPayload(payload *models.Error) *ReplaceSSLFrontUseBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace s s l front use bad request response +func (o *ReplaceSSLFrontUseBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSSLFrontUseBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSSLFrontUseNotFoundCode is the HTTP code returned for type ReplaceSSLFrontUseNotFound +const ReplaceSSLFrontUseNotFoundCode int = 404 + +/* +ReplaceSSLFrontUseNotFound The specified resource was not found + +swagger:response replaceSSLFrontUseNotFound +*/ +type ReplaceSSLFrontUseNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSSLFrontUseNotFound creates ReplaceSSLFrontUseNotFound with default headers values +func NewReplaceSSLFrontUseNotFound() *ReplaceSSLFrontUseNotFound { + + return &ReplaceSSLFrontUseNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace s s l front use not found response +func (o *ReplaceSSLFrontUseNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceSSLFrontUseNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace s s l front use not found response +func (o *ReplaceSSLFrontUseNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace s s l front use not found response +func (o *ReplaceSSLFrontUseNotFound) WithPayload(payload *models.Error) *ReplaceSSLFrontUseNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace s s l front use not found response +func (o *ReplaceSSLFrontUseNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSSLFrontUseNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceSSLFrontUseDefault General Error + +swagger:response replaceSSLFrontUseDefault +*/ +type ReplaceSSLFrontUseDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSSLFrontUseDefault creates ReplaceSSLFrontUseDefault with default headers values +func NewReplaceSSLFrontUseDefault(code int) *ReplaceSSLFrontUseDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceSSLFrontUseDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace s s l front use default response +func (o *ReplaceSSLFrontUseDefault) WithStatusCode(code int) *ReplaceSSLFrontUseDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace s s l front use default response +func (o *ReplaceSSLFrontUseDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace s s l front use default response +func (o *ReplaceSSLFrontUseDefault) WithConfigurationVersion(configurationVersion string) *ReplaceSSLFrontUseDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace s s l front use default response +func (o *ReplaceSSLFrontUseDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace s s l front use default response +func (o *ReplaceSSLFrontUseDefault) WithPayload(payload *models.Error) *ReplaceSSLFrontUseDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace s s l front use default response +func (o *ReplaceSSLFrontUseDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSSLFrontUseDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_front_use/replace_s_s_l_front_use_urlbuilder.go b/operations/s_s_l_front_use/replace_s_s_l_front_use_urlbuilder.go new file mode 100644 index 00000000..91e89d77 --- /dev/null +++ b/operations/s_s_l_front_use/replace_s_s_l_front_use_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_front_use + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceSSLFrontUseURL generates an URL for the replace s s l front use operation +type ReplaceSSLFrontUseURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSSLFrontUseURL) WithBasePath(bp string) *ReplaceSSLFrontUseURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSSLFrontUseURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceSSLFrontUseURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/ssl_front_uses/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceSSLFrontUseURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceSSLFrontUseURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceSSLFrontUseURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceSSLFrontUseURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceSSLFrontUseURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceSSLFrontUseURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceSSLFrontUseURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceSSLFrontUseURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/add_ca_entry.go b/operations/s_s_l_runtime/add_ca_entry.go new file mode 100644 index 00000000..fd4932d3 --- /dev/null +++ b/operations/s_s_l_runtime/add_ca_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddCaEntryHandlerFunc turns a function with the right signature into a add ca entry handler +type AddCaEntryHandlerFunc func(AddCaEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddCaEntryHandlerFunc) Handle(params AddCaEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddCaEntryHandler interface for that can handle valid add ca entry params +type AddCaEntryHandler interface { + Handle(AddCaEntryParams, interface{}) middleware.Responder +} + +// NewAddCaEntry creates a new http.Handler for the add ca entry operation +func NewAddCaEntry(ctx *middleware.Context, handler AddCaEntryHandler) *AddCaEntry { + return &AddCaEntry{Context: ctx, Handler: handler} +} + +/* + AddCaEntry swagger:route POST /services/haproxy/runtime/ssl_ca_files/{name}/entries SSLRuntime addCaEntry + +# Add a certificate to a CA file + +Adds an entry to an existing CA file using the runtime socket. +*/ +type AddCaEntry struct { + Context *middleware.Context + Handler AddCaEntryHandler +} + +func (o *AddCaEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewAddCaEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/add_ca_entry_parameters.go b/operations/s_s_l_runtime/add_ca_entry_parameters.go new file mode 100644 index 00000000..1c9ba040 --- /dev/null +++ b/operations/s_s_l_runtime/add_ca_entry_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// AddCaEntryMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var AddCaEntryMaxParseMemory int64 = 32 << 20 + +// NewAddCaEntryParams creates a new AddCaEntryParams object +// +// There are no default values defined in the spec. +func NewAddCaEntryParams() AddCaEntryParams { + + return AddCaEntryParams{} +} + +// AddCaEntryParams contains all the bound params for the add ca entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters addCaEntry +type AddCaEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Payload of the cert entry + Required: true + In: formData + */ + FileUpload io.ReadCloser + /*SSL CA file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddCaEntryParams() beforehand. +func (o *AddCaEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(AddCaEntryMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + // Required: true + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *AddCaEntryParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *AddCaEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/add_ca_entry_responses.go b/operations/s_s_l_runtime/add_ca_entry_responses.go new file mode 100644 index 00000000..7701bb92 --- /dev/null +++ b/operations/s_s_l_runtime/add_ca_entry_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// AddCaEntryCreatedCode is the HTTP code returned for type AddCaEntryCreated +const AddCaEntryCreatedCode int = 201 + +/* +AddCaEntryCreated Successful operation + +swagger:response addCaEntryCreated +*/ +type AddCaEntryCreated struct { + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewAddCaEntryCreated creates AddCaEntryCreated with default headers values +func NewAddCaEntryCreated() *AddCaEntryCreated { + + return &AddCaEntryCreated{} +} + +// WithPayload adds the payload to the add ca entry created response +func (o *AddCaEntryCreated) WithPayload(payload *models.SslCertificate) *AddCaEntryCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add ca entry created response +func (o *AddCaEntryCreated) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddCaEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddCaEntryNotFoundCode is the HTTP code returned for type AddCaEntryNotFound +const AddCaEntryNotFoundCode int = 404 + +/* +AddCaEntryNotFound The specified resource was not found + +swagger:response addCaEntryNotFound +*/ +type AddCaEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddCaEntryNotFound creates AddCaEntryNotFound with default headers values +func NewAddCaEntryNotFound() *AddCaEntryNotFound { + + return &AddCaEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the add ca entry not found response +func (o *AddCaEntryNotFound) WithConfigurationVersion(configurationVersion string) *AddCaEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add ca entry not found response +func (o *AddCaEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add ca entry not found response +func (o *AddCaEntryNotFound) WithPayload(payload *models.Error) *AddCaEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add ca entry not found response +func (o *AddCaEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddCaEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +AddCaEntryDefault General Error + +swagger:response addCaEntryDefault +*/ +type AddCaEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddCaEntryDefault creates AddCaEntryDefault with default headers values +func NewAddCaEntryDefault(code int) *AddCaEntryDefault { + if code <= 0 { + code = 500 + } + + return &AddCaEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the add ca entry default response +func (o *AddCaEntryDefault) WithStatusCode(code int) *AddCaEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the add ca entry default response +func (o *AddCaEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the add ca entry default response +func (o *AddCaEntryDefault) WithConfigurationVersion(configurationVersion string) *AddCaEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add ca entry default response +func (o *AddCaEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add ca entry default response +func (o *AddCaEntryDefault) WithPayload(payload *models.Error) *AddCaEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add ca entry default response +func (o *AddCaEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddCaEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/add_ca_entry_urlbuilder.go b/operations/s_s_l_runtime/add_ca_entry_urlbuilder.go new file mode 100644 index 00000000..add4e240 --- /dev/null +++ b/operations/s_s_l_runtime/add_ca_entry_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// AddCaEntryURL generates an URL for the add ca entry operation +type AddCaEntryURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddCaEntryURL) WithBasePath(bp string) *AddCaEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddCaEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddCaEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_ca_files/{name}/entries" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on AddCaEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddCaEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddCaEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddCaEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddCaEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddCaEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddCaEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/add_crt_list_entry.go b/operations/s_s_l_runtime/add_crt_list_entry.go new file mode 100644 index 00000000..72fb4df2 --- /dev/null +++ b/operations/s_s_l_runtime/add_crt_list_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddCrtListEntryHandlerFunc turns a function with the right signature into a add crt list entry handler +type AddCrtListEntryHandlerFunc func(AddCrtListEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddCrtListEntryHandlerFunc) Handle(params AddCrtListEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddCrtListEntryHandler interface for that can handle valid add crt list entry params +type AddCrtListEntryHandler interface { + Handle(AddCrtListEntryParams, interface{}) middleware.Responder +} + +// NewAddCrtListEntry creates a new http.Handler for the add crt list entry operation +func NewAddCrtListEntry(ctx *middleware.Context, handler AddCrtListEntryHandler) *AddCrtListEntry { + return &AddCrtListEntry{Context: ctx, Handler: handler} +} + +/* + AddCrtListEntry swagger:route POST /services/haproxy/runtime/ssl_crt_lists/entries SSLRuntime addCrtListEntry + +# Add an entry into a crt-list + +Appends an entry to the given crt-list using the runtime socket. +*/ +type AddCrtListEntry struct { + Context *middleware.Context + Handler AddCrtListEntryHandler +} + +func (o *AddCrtListEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewAddCrtListEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/add_crt_list_entry_parameters.go b/operations/s_s_l_runtime/add_crt_list_entry_parameters.go new file mode 100644 index 00000000..1abba27b --- /dev/null +++ b/operations/s_s_l_runtime/add_crt_list_entry_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewAddCrtListEntryParams creates a new AddCrtListEntryParams object +// +// There are no default values defined in the spec. +func NewAddCrtListEntryParams() AddCrtListEntryParams { + + return AddCrtListEntryParams{} +} + +// AddCrtListEntryParams contains all the bound params for the add crt list entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters addCrtListEntry +type AddCrtListEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SslCrtListEntry + /*SSL crt-list filename + Required: true + In: query + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddCrtListEntryParams() beforehand. +func (o *AddCrtListEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SslCrtListEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qName, qhkName, _ := qs.GetOK("name") + if err := o.bindName(qName, qhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from query. +func (o *AddCrtListEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("name", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("name", "query", raw); err != nil { + return err + } + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/add_crt_list_entry_responses.go b/operations/s_s_l_runtime/add_crt_list_entry_responses.go new file mode 100644 index 00000000..cb100ec1 --- /dev/null +++ b/operations/s_s_l_runtime/add_crt_list_entry_responses.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// AddCrtListEntryCreatedCode is the HTTP code returned for type AddCrtListEntryCreated +const AddCrtListEntryCreatedCode int = 201 + +/* +AddCrtListEntryCreated Successful operation + +swagger:response addCrtListEntryCreated +*/ +type AddCrtListEntryCreated struct { +} + +// NewAddCrtListEntryCreated creates AddCrtListEntryCreated with default headers values +func NewAddCrtListEntryCreated() *AddCrtListEntryCreated { + + return &AddCrtListEntryCreated{} +} + +// WriteResponse to the client +func (o *AddCrtListEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// AddCrtListEntryBadRequestCode is the HTTP code returned for type AddCrtListEntryBadRequest +const AddCrtListEntryBadRequestCode int = 400 + +/* +AddCrtListEntryBadRequest Bad request + +swagger:response addCrtListEntryBadRequest +*/ +type AddCrtListEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddCrtListEntryBadRequest creates AddCrtListEntryBadRequest with default headers values +func NewAddCrtListEntryBadRequest() *AddCrtListEntryBadRequest { + + return &AddCrtListEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the add crt list entry bad request response +func (o *AddCrtListEntryBadRequest) WithConfigurationVersion(configurationVersion string) *AddCrtListEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add crt list entry bad request response +func (o *AddCrtListEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add crt list entry bad request response +func (o *AddCrtListEntryBadRequest) WithPayload(payload *models.Error) *AddCrtListEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add crt list entry bad request response +func (o *AddCrtListEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddCrtListEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddCrtListEntryConflictCode is the HTTP code returned for type AddCrtListEntryConflict +const AddCrtListEntryConflictCode int = 409 + +/* +AddCrtListEntryConflict The specified resource already exists + +swagger:response addCrtListEntryConflict +*/ +type AddCrtListEntryConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddCrtListEntryConflict creates AddCrtListEntryConflict with default headers values +func NewAddCrtListEntryConflict() *AddCrtListEntryConflict { + + return &AddCrtListEntryConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the add crt list entry conflict response +func (o *AddCrtListEntryConflict) WithConfigurationVersion(configurationVersion string) *AddCrtListEntryConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add crt list entry conflict response +func (o *AddCrtListEntryConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add crt list entry conflict response +func (o *AddCrtListEntryConflict) WithPayload(payload *models.Error) *AddCrtListEntryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add crt list entry conflict response +func (o *AddCrtListEntryConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddCrtListEntryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +AddCrtListEntryDefault General Error + +swagger:response addCrtListEntryDefault +*/ +type AddCrtListEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddCrtListEntryDefault creates AddCrtListEntryDefault with default headers values +func NewAddCrtListEntryDefault(code int) *AddCrtListEntryDefault { + if code <= 0 { + code = 500 + } + + return &AddCrtListEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the add crt list entry default response +func (o *AddCrtListEntryDefault) WithStatusCode(code int) *AddCrtListEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the add crt list entry default response +func (o *AddCrtListEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the add crt list entry default response +func (o *AddCrtListEntryDefault) WithConfigurationVersion(configurationVersion string) *AddCrtListEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add crt list entry default response +func (o *AddCrtListEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add crt list entry default response +func (o *AddCrtListEntryDefault) WithPayload(payload *models.Error) *AddCrtListEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add crt list entry default response +func (o *AddCrtListEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddCrtListEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/add_crt_list_entry_urlbuilder.go b/operations/s_s_l_runtime/add_crt_list_entry_urlbuilder.go new file mode 100644 index 00000000..9a25a122 --- /dev/null +++ b/operations/s_s_l_runtime/add_crt_list_entry_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// AddCrtListEntryURL generates an URL for the add crt list entry operation +type AddCrtListEntryURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddCrtListEntryURL) WithBasePath(bp string) *AddCrtListEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddCrtListEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddCrtListEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crt_lists/entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + nameQ := o.Name + if nameQ != "" { + qs.Set("name", nameQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddCrtListEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddCrtListEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddCrtListEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddCrtListEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddCrtListEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddCrtListEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/create_ca_file.go b/operations/s_s_l_runtime/create_ca_file.go new file mode 100644 index 00000000..d1117220 --- /dev/null +++ b/operations/s_s_l_runtime/create_ca_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateCaFileHandlerFunc turns a function with the right signature into a create ca file handler +type CreateCaFileHandlerFunc func(CreateCaFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateCaFileHandlerFunc) Handle(params CreateCaFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateCaFileHandler interface for that can handle valid create ca file params +type CreateCaFileHandler interface { + Handle(CreateCaFileParams, interface{}) middleware.Responder +} + +// NewCreateCaFile creates a new http.Handler for the create ca file operation +func NewCreateCaFile(ctx *middleware.Context, handler CreateCaFileHandler) *CreateCaFile { + return &CreateCaFile{Context: ctx, Handler: handler} +} + +/* + CreateCaFile swagger:route POST /services/haproxy/runtime/ssl_ca_files SSLRuntime createCaFile + +# Creates a new SSL CA file + +Creates a new SSL CA file using the runtime socket. +*/ +type CreateCaFile struct { + Context *middleware.Context + Handler CreateCaFileHandler +} + +func (o *CreateCaFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateCaFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/create_ca_file_parameters.go b/operations/s_s_l_runtime/create_ca_file_parameters.go new file mode 100644 index 00000000..39a671d5 --- /dev/null +++ b/operations/s_s_l_runtime/create_ca_file_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" +) + +// CreateCaFileMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateCaFileMaxParseMemory int64 = 32 << 20 + +// NewCreateCaFileParams creates a new CreateCaFileParams object +// +// There are no default values defined in the spec. +func NewCreateCaFileParams() CreateCaFileParams { + + return CreateCaFileParams{} +} + +// CreateCaFileParams contains all the bound params for the create ca file operation +// typically these are obtained from a http.Request +// +// swagger:parameters createCaFile +type CreateCaFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*CA certificate file + Required: true + In: formData + */ + FileUpload io.ReadCloser +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateCaFileParams() beforehand. +func (o *CreateCaFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(CreateCaFileMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + // Required: true + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateCaFileParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} diff --git a/operations/s_s_l_runtime/create_ca_file_responses.go b/operations/s_s_l_runtime/create_ca_file_responses.go new file mode 100644 index 00000000..732283af --- /dev/null +++ b/operations/s_s_l_runtime/create_ca_file_responses.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateCaFileCreatedCode is the HTTP code returned for type CreateCaFileCreated +const CreateCaFileCreatedCode int = 201 + +/* +CreateCaFileCreated SSL CA file created + +swagger:response createCaFileCreated +*/ +type CreateCaFileCreated struct { +} + +// NewCreateCaFileCreated creates CreateCaFileCreated with default headers values +func NewCreateCaFileCreated() *CreateCaFileCreated { + + return &CreateCaFileCreated{} +} + +// WriteResponse to the client +func (o *CreateCaFileCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateCaFileBadRequestCode is the HTTP code returned for type CreateCaFileBadRequest +const CreateCaFileBadRequestCode int = 400 + +/* +CreateCaFileBadRequest Bad request + +swagger:response createCaFileBadRequest +*/ +type CreateCaFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCaFileBadRequest creates CreateCaFileBadRequest with default headers values +func NewCreateCaFileBadRequest() *CreateCaFileBadRequest { + + return &CreateCaFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create ca file bad request response +func (o *CreateCaFileBadRequest) WithConfigurationVersion(configurationVersion string) *CreateCaFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create ca file bad request response +func (o *CreateCaFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create ca file bad request response +func (o *CreateCaFileBadRequest) WithPayload(payload *models.Error) *CreateCaFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ca file bad request response +func (o *CreateCaFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCaFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCaFileConflictCode is the HTTP code returned for type CreateCaFileConflict +const CreateCaFileConflictCode int = 409 + +/* +CreateCaFileConflict The specified resource already exists + +swagger:response createCaFileConflict +*/ +type CreateCaFileConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCaFileConflict creates CreateCaFileConflict with default headers values +func NewCreateCaFileConflict() *CreateCaFileConflict { + + return &CreateCaFileConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create ca file conflict response +func (o *CreateCaFileConflict) WithConfigurationVersion(configurationVersion string) *CreateCaFileConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create ca file conflict response +func (o *CreateCaFileConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create ca file conflict response +func (o *CreateCaFileConflict) WithPayload(payload *models.Error) *CreateCaFileConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ca file conflict response +func (o *CreateCaFileConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCaFileConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateCaFileDefault General Error + +swagger:response createCaFileDefault +*/ +type CreateCaFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCaFileDefault creates CreateCaFileDefault with default headers values +func NewCreateCaFileDefault(code int) *CreateCaFileDefault { + if code <= 0 { + code = 500 + } + + return &CreateCaFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create ca file default response +func (o *CreateCaFileDefault) WithStatusCode(code int) *CreateCaFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create ca file default response +func (o *CreateCaFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create ca file default response +func (o *CreateCaFileDefault) WithConfigurationVersion(configurationVersion string) *CreateCaFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create ca file default response +func (o *CreateCaFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create ca file default response +func (o *CreateCaFileDefault) WithPayload(payload *models.Error) *CreateCaFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create ca file default response +func (o *CreateCaFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCaFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/create_ca_file_urlbuilder.go b/operations/s_s_l_runtime/create_ca_file_urlbuilder.go new file mode 100644 index 00000000..39847f08 --- /dev/null +++ b/operations/s_s_l_runtime/create_ca_file_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateCaFileURL generates an URL for the create ca file operation +type CreateCaFileURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCaFileURL) WithBasePath(bp string) *CreateCaFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCaFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateCaFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_ca_files" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateCaFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateCaFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateCaFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateCaFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateCaFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateCaFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/create_cert.go b/operations/s_s_l_runtime/create_cert.go new file mode 100644 index 00000000..16f4ed2f --- /dev/null +++ b/operations/s_s_l_runtime/create_cert.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateCertHandlerFunc turns a function with the right signature into a create cert handler +type CreateCertHandlerFunc func(CreateCertParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateCertHandlerFunc) Handle(params CreateCertParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateCertHandler interface for that can handle valid create cert params +type CreateCertHandler interface { + Handle(CreateCertParams, interface{}) middleware.Responder +} + +// NewCreateCert creates a new http.Handler for the create cert operation +func NewCreateCert(ctx *middleware.Context, handler CreateCertHandler) *CreateCert { + return &CreateCert{Context: ctx, Handler: handler} +} + +/* + CreateCert swagger:route POST /services/haproxy/runtime/ssl_certs SSLRuntime createCert + +# Create a new SSL certificate file + +Creates a new SSL certificate file using the runtime socket. +*/ +type CreateCert struct { + Context *middleware.Context + Handler CreateCertHandler +} + +func (o *CreateCert) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateCertParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/create_cert_parameters.go b/operations/s_s_l_runtime/create_cert_parameters.go new file mode 100644 index 00000000..3ee87a25 --- /dev/null +++ b/operations/s_s_l_runtime/create_cert_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" +) + +// CreateCertMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateCertMaxParseMemory int64 = 32 << 20 + +// NewCreateCertParams creates a new CreateCertParams object +// +// There are no default values defined in the spec. +func NewCreateCertParams() CreateCertParams { + + return CreateCertParams{} +} + +// CreateCertParams contains all the bound params for the create cert operation +// typically these are obtained from a http.Request +// +// swagger:parameters createCert +type CreateCertParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Certificate file + Required: true + In: formData + */ + FileUpload io.ReadCloser +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateCertParams() beforehand. +func (o *CreateCertParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(CreateCertMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + // Required: true + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateCertParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} diff --git a/operations/s_s_l_runtime/create_cert_responses.go b/operations/s_s_l_runtime/create_cert_responses.go new file mode 100644 index 00000000..1360ccd0 --- /dev/null +++ b/operations/s_s_l_runtime/create_cert_responses.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateCertCreatedCode is the HTTP code returned for type CreateCertCreated +const CreateCertCreatedCode int = 201 + +/* +CreateCertCreated Certificate created + +swagger:response createCertCreated +*/ +type CreateCertCreated struct { +} + +// NewCreateCertCreated creates CreateCertCreated with default headers values +func NewCreateCertCreated() *CreateCertCreated { + + return &CreateCertCreated{} +} + +// WriteResponse to the client +func (o *CreateCertCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateCertBadRequestCode is the HTTP code returned for type CreateCertBadRequest +const CreateCertBadRequestCode int = 400 + +/* +CreateCertBadRequest Bad request + +swagger:response createCertBadRequest +*/ +type CreateCertBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCertBadRequest creates CreateCertBadRequest with default headers values +func NewCreateCertBadRequest() *CreateCertBadRequest { + + return &CreateCertBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create cert bad request response +func (o *CreateCertBadRequest) WithConfigurationVersion(configurationVersion string) *CreateCertBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create cert bad request response +func (o *CreateCertBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create cert bad request response +func (o *CreateCertBadRequest) WithPayload(payload *models.Error) *CreateCertBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cert bad request response +func (o *CreateCertBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCertBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCertConflictCode is the HTTP code returned for type CreateCertConflict +const CreateCertConflictCode int = 409 + +/* +CreateCertConflict The specified resource already exists + +swagger:response createCertConflict +*/ +type CreateCertConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCertConflict creates CreateCertConflict with default headers values +func NewCreateCertConflict() *CreateCertConflict { + + return &CreateCertConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create cert conflict response +func (o *CreateCertConflict) WithConfigurationVersion(configurationVersion string) *CreateCertConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create cert conflict response +func (o *CreateCertConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create cert conflict response +func (o *CreateCertConflict) WithPayload(payload *models.Error) *CreateCertConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cert conflict response +func (o *CreateCertConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCertConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateCertDefault General Error + +swagger:response createCertDefault +*/ +type CreateCertDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCertDefault creates CreateCertDefault with default headers values +func NewCreateCertDefault(code int) *CreateCertDefault { + if code <= 0 { + code = 500 + } + + return &CreateCertDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create cert default response +func (o *CreateCertDefault) WithStatusCode(code int) *CreateCertDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create cert default response +func (o *CreateCertDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create cert default response +func (o *CreateCertDefault) WithConfigurationVersion(configurationVersion string) *CreateCertDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create cert default response +func (o *CreateCertDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create cert default response +func (o *CreateCertDefault) WithPayload(payload *models.Error) *CreateCertDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create cert default response +func (o *CreateCertDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCertDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/create_cert_urlbuilder.go b/operations/s_s_l_runtime/create_cert_urlbuilder.go new file mode 100644 index 00000000..d496b244 --- /dev/null +++ b/operations/s_s_l_runtime/create_cert_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateCertURL generates an URL for the create cert operation +type CreateCertURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCertURL) WithBasePath(bp string) *CreateCertURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCertURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateCertURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_certs" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateCertURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateCertURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateCertURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateCertURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateCertURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateCertURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/create_crl.go b/operations/s_s_l_runtime/create_crl.go new file mode 100644 index 00000000..a9538173 --- /dev/null +++ b/operations/s_s_l_runtime/create_crl.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateCrlHandlerFunc turns a function with the right signature into a create crl handler +type CreateCrlHandlerFunc func(CreateCrlParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateCrlHandlerFunc) Handle(params CreateCrlParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateCrlHandler interface for that can handle valid create crl params +type CreateCrlHandler interface { + Handle(CreateCrlParams, interface{}) middleware.Responder +} + +// NewCreateCrl creates a new http.Handler for the create crl operation +func NewCreateCrl(ctx *middleware.Context, handler CreateCrlHandler) *CreateCrl { + return &CreateCrl{Context: ctx, Handler: handler} +} + +/* + CreateCrl swagger:route POST /services/haproxy/runtime/ssl_crl_files SSLRuntime createCrl + +# Create a new CRL file + +Creates a new CRL file with its contents using the runtime socket. +*/ +type CreateCrl struct { + Context *middleware.Context + Handler CreateCrlHandler +} + +func (o *CreateCrl) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateCrlParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/create_crl_parameters.go b/operations/s_s_l_runtime/create_crl_parameters.go new file mode 100644 index 00000000..e3550f50 --- /dev/null +++ b/operations/s_s_l_runtime/create_crl_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" +) + +// CreateCrlMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateCrlMaxParseMemory int64 = 32 << 20 + +// NewCreateCrlParams creates a new CreateCrlParams object +// +// There are no default values defined in the spec. +func NewCreateCrlParams() CreateCrlParams { + + return CreateCrlParams{} +} + +// CreateCrlParams contains all the bound params for the create crl operation +// typically these are obtained from a http.Request +// +// swagger:parameters createCrl +type CreateCrlParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*CRL file + Required: true + In: formData + */ + FileUpload io.ReadCloser +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateCrlParams() beforehand. +func (o *CreateCrlParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(CreateCrlMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + // Required: true + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateCrlParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} diff --git a/operations/s_s_l_runtime/create_crl_responses.go b/operations/s_s_l_runtime/create_crl_responses.go new file mode 100644 index 00000000..e7879e5a --- /dev/null +++ b/operations/s_s_l_runtime/create_crl_responses.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateCrlCreatedCode is the HTTP code returned for type CreateCrlCreated +const CreateCrlCreatedCode int = 201 + +/* +CreateCrlCreated CRL file created + +swagger:response createCrlCreated +*/ +type CreateCrlCreated struct { +} + +// NewCreateCrlCreated creates CreateCrlCreated with default headers values +func NewCreateCrlCreated() *CreateCrlCreated { + + return &CreateCrlCreated{} +} + +// WriteResponse to the client +func (o *CreateCrlCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(201) +} + +// CreateCrlBadRequestCode is the HTTP code returned for type CreateCrlBadRequest +const CreateCrlBadRequestCode int = 400 + +/* +CreateCrlBadRequest Bad request + +swagger:response createCrlBadRequest +*/ +type CreateCrlBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrlBadRequest creates CreateCrlBadRequest with default headers values +func NewCreateCrlBadRequest() *CreateCrlBadRequest { + + return &CreateCrlBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create crl bad request response +func (o *CreateCrlBadRequest) WithConfigurationVersion(configurationVersion string) *CreateCrlBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crl bad request response +func (o *CreateCrlBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crl bad request response +func (o *CreateCrlBadRequest) WithPayload(payload *models.Error) *CreateCrlBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crl bad request response +func (o *CreateCrlBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrlBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateCrlConflictCode is the HTTP code returned for type CreateCrlConflict +const CreateCrlConflictCode int = 409 + +/* +CreateCrlConflict The specified resource already exists + +swagger:response createCrlConflict +*/ +type CreateCrlConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrlConflict creates CreateCrlConflict with default headers values +func NewCreateCrlConflict() *CreateCrlConflict { + + return &CreateCrlConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create crl conflict response +func (o *CreateCrlConflict) WithConfigurationVersion(configurationVersion string) *CreateCrlConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crl conflict response +func (o *CreateCrlConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crl conflict response +func (o *CreateCrlConflict) WithPayload(payload *models.Error) *CreateCrlConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crl conflict response +func (o *CreateCrlConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrlConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateCrlDefault General Error + +swagger:response createCrlDefault +*/ +type CreateCrlDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateCrlDefault creates CreateCrlDefault with default headers values +func NewCreateCrlDefault(code int) *CreateCrlDefault { + if code <= 0 { + code = 500 + } + + return &CreateCrlDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create crl default response +func (o *CreateCrlDefault) WithStatusCode(code int) *CreateCrlDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create crl default response +func (o *CreateCrlDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create crl default response +func (o *CreateCrlDefault) WithConfigurationVersion(configurationVersion string) *CreateCrlDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create crl default response +func (o *CreateCrlDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create crl default response +func (o *CreateCrlDefault) WithPayload(payload *models.Error) *CreateCrlDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create crl default response +func (o *CreateCrlDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateCrlDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/create_crl_urlbuilder.go b/operations/s_s_l_runtime/create_crl_urlbuilder.go new file mode 100644 index 00000000..e2f3b0aa --- /dev/null +++ b/operations/s_s_l_runtime/create_crl_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateCrlURL generates an URL for the create crl operation +type CreateCrlURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCrlURL) WithBasePath(bp string) *CreateCrlURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateCrlURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateCrlURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crl_files" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateCrlURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateCrlURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateCrlURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateCrlURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateCrlURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateCrlURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/delete_ca_file.go b/operations/s_s_l_runtime/delete_ca_file.go new file mode 100644 index 00000000..f46b2c4e --- /dev/null +++ b/operations/s_s_l_runtime/delete_ca_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCaFileHandlerFunc turns a function with the right signature into a delete ca file handler +type DeleteCaFileHandlerFunc func(DeleteCaFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCaFileHandlerFunc) Handle(params DeleteCaFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteCaFileHandler interface for that can handle valid delete ca file params +type DeleteCaFileHandler interface { + Handle(DeleteCaFileParams, interface{}) middleware.Responder +} + +// NewDeleteCaFile creates a new http.Handler for the delete ca file operation +func NewDeleteCaFile(ctx *middleware.Context, handler DeleteCaFileHandler) *DeleteCaFile { + return &DeleteCaFile{Context: ctx, Handler: handler} +} + +/* + DeleteCaFile swagger:route DELETE /services/haproxy/runtime/ssl_ca_files/{name} SSLRuntime deleteCaFile + +# Deletes a CA file + +Deletes a CA file +*/ +type DeleteCaFile struct { + Context *middleware.Context + Handler DeleteCaFileHandler +} + +func (o *DeleteCaFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCaFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/delete_ca_file_parameters.go b/operations/s_s_l_runtime/delete_ca_file_parameters.go new file mode 100644 index 00000000..d615cd2e --- /dev/null +++ b/operations/s_s_l_runtime/delete_ca_file_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteCaFileParams creates a new DeleteCaFileParams object +// +// There are no default values defined in the spec. +func NewDeleteCaFileParams() DeleteCaFileParams { + + return DeleteCaFileParams{} +} + +// DeleteCaFileParams contains all the bound params for the delete ca file operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCaFile +type DeleteCaFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL CA file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCaFileParams() beforehand. +func (o *DeleteCaFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteCaFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/delete_ca_file_responses.go b/operations/s_s_l_runtime/delete_ca_file_responses.go new file mode 100644 index 00000000..b206f778 --- /dev/null +++ b/operations/s_s_l_runtime/delete_ca_file_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteCaFileNoContentCode is the HTTP code returned for type DeleteCaFileNoContent +const DeleteCaFileNoContentCode int = 204 + +/* +DeleteCaFileNoContent SSL CA deleted + +swagger:response deleteCaFileNoContent +*/ +type DeleteCaFileNoContent struct { +} + +// NewDeleteCaFileNoContent creates DeleteCaFileNoContent with default headers values +func NewDeleteCaFileNoContent() *DeleteCaFileNoContent { + + return &DeleteCaFileNoContent{} +} + +// WriteResponse to the client +func (o *DeleteCaFileNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteCaFileBadRequestCode is the HTTP code returned for type DeleteCaFileBadRequest +const DeleteCaFileBadRequestCode int = 400 + +/* +DeleteCaFileBadRequest Bad request + +swagger:response deleteCaFileBadRequest +*/ +type DeleteCaFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCaFileBadRequest creates DeleteCaFileBadRequest with default headers values +func NewDeleteCaFileBadRequest() *DeleteCaFileBadRequest { + + return &DeleteCaFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete ca file bad request response +func (o *DeleteCaFileBadRequest) WithConfigurationVersion(configurationVersion string) *DeleteCaFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete ca file bad request response +func (o *DeleteCaFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete ca file bad request response +func (o *DeleteCaFileBadRequest) WithPayload(payload *models.Error) *DeleteCaFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete ca file bad request response +func (o *DeleteCaFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCaFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteCaFileDefault General Error + +swagger:response deleteCaFileDefault +*/ +type DeleteCaFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCaFileDefault creates DeleteCaFileDefault with default headers values +func NewDeleteCaFileDefault(code int) *DeleteCaFileDefault { + if code <= 0 { + code = 500 + } + + return &DeleteCaFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete ca file default response +func (o *DeleteCaFileDefault) WithStatusCode(code int) *DeleteCaFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete ca file default response +func (o *DeleteCaFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete ca file default response +func (o *DeleteCaFileDefault) WithConfigurationVersion(configurationVersion string) *DeleteCaFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete ca file default response +func (o *DeleteCaFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete ca file default response +func (o *DeleteCaFileDefault) WithPayload(payload *models.Error) *DeleteCaFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete ca file default response +func (o *DeleteCaFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCaFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/delete_ca_file_urlbuilder.go b/operations/s_s_l_runtime/delete_ca_file_urlbuilder.go new file mode 100644 index 00000000..552a8cff --- /dev/null +++ b/operations/s_s_l_runtime/delete_ca_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteCaFileURL generates an URL for the delete ca file operation +type DeleteCaFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCaFileURL) WithBasePath(bp string) *DeleteCaFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCaFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCaFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_ca_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteCaFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCaFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCaFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCaFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCaFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCaFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCaFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/delete_cert.go b/operations/s_s_l_runtime/delete_cert.go new file mode 100644 index 00000000..2f8ce9d0 --- /dev/null +++ b/operations/s_s_l_runtime/delete_cert.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCertHandlerFunc turns a function with the right signature into a delete cert handler +type DeleteCertHandlerFunc func(DeleteCertParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCertHandlerFunc) Handle(params DeleteCertParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteCertHandler interface for that can handle valid delete cert params +type DeleteCertHandler interface { + Handle(DeleteCertParams, interface{}) middleware.Responder +} + +// NewDeleteCert creates a new http.Handler for the delete cert operation +func NewDeleteCert(ctx *middleware.Context, handler DeleteCertHandler) *DeleteCert { + return &DeleteCert{Context: ctx, Handler: handler} +} + +/* + DeleteCert swagger:route DELETE /services/haproxy/runtime/ssl_certs/{name} SSLRuntime deleteCert + +# Delete a certificate + +Deletes a certificate using the runtime socket. +*/ +type DeleteCert struct { + Context *middleware.Context + Handler DeleteCertHandler +} + +func (o *DeleteCert) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCertParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/delete_cert_parameters.go b/operations/s_s_l_runtime/delete_cert_parameters.go new file mode 100644 index 00000000..ac1f0001 --- /dev/null +++ b/operations/s_s_l_runtime/delete_cert_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteCertParams creates a new DeleteCertParams object +// +// There are no default values defined in the spec. +func NewDeleteCertParams() DeleteCertParams { + + return DeleteCertParams{} +} + +// DeleteCertParams contains all the bound params for the delete cert operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCert +type DeleteCertParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL certificate name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCertParams() beforehand. +func (o *DeleteCertParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteCertParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/delete_cert_responses.go b/operations/s_s_l_runtime/delete_cert_responses.go new file mode 100644 index 00000000..d6ef7aca --- /dev/null +++ b/operations/s_s_l_runtime/delete_cert_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteCertNoContentCode is the HTTP code returned for type DeleteCertNoContent +const DeleteCertNoContentCode int = 204 + +/* +DeleteCertNoContent File deleted + +swagger:response deleteCertNoContent +*/ +type DeleteCertNoContent struct { +} + +// NewDeleteCertNoContent creates DeleteCertNoContent with default headers values +func NewDeleteCertNoContent() *DeleteCertNoContent { + + return &DeleteCertNoContent{} +} + +// WriteResponse to the client +func (o *DeleteCertNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteCertBadRequestCode is the HTTP code returned for type DeleteCertBadRequest +const DeleteCertBadRequestCode int = 400 + +/* +DeleteCertBadRequest Bad request + +swagger:response deleteCertBadRequest +*/ +type DeleteCertBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCertBadRequest creates DeleteCertBadRequest with default headers values +func NewDeleteCertBadRequest() *DeleteCertBadRequest { + + return &DeleteCertBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete cert bad request response +func (o *DeleteCertBadRequest) WithConfigurationVersion(configurationVersion string) *DeleteCertBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete cert bad request response +func (o *DeleteCertBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete cert bad request response +func (o *DeleteCertBadRequest) WithPayload(payload *models.Error) *DeleteCertBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete cert bad request response +func (o *DeleteCertBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCertBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteCertDefault General Error + +swagger:response deleteCertDefault +*/ +type DeleteCertDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCertDefault creates DeleteCertDefault with default headers values +func NewDeleteCertDefault(code int) *DeleteCertDefault { + if code <= 0 { + code = 500 + } + + return &DeleteCertDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete cert default response +func (o *DeleteCertDefault) WithStatusCode(code int) *DeleteCertDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete cert default response +func (o *DeleteCertDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete cert default response +func (o *DeleteCertDefault) WithConfigurationVersion(configurationVersion string) *DeleteCertDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete cert default response +func (o *DeleteCertDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete cert default response +func (o *DeleteCertDefault) WithPayload(payload *models.Error) *DeleteCertDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete cert default response +func (o *DeleteCertDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCertDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/delete_cert_urlbuilder.go b/operations/s_s_l_runtime/delete_cert_urlbuilder.go new file mode 100644 index 00000000..7c6bf389 --- /dev/null +++ b/operations/s_s_l_runtime/delete_cert_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteCertURL generates an URL for the delete cert operation +type DeleteCertURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCertURL) WithBasePath(bp string) *DeleteCertURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCertURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCertURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_certs/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteCertURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCertURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCertURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCertURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCertURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCertURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCertURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/delete_crl.go b/operations/s_s_l_runtime/delete_crl.go new file mode 100644 index 00000000..5209af61 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crl.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCrlHandlerFunc turns a function with the right signature into a delete crl handler +type DeleteCrlHandlerFunc func(DeleteCrlParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCrlHandlerFunc) Handle(params DeleteCrlParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteCrlHandler interface for that can handle valid delete crl params +type DeleteCrlHandler interface { + Handle(DeleteCrlParams, interface{}) middleware.Responder +} + +// NewDeleteCrl creates a new http.Handler for the delete crl operation +func NewDeleteCrl(ctx *middleware.Context, handler DeleteCrlHandler) *DeleteCrl { + return &DeleteCrl{Context: ctx, Handler: handler} +} + +/* + DeleteCrl swagger:route DELETE /services/haproxy/runtime/ssl_crl_files/{name} SSLRuntime deleteCrl + +# Delete a CRL file + +Deletes a CRL file using the runtime socket. +*/ +type DeleteCrl struct { + Context *middleware.Context + Handler DeleteCrlHandler +} + +func (o *DeleteCrl) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCrlParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/delete_crl_parameters.go b/operations/s_s_l_runtime/delete_crl_parameters.go new file mode 100644 index 00000000..58b11f14 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crl_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteCrlParams creates a new DeleteCrlParams object +// +// There are no default values defined in the spec. +func NewDeleteCrlParams() DeleteCrlParams { + + return DeleteCrlParams{} +} + +// DeleteCrlParams contains all the bound params for the delete crl operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCrl +type DeleteCrlParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*CRL file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCrlParams() beforehand. +func (o *DeleteCrlParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteCrlParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/delete_crl_responses.go b/operations/s_s_l_runtime/delete_crl_responses.go new file mode 100644 index 00000000..3b92e898 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crl_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteCrlNoContentCode is the HTTP code returned for type DeleteCrlNoContent +const DeleteCrlNoContentCode int = 204 + +/* +DeleteCrlNoContent File deleted + +swagger:response deleteCrlNoContent +*/ +type DeleteCrlNoContent struct { +} + +// NewDeleteCrlNoContent creates DeleteCrlNoContent with default headers values +func NewDeleteCrlNoContent() *DeleteCrlNoContent { + + return &DeleteCrlNoContent{} +} + +// WriteResponse to the client +func (o *DeleteCrlNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteCrlBadRequestCode is the HTTP code returned for type DeleteCrlBadRequest +const DeleteCrlBadRequestCode int = 400 + +/* +DeleteCrlBadRequest Bad request + +swagger:response deleteCrlBadRequest +*/ +type DeleteCrlBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrlBadRequest creates DeleteCrlBadRequest with default headers values +func NewDeleteCrlBadRequest() *DeleteCrlBadRequest { + + return &DeleteCrlBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete crl bad request response +func (o *DeleteCrlBadRequest) WithConfigurationVersion(configurationVersion string) *DeleteCrlBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crl bad request response +func (o *DeleteCrlBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crl bad request response +func (o *DeleteCrlBadRequest) WithPayload(payload *models.Error) *DeleteCrlBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crl bad request response +func (o *DeleteCrlBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrlBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteCrlDefault General Error + +swagger:response deleteCrlDefault +*/ +type DeleteCrlDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrlDefault creates DeleteCrlDefault with default headers values +func NewDeleteCrlDefault(code int) *DeleteCrlDefault { + if code <= 0 { + code = 500 + } + + return &DeleteCrlDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete crl default response +func (o *DeleteCrlDefault) WithStatusCode(code int) *DeleteCrlDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete crl default response +func (o *DeleteCrlDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete crl default response +func (o *DeleteCrlDefault) WithConfigurationVersion(configurationVersion string) *DeleteCrlDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crl default response +func (o *DeleteCrlDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crl default response +func (o *DeleteCrlDefault) WithPayload(payload *models.Error) *DeleteCrlDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crl default response +func (o *DeleteCrlDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrlDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/delete_crl_urlbuilder.go b/operations/s_s_l_runtime/delete_crl_urlbuilder.go new file mode 100644 index 00000000..95cccf86 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crl_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteCrlURL generates an URL for the delete crl operation +type DeleteCrlURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrlURL) WithBasePath(bp string) *DeleteCrlURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrlURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCrlURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crl_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteCrlURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCrlURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCrlURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCrlURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCrlURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCrlURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCrlURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/delete_crt_list_entry.go b/operations/s_s_l_runtime/delete_crt_list_entry.go new file mode 100644 index 00000000..0f004d09 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crt_list_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteCrtListEntryHandlerFunc turns a function with the right signature into a delete crt list entry handler +type DeleteCrtListEntryHandlerFunc func(DeleteCrtListEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteCrtListEntryHandlerFunc) Handle(params DeleteCrtListEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteCrtListEntryHandler interface for that can handle valid delete crt list entry params +type DeleteCrtListEntryHandler interface { + Handle(DeleteCrtListEntryParams, interface{}) middleware.Responder +} + +// NewDeleteCrtListEntry creates a new http.Handler for the delete crt list entry operation +func NewDeleteCrtListEntry(ctx *middleware.Context, handler DeleteCrtListEntryHandler) *DeleteCrtListEntry { + return &DeleteCrtListEntry{Context: ctx, Handler: handler} +} + +/* + DeleteCrtListEntry swagger:route DELETE /services/haproxy/runtime/ssl_crt_lists/entries SSLRuntime deleteCrtListEntry + +# Delete an entry from a crt-list + +Deletes a single entry from the given crt-list using the runtime socket. +*/ +type DeleteCrtListEntry struct { + Context *middleware.Context + Handler DeleteCrtListEntryHandler +} + +func (o *DeleteCrtListEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteCrtListEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/delete_crt_list_entry_parameters.go b/operations/s_s_l_runtime/delete_crt_list_entry_parameters.go new file mode 100644 index 00000000..15c5ead0 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crt_list_entry_parameters.go @@ -0,0 +1,176 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteCrtListEntryParams creates a new DeleteCrtListEntryParams object +// +// There are no default values defined in the spec. +func NewDeleteCrtListEntryParams() DeleteCrtListEntryParams { + + return DeleteCrtListEntryParams{} +} + +// DeleteCrtListEntryParams contains all the bound params for the delete crt list entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteCrtListEntry +type DeleteCrtListEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL cert entry name + Required: true + In: query + */ + CertFile string + /*The line number where the entry is located, in case several entries share the same certificate. + Minimum: 1 + In: query + */ + LineNumber *int64 + /*SSL crt list name + Required: true + In: query + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteCrtListEntryParams() beforehand. +func (o *DeleteCrtListEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qCertFile, qhkCertFile, _ := qs.GetOK("cert_file") + if err := o.bindCertFile(qCertFile, qhkCertFile, route.Formats); err != nil { + res = append(res, err) + } + + qLineNumber, qhkLineNumber, _ := qs.GetOK("line_number") + if err := o.bindLineNumber(qLineNumber, qhkLineNumber, route.Formats); err != nil { + res = append(res, err) + } + + qName, qhkName, _ := qs.GetOK("name") + if err := o.bindName(qName, qhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCertFile binds and validates parameter CertFile from query. +func (o *DeleteCrtListEntryParams) bindCertFile(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("cert_file", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("cert_file", "query", raw); err != nil { + return err + } + o.CertFile = raw + + return nil +} + +// bindLineNumber binds and validates parameter LineNumber from query. +func (o *DeleteCrtListEntryParams) bindLineNumber(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("line_number", "query", "int64", raw) + } + o.LineNumber = &value + + if err := o.validateLineNumber(formats); err != nil { + return err + } + + return nil +} + +// validateLineNumber carries on validations for parameter LineNumber +func (o *DeleteCrtListEntryParams) validateLineNumber(formats strfmt.Registry) error { + + if err := validate.MinimumInt("line_number", "query", *o.LineNumber, 1, false); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from query. +func (o *DeleteCrtListEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("name", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("name", "query", raw); err != nil { + return err + } + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/delete_crt_list_entry_responses.go b/operations/s_s_l_runtime/delete_crt_list_entry_responses.go new file mode 100644 index 00000000..420bb7b7 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crt_list_entry_responses.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteCrtListEntryNoContentCode is the HTTP code returned for type DeleteCrtListEntryNoContent +const DeleteCrtListEntryNoContentCode int = 204 + +/* +DeleteCrtListEntryNoContent Successful operation + +swagger:response deleteCrtListEntryNoContent +*/ +type DeleteCrtListEntryNoContent struct { +} + +// NewDeleteCrtListEntryNoContent creates DeleteCrtListEntryNoContent with default headers values +func NewDeleteCrtListEntryNoContent() *DeleteCrtListEntryNoContent { + + return &DeleteCrtListEntryNoContent{} +} + +// WriteResponse to the client +func (o *DeleteCrtListEntryNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteCrtListEntryBadRequestCode is the HTTP code returned for type DeleteCrtListEntryBadRequest +const DeleteCrtListEntryBadRequestCode int = 400 + +/* +DeleteCrtListEntryBadRequest Bad request + +swagger:response deleteCrtListEntryBadRequest +*/ +type DeleteCrtListEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrtListEntryBadRequest creates DeleteCrtListEntryBadRequest with default headers values +func NewDeleteCrtListEntryBadRequest() *DeleteCrtListEntryBadRequest { + + return &DeleteCrtListEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete crt list entry bad request response +func (o *DeleteCrtListEntryBadRequest) WithConfigurationVersion(configurationVersion string) *DeleteCrtListEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crt list entry bad request response +func (o *DeleteCrtListEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crt list entry bad request response +func (o *DeleteCrtListEntryBadRequest) WithPayload(payload *models.Error) *DeleteCrtListEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crt list entry bad request response +func (o *DeleteCrtListEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrtListEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteCrtListEntryNotFoundCode is the HTTP code returned for type DeleteCrtListEntryNotFound +const DeleteCrtListEntryNotFoundCode int = 404 + +/* +DeleteCrtListEntryNotFound The specified resource was not found + +swagger:response deleteCrtListEntryNotFound +*/ +type DeleteCrtListEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrtListEntryNotFound creates DeleteCrtListEntryNotFound with default headers values +func NewDeleteCrtListEntryNotFound() *DeleteCrtListEntryNotFound { + + return &DeleteCrtListEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete crt list entry not found response +func (o *DeleteCrtListEntryNotFound) WithConfigurationVersion(configurationVersion string) *DeleteCrtListEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crt list entry not found response +func (o *DeleteCrtListEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crt list entry not found response +func (o *DeleteCrtListEntryNotFound) WithPayload(payload *models.Error) *DeleteCrtListEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crt list entry not found response +func (o *DeleteCrtListEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrtListEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteCrtListEntryDefault General Error + +swagger:response deleteCrtListEntryDefault +*/ +type DeleteCrtListEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteCrtListEntryDefault creates DeleteCrtListEntryDefault with default headers values +func NewDeleteCrtListEntryDefault(code int) *DeleteCrtListEntryDefault { + if code <= 0 { + code = 500 + } + + return &DeleteCrtListEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete crt list entry default response +func (o *DeleteCrtListEntryDefault) WithStatusCode(code int) *DeleteCrtListEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete crt list entry default response +func (o *DeleteCrtListEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete crt list entry default response +func (o *DeleteCrtListEntryDefault) WithConfigurationVersion(configurationVersion string) *DeleteCrtListEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete crt list entry default response +func (o *DeleteCrtListEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete crt list entry default response +func (o *DeleteCrtListEntryDefault) WithPayload(payload *models.Error) *DeleteCrtListEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete crt list entry default response +func (o *DeleteCrtListEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteCrtListEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/delete_crt_list_entry_urlbuilder.go b/operations/s_s_l_runtime/delete_crt_list_entry_urlbuilder.go new file mode 100644 index 00000000..30246069 --- /dev/null +++ b/operations/s_s_l_runtime/delete_crt_list_entry_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// DeleteCrtListEntryURL generates an URL for the delete crt list entry operation +type DeleteCrtListEntryURL struct { + CertFile string + LineNumber *int64 + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrtListEntryURL) WithBasePath(bp string) *DeleteCrtListEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteCrtListEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteCrtListEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crt_lists/entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + certFileQ := o.CertFile + if certFileQ != "" { + qs.Set("cert_file", certFileQ) + } + + var lineNumberQ string + if o.LineNumber != nil { + lineNumberQ = swag.FormatInt64(*o.LineNumber) + } + if lineNumberQ != "" { + qs.Set("line_number", lineNumberQ) + } + + nameQ := o.Name + if nameQ != "" { + qs.Set("name", nameQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteCrtListEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteCrtListEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteCrtListEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteCrtListEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteCrtListEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteCrtListEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_all_ca_files.go b/operations/s_s_l_runtime/get_all_ca_files.go new file mode 100644 index 00000000..433b6ec1 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_ca_files.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllCaFilesHandlerFunc turns a function with the right signature into a get all ca files handler +type GetAllCaFilesHandlerFunc func(GetAllCaFilesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllCaFilesHandlerFunc) Handle(params GetAllCaFilesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllCaFilesHandler interface for that can handle valid get all ca files params +type GetAllCaFilesHandler interface { + Handle(GetAllCaFilesParams, interface{}) middleware.Responder +} + +// NewGetAllCaFiles creates a new http.Handler for the get all ca files operation +func NewGetAllCaFiles(ctx *middleware.Context, handler GetAllCaFilesHandler) *GetAllCaFiles { + return &GetAllCaFiles{Context: ctx, Handler: handler} +} + +/* + GetAllCaFiles swagger:route GET /services/haproxy/runtime/ssl_ca_files SSLRuntime getAllCaFiles + +# Return an array of all SSL CA files + +Returns all SSL CA files using the runtime socket. +*/ +type GetAllCaFiles struct { + Context *middleware.Context + Handler GetAllCaFilesHandler +} + +func (o *GetAllCaFiles) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllCaFilesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_all_ca_files_parameters.go b/operations/s_s_l_runtime/get_all_ca_files_parameters.go new file mode 100644 index 00000000..9ff7b51c --- /dev/null +++ b/operations/s_s_l_runtime/get_all_ca_files_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllCaFilesParams creates a new GetAllCaFilesParams object +// +// There are no default values defined in the spec. +func NewGetAllCaFilesParams() GetAllCaFilesParams { + + return GetAllCaFilesParams{} +} + +// GetAllCaFilesParams contains all the bound params for the get all ca files operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllCaFiles +type GetAllCaFilesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllCaFilesParams() beforehand. +func (o *GetAllCaFilesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/s_s_l_runtime/get_all_ca_files_responses.go b/operations/s_s_l_runtime/get_all_ca_files_responses.go new file mode 100644 index 00000000..69f3ea4b --- /dev/null +++ b/operations/s_s_l_runtime/get_all_ca_files_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllCaFilesOKCode is the HTTP code returned for type GetAllCaFilesOK +const GetAllCaFilesOKCode int = 200 + +/* +GetAllCaFilesOK Successful operation + +swagger:response getAllCaFilesOK +*/ +type GetAllCaFilesOK struct { + + /* + In: Body + */ + Payload models.SslCaFiles `json:"body,omitempty"` +} + +// NewGetAllCaFilesOK creates GetAllCaFilesOK with default headers values +func NewGetAllCaFilesOK() *GetAllCaFilesOK { + + return &GetAllCaFilesOK{} +} + +// WithPayload adds the payload to the get all ca files o k response +func (o *GetAllCaFilesOK) WithPayload(payload models.SslCaFiles) *GetAllCaFilesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all ca files o k response +func (o *GetAllCaFilesOK) SetPayload(payload models.SslCaFiles) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCaFilesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCaFiles{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllCaFilesDefault General Error + +swagger:response getAllCaFilesDefault +*/ +type GetAllCaFilesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllCaFilesDefault creates GetAllCaFilesDefault with default headers values +func NewGetAllCaFilesDefault(code int) *GetAllCaFilesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllCaFilesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all ca files default response +func (o *GetAllCaFilesDefault) WithStatusCode(code int) *GetAllCaFilesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all ca files default response +func (o *GetAllCaFilesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all ca files default response +func (o *GetAllCaFilesDefault) WithConfigurationVersion(configurationVersion string) *GetAllCaFilesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all ca files default response +func (o *GetAllCaFilesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all ca files default response +func (o *GetAllCaFilesDefault) WithPayload(payload *models.Error) *GetAllCaFilesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all ca files default response +func (o *GetAllCaFilesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCaFilesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_all_ca_files_urlbuilder.go b/operations/s_s_l_runtime/get_all_ca_files_urlbuilder.go new file mode 100644 index 00000000..19cf80e4 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_ca_files_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllCaFilesURL generates an URL for the get all ca files operation +type GetAllCaFilesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCaFilesURL) WithBasePath(bp string) *GetAllCaFilesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCaFilesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllCaFilesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_ca_files" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllCaFilesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllCaFilesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllCaFilesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllCaFilesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllCaFilesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllCaFilesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_all_certs.go b/operations/s_s_l_runtime/get_all_certs.go new file mode 100644 index 00000000..6b0e40cd --- /dev/null +++ b/operations/s_s_l_runtime/get_all_certs.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllCertsHandlerFunc turns a function with the right signature into a get all certs handler +type GetAllCertsHandlerFunc func(GetAllCertsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllCertsHandlerFunc) Handle(params GetAllCertsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllCertsHandler interface for that can handle valid get all certs params +type GetAllCertsHandler interface { + Handle(GetAllCertsParams, interface{}) middleware.Responder +} + +// NewGetAllCerts creates a new http.Handler for the get all certs operation +func NewGetAllCerts(ctx *middleware.Context, handler GetAllCertsHandler) *GetAllCerts { + return &GetAllCerts{Context: ctx, Handler: handler} +} + +/* + GetAllCerts swagger:route GET /services/haproxy/runtime/ssl_certs SSLRuntime getAllCerts + +# Return a list of SSL certificate files + +Returns certificate files descriptions from runtime. +*/ +type GetAllCerts struct { + Context *middleware.Context + Handler GetAllCertsHandler +} + +func (o *GetAllCerts) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllCertsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_all_certs_parameters.go b/operations/s_s_l_runtime/get_all_certs_parameters.go new file mode 100644 index 00000000..ffc76108 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_certs_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllCertsParams creates a new GetAllCertsParams object +// +// There are no default values defined in the spec. +func NewGetAllCertsParams() GetAllCertsParams { + + return GetAllCertsParams{} +} + +// GetAllCertsParams contains all the bound params for the get all certs operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllCerts +type GetAllCertsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllCertsParams() beforehand. +func (o *GetAllCertsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/s_s_l_runtime/get_all_certs_responses.go b/operations/s_s_l_runtime/get_all_certs_responses.go new file mode 100644 index 00000000..13f4051b --- /dev/null +++ b/operations/s_s_l_runtime/get_all_certs_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllCertsOKCode is the HTTP code returned for type GetAllCertsOK +const GetAllCertsOKCode int = 200 + +/* +GetAllCertsOK Successful operation + +swagger:response getAllCertsOK +*/ +type GetAllCertsOK struct { + + /* + In: Body + */ + Payload models.SslCertificates `json:"body,omitempty"` +} + +// NewGetAllCertsOK creates GetAllCertsOK with default headers values +func NewGetAllCertsOK() *GetAllCertsOK { + + return &GetAllCertsOK{} +} + +// WithPayload adds the payload to the get all certs o k response +func (o *GetAllCertsOK) WithPayload(payload models.SslCertificates) *GetAllCertsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all certs o k response +func (o *GetAllCertsOK) SetPayload(payload models.SslCertificates) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCertsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCertificates{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllCertsDefault General Error + +swagger:response getAllCertsDefault +*/ +type GetAllCertsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllCertsDefault creates GetAllCertsDefault with default headers values +func NewGetAllCertsDefault(code int) *GetAllCertsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllCertsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all certs default response +func (o *GetAllCertsDefault) WithStatusCode(code int) *GetAllCertsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all certs default response +func (o *GetAllCertsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all certs default response +func (o *GetAllCertsDefault) WithConfigurationVersion(configurationVersion string) *GetAllCertsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all certs default response +func (o *GetAllCertsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all certs default response +func (o *GetAllCertsDefault) WithPayload(payload *models.Error) *GetAllCertsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all certs default response +func (o *GetAllCertsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCertsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_all_certs_urlbuilder.go b/operations/s_s_l_runtime/get_all_certs_urlbuilder.go new file mode 100644 index 00000000..aafe5920 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_certs_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllCertsURL generates an URL for the get all certs operation +type GetAllCertsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCertsURL) WithBasePath(bp string) *GetAllCertsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCertsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllCertsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_certs" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllCertsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllCertsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllCertsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllCertsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllCertsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllCertsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_all_crl.go b/operations/s_s_l_runtime/get_all_crl.go new file mode 100644 index 00000000..7c6125c7 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crl.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllCrlHandlerFunc turns a function with the right signature into a get all crl handler +type GetAllCrlHandlerFunc func(GetAllCrlParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllCrlHandlerFunc) Handle(params GetAllCrlParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllCrlHandler interface for that can handle valid get all crl params +type GetAllCrlHandler interface { + Handle(GetAllCrlParams, interface{}) middleware.Responder +} + +// NewGetAllCrl creates a new http.Handler for the get all crl operation +func NewGetAllCrl(ctx *middleware.Context, handler GetAllCrlHandler) *GetAllCrl { + return &GetAllCrl{Context: ctx, Handler: handler} +} + +/* + GetAllCrl swagger:route GET /services/haproxy/runtime/ssl_crl_files SSLRuntime getAllCrl + +# Return an array of all the CRL files + +Returns all the certificate revocation list files using the runtime socket. +*/ +type GetAllCrl struct { + Context *middleware.Context + Handler GetAllCrlHandler +} + +func (o *GetAllCrl) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllCrlParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_all_crl_parameters.go b/operations/s_s_l_runtime/get_all_crl_parameters.go new file mode 100644 index 00000000..d0b15220 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crl_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllCrlParams creates a new GetAllCrlParams object +// +// There are no default values defined in the spec. +func NewGetAllCrlParams() GetAllCrlParams { + + return GetAllCrlParams{} +} + +// GetAllCrlParams contains all the bound params for the get all crl operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllCrl +type GetAllCrlParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllCrlParams() beforehand. +func (o *GetAllCrlParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/s_s_l_runtime/get_all_crl_responses.go b/operations/s_s_l_runtime/get_all_crl_responses.go new file mode 100644 index 00000000..68c950cd --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crl_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllCrlOKCode is the HTTP code returned for type GetAllCrlOK +const GetAllCrlOKCode int = 200 + +/* +GetAllCrlOK Successful operation + +swagger:response getAllCrlOK +*/ +type GetAllCrlOK struct { + + /* + In: Body + */ + Payload models.SslCrls `json:"body,omitempty"` +} + +// NewGetAllCrlOK creates GetAllCrlOK with default headers values +func NewGetAllCrlOK() *GetAllCrlOK { + + return &GetAllCrlOK{} +} + +// WithPayload adds the payload to the get all crl o k response +func (o *GetAllCrlOK) WithPayload(payload models.SslCrls) *GetAllCrlOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all crl o k response +func (o *GetAllCrlOK) SetPayload(payload models.SslCrls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCrlOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCrls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllCrlDefault General Error + +swagger:response getAllCrlDefault +*/ +type GetAllCrlDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllCrlDefault creates GetAllCrlDefault with default headers values +func NewGetAllCrlDefault(code int) *GetAllCrlDefault { + if code <= 0 { + code = 500 + } + + return &GetAllCrlDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all crl default response +func (o *GetAllCrlDefault) WithStatusCode(code int) *GetAllCrlDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all crl default response +func (o *GetAllCrlDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all crl default response +func (o *GetAllCrlDefault) WithConfigurationVersion(configurationVersion string) *GetAllCrlDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all crl default response +func (o *GetAllCrlDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all crl default response +func (o *GetAllCrlDefault) WithPayload(payload *models.Error) *GetAllCrlDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all crl default response +func (o *GetAllCrlDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCrlDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_all_crl_urlbuilder.go b/operations/s_s_l_runtime/get_all_crl_urlbuilder.go new file mode 100644 index 00000000..af859305 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crl_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllCrlURL generates an URL for the get all crl operation +type GetAllCrlURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCrlURL) WithBasePath(bp string) *GetAllCrlURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCrlURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllCrlURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crl_files" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllCrlURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllCrlURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllCrlURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllCrlURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllCrlURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllCrlURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_all_crt_list_entries.go b/operations/s_s_l_runtime/get_all_crt_list_entries.go new file mode 100644 index 00000000..a9668905 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_list_entries.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllCrtListEntriesHandlerFunc turns a function with the right signature into a get all crt list entries handler +type GetAllCrtListEntriesHandlerFunc func(GetAllCrtListEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllCrtListEntriesHandlerFunc) Handle(params GetAllCrtListEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllCrtListEntriesHandler interface for that can handle valid get all crt list entries params +type GetAllCrtListEntriesHandler interface { + Handle(GetAllCrtListEntriesParams, interface{}) middleware.Responder +} + +// NewGetAllCrtListEntries creates a new http.Handler for the get all crt list entries operation +func NewGetAllCrtListEntries(ctx *middleware.Context, handler GetAllCrtListEntriesHandler) *GetAllCrtListEntries { + return &GetAllCrtListEntries{Context: ctx, Handler: handler} +} + +/* + GetAllCrtListEntries swagger:route GET /services/haproxy/runtime/ssl_crt_lists/entries SSLRuntime getAllCrtListEntries + +# Get all the entries inside a crt-list + +Returns an array of entries present inside the given crt-list file. Their index can be used to delete them. +*/ +type GetAllCrtListEntries struct { + Context *middleware.Context + Handler GetAllCrtListEntriesHandler +} + +func (o *GetAllCrtListEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllCrtListEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_all_crt_list_entries_parameters.go b/operations/s_s_l_runtime/get_all_crt_list_entries_parameters.go new file mode 100644 index 00000000..6bfaf35e --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_list_entries_parameters.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetAllCrtListEntriesParams creates a new GetAllCrtListEntriesParams object +// +// There are no default values defined in the spec. +func NewGetAllCrtListEntriesParams() GetAllCrtListEntriesParams { + + return GetAllCrtListEntriesParams{} +} + +// GetAllCrtListEntriesParams contains all the bound params for the get all crt list entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllCrtListEntries +type GetAllCrtListEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL crt-list filename + Required: true + In: query + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllCrtListEntriesParams() beforehand. +func (o *GetAllCrtListEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qName, qhkName, _ := qs.GetOK("name") + if err := o.bindName(qName, qhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from query. +func (o *GetAllCrtListEntriesParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("name", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("name", "query", raw); err != nil { + return err + } + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/get_all_crt_list_entries_responses.go b/operations/s_s_l_runtime/get_all_crt_list_entries_responses.go new file mode 100644 index 00000000..fd93dc05 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_list_entries_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllCrtListEntriesOKCode is the HTTP code returned for type GetAllCrtListEntriesOK +const GetAllCrtListEntriesOKCode int = 200 + +/* +GetAllCrtListEntriesOK Successful operation + +swagger:response getAllCrtListEntriesOK +*/ +type GetAllCrtListEntriesOK struct { + + /* + In: Body + */ + Payload models.SslCrtListEntries `json:"body,omitempty"` +} + +// NewGetAllCrtListEntriesOK creates GetAllCrtListEntriesOK with default headers values +func NewGetAllCrtListEntriesOK() *GetAllCrtListEntriesOK { + + return &GetAllCrtListEntriesOK{} +} + +// WithPayload adds the payload to the get all crt list entries o k response +func (o *GetAllCrtListEntriesOK) WithPayload(payload models.SslCrtListEntries) *GetAllCrtListEntriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all crt list entries o k response +func (o *GetAllCrtListEntriesOK) SetPayload(payload models.SslCrtListEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCrtListEntriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCrtListEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllCrtListEntriesDefault General Error + +swagger:response getAllCrtListEntriesDefault +*/ +type GetAllCrtListEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllCrtListEntriesDefault creates GetAllCrtListEntriesDefault with default headers values +func NewGetAllCrtListEntriesDefault(code int) *GetAllCrtListEntriesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllCrtListEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all crt list entries default response +func (o *GetAllCrtListEntriesDefault) WithStatusCode(code int) *GetAllCrtListEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all crt list entries default response +func (o *GetAllCrtListEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all crt list entries default response +func (o *GetAllCrtListEntriesDefault) WithConfigurationVersion(configurationVersion string) *GetAllCrtListEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all crt list entries default response +func (o *GetAllCrtListEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all crt list entries default response +func (o *GetAllCrtListEntriesDefault) WithPayload(payload *models.Error) *GetAllCrtListEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all crt list entries default response +func (o *GetAllCrtListEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCrtListEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_all_crt_list_entries_urlbuilder.go b/operations/s_s_l_runtime/get_all_crt_list_entries_urlbuilder.go new file mode 100644 index 00000000..e5770430 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_list_entries_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllCrtListEntriesURL generates an URL for the get all crt list entries operation +type GetAllCrtListEntriesURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCrtListEntriesURL) WithBasePath(bp string) *GetAllCrtListEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCrtListEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllCrtListEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crt_lists/entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + nameQ := o.Name + if nameQ != "" { + qs.Set("name", nameQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllCrtListEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllCrtListEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllCrtListEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllCrtListEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllCrtListEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllCrtListEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_all_crt_lists.go b/operations/s_s_l_runtime/get_all_crt_lists.go new file mode 100644 index 00000000..4d621cd2 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_lists.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllCrtListsHandlerFunc turns a function with the right signature into a get all crt lists handler +type GetAllCrtListsHandlerFunc func(GetAllCrtListsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllCrtListsHandlerFunc) Handle(params GetAllCrtListsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllCrtListsHandler interface for that can handle valid get all crt lists params +type GetAllCrtListsHandler interface { + Handle(GetAllCrtListsParams, interface{}) middleware.Responder +} + +// NewGetAllCrtLists creates a new http.Handler for the get all crt lists operation +func NewGetAllCrtLists(ctx *middleware.Context, handler GetAllCrtListsHandler) *GetAllCrtLists { + return &GetAllCrtLists{Context: ctx, Handler: handler} +} + +/* + GetAllCrtLists swagger:route GET /services/haproxy/runtime/ssl_crt_lists SSLRuntime getAllCrtLists + +# Get the list of all crt-list files + +Returns an array of crt-list file descriptions from runtime. +*/ +type GetAllCrtLists struct { + Context *middleware.Context + Handler GetAllCrtListsHandler +} + +func (o *GetAllCrtLists) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllCrtListsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_all_crt_lists_parameters.go b/operations/s_s_l_runtime/get_all_crt_lists_parameters.go new file mode 100644 index 00000000..31246576 --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_lists_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllCrtListsParams creates a new GetAllCrtListsParams object +// +// There are no default values defined in the spec. +func NewGetAllCrtListsParams() GetAllCrtListsParams { + + return GetAllCrtListsParams{} +} + +// GetAllCrtListsParams contains all the bound params for the get all crt lists operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllCrtLists +type GetAllCrtListsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllCrtListsParams() beforehand. +func (o *GetAllCrtListsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/s_s_l_runtime/get_all_crt_lists_responses.go b/operations/s_s_l_runtime/get_all_crt_lists_responses.go new file mode 100644 index 00000000..ed514b7d --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_lists_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllCrtListsOKCode is the HTTP code returned for type GetAllCrtListsOK +const GetAllCrtListsOKCode int = 200 + +/* +GetAllCrtListsOK Successful operation + +swagger:response getAllCrtListsOK +*/ +type GetAllCrtListsOK struct { + + /* + In: Body + */ + Payload models.SslCrtLists `json:"body,omitempty"` +} + +// NewGetAllCrtListsOK creates GetAllCrtListsOK with default headers values +func NewGetAllCrtListsOK() *GetAllCrtListsOK { + + return &GetAllCrtListsOK{} +} + +// WithPayload adds the payload to the get all crt lists o k response +func (o *GetAllCrtListsOK) WithPayload(payload models.SslCrtLists) *GetAllCrtListsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all crt lists o k response +func (o *GetAllCrtListsOK) SetPayload(payload models.SslCrtLists) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCrtListsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCrtLists{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllCrtListsDefault General Error + +swagger:response getAllCrtListsDefault +*/ +type GetAllCrtListsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllCrtListsDefault creates GetAllCrtListsDefault with default headers values +func NewGetAllCrtListsDefault(code int) *GetAllCrtListsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllCrtListsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all crt lists default response +func (o *GetAllCrtListsDefault) WithStatusCode(code int) *GetAllCrtListsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all crt lists default response +func (o *GetAllCrtListsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all crt lists default response +func (o *GetAllCrtListsDefault) WithConfigurationVersion(configurationVersion string) *GetAllCrtListsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all crt lists default response +func (o *GetAllCrtListsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all crt lists default response +func (o *GetAllCrtListsDefault) WithPayload(payload *models.Error) *GetAllCrtListsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all crt lists default response +func (o *GetAllCrtListsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllCrtListsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_all_crt_lists_urlbuilder.go b/operations/s_s_l_runtime/get_all_crt_lists_urlbuilder.go new file mode 100644 index 00000000..e07794ca --- /dev/null +++ b/operations/s_s_l_runtime/get_all_crt_lists_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllCrtListsURL generates an URL for the get all crt lists operation +type GetAllCrtListsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCrtListsURL) WithBasePath(bp string) *GetAllCrtListsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllCrtListsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllCrtListsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crt_lists" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllCrtListsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllCrtListsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllCrtListsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllCrtListsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllCrtListsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllCrtListsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_ca_entry.go b/operations/s_s_l_runtime/get_ca_entry.go new file mode 100644 index 00000000..fdb84f61 --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCaEntryHandlerFunc turns a function with the right signature into a get ca entry handler +type GetCaEntryHandlerFunc func(GetCaEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCaEntryHandlerFunc) Handle(params GetCaEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCaEntryHandler interface for that can handle valid get ca entry params +type GetCaEntryHandler interface { + Handle(GetCaEntryParams, interface{}) middleware.Responder +} + +// NewGetCaEntry creates a new http.Handler for the get ca entry operation +func NewGetCaEntry(ctx *middleware.Context, handler GetCaEntryHandler) *GetCaEntry { + return &GetCaEntry{Context: ctx, Handler: handler} +} + +/* + GetCaEntry swagger:route GET /services/haproxy/runtime/ssl_ca_files/{name}/entries/{index} SSLRuntime getCaEntry + +# Return an SSL CA file cert entry + +Returns an SSL CA file cert entry. +*/ +type GetCaEntry struct { + Context *middleware.Context + Handler GetCaEntryHandler +} + +func (o *GetCaEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCaEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_ca_entry_parameters.go b/operations/s_s_l_runtime/get_ca_entry_parameters.go new file mode 100644 index 00000000..c012263a --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_entry_parameters.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetCaEntryParams creates a new GetCaEntryParams object +// +// There are no default values defined in the spec. +func NewGetCaEntryParams() GetCaEntryParams { + + return GetCaEntryParams{} +} + +// GetCaEntryParams contains all the bound params for the get ca entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCaEntry +type GetCaEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL CA file index + Required: true + Minimum: 0 + In: path + */ + Index int64 + /*SSL CA file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCaEntryParams() beforehand. +func (o *GetCaEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetCaEntryParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + if err := o.validateIndex(formats); err != nil { + return err + } + + return nil +} + +// validateIndex carries on validations for parameter Index +func (o *GetCaEntryParams) validateIndex(formats strfmt.Registry) error { + + if err := validate.MinimumInt("index", "path", o.Index, 0, false); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetCaEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/get_ca_entry_responses.go b/operations/s_s_l_runtime/get_ca_entry_responses.go new file mode 100644 index 00000000..62b9fb95 --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_entry_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCaEntryOKCode is the HTTP code returned for type GetCaEntryOK +const GetCaEntryOKCode int = 200 + +/* +GetCaEntryOK Successful operation + +swagger:response getCaEntryOK +*/ +type GetCaEntryOK struct { + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewGetCaEntryOK creates GetCaEntryOK with default headers values +func NewGetCaEntryOK() *GetCaEntryOK { + + return &GetCaEntryOK{} +} + +// WithPayload adds the payload to the get ca entry o k response +func (o *GetCaEntryOK) WithPayload(payload *models.SslCertificate) *GetCaEntryOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ca entry o k response +func (o *GetCaEntryOK) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCaEntryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetCaEntryNotFoundCode is the HTTP code returned for type GetCaEntryNotFound +const GetCaEntryNotFoundCode int = 404 + +/* +GetCaEntryNotFound The specified resource was not found + +swagger:response getCaEntryNotFound +*/ +type GetCaEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCaEntryNotFound creates GetCaEntryNotFound with default headers values +func NewGetCaEntryNotFound() *GetCaEntryNotFound { + + return &GetCaEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get ca entry not found response +func (o *GetCaEntryNotFound) WithConfigurationVersion(configurationVersion string) *GetCaEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get ca entry not found response +func (o *GetCaEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get ca entry not found response +func (o *GetCaEntryNotFound) WithPayload(payload *models.Error) *GetCaEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ca entry not found response +func (o *GetCaEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCaEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetCaEntryDefault General Error + +swagger:response getCaEntryDefault +*/ +type GetCaEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCaEntryDefault creates GetCaEntryDefault with default headers values +func NewGetCaEntryDefault(code int) *GetCaEntryDefault { + if code <= 0 { + code = 500 + } + + return &GetCaEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get ca entry default response +func (o *GetCaEntryDefault) WithStatusCode(code int) *GetCaEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get ca entry default response +func (o *GetCaEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get ca entry default response +func (o *GetCaEntryDefault) WithConfigurationVersion(configurationVersion string) *GetCaEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get ca entry default response +func (o *GetCaEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get ca entry default response +func (o *GetCaEntryDefault) WithPayload(payload *models.Error) *GetCaEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ca entry default response +func (o *GetCaEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCaEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_ca_entry_urlbuilder.go b/operations/s_s_l_runtime/get_ca_entry_urlbuilder.go new file mode 100644 index 00000000..f75296b1 --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_entry_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetCaEntryURL generates an URL for the get ca entry operation +type GetCaEntryURL struct { + Index int64 + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCaEntryURL) WithBasePath(bp string) *GetCaEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCaEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCaEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_ca_files/{name}/entries/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetCaEntryURL") + } + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetCaEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCaEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCaEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCaEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCaEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCaEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCaEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_ca_file.go b/operations/s_s_l_runtime/get_ca_file.go new file mode 100644 index 00000000..e90cbc21 --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCaFileHandlerFunc turns a function with the right signature into a get ca file handler +type GetCaFileHandlerFunc func(GetCaFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCaFileHandlerFunc) Handle(params GetCaFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCaFileHandler interface for that can handle valid get ca file params +type GetCaFileHandler interface { + Handle(GetCaFileParams, interface{}) middleware.Responder +} + +// NewGetCaFile creates a new http.Handler for the get ca file operation +func NewGetCaFile(ctx *middleware.Context, handler GetCaFileHandler) *GetCaFile { + return &GetCaFile{Context: ctx, Handler: handler} +} + +/* + GetCaFile swagger:route GET /services/haproxy/runtime/ssl_ca_files/{name} SSLRuntime getCaFile + +# Return an SSL CA file + +Returns an SSL CA file by name using the runtime socket. +*/ +type GetCaFile struct { + Context *middleware.Context + Handler GetCaFileHandler +} + +func (o *GetCaFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCaFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_ca_file_parameters.go b/operations/s_s_l_runtime/get_ca_file_parameters.go new file mode 100644 index 00000000..10615eb1 --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_file_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetCaFileParams creates a new GetCaFileParams object +// +// There are no default values defined in the spec. +func NewGetCaFileParams() GetCaFileParams { + + return GetCaFileParams{} +} + +// GetCaFileParams contains all the bound params for the get ca file operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCaFile +type GetCaFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL CA file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCaFileParams() beforehand. +func (o *GetCaFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetCaFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/get_ca_file_responses.go b/operations/s_s_l_runtime/get_ca_file_responses.go new file mode 100644 index 00000000..9a602137 --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_file_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCaFileOKCode is the HTTP code returned for type GetCaFileOK +const GetCaFileOKCode int = 200 + +/* +GetCaFileOK Successful operation + +swagger:response getCaFileOK +*/ +type GetCaFileOK struct { + + /* + In: Body + */ + Payload *models.SslCaFile `json:"body,omitempty"` +} + +// NewGetCaFileOK creates GetCaFileOK with default headers values +func NewGetCaFileOK() *GetCaFileOK { + + return &GetCaFileOK{} +} + +// WithPayload adds the payload to the get ca file o k response +func (o *GetCaFileOK) WithPayload(payload *models.SslCaFile) *GetCaFileOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ca file o k response +func (o *GetCaFileOK) SetPayload(payload *models.SslCaFile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCaFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetCaFileNotFoundCode is the HTTP code returned for type GetCaFileNotFound +const GetCaFileNotFoundCode int = 404 + +/* +GetCaFileNotFound The specified resource was not found + +swagger:response getCaFileNotFound +*/ +type GetCaFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCaFileNotFound creates GetCaFileNotFound with default headers values +func NewGetCaFileNotFound() *GetCaFileNotFound { + + return &GetCaFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get ca file not found response +func (o *GetCaFileNotFound) WithConfigurationVersion(configurationVersion string) *GetCaFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get ca file not found response +func (o *GetCaFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get ca file not found response +func (o *GetCaFileNotFound) WithPayload(payload *models.Error) *GetCaFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ca file not found response +func (o *GetCaFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCaFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetCaFileDefault General Error + +swagger:response getCaFileDefault +*/ +type GetCaFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCaFileDefault creates GetCaFileDefault with default headers values +func NewGetCaFileDefault(code int) *GetCaFileDefault { + if code <= 0 { + code = 500 + } + + return &GetCaFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get ca file default response +func (o *GetCaFileDefault) WithStatusCode(code int) *GetCaFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get ca file default response +func (o *GetCaFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get ca file default response +func (o *GetCaFileDefault) WithConfigurationVersion(configurationVersion string) *GetCaFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get ca file default response +func (o *GetCaFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get ca file default response +func (o *GetCaFileDefault) WithPayload(payload *models.Error) *GetCaFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get ca file default response +func (o *GetCaFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCaFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_ca_file_urlbuilder.go b/operations/s_s_l_runtime/get_ca_file_urlbuilder.go new file mode 100644 index 00000000..68ec3139 --- /dev/null +++ b/operations/s_s_l_runtime/get_ca_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetCaFileURL generates an URL for the get ca file operation +type GetCaFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCaFileURL) WithBasePath(bp string) *GetCaFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCaFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCaFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_ca_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetCaFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCaFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCaFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCaFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCaFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCaFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCaFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_cert.go b/operations/s_s_l_runtime/get_cert.go new file mode 100644 index 00000000..38d8f7b0 --- /dev/null +++ b/operations/s_s_l_runtime/get_cert.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCertHandlerFunc turns a function with the right signature into a get cert handler +type GetCertHandlerFunc func(GetCertParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCertHandlerFunc) Handle(params GetCertParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCertHandler interface for that can handle valid get cert params +type GetCertHandler interface { + Handle(GetCertParams, interface{}) middleware.Responder +} + +// NewGetCert creates a new http.Handler for the get cert operation +func NewGetCert(ctx *middleware.Context, handler GetCertHandler) *GetCert { + return &GetCert{Context: ctx, Handler: handler} +} + +/* + GetCert swagger:route GET /services/haproxy/runtime/ssl_certs/{name} SSLRuntime getCert + +# Return one structured certificate + +Returns one structured certificate using the runtime socket. +*/ +type GetCert struct { + Context *middleware.Context + Handler GetCertHandler +} + +func (o *GetCert) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCertParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_cert_parameters.go b/operations/s_s_l_runtime/get_cert_parameters.go new file mode 100644 index 00000000..7c80231f --- /dev/null +++ b/operations/s_s_l_runtime/get_cert_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetCertParams creates a new GetCertParams object +// +// There are no default values defined in the spec. +func NewGetCertParams() GetCertParams { + + return GetCertParams{} +} + +// GetCertParams contains all the bound params for the get cert operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCert +type GetCertParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL certificate name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCertParams() beforehand. +func (o *GetCertParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetCertParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/get_cert_responses.go b/operations/s_s_l_runtime/get_cert_responses.go new file mode 100644 index 00000000..aa0864d5 --- /dev/null +++ b/operations/s_s_l_runtime/get_cert_responses.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCertOKCode is the HTTP code returned for type GetCertOK +const GetCertOKCode int = 200 + +/* +GetCertOK Successful operation + +swagger:response getCertOK +*/ +type GetCertOK struct { + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewGetCertOK creates GetCertOK with default headers values +func NewGetCertOK() *GetCertOK { + + return &GetCertOK{} +} + +// WithPayload adds the payload to the get cert o k response +func (o *GetCertOK) WithPayload(payload *models.SslCertificate) *GetCertOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cert o k response +func (o *GetCertOK) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCertOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetCertDefault General Error + +swagger:response getCertDefault +*/ +type GetCertDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCertDefault creates GetCertDefault with default headers values +func NewGetCertDefault(code int) *GetCertDefault { + if code <= 0 { + code = 500 + } + + return &GetCertDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get cert default response +func (o *GetCertDefault) WithStatusCode(code int) *GetCertDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get cert default response +func (o *GetCertDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get cert default response +func (o *GetCertDefault) WithConfigurationVersion(configurationVersion string) *GetCertDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get cert default response +func (o *GetCertDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get cert default response +func (o *GetCertDefault) WithPayload(payload *models.Error) *GetCertDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get cert default response +func (o *GetCertDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCertDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_cert_urlbuilder.go b/operations/s_s_l_runtime/get_cert_urlbuilder.go new file mode 100644 index 00000000..78e9789e --- /dev/null +++ b/operations/s_s_l_runtime/get_cert_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetCertURL generates an URL for the get cert operation +type GetCertURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCertURL) WithBasePath(bp string) *GetCertURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCertURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCertURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_certs/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetCertURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCertURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCertURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCertURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCertURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCertURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCertURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/get_crl.go b/operations/s_s_l_runtime/get_crl.go new file mode 100644 index 00000000..7d130a6d --- /dev/null +++ b/operations/s_s_l_runtime/get_crl.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetCrlHandlerFunc turns a function with the right signature into a get crl handler +type GetCrlHandlerFunc func(GetCrlParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetCrlHandlerFunc) Handle(params GetCrlParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetCrlHandler interface for that can handle valid get crl params +type GetCrlHandler interface { + Handle(GetCrlParams, interface{}) middleware.Responder +} + +// NewGetCrl creates a new http.Handler for the get crl operation +func NewGetCrl(ctx *middleware.Context, handler GetCrlHandler) *GetCrl { + return &GetCrl{Context: ctx, Handler: handler} +} + +/* + GetCrl swagger:route GET /services/haproxy/runtime/ssl_crl_files/{name} SSLRuntime getCrl + +# Get the contents of a CRL file + +Returns one or all entries in a CRL file using the runtime socket. +*/ +type GetCrl struct { + Context *middleware.Context + Handler GetCrlHandler +} + +func (o *GetCrl) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetCrlParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/get_crl_parameters.go b/operations/s_s_l_runtime/get_crl_parameters.go new file mode 100644 index 00000000..9bd39538 --- /dev/null +++ b/operations/s_s_l_runtime/get_crl_parameters.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewGetCrlParams creates a new GetCrlParams object +// +// There are no default values defined in the spec. +func NewGetCrlParams() GetCrlParams { + + return GetCrlParams{} +} + +// GetCrlParams contains all the bound params for the get crl operation +// typically these are obtained from a http.Request +// +// swagger:parameters getCrl +type GetCrlParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Entry index to return. Starts at 1. If not provided, all entries are returned. + Minimum: 1 + In: query + */ + Index *int64 + /*CRL file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetCrlParams() beforehand. +func (o *GetCrlParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qIndex, qhkIndex, _ := qs.GetOK("index") + if err := o.bindIndex(qIndex, qhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from query. +func (o *GetCrlParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "query", "int64", raw) + } + o.Index = &value + + if err := o.validateIndex(formats); err != nil { + return err + } + + return nil +} + +// validateIndex carries on validations for parameter Index +func (o *GetCrlParams) validateIndex(formats strfmt.Registry) error { + + if err := validate.MinimumInt("index", "query", *o.Index, 1, false); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetCrlParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/get_crl_responses.go b/operations/s_s_l_runtime/get_crl_responses.go new file mode 100644 index 00000000..3cb69a76 --- /dev/null +++ b/operations/s_s_l_runtime/get_crl_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetCrlOKCode is the HTTP code returned for type GetCrlOK +const GetCrlOKCode int = 200 + +/* +GetCrlOK Successful operation + +swagger:response getCrlOK +*/ +type GetCrlOK struct { + + /* + In: Body + */ + Payload models.SslCrlEntries `json:"body,omitempty"` +} + +// NewGetCrlOK creates GetCrlOK with default headers values +func NewGetCrlOK() *GetCrlOK { + + return &GetCrlOK{} +} + +// WithPayload adds the payload to the get crl o k response +func (o *GetCrlOK) WithPayload(payload models.SslCrlEntries) *GetCrlOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crl o k response +func (o *GetCrlOK) SetPayload(payload models.SslCrlEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrlOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCrlEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetCrlNotFoundCode is the HTTP code returned for type GetCrlNotFound +const GetCrlNotFoundCode int = 404 + +/* +GetCrlNotFound The specified resource was not found + +swagger:response getCrlNotFound +*/ +type GetCrlNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrlNotFound creates GetCrlNotFound with default headers values +func NewGetCrlNotFound() *GetCrlNotFound { + + return &GetCrlNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get crl not found response +func (o *GetCrlNotFound) WithConfigurationVersion(configurationVersion string) *GetCrlNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crl not found response +func (o *GetCrlNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crl not found response +func (o *GetCrlNotFound) WithPayload(payload *models.Error) *GetCrlNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crl not found response +func (o *GetCrlNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrlNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetCrlDefault General Error + +swagger:response getCrlDefault +*/ +type GetCrlDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetCrlDefault creates GetCrlDefault with default headers values +func NewGetCrlDefault(code int) *GetCrlDefault { + if code <= 0 { + code = 500 + } + + return &GetCrlDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get crl default response +func (o *GetCrlDefault) WithStatusCode(code int) *GetCrlDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get crl default response +func (o *GetCrlDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get crl default response +func (o *GetCrlDefault) WithConfigurationVersion(configurationVersion string) *GetCrlDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get crl default response +func (o *GetCrlDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get crl default response +func (o *GetCrlDefault) WithPayload(payload *models.Error) *GetCrlDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get crl default response +func (o *GetCrlDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetCrlDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/get_crl_urlbuilder.go b/operations/s_s_l_runtime/get_crl_urlbuilder.go new file mode 100644 index 00000000..2a62d65a --- /dev/null +++ b/operations/s_s_l_runtime/get_crl_urlbuilder.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetCrlURL generates an URL for the get crl operation +type GetCrlURL struct { + Name string + + Index *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrlURL) WithBasePath(bp string) *GetCrlURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetCrlURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetCrlURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crl_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetCrlURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var indexQ string + if o.Index != nil { + indexQ = swag.FormatInt64(*o.Index) + } + if indexQ != "" { + qs.Set("index", indexQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetCrlURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetCrlURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetCrlURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetCrlURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetCrlURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetCrlURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/replace_cert.go b/operations/s_s_l_runtime/replace_cert.go new file mode 100644 index 00000000..f9521261 --- /dev/null +++ b/operations/s_s_l_runtime/replace_cert.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceCertHandlerFunc turns a function with the right signature into a replace cert handler +type ReplaceCertHandlerFunc func(ReplaceCertParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceCertHandlerFunc) Handle(params ReplaceCertParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceCertHandler interface for that can handle valid replace cert params +type ReplaceCertHandler interface { + Handle(ReplaceCertParams, interface{}) middleware.Responder +} + +// NewReplaceCert creates a new http.Handler for the replace cert operation +func NewReplaceCert(ctx *middleware.Context, handler ReplaceCertHandler) *ReplaceCert { + return &ReplaceCert{Context: ctx, Handler: handler} +} + +/* + ReplaceCert swagger:route PUT /services/haproxy/runtime/ssl_certs/{name} SSLRuntime replaceCert + +# Replace the contents of a certificate + +Sets a certificate payload using the runtime socket. +*/ +type ReplaceCert struct { + Context *middleware.Context + Handler ReplaceCertHandler +} + +func (o *ReplaceCert) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceCertParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/replace_cert_parameters.go b/operations/s_s_l_runtime/replace_cert_parameters.go new file mode 100644 index 00000000..05478796 --- /dev/null +++ b/operations/s_s_l_runtime/replace_cert_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// ReplaceCertMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var ReplaceCertMaxParseMemory int64 = 32 << 20 + +// NewReplaceCertParams creates a new ReplaceCertParams object +// +// There are no default values defined in the spec. +func NewReplaceCertParams() ReplaceCertParams { + + return ReplaceCertParams{} +} + +// ReplaceCertParams contains all the bound params for the replace cert operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceCert +type ReplaceCertParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: formData + */ + FileUpload io.ReadCloser + /*SSL certificate name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceCertParams() beforehand. +func (o *ReplaceCertParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(ReplaceCertMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + // Required: true + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *ReplaceCertParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceCertParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/replace_cert_responses.go b/operations/s_s_l_runtime/replace_cert_responses.go new file mode 100644 index 00000000..32e3ecac --- /dev/null +++ b/operations/s_s_l_runtime/replace_cert_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceCertOKCode is the HTTP code returned for type ReplaceCertOK +const ReplaceCertOKCode int = 200 + +/* +ReplaceCertOK File updated + +swagger:response replaceCertOK +*/ +type ReplaceCertOK struct { +} + +// NewReplaceCertOK creates ReplaceCertOK with default headers values +func NewReplaceCertOK() *ReplaceCertOK { + + return &ReplaceCertOK{} +} + +// WriteResponse to the client +func (o *ReplaceCertOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// ReplaceCertBadRequestCode is the HTTP code returned for type ReplaceCertBadRequest +const ReplaceCertBadRequestCode int = 400 + +/* +ReplaceCertBadRequest Bad request + +swagger:response replaceCertBadRequest +*/ +type ReplaceCertBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCertBadRequest creates ReplaceCertBadRequest with default headers values +func NewReplaceCertBadRequest() *ReplaceCertBadRequest { + + return &ReplaceCertBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace cert bad request response +func (o *ReplaceCertBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceCertBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace cert bad request response +func (o *ReplaceCertBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace cert bad request response +func (o *ReplaceCertBadRequest) WithPayload(payload *models.Error) *ReplaceCertBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace cert bad request response +func (o *ReplaceCertBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCertBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceCertDefault General Error + +swagger:response replaceCertDefault +*/ +type ReplaceCertDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCertDefault creates ReplaceCertDefault with default headers values +func NewReplaceCertDefault(code int) *ReplaceCertDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceCertDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace cert default response +func (o *ReplaceCertDefault) WithStatusCode(code int) *ReplaceCertDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace cert default response +func (o *ReplaceCertDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace cert default response +func (o *ReplaceCertDefault) WithConfigurationVersion(configurationVersion string) *ReplaceCertDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace cert default response +func (o *ReplaceCertDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace cert default response +func (o *ReplaceCertDefault) WithPayload(payload *models.Error) *ReplaceCertDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace cert default response +func (o *ReplaceCertDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCertDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/replace_cert_urlbuilder.go b/operations/s_s_l_runtime/replace_cert_urlbuilder.go new file mode 100644 index 00000000..001c9da8 --- /dev/null +++ b/operations/s_s_l_runtime/replace_cert_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ReplaceCertURL generates an URL for the replace cert operation +type ReplaceCertURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCertURL) WithBasePath(bp string) *ReplaceCertURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCertURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceCertURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_certs/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceCertURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceCertURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceCertURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceCertURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceCertURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceCertURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceCertURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/replace_crl.go b/operations/s_s_l_runtime/replace_crl.go new file mode 100644 index 00000000..f849983d --- /dev/null +++ b/operations/s_s_l_runtime/replace_crl.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceCrlHandlerFunc turns a function with the right signature into a replace crl handler +type ReplaceCrlHandlerFunc func(ReplaceCrlParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceCrlHandlerFunc) Handle(params ReplaceCrlParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceCrlHandler interface for that can handle valid replace crl params +type ReplaceCrlHandler interface { + Handle(ReplaceCrlParams, interface{}) middleware.Responder +} + +// NewReplaceCrl creates a new http.Handler for the replace crl operation +func NewReplaceCrl(ctx *middleware.Context, handler ReplaceCrlHandler) *ReplaceCrl { + return &ReplaceCrl{Context: ctx, Handler: handler} +} + +/* + ReplaceCrl swagger:route PUT /services/haproxy/runtime/ssl_crl_files/{name} SSLRuntime replaceCrl + +# Replace the contents of a CRL file + +Replaces the contents of a CRL file using the runtime socket. +*/ +type ReplaceCrl struct { + Context *middleware.Context + Handler ReplaceCrlHandler +} + +func (o *ReplaceCrl) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceCrlParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/replace_crl_parameters.go b/operations/s_s_l_runtime/replace_crl_parameters.go new file mode 100644 index 00000000..8a31f685 --- /dev/null +++ b/operations/s_s_l_runtime/replace_crl_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// ReplaceCrlMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var ReplaceCrlMaxParseMemory int64 = 32 << 20 + +// NewReplaceCrlParams creates a new ReplaceCrlParams object +// +// There are no default values defined in the spec. +func NewReplaceCrlParams() ReplaceCrlParams { + + return ReplaceCrlParams{} +} + +// ReplaceCrlParams contains all the bound params for the replace crl operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceCrl +type ReplaceCrlParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*CRL file contents + Required: true + In: formData + */ + FileUpload io.ReadCloser + /*CRL file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceCrlParams() beforehand. +func (o *ReplaceCrlParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(ReplaceCrlMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + // Required: true + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *ReplaceCrlParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceCrlParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/replace_crl_responses.go b/operations/s_s_l_runtime/replace_crl_responses.go new file mode 100644 index 00000000..1741ec34 --- /dev/null +++ b/operations/s_s_l_runtime/replace_crl_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceCrlOKCode is the HTTP code returned for type ReplaceCrlOK +const ReplaceCrlOKCode int = 200 + +/* +ReplaceCrlOK File modified + +swagger:response replaceCrlOK +*/ +type ReplaceCrlOK struct { +} + +// NewReplaceCrlOK creates ReplaceCrlOK with default headers values +func NewReplaceCrlOK() *ReplaceCrlOK { + + return &ReplaceCrlOK{} +} + +// WriteResponse to the client +func (o *ReplaceCrlOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// ReplaceCrlBadRequestCode is the HTTP code returned for type ReplaceCrlBadRequest +const ReplaceCrlBadRequestCode int = 400 + +/* +ReplaceCrlBadRequest Bad request + +swagger:response replaceCrlBadRequest +*/ +type ReplaceCrlBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCrlBadRequest creates ReplaceCrlBadRequest with default headers values +func NewReplaceCrlBadRequest() *ReplaceCrlBadRequest { + + return &ReplaceCrlBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace crl bad request response +func (o *ReplaceCrlBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceCrlBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace crl bad request response +func (o *ReplaceCrlBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace crl bad request response +func (o *ReplaceCrlBadRequest) WithPayload(payload *models.Error) *ReplaceCrlBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace crl bad request response +func (o *ReplaceCrlBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCrlBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceCrlDefault General Error + +swagger:response replaceCrlDefault +*/ +type ReplaceCrlDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceCrlDefault creates ReplaceCrlDefault with default headers values +func NewReplaceCrlDefault(code int) *ReplaceCrlDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceCrlDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace crl default response +func (o *ReplaceCrlDefault) WithStatusCode(code int) *ReplaceCrlDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace crl default response +func (o *ReplaceCrlDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace crl default response +func (o *ReplaceCrlDefault) WithConfigurationVersion(configurationVersion string) *ReplaceCrlDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace crl default response +func (o *ReplaceCrlDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace crl default response +func (o *ReplaceCrlDefault) WithPayload(payload *models.Error) *ReplaceCrlDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace crl default response +func (o *ReplaceCrlDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceCrlDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/replace_crl_urlbuilder.go b/operations/s_s_l_runtime/replace_crl_urlbuilder.go new file mode 100644 index 00000000..2ab67563 --- /dev/null +++ b/operations/s_s_l_runtime/replace_crl_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ReplaceCrlURL generates an URL for the replace crl operation +type ReplaceCrlURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCrlURL) WithBasePath(bp string) *ReplaceCrlURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceCrlURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceCrlURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_crl_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceCrlURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceCrlURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceCrlURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceCrlURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceCrlURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceCrlURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceCrlURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/s_s_l_runtime/set_ca_file.go b/operations/s_s_l_runtime/set_ca_file.go new file mode 100644 index 00000000..26cbd904 --- /dev/null +++ b/operations/s_s_l_runtime/set_ca_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// SetCaFileHandlerFunc turns a function with the right signature into a set ca file handler +type SetCaFileHandlerFunc func(SetCaFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SetCaFileHandlerFunc) Handle(params SetCaFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SetCaFileHandler interface for that can handle valid set ca file params +type SetCaFileHandler interface { + Handle(SetCaFileParams, interface{}) middleware.Responder +} + +// NewSetCaFile creates a new http.Handler for the set ca file operation +func NewSetCaFile(ctx *middleware.Context, handler SetCaFileHandler) *SetCaFile { + return &SetCaFile{Context: ctx, Handler: handler} +} + +/* + SetCaFile swagger:route PUT /services/haproxy/runtime/ssl_ca_files/{name} SSLRuntime setCaFile + +# Update the contents of a CA file + +Replace the contents of a CA file using the runtime socket. +*/ +type SetCaFile struct { + Context *middleware.Context + Handler SetCaFileHandler +} + +func (o *SetCaFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewSetCaFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/s_s_l_runtime/set_ca_file_parameters.go b/operations/s_s_l_runtime/set_ca_file_parameters.go new file mode 100644 index 00000000..947cec04 --- /dev/null +++ b/operations/s_s_l_runtime/set_ca_file_parameters.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// SetCaFileMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var SetCaFileMaxParseMemory int64 = 32 << 20 + +// NewSetCaFileParams creates a new SetCaFileParams object +// +// There are no default values defined in the spec. +func NewSetCaFileParams() SetCaFileParams { + + return SetCaFileParams{} +} + +// SetCaFileParams contains all the bound params for the set ca file operation +// typically these are obtained from a http.Request +// +// swagger:parameters setCaFile +type SetCaFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: formData + */ + FileUpload io.ReadCloser + /*SSL CA file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSetCaFileParams() beforehand. +func (o *SetCaFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(SetCaFileMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + // Required: true + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *SetCaFileParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *SetCaFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/s_s_l_runtime/set_ca_file_responses.go b/operations/s_s_l_runtime/set_ca_file_responses.go new file mode 100644 index 00000000..9f451375 --- /dev/null +++ b/operations/s_s_l_runtime/set_ca_file_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// SetCaFileOKCode is the HTTP code returned for type SetCaFileOK +const SetCaFileOKCode int = 200 + +/* +SetCaFileOK SSL CA payload added + +swagger:response setCaFileOK +*/ +type SetCaFileOK struct { +} + +// NewSetCaFileOK creates SetCaFileOK with default headers values +func NewSetCaFileOK() *SetCaFileOK { + + return &SetCaFileOK{} +} + +// WriteResponse to the client +func (o *SetCaFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// SetCaFileBadRequestCode is the HTTP code returned for type SetCaFileBadRequest +const SetCaFileBadRequestCode int = 400 + +/* +SetCaFileBadRequest Bad request + +swagger:response setCaFileBadRequest +*/ +type SetCaFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewSetCaFileBadRequest creates SetCaFileBadRequest with default headers values +func NewSetCaFileBadRequest() *SetCaFileBadRequest { + + return &SetCaFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the set ca file bad request response +func (o *SetCaFileBadRequest) WithConfigurationVersion(configurationVersion string) *SetCaFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the set ca file bad request response +func (o *SetCaFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the set ca file bad request response +func (o *SetCaFileBadRequest) WithPayload(payload *models.Error) *SetCaFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set ca file bad request response +func (o *SetCaFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetCaFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +SetCaFileDefault General Error + +swagger:response setCaFileDefault +*/ +type SetCaFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewSetCaFileDefault creates SetCaFileDefault with default headers values +func NewSetCaFileDefault(code int) *SetCaFileDefault { + if code <= 0 { + code = 500 + } + + return &SetCaFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the set ca file default response +func (o *SetCaFileDefault) WithStatusCode(code int) *SetCaFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the set ca file default response +func (o *SetCaFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the set ca file default response +func (o *SetCaFileDefault) WithConfigurationVersion(configurationVersion string) *SetCaFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the set ca file default response +func (o *SetCaFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the set ca file default response +func (o *SetCaFileDefault) WithPayload(payload *models.Error) *SetCaFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set ca file default response +func (o *SetCaFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetCaFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/s_s_l_runtime/set_ca_file_urlbuilder.go b/operations/s_s_l_runtime/set_ca_file_urlbuilder.go new file mode 100644 index 00000000..b2177ff1 --- /dev/null +++ b/operations/s_s_l_runtime/set_ca_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package s_s_l_runtime + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// SetCaFileURL generates an URL for the set ca file operation +type SetCaFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetCaFileURL) WithBasePath(bp string) *SetCaFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetCaFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SetCaFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/ssl_ca_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on SetCaFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SetCaFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SetCaFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SetCaFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SetCaFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SetCaFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SetCaFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/add_runtime_server.go b/operations/server/add_runtime_server.go new file mode 100644 index 00000000..f6028ff6 --- /dev/null +++ b/operations/server/add_runtime_server.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// AddRuntimeServerHandlerFunc turns a function with the right signature into a add runtime server handler +type AddRuntimeServerHandlerFunc func(AddRuntimeServerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn AddRuntimeServerHandlerFunc) Handle(params AddRuntimeServerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// AddRuntimeServerHandler interface for that can handle valid add runtime server params +type AddRuntimeServerHandler interface { + Handle(AddRuntimeServerParams, interface{}) middleware.Responder +} + +// NewAddRuntimeServer creates a new http.Handler for the add runtime server operation +func NewAddRuntimeServer(ctx *middleware.Context, handler AddRuntimeServerHandler) *AddRuntimeServer { + return &AddRuntimeServer{Context: ctx, Handler: handler} +} + +/* + AddRuntimeServer swagger:route POST /services/haproxy/runtime/backends/{parent_name}/servers Server addRuntimeServer + +# Adds a new server to a backend + +Adds a new server to the specified backend +*/ +type AddRuntimeServer struct { + Context *middleware.Context + Handler AddRuntimeServerHandler +} + +func (o *AddRuntimeServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewAddRuntimeServerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/add_runtime_server_parameters.go b/operations/server/add_runtime_server_parameters.go new file mode 100644 index 00000000..279d8777 --- /dev/null +++ b/operations/server/add_runtime_server_parameters.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewAddRuntimeServerParams creates a new AddRuntimeServerParams object +// +// There are no default values defined in the spec. +func NewAddRuntimeServerParams() AddRuntimeServerParams { + + return AddRuntimeServerParams{} +} + +// AddRuntimeServerParams contains all the bound params for the add runtime server operation +// typically these are obtained from a http.Request +// +// swagger:parameters addRuntimeServer +type AddRuntimeServerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.RuntimeAddServer + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewAddRuntimeServerParams() beforehand. +func (o *AddRuntimeServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RuntimeAddServer + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *AddRuntimeServerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/server/add_runtime_server_responses.go b/operations/server/add_runtime_server_responses.go new file mode 100644 index 00000000..989b10f3 --- /dev/null +++ b/operations/server/add_runtime_server_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// AddRuntimeServerCreatedCode is the HTTP code returned for type AddRuntimeServerCreated +const AddRuntimeServerCreatedCode int = 201 + +/* +AddRuntimeServerCreated Server added + +swagger:response addRuntimeServerCreated +*/ +type AddRuntimeServerCreated struct { + + /* + In: Body + */ + Payload *models.RuntimeAddServer `json:"body,omitempty"` +} + +// NewAddRuntimeServerCreated creates AddRuntimeServerCreated with default headers values +func NewAddRuntimeServerCreated() *AddRuntimeServerCreated { + + return &AddRuntimeServerCreated{} +} + +// WithPayload adds the payload to the add runtime server created response +func (o *AddRuntimeServerCreated) WithPayload(payload *models.RuntimeAddServer) *AddRuntimeServerCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add runtime server created response +func (o *AddRuntimeServerCreated) SetPayload(payload *models.RuntimeAddServer) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddRuntimeServerCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddRuntimeServerBadRequestCode is the HTTP code returned for type AddRuntimeServerBadRequest +const AddRuntimeServerBadRequestCode int = 400 + +/* +AddRuntimeServerBadRequest Bad request + +swagger:response addRuntimeServerBadRequest +*/ +type AddRuntimeServerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddRuntimeServerBadRequest creates AddRuntimeServerBadRequest with default headers values +func NewAddRuntimeServerBadRequest() *AddRuntimeServerBadRequest { + + return &AddRuntimeServerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the add runtime server bad request response +func (o *AddRuntimeServerBadRequest) WithConfigurationVersion(configurationVersion string) *AddRuntimeServerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add runtime server bad request response +func (o *AddRuntimeServerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add runtime server bad request response +func (o *AddRuntimeServerBadRequest) WithPayload(payload *models.Error) *AddRuntimeServerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add runtime server bad request response +func (o *AddRuntimeServerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddRuntimeServerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddRuntimeServerNotFoundCode is the HTTP code returned for type AddRuntimeServerNotFound +const AddRuntimeServerNotFoundCode int = 404 + +/* +AddRuntimeServerNotFound The specified resource was not found + +swagger:response addRuntimeServerNotFound +*/ +type AddRuntimeServerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddRuntimeServerNotFound creates AddRuntimeServerNotFound with default headers values +func NewAddRuntimeServerNotFound() *AddRuntimeServerNotFound { + + return &AddRuntimeServerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the add runtime server not found response +func (o *AddRuntimeServerNotFound) WithConfigurationVersion(configurationVersion string) *AddRuntimeServerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add runtime server not found response +func (o *AddRuntimeServerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add runtime server not found response +func (o *AddRuntimeServerNotFound) WithPayload(payload *models.Error) *AddRuntimeServerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add runtime server not found response +func (o *AddRuntimeServerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddRuntimeServerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// AddRuntimeServerConflictCode is the HTTP code returned for type AddRuntimeServerConflict +const AddRuntimeServerConflictCode int = 409 + +/* +AddRuntimeServerConflict The specified resource already exists + +swagger:response addRuntimeServerConflict +*/ +type AddRuntimeServerConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddRuntimeServerConflict creates AddRuntimeServerConflict with default headers values +func NewAddRuntimeServerConflict() *AddRuntimeServerConflict { + + return &AddRuntimeServerConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the add runtime server conflict response +func (o *AddRuntimeServerConflict) WithConfigurationVersion(configurationVersion string) *AddRuntimeServerConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add runtime server conflict response +func (o *AddRuntimeServerConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add runtime server conflict response +func (o *AddRuntimeServerConflict) WithPayload(payload *models.Error) *AddRuntimeServerConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add runtime server conflict response +func (o *AddRuntimeServerConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddRuntimeServerConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +AddRuntimeServerDefault General Error + +swagger:response addRuntimeServerDefault +*/ +type AddRuntimeServerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewAddRuntimeServerDefault creates AddRuntimeServerDefault with default headers values +func NewAddRuntimeServerDefault(code int) *AddRuntimeServerDefault { + if code <= 0 { + code = 500 + } + + return &AddRuntimeServerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the add runtime server default response +func (o *AddRuntimeServerDefault) WithStatusCode(code int) *AddRuntimeServerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the add runtime server default response +func (o *AddRuntimeServerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the add runtime server default response +func (o *AddRuntimeServerDefault) WithConfigurationVersion(configurationVersion string) *AddRuntimeServerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the add runtime server default response +func (o *AddRuntimeServerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the add runtime server default response +func (o *AddRuntimeServerDefault) WithPayload(payload *models.Error) *AddRuntimeServerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the add runtime server default response +func (o *AddRuntimeServerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *AddRuntimeServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/add_runtime_server_urlbuilder.go b/operations/server/add_runtime_server_urlbuilder.go new file mode 100644 index 00000000..1f69e2f1 --- /dev/null +++ b/operations/server/add_runtime_server_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// AddRuntimeServerURL generates an URL for the add runtime server operation +type AddRuntimeServerURL struct { + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddRuntimeServerURL) WithBasePath(bp string) *AddRuntimeServerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *AddRuntimeServerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *AddRuntimeServerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/backends/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on AddRuntimeServerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *AddRuntimeServerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *AddRuntimeServerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *AddRuntimeServerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on AddRuntimeServerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on AddRuntimeServerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *AddRuntimeServerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/create_server.go b/operations/server/create_server.go deleted file mode 100644 index 6bccb59e..00000000 --- a/operations/server/create_server.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateServerHandlerFunc turns a function with the right signature into a create server handler -type CreateServerHandlerFunc func(CreateServerParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateServerHandlerFunc) Handle(params CreateServerParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateServerHandler interface for that can handle valid create server params -type CreateServerHandler interface { - Handle(CreateServerParams, interface{}) middleware.Responder -} - -// NewCreateServer creates a new http.Handler for the create server operation -func NewCreateServer(ctx *middleware.Context, handler CreateServerHandler) *CreateServer { - return &CreateServer{Context: ctx, Handler: handler} -} - -/*CreateServer swagger:route POST /services/haproxy/configuration/servers Server createServer - -Add a new server - -Adds a new server in the specified backend in the configuration file. - -*/ -type CreateServer struct { - Context *middleware.Context - Handler CreateServerHandler -} - -func (o *CreateServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateServerParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/server/create_server_backend.go b/operations/server/create_server_backend.go new file mode 100644 index 00000000..62fa1764 --- /dev/null +++ b/operations/server/create_server_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateServerBackendHandlerFunc turns a function with the right signature into a create server backend handler +type CreateServerBackendHandlerFunc func(CreateServerBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateServerBackendHandlerFunc) Handle(params CreateServerBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateServerBackendHandler interface for that can handle valid create server backend params +type CreateServerBackendHandler interface { + Handle(CreateServerBackendParams, interface{}) middleware.Responder +} + +// NewCreateServerBackend creates a new http.Handler for the create server backend operation +func NewCreateServerBackend(ctx *middleware.Context, handler CreateServerBackendHandler) *CreateServerBackend { + return &CreateServerBackend{Context: ctx, Handler: handler} +} + +/* + CreateServerBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/servers Server createServerBackend + +# Add a new server + +Adds a new server in the specified backend in the configuration file. +*/ +type CreateServerBackend struct { + Context *middleware.Context + Handler CreateServerBackendHandler +} + +func (o *CreateServerBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateServerBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/create_server_backend_parameters.go b/operations/server/create_server_backend_parameters.go new file mode 100644 index 00000000..b09ed44a --- /dev/null +++ b/operations/server/create_server_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateServerBackendParams creates a new CreateServerBackendParams object +// with the default values initialized. +func NewCreateServerBackendParams() CreateServerBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateServerBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateServerBackendParams contains all the bound params for the create server backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createServerBackend +type CreateServerBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Server + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateServerBackendParams() beforehand. +func (o *CreateServerBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Server + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateServerBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateServerBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateServerBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateServerBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateServerBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/create_server_backend_responses.go b/operations/server/create_server_backend_responses.go new file mode 100644 index 00000000..ddf7d83b --- /dev/null +++ b/operations/server/create_server_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateServerBackendCreatedCode is the HTTP code returned for type CreateServerBackendCreated +const CreateServerBackendCreatedCode int = 201 + +/* +CreateServerBackendCreated Server created + +swagger:response createServerBackendCreated +*/ +type CreateServerBackendCreated struct { + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewCreateServerBackendCreated creates CreateServerBackendCreated with default headers values +func NewCreateServerBackendCreated() *CreateServerBackendCreated { + + return &CreateServerBackendCreated{} +} + +// WithPayload adds the payload to the create server backend created response +func (o *CreateServerBackendCreated) WithPayload(payload *models.Server) *CreateServerBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server backend created response +func (o *CreateServerBackendCreated) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerBackendAcceptedCode is the HTTP code returned for type CreateServerBackendAccepted +const CreateServerBackendAcceptedCode int = 202 + +/* +CreateServerBackendAccepted Configuration change accepted and reload requested + +swagger:response createServerBackendAccepted +*/ +type CreateServerBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewCreateServerBackendAccepted creates CreateServerBackendAccepted with default headers values +func NewCreateServerBackendAccepted() *CreateServerBackendAccepted { + + return &CreateServerBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create server backend accepted response +func (o *CreateServerBackendAccepted) WithReloadID(reloadID string) *CreateServerBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create server backend accepted response +func (o *CreateServerBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create server backend accepted response +func (o *CreateServerBackendAccepted) WithPayload(payload *models.Server) *CreateServerBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server backend accepted response +func (o *CreateServerBackendAccepted) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerBackendBadRequestCode is the HTTP code returned for type CreateServerBackendBadRequest +const CreateServerBackendBadRequestCode int = 400 + +/* +CreateServerBackendBadRequest Bad request + +swagger:response createServerBackendBadRequest +*/ +type CreateServerBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerBackendBadRequest creates CreateServerBackendBadRequest with default headers values +func NewCreateServerBackendBadRequest() *CreateServerBackendBadRequest { + + return &CreateServerBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server backend bad request response +func (o *CreateServerBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateServerBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server backend bad request response +func (o *CreateServerBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server backend bad request response +func (o *CreateServerBackendBadRequest) WithPayload(payload *models.Error) *CreateServerBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server backend bad request response +func (o *CreateServerBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerBackendConflictCode is the HTTP code returned for type CreateServerBackendConflict +const CreateServerBackendConflictCode int = 409 + +/* +CreateServerBackendConflict The specified resource already exists + +swagger:response createServerBackendConflict +*/ +type CreateServerBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerBackendConflict creates CreateServerBackendConflict with default headers values +func NewCreateServerBackendConflict() *CreateServerBackendConflict { + + return &CreateServerBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server backend conflict response +func (o *CreateServerBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateServerBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server backend conflict response +func (o *CreateServerBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server backend conflict response +func (o *CreateServerBackendConflict) WithPayload(payload *models.Error) *CreateServerBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server backend conflict response +func (o *CreateServerBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateServerBackendDefault General Error + +swagger:response createServerBackendDefault +*/ +type CreateServerBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerBackendDefault creates CreateServerBackendDefault with default headers values +func NewCreateServerBackendDefault(code int) *CreateServerBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateServerBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create server backend default response +func (o *CreateServerBackendDefault) WithStatusCode(code int) *CreateServerBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create server backend default response +func (o *CreateServerBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create server backend default response +func (o *CreateServerBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateServerBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server backend default response +func (o *CreateServerBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server backend default response +func (o *CreateServerBackendDefault) WithPayload(payload *models.Error) *CreateServerBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server backend default response +func (o *CreateServerBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/create_server_backend_urlbuilder.go b/operations/server/create_server_backend_urlbuilder.go new file mode 100644 index 00000000..2f434fe7 --- /dev/null +++ b/operations/server/create_server_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateServerBackendURL generates an URL for the create server backend operation +type CreateServerBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerBackendURL) WithBasePath(bp string) *CreateServerBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateServerBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateServerBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateServerBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateServerBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateServerBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateServerBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateServerBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateServerBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/create_server_parameters.go b/operations/server/create_server_parameters.go deleted file mode 100644 index 0bbb39df..00000000 --- a/operations/server/create_server_parameters.go +++ /dev/null @@ -1,228 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateServerParams creates a new CreateServerParams object -// with the default values initialized. -func NewCreateServerParams() CreateServerParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateServerParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateServerParams contains all the bound params for the create server operation -// typically these are obtained from a http.Request -// -// swagger:parameters createServer -type CreateServerParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /* - Required: true - In: body - */ - Data *models.Server - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateServerParams() beforehand. -func (o *CreateServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.Server - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *CreateServerParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateServerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateServerParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateServerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateServerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/server/create_server_peer.go b/operations/server/create_server_peer.go new file mode 100644 index 00000000..40d8ae9d --- /dev/null +++ b/operations/server/create_server_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateServerPeerHandlerFunc turns a function with the right signature into a create server peer handler +type CreateServerPeerHandlerFunc func(CreateServerPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateServerPeerHandlerFunc) Handle(params CreateServerPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateServerPeerHandler interface for that can handle valid create server peer params +type CreateServerPeerHandler interface { + Handle(CreateServerPeerParams, interface{}) middleware.Responder +} + +// NewCreateServerPeer creates a new http.Handler for the create server peer operation +func NewCreateServerPeer(ctx *middleware.Context, handler CreateServerPeerHandler) *CreateServerPeer { + return &CreateServerPeer{Context: ctx, Handler: handler} +} + +/* + CreateServerPeer swagger:route POST /services/haproxy/configuration/peers/{parent_name}/servers Server createServerPeer + +# Add a new server + +Adds a new server in the specified backend in the configuration file. +*/ +type CreateServerPeer struct { + Context *middleware.Context + Handler CreateServerPeerHandler +} + +func (o *CreateServerPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateServerPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/create_server_peer_parameters.go b/operations/server/create_server_peer_parameters.go new file mode 100644 index 00000000..2b37d5da --- /dev/null +++ b/operations/server/create_server_peer_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateServerPeerParams creates a new CreateServerPeerParams object +// with the default values initialized. +func NewCreateServerPeerParams() CreateServerPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateServerPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateServerPeerParams contains all the bound params for the create server peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters createServerPeer +type CreateServerPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Server + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateServerPeerParams() beforehand. +func (o *CreateServerPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Server + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateServerPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateServerPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateServerPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateServerPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateServerPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/create_server_peer_responses.go b/operations/server/create_server_peer_responses.go new file mode 100644 index 00000000..6cbefe7e --- /dev/null +++ b/operations/server/create_server_peer_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateServerPeerCreatedCode is the HTTP code returned for type CreateServerPeerCreated +const CreateServerPeerCreatedCode int = 201 + +/* +CreateServerPeerCreated Server created + +swagger:response createServerPeerCreated +*/ +type CreateServerPeerCreated struct { + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewCreateServerPeerCreated creates CreateServerPeerCreated with default headers values +func NewCreateServerPeerCreated() *CreateServerPeerCreated { + + return &CreateServerPeerCreated{} +} + +// WithPayload adds the payload to the create server peer created response +func (o *CreateServerPeerCreated) WithPayload(payload *models.Server) *CreateServerPeerCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server peer created response +func (o *CreateServerPeerCreated) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerPeerCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerPeerAcceptedCode is the HTTP code returned for type CreateServerPeerAccepted +const CreateServerPeerAcceptedCode int = 202 + +/* +CreateServerPeerAccepted Configuration change accepted and reload requested + +swagger:response createServerPeerAccepted +*/ +type CreateServerPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewCreateServerPeerAccepted creates CreateServerPeerAccepted with default headers values +func NewCreateServerPeerAccepted() *CreateServerPeerAccepted { + + return &CreateServerPeerAccepted{} +} + +// WithReloadID adds the reloadId to the create server peer accepted response +func (o *CreateServerPeerAccepted) WithReloadID(reloadID string) *CreateServerPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create server peer accepted response +func (o *CreateServerPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create server peer accepted response +func (o *CreateServerPeerAccepted) WithPayload(payload *models.Server) *CreateServerPeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server peer accepted response +func (o *CreateServerPeerAccepted) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerPeerBadRequestCode is the HTTP code returned for type CreateServerPeerBadRequest +const CreateServerPeerBadRequestCode int = 400 + +/* +CreateServerPeerBadRequest Bad request + +swagger:response createServerPeerBadRequest +*/ +type CreateServerPeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerPeerBadRequest creates CreateServerPeerBadRequest with default headers values +func NewCreateServerPeerBadRequest() *CreateServerPeerBadRequest { + + return &CreateServerPeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server peer bad request response +func (o *CreateServerPeerBadRequest) WithConfigurationVersion(configurationVersion string) *CreateServerPeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server peer bad request response +func (o *CreateServerPeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server peer bad request response +func (o *CreateServerPeerBadRequest) WithPayload(payload *models.Error) *CreateServerPeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server peer bad request response +func (o *CreateServerPeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerPeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerPeerConflictCode is the HTTP code returned for type CreateServerPeerConflict +const CreateServerPeerConflictCode int = 409 + +/* +CreateServerPeerConflict The specified resource already exists + +swagger:response createServerPeerConflict +*/ +type CreateServerPeerConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerPeerConflict creates CreateServerPeerConflict with default headers values +func NewCreateServerPeerConflict() *CreateServerPeerConflict { + + return &CreateServerPeerConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server peer conflict response +func (o *CreateServerPeerConflict) WithConfigurationVersion(configurationVersion string) *CreateServerPeerConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server peer conflict response +func (o *CreateServerPeerConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server peer conflict response +func (o *CreateServerPeerConflict) WithPayload(payload *models.Error) *CreateServerPeerConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server peer conflict response +func (o *CreateServerPeerConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerPeerConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateServerPeerDefault General Error + +swagger:response createServerPeerDefault +*/ +type CreateServerPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerPeerDefault creates CreateServerPeerDefault with default headers values +func NewCreateServerPeerDefault(code int) *CreateServerPeerDefault { + if code <= 0 { + code = 500 + } + + return &CreateServerPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create server peer default response +func (o *CreateServerPeerDefault) WithStatusCode(code int) *CreateServerPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create server peer default response +func (o *CreateServerPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create server peer default response +func (o *CreateServerPeerDefault) WithConfigurationVersion(configurationVersion string) *CreateServerPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server peer default response +func (o *CreateServerPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server peer default response +func (o *CreateServerPeerDefault) WithPayload(payload *models.Error) *CreateServerPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server peer default response +func (o *CreateServerPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/create_server_peer_urlbuilder.go b/operations/server/create_server_peer_urlbuilder.go new file mode 100644 index 00000000..5b2d939e --- /dev/null +++ b/operations/server/create_server_peer_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateServerPeerURL generates an URL for the create server peer operation +type CreateServerPeerURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerPeerURL) WithBasePath(bp string) *CreateServerPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateServerPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateServerPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateServerPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateServerPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateServerPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateServerPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateServerPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateServerPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/create_server_responses.go b/operations/server/create_server_responses.go deleted file mode 100644 index b9a0cd6d..00000000 --- a/operations/server/create_server_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateServerCreatedCode is the HTTP code returned for type CreateServerCreated -const CreateServerCreatedCode int = 201 - -/*CreateServerCreated Server created - -swagger:response createServerCreated -*/ -type CreateServerCreated struct { - - /* - In: Body - */ - Payload *models.Server `json:"body,omitempty"` -} - -// NewCreateServerCreated creates CreateServerCreated with default headers values -func NewCreateServerCreated() *CreateServerCreated { - - return &CreateServerCreated{} -} - -// WithPayload adds the payload to the create server created response -func (o *CreateServerCreated) WithPayload(payload *models.Server) *CreateServerCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create server created response -func (o *CreateServerCreated) SetPayload(payload *models.Server) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateServerCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateServerAcceptedCode is the HTTP code returned for type CreateServerAccepted -const CreateServerAcceptedCode int = 202 - -/*CreateServerAccepted Configuration change accepted and reload requested - -swagger:response createServerAccepted -*/ -type CreateServerAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.Server `json:"body,omitempty"` -} - -// NewCreateServerAccepted creates CreateServerAccepted with default headers values -func NewCreateServerAccepted() *CreateServerAccepted { - - return &CreateServerAccepted{} -} - -// WithReloadID adds the reloadId to the create server accepted response -func (o *CreateServerAccepted) WithReloadID(reloadID string) *CreateServerAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create server accepted response -func (o *CreateServerAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create server accepted response -func (o *CreateServerAccepted) WithPayload(payload *models.Server) *CreateServerAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create server accepted response -func (o *CreateServerAccepted) SetPayload(payload *models.Server) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateServerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateServerBadRequestCode is the HTTP code returned for type CreateServerBadRequest -const CreateServerBadRequestCode int = 400 - -/*CreateServerBadRequest Bad request - -swagger:response createServerBadRequest -*/ -type CreateServerBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateServerBadRequest creates CreateServerBadRequest with default headers values -func NewCreateServerBadRequest() *CreateServerBadRequest { - - return &CreateServerBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create server bad request response -func (o *CreateServerBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateServerBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create server bad request response -func (o *CreateServerBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create server bad request response -func (o *CreateServerBadRequest) WithPayload(payload *models.Error) *CreateServerBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create server bad request response -func (o *CreateServerBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateServerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateServerConflictCode is the HTTP code returned for type CreateServerConflict -const CreateServerConflictCode int = 409 - -/*CreateServerConflict The specified resource already exists - -swagger:response createServerConflict -*/ -type CreateServerConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateServerConflict creates CreateServerConflict with default headers values -func NewCreateServerConflict() *CreateServerConflict { - - return &CreateServerConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create server conflict response -func (o *CreateServerConflict) WithConfigurationVersion(configurationVersion int64) *CreateServerConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create server conflict response -func (o *CreateServerConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create server conflict response -func (o *CreateServerConflict) WithPayload(payload *models.Error) *CreateServerConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create server conflict response -func (o *CreateServerConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateServerConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateServerDefault General Error - -swagger:response createServerDefault -*/ -type CreateServerDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateServerDefault creates CreateServerDefault with default headers values -func NewCreateServerDefault(code int) *CreateServerDefault { - if code <= 0 { - code = 500 - } - - return &CreateServerDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create server default response -func (o *CreateServerDefault) WithStatusCode(code int) *CreateServerDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create server default response -func (o *CreateServerDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create server default response -func (o *CreateServerDefault) WithConfigurationVersion(configurationVersion int64) *CreateServerDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create server default response -func (o *CreateServerDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create server default response -func (o *CreateServerDefault) WithPayload(payload *models.Error) *CreateServerDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create server default response -func (o *CreateServerDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/server/create_server_ring.go b/operations/server/create_server_ring.go new file mode 100644 index 00000000..bb982d34 --- /dev/null +++ b/operations/server/create_server_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateServerRingHandlerFunc turns a function with the right signature into a create server ring handler +type CreateServerRingHandlerFunc func(CreateServerRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateServerRingHandlerFunc) Handle(params CreateServerRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateServerRingHandler interface for that can handle valid create server ring params +type CreateServerRingHandler interface { + Handle(CreateServerRingParams, interface{}) middleware.Responder +} + +// NewCreateServerRing creates a new http.Handler for the create server ring operation +func NewCreateServerRing(ctx *middleware.Context, handler CreateServerRingHandler) *CreateServerRing { + return &CreateServerRing{Context: ctx, Handler: handler} +} + +/* + CreateServerRing swagger:route POST /services/haproxy/configuration/rings/{parent_name}/servers Server createServerRing + +# Add a new server + +Adds a new server in the specified backend in the configuration file. +*/ +type CreateServerRing struct { + Context *middleware.Context + Handler CreateServerRingHandler +} + +func (o *CreateServerRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateServerRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/create_server_ring_parameters.go b/operations/server/create_server_ring_parameters.go new file mode 100644 index 00000000..e3683e1f --- /dev/null +++ b/operations/server/create_server_ring_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateServerRingParams creates a new CreateServerRingParams object +// with the default values initialized. +func NewCreateServerRingParams() CreateServerRingParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateServerRingParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateServerRingParams contains all the bound params for the create server ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters createServerRing +type CreateServerRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Server + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateServerRingParams() beforehand. +func (o *CreateServerRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Server + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateServerRingParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateServerRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateServerRingParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateServerRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateServerRingParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/create_server_ring_responses.go b/operations/server/create_server_ring_responses.go new file mode 100644 index 00000000..8eabe3a8 --- /dev/null +++ b/operations/server/create_server_ring_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateServerRingCreatedCode is the HTTP code returned for type CreateServerRingCreated +const CreateServerRingCreatedCode int = 201 + +/* +CreateServerRingCreated Server created + +swagger:response createServerRingCreated +*/ +type CreateServerRingCreated struct { + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewCreateServerRingCreated creates CreateServerRingCreated with default headers values +func NewCreateServerRingCreated() *CreateServerRingCreated { + + return &CreateServerRingCreated{} +} + +// WithPayload adds the payload to the create server ring created response +func (o *CreateServerRingCreated) WithPayload(payload *models.Server) *CreateServerRingCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server ring created response +func (o *CreateServerRingCreated) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerRingCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerRingAcceptedCode is the HTTP code returned for type CreateServerRingAccepted +const CreateServerRingAcceptedCode int = 202 + +/* +CreateServerRingAccepted Configuration change accepted and reload requested + +swagger:response createServerRingAccepted +*/ +type CreateServerRingAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewCreateServerRingAccepted creates CreateServerRingAccepted with default headers values +func NewCreateServerRingAccepted() *CreateServerRingAccepted { + + return &CreateServerRingAccepted{} +} + +// WithReloadID adds the reloadId to the create server ring accepted response +func (o *CreateServerRingAccepted) WithReloadID(reloadID string) *CreateServerRingAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create server ring accepted response +func (o *CreateServerRingAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create server ring accepted response +func (o *CreateServerRingAccepted) WithPayload(payload *models.Server) *CreateServerRingAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server ring accepted response +func (o *CreateServerRingAccepted) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerRingAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerRingBadRequestCode is the HTTP code returned for type CreateServerRingBadRequest +const CreateServerRingBadRequestCode int = 400 + +/* +CreateServerRingBadRequest Bad request + +swagger:response createServerRingBadRequest +*/ +type CreateServerRingBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerRingBadRequest creates CreateServerRingBadRequest with default headers values +func NewCreateServerRingBadRequest() *CreateServerRingBadRequest { + + return &CreateServerRingBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server ring bad request response +func (o *CreateServerRingBadRequest) WithConfigurationVersion(configurationVersion string) *CreateServerRingBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server ring bad request response +func (o *CreateServerRingBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server ring bad request response +func (o *CreateServerRingBadRequest) WithPayload(payload *models.Error) *CreateServerRingBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server ring bad request response +func (o *CreateServerRingBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerRingBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerRingConflictCode is the HTTP code returned for type CreateServerRingConflict +const CreateServerRingConflictCode int = 409 + +/* +CreateServerRingConflict The specified resource already exists + +swagger:response createServerRingConflict +*/ +type CreateServerRingConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerRingConflict creates CreateServerRingConflict with default headers values +func NewCreateServerRingConflict() *CreateServerRingConflict { + + return &CreateServerRingConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server ring conflict response +func (o *CreateServerRingConflict) WithConfigurationVersion(configurationVersion string) *CreateServerRingConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server ring conflict response +func (o *CreateServerRingConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server ring conflict response +func (o *CreateServerRingConflict) WithPayload(payload *models.Error) *CreateServerRingConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server ring conflict response +func (o *CreateServerRingConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerRingConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateServerRingDefault General Error + +swagger:response createServerRingDefault +*/ +type CreateServerRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerRingDefault creates CreateServerRingDefault with default headers values +func NewCreateServerRingDefault(code int) *CreateServerRingDefault { + if code <= 0 { + code = 500 + } + + return &CreateServerRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create server ring default response +func (o *CreateServerRingDefault) WithStatusCode(code int) *CreateServerRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create server ring default response +func (o *CreateServerRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create server ring default response +func (o *CreateServerRingDefault) WithConfigurationVersion(configurationVersion string) *CreateServerRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server ring default response +func (o *CreateServerRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server ring default response +func (o *CreateServerRingDefault) WithPayload(payload *models.Error) *CreateServerRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server ring default response +func (o *CreateServerRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/create_server_ring_urlbuilder.go b/operations/server/create_server_ring_urlbuilder.go new file mode 100644 index 00000000..be100cd8 --- /dev/null +++ b/operations/server/create_server_ring_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateServerRingURL generates an URL for the create server ring operation +type CreateServerRingURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerRingURL) WithBasePath(bp string) *CreateServerRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateServerRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateServerRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateServerRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateServerRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateServerRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateServerRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateServerRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateServerRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/create_server_urlbuilder.go b/operations/server/create_server_urlbuilder.go deleted file mode 100644 index c10a4d1d..00000000 --- a/operations/server/create_server_urlbuilder.go +++ /dev/null @@ -1,144 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateServerURL generates an URL for the create server operation -type CreateServerURL struct { - Backend string - ForceReload *bool - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateServerURL) WithBasePath(bp string) *CreateServerURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateServerURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateServerURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/servers" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateServerURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateServerURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateServerURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateServerURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateServerURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateServerURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/server/delete_runtime_server.go b/operations/server/delete_runtime_server.go new file mode 100644 index 00000000..b423e9c9 --- /dev/null +++ b/operations/server/delete_runtime_server.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteRuntimeServerHandlerFunc turns a function with the right signature into a delete runtime server handler +type DeleteRuntimeServerHandlerFunc func(DeleteRuntimeServerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteRuntimeServerHandlerFunc) Handle(params DeleteRuntimeServerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteRuntimeServerHandler interface for that can handle valid delete runtime server params +type DeleteRuntimeServerHandler interface { + Handle(DeleteRuntimeServerParams, interface{}) middleware.Responder +} + +// NewDeleteRuntimeServer creates a new http.Handler for the delete runtime server operation +func NewDeleteRuntimeServer(ctx *middleware.Context, handler DeleteRuntimeServerHandler) *DeleteRuntimeServer { + return &DeleteRuntimeServer{Context: ctx, Handler: handler} +} + +/* + DeleteRuntimeServer swagger:route DELETE /services/haproxy/runtime/backends/{parent_name}/servers/{name} Server deleteRuntimeServer + +# Deletes a server from a backend + +Deletes a server from the specified backend +*/ +type DeleteRuntimeServer struct { + Context *middleware.Context + Handler DeleteRuntimeServerHandler +} + +func (o *DeleteRuntimeServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteRuntimeServerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/delete_runtime_server_parameters.go b/operations/server/delete_runtime_server_parameters.go new file mode 100644 index 00000000..ec68099b --- /dev/null +++ b/operations/server/delete_runtime_server_parameters.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteRuntimeServerParams creates a new DeleteRuntimeServerParams object +// +// There are no default values defined in the spec. +func NewDeleteRuntimeServerParams() DeleteRuntimeServerParams { + + return DeleteRuntimeServerParams{} +} + +// DeleteRuntimeServerParams contains all the bound params for the delete runtime server operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteRuntimeServer +type DeleteRuntimeServerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteRuntimeServerParams() beforehand. +func (o *DeleteRuntimeServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteRuntimeServerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteRuntimeServerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/server/delete_runtime_server_responses.go b/operations/server/delete_runtime_server_responses.go new file mode 100644 index 00000000..c183c98a --- /dev/null +++ b/operations/server/delete_runtime_server_responses.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteRuntimeServerNoContentCode is the HTTP code returned for type DeleteRuntimeServerNoContent +const DeleteRuntimeServerNoContentCode int = 204 + +/* +DeleteRuntimeServerNoContent Server deleted + +swagger:response deleteRuntimeServerNoContent +*/ +type DeleteRuntimeServerNoContent struct { +} + +// NewDeleteRuntimeServerNoContent creates DeleteRuntimeServerNoContent with default headers values +func NewDeleteRuntimeServerNoContent() *DeleteRuntimeServerNoContent { + + return &DeleteRuntimeServerNoContent{} +} + +// WriteResponse to the client +func (o *DeleteRuntimeServerNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteRuntimeServerBadRequestCode is the HTTP code returned for type DeleteRuntimeServerBadRequest +const DeleteRuntimeServerBadRequestCode int = 400 + +/* +DeleteRuntimeServerBadRequest Bad request + +swagger:response deleteRuntimeServerBadRequest +*/ +type DeleteRuntimeServerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteRuntimeServerBadRequest creates DeleteRuntimeServerBadRequest with default headers values +func NewDeleteRuntimeServerBadRequest() *DeleteRuntimeServerBadRequest { + + return &DeleteRuntimeServerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete runtime server bad request response +func (o *DeleteRuntimeServerBadRequest) WithConfigurationVersion(configurationVersion string) *DeleteRuntimeServerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete runtime server bad request response +func (o *DeleteRuntimeServerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete runtime server bad request response +func (o *DeleteRuntimeServerBadRequest) WithPayload(payload *models.Error) *DeleteRuntimeServerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete runtime server bad request response +func (o *DeleteRuntimeServerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRuntimeServerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteRuntimeServerNotFoundCode is the HTTP code returned for type DeleteRuntimeServerNotFound +const DeleteRuntimeServerNotFoundCode int = 404 + +/* +DeleteRuntimeServerNotFound The specified resource was not found + +swagger:response deleteRuntimeServerNotFound +*/ +type DeleteRuntimeServerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteRuntimeServerNotFound creates DeleteRuntimeServerNotFound with default headers values +func NewDeleteRuntimeServerNotFound() *DeleteRuntimeServerNotFound { + + return &DeleteRuntimeServerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete runtime server not found response +func (o *DeleteRuntimeServerNotFound) WithConfigurationVersion(configurationVersion string) *DeleteRuntimeServerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete runtime server not found response +func (o *DeleteRuntimeServerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete runtime server not found response +func (o *DeleteRuntimeServerNotFound) WithPayload(payload *models.Error) *DeleteRuntimeServerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete runtime server not found response +func (o *DeleteRuntimeServerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRuntimeServerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteRuntimeServerDefault General Error + +swagger:response deleteRuntimeServerDefault +*/ +type DeleteRuntimeServerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteRuntimeServerDefault creates DeleteRuntimeServerDefault with default headers values +func NewDeleteRuntimeServerDefault(code int) *DeleteRuntimeServerDefault { + if code <= 0 { + code = 500 + } + + return &DeleteRuntimeServerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete runtime server default response +func (o *DeleteRuntimeServerDefault) WithStatusCode(code int) *DeleteRuntimeServerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete runtime server default response +func (o *DeleteRuntimeServerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete runtime server default response +func (o *DeleteRuntimeServerDefault) WithConfigurationVersion(configurationVersion string) *DeleteRuntimeServerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete runtime server default response +func (o *DeleteRuntimeServerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete runtime server default response +func (o *DeleteRuntimeServerDefault) WithPayload(payload *models.Error) *DeleteRuntimeServerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete runtime server default response +func (o *DeleteRuntimeServerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteRuntimeServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/delete_runtime_server_urlbuilder.go b/operations/server/delete_runtime_server_urlbuilder.go new file mode 100644 index 00000000..41660d61 --- /dev/null +++ b/operations/server/delete_runtime_server_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteRuntimeServerURL generates an URL for the delete runtime server operation +type DeleteRuntimeServerURL struct { + Name string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRuntimeServerURL) WithBasePath(bp string) *DeleteRuntimeServerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteRuntimeServerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteRuntimeServerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/backends/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteRuntimeServerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteRuntimeServerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteRuntimeServerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteRuntimeServerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteRuntimeServerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteRuntimeServerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteRuntimeServerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteRuntimeServerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/delete_server.go b/operations/server/delete_server.go deleted file mode 100644 index a2cf9945..00000000 --- a/operations/server/delete_server.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteServerHandlerFunc turns a function with the right signature into a delete server handler -type DeleteServerHandlerFunc func(DeleteServerParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteServerHandlerFunc) Handle(params DeleteServerParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteServerHandler interface for that can handle valid delete server params -type DeleteServerHandler interface { - Handle(DeleteServerParams, interface{}) middleware.Responder -} - -// NewDeleteServer creates a new http.Handler for the delete server operation -func NewDeleteServer(ctx *middleware.Context, handler DeleteServerHandler) *DeleteServer { - return &DeleteServer{Context: ctx, Handler: handler} -} - -/*DeleteServer swagger:route DELETE /services/haproxy/configuration/servers/{name} Server deleteServer - -Delete a server - -Deletes a server configuration by it's name in the specified backend. - -*/ -type DeleteServer struct { - Context *middleware.Context - Handler DeleteServerHandler -} - -func (o *DeleteServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteServerParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/server/delete_server_backend.go b/operations/server/delete_server_backend.go new file mode 100644 index 00000000..674f1c64 --- /dev/null +++ b/operations/server/delete_server_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteServerBackendHandlerFunc turns a function with the right signature into a delete server backend handler +type DeleteServerBackendHandlerFunc func(DeleteServerBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteServerBackendHandlerFunc) Handle(params DeleteServerBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteServerBackendHandler interface for that can handle valid delete server backend params +type DeleteServerBackendHandler interface { + Handle(DeleteServerBackendParams, interface{}) middleware.Responder +} + +// NewDeleteServerBackend creates a new http.Handler for the delete server backend operation +func NewDeleteServerBackend(ctx *middleware.Context, handler DeleteServerBackendHandler) *DeleteServerBackend { + return &DeleteServerBackend{Context: ctx, Handler: handler} +} + +/* + DeleteServerBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/servers/{name} Server deleteServerBackend + +# Delete a server + +Deletes a server configuration by it's name in the specified backend. +*/ +type DeleteServerBackend struct { + Context *middleware.Context + Handler DeleteServerBackendHandler +} + +func (o *DeleteServerBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteServerBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/delete_server_backend_parameters.go b/operations/server/delete_server_backend_parameters.go new file mode 100644 index 00000000..d6b2c147 --- /dev/null +++ b/operations/server/delete_server_backend_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteServerBackendParams creates a new DeleteServerBackendParams object +// with the default values initialized. +func NewDeleteServerBackendParams() DeleteServerBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteServerBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteServerBackendParams contains all the bound params for the delete server backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteServerBackend +type DeleteServerBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteServerBackendParams() beforehand. +func (o *DeleteServerBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteServerBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteServerBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteServerBackendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteServerBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteServerBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteServerBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/delete_server_backend_responses.go b/operations/server/delete_server_backend_responses.go new file mode 100644 index 00000000..b7f7909e --- /dev/null +++ b/operations/server/delete_server_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteServerBackendAcceptedCode is the HTTP code returned for type DeleteServerBackendAccepted +const DeleteServerBackendAcceptedCode int = 202 + +/* +DeleteServerBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteServerBackendAccepted +*/ +type DeleteServerBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteServerBackendAccepted creates DeleteServerBackendAccepted with default headers values +func NewDeleteServerBackendAccepted() *DeleteServerBackendAccepted { + + return &DeleteServerBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete server backend accepted response +func (o *DeleteServerBackendAccepted) WithReloadID(reloadID string) *DeleteServerBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete server backend accepted response +func (o *DeleteServerBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteServerBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteServerBackendNoContentCode is the HTTP code returned for type DeleteServerBackendNoContent +const DeleteServerBackendNoContentCode int = 204 + +/* +DeleteServerBackendNoContent Server deleted + +swagger:response deleteServerBackendNoContent +*/ +type DeleteServerBackendNoContent struct { +} + +// NewDeleteServerBackendNoContent creates DeleteServerBackendNoContent with default headers values +func NewDeleteServerBackendNoContent() *DeleteServerBackendNoContent { + + return &DeleteServerBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteServerBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteServerBackendNotFoundCode is the HTTP code returned for type DeleteServerBackendNotFound +const DeleteServerBackendNotFoundCode int = 404 + +/* +DeleteServerBackendNotFound The specified resource was not found + +swagger:response deleteServerBackendNotFound +*/ +type DeleteServerBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerBackendNotFound creates DeleteServerBackendNotFound with default headers values +func NewDeleteServerBackendNotFound() *DeleteServerBackendNotFound { + + return &DeleteServerBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete server backend not found response +func (o *DeleteServerBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteServerBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server backend not found response +func (o *DeleteServerBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server backend not found response +func (o *DeleteServerBackendNotFound) WithPayload(payload *models.Error) *DeleteServerBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server backend not found response +func (o *DeleteServerBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteServerBackendDefault General Error + +swagger:response deleteServerBackendDefault +*/ +type DeleteServerBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerBackendDefault creates DeleteServerBackendDefault with default headers values +func NewDeleteServerBackendDefault(code int) *DeleteServerBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteServerBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete server backend default response +func (o *DeleteServerBackendDefault) WithStatusCode(code int) *DeleteServerBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete server backend default response +func (o *DeleteServerBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete server backend default response +func (o *DeleteServerBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteServerBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server backend default response +func (o *DeleteServerBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server backend default response +func (o *DeleteServerBackendDefault) WithPayload(payload *models.Error) *DeleteServerBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server backend default response +func (o *DeleteServerBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/delete_server_backend_urlbuilder.go b/operations/server/delete_server_backend_urlbuilder.go new file mode 100644 index 00000000..a5d0310a --- /dev/null +++ b/operations/server/delete_server_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteServerBackendURL generates an URL for the delete server backend operation +type DeleteServerBackendURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerBackendURL) WithBasePath(bp string) *DeleteServerBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteServerBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteServerBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteServerBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteServerBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteServerBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteServerBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteServerBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteServerBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteServerBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/delete_server_parameters.go b/operations/server/delete_server_parameters.go deleted file mode 100644 index 37b8987b..00000000 --- a/operations/server/delete_server_parameters.go +++ /dev/null @@ -1,223 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteServerParams creates a new DeleteServerParams object -// with the default values initialized. -func NewDeleteServerParams() DeleteServerParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteServerParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteServerParams contains all the bound params for the delete server operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteServer -type DeleteServerParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Server name - Required: true - In: path - */ - Name string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteServerParams() beforehand. -func (o *DeleteServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rName, rhkName, _ := route.Params.GetOK("name") - if err := o.bindName(rName, rhkName, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *DeleteServerParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteServerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteServerParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindName binds and validates parameter Name from path. -func (o *DeleteServerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - o.Name = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteServerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteServerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/server/delete_server_peer.go b/operations/server/delete_server_peer.go new file mode 100644 index 00000000..c28f13a3 --- /dev/null +++ b/operations/server/delete_server_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteServerPeerHandlerFunc turns a function with the right signature into a delete server peer handler +type DeleteServerPeerHandlerFunc func(DeleteServerPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteServerPeerHandlerFunc) Handle(params DeleteServerPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteServerPeerHandler interface for that can handle valid delete server peer params +type DeleteServerPeerHandler interface { + Handle(DeleteServerPeerParams, interface{}) middleware.Responder +} + +// NewDeleteServerPeer creates a new http.Handler for the delete server peer operation +func NewDeleteServerPeer(ctx *middleware.Context, handler DeleteServerPeerHandler) *DeleteServerPeer { + return &DeleteServerPeer{Context: ctx, Handler: handler} +} + +/* + DeleteServerPeer swagger:route DELETE /services/haproxy/configuration/peers/{parent_name}/servers/{name} Server deleteServerPeer + +# Delete a server + +Deletes a server configuration by it's name in the specified backend. +*/ +type DeleteServerPeer struct { + Context *middleware.Context + Handler DeleteServerPeerHandler +} + +func (o *DeleteServerPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteServerPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/delete_server_peer_parameters.go b/operations/server/delete_server_peer_parameters.go new file mode 100644 index 00000000..82d2f6d9 --- /dev/null +++ b/operations/server/delete_server_peer_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteServerPeerParams creates a new DeleteServerPeerParams object +// with the default values initialized. +func NewDeleteServerPeerParams() DeleteServerPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteServerPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteServerPeerParams contains all the bound params for the delete server peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteServerPeer +type DeleteServerPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteServerPeerParams() beforehand. +func (o *DeleteServerPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteServerPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteServerPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteServerPeerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteServerPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteServerPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteServerPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/delete_server_peer_responses.go b/operations/server/delete_server_peer_responses.go new file mode 100644 index 00000000..d710f89a --- /dev/null +++ b/operations/server/delete_server_peer_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteServerPeerAcceptedCode is the HTTP code returned for type DeleteServerPeerAccepted +const DeleteServerPeerAcceptedCode int = 202 + +/* +DeleteServerPeerAccepted Configuration change accepted and reload requested + +swagger:response deleteServerPeerAccepted +*/ +type DeleteServerPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteServerPeerAccepted creates DeleteServerPeerAccepted with default headers values +func NewDeleteServerPeerAccepted() *DeleteServerPeerAccepted { + + return &DeleteServerPeerAccepted{} +} + +// WithReloadID adds the reloadId to the delete server peer accepted response +func (o *DeleteServerPeerAccepted) WithReloadID(reloadID string) *DeleteServerPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete server peer accepted response +func (o *DeleteServerPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteServerPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteServerPeerNoContentCode is the HTTP code returned for type DeleteServerPeerNoContent +const DeleteServerPeerNoContentCode int = 204 + +/* +DeleteServerPeerNoContent Server deleted + +swagger:response deleteServerPeerNoContent +*/ +type DeleteServerPeerNoContent struct { +} + +// NewDeleteServerPeerNoContent creates DeleteServerPeerNoContent with default headers values +func NewDeleteServerPeerNoContent() *DeleteServerPeerNoContent { + + return &DeleteServerPeerNoContent{} +} + +// WriteResponse to the client +func (o *DeleteServerPeerNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteServerPeerNotFoundCode is the HTTP code returned for type DeleteServerPeerNotFound +const DeleteServerPeerNotFoundCode int = 404 + +/* +DeleteServerPeerNotFound The specified resource was not found + +swagger:response deleteServerPeerNotFound +*/ +type DeleteServerPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerPeerNotFound creates DeleteServerPeerNotFound with default headers values +func NewDeleteServerPeerNotFound() *DeleteServerPeerNotFound { + + return &DeleteServerPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete server peer not found response +func (o *DeleteServerPeerNotFound) WithConfigurationVersion(configurationVersion string) *DeleteServerPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server peer not found response +func (o *DeleteServerPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server peer not found response +func (o *DeleteServerPeerNotFound) WithPayload(payload *models.Error) *DeleteServerPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server peer not found response +func (o *DeleteServerPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteServerPeerDefault General Error + +swagger:response deleteServerPeerDefault +*/ +type DeleteServerPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerPeerDefault creates DeleteServerPeerDefault with default headers values +func NewDeleteServerPeerDefault(code int) *DeleteServerPeerDefault { + if code <= 0 { + code = 500 + } + + return &DeleteServerPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete server peer default response +func (o *DeleteServerPeerDefault) WithStatusCode(code int) *DeleteServerPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete server peer default response +func (o *DeleteServerPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete server peer default response +func (o *DeleteServerPeerDefault) WithConfigurationVersion(configurationVersion string) *DeleteServerPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server peer default response +func (o *DeleteServerPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server peer default response +func (o *DeleteServerPeerDefault) WithPayload(payload *models.Error) *DeleteServerPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server peer default response +func (o *DeleteServerPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/delete_server_peer_urlbuilder.go b/operations/server/delete_server_peer_urlbuilder.go new file mode 100644 index 00000000..e8bd22c3 --- /dev/null +++ b/operations/server/delete_server_peer_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteServerPeerURL generates an URL for the delete server peer operation +type DeleteServerPeerURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerPeerURL) WithBasePath(bp string) *DeleteServerPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteServerPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteServerPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteServerPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteServerPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteServerPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteServerPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteServerPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteServerPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteServerPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/delete_server_responses.go b/operations/server/delete_server_responses.go deleted file mode 100644 index a57a86ad..00000000 --- a/operations/server/delete_server_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteServerAcceptedCode is the HTTP code returned for type DeleteServerAccepted -const DeleteServerAcceptedCode int = 202 - -/*DeleteServerAccepted Configuration change accepted and reload requested - -swagger:response deleteServerAccepted -*/ -type DeleteServerAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteServerAccepted creates DeleteServerAccepted with default headers values -func NewDeleteServerAccepted() *DeleteServerAccepted { - - return &DeleteServerAccepted{} -} - -// WithReloadID adds the reloadId to the delete server accepted response -func (o *DeleteServerAccepted) WithReloadID(reloadID string) *DeleteServerAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete server accepted response -func (o *DeleteServerAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteServerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteServerNoContentCode is the HTTP code returned for type DeleteServerNoContent -const DeleteServerNoContentCode int = 204 - -/*DeleteServerNoContent Server deleted - -swagger:response deleteServerNoContent -*/ -type DeleteServerNoContent struct { -} - -// NewDeleteServerNoContent creates DeleteServerNoContent with default headers values -func NewDeleteServerNoContent() *DeleteServerNoContent { - - return &DeleteServerNoContent{} -} - -// WriteResponse to the client -func (o *DeleteServerNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteServerNotFoundCode is the HTTP code returned for type DeleteServerNotFound -const DeleteServerNotFoundCode int = 404 - -/*DeleteServerNotFound The specified resource was not found - -swagger:response deleteServerNotFound -*/ -type DeleteServerNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteServerNotFound creates DeleteServerNotFound with default headers values -func NewDeleteServerNotFound() *DeleteServerNotFound { - - return &DeleteServerNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete server not found response -func (o *DeleteServerNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteServerNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete server not found response -func (o *DeleteServerNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete server not found response -func (o *DeleteServerNotFound) WithPayload(payload *models.Error) *DeleteServerNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete server not found response -func (o *DeleteServerNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteServerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteServerDefault General Error - -swagger:response deleteServerDefault -*/ -type DeleteServerDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteServerDefault creates DeleteServerDefault with default headers values -func NewDeleteServerDefault(code int) *DeleteServerDefault { - if code <= 0 { - code = 500 - } - - return &DeleteServerDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete server default response -func (o *DeleteServerDefault) WithStatusCode(code int) *DeleteServerDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete server default response -func (o *DeleteServerDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete server default response -func (o *DeleteServerDefault) WithConfigurationVersion(configurationVersion int64) *DeleteServerDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete server default response -func (o *DeleteServerDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete server default response -func (o *DeleteServerDefault) WithPayload(payload *models.Error) *DeleteServerDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete server default response -func (o *DeleteServerDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/server/delete_server_ring.go b/operations/server/delete_server_ring.go new file mode 100644 index 00000000..9512739b --- /dev/null +++ b/operations/server/delete_server_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteServerRingHandlerFunc turns a function with the right signature into a delete server ring handler +type DeleteServerRingHandlerFunc func(DeleteServerRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteServerRingHandlerFunc) Handle(params DeleteServerRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteServerRingHandler interface for that can handle valid delete server ring params +type DeleteServerRingHandler interface { + Handle(DeleteServerRingParams, interface{}) middleware.Responder +} + +// NewDeleteServerRing creates a new http.Handler for the delete server ring operation +func NewDeleteServerRing(ctx *middleware.Context, handler DeleteServerRingHandler) *DeleteServerRing { + return &DeleteServerRing{Context: ctx, Handler: handler} +} + +/* + DeleteServerRing swagger:route DELETE /services/haproxy/configuration/rings/{parent_name}/servers/{name} Server deleteServerRing + +# Delete a server + +Deletes a server configuration by it's name in the specified backend. +*/ +type DeleteServerRing struct { + Context *middleware.Context + Handler DeleteServerRingHandler +} + +func (o *DeleteServerRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteServerRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/delete_server_ring_parameters.go b/operations/server/delete_server_ring_parameters.go new file mode 100644 index 00000000..50207734 --- /dev/null +++ b/operations/server/delete_server_ring_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteServerRingParams creates a new DeleteServerRingParams object +// with the default values initialized. +func NewDeleteServerRingParams() DeleteServerRingParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteServerRingParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteServerRingParams contains all the bound params for the delete server ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteServerRing +type DeleteServerRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteServerRingParams() beforehand. +func (o *DeleteServerRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteServerRingParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteServerRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteServerRingParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteServerRingParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteServerRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteServerRingParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/delete_server_ring_responses.go b/operations/server/delete_server_ring_responses.go new file mode 100644 index 00000000..ab08093f --- /dev/null +++ b/operations/server/delete_server_ring_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteServerRingAcceptedCode is the HTTP code returned for type DeleteServerRingAccepted +const DeleteServerRingAcceptedCode int = 202 + +/* +DeleteServerRingAccepted Configuration change accepted and reload requested + +swagger:response deleteServerRingAccepted +*/ +type DeleteServerRingAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteServerRingAccepted creates DeleteServerRingAccepted with default headers values +func NewDeleteServerRingAccepted() *DeleteServerRingAccepted { + + return &DeleteServerRingAccepted{} +} + +// WithReloadID adds the reloadId to the delete server ring accepted response +func (o *DeleteServerRingAccepted) WithReloadID(reloadID string) *DeleteServerRingAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete server ring accepted response +func (o *DeleteServerRingAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteServerRingAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteServerRingNoContentCode is the HTTP code returned for type DeleteServerRingNoContent +const DeleteServerRingNoContentCode int = 204 + +/* +DeleteServerRingNoContent Server deleted + +swagger:response deleteServerRingNoContent +*/ +type DeleteServerRingNoContent struct { +} + +// NewDeleteServerRingNoContent creates DeleteServerRingNoContent with default headers values +func NewDeleteServerRingNoContent() *DeleteServerRingNoContent { + + return &DeleteServerRingNoContent{} +} + +// WriteResponse to the client +func (o *DeleteServerRingNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteServerRingNotFoundCode is the HTTP code returned for type DeleteServerRingNotFound +const DeleteServerRingNotFoundCode int = 404 + +/* +DeleteServerRingNotFound The specified resource was not found + +swagger:response deleteServerRingNotFound +*/ +type DeleteServerRingNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerRingNotFound creates DeleteServerRingNotFound with default headers values +func NewDeleteServerRingNotFound() *DeleteServerRingNotFound { + + return &DeleteServerRingNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete server ring not found response +func (o *DeleteServerRingNotFound) WithConfigurationVersion(configurationVersion string) *DeleteServerRingNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server ring not found response +func (o *DeleteServerRingNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server ring not found response +func (o *DeleteServerRingNotFound) WithPayload(payload *models.Error) *DeleteServerRingNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server ring not found response +func (o *DeleteServerRingNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerRingNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteServerRingDefault General Error + +swagger:response deleteServerRingDefault +*/ +type DeleteServerRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerRingDefault creates DeleteServerRingDefault with default headers values +func NewDeleteServerRingDefault(code int) *DeleteServerRingDefault { + if code <= 0 { + code = 500 + } + + return &DeleteServerRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete server ring default response +func (o *DeleteServerRingDefault) WithStatusCode(code int) *DeleteServerRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete server ring default response +func (o *DeleteServerRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete server ring default response +func (o *DeleteServerRingDefault) WithConfigurationVersion(configurationVersion string) *DeleteServerRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server ring default response +func (o *DeleteServerRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server ring default response +func (o *DeleteServerRingDefault) WithPayload(payload *models.Error) *DeleteServerRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server ring default response +func (o *DeleteServerRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/delete_server_ring_urlbuilder.go b/operations/server/delete_server_ring_urlbuilder.go new file mode 100644 index 00000000..39570019 --- /dev/null +++ b/operations/server/delete_server_ring_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteServerRingURL generates an URL for the delete server ring operation +type DeleteServerRingURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerRingURL) WithBasePath(bp string) *DeleteServerRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteServerRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteServerRingURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteServerRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteServerRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteServerRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteServerRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteServerRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteServerRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteServerRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/delete_server_urlbuilder.go b/operations/server/delete_server_urlbuilder.go deleted file mode 100644 index f2431ee9..00000000 --- a/operations/server/delete_server_urlbuilder.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteServerURL generates an URL for the delete server operation -type DeleteServerURL struct { - Name string - - Backend string - ForceReload *bool - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteServerURL) WithBasePath(bp string) *DeleteServerURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteServerURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteServerURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/servers/{name}" - - name := o.Name - if name != "" { - _path = strings.Replace(_path, "{name}", name, -1) - } else { - return nil, errors.New("name is required on DeleteServerURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteServerURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteServerURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteServerURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteServerURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteServerURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteServerURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/server/get_all_runtime_server.go b/operations/server/get_all_runtime_server.go new file mode 100644 index 00000000..06b74e2e --- /dev/null +++ b/operations/server/get_all_runtime_server.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllRuntimeServerHandlerFunc turns a function with the right signature into a get all runtime server handler +type GetAllRuntimeServerHandlerFunc func(GetAllRuntimeServerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllRuntimeServerHandlerFunc) Handle(params GetAllRuntimeServerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllRuntimeServerHandler interface for that can handle valid get all runtime server params +type GetAllRuntimeServerHandler interface { + Handle(GetAllRuntimeServerParams, interface{}) middleware.Responder +} + +// NewGetAllRuntimeServer creates a new http.Handler for the get all runtime server operation +func NewGetAllRuntimeServer(ctx *middleware.Context, handler GetAllRuntimeServerHandler) *GetAllRuntimeServer { + return &GetAllRuntimeServer{Context: ctx, Handler: handler} +} + +/* + GetAllRuntimeServer swagger:route GET /services/haproxy/runtime/backends/{parent_name}/servers Server getAllRuntimeServer + +Return an array of runtime servers' settings + +Returns an array of all servers' runtime settings. +*/ +type GetAllRuntimeServer struct { + Context *middleware.Context + Handler GetAllRuntimeServerHandler +} + +func (o *GetAllRuntimeServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllRuntimeServerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_all_runtime_server_parameters.go b/operations/server/get_all_runtime_server_parameters.go new file mode 100644 index 00000000..3694a36c --- /dev/null +++ b/operations/server/get_all_runtime_server_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllRuntimeServerParams creates a new GetAllRuntimeServerParams object +// +// There are no default values defined in the spec. +func NewGetAllRuntimeServerParams() GetAllRuntimeServerParams { + + return GetAllRuntimeServerParams{} +} + +// GetAllRuntimeServerParams contains all the bound params for the get all runtime server operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllRuntimeServer +type GetAllRuntimeServerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllRuntimeServerParams() beforehand. +func (o *GetAllRuntimeServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllRuntimeServerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/server/get_all_runtime_server_responses.go b/operations/server/get_all_runtime_server_responses.go new file mode 100644 index 00000000..5c0df832 --- /dev/null +++ b/operations/server/get_all_runtime_server_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllRuntimeServerOKCode is the HTTP code returned for type GetAllRuntimeServerOK +const GetAllRuntimeServerOKCode int = 200 + +/* +GetAllRuntimeServerOK Successful operation + +swagger:response getAllRuntimeServerOK +*/ +type GetAllRuntimeServerOK struct { + + /* + In: Body + */ + Payload models.RuntimeServers `json:"body,omitempty"` +} + +// NewGetAllRuntimeServerOK creates GetAllRuntimeServerOK with default headers values +func NewGetAllRuntimeServerOK() *GetAllRuntimeServerOK { + + return &GetAllRuntimeServerOK{} +} + +// WithPayload adds the payload to the get all runtime server o k response +func (o *GetAllRuntimeServerOK) WithPayload(payload models.RuntimeServers) *GetAllRuntimeServerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all runtime server o k response +func (o *GetAllRuntimeServerOK) SetPayload(payload models.RuntimeServers) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllRuntimeServerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.RuntimeServers{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllRuntimeServerDefault General Error + +swagger:response getAllRuntimeServerDefault +*/ +type GetAllRuntimeServerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllRuntimeServerDefault creates GetAllRuntimeServerDefault with default headers values +func NewGetAllRuntimeServerDefault(code int) *GetAllRuntimeServerDefault { + if code <= 0 { + code = 500 + } + + return &GetAllRuntimeServerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all runtime server default response +func (o *GetAllRuntimeServerDefault) WithStatusCode(code int) *GetAllRuntimeServerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all runtime server default response +func (o *GetAllRuntimeServerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all runtime server default response +func (o *GetAllRuntimeServerDefault) WithConfigurationVersion(configurationVersion string) *GetAllRuntimeServerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all runtime server default response +func (o *GetAllRuntimeServerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all runtime server default response +func (o *GetAllRuntimeServerDefault) WithPayload(payload *models.Error) *GetAllRuntimeServerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all runtime server default response +func (o *GetAllRuntimeServerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllRuntimeServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_all_runtime_server_urlbuilder.go b/operations/server/get_all_runtime_server_urlbuilder.go new file mode 100644 index 00000000..8d36a8a4 --- /dev/null +++ b/operations/server/get_all_runtime_server_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllRuntimeServerURL generates an URL for the get all runtime server operation +type GetAllRuntimeServerURL struct { + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllRuntimeServerURL) WithBasePath(bp string) *GetAllRuntimeServerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllRuntimeServerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllRuntimeServerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/backends/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllRuntimeServerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllRuntimeServerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllRuntimeServerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllRuntimeServerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllRuntimeServerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllRuntimeServerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllRuntimeServerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_all_server_backend.go b/operations/server/get_all_server_backend.go new file mode 100644 index 00000000..ec714158 --- /dev/null +++ b/operations/server/get_all_server_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllServerBackendHandlerFunc turns a function with the right signature into a get all server backend handler +type GetAllServerBackendHandlerFunc func(GetAllServerBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllServerBackendHandlerFunc) Handle(params GetAllServerBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllServerBackendHandler interface for that can handle valid get all server backend params +type GetAllServerBackendHandler interface { + Handle(GetAllServerBackendParams, interface{}) middleware.Responder +} + +// NewGetAllServerBackend creates a new http.Handler for the get all server backend operation +func NewGetAllServerBackend(ctx *middleware.Context, handler GetAllServerBackendHandler) *GetAllServerBackend { + return &GetAllServerBackend{Context: ctx, Handler: handler} +} + +/* + GetAllServerBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/servers Server getAllServerBackend + +# Return an array of servers + +Returns an array of all servers that are configured in specified backend. +*/ +type GetAllServerBackend struct { + Context *middleware.Context + Handler GetAllServerBackendHandler +} + +func (o *GetAllServerBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllServerBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_all_server_backend_parameters.go b/operations/server/get_all_server_backend_parameters.go new file mode 100644 index 00000000..90a9b74a --- /dev/null +++ b/operations/server/get_all_server_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllServerBackendParams creates a new GetAllServerBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllServerBackendParams() GetAllServerBackendParams { + + return GetAllServerBackendParams{} +} + +// GetAllServerBackendParams contains all the bound params for the get all server backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllServerBackend +type GetAllServerBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllServerBackendParams() beforehand. +func (o *GetAllServerBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllServerBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllServerBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server/get_all_server_backend_responses.go b/operations/server/get_all_server_backend_responses.go new file mode 100644 index 00000000..3e760c43 --- /dev/null +++ b/operations/server/get_all_server_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllServerBackendOKCode is the HTTP code returned for type GetAllServerBackendOK +const GetAllServerBackendOKCode int = 200 + +/* +GetAllServerBackendOK Successful operation + +swagger:response getAllServerBackendOK +*/ +type GetAllServerBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Servers `json:"body,omitempty"` +} + +// NewGetAllServerBackendOK creates GetAllServerBackendOK with default headers values +func NewGetAllServerBackendOK() *GetAllServerBackendOK { + + return &GetAllServerBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all server backend o k response +func (o *GetAllServerBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllServerBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all server backend o k response +func (o *GetAllServerBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all server backend o k response +func (o *GetAllServerBackendOK) WithPayload(payload models.Servers) *GetAllServerBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all server backend o k response +func (o *GetAllServerBackendOK) SetPayload(payload models.Servers) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllServerBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Servers{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllServerBackendDefault General Error + +swagger:response getAllServerBackendDefault +*/ +type GetAllServerBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllServerBackendDefault creates GetAllServerBackendDefault with default headers values +func NewGetAllServerBackendDefault(code int) *GetAllServerBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllServerBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all server backend default response +func (o *GetAllServerBackendDefault) WithStatusCode(code int) *GetAllServerBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all server backend default response +func (o *GetAllServerBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all server backend default response +func (o *GetAllServerBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllServerBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all server backend default response +func (o *GetAllServerBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all server backend default response +func (o *GetAllServerBackendDefault) WithPayload(payload *models.Error) *GetAllServerBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all server backend default response +func (o *GetAllServerBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllServerBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_all_server_backend_urlbuilder.go b/operations/server/get_all_server_backend_urlbuilder.go new file mode 100644 index 00000000..1b1c8791 --- /dev/null +++ b/operations/server/get_all_server_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllServerBackendURL generates an URL for the get all server backend operation +type GetAllServerBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllServerBackendURL) WithBasePath(bp string) *GetAllServerBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllServerBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllServerBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllServerBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllServerBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllServerBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllServerBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllServerBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllServerBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllServerBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_all_server_peer.go b/operations/server/get_all_server_peer.go new file mode 100644 index 00000000..f6dd3d89 --- /dev/null +++ b/operations/server/get_all_server_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllServerPeerHandlerFunc turns a function with the right signature into a get all server peer handler +type GetAllServerPeerHandlerFunc func(GetAllServerPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllServerPeerHandlerFunc) Handle(params GetAllServerPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllServerPeerHandler interface for that can handle valid get all server peer params +type GetAllServerPeerHandler interface { + Handle(GetAllServerPeerParams, interface{}) middleware.Responder +} + +// NewGetAllServerPeer creates a new http.Handler for the get all server peer operation +func NewGetAllServerPeer(ctx *middleware.Context, handler GetAllServerPeerHandler) *GetAllServerPeer { + return &GetAllServerPeer{Context: ctx, Handler: handler} +} + +/* + GetAllServerPeer swagger:route GET /services/haproxy/configuration/peers/{parent_name}/servers Server getAllServerPeer + +# Return an array of servers + +Returns an array of all servers that are configured in specified backend. +*/ +type GetAllServerPeer struct { + Context *middleware.Context + Handler GetAllServerPeerHandler +} + +func (o *GetAllServerPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllServerPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_all_server_peer_parameters.go b/operations/server/get_all_server_peer_parameters.go new file mode 100644 index 00000000..acad0f2a --- /dev/null +++ b/operations/server/get_all_server_peer_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllServerPeerParams creates a new GetAllServerPeerParams object +// +// There are no default values defined in the spec. +func NewGetAllServerPeerParams() GetAllServerPeerParams { + + return GetAllServerPeerParams{} +} + +// GetAllServerPeerParams contains all the bound params for the get all server peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllServerPeer +type GetAllServerPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllServerPeerParams() beforehand. +func (o *GetAllServerPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllServerPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllServerPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server/get_all_server_peer_responses.go b/operations/server/get_all_server_peer_responses.go new file mode 100644 index 00000000..26275761 --- /dev/null +++ b/operations/server/get_all_server_peer_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllServerPeerOKCode is the HTTP code returned for type GetAllServerPeerOK +const GetAllServerPeerOKCode int = 200 + +/* +GetAllServerPeerOK Successful operation + +swagger:response getAllServerPeerOK +*/ +type GetAllServerPeerOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Servers `json:"body,omitempty"` +} + +// NewGetAllServerPeerOK creates GetAllServerPeerOK with default headers values +func NewGetAllServerPeerOK() *GetAllServerPeerOK { + + return &GetAllServerPeerOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all server peer o k response +func (o *GetAllServerPeerOK) WithConfigurationVersion(configurationVersion string) *GetAllServerPeerOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all server peer o k response +func (o *GetAllServerPeerOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all server peer o k response +func (o *GetAllServerPeerOK) WithPayload(payload models.Servers) *GetAllServerPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all server peer o k response +func (o *GetAllServerPeerOK) SetPayload(payload models.Servers) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllServerPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Servers{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllServerPeerDefault General Error + +swagger:response getAllServerPeerDefault +*/ +type GetAllServerPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllServerPeerDefault creates GetAllServerPeerDefault with default headers values +func NewGetAllServerPeerDefault(code int) *GetAllServerPeerDefault { + if code <= 0 { + code = 500 + } + + return &GetAllServerPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all server peer default response +func (o *GetAllServerPeerDefault) WithStatusCode(code int) *GetAllServerPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all server peer default response +func (o *GetAllServerPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all server peer default response +func (o *GetAllServerPeerDefault) WithConfigurationVersion(configurationVersion string) *GetAllServerPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all server peer default response +func (o *GetAllServerPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all server peer default response +func (o *GetAllServerPeerDefault) WithPayload(payload *models.Error) *GetAllServerPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all server peer default response +func (o *GetAllServerPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllServerPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_all_server_peer_urlbuilder.go b/operations/server/get_all_server_peer_urlbuilder.go new file mode 100644 index 00000000..1335ae40 --- /dev/null +++ b/operations/server/get_all_server_peer_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllServerPeerURL generates an URL for the get all server peer operation +type GetAllServerPeerURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllServerPeerURL) WithBasePath(bp string) *GetAllServerPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllServerPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllServerPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllServerPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllServerPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllServerPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllServerPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllServerPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllServerPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllServerPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_all_server_ring.go b/operations/server/get_all_server_ring.go new file mode 100644 index 00000000..e8481acf --- /dev/null +++ b/operations/server/get_all_server_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllServerRingHandlerFunc turns a function with the right signature into a get all server ring handler +type GetAllServerRingHandlerFunc func(GetAllServerRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllServerRingHandlerFunc) Handle(params GetAllServerRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllServerRingHandler interface for that can handle valid get all server ring params +type GetAllServerRingHandler interface { + Handle(GetAllServerRingParams, interface{}) middleware.Responder +} + +// NewGetAllServerRing creates a new http.Handler for the get all server ring operation +func NewGetAllServerRing(ctx *middleware.Context, handler GetAllServerRingHandler) *GetAllServerRing { + return &GetAllServerRing{Context: ctx, Handler: handler} +} + +/* + GetAllServerRing swagger:route GET /services/haproxy/configuration/rings/{parent_name}/servers Server getAllServerRing + +# Return an array of servers + +Returns an array of all servers that are configured in specified backend. +*/ +type GetAllServerRing struct { + Context *middleware.Context + Handler GetAllServerRingHandler +} + +func (o *GetAllServerRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllServerRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_all_server_ring_parameters.go b/operations/server/get_all_server_ring_parameters.go new file mode 100644 index 00000000..260cf427 --- /dev/null +++ b/operations/server/get_all_server_ring_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllServerRingParams creates a new GetAllServerRingParams object +// +// There are no default values defined in the spec. +func NewGetAllServerRingParams() GetAllServerRingParams { + + return GetAllServerRingParams{} +} + +// GetAllServerRingParams contains all the bound params for the get all server ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllServerRing +type GetAllServerRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllServerRingParams() beforehand. +func (o *GetAllServerRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllServerRingParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllServerRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server/get_all_server_ring_responses.go b/operations/server/get_all_server_ring_responses.go new file mode 100644 index 00000000..f5d7d93c --- /dev/null +++ b/operations/server/get_all_server_ring_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllServerRingOKCode is the HTTP code returned for type GetAllServerRingOK +const GetAllServerRingOKCode int = 200 + +/* +GetAllServerRingOK Successful operation + +swagger:response getAllServerRingOK +*/ +type GetAllServerRingOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Servers `json:"body,omitempty"` +} + +// NewGetAllServerRingOK creates GetAllServerRingOK with default headers values +func NewGetAllServerRingOK() *GetAllServerRingOK { + + return &GetAllServerRingOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all server ring o k response +func (o *GetAllServerRingOK) WithConfigurationVersion(configurationVersion string) *GetAllServerRingOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all server ring o k response +func (o *GetAllServerRingOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all server ring o k response +func (o *GetAllServerRingOK) WithPayload(payload models.Servers) *GetAllServerRingOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all server ring o k response +func (o *GetAllServerRingOK) SetPayload(payload models.Servers) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllServerRingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Servers{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllServerRingDefault General Error + +swagger:response getAllServerRingDefault +*/ +type GetAllServerRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllServerRingDefault creates GetAllServerRingDefault with default headers values +func NewGetAllServerRingDefault(code int) *GetAllServerRingDefault { + if code <= 0 { + code = 500 + } + + return &GetAllServerRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all server ring default response +func (o *GetAllServerRingDefault) WithStatusCode(code int) *GetAllServerRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all server ring default response +func (o *GetAllServerRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all server ring default response +func (o *GetAllServerRingDefault) WithConfigurationVersion(configurationVersion string) *GetAllServerRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all server ring default response +func (o *GetAllServerRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all server ring default response +func (o *GetAllServerRingDefault) WithPayload(payload *models.Error) *GetAllServerRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all server ring default response +func (o *GetAllServerRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllServerRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_all_server_ring_urlbuilder.go b/operations/server/get_all_server_ring_urlbuilder.go new file mode 100644 index 00000000..3b4ef843 --- /dev/null +++ b/operations/server/get_all_server_ring_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllServerRingURL generates an URL for the get all server ring operation +type GetAllServerRingURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllServerRingURL) WithBasePath(bp string) *GetAllServerRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllServerRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllServerRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{parent_name}/servers" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllServerRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllServerRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllServerRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllServerRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllServerRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllServerRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllServerRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_runtime_server.go b/operations/server/get_runtime_server.go new file mode 100644 index 00000000..e0eba4bc --- /dev/null +++ b/operations/server/get_runtime_server.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetRuntimeServerHandlerFunc turns a function with the right signature into a get runtime server handler +type GetRuntimeServerHandlerFunc func(GetRuntimeServerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetRuntimeServerHandlerFunc) Handle(params GetRuntimeServerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetRuntimeServerHandler interface for that can handle valid get runtime server params +type GetRuntimeServerHandler interface { + Handle(GetRuntimeServerParams, interface{}) middleware.Responder +} + +// NewGetRuntimeServer creates a new http.Handler for the get runtime server operation +func NewGetRuntimeServer(ctx *middleware.Context, handler GetRuntimeServerHandler) *GetRuntimeServer { + return &GetRuntimeServer{Context: ctx, Handler: handler} +} + +/* + GetRuntimeServer swagger:route GET /services/haproxy/runtime/backends/{parent_name}/servers/{name} Server getRuntimeServer + +# Return one server runtime settings + +Returns one server runtime settings by it's name in the specified backend. +*/ +type GetRuntimeServer struct { + Context *middleware.Context + Handler GetRuntimeServerHandler +} + +func (o *GetRuntimeServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetRuntimeServerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_runtime_server_parameters.go b/operations/server/get_runtime_server_parameters.go new file mode 100644 index 00000000..fbf48706 --- /dev/null +++ b/operations/server/get_runtime_server_parameters.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetRuntimeServerParams creates a new GetRuntimeServerParams object +// +// There are no default values defined in the spec. +func NewGetRuntimeServerParams() GetRuntimeServerParams { + + return GetRuntimeServerParams{} +} + +// GetRuntimeServerParams contains all the bound params for the get runtime server operation +// typically these are obtained from a http.Request +// +// swagger:parameters getRuntimeServer +type GetRuntimeServerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetRuntimeServerParams() beforehand. +func (o *GetRuntimeServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetRuntimeServerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetRuntimeServerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/server/get_runtime_server_responses.go b/operations/server/get_runtime_server_responses.go new file mode 100644 index 00000000..e94ff044 --- /dev/null +++ b/operations/server/get_runtime_server_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetRuntimeServerOKCode is the HTTP code returned for type GetRuntimeServerOK +const GetRuntimeServerOKCode int = 200 + +/* +GetRuntimeServerOK Successful operation + +swagger:response getRuntimeServerOK +*/ +type GetRuntimeServerOK struct { + + /* + In: Body + */ + Payload *models.RuntimeServer `json:"body,omitempty"` +} + +// NewGetRuntimeServerOK creates GetRuntimeServerOK with default headers values +func NewGetRuntimeServerOK() *GetRuntimeServerOK { + + return &GetRuntimeServerOK{} +} + +// WithPayload adds the payload to the get runtime server o k response +func (o *GetRuntimeServerOK) WithPayload(payload *models.RuntimeServer) *GetRuntimeServerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime server o k response +func (o *GetRuntimeServerOK) SetPayload(payload *models.RuntimeServer) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeServerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetRuntimeServerNotFoundCode is the HTTP code returned for type GetRuntimeServerNotFound +const GetRuntimeServerNotFoundCode int = 404 + +/* +GetRuntimeServerNotFound The specified resource was not found + +swagger:response getRuntimeServerNotFound +*/ +type GetRuntimeServerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRuntimeServerNotFound creates GetRuntimeServerNotFound with default headers values +func NewGetRuntimeServerNotFound() *GetRuntimeServerNotFound { + + return &GetRuntimeServerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get runtime server not found response +func (o *GetRuntimeServerNotFound) WithConfigurationVersion(configurationVersion string) *GetRuntimeServerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get runtime server not found response +func (o *GetRuntimeServerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get runtime server not found response +func (o *GetRuntimeServerNotFound) WithPayload(payload *models.Error) *GetRuntimeServerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime server not found response +func (o *GetRuntimeServerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeServerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetRuntimeServerDefault General Error + +swagger:response getRuntimeServerDefault +*/ +type GetRuntimeServerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetRuntimeServerDefault creates GetRuntimeServerDefault with default headers values +func NewGetRuntimeServerDefault(code int) *GetRuntimeServerDefault { + if code <= 0 { + code = 500 + } + + return &GetRuntimeServerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get runtime server default response +func (o *GetRuntimeServerDefault) WithStatusCode(code int) *GetRuntimeServerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get runtime server default response +func (o *GetRuntimeServerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get runtime server default response +func (o *GetRuntimeServerDefault) WithConfigurationVersion(configurationVersion string) *GetRuntimeServerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get runtime server default response +func (o *GetRuntimeServerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get runtime server default response +func (o *GetRuntimeServerDefault) WithPayload(payload *models.Error) *GetRuntimeServerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get runtime server default response +func (o *GetRuntimeServerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetRuntimeServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_runtime_server_urlbuilder.go b/operations/server/get_runtime_server_urlbuilder.go new file mode 100644 index 00000000..cb0e5ed9 --- /dev/null +++ b/operations/server/get_runtime_server_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetRuntimeServerURL generates an URL for the get runtime server operation +type GetRuntimeServerURL struct { + Name string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRuntimeServerURL) WithBasePath(bp string) *GetRuntimeServerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetRuntimeServerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetRuntimeServerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/backends/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetRuntimeServerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetRuntimeServerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetRuntimeServerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetRuntimeServerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetRuntimeServerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetRuntimeServerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetRuntimeServerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetRuntimeServerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_server.go b/operations/server/get_server.go deleted file mode 100644 index e1685cf8..00000000 --- a/operations/server/get_server.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetServerHandlerFunc turns a function with the right signature into a get server handler -type GetServerHandlerFunc func(GetServerParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetServerHandlerFunc) Handle(params GetServerParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetServerHandler interface for that can handle valid get server params -type GetServerHandler interface { - Handle(GetServerParams, interface{}) middleware.Responder -} - -// NewGetServer creates a new http.Handler for the get server operation -func NewGetServer(ctx *middleware.Context, handler GetServerHandler) *GetServer { - return &GetServer{Context: ctx, Handler: handler} -} - -/*GetServer swagger:route GET /services/haproxy/configuration/servers/{name} Server getServer - -Return one server - -Returns one server configuration by it's name in the specified backend. - -*/ -type GetServer struct { - Context *middleware.Context - Handler GetServerHandler -} - -func (o *GetServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetServerParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetServerOKBody get server o k body -// swagger:model GetServerOKBody -type GetServerOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Server `json:"data,omitempty"` -} - -// Validate validates this get server o k body -func (o *GetServerOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetServerOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getServerOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetServerOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetServerOKBody) UnmarshalBinary(b []byte) error { - var res GetServerOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/server/get_server_backend.go b/operations/server/get_server_backend.go new file mode 100644 index 00000000..04e97a1f --- /dev/null +++ b/operations/server/get_server_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServerBackendHandlerFunc turns a function with the right signature into a get server backend handler +type GetServerBackendHandlerFunc func(GetServerBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServerBackendHandlerFunc) Handle(params GetServerBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServerBackendHandler interface for that can handle valid get server backend params +type GetServerBackendHandler interface { + Handle(GetServerBackendParams, interface{}) middleware.Responder +} + +// NewGetServerBackend creates a new http.Handler for the get server backend operation +func NewGetServerBackend(ctx *middleware.Context, handler GetServerBackendHandler) *GetServerBackend { + return &GetServerBackend{Context: ctx, Handler: handler} +} + +/* + GetServerBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/servers/{name} Server getServerBackend + +# Return one server + +Returns one server configuration by it's name in the specified backend. +*/ +type GetServerBackend struct { + Context *middleware.Context + Handler GetServerBackendHandler +} + +func (o *GetServerBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServerBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_server_backend_parameters.go b/operations/server/get_server_backend_parameters.go new file mode 100644 index 00000000..9db9eae2 --- /dev/null +++ b/operations/server/get_server_backend_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServerBackendParams creates a new GetServerBackendParams object +// +// There are no default values defined in the spec. +func NewGetServerBackendParams() GetServerBackendParams { + + return GetServerBackendParams{} +} + +// GetServerBackendParams contains all the bound params for the get server backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getServerBackend +type GetServerBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServerBackendParams() beforehand. +func (o *GetServerBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetServerBackendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServerBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetServerBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server/get_server_backend_responses.go b/operations/server/get_server_backend_responses.go new file mode 100644 index 00000000..9d69de2c --- /dev/null +++ b/operations/server/get_server_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServerBackendOKCode is the HTTP code returned for type GetServerBackendOK +const GetServerBackendOKCode int = 200 + +/* +GetServerBackendOK Successful operation + +swagger:response getServerBackendOK +*/ +type GetServerBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewGetServerBackendOK creates GetServerBackendOK with default headers values +func NewGetServerBackendOK() *GetServerBackendOK { + + return &GetServerBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server backend o k response +func (o *GetServerBackendOK) WithConfigurationVersion(configurationVersion string) *GetServerBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server backend o k response +func (o *GetServerBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server backend o k response +func (o *GetServerBackendOK) WithPayload(payload *models.Server) *GetServerBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server backend o k response +func (o *GetServerBackendOK) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServerBackendNotFoundCode is the HTTP code returned for type GetServerBackendNotFound +const GetServerBackendNotFoundCode int = 404 + +/* +GetServerBackendNotFound The specified resource was not found + +swagger:response getServerBackendNotFound +*/ +type GetServerBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerBackendNotFound creates GetServerBackendNotFound with default headers values +func NewGetServerBackendNotFound() *GetServerBackendNotFound { + + return &GetServerBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server backend not found response +func (o *GetServerBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetServerBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server backend not found response +func (o *GetServerBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server backend not found response +func (o *GetServerBackendNotFound) WithPayload(payload *models.Error) *GetServerBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server backend not found response +func (o *GetServerBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetServerBackendDefault General Error + +swagger:response getServerBackendDefault +*/ +type GetServerBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerBackendDefault creates GetServerBackendDefault with default headers values +func NewGetServerBackendDefault(code int) *GetServerBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetServerBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get server backend default response +func (o *GetServerBackendDefault) WithStatusCode(code int) *GetServerBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get server backend default response +func (o *GetServerBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get server backend default response +func (o *GetServerBackendDefault) WithConfigurationVersion(configurationVersion string) *GetServerBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server backend default response +func (o *GetServerBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server backend default response +func (o *GetServerBackendDefault) WithPayload(payload *models.Error) *GetServerBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server backend default response +func (o *GetServerBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_server_backend_urlbuilder.go b/operations/server/get_server_backend_urlbuilder.go new file mode 100644 index 00000000..14c2f79b --- /dev/null +++ b/operations/server/get_server_backend_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServerBackendURL generates an URL for the get server backend operation +type GetServerBackendURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerBackendURL) WithBasePath(bp string) *GetServerBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServerBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetServerBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServerBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServerBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServerBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServerBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServerBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServerBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServerBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_server_parameters.go b/operations/server/get_server_parameters.go deleted file mode 100644 index 0098f399..00000000 --- a/operations/server/get_server_parameters.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetServerParams creates a new GetServerParams object -// no default values defined in spec. -func NewGetServerParams() GetServerParams { - - return GetServerParams{} -} - -// GetServerParams contains all the bound params for the get server operation -// typically these are obtained from a http.Request -// -// swagger:parameters getServer -type GetServerParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /*Server name - Required: true - In: path - */ - Name string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetServerParams() beforehand. -func (o *GetServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - rName, rhkName, _ := route.Params.GetOK("name") - if err := o.bindName(rName, rhkName, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *GetServerParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindName binds and validates parameter Name from path. -func (o *GetServerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - o.Name = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetServerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/server/get_server_peer.go b/operations/server/get_server_peer.go new file mode 100644 index 00000000..a400e7bd --- /dev/null +++ b/operations/server/get_server_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServerPeerHandlerFunc turns a function with the right signature into a get server peer handler +type GetServerPeerHandlerFunc func(GetServerPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServerPeerHandlerFunc) Handle(params GetServerPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServerPeerHandler interface for that can handle valid get server peer params +type GetServerPeerHandler interface { + Handle(GetServerPeerParams, interface{}) middleware.Responder +} + +// NewGetServerPeer creates a new http.Handler for the get server peer operation +func NewGetServerPeer(ctx *middleware.Context, handler GetServerPeerHandler) *GetServerPeer { + return &GetServerPeer{Context: ctx, Handler: handler} +} + +/* + GetServerPeer swagger:route GET /services/haproxy/configuration/peers/{parent_name}/servers/{name} Server getServerPeer + +# Return one server + +Returns one server configuration by it's name in the specified backend. +*/ +type GetServerPeer struct { + Context *middleware.Context + Handler GetServerPeerHandler +} + +func (o *GetServerPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServerPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_server_peer_parameters.go b/operations/server/get_server_peer_parameters.go new file mode 100644 index 00000000..314b5649 --- /dev/null +++ b/operations/server/get_server_peer_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServerPeerParams creates a new GetServerPeerParams object +// +// There are no default values defined in the spec. +func NewGetServerPeerParams() GetServerPeerParams { + + return GetServerPeerParams{} +} + +// GetServerPeerParams contains all the bound params for the get server peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters getServerPeer +type GetServerPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServerPeerParams() beforehand. +func (o *GetServerPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetServerPeerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServerPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetServerPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server/get_server_peer_responses.go b/operations/server/get_server_peer_responses.go new file mode 100644 index 00000000..0aa0b929 --- /dev/null +++ b/operations/server/get_server_peer_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServerPeerOKCode is the HTTP code returned for type GetServerPeerOK +const GetServerPeerOKCode int = 200 + +/* +GetServerPeerOK Successful operation + +swagger:response getServerPeerOK +*/ +type GetServerPeerOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewGetServerPeerOK creates GetServerPeerOK with default headers values +func NewGetServerPeerOK() *GetServerPeerOK { + + return &GetServerPeerOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server peer o k response +func (o *GetServerPeerOK) WithConfigurationVersion(configurationVersion string) *GetServerPeerOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server peer o k response +func (o *GetServerPeerOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server peer o k response +func (o *GetServerPeerOK) WithPayload(payload *models.Server) *GetServerPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server peer o k response +func (o *GetServerPeerOK) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServerPeerNotFoundCode is the HTTP code returned for type GetServerPeerNotFound +const GetServerPeerNotFoundCode int = 404 + +/* +GetServerPeerNotFound The specified resource was not found + +swagger:response getServerPeerNotFound +*/ +type GetServerPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerPeerNotFound creates GetServerPeerNotFound with default headers values +func NewGetServerPeerNotFound() *GetServerPeerNotFound { + + return &GetServerPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server peer not found response +func (o *GetServerPeerNotFound) WithConfigurationVersion(configurationVersion string) *GetServerPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server peer not found response +func (o *GetServerPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server peer not found response +func (o *GetServerPeerNotFound) WithPayload(payload *models.Error) *GetServerPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server peer not found response +func (o *GetServerPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetServerPeerDefault General Error + +swagger:response getServerPeerDefault +*/ +type GetServerPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerPeerDefault creates GetServerPeerDefault with default headers values +func NewGetServerPeerDefault(code int) *GetServerPeerDefault { + if code <= 0 { + code = 500 + } + + return &GetServerPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get server peer default response +func (o *GetServerPeerDefault) WithStatusCode(code int) *GetServerPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get server peer default response +func (o *GetServerPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get server peer default response +func (o *GetServerPeerDefault) WithConfigurationVersion(configurationVersion string) *GetServerPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server peer default response +func (o *GetServerPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server peer default response +func (o *GetServerPeerDefault) WithPayload(payload *models.Error) *GetServerPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server peer default response +func (o *GetServerPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_server_peer_urlbuilder.go b/operations/server/get_server_peer_urlbuilder.go new file mode 100644 index 00000000..544f0e96 --- /dev/null +++ b/operations/server/get_server_peer_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServerPeerURL generates an URL for the get server peer operation +type GetServerPeerURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerPeerURL) WithBasePath(bp string) *GetServerPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServerPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetServerPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServerPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServerPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServerPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServerPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServerPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServerPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServerPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_server_responses.go b/operations/server/get_server_responses.go deleted file mode 100644 index 35263618..00000000 --- a/operations/server/get_server_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetServerOKCode is the HTTP code returned for type GetServerOK -const GetServerOKCode int = 200 - -/*GetServerOK Successful operation - -swagger:response getServerOK -*/ -type GetServerOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetServerOKBody `json:"body,omitempty"` -} - -// NewGetServerOK creates GetServerOK with default headers values -func NewGetServerOK() *GetServerOK { - - return &GetServerOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get server o k response -func (o *GetServerOK) WithConfigurationVersion(configurationVersion int64) *GetServerOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get server o k response -func (o *GetServerOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get server o k response -func (o *GetServerOK) WithPayload(payload *GetServerOKBody) *GetServerOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get server o k response -func (o *GetServerOK) SetPayload(payload *GetServerOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetServerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetServerNotFoundCode is the HTTP code returned for type GetServerNotFound -const GetServerNotFoundCode int = 404 - -/*GetServerNotFound The specified resource was not found - -swagger:response getServerNotFound -*/ -type GetServerNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetServerNotFound creates GetServerNotFound with default headers values -func NewGetServerNotFound() *GetServerNotFound { - - return &GetServerNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get server not found response -func (o *GetServerNotFound) WithConfigurationVersion(configurationVersion int64) *GetServerNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get server not found response -func (o *GetServerNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get server not found response -func (o *GetServerNotFound) WithPayload(payload *models.Error) *GetServerNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get server not found response -func (o *GetServerNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetServerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetServerDefault General Error - -swagger:response getServerDefault -*/ -type GetServerDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetServerDefault creates GetServerDefault with default headers values -func NewGetServerDefault(code int) *GetServerDefault { - if code <= 0 { - code = 500 - } - - return &GetServerDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get server default response -func (o *GetServerDefault) WithStatusCode(code int) *GetServerDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get server default response -func (o *GetServerDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get server default response -func (o *GetServerDefault) WithConfigurationVersion(configurationVersion int64) *GetServerDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get server default response -func (o *GetServerDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get server default response -func (o *GetServerDefault) WithPayload(payload *models.Error) *GetServerDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get server default response -func (o *GetServerDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/server/get_server_ring.go b/operations/server/get_server_ring.go new file mode 100644 index 00000000..4248d874 --- /dev/null +++ b/operations/server/get_server_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServerRingHandlerFunc turns a function with the right signature into a get server ring handler +type GetServerRingHandlerFunc func(GetServerRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServerRingHandlerFunc) Handle(params GetServerRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServerRingHandler interface for that can handle valid get server ring params +type GetServerRingHandler interface { + Handle(GetServerRingParams, interface{}) middleware.Responder +} + +// NewGetServerRing creates a new http.Handler for the get server ring operation +func NewGetServerRing(ctx *middleware.Context, handler GetServerRingHandler) *GetServerRing { + return &GetServerRing{Context: ctx, Handler: handler} +} + +/* + GetServerRing swagger:route GET /services/haproxy/configuration/rings/{parent_name}/servers/{name} Server getServerRing + +# Return one server + +Returns one server configuration by it's name in the specified backend. +*/ +type GetServerRing struct { + Context *middleware.Context + Handler GetServerRingHandler +} + +func (o *GetServerRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServerRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/get_server_ring_parameters.go b/operations/server/get_server_ring_parameters.go new file mode 100644 index 00000000..ebf089f3 --- /dev/null +++ b/operations/server/get_server_ring_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServerRingParams creates a new GetServerRingParams object +// +// There are no default values defined in the spec. +func NewGetServerRingParams() GetServerRingParams { + + return GetServerRingParams{} +} + +// GetServerRingParams contains all the bound params for the get server ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters getServerRing +type GetServerRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServerRingParams() beforehand. +func (o *GetServerRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetServerRingParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServerRingParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetServerRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server/get_server_ring_responses.go b/operations/server/get_server_ring_responses.go new file mode 100644 index 00000000..3a49f251 --- /dev/null +++ b/operations/server/get_server_ring_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServerRingOKCode is the HTTP code returned for type GetServerRingOK +const GetServerRingOKCode int = 200 + +/* +GetServerRingOK Successful operation + +swagger:response getServerRingOK +*/ +type GetServerRingOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewGetServerRingOK creates GetServerRingOK with default headers values +func NewGetServerRingOK() *GetServerRingOK { + + return &GetServerRingOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server ring o k response +func (o *GetServerRingOK) WithConfigurationVersion(configurationVersion string) *GetServerRingOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server ring o k response +func (o *GetServerRingOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server ring o k response +func (o *GetServerRingOK) WithPayload(payload *models.Server) *GetServerRingOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server ring o k response +func (o *GetServerRingOK) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerRingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServerRingNotFoundCode is the HTTP code returned for type GetServerRingNotFound +const GetServerRingNotFoundCode int = 404 + +/* +GetServerRingNotFound The specified resource was not found + +swagger:response getServerRingNotFound +*/ +type GetServerRingNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerRingNotFound creates GetServerRingNotFound with default headers values +func NewGetServerRingNotFound() *GetServerRingNotFound { + + return &GetServerRingNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server ring not found response +func (o *GetServerRingNotFound) WithConfigurationVersion(configurationVersion string) *GetServerRingNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server ring not found response +func (o *GetServerRingNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server ring not found response +func (o *GetServerRingNotFound) WithPayload(payload *models.Error) *GetServerRingNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server ring not found response +func (o *GetServerRingNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerRingNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetServerRingDefault General Error + +swagger:response getServerRingDefault +*/ +type GetServerRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerRingDefault creates GetServerRingDefault with default headers values +func NewGetServerRingDefault(code int) *GetServerRingDefault { + if code <= 0 { + code = 500 + } + + return &GetServerRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get server ring default response +func (o *GetServerRingDefault) WithStatusCode(code int) *GetServerRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get server ring default response +func (o *GetServerRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get server ring default response +func (o *GetServerRingDefault) WithConfigurationVersion(configurationVersion string) *GetServerRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server ring default response +func (o *GetServerRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server ring default response +func (o *GetServerRingDefault) WithPayload(payload *models.Error) *GetServerRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server ring default response +func (o *GetServerRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/get_server_ring_urlbuilder.go b/operations/server/get_server_ring_urlbuilder.go new file mode 100644 index 00000000..be9228d9 --- /dev/null +++ b/operations/server/get_server_ring_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServerRingURL generates an URL for the get server ring operation +type GetServerRingURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerRingURL) WithBasePath(bp string) *GetServerRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServerRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetServerRingURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServerRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServerRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServerRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServerRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServerRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServerRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServerRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/get_server_urlbuilder.go b/operations/server/get_server_urlbuilder.go deleted file mode 100644 index d06c477e..00000000 --- a/operations/server/get_server_urlbuilder.go +++ /dev/null @@ -1,134 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" -) - -// GetServerURL generates an URL for the get server operation -type GetServerURL struct { - Name string - - Backend string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetServerURL) WithBasePath(bp string) *GetServerURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetServerURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetServerURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/servers/{name}" - - name := o.Name - if name != "" { - _path = strings.Replace(_path, "{name}", name, -1) - } else { - return nil, errors.New("name is required on GetServerURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetServerURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetServerURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetServerURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetServerURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetServerURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetServerURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/server/get_servers.go b/operations/server/get_servers.go deleted file mode 100644 index e0bd98bd..00000000 --- a/operations/server/get_servers.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetServersHandlerFunc turns a function with the right signature into a get servers handler -type GetServersHandlerFunc func(GetServersParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetServersHandlerFunc) Handle(params GetServersParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetServersHandler interface for that can handle valid get servers params -type GetServersHandler interface { - Handle(GetServersParams, interface{}) middleware.Responder -} - -// NewGetServers creates a new http.Handler for the get servers operation -func NewGetServers(ctx *middleware.Context, handler GetServersHandler) *GetServers { - return &GetServers{Context: ctx, Handler: handler} -} - -/*GetServers swagger:route GET /services/haproxy/configuration/servers Server getServers - -Return an array of servers - -Returns an array of all servers that are configured in specified backend. - -*/ -type GetServers struct { - Context *middleware.Context - Handler GetServersHandler -} - -func (o *GetServers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetServersParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetServersOKBody get servers o k body -// swagger:model GetServersOKBody -type GetServersOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.Servers `json:"data"` -} - -// Validate validates this get servers o k body -func (o *GetServersOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetServersOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getServersOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getServersOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetServersOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetServersOKBody) UnmarshalBinary(b []byte) error { - var res GetServersOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/server/get_servers_parameters.go b/operations/server/get_servers_parameters.go deleted file mode 100644 index 8f34fd5d..00000000 --- a/operations/server/get_servers_parameters.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetServersParams creates a new GetServersParams object -// no default values defined in spec. -func NewGetServersParams() GetServersParams { - - return GetServersParams{} -} - -// GetServersParams contains all the bound params for the get servers operation -// typically these are obtained from a http.Request -// -// swagger:parameters getServers -type GetServersParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetServersParams() beforehand. -func (o *GetServersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *GetServersParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetServersParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/server/get_servers_responses.go b/operations/server/get_servers_responses.go deleted file mode 100644 index 94aa20af..00000000 --- a/operations/server/get_servers_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetServersOKCode is the HTTP code returned for type GetServersOK -const GetServersOKCode int = 200 - -/*GetServersOK Successful operation - -swagger:response getServersOK -*/ -type GetServersOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetServersOKBody `json:"body,omitempty"` -} - -// NewGetServersOK creates GetServersOK with default headers values -func NewGetServersOK() *GetServersOK { - - return &GetServersOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get servers o k response -func (o *GetServersOK) WithConfigurationVersion(configurationVersion int64) *GetServersOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get servers o k response -func (o *GetServersOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get servers o k response -func (o *GetServersOK) WithPayload(payload *GetServersOKBody) *GetServersOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get servers o k response -func (o *GetServersOK) SetPayload(payload *GetServersOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetServersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetServersDefault General Error - -swagger:response getServersDefault -*/ -type GetServersDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetServersDefault creates GetServersDefault with default headers values -func NewGetServersDefault(code int) *GetServersDefault { - if code <= 0 { - code = 500 - } - - return &GetServersDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get servers default response -func (o *GetServersDefault) WithStatusCode(code int) *GetServersDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get servers default response -func (o *GetServersDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get servers default response -func (o *GetServersDefault) WithConfigurationVersion(configurationVersion int64) *GetServersDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get servers default response -func (o *GetServersDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get servers default response -func (o *GetServersDefault) WithPayload(payload *models.Error) *GetServersDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get servers default response -func (o *GetServersDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetServersDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/server/get_servers_urlbuilder.go b/operations/server/get_servers_urlbuilder.go deleted file mode 100644 index 961e57f1..00000000 --- a/operations/server/get_servers_urlbuilder.go +++ /dev/null @@ -1,124 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetServersURL generates an URL for the get servers operation -type GetServersURL struct { - Backend string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetServersURL) WithBasePath(bp string) *GetServersURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetServersURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetServersURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/servers" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetServersURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetServersURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetServersURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetServersURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetServersURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetServersURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/server/replace_runtime_server.go b/operations/server/replace_runtime_server.go new file mode 100644 index 00000000..c5c49326 --- /dev/null +++ b/operations/server/replace_runtime_server.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceRuntimeServerHandlerFunc turns a function with the right signature into a replace runtime server handler +type ReplaceRuntimeServerHandlerFunc func(ReplaceRuntimeServerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceRuntimeServerHandlerFunc) Handle(params ReplaceRuntimeServerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceRuntimeServerHandler interface for that can handle valid replace runtime server params +type ReplaceRuntimeServerHandler interface { + Handle(ReplaceRuntimeServerParams, interface{}) middleware.Responder +} + +// NewReplaceRuntimeServer creates a new http.Handler for the replace runtime server operation +func NewReplaceRuntimeServer(ctx *middleware.Context, handler ReplaceRuntimeServerHandler) *ReplaceRuntimeServer { + return &ReplaceRuntimeServer{Context: ctx, Handler: handler} +} + +/* + ReplaceRuntimeServer swagger:route PUT /services/haproxy/runtime/backends/{parent_name}/servers/{name} Server replaceRuntimeServer + +# Replace server transient settings + +Replaces a server transient settings by it's name in the specified backend. +*/ +type ReplaceRuntimeServer struct { + Context *middleware.Context + Handler ReplaceRuntimeServerHandler +} + +func (o *ReplaceRuntimeServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceRuntimeServerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/replace_runtime_server_parameters.go b/operations/server/replace_runtime_server_parameters.go new file mode 100644 index 00000000..21fd8a27 --- /dev/null +++ b/operations/server/replace_runtime_server_parameters.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceRuntimeServerParams creates a new ReplaceRuntimeServerParams object +// +// There are no default values defined in the spec. +func NewReplaceRuntimeServerParams() ReplaceRuntimeServerParams { + + return ReplaceRuntimeServerParams{} +} + +// ReplaceRuntimeServerParams contains all the bound params for the replace runtime server operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceRuntimeServer +type ReplaceRuntimeServerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.RuntimeServer + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceRuntimeServerParams() beforehand. +func (o *ReplaceRuntimeServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RuntimeServer + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceRuntimeServerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceRuntimeServerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/server/replace_runtime_server_responses.go b/operations/server/replace_runtime_server_responses.go new file mode 100644 index 00000000..3f1010d5 --- /dev/null +++ b/operations/server/replace_runtime_server_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceRuntimeServerOKCode is the HTTP code returned for type ReplaceRuntimeServerOK +const ReplaceRuntimeServerOKCode int = 200 + +/* +ReplaceRuntimeServerOK Server transient settings replaced + +swagger:response replaceRuntimeServerOK +*/ +type ReplaceRuntimeServerOK struct { + + /* + In: Body + */ + Payload *models.RuntimeServer `json:"body,omitempty"` +} + +// NewReplaceRuntimeServerOK creates ReplaceRuntimeServerOK with default headers values +func NewReplaceRuntimeServerOK() *ReplaceRuntimeServerOK { + + return &ReplaceRuntimeServerOK{} +} + +// WithPayload adds the payload to the replace runtime server o k response +func (o *ReplaceRuntimeServerOK) WithPayload(payload *models.RuntimeServer) *ReplaceRuntimeServerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime server o k response +func (o *ReplaceRuntimeServerOK) SetPayload(payload *models.RuntimeServer) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeServerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceRuntimeServerBadRequestCode is the HTTP code returned for type ReplaceRuntimeServerBadRequest +const ReplaceRuntimeServerBadRequestCode int = 400 + +/* +ReplaceRuntimeServerBadRequest Bad request + +swagger:response replaceRuntimeServerBadRequest +*/ +type ReplaceRuntimeServerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRuntimeServerBadRequest creates ReplaceRuntimeServerBadRequest with default headers values +func NewReplaceRuntimeServerBadRequest() *ReplaceRuntimeServerBadRequest { + + return &ReplaceRuntimeServerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace runtime server bad request response +func (o *ReplaceRuntimeServerBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceRuntimeServerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace runtime server bad request response +func (o *ReplaceRuntimeServerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace runtime server bad request response +func (o *ReplaceRuntimeServerBadRequest) WithPayload(payload *models.Error) *ReplaceRuntimeServerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime server bad request response +func (o *ReplaceRuntimeServerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeServerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceRuntimeServerNotFoundCode is the HTTP code returned for type ReplaceRuntimeServerNotFound +const ReplaceRuntimeServerNotFoundCode int = 404 + +/* +ReplaceRuntimeServerNotFound The specified resource was not found + +swagger:response replaceRuntimeServerNotFound +*/ +type ReplaceRuntimeServerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRuntimeServerNotFound creates ReplaceRuntimeServerNotFound with default headers values +func NewReplaceRuntimeServerNotFound() *ReplaceRuntimeServerNotFound { + + return &ReplaceRuntimeServerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace runtime server not found response +func (o *ReplaceRuntimeServerNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceRuntimeServerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace runtime server not found response +func (o *ReplaceRuntimeServerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace runtime server not found response +func (o *ReplaceRuntimeServerNotFound) WithPayload(payload *models.Error) *ReplaceRuntimeServerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime server not found response +func (o *ReplaceRuntimeServerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeServerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceRuntimeServerDefault General Error + +swagger:response replaceRuntimeServerDefault +*/ +type ReplaceRuntimeServerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceRuntimeServerDefault creates ReplaceRuntimeServerDefault with default headers values +func NewReplaceRuntimeServerDefault(code int) *ReplaceRuntimeServerDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceRuntimeServerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace runtime server default response +func (o *ReplaceRuntimeServerDefault) WithStatusCode(code int) *ReplaceRuntimeServerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace runtime server default response +func (o *ReplaceRuntimeServerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace runtime server default response +func (o *ReplaceRuntimeServerDefault) WithConfigurationVersion(configurationVersion string) *ReplaceRuntimeServerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace runtime server default response +func (o *ReplaceRuntimeServerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace runtime server default response +func (o *ReplaceRuntimeServerDefault) WithPayload(payload *models.Error) *ReplaceRuntimeServerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace runtime server default response +func (o *ReplaceRuntimeServerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceRuntimeServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/replace_runtime_server_urlbuilder.go b/operations/server/replace_runtime_server_urlbuilder.go new file mode 100644 index 00000000..af0b6292 --- /dev/null +++ b/operations/server/replace_runtime_server_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ReplaceRuntimeServerURL generates an URL for the replace runtime server operation +type ReplaceRuntimeServerURL struct { + Name string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceRuntimeServerURL) WithBasePath(bp string) *ReplaceRuntimeServerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceRuntimeServerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceRuntimeServerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/backends/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceRuntimeServerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceRuntimeServerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceRuntimeServerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceRuntimeServerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceRuntimeServerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceRuntimeServerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceRuntimeServerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceRuntimeServerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/replace_server.go b/operations/server/replace_server.go deleted file mode 100644 index 54da8e04..00000000 --- a/operations/server/replace_server.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceServerHandlerFunc turns a function with the right signature into a replace server handler -type ReplaceServerHandlerFunc func(ReplaceServerParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceServerHandlerFunc) Handle(params ReplaceServerParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceServerHandler interface for that can handle valid replace server params -type ReplaceServerHandler interface { - Handle(ReplaceServerParams, interface{}) middleware.Responder -} - -// NewReplaceServer creates a new http.Handler for the replace server operation -func NewReplaceServer(ctx *middleware.Context, handler ReplaceServerHandler) *ReplaceServer { - return &ReplaceServer{Context: ctx, Handler: handler} -} - -/*ReplaceServer swagger:route PUT /services/haproxy/configuration/servers/{name} Server replaceServer - -Replace a server - -Replaces a server configuration by it's name in the specified backend. - -*/ -type ReplaceServer struct { - Context *middleware.Context - Handler ReplaceServerHandler -} - -func (o *ReplaceServer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceServerParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/server/replace_server_backend.go b/operations/server/replace_server_backend.go new file mode 100644 index 00000000..2625f055 --- /dev/null +++ b/operations/server/replace_server_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceServerBackendHandlerFunc turns a function with the right signature into a replace server backend handler +type ReplaceServerBackendHandlerFunc func(ReplaceServerBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceServerBackendHandlerFunc) Handle(params ReplaceServerBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceServerBackendHandler interface for that can handle valid replace server backend params +type ReplaceServerBackendHandler interface { + Handle(ReplaceServerBackendParams, interface{}) middleware.Responder +} + +// NewReplaceServerBackend creates a new http.Handler for the replace server backend operation +func NewReplaceServerBackend(ctx *middleware.Context, handler ReplaceServerBackendHandler) *ReplaceServerBackend { + return &ReplaceServerBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceServerBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/servers/{name} Server replaceServerBackend + +# Replace a server + +Replaces a server configuration by it's name in the specified backend. +*/ +type ReplaceServerBackend struct { + Context *middleware.Context + Handler ReplaceServerBackendHandler +} + +func (o *ReplaceServerBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceServerBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/replace_server_backend_parameters.go b/operations/server/replace_server_backend_parameters.go new file mode 100644 index 00000000..816221fb --- /dev/null +++ b/operations/server/replace_server_backend_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceServerBackendParams creates a new ReplaceServerBackendParams object +// with the default values initialized. +func NewReplaceServerBackendParams() ReplaceServerBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceServerBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceServerBackendParams contains all the bound params for the replace server backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceServerBackend +type ReplaceServerBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Server + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceServerBackendParams() beforehand. +func (o *ReplaceServerBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Server + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceServerBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceServerBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceServerBackendParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceServerBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceServerBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceServerBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/replace_server_backend_responses.go b/operations/server/replace_server_backend_responses.go new file mode 100644 index 00000000..117c855f --- /dev/null +++ b/operations/server/replace_server_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceServerBackendOKCode is the HTTP code returned for type ReplaceServerBackendOK +const ReplaceServerBackendOKCode int = 200 + +/* +ReplaceServerBackendOK Server replaced + +swagger:response replaceServerBackendOK +*/ +type ReplaceServerBackendOK struct { + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewReplaceServerBackendOK creates ReplaceServerBackendOK with default headers values +func NewReplaceServerBackendOK() *ReplaceServerBackendOK { + + return &ReplaceServerBackendOK{} +} + +// WithPayload adds the payload to the replace server backend o k response +func (o *ReplaceServerBackendOK) WithPayload(payload *models.Server) *ReplaceServerBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server backend o k response +func (o *ReplaceServerBackendOK) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerBackendAcceptedCode is the HTTP code returned for type ReplaceServerBackendAccepted +const ReplaceServerBackendAcceptedCode int = 202 + +/* +ReplaceServerBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceServerBackendAccepted +*/ +type ReplaceServerBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewReplaceServerBackendAccepted creates ReplaceServerBackendAccepted with default headers values +func NewReplaceServerBackendAccepted() *ReplaceServerBackendAccepted { + + return &ReplaceServerBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace server backend accepted response +func (o *ReplaceServerBackendAccepted) WithReloadID(reloadID string) *ReplaceServerBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace server backend accepted response +func (o *ReplaceServerBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace server backend accepted response +func (o *ReplaceServerBackendAccepted) WithPayload(payload *models.Server) *ReplaceServerBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server backend accepted response +func (o *ReplaceServerBackendAccepted) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerBackendBadRequestCode is the HTTP code returned for type ReplaceServerBackendBadRequest +const ReplaceServerBackendBadRequestCode int = 400 + +/* +ReplaceServerBackendBadRequest Bad request + +swagger:response replaceServerBackendBadRequest +*/ +type ReplaceServerBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerBackendBadRequest creates ReplaceServerBackendBadRequest with default headers values +func NewReplaceServerBackendBadRequest() *ReplaceServerBackendBadRequest { + + return &ReplaceServerBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server backend bad request response +func (o *ReplaceServerBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceServerBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server backend bad request response +func (o *ReplaceServerBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server backend bad request response +func (o *ReplaceServerBackendBadRequest) WithPayload(payload *models.Error) *ReplaceServerBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server backend bad request response +func (o *ReplaceServerBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerBackendNotFoundCode is the HTTP code returned for type ReplaceServerBackendNotFound +const ReplaceServerBackendNotFoundCode int = 404 + +/* +ReplaceServerBackendNotFound The specified resource was not found + +swagger:response replaceServerBackendNotFound +*/ +type ReplaceServerBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerBackendNotFound creates ReplaceServerBackendNotFound with default headers values +func NewReplaceServerBackendNotFound() *ReplaceServerBackendNotFound { + + return &ReplaceServerBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server backend not found response +func (o *ReplaceServerBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceServerBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server backend not found response +func (o *ReplaceServerBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server backend not found response +func (o *ReplaceServerBackendNotFound) WithPayload(payload *models.Error) *ReplaceServerBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server backend not found response +func (o *ReplaceServerBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceServerBackendDefault General Error + +swagger:response replaceServerBackendDefault +*/ +type ReplaceServerBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerBackendDefault creates ReplaceServerBackendDefault with default headers values +func NewReplaceServerBackendDefault(code int) *ReplaceServerBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceServerBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace server backend default response +func (o *ReplaceServerBackendDefault) WithStatusCode(code int) *ReplaceServerBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace server backend default response +func (o *ReplaceServerBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace server backend default response +func (o *ReplaceServerBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceServerBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server backend default response +func (o *ReplaceServerBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server backend default response +func (o *ReplaceServerBackendDefault) WithPayload(payload *models.Error) *ReplaceServerBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server backend default response +func (o *ReplaceServerBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/replace_server_backend_urlbuilder.go b/operations/server/replace_server_backend_urlbuilder.go new file mode 100644 index 00000000..5470aa21 --- /dev/null +++ b/operations/server/replace_server_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceServerBackendURL generates an URL for the replace server backend operation +type ReplaceServerBackendURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerBackendURL) WithBasePath(bp string) *ReplaceServerBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceServerBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceServerBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceServerBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceServerBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceServerBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceServerBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceServerBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceServerBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceServerBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/replace_server_parameters.go b/operations/server/replace_server_parameters.go deleted file mode 100644 index 690d8593..00000000 --- a/operations/server/replace_server_parameters.go +++ /dev/null @@ -1,253 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceServerParams creates a new ReplaceServerParams object -// with the default values initialized. -func NewReplaceServerParams() ReplaceServerParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceServerParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceServerParams contains all the bound params for the replace server operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceServer -type ReplaceServerParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /* - Required: true - In: body - */ - Data *models.Server - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Server name - Required: true - In: path - */ - Name string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceServerParams() beforehand. -func (o *ReplaceServerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.Server - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rName, rhkName, _ := route.Params.GetOK("name") - if err := o.bindName(rName, rhkName, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *ReplaceServerParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceServerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceServerParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindName binds and validates parameter Name from path. -func (o *ReplaceServerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - o.Name = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceServerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceServerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/server/replace_server_peer.go b/operations/server/replace_server_peer.go new file mode 100644 index 00000000..9b0251e6 --- /dev/null +++ b/operations/server/replace_server_peer.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceServerPeerHandlerFunc turns a function with the right signature into a replace server peer handler +type ReplaceServerPeerHandlerFunc func(ReplaceServerPeerParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceServerPeerHandlerFunc) Handle(params ReplaceServerPeerParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceServerPeerHandler interface for that can handle valid replace server peer params +type ReplaceServerPeerHandler interface { + Handle(ReplaceServerPeerParams, interface{}) middleware.Responder +} + +// NewReplaceServerPeer creates a new http.Handler for the replace server peer operation +func NewReplaceServerPeer(ctx *middleware.Context, handler ReplaceServerPeerHandler) *ReplaceServerPeer { + return &ReplaceServerPeer{Context: ctx, Handler: handler} +} + +/* + ReplaceServerPeer swagger:route PUT /services/haproxy/configuration/peers/{parent_name}/servers/{name} Server replaceServerPeer + +# Replace a server + +Replaces a server configuration by it's name in the specified backend. +*/ +type ReplaceServerPeer struct { + Context *middleware.Context + Handler ReplaceServerPeerHandler +} + +func (o *ReplaceServerPeer) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceServerPeerParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/replace_server_peer_parameters.go b/operations/server/replace_server_peer_parameters.go new file mode 100644 index 00000000..8149b2de --- /dev/null +++ b/operations/server/replace_server_peer_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceServerPeerParams creates a new ReplaceServerPeerParams object +// with the default values initialized. +func NewReplaceServerPeerParams() ReplaceServerPeerParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceServerPeerParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceServerPeerParams contains all the bound params for the replace server peer operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceServerPeer +type ReplaceServerPeerParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Server + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceServerPeerParams() beforehand. +func (o *ReplaceServerPeerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Server + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceServerPeerParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceServerPeerParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceServerPeerParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceServerPeerParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceServerPeerParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceServerPeerParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/replace_server_peer_responses.go b/operations/server/replace_server_peer_responses.go new file mode 100644 index 00000000..8767893e --- /dev/null +++ b/operations/server/replace_server_peer_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceServerPeerOKCode is the HTTP code returned for type ReplaceServerPeerOK +const ReplaceServerPeerOKCode int = 200 + +/* +ReplaceServerPeerOK Server replaced + +swagger:response replaceServerPeerOK +*/ +type ReplaceServerPeerOK struct { + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewReplaceServerPeerOK creates ReplaceServerPeerOK with default headers values +func NewReplaceServerPeerOK() *ReplaceServerPeerOK { + + return &ReplaceServerPeerOK{} +} + +// WithPayload adds the payload to the replace server peer o k response +func (o *ReplaceServerPeerOK) WithPayload(payload *models.Server) *ReplaceServerPeerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server peer o k response +func (o *ReplaceServerPeerOK) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerPeerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerPeerAcceptedCode is the HTTP code returned for type ReplaceServerPeerAccepted +const ReplaceServerPeerAcceptedCode int = 202 + +/* +ReplaceServerPeerAccepted Configuration change accepted and reload requested + +swagger:response replaceServerPeerAccepted +*/ +type ReplaceServerPeerAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewReplaceServerPeerAccepted creates ReplaceServerPeerAccepted with default headers values +func NewReplaceServerPeerAccepted() *ReplaceServerPeerAccepted { + + return &ReplaceServerPeerAccepted{} +} + +// WithReloadID adds the reloadId to the replace server peer accepted response +func (o *ReplaceServerPeerAccepted) WithReloadID(reloadID string) *ReplaceServerPeerAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace server peer accepted response +func (o *ReplaceServerPeerAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace server peer accepted response +func (o *ReplaceServerPeerAccepted) WithPayload(payload *models.Server) *ReplaceServerPeerAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server peer accepted response +func (o *ReplaceServerPeerAccepted) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerPeerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerPeerBadRequestCode is the HTTP code returned for type ReplaceServerPeerBadRequest +const ReplaceServerPeerBadRequestCode int = 400 + +/* +ReplaceServerPeerBadRequest Bad request + +swagger:response replaceServerPeerBadRequest +*/ +type ReplaceServerPeerBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerPeerBadRequest creates ReplaceServerPeerBadRequest with default headers values +func NewReplaceServerPeerBadRequest() *ReplaceServerPeerBadRequest { + + return &ReplaceServerPeerBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server peer bad request response +func (o *ReplaceServerPeerBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceServerPeerBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server peer bad request response +func (o *ReplaceServerPeerBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server peer bad request response +func (o *ReplaceServerPeerBadRequest) WithPayload(payload *models.Error) *ReplaceServerPeerBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server peer bad request response +func (o *ReplaceServerPeerBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerPeerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerPeerNotFoundCode is the HTTP code returned for type ReplaceServerPeerNotFound +const ReplaceServerPeerNotFoundCode int = 404 + +/* +ReplaceServerPeerNotFound The specified resource was not found + +swagger:response replaceServerPeerNotFound +*/ +type ReplaceServerPeerNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerPeerNotFound creates ReplaceServerPeerNotFound with default headers values +func NewReplaceServerPeerNotFound() *ReplaceServerPeerNotFound { + + return &ReplaceServerPeerNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server peer not found response +func (o *ReplaceServerPeerNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceServerPeerNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server peer not found response +func (o *ReplaceServerPeerNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server peer not found response +func (o *ReplaceServerPeerNotFound) WithPayload(payload *models.Error) *ReplaceServerPeerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server peer not found response +func (o *ReplaceServerPeerNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerPeerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceServerPeerDefault General Error + +swagger:response replaceServerPeerDefault +*/ +type ReplaceServerPeerDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerPeerDefault creates ReplaceServerPeerDefault with default headers values +func NewReplaceServerPeerDefault(code int) *ReplaceServerPeerDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceServerPeerDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace server peer default response +func (o *ReplaceServerPeerDefault) WithStatusCode(code int) *ReplaceServerPeerDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace server peer default response +func (o *ReplaceServerPeerDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace server peer default response +func (o *ReplaceServerPeerDefault) WithConfigurationVersion(configurationVersion string) *ReplaceServerPeerDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server peer default response +func (o *ReplaceServerPeerDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server peer default response +func (o *ReplaceServerPeerDefault) WithPayload(payload *models.Error) *ReplaceServerPeerDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server peer default response +func (o *ReplaceServerPeerDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerPeerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/replace_server_peer_urlbuilder.go b/operations/server/replace_server_peer_urlbuilder.go new file mode 100644 index 00000000..3d325281 --- /dev/null +++ b/operations/server/replace_server_peer_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceServerPeerURL generates an URL for the replace server peer operation +type ReplaceServerPeerURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerPeerURL) WithBasePath(bp string) *ReplaceServerPeerURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerPeerURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceServerPeerURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceServerPeerURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceServerPeerURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceServerPeerURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceServerPeerURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceServerPeerURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceServerPeerURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceServerPeerURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceServerPeerURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/replace_server_responses.go b/operations/server/replace_server_responses.go deleted file mode 100644 index fce31bdb..00000000 --- a/operations/server/replace_server_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceServerOKCode is the HTTP code returned for type ReplaceServerOK -const ReplaceServerOKCode int = 200 - -/*ReplaceServerOK Server replaced - -swagger:response replaceServerOK -*/ -type ReplaceServerOK struct { - - /* - In: Body - */ - Payload *models.Server `json:"body,omitempty"` -} - -// NewReplaceServerOK creates ReplaceServerOK with default headers values -func NewReplaceServerOK() *ReplaceServerOK { - - return &ReplaceServerOK{} -} - -// WithPayload adds the payload to the replace server o k response -func (o *ReplaceServerOK) WithPayload(payload *models.Server) *ReplaceServerOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace server o k response -func (o *ReplaceServerOK) SetPayload(payload *models.Server) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceServerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceServerAcceptedCode is the HTTP code returned for type ReplaceServerAccepted -const ReplaceServerAcceptedCode int = 202 - -/*ReplaceServerAccepted Configuration change accepted and reload requested - -swagger:response replaceServerAccepted -*/ -type ReplaceServerAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.Server `json:"body,omitempty"` -} - -// NewReplaceServerAccepted creates ReplaceServerAccepted with default headers values -func NewReplaceServerAccepted() *ReplaceServerAccepted { - - return &ReplaceServerAccepted{} -} - -// WithReloadID adds the reloadId to the replace server accepted response -func (o *ReplaceServerAccepted) WithReloadID(reloadID string) *ReplaceServerAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace server accepted response -func (o *ReplaceServerAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace server accepted response -func (o *ReplaceServerAccepted) WithPayload(payload *models.Server) *ReplaceServerAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace server accepted response -func (o *ReplaceServerAccepted) SetPayload(payload *models.Server) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceServerAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceServerBadRequestCode is the HTTP code returned for type ReplaceServerBadRequest -const ReplaceServerBadRequestCode int = 400 - -/*ReplaceServerBadRequest Bad request - -swagger:response replaceServerBadRequest -*/ -type ReplaceServerBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceServerBadRequest creates ReplaceServerBadRequest with default headers values -func NewReplaceServerBadRequest() *ReplaceServerBadRequest { - - return &ReplaceServerBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace server bad request response -func (o *ReplaceServerBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceServerBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace server bad request response -func (o *ReplaceServerBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace server bad request response -func (o *ReplaceServerBadRequest) WithPayload(payload *models.Error) *ReplaceServerBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace server bad request response -func (o *ReplaceServerBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceServerBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceServerNotFoundCode is the HTTP code returned for type ReplaceServerNotFound -const ReplaceServerNotFoundCode int = 404 - -/*ReplaceServerNotFound The specified resource was not found - -swagger:response replaceServerNotFound -*/ -type ReplaceServerNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceServerNotFound creates ReplaceServerNotFound with default headers values -func NewReplaceServerNotFound() *ReplaceServerNotFound { - - return &ReplaceServerNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace server not found response -func (o *ReplaceServerNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceServerNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace server not found response -func (o *ReplaceServerNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace server not found response -func (o *ReplaceServerNotFound) WithPayload(payload *models.Error) *ReplaceServerNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace server not found response -func (o *ReplaceServerNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceServerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceServerDefault General Error - -swagger:response replaceServerDefault -*/ -type ReplaceServerDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceServerDefault creates ReplaceServerDefault with default headers values -func NewReplaceServerDefault(code int) *ReplaceServerDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceServerDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace server default response -func (o *ReplaceServerDefault) WithStatusCode(code int) *ReplaceServerDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace server default response -func (o *ReplaceServerDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace server default response -func (o *ReplaceServerDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceServerDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace server default response -func (o *ReplaceServerDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace server default response -func (o *ReplaceServerDefault) WithPayload(payload *models.Error) *ReplaceServerDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace server default response -func (o *ReplaceServerDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceServerDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/server/replace_server_ring.go b/operations/server/replace_server_ring.go new file mode 100644 index 00000000..3b9055a2 --- /dev/null +++ b/operations/server/replace_server_ring.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceServerRingHandlerFunc turns a function with the right signature into a replace server ring handler +type ReplaceServerRingHandlerFunc func(ReplaceServerRingParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceServerRingHandlerFunc) Handle(params ReplaceServerRingParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceServerRingHandler interface for that can handle valid replace server ring params +type ReplaceServerRingHandler interface { + Handle(ReplaceServerRingParams, interface{}) middleware.Responder +} + +// NewReplaceServerRing creates a new http.Handler for the replace server ring operation +func NewReplaceServerRing(ctx *middleware.Context, handler ReplaceServerRingHandler) *ReplaceServerRing { + return &ReplaceServerRing{Context: ctx, Handler: handler} +} + +/* + ReplaceServerRing swagger:route PUT /services/haproxy/configuration/rings/{parent_name}/servers/{name} Server replaceServerRing + +# Replace a server + +Replaces a server configuration by it's name in the specified backend. +*/ +type ReplaceServerRing struct { + Context *middleware.Context + Handler ReplaceServerRingHandler +} + +func (o *ReplaceServerRing) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceServerRingParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server/replace_server_ring_parameters.go b/operations/server/replace_server_ring_parameters.go new file mode 100644 index 00000000..542aa0fc --- /dev/null +++ b/operations/server/replace_server_ring_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceServerRingParams creates a new ReplaceServerRingParams object +// with the default values initialized. +func NewReplaceServerRingParams() ReplaceServerRingParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceServerRingParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceServerRingParams contains all the bound params for the replace server ring operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceServerRing +type ReplaceServerRingParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Server + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Server name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceServerRingParams() beforehand. +func (o *ReplaceServerRingParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Server + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceServerRingParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceServerRingParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceServerRingParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceServerRingParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceServerRingParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceServerRingParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server/replace_server_ring_responses.go b/operations/server/replace_server_ring_responses.go new file mode 100644 index 00000000..420a9c61 --- /dev/null +++ b/operations/server/replace_server_ring_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceServerRingOKCode is the HTTP code returned for type ReplaceServerRingOK +const ReplaceServerRingOKCode int = 200 + +/* +ReplaceServerRingOK Server replaced + +swagger:response replaceServerRingOK +*/ +type ReplaceServerRingOK struct { + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewReplaceServerRingOK creates ReplaceServerRingOK with default headers values +func NewReplaceServerRingOK() *ReplaceServerRingOK { + + return &ReplaceServerRingOK{} +} + +// WithPayload adds the payload to the replace server ring o k response +func (o *ReplaceServerRingOK) WithPayload(payload *models.Server) *ReplaceServerRingOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server ring o k response +func (o *ReplaceServerRingOK) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerRingOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerRingAcceptedCode is the HTTP code returned for type ReplaceServerRingAccepted +const ReplaceServerRingAcceptedCode int = 202 + +/* +ReplaceServerRingAccepted Configuration change accepted and reload requested + +swagger:response replaceServerRingAccepted +*/ +type ReplaceServerRingAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Server `json:"body,omitempty"` +} + +// NewReplaceServerRingAccepted creates ReplaceServerRingAccepted with default headers values +func NewReplaceServerRingAccepted() *ReplaceServerRingAccepted { + + return &ReplaceServerRingAccepted{} +} + +// WithReloadID adds the reloadId to the replace server ring accepted response +func (o *ReplaceServerRingAccepted) WithReloadID(reloadID string) *ReplaceServerRingAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace server ring accepted response +func (o *ReplaceServerRingAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace server ring accepted response +func (o *ReplaceServerRingAccepted) WithPayload(payload *models.Server) *ReplaceServerRingAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server ring accepted response +func (o *ReplaceServerRingAccepted) SetPayload(payload *models.Server) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerRingAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerRingBadRequestCode is the HTTP code returned for type ReplaceServerRingBadRequest +const ReplaceServerRingBadRequestCode int = 400 + +/* +ReplaceServerRingBadRequest Bad request + +swagger:response replaceServerRingBadRequest +*/ +type ReplaceServerRingBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerRingBadRequest creates ReplaceServerRingBadRequest with default headers values +func NewReplaceServerRingBadRequest() *ReplaceServerRingBadRequest { + + return &ReplaceServerRingBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server ring bad request response +func (o *ReplaceServerRingBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceServerRingBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server ring bad request response +func (o *ReplaceServerRingBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server ring bad request response +func (o *ReplaceServerRingBadRequest) WithPayload(payload *models.Error) *ReplaceServerRingBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server ring bad request response +func (o *ReplaceServerRingBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerRingBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerRingNotFoundCode is the HTTP code returned for type ReplaceServerRingNotFound +const ReplaceServerRingNotFoundCode int = 404 + +/* +ReplaceServerRingNotFound The specified resource was not found + +swagger:response replaceServerRingNotFound +*/ +type ReplaceServerRingNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerRingNotFound creates ReplaceServerRingNotFound with default headers values +func NewReplaceServerRingNotFound() *ReplaceServerRingNotFound { + + return &ReplaceServerRingNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server ring not found response +func (o *ReplaceServerRingNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceServerRingNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server ring not found response +func (o *ReplaceServerRingNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server ring not found response +func (o *ReplaceServerRingNotFound) WithPayload(payload *models.Error) *ReplaceServerRingNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server ring not found response +func (o *ReplaceServerRingNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerRingNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceServerRingDefault General Error + +swagger:response replaceServerRingDefault +*/ +type ReplaceServerRingDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerRingDefault creates ReplaceServerRingDefault with default headers values +func NewReplaceServerRingDefault(code int) *ReplaceServerRingDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceServerRingDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace server ring default response +func (o *ReplaceServerRingDefault) WithStatusCode(code int) *ReplaceServerRingDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace server ring default response +func (o *ReplaceServerRingDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace server ring default response +func (o *ReplaceServerRingDefault) WithConfigurationVersion(configurationVersion string) *ReplaceServerRingDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server ring default response +func (o *ReplaceServerRingDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server ring default response +func (o *ReplaceServerRingDefault) WithPayload(payload *models.Error) *ReplaceServerRingDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server ring default response +func (o *ReplaceServerRingDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerRingDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server/replace_server_ring_urlbuilder.go b/operations/server/replace_server_ring_urlbuilder.go new file mode 100644 index 00000000..edc27772 --- /dev/null +++ b/operations/server/replace_server_ring_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceServerRingURL generates an URL for the replace server ring operation +type ReplaceServerRingURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerRingURL) WithBasePath(bp string) *ReplaceServerRingURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerRingURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceServerRingURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/rings/{parent_name}/servers/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceServerRingURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceServerRingURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceServerRingURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceServerRingURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceServerRingURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceServerRingURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceServerRingURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceServerRingURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server/replace_server_urlbuilder.go b/operations/server/replace_server_urlbuilder.go deleted file mode 100644 index f2d9ab6a..00000000 --- a/operations/server/replace_server_urlbuilder.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package server - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceServerURL generates an URL for the replace server operation -type ReplaceServerURL struct { - Name string - - Backend string - ForceReload *bool - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceServerURL) WithBasePath(bp string) *ReplaceServerURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceServerURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceServerURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/servers/{name}" - - name := o.Name - if name != "" { - _path = strings.Replace(_path, "{name}", name, -1) - } else { - return nil, errors.New("name is required on ReplaceServerURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceServerURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceServerURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceServerURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceServerURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceServerURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceServerURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/server_switching_rule/create_server_switching_rule.go b/operations/server_switching_rule/create_server_switching_rule.go index f8d76db9..34c56405 100644 --- a/operations/server_switching_rule/create_server_switching_rule.go +++ b/operations/server_switching_rule/create_server_switching_rule.go @@ -23,7 +23,7 @@ package server_switching_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // CreateServerSwitchingRuleHandlerFunc turns a function with the right signature into a create server switching rule handler @@ -44,12 +44,12 @@ func NewCreateServerSwitchingRule(ctx *middleware.Context, handler CreateServerS return &CreateServerSwitchingRule{Context: ctx, Handler: handler} } -/*CreateServerSwitchingRule swagger:route POST /services/haproxy/configuration/server_switching_rules ServerSwitchingRule createServerSwitchingRule +/* + CreateServerSwitchingRule swagger:route POST /services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index} ServerSwitchingRule createServerSwitchingRule -Add a new Server Switching Rule +# Add a new Server Switching Rule Adds a new Server Switching Rule of the specified type in the specified backend. - */ type CreateServerSwitchingRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type CreateServerSwitchingRule struct { func (o *CreateServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewCreateServerSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *CreateServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Re } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/server_switching_rule/create_server_switching_rule_parameters.go b/operations/server_switching_rule/create_server_switching_rule_parameters.go index 2123f51e..d9db693a 100644 --- a/operations/server_switching_rule/create_server_switching_rule_parameters.go +++ b/operations/server_switching_rule/create_server_switching_rule_parameters.go @@ -27,12 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewCreateServerSwitchingRuleParams creates a new CreateServerSwitchingRuleParams object @@ -59,11 +57,6 @@ type CreateServerSwitchingRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name - Required: true - In: query - */ - Backend string /* Required: true In: body @@ -74,6 +67,16 @@ type CreateServerSwitchingRuleParams struct { Default: false */ ForceReload *bool + /*Switching Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -95,17 +98,12 @@ func (o *CreateServerSwitchingRuleParams) BindRequest(r *http.Request, route *mi qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - if runtime.HasBody(r) { defer r.Body.Close() var body models.ServerSwitchingRule if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -120,13 +118,24 @@ func (o *CreateServerSwitchingRuleParams) BindRequest(r *http.Request, route *mi } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) @@ -136,53 +145,65 @@ func (o *CreateServerSwitchingRuleParams) BindRequest(r *http.Request, route *mi if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *CreateServerSwitchingRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateServerSwitchingRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } - // Required: true + // Required: false // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateServerSwitchingRuleParams() + return nil } - o.Backend = raw + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value return nil } -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateServerSwitchingRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindIndex binds and validates parameter Index from path. +func (o *CreateServerSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateServerSwitchingRuleParams() - return nil - } + // Required: true + // Parameter is provided by construction from the route - value, err := swag.ConvertBool(raw) + value, err := swag.ConvertInt64(raw) if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) + return errors.InvalidType("index", "path", "int64", raw) } - o.ForceReload = &value + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateServerSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -196,10 +217,10 @@ func (o *CreateServerSwitchingRuleParams) bindTransactionID(rawData []string, ha // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -214,6 +235,7 @@ func (o *CreateServerSwitchingRuleParams) bindVersion(rawData []string, hasKey b // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/server_switching_rule/create_server_switching_rule_responses.go b/operations/server_switching_rule/create_server_switching_rule_responses.go index d8e7573c..7a8a879b 100644 --- a/operations/server_switching_rule/create_server_switching_rule_responses.go +++ b/operations/server_switching_rule/create_server_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // CreateServerSwitchingRuleCreatedCode is the HTTP code returned for type CreateServerSwitchingRuleCreated const CreateServerSwitchingRuleCreatedCode int = 201 -/*CreateServerSwitchingRuleCreated Server Switching Rule created +/* +CreateServerSwitchingRuleCreated Server Switching Rule created swagger:response createServerSwitchingRuleCreated */ @@ -76,7 +76,8 @@ func (o *CreateServerSwitchingRuleCreated) WriteResponse(rw http.ResponseWriter, // CreateServerSwitchingRuleAcceptedCode is the HTTP code returned for type CreateServerSwitchingRuleAccepted const CreateServerSwitchingRuleAcceptedCode int = 202 -/*CreateServerSwitchingRuleAccepted Configuration change accepted and reload requested +/* +CreateServerSwitchingRuleAccepted Configuration change accepted and reload requested swagger:response createServerSwitchingRuleAccepted */ @@ -142,7 +143,8 @@ func (o *CreateServerSwitchingRuleAccepted) WriteResponse(rw http.ResponseWriter // CreateServerSwitchingRuleBadRequestCode is the HTTP code returned for type CreateServerSwitchingRuleBadRequest const CreateServerSwitchingRuleBadRequestCode int = 400 -/*CreateServerSwitchingRuleBadRequest Bad request +/* +CreateServerSwitchingRuleBadRequest Bad request swagger:response createServerSwitchingRuleBadRequest */ @@ -150,7 +152,7 @@ type CreateServerSwitchingRuleBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewCreateServerSwitchingRuleBadRequest() *CreateServerSwitchingRuleBadReque } // WithConfigurationVersion adds the configurationVersion to the create server switching rule bad request response -func (o *CreateServerSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateServerSwitchingRuleBadRequest { +func (o *CreateServerSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion string) *CreateServerSwitchingRuleBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create server switching rule bad request response -func (o *CreateServerSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateServerSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *CreateServerSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWrit // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *CreateServerSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWrit // CreateServerSwitchingRuleConflictCode is the HTTP code returned for type CreateServerSwitchingRuleConflict const CreateServerSwitchingRuleConflictCode int = 409 -/*CreateServerSwitchingRuleConflict The specified resource already exists +/* +CreateServerSwitchingRuleConflict The specified resource already exists swagger:response createServerSwitchingRuleConflict */ @@ -216,7 +219,7 @@ type CreateServerSwitchingRuleConflict struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewCreateServerSwitchingRuleConflict() *CreateServerSwitchingRuleConflict { } // WithConfigurationVersion adds the configurationVersion to the create server switching rule conflict response -func (o *CreateServerSwitchingRuleConflict) WithConfigurationVersion(configurationVersion int64) *CreateServerSwitchingRuleConflict { +func (o *CreateServerSwitchingRuleConflict) WithConfigurationVersion(configurationVersion string) *CreateServerSwitchingRuleConflict { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create server switching rule conflict response -func (o *CreateServerSwitchingRuleConflict) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateServerSwitchingRuleConflict) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *CreateServerSwitchingRuleConflict) WriteResponse(rw http.ResponseWriter // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *CreateServerSwitchingRuleConflict) WriteResponse(rw http.ResponseWriter } } -/*CreateServerSwitchingRuleDefault General Error +/* +CreateServerSwitchingRuleDefault General Error swagger:response createServerSwitchingRuleDefault */ @@ -280,7 +284,7 @@ type CreateServerSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *CreateServerSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the create server switching rule default response -func (o *CreateServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *CreateServerSwitchingRuleDefault { +func (o *CreateServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *CreateServerSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create server switching rule default response -func (o *CreateServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *CreateServerSwitchingRuleDefault) WriteResponse(rw http.ResponseWriter, // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/server_switching_rule/create_server_switching_rule_urlbuilder.go b/operations/server_switching_rule/create_server_switching_rule_urlbuilder.go index 07fa3b90..99afacfc 100644 --- a/operations/server_switching_rule/create_server_switching_rule_urlbuilder.go +++ b/operations/server_switching_rule/create_server_switching_rule_urlbuilder.go @@ -24,13 +24,16 @@ import ( "errors" "net/url" golangswaggerpaths "path" + "strings" "github.com/go-openapi/swag" ) // CreateServerSwitchingRuleURL generates an URL for the create server switching rule operation type CreateServerSwitchingRuleURL struct { - Backend string + Index int64 + ParentName string + ForceReload *bool TransactionID *string Version *int64 @@ -59,43 +62,52 @@ func (o *CreateServerSwitchingRuleURL) SetBasePath(bp string) { func (o *CreateServerSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/server_switching_rules" + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateServerSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateServerSwitchingRuleURL") + } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/server_switching_rule/delete_server_switching_rule.go b/operations/server_switching_rule/delete_server_switching_rule.go index 34fae60c..bb31f4c3 100644 --- a/operations/server_switching_rule/delete_server_switching_rule.go +++ b/operations/server_switching_rule/delete_server_switching_rule.go @@ -23,7 +23,7 @@ package server_switching_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // DeleteServerSwitchingRuleHandlerFunc turns a function with the right signature into a delete server switching rule handler @@ -44,12 +44,12 @@ func NewDeleteServerSwitchingRule(ctx *middleware.Context, handler DeleteServerS return &DeleteServerSwitchingRule{Context: ctx, Handler: handler} } -/*DeleteServerSwitchingRule swagger:route DELETE /services/haproxy/configuration/server_switching_rules/{id} ServerSwitchingRule deleteServerSwitchingRule +/* + DeleteServerSwitchingRule swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index} ServerSwitchingRule deleteServerSwitchingRule -Delete a Server Switching Rule - -Deletes a Server Switching Rule configuration by it's ID from the specified backend. +# Delete a Server Switching Rule +Deletes a Server Switching Rule configuration by it's index from the specified backend. */ type DeleteServerSwitchingRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type DeleteServerSwitchingRule struct { func (o *DeleteServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewDeleteServerSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *DeleteServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Re } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/server_switching_rule/delete_server_switching_rule_parameters.go b/operations/server_switching_rule/delete_server_switching_rule_parameters.go index 1f587d7f..9524aabf 100644 --- a/operations/server_switching_rule/delete_server_switching_rule_parameters.go +++ b/operations/server_switching_rule/delete_server_switching_rule_parameters.go @@ -26,10 +26,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewDeleteServerSwitchingRuleParams creates a new DeleteServerSwitchingRuleParams object @@ -56,21 +54,21 @@ type DeleteServerSwitchingRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name - Required: true - In: query - */ - Backend string /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. In: query Default: false */ ForceReload *bool - /*Switching Rule ID + /*Switching Rule Index Required: true In: path */ - ID int64 + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -92,18 +90,18 @@ func (o *DeleteServerSwitchingRuleParams) BindRequest(r *http.Request, route *mi qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -116,34 +114,12 @@ func (o *DeleteServerSwitchingRuleParams) BindRequest(r *http.Request, route *mi if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *DeleteServerSwitchingRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - // bindForceReload binds and validates parameter ForceReload from query. func (o *DeleteServerSwitchingRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -153,6 +129,7 @@ func (o *DeleteServerSwitchingRuleParams) bindForceReload(rawData []string, hasK // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewDeleteServerSwitchingRuleParams() return nil @@ -167,8 +144,8 @@ func (o *DeleteServerSwitchingRuleParams) bindForceReload(rawData []string, hasK return nil } -// bindID binds and validates parameter ID from path. -func (o *DeleteServerSwitchingRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindIndex binds and validates parameter Index from path. +func (o *DeleteServerSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -179,9 +156,23 @@ func (o *DeleteServerSwitchingRuleParams) bindID(rawData []string, hasKey bool, value, err := swag.ConvertInt64(raw) if err != nil { - return errors.InvalidType("id", "path", "int64", raw) + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteServerSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] } - o.ID = value + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -195,10 +186,10 @@ func (o *DeleteServerSwitchingRuleParams) bindTransactionID(rawData []string, ha // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -213,6 +204,7 @@ func (o *DeleteServerSwitchingRuleParams) bindVersion(rawData []string, hasKey b // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/server_switching_rule/delete_server_switching_rule_responses.go b/operations/server_switching_rule/delete_server_switching_rule_responses.go index 4f86720b..23fd47af 100644 --- a/operations/server_switching_rule/delete_server_switching_rule_responses.go +++ b/operations/server_switching_rule/delete_server_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // DeleteServerSwitchingRuleAcceptedCode is the HTTP code returned for type DeleteServerSwitchingRuleAccepted const DeleteServerSwitchingRuleAcceptedCode int = 202 -/*DeleteServerSwitchingRuleAccepted Configuration change accepted and reload requested +/* +DeleteServerSwitchingRuleAccepted Configuration change accepted and reload requested swagger:response deleteServerSwitchingRuleAccepted */ @@ -78,7 +78,8 @@ func (o *DeleteServerSwitchingRuleAccepted) WriteResponse(rw http.ResponseWriter // DeleteServerSwitchingRuleNoContentCode is the HTTP code returned for type DeleteServerSwitchingRuleNoContent const DeleteServerSwitchingRuleNoContentCode int = 204 -/*DeleteServerSwitchingRuleNoContent Server Switching Rule deleted +/* +DeleteServerSwitchingRuleNoContent Server Switching Rule deleted swagger:response deleteServerSwitchingRuleNoContent */ @@ -102,7 +103,8 @@ func (o *DeleteServerSwitchingRuleNoContent) WriteResponse(rw http.ResponseWrite // DeleteServerSwitchingRuleNotFoundCode is the HTTP code returned for type DeleteServerSwitchingRuleNotFound const DeleteServerSwitchingRuleNotFoundCode int = 404 -/*DeleteServerSwitchingRuleNotFound The specified resource was not found +/* +DeleteServerSwitchingRuleNotFound The specified resource was not found swagger:response deleteServerSwitchingRuleNotFound */ @@ -110,7 +112,7 @@ type DeleteServerSwitchingRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -125,13 +127,13 @@ func NewDeleteServerSwitchingRuleNotFound() *DeleteServerSwitchingRuleNotFound { } // WithConfigurationVersion adds the configurationVersion to the delete server switching rule not found response -func (o *DeleteServerSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteServerSwitchingRuleNotFound { +func (o *DeleteServerSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion string) *DeleteServerSwitchingRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete server switching rule not found response -func (o *DeleteServerSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteServerSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -151,7 +153,7 @@ func (o *DeleteServerSwitchingRuleNotFound) WriteResponse(rw http.ResponseWriter // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -165,7 +167,8 @@ func (o *DeleteServerSwitchingRuleNotFound) WriteResponse(rw http.ResponseWriter } } -/*DeleteServerSwitchingRuleDefault General Error +/* +DeleteServerSwitchingRuleDefault General Error swagger:response deleteServerSwitchingRuleDefault */ @@ -174,7 +177,7 @@ type DeleteServerSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -205,13 +208,13 @@ func (o *DeleteServerSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the delete server switching rule default response -func (o *DeleteServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *DeleteServerSwitchingRuleDefault { +func (o *DeleteServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *DeleteServerSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete server switching rule default response -func (o *DeleteServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -231,7 +234,7 @@ func (o *DeleteServerSwitchingRuleDefault) WriteResponse(rw http.ResponseWriter, // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/server_switching_rule/delete_server_switching_rule_urlbuilder.go b/operations/server_switching_rule/delete_server_switching_rule_urlbuilder.go index de064ffd..f8bf3f7c 100644 --- a/operations/server_switching_rule/delete_server_switching_rule_urlbuilder.go +++ b/operations/server_switching_rule/delete_server_switching_rule_urlbuilder.go @@ -31,9 +31,9 @@ import ( // DeleteServerSwitchingRuleURL generates an URL for the delete server switching rule operation type DeleteServerSwitchingRuleURL struct { - ID int64 + Index int64 + ParentName string - Backend string ForceReload *bool TransactionID *string Version *int64 @@ -62,50 +62,52 @@ func (o *DeleteServerSwitchingRuleURL) SetBasePath(bp string) { func (o *DeleteServerSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/server_switching_rules/{id}" + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on DeleteServerSwitchingRuleURL") + return nil, errors.New("index is required on DeleteServerSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteServerSwitchingRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/server_switching_rule/get_server_switching_rule.go b/operations/server_switching_rule/get_server_switching_rule.go index 65f5e7e9..80f407b4 100644 --- a/operations/server_switching_rule/get_server_switching_rule.go +++ b/operations/server_switching_rule/get_server_switching_rule.go @@ -23,12 +23,7 @@ package server_switching_rule import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetServerSwitchingRuleHandlerFunc turns a function with the right signature into a get server switching rule handler @@ -49,12 +44,12 @@ func NewGetServerSwitchingRule(ctx *middleware.Context, handler GetServerSwitchi return &GetServerSwitchingRule{Context: ctx, Handler: handler} } -/*GetServerSwitchingRule swagger:route GET /services/haproxy/configuration/server_switching_rules/{id} ServerSwitchingRule getServerSwitchingRule - -Return one Server Switching Rule +/* + GetServerSwitchingRule swagger:route GET /services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index} ServerSwitchingRule getServerSwitchingRule -Returns one Server Switching Rule configuration by it's ID in the specified backend. +# Return one Server Switching Rule +Returns one Server Switching Rule configuration by it's index in the specified backend. */ type GetServerSwitchingRule struct { Context *middleware.Context @@ -64,21 +59,20 @@ type GetServerSwitchingRule struct { func (o *GetServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetServerSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -87,68 +81,6 @@ func (o *GetServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Reque } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetServerSwitchingRuleOKBody get server switching rule o k body -// swagger:model GetServerSwitchingRuleOKBody -type GetServerSwitchingRuleOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.ServerSwitchingRule `json:"data,omitempty"` -} - -// Validate validates this get server switching rule o k body -func (o *GetServerSwitchingRuleOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetServerSwitchingRuleOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getServerSwitchingRuleOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetServerSwitchingRuleOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetServerSwitchingRuleOKBody) UnmarshalBinary(b []byte) error { - var res GetServerSwitchingRuleOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/server_switching_rule/get_server_switching_rule_parameters.go b/operations/server_switching_rule/get_server_switching_rule_parameters.go index a3319d1a..b2060b50 100644 --- a/operations/server_switching_rule/get_server_switching_rule_parameters.go +++ b/operations/server_switching_rule/get_server_switching_rule_parameters.go @@ -26,14 +26,13 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewGetServerSwitchingRuleParams creates a new GetServerSwitchingRuleParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetServerSwitchingRuleParams() GetServerSwitchingRuleParams { return GetServerSwitchingRuleParams{} @@ -48,16 +47,16 @@ type GetServerSwitchingRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name + /*Switching Rule Index Required: true - In: query + In: path */ - Backend string - /*Switching Rule ID + Index int64 + /*Parent name Required: true In: path */ - ID int64 + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -75,13 +74,13 @@ func (o *GetServerSwitchingRuleParams) BindRequest(r *http.Request, route *middl qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -89,36 +88,33 @@ func (o *GetServerSwitchingRuleParams) BindRequest(r *http.Request, route *middl if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *GetServerSwitchingRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } +// bindIndex binds and validates parameter Index from path. +func (o *GetServerSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } + // Parameter is provided by construction from the route - o.Backend = raw + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value return nil } -// bindID binds and validates parameter ID from path. -func (o *GetServerSwitchingRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServerSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -126,12 +122,7 @@ func (o *GetServerSwitchingRuleParams) bindID(rawData []string, hasKey bool, for // Required: true // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value + o.ParentName = raw return nil } @@ -145,10 +136,10 @@ func (o *GetServerSwitchingRuleParams) bindTransactionID(rawData []string, hasKe // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/server_switching_rule/get_server_switching_rule_responses.go b/operations/server_switching_rule/get_server_switching_rule_responses.go index 40e32e95..ec4dbfc1 100644 --- a/operations/server_switching_rule/get_server_switching_rule_responses.go +++ b/operations/server_switching_rule/get_server_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetServerSwitchingRuleOKCode is the HTTP code returned for type GetServerSwitchingRuleOK const GetServerSwitchingRuleOKCode int = 200 -/*GetServerSwitchingRuleOK Successful operation +/* +GetServerSwitchingRuleOK Successful operation swagger:response getServerSwitchingRuleOK */ @@ -40,12 +40,12 @@ type GetServerSwitchingRuleOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetServerSwitchingRuleOKBody `json:"body,omitempty"` + Payload *models.ServerSwitchingRule `json:"body,omitempty"` } // NewGetServerSwitchingRuleOK creates GetServerSwitchingRuleOK with default headers values @@ -55,24 +55,24 @@ func NewGetServerSwitchingRuleOK() *GetServerSwitchingRuleOK { } // WithConfigurationVersion adds the configurationVersion to the get server switching rule o k response -func (o *GetServerSwitchingRuleOK) WithConfigurationVersion(configurationVersion int64) *GetServerSwitchingRuleOK { +func (o *GetServerSwitchingRuleOK) WithConfigurationVersion(configurationVersion string) *GetServerSwitchingRuleOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get server switching rule o k response -func (o *GetServerSwitchingRuleOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetServerSwitchingRuleOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get server switching rule o k response -func (o *GetServerSwitchingRuleOK) WithPayload(payload *GetServerSwitchingRuleOKBody) *GetServerSwitchingRuleOK { +func (o *GetServerSwitchingRuleOK) WithPayload(payload *models.ServerSwitchingRule) *GetServerSwitchingRuleOK { o.Payload = payload return o } // SetPayload sets the payload to the get server switching rule o k response -func (o *GetServerSwitchingRuleOK) SetPayload(payload *GetServerSwitchingRuleOKBody) { +func (o *GetServerSwitchingRuleOK) SetPayload(payload *models.ServerSwitchingRule) { o.Payload = payload } @@ -81,7 +81,7 @@ func (o *GetServerSwitchingRuleOK) WriteResponse(rw http.ResponseWriter, produce // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -98,7 +98,8 @@ func (o *GetServerSwitchingRuleOK) WriteResponse(rw http.ResponseWriter, produce // GetServerSwitchingRuleNotFoundCode is the HTTP code returned for type GetServerSwitchingRuleNotFound const GetServerSwitchingRuleNotFoundCode int = 404 -/*GetServerSwitchingRuleNotFound The specified resource was not found +/* +GetServerSwitchingRuleNotFound The specified resource was not found swagger:response getServerSwitchingRuleNotFound */ @@ -106,7 +107,7 @@ type GetServerSwitchingRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -121,13 +122,13 @@ func NewGetServerSwitchingRuleNotFound() *GetServerSwitchingRuleNotFound { } // WithConfigurationVersion adds the configurationVersion to the get server switching rule not found response -func (o *GetServerSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion int64) *GetServerSwitchingRuleNotFound { +func (o *GetServerSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion string) *GetServerSwitchingRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get server switching rule not found response -func (o *GetServerSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetServerSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -147,7 +148,7 @@ func (o *GetServerSwitchingRuleNotFound) WriteResponse(rw http.ResponseWriter, p // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -161,7 +162,8 @@ func (o *GetServerSwitchingRuleNotFound) WriteResponse(rw http.ResponseWriter, p } } -/*GetServerSwitchingRuleDefault General Error +/* +GetServerSwitchingRuleDefault General Error swagger:response getServerSwitchingRuleDefault */ @@ -170,7 +172,7 @@ type GetServerSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -201,13 +203,13 @@ func (o *GetServerSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get server switching rule default response -func (o *GetServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *GetServerSwitchingRuleDefault { +func (o *GetServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *GetServerSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get server switching rule default response -func (o *GetServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -227,7 +229,7 @@ func (o *GetServerSwitchingRuleDefault) WriteResponse(rw http.ResponseWriter, pr // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/server_switching_rule/get_server_switching_rule_urlbuilder.go b/operations/server_switching_rule/get_server_switching_rule_urlbuilder.go index ebb1671d..fac69270 100644 --- a/operations/server_switching_rule/get_server_switching_rule_urlbuilder.go +++ b/operations/server_switching_rule/get_server_switching_rule_urlbuilder.go @@ -31,9 +31,9 @@ import ( // GetServerSwitchingRuleURL generates an URL for the get server switching rule operation type GetServerSwitchingRuleURL struct { - ID int64 + Index int64 + ParentName string - Backend string TransactionID *string _basePath string @@ -60,34 +60,36 @@ func (o *GetServerSwitchingRuleURL) SetBasePath(bp string) { func (o *GetServerSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/server_switching_rules/{id}" + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on GetServerSwitchingRuleURL") + return nil, errors.New("index is required on GetServerSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServerSwitchingRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/server_switching_rule/get_server_switching_rules.go b/operations/server_switching_rule/get_server_switching_rules.go index f3ad40e1..c0ac5106 100644 --- a/operations/server_switching_rule/get_server_switching_rules.go +++ b/operations/server_switching_rule/get_server_switching_rules.go @@ -23,13 +23,7 @@ package server_switching_rule import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetServerSwitchingRulesHandlerFunc turns a function with the right signature into a get server switching rules handler @@ -50,12 +44,12 @@ func NewGetServerSwitchingRules(ctx *middleware.Context, handler GetServerSwitch return &GetServerSwitchingRules{Context: ctx, Handler: handler} } -/*GetServerSwitchingRules swagger:route GET /services/haproxy/configuration/server_switching_rules ServerSwitchingRule getServerSwitchingRules +/* + GetServerSwitchingRules swagger:route GET /services/haproxy/configuration/backends/{parent_name}/server_switching_rules ServerSwitchingRule getServerSwitchingRules -Return an array of all Server Switching Rules +# Return an array of all Server Switching Rules Returns all Backend Switching Rules that are configured in specified backend. - */ type GetServerSwitchingRules struct { Context *middleware.Context @@ -65,21 +59,20 @@ type GetServerSwitchingRules struct { func (o *GetServerSwitchingRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetServerSwitchingRulesParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -88,67 +81,6 @@ func (o *GetServerSwitchingRules) ServeHTTP(rw http.ResponseWriter, r *http.Requ } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetServerSwitchingRulesOKBody get server switching rules o k body -// swagger:model GetServerSwitchingRulesOKBody -type GetServerSwitchingRulesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.ServerSwitchingRules `json:"data"` -} - -// Validate validates this get server switching rules o k body -func (o *GetServerSwitchingRulesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetServerSwitchingRulesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getServerSwitchingRulesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getServerSwitchingRulesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetServerSwitchingRulesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetServerSwitchingRulesOKBody) UnmarshalBinary(b []byte) error { - var res GetServerSwitchingRulesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/server_switching_rule/get_server_switching_rules_parameters.go b/operations/server_switching_rule/get_server_switching_rules_parameters.go index 12f82213..b5ef8ec4 100644 --- a/operations/server_switching_rule/get_server_switching_rules_parameters.go +++ b/operations/server_switching_rule/get_server_switching_rules_parameters.go @@ -26,13 +26,12 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewGetServerSwitchingRulesParams creates a new GetServerSwitchingRulesParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetServerSwitchingRulesParams() GetServerSwitchingRulesParams { return GetServerSwitchingRulesParams{} @@ -47,11 +46,11 @@ type GetServerSwitchingRulesParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name + /*Parent name Required: true - In: query + In: path */ - Backend string + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -69,8 +68,8 @@ func (o *GetServerSwitchingRulesParams) BindRequest(r *http.Request, route *midd qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -78,30 +77,22 @@ func (o *GetServerSwitchingRulesParams) BindRequest(r *http.Request, route *midd if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *GetServerSwitchingRulesParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServerSwitchingRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -115,10 +106,10 @@ func (o *GetServerSwitchingRulesParams) bindTransactionID(rawData []string, hasK // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/server_switching_rule/get_server_switching_rules_responses.go b/operations/server_switching_rule/get_server_switching_rules_responses.go index e739fc8f..7b654c3a 100644 --- a/operations/server_switching_rule/get_server_switching_rules_responses.go +++ b/operations/server_switching_rule/get_server_switching_rules_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetServerSwitchingRulesOKCode is the HTTP code returned for type GetServerSwitchingRulesOK const GetServerSwitchingRulesOKCode int = 200 -/*GetServerSwitchingRulesOK Successful operation +/* +GetServerSwitchingRulesOK Successful operation swagger:response getServerSwitchingRulesOK */ @@ -40,12 +40,12 @@ type GetServerSwitchingRulesOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetServerSwitchingRulesOKBody `json:"body,omitempty"` + Payload models.ServerSwitchingRules `json:"body,omitempty"` } // NewGetServerSwitchingRulesOK creates GetServerSwitchingRulesOK with default headers values @@ -55,24 +55,24 @@ func NewGetServerSwitchingRulesOK() *GetServerSwitchingRulesOK { } // WithConfigurationVersion adds the configurationVersion to the get server switching rules o k response -func (o *GetServerSwitchingRulesOK) WithConfigurationVersion(configurationVersion int64) *GetServerSwitchingRulesOK { +func (o *GetServerSwitchingRulesOK) WithConfigurationVersion(configurationVersion string) *GetServerSwitchingRulesOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get server switching rules o k response -func (o *GetServerSwitchingRulesOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetServerSwitchingRulesOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get server switching rules o k response -func (o *GetServerSwitchingRulesOK) WithPayload(payload *GetServerSwitchingRulesOKBody) *GetServerSwitchingRulesOK { +func (o *GetServerSwitchingRulesOK) WithPayload(payload models.ServerSwitchingRules) *GetServerSwitchingRulesOK { o.Payload = payload return o } // SetPayload sets the payload to the get server switching rules o k response -func (o *GetServerSwitchingRulesOK) SetPayload(payload *GetServerSwitchingRulesOKBody) { +func (o *GetServerSwitchingRulesOK) SetPayload(payload models.ServerSwitchingRules) { o.Payload = payload } @@ -81,21 +81,25 @@ func (o *GetServerSwitchingRulesOK) WriteResponse(rw http.ResponseWriter, produc // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if payload == nil { + // return empty array + payload = models.ServerSwitchingRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*GetServerSwitchingRulesDefault General Error +/* +GetServerSwitchingRulesDefault General Error swagger:response getServerSwitchingRulesDefault */ @@ -104,7 +108,7 @@ type GetServerSwitchingRulesDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -135,13 +139,13 @@ func (o *GetServerSwitchingRulesDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get server switching rules default response -func (o *GetServerSwitchingRulesDefault) WithConfigurationVersion(configurationVersion int64) *GetServerSwitchingRulesDefault { +func (o *GetServerSwitchingRulesDefault) WithConfigurationVersion(configurationVersion string) *GetServerSwitchingRulesDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get server switching rules default response -func (o *GetServerSwitchingRulesDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetServerSwitchingRulesDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -161,7 +165,7 @@ func (o *GetServerSwitchingRulesDefault) WriteResponse(rw http.ResponseWriter, p // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/server_switching_rule/get_server_switching_rules_urlbuilder.go b/operations/server_switching_rule/get_server_switching_rules_urlbuilder.go index a08b7825..9f8f0ad9 100644 --- a/operations/server_switching_rule/get_server_switching_rules_urlbuilder.go +++ b/operations/server_switching_rule/get_server_switching_rules_urlbuilder.go @@ -24,11 +24,13 @@ import ( "errors" "net/url" golangswaggerpaths "path" + "strings" ) // GetServerSwitchingRulesURL generates an URL for the get server switching rules operation type GetServerSwitchingRulesURL struct { - Backend string + ParentName string + TransactionID *string _basePath string @@ -55,27 +57,29 @@ func (o *GetServerSwitchingRulesURL) SetBasePath(bp string) { func (o *GetServerSwitchingRulesURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/server_switching_rules" + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServerSwitchingRulesURL") + } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/server_switching_rule/replace_server_switching_rule.go b/operations/server_switching_rule/replace_server_switching_rule.go index 6e6247fe..2205ef3f 100644 --- a/operations/server_switching_rule/replace_server_switching_rule.go +++ b/operations/server_switching_rule/replace_server_switching_rule.go @@ -23,7 +23,7 @@ package server_switching_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // ReplaceServerSwitchingRuleHandlerFunc turns a function with the right signature into a replace server switching rule handler @@ -44,12 +44,12 @@ func NewReplaceServerSwitchingRule(ctx *middleware.Context, handler ReplaceServe return &ReplaceServerSwitchingRule{Context: ctx, Handler: handler} } -/*ReplaceServerSwitchingRule swagger:route PUT /services/haproxy/configuration/server_switching_rules/{id} ServerSwitchingRule replaceServerSwitchingRule +/* + ReplaceServerSwitchingRule swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index} ServerSwitchingRule replaceServerSwitchingRule -Replace a Server Switching Rule - -Replaces a Server Switching Rule configuration by it's ID in the specified backend. +# Replace a Server Switching Rule +Replaces a Server Switching Rule configuration by it's index in the specified backend. */ type ReplaceServerSwitchingRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type ReplaceServerSwitchingRule struct { func (o *ReplaceServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewReplaceServerSwitchingRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *ReplaceServerSwitchingRule) ServeHTTP(rw http.ResponseWriter, r *http.R } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/server_switching_rule/replace_server_switching_rule_parameters.go b/operations/server_switching_rule/replace_server_switching_rule_parameters.go index aa80587a..5b138025 100644 --- a/operations/server_switching_rule/replace_server_switching_rule_parameters.go +++ b/operations/server_switching_rule/replace_server_switching_rule_parameters.go @@ -27,12 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewReplaceServerSwitchingRuleParams creates a new ReplaceServerSwitchingRuleParams object @@ -59,11 +57,6 @@ type ReplaceServerSwitchingRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name - Required: true - In: query - */ - Backend string /* Required: true In: body @@ -74,11 +67,16 @@ type ReplaceServerSwitchingRuleParams struct { Default: false */ ForceReload *bool - /*Switching Rule ID + /*Switching Rule Index Required: true In: path */ - ID int64 + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -100,17 +98,12 @@ func (o *ReplaceServerSwitchingRuleParams) BindRequest(r *http.Request, route *m qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - if runtime.HasBody(r) { defer r.Body.Close() var body models.ServerSwitchingRule if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -125,15 +118,21 @@ func (o *ReplaceServerSwitchingRuleParams) BindRequest(r *http.Request, route *m } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -146,34 +145,12 @@ func (o *ReplaceServerSwitchingRuleParams) BindRequest(r *http.Request, route *m if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *ReplaceServerSwitchingRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - // bindForceReload binds and validates parameter ForceReload from query. func (o *ReplaceServerSwitchingRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -183,6 +160,7 @@ func (o *ReplaceServerSwitchingRuleParams) bindForceReload(rawData []string, has // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewReplaceServerSwitchingRuleParams() return nil @@ -197,8 +175,8 @@ func (o *ReplaceServerSwitchingRuleParams) bindForceReload(rawData []string, has return nil } -// bindID binds and validates parameter ID from path. -func (o *ReplaceServerSwitchingRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceServerSwitchingRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -209,9 +187,23 @@ func (o *ReplaceServerSwitchingRuleParams) bindID(rawData []string, hasKey bool, value, err := swag.ConvertInt64(raw) if err != nil { - return errors.InvalidType("id", "path", "int64", raw) + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceServerSwitchingRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] } - o.ID = value + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -225,10 +217,10 @@ func (o *ReplaceServerSwitchingRuleParams) bindTransactionID(rawData []string, h // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -243,6 +235,7 @@ func (o *ReplaceServerSwitchingRuleParams) bindVersion(rawData []string, hasKey // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/server_switching_rule/replace_server_switching_rule_responses.go b/operations/server_switching_rule/replace_server_switching_rule_responses.go index 240df482..e92b93bd 100644 --- a/operations/server_switching_rule/replace_server_switching_rule_responses.go +++ b/operations/server_switching_rule/replace_server_switching_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // ReplaceServerSwitchingRuleOKCode is the HTTP code returned for type ReplaceServerSwitchingRuleOK const ReplaceServerSwitchingRuleOKCode int = 200 -/*ReplaceServerSwitchingRuleOK Server Switching Rule replaced +/* +ReplaceServerSwitchingRuleOK Server Switching Rule replaced swagger:response replaceServerSwitchingRuleOK */ @@ -76,7 +76,8 @@ func (o *ReplaceServerSwitchingRuleOK) WriteResponse(rw http.ResponseWriter, pro // ReplaceServerSwitchingRuleAcceptedCode is the HTTP code returned for type ReplaceServerSwitchingRuleAccepted const ReplaceServerSwitchingRuleAcceptedCode int = 202 -/*ReplaceServerSwitchingRuleAccepted Configuration change accepted and reload requested +/* +ReplaceServerSwitchingRuleAccepted Configuration change accepted and reload requested swagger:response replaceServerSwitchingRuleAccepted */ @@ -142,7 +143,8 @@ func (o *ReplaceServerSwitchingRuleAccepted) WriteResponse(rw http.ResponseWrite // ReplaceServerSwitchingRuleBadRequestCode is the HTTP code returned for type ReplaceServerSwitchingRuleBadRequest const ReplaceServerSwitchingRuleBadRequestCode int = 400 -/*ReplaceServerSwitchingRuleBadRequest Bad request +/* +ReplaceServerSwitchingRuleBadRequest Bad request swagger:response replaceServerSwitchingRuleBadRequest */ @@ -150,7 +152,7 @@ type ReplaceServerSwitchingRuleBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewReplaceServerSwitchingRuleBadRequest() *ReplaceServerSwitchingRuleBadReq } // WithConfigurationVersion adds the configurationVersion to the replace server switching rule bad request response -func (o *ReplaceServerSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceServerSwitchingRuleBadRequest { +func (o *ReplaceServerSwitchingRuleBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceServerSwitchingRuleBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace server switching rule bad request response -func (o *ReplaceServerSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceServerSwitchingRuleBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *ReplaceServerSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWri // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *ReplaceServerSwitchingRuleBadRequest) WriteResponse(rw http.ResponseWri // ReplaceServerSwitchingRuleNotFoundCode is the HTTP code returned for type ReplaceServerSwitchingRuleNotFound const ReplaceServerSwitchingRuleNotFoundCode int = 404 -/*ReplaceServerSwitchingRuleNotFound The specified resource was not found +/* +ReplaceServerSwitchingRuleNotFound The specified resource was not found swagger:response replaceServerSwitchingRuleNotFound */ @@ -216,7 +219,7 @@ type ReplaceServerSwitchingRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewReplaceServerSwitchingRuleNotFound() *ReplaceServerSwitchingRuleNotFound } // WithConfigurationVersion adds the configurationVersion to the replace server switching rule not found response -func (o *ReplaceServerSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceServerSwitchingRuleNotFound { +func (o *ReplaceServerSwitchingRuleNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceServerSwitchingRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace server switching rule not found response -func (o *ReplaceServerSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceServerSwitchingRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *ReplaceServerSwitchingRuleNotFound) WriteResponse(rw http.ResponseWrite // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *ReplaceServerSwitchingRuleNotFound) WriteResponse(rw http.ResponseWrite } } -/*ReplaceServerSwitchingRuleDefault General Error +/* +ReplaceServerSwitchingRuleDefault General Error swagger:response replaceServerSwitchingRuleDefault */ @@ -280,7 +284,7 @@ type ReplaceServerSwitchingRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *ReplaceServerSwitchingRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the replace server switching rule default response -func (o *ReplaceServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceServerSwitchingRuleDefault { +func (o *ReplaceServerSwitchingRuleDefault) WithConfigurationVersion(configurationVersion string) *ReplaceServerSwitchingRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace server switching rule default response -func (o *ReplaceServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceServerSwitchingRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *ReplaceServerSwitchingRuleDefault) WriteResponse(rw http.ResponseWriter // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/server_switching_rule/replace_server_switching_rule_urlbuilder.go b/operations/server_switching_rule/replace_server_switching_rule_urlbuilder.go index 0f8d08c0..9c6357b3 100644 --- a/operations/server_switching_rule/replace_server_switching_rule_urlbuilder.go +++ b/operations/server_switching_rule/replace_server_switching_rule_urlbuilder.go @@ -31,9 +31,9 @@ import ( // ReplaceServerSwitchingRuleURL generates an URL for the replace server switching rule operation type ReplaceServerSwitchingRuleURL struct { - ID int64 + Index int64 + ParentName string - Backend string ForceReload *bool TransactionID *string Version *int64 @@ -62,50 +62,52 @@ func (o *ReplaceServerSwitchingRuleURL) SetBasePath(bp string) { func (o *ReplaceServerSwitchingRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/server_switching_rules/{id}" + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on ReplaceServerSwitchingRuleURL") + return nil, errors.New("index is required on ReplaceServerSwitchingRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceServerSwitchingRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/server_switching_rule/replace_server_switching_rules.go b/operations/server_switching_rule/replace_server_switching_rules.go new file mode 100644 index 00000000..9b04b316 --- /dev/null +++ b/operations/server_switching_rule/replace_server_switching_rules.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceServerSwitchingRulesHandlerFunc turns a function with the right signature into a replace server switching rules handler +type ReplaceServerSwitchingRulesHandlerFunc func(ReplaceServerSwitchingRulesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceServerSwitchingRulesHandlerFunc) Handle(params ReplaceServerSwitchingRulesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceServerSwitchingRulesHandler interface for that can handle valid replace server switching rules params +type ReplaceServerSwitchingRulesHandler interface { + Handle(ReplaceServerSwitchingRulesParams, interface{}) middleware.Responder +} + +// NewReplaceServerSwitchingRules creates a new http.Handler for the replace server switching rules operation +func NewReplaceServerSwitchingRules(ctx *middleware.Context, handler ReplaceServerSwitchingRulesHandler) *ReplaceServerSwitchingRules { + return &ReplaceServerSwitchingRules{Context: ctx, Handler: handler} +} + +/* + ReplaceServerSwitchingRules swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/server_switching_rules ServerSwitchingRule replaceServerSwitchingRules + +# Replace an Server Switching Rule list + +Replaces a whole list of Server Switching Rules with the list given in parameter +*/ +type ReplaceServerSwitchingRules struct { + Context *middleware.Context + Handler ReplaceServerSwitchingRulesHandler +} + +func (o *ReplaceServerSwitchingRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceServerSwitchingRulesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server_switching_rule/replace_server_switching_rules_parameters.go b/operations/server_switching_rule/replace_server_switching_rules_parameters.go new file mode 100644 index 00000000..2dcfd584 --- /dev/null +++ b/operations/server_switching_rule/replace_server_switching_rules_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceServerSwitchingRulesParams creates a new ReplaceServerSwitchingRulesParams object +// with the default values initialized. +func NewReplaceServerSwitchingRulesParams() ReplaceServerSwitchingRulesParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceServerSwitchingRulesParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceServerSwitchingRulesParams contains all the bound params for the replace server switching rules operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceServerSwitchingRules +type ReplaceServerSwitchingRulesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.ServerSwitchingRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceServerSwitchingRulesParams() beforehand. +func (o *ReplaceServerSwitchingRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ServerSwitchingRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceServerSwitchingRulesParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceServerSwitchingRulesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceServerSwitchingRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceServerSwitchingRulesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceServerSwitchingRulesParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server_switching_rule/replace_server_switching_rules_responses.go b/operations/server_switching_rule/replace_server_switching_rules_responses.go new file mode 100644 index 00000000..4c1fdd6a --- /dev/null +++ b/operations/server_switching_rule/replace_server_switching_rules_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceServerSwitchingRulesOKCode is the HTTP code returned for type ReplaceServerSwitchingRulesOK +const ReplaceServerSwitchingRulesOKCode int = 200 + +/* +ReplaceServerSwitchingRulesOK All Server Switching Rule lines replaced + +swagger:response replaceServerSwitchingRulesOK +*/ +type ReplaceServerSwitchingRulesOK struct { + + /* + In: Body + */ + Payload models.ServerSwitchingRules `json:"body,omitempty"` +} + +// NewReplaceServerSwitchingRulesOK creates ReplaceServerSwitchingRulesOK with default headers values +func NewReplaceServerSwitchingRulesOK() *ReplaceServerSwitchingRulesOK { + + return &ReplaceServerSwitchingRulesOK{} +} + +// WithPayload adds the payload to the replace server switching rules o k response +func (o *ReplaceServerSwitchingRulesOK) WithPayload(payload models.ServerSwitchingRules) *ReplaceServerSwitchingRulesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server switching rules o k response +func (o *ReplaceServerSwitchingRulesOK) SetPayload(payload models.ServerSwitchingRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerSwitchingRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.ServerSwitchingRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceServerSwitchingRulesAcceptedCode is the HTTP code returned for type ReplaceServerSwitchingRulesAccepted +const ReplaceServerSwitchingRulesAcceptedCode int = 202 + +/* +ReplaceServerSwitchingRulesAccepted Configuration change accepted and reload requested + +swagger:response replaceServerSwitchingRulesAccepted +*/ +type ReplaceServerSwitchingRulesAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.ServerSwitchingRules `json:"body,omitempty"` +} + +// NewReplaceServerSwitchingRulesAccepted creates ReplaceServerSwitchingRulesAccepted with default headers values +func NewReplaceServerSwitchingRulesAccepted() *ReplaceServerSwitchingRulesAccepted { + + return &ReplaceServerSwitchingRulesAccepted{} +} + +// WithReloadID adds the reloadId to the replace server switching rules accepted response +func (o *ReplaceServerSwitchingRulesAccepted) WithReloadID(reloadID string) *ReplaceServerSwitchingRulesAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace server switching rules accepted response +func (o *ReplaceServerSwitchingRulesAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace server switching rules accepted response +func (o *ReplaceServerSwitchingRulesAccepted) WithPayload(payload models.ServerSwitchingRules) *ReplaceServerSwitchingRulesAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server switching rules accepted response +func (o *ReplaceServerSwitchingRulesAccepted) SetPayload(payload models.ServerSwitchingRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerSwitchingRulesAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.ServerSwitchingRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceServerSwitchingRulesBadRequestCode is the HTTP code returned for type ReplaceServerSwitchingRulesBadRequest +const ReplaceServerSwitchingRulesBadRequestCode int = 400 + +/* +ReplaceServerSwitchingRulesBadRequest Bad request + +swagger:response replaceServerSwitchingRulesBadRequest +*/ +type ReplaceServerSwitchingRulesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerSwitchingRulesBadRequest creates ReplaceServerSwitchingRulesBadRequest with default headers values +func NewReplaceServerSwitchingRulesBadRequest() *ReplaceServerSwitchingRulesBadRequest { + + return &ReplaceServerSwitchingRulesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server switching rules bad request response +func (o *ReplaceServerSwitchingRulesBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceServerSwitchingRulesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server switching rules bad request response +func (o *ReplaceServerSwitchingRulesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server switching rules bad request response +func (o *ReplaceServerSwitchingRulesBadRequest) WithPayload(payload *models.Error) *ReplaceServerSwitchingRulesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server switching rules bad request response +func (o *ReplaceServerSwitchingRulesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerSwitchingRulesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceServerSwitchingRulesDefault General Error + +swagger:response replaceServerSwitchingRulesDefault +*/ +type ReplaceServerSwitchingRulesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerSwitchingRulesDefault creates ReplaceServerSwitchingRulesDefault with default headers values +func NewReplaceServerSwitchingRulesDefault(code int) *ReplaceServerSwitchingRulesDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceServerSwitchingRulesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace server switching rules default response +func (o *ReplaceServerSwitchingRulesDefault) WithStatusCode(code int) *ReplaceServerSwitchingRulesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace server switching rules default response +func (o *ReplaceServerSwitchingRulesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace server switching rules default response +func (o *ReplaceServerSwitchingRulesDefault) WithConfigurationVersion(configurationVersion string) *ReplaceServerSwitchingRulesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server switching rules default response +func (o *ReplaceServerSwitchingRulesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server switching rules default response +func (o *ReplaceServerSwitchingRulesDefault) WithPayload(payload *models.Error) *ReplaceServerSwitchingRulesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server switching rules default response +func (o *ReplaceServerSwitchingRulesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerSwitchingRulesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server_switching_rule/replace_server_switching_rules_urlbuilder.go b/operations/server_switching_rule/replace_server_switching_rules_urlbuilder.go new file mode 100644 index 00000000..30b6406d --- /dev/null +++ b/operations/server_switching_rule/replace_server_switching_rules_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_switching_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceServerSwitchingRulesURL generates an URL for the replace server switching rules operation +type ReplaceServerSwitchingRulesURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerSwitchingRulesURL) WithBasePath(bp string) *ReplaceServerSwitchingRulesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerSwitchingRulesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceServerSwitchingRulesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_switching_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceServerSwitchingRulesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceServerSwitchingRulesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceServerSwitchingRulesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceServerSwitchingRulesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceServerSwitchingRulesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceServerSwitchingRulesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceServerSwitchingRulesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server_template/create_server_template.go b/operations/server_template/create_server_template.go new file mode 100644 index 00000000..cd1bae1b --- /dev/null +++ b/operations/server_template/create_server_template.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateServerTemplateHandlerFunc turns a function with the right signature into a create server template handler +type CreateServerTemplateHandlerFunc func(CreateServerTemplateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateServerTemplateHandlerFunc) Handle(params CreateServerTemplateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateServerTemplateHandler interface for that can handle valid create server template params +type CreateServerTemplateHandler interface { + Handle(CreateServerTemplateParams, interface{}) middleware.Responder +} + +// NewCreateServerTemplate creates a new http.Handler for the create server template operation +func NewCreateServerTemplate(ctx *middleware.Context, handler CreateServerTemplateHandler) *CreateServerTemplate { + return &CreateServerTemplate{Context: ctx, Handler: handler} +} + +/* + CreateServerTemplate swagger:route POST /services/haproxy/configuration/backends/{parent_name}/server_templates ServerTemplate createServerTemplate + +# Add a new server template + +Adds a new server template in the specified backend in the configuration file. +*/ +type CreateServerTemplate struct { + Context *middleware.Context + Handler CreateServerTemplateHandler +} + +func (o *CreateServerTemplate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateServerTemplateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server_template/create_server_template_parameters.go b/operations/server_template/create_server_template_parameters.go new file mode 100644 index 00000000..96e43990 --- /dev/null +++ b/operations/server_template/create_server_template_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateServerTemplateParams creates a new CreateServerTemplateParams object +// with the default values initialized. +func NewCreateServerTemplateParams() CreateServerTemplateParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateServerTemplateParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateServerTemplateParams contains all the bound params for the create server template operation +// typically these are obtained from a http.Request +// +// swagger:parameters createServerTemplate +type CreateServerTemplateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ServerTemplate + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateServerTemplateParams() beforehand. +func (o *CreateServerTemplateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ServerTemplate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateServerTemplateParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateServerTemplateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateServerTemplateParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateServerTemplateParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateServerTemplateParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server_template/create_server_template_responses.go b/operations/server_template/create_server_template_responses.go new file mode 100644 index 00000000..f77ae071 --- /dev/null +++ b/operations/server_template/create_server_template_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateServerTemplateCreatedCode is the HTTP code returned for type CreateServerTemplateCreated +const CreateServerTemplateCreatedCode int = 201 + +/* +CreateServerTemplateCreated Server template created + +swagger:response createServerTemplateCreated +*/ +type CreateServerTemplateCreated struct { + + /* + In: Body + */ + Payload *models.ServerTemplate `json:"body,omitempty"` +} + +// NewCreateServerTemplateCreated creates CreateServerTemplateCreated with default headers values +func NewCreateServerTemplateCreated() *CreateServerTemplateCreated { + + return &CreateServerTemplateCreated{} +} + +// WithPayload adds the payload to the create server template created response +func (o *CreateServerTemplateCreated) WithPayload(payload *models.ServerTemplate) *CreateServerTemplateCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server template created response +func (o *CreateServerTemplateCreated) SetPayload(payload *models.ServerTemplate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerTemplateCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerTemplateAcceptedCode is the HTTP code returned for type CreateServerTemplateAccepted +const CreateServerTemplateAcceptedCode int = 202 + +/* +CreateServerTemplateAccepted Configuration change accepted and reload requested + +swagger:response createServerTemplateAccepted +*/ +type CreateServerTemplateAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ServerTemplate `json:"body,omitempty"` +} + +// NewCreateServerTemplateAccepted creates CreateServerTemplateAccepted with default headers values +func NewCreateServerTemplateAccepted() *CreateServerTemplateAccepted { + + return &CreateServerTemplateAccepted{} +} + +// WithReloadID adds the reloadId to the create server template accepted response +func (o *CreateServerTemplateAccepted) WithReloadID(reloadID string) *CreateServerTemplateAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create server template accepted response +func (o *CreateServerTemplateAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create server template accepted response +func (o *CreateServerTemplateAccepted) WithPayload(payload *models.ServerTemplate) *CreateServerTemplateAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server template accepted response +func (o *CreateServerTemplateAccepted) SetPayload(payload *models.ServerTemplate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerTemplateAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerTemplateBadRequestCode is the HTTP code returned for type CreateServerTemplateBadRequest +const CreateServerTemplateBadRequestCode int = 400 + +/* +CreateServerTemplateBadRequest Bad request + +swagger:response createServerTemplateBadRequest +*/ +type CreateServerTemplateBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerTemplateBadRequest creates CreateServerTemplateBadRequest with default headers values +func NewCreateServerTemplateBadRequest() *CreateServerTemplateBadRequest { + + return &CreateServerTemplateBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server template bad request response +func (o *CreateServerTemplateBadRequest) WithConfigurationVersion(configurationVersion string) *CreateServerTemplateBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server template bad request response +func (o *CreateServerTemplateBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server template bad request response +func (o *CreateServerTemplateBadRequest) WithPayload(payload *models.Error) *CreateServerTemplateBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server template bad request response +func (o *CreateServerTemplateBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerTemplateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateServerTemplateConflictCode is the HTTP code returned for type CreateServerTemplateConflict +const CreateServerTemplateConflictCode int = 409 + +/* +CreateServerTemplateConflict The specified resource already exists + +swagger:response createServerTemplateConflict +*/ +type CreateServerTemplateConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerTemplateConflict creates CreateServerTemplateConflict with default headers values +func NewCreateServerTemplateConflict() *CreateServerTemplateConflict { + + return &CreateServerTemplateConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create server template conflict response +func (o *CreateServerTemplateConflict) WithConfigurationVersion(configurationVersion string) *CreateServerTemplateConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server template conflict response +func (o *CreateServerTemplateConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server template conflict response +func (o *CreateServerTemplateConflict) WithPayload(payload *models.Error) *CreateServerTemplateConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server template conflict response +func (o *CreateServerTemplateConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerTemplateConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateServerTemplateDefault General Error + +swagger:response createServerTemplateDefault +*/ +type CreateServerTemplateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateServerTemplateDefault creates CreateServerTemplateDefault with default headers values +func NewCreateServerTemplateDefault(code int) *CreateServerTemplateDefault { + if code <= 0 { + code = 500 + } + + return &CreateServerTemplateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create server template default response +func (o *CreateServerTemplateDefault) WithStatusCode(code int) *CreateServerTemplateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create server template default response +func (o *CreateServerTemplateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create server template default response +func (o *CreateServerTemplateDefault) WithConfigurationVersion(configurationVersion string) *CreateServerTemplateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create server template default response +func (o *CreateServerTemplateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create server template default response +func (o *CreateServerTemplateDefault) WithPayload(payload *models.Error) *CreateServerTemplateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create server template default response +func (o *CreateServerTemplateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateServerTemplateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server_template/create_server_template_urlbuilder.go b/operations/server_template/create_server_template_urlbuilder.go new file mode 100644 index 00000000..0504794c --- /dev/null +++ b/operations/server_template/create_server_template_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateServerTemplateURL generates an URL for the create server template operation +type CreateServerTemplateURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerTemplateURL) WithBasePath(bp string) *CreateServerTemplateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateServerTemplateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateServerTemplateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_templates" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateServerTemplateURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateServerTemplateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateServerTemplateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateServerTemplateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateServerTemplateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateServerTemplateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateServerTemplateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server_template/delete_server_template.go b/operations/server_template/delete_server_template.go new file mode 100644 index 00000000..68051868 --- /dev/null +++ b/operations/server_template/delete_server_template.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteServerTemplateHandlerFunc turns a function with the right signature into a delete server template handler +type DeleteServerTemplateHandlerFunc func(DeleteServerTemplateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteServerTemplateHandlerFunc) Handle(params DeleteServerTemplateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteServerTemplateHandler interface for that can handle valid delete server template params +type DeleteServerTemplateHandler interface { + Handle(DeleteServerTemplateParams, interface{}) middleware.Responder +} + +// NewDeleteServerTemplate creates a new http.Handler for the delete server template operation +func NewDeleteServerTemplate(ctx *middleware.Context, handler DeleteServerTemplateHandler) *DeleteServerTemplate { + return &DeleteServerTemplate{Context: ctx, Handler: handler} +} + +/* + DeleteServerTemplate swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix} ServerTemplate deleteServerTemplate + +# Delete a server template + +Deletes a server template configuration by it's prefix in the specified backend. +*/ +type DeleteServerTemplate struct { + Context *middleware.Context + Handler DeleteServerTemplateHandler +} + +func (o *DeleteServerTemplate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteServerTemplateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server_template/delete_server_template_parameters.go b/operations/server_template/delete_server_template_parameters.go new file mode 100644 index 00000000..174599c1 --- /dev/null +++ b/operations/server_template/delete_server_template_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteServerTemplateParams creates a new DeleteServerTemplateParams object +// with the default values initialized. +func NewDeleteServerTemplateParams() DeleteServerTemplateParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteServerTemplateParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteServerTemplateParams contains all the bound params for the delete server template operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteServerTemplate +type DeleteServerTemplateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*Server template prefix + Required: true + In: path + */ + Prefix string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteServerTemplateParams() beforehand. +func (o *DeleteServerTemplateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rPrefix, rhkPrefix, _ := route.Params.GetOK("prefix") + if err := o.bindPrefix(rPrefix, rhkPrefix, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteServerTemplateParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteServerTemplateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteServerTemplateParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindPrefix binds and validates parameter Prefix from path. +func (o *DeleteServerTemplateParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Prefix = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteServerTemplateParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteServerTemplateParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server_template/delete_server_template_responses.go b/operations/server_template/delete_server_template_responses.go new file mode 100644 index 00000000..20b0f13b --- /dev/null +++ b/operations/server_template/delete_server_template_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteServerTemplateAcceptedCode is the HTTP code returned for type DeleteServerTemplateAccepted +const DeleteServerTemplateAcceptedCode int = 202 + +/* +DeleteServerTemplateAccepted Configuration change accepted and reload requested + +swagger:response deleteServerTemplateAccepted +*/ +type DeleteServerTemplateAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteServerTemplateAccepted creates DeleteServerTemplateAccepted with default headers values +func NewDeleteServerTemplateAccepted() *DeleteServerTemplateAccepted { + + return &DeleteServerTemplateAccepted{} +} + +// WithReloadID adds the reloadId to the delete server template accepted response +func (o *DeleteServerTemplateAccepted) WithReloadID(reloadID string) *DeleteServerTemplateAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete server template accepted response +func (o *DeleteServerTemplateAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteServerTemplateAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteServerTemplateNoContentCode is the HTTP code returned for type DeleteServerTemplateNoContent +const DeleteServerTemplateNoContentCode int = 204 + +/* +DeleteServerTemplateNoContent Server template deleted + +swagger:response deleteServerTemplateNoContent +*/ +type DeleteServerTemplateNoContent struct { +} + +// NewDeleteServerTemplateNoContent creates DeleteServerTemplateNoContent with default headers values +func NewDeleteServerTemplateNoContent() *DeleteServerTemplateNoContent { + + return &DeleteServerTemplateNoContent{} +} + +// WriteResponse to the client +func (o *DeleteServerTemplateNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteServerTemplateNotFoundCode is the HTTP code returned for type DeleteServerTemplateNotFound +const DeleteServerTemplateNotFoundCode int = 404 + +/* +DeleteServerTemplateNotFound The specified resource was not found + +swagger:response deleteServerTemplateNotFound +*/ +type DeleteServerTemplateNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerTemplateNotFound creates DeleteServerTemplateNotFound with default headers values +func NewDeleteServerTemplateNotFound() *DeleteServerTemplateNotFound { + + return &DeleteServerTemplateNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete server template not found response +func (o *DeleteServerTemplateNotFound) WithConfigurationVersion(configurationVersion string) *DeleteServerTemplateNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server template not found response +func (o *DeleteServerTemplateNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server template not found response +func (o *DeleteServerTemplateNotFound) WithPayload(payload *models.Error) *DeleteServerTemplateNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server template not found response +func (o *DeleteServerTemplateNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerTemplateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteServerTemplateDefault General Error + +swagger:response deleteServerTemplateDefault +*/ +type DeleteServerTemplateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteServerTemplateDefault creates DeleteServerTemplateDefault with default headers values +func NewDeleteServerTemplateDefault(code int) *DeleteServerTemplateDefault { + if code <= 0 { + code = 500 + } + + return &DeleteServerTemplateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete server template default response +func (o *DeleteServerTemplateDefault) WithStatusCode(code int) *DeleteServerTemplateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete server template default response +func (o *DeleteServerTemplateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete server template default response +func (o *DeleteServerTemplateDefault) WithConfigurationVersion(configurationVersion string) *DeleteServerTemplateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete server template default response +func (o *DeleteServerTemplateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete server template default response +func (o *DeleteServerTemplateDefault) WithPayload(payload *models.Error) *DeleteServerTemplateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete server template default response +func (o *DeleteServerTemplateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteServerTemplateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server_template/delete_server_template_urlbuilder.go b/operations/server_template/delete_server_template_urlbuilder.go new file mode 100644 index 00000000..9684ee34 --- /dev/null +++ b/operations/server_template/delete_server_template_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteServerTemplateURL generates an URL for the delete server template operation +type DeleteServerTemplateURL struct { + ParentName string + Prefix string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerTemplateURL) WithBasePath(bp string) *DeleteServerTemplateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteServerTemplateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteServerTemplateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteServerTemplateURL") + } + + prefix := o.Prefix + if prefix != "" { + _path = strings.Replace(_path, "{prefix}", prefix, -1) + } else { + return nil, errors.New("prefix is required on DeleteServerTemplateURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteServerTemplateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteServerTemplateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteServerTemplateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteServerTemplateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteServerTemplateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteServerTemplateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server_template/get_server_template.go b/operations/server_template/get_server_template.go new file mode 100644 index 00000000..65cb73db --- /dev/null +++ b/operations/server_template/get_server_template.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServerTemplateHandlerFunc turns a function with the right signature into a get server template handler +type GetServerTemplateHandlerFunc func(GetServerTemplateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServerTemplateHandlerFunc) Handle(params GetServerTemplateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServerTemplateHandler interface for that can handle valid get server template params +type GetServerTemplateHandler interface { + Handle(GetServerTemplateParams, interface{}) middleware.Responder +} + +// NewGetServerTemplate creates a new http.Handler for the get server template operation +func NewGetServerTemplate(ctx *middleware.Context, handler GetServerTemplateHandler) *GetServerTemplate { + return &GetServerTemplate{Context: ctx, Handler: handler} +} + +/* + GetServerTemplate swagger:route GET /services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix} ServerTemplate getServerTemplate + +# Return one server template + +Returns one server template configuration by it's prefix in the specified backend. +*/ +type GetServerTemplate struct { + Context *middleware.Context + Handler GetServerTemplateHandler +} + +func (o *GetServerTemplate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServerTemplateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server_template/get_server_template_parameters.go b/operations/server_template/get_server_template_parameters.go new file mode 100644 index 00000000..e7925320 --- /dev/null +++ b/operations/server_template/get_server_template_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServerTemplateParams creates a new GetServerTemplateParams object +// +// There are no default values defined in the spec. +func NewGetServerTemplateParams() GetServerTemplateParams { + + return GetServerTemplateParams{} +} + +// GetServerTemplateParams contains all the bound params for the get server template operation +// typically these are obtained from a http.Request +// +// swagger:parameters getServerTemplate +type GetServerTemplateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*Server template prefix + Required: true + In: path + */ + Prefix string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServerTemplateParams() beforehand. +func (o *GetServerTemplateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rPrefix, rhkPrefix, _ := route.Params.GetOK("prefix") + if err := o.bindPrefix(rPrefix, rhkPrefix, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServerTemplateParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindPrefix binds and validates parameter Prefix from path. +func (o *GetServerTemplateParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Prefix = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetServerTemplateParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server_template/get_server_template_responses.go b/operations/server_template/get_server_template_responses.go new file mode 100644 index 00000000..35eceb46 --- /dev/null +++ b/operations/server_template/get_server_template_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServerTemplateOKCode is the HTTP code returned for type GetServerTemplateOK +const GetServerTemplateOKCode int = 200 + +/* +GetServerTemplateOK Successful operation + +swagger:response getServerTemplateOK +*/ +type GetServerTemplateOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.ServerTemplate `json:"body,omitempty"` +} + +// NewGetServerTemplateOK creates GetServerTemplateOK with default headers values +func NewGetServerTemplateOK() *GetServerTemplateOK { + + return &GetServerTemplateOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server template o k response +func (o *GetServerTemplateOK) WithConfigurationVersion(configurationVersion string) *GetServerTemplateOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server template o k response +func (o *GetServerTemplateOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server template o k response +func (o *GetServerTemplateOK) WithPayload(payload *models.ServerTemplate) *GetServerTemplateOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server template o k response +func (o *GetServerTemplateOK) SetPayload(payload *models.ServerTemplate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerTemplateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetServerTemplateNotFoundCode is the HTTP code returned for type GetServerTemplateNotFound +const GetServerTemplateNotFoundCode int = 404 + +/* +GetServerTemplateNotFound The specified resource was not found + +swagger:response getServerTemplateNotFound +*/ +type GetServerTemplateNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerTemplateNotFound creates GetServerTemplateNotFound with default headers values +func NewGetServerTemplateNotFound() *GetServerTemplateNotFound { + + return &GetServerTemplateNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server template not found response +func (o *GetServerTemplateNotFound) WithConfigurationVersion(configurationVersion string) *GetServerTemplateNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server template not found response +func (o *GetServerTemplateNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server template not found response +func (o *GetServerTemplateNotFound) WithPayload(payload *models.Error) *GetServerTemplateNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server template not found response +func (o *GetServerTemplateNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerTemplateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetServerTemplateDefault General Error + +swagger:response getServerTemplateDefault +*/ +type GetServerTemplateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerTemplateDefault creates GetServerTemplateDefault with default headers values +func NewGetServerTemplateDefault(code int) *GetServerTemplateDefault { + if code <= 0 { + code = 500 + } + + return &GetServerTemplateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get server template default response +func (o *GetServerTemplateDefault) WithStatusCode(code int) *GetServerTemplateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get server template default response +func (o *GetServerTemplateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get server template default response +func (o *GetServerTemplateDefault) WithConfigurationVersion(configurationVersion string) *GetServerTemplateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server template default response +func (o *GetServerTemplateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server template default response +func (o *GetServerTemplateDefault) WithPayload(payload *models.Error) *GetServerTemplateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server template default response +func (o *GetServerTemplateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerTemplateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server_template/get_server_template_urlbuilder.go b/operations/server_template/get_server_template_urlbuilder.go new file mode 100644 index 00000000..1a0771cb --- /dev/null +++ b/operations/server_template/get_server_template_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServerTemplateURL generates an URL for the get server template operation +type GetServerTemplateURL struct { + ParentName string + Prefix string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerTemplateURL) WithBasePath(bp string) *GetServerTemplateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerTemplateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServerTemplateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServerTemplateURL") + } + + prefix := o.Prefix + if prefix != "" { + _path = strings.Replace(_path, "{prefix}", prefix, -1) + } else { + return nil, errors.New("prefix is required on GetServerTemplateURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServerTemplateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServerTemplateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServerTemplateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServerTemplateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServerTemplateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServerTemplateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server_template/get_server_templates.go b/operations/server_template/get_server_templates.go new file mode 100644 index 00000000..62ab94f1 --- /dev/null +++ b/operations/server_template/get_server_templates.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetServerTemplatesHandlerFunc turns a function with the right signature into a get server templates handler +type GetServerTemplatesHandlerFunc func(GetServerTemplatesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetServerTemplatesHandlerFunc) Handle(params GetServerTemplatesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetServerTemplatesHandler interface for that can handle valid get server templates params +type GetServerTemplatesHandler interface { + Handle(GetServerTemplatesParams, interface{}) middleware.Responder +} + +// NewGetServerTemplates creates a new http.Handler for the get server templates operation +func NewGetServerTemplates(ctx *middleware.Context, handler GetServerTemplatesHandler) *GetServerTemplates { + return &GetServerTemplates{Context: ctx, Handler: handler} +} + +/* + GetServerTemplates swagger:route GET /services/haproxy/configuration/backends/{parent_name}/server_templates ServerTemplate getServerTemplates + +# Return an array of server templates + +Returns an array of all server templates that are configured in specified backend. +*/ +type GetServerTemplates struct { + Context *middleware.Context + Handler GetServerTemplatesHandler +} + +func (o *GetServerTemplates) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetServerTemplatesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server_template/get_server_templates_parameters.go b/operations/server_template/get_server_templates_parameters.go new file mode 100644 index 00000000..06b3a7c3 --- /dev/null +++ b/operations/server_template/get_server_templates_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetServerTemplatesParams creates a new GetServerTemplatesParams object +// +// There are no default values defined in the spec. +func NewGetServerTemplatesParams() GetServerTemplatesParams { + + return GetServerTemplatesParams{} +} + +// GetServerTemplatesParams contains all the bound params for the get server templates operation +// typically these are obtained from a http.Request +// +// swagger:parameters getServerTemplates +type GetServerTemplatesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetServerTemplatesParams() beforehand. +func (o *GetServerTemplatesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetServerTemplatesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetServerTemplatesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/server_template/get_server_templates_responses.go b/operations/server_template/get_server_templates_responses.go new file mode 100644 index 00000000..46e5e733 --- /dev/null +++ b/operations/server_template/get_server_templates_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetServerTemplatesOKCode is the HTTP code returned for type GetServerTemplatesOK +const GetServerTemplatesOKCode int = 200 + +/* +GetServerTemplatesOK Successful operation + +swagger:response getServerTemplatesOK +*/ +type GetServerTemplatesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.ServerTemplates `json:"body,omitempty"` +} + +// NewGetServerTemplatesOK creates GetServerTemplatesOK with default headers values +func NewGetServerTemplatesOK() *GetServerTemplatesOK { + + return &GetServerTemplatesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get server templates o k response +func (o *GetServerTemplatesOK) WithConfigurationVersion(configurationVersion string) *GetServerTemplatesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server templates o k response +func (o *GetServerTemplatesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server templates o k response +func (o *GetServerTemplatesOK) WithPayload(payload models.ServerTemplates) *GetServerTemplatesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server templates o k response +func (o *GetServerTemplatesOK) SetPayload(payload models.ServerTemplates) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerTemplatesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.ServerTemplates{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetServerTemplatesDefault General Error + +swagger:response getServerTemplatesDefault +*/ +type GetServerTemplatesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetServerTemplatesDefault creates GetServerTemplatesDefault with default headers values +func NewGetServerTemplatesDefault(code int) *GetServerTemplatesDefault { + if code <= 0 { + code = 500 + } + + return &GetServerTemplatesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get server templates default response +func (o *GetServerTemplatesDefault) WithStatusCode(code int) *GetServerTemplatesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get server templates default response +func (o *GetServerTemplatesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get server templates default response +func (o *GetServerTemplatesDefault) WithConfigurationVersion(configurationVersion string) *GetServerTemplatesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get server templates default response +func (o *GetServerTemplatesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get server templates default response +func (o *GetServerTemplatesDefault) WithPayload(payload *models.Error) *GetServerTemplatesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get server templates default response +func (o *GetServerTemplatesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetServerTemplatesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server_template/get_server_templates_urlbuilder.go b/operations/server_template/get_server_templates_urlbuilder.go new file mode 100644 index 00000000..a7b153e8 --- /dev/null +++ b/operations/server_template/get_server_templates_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetServerTemplatesURL generates an URL for the get server templates operation +type GetServerTemplatesURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerTemplatesURL) WithBasePath(bp string) *GetServerTemplatesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetServerTemplatesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetServerTemplatesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_templates" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetServerTemplatesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetServerTemplatesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetServerTemplatesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetServerTemplatesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetServerTemplatesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetServerTemplatesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetServerTemplatesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/server_template/replace_server_template.go b/operations/server_template/replace_server_template.go new file mode 100644 index 00000000..c899fe0f --- /dev/null +++ b/operations/server_template/replace_server_template.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceServerTemplateHandlerFunc turns a function with the right signature into a replace server template handler +type ReplaceServerTemplateHandlerFunc func(ReplaceServerTemplateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceServerTemplateHandlerFunc) Handle(params ReplaceServerTemplateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceServerTemplateHandler interface for that can handle valid replace server template params +type ReplaceServerTemplateHandler interface { + Handle(ReplaceServerTemplateParams, interface{}) middleware.Responder +} + +// NewReplaceServerTemplate creates a new http.Handler for the replace server template operation +func NewReplaceServerTemplate(ctx *middleware.Context, handler ReplaceServerTemplateHandler) *ReplaceServerTemplate { + return &ReplaceServerTemplate{Context: ctx, Handler: handler} +} + +/* + ReplaceServerTemplate swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix} ServerTemplate replaceServerTemplate + +# Replace a server template + +Replaces a server template configuration by it's prefix in the specified backend. +*/ +type ReplaceServerTemplate struct { + Context *middleware.Context + Handler ReplaceServerTemplateHandler +} + +func (o *ReplaceServerTemplate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceServerTemplateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/server_template/replace_server_template_parameters.go b/operations/server_template/replace_server_template_parameters.go new file mode 100644 index 00000000..01aa8802 --- /dev/null +++ b/operations/server_template/replace_server_template_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceServerTemplateParams creates a new ReplaceServerTemplateParams object +// with the default values initialized. +func NewReplaceServerTemplateParams() ReplaceServerTemplateParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceServerTemplateParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceServerTemplateParams contains all the bound params for the replace server template operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceServerTemplate +type ReplaceServerTemplateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.ServerTemplate + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*Server template prefix + Required: true + In: path + */ + Prefix string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceServerTemplateParams() beforehand. +func (o *ReplaceServerTemplateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ServerTemplate + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rPrefix, rhkPrefix, _ := route.Params.GetOK("prefix") + if err := o.bindPrefix(rPrefix, rhkPrefix, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceServerTemplateParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceServerTemplateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceServerTemplateParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindPrefix binds and validates parameter Prefix from path. +func (o *ReplaceServerTemplateParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Prefix = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceServerTemplateParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceServerTemplateParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/server_template/replace_server_template_responses.go b/operations/server_template/replace_server_template_responses.go new file mode 100644 index 00000000..68e085d0 --- /dev/null +++ b/operations/server_template/replace_server_template_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceServerTemplateOKCode is the HTTP code returned for type ReplaceServerTemplateOK +const ReplaceServerTemplateOKCode int = 200 + +/* +ReplaceServerTemplateOK Server template replaced + +swagger:response replaceServerTemplateOK +*/ +type ReplaceServerTemplateOK struct { + + /* + In: Body + */ + Payload *models.ServerTemplate `json:"body,omitempty"` +} + +// NewReplaceServerTemplateOK creates ReplaceServerTemplateOK with default headers values +func NewReplaceServerTemplateOK() *ReplaceServerTemplateOK { + + return &ReplaceServerTemplateOK{} +} + +// WithPayload adds the payload to the replace server template o k response +func (o *ReplaceServerTemplateOK) WithPayload(payload *models.ServerTemplate) *ReplaceServerTemplateOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server template o k response +func (o *ReplaceServerTemplateOK) SetPayload(payload *models.ServerTemplate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerTemplateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerTemplateAcceptedCode is the HTTP code returned for type ReplaceServerTemplateAccepted +const ReplaceServerTemplateAcceptedCode int = 202 + +/* +ReplaceServerTemplateAccepted Configuration change accepted and reload requested + +swagger:response replaceServerTemplateAccepted +*/ +type ReplaceServerTemplateAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.ServerTemplate `json:"body,omitempty"` +} + +// NewReplaceServerTemplateAccepted creates ReplaceServerTemplateAccepted with default headers values +func NewReplaceServerTemplateAccepted() *ReplaceServerTemplateAccepted { + + return &ReplaceServerTemplateAccepted{} +} + +// WithReloadID adds the reloadId to the replace server template accepted response +func (o *ReplaceServerTemplateAccepted) WithReloadID(reloadID string) *ReplaceServerTemplateAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace server template accepted response +func (o *ReplaceServerTemplateAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace server template accepted response +func (o *ReplaceServerTemplateAccepted) WithPayload(payload *models.ServerTemplate) *ReplaceServerTemplateAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server template accepted response +func (o *ReplaceServerTemplateAccepted) SetPayload(payload *models.ServerTemplate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerTemplateAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerTemplateBadRequestCode is the HTTP code returned for type ReplaceServerTemplateBadRequest +const ReplaceServerTemplateBadRequestCode int = 400 + +/* +ReplaceServerTemplateBadRequest Bad request + +swagger:response replaceServerTemplateBadRequest +*/ +type ReplaceServerTemplateBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerTemplateBadRequest creates ReplaceServerTemplateBadRequest with default headers values +func NewReplaceServerTemplateBadRequest() *ReplaceServerTemplateBadRequest { + + return &ReplaceServerTemplateBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server template bad request response +func (o *ReplaceServerTemplateBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceServerTemplateBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server template bad request response +func (o *ReplaceServerTemplateBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server template bad request response +func (o *ReplaceServerTemplateBadRequest) WithPayload(payload *models.Error) *ReplaceServerTemplateBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server template bad request response +func (o *ReplaceServerTemplateBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerTemplateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceServerTemplateNotFoundCode is the HTTP code returned for type ReplaceServerTemplateNotFound +const ReplaceServerTemplateNotFoundCode int = 404 + +/* +ReplaceServerTemplateNotFound The specified resource was not found + +swagger:response replaceServerTemplateNotFound +*/ +type ReplaceServerTemplateNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerTemplateNotFound creates ReplaceServerTemplateNotFound with default headers values +func NewReplaceServerTemplateNotFound() *ReplaceServerTemplateNotFound { + + return &ReplaceServerTemplateNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace server template not found response +func (o *ReplaceServerTemplateNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceServerTemplateNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server template not found response +func (o *ReplaceServerTemplateNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server template not found response +func (o *ReplaceServerTemplateNotFound) WithPayload(payload *models.Error) *ReplaceServerTemplateNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server template not found response +func (o *ReplaceServerTemplateNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerTemplateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceServerTemplateDefault General Error + +swagger:response replaceServerTemplateDefault +*/ +type ReplaceServerTemplateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceServerTemplateDefault creates ReplaceServerTemplateDefault with default headers values +func NewReplaceServerTemplateDefault(code int) *ReplaceServerTemplateDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceServerTemplateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace server template default response +func (o *ReplaceServerTemplateDefault) WithStatusCode(code int) *ReplaceServerTemplateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace server template default response +func (o *ReplaceServerTemplateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace server template default response +func (o *ReplaceServerTemplateDefault) WithConfigurationVersion(configurationVersion string) *ReplaceServerTemplateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace server template default response +func (o *ReplaceServerTemplateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace server template default response +func (o *ReplaceServerTemplateDefault) WithPayload(payload *models.Error) *ReplaceServerTemplateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace server template default response +func (o *ReplaceServerTemplateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceServerTemplateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/server_template/replace_server_template_urlbuilder.go b/operations/server_template/replace_server_template_urlbuilder.go new file mode 100644 index 00000000..3a33f270 --- /dev/null +++ b/operations/server_template/replace_server_template_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package server_template + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceServerTemplateURL generates an URL for the replace server template operation +type ReplaceServerTemplateURL struct { + ParentName string + Prefix string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerTemplateURL) WithBasePath(bp string) *ReplaceServerTemplateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceServerTemplateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceServerTemplateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/server_templates/{prefix}" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceServerTemplateURL") + } + + prefix := o.Prefix + if prefix != "" { + _path = strings.Replace(_path, "{prefix}", prefix, -1) + } else { + return nil, errors.New("prefix is required on ReplaceServerTemplateURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceServerTemplateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceServerTemplateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceServerTemplateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceServerTemplateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceServerTemplateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceServerTemplateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/create_a_w_s_region.go b/operations/service_discovery/create_a_w_s_region.go new file mode 100644 index 00000000..8cdfe650 --- /dev/null +++ b/operations/service_discovery/create_a_w_s_region.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateAWSRegionHandlerFunc turns a function with the right signature into a create a w s region handler +type CreateAWSRegionHandlerFunc func(CreateAWSRegionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateAWSRegionHandlerFunc) Handle(params CreateAWSRegionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateAWSRegionHandler interface for that can handle valid create a w s region params +type CreateAWSRegionHandler interface { + Handle(CreateAWSRegionParams, interface{}) middleware.Responder +} + +// NewCreateAWSRegion creates a new http.Handler for the create a w s region operation +func NewCreateAWSRegion(ctx *middleware.Context, handler CreateAWSRegionHandler) *CreateAWSRegion { + return &CreateAWSRegion{Context: ctx, Handler: handler} +} + +/* + CreateAWSRegion swagger:route POST /service_discovery/aws ServiceDiscovery createAWSRegion + +# Add a new AWS region + +Add a new AWS region. +Credentials are not required in case Dataplane API is running in an EC2 instance with proper IAM role attached. +*/ +type CreateAWSRegion struct { + Context *middleware.Context + Handler CreateAWSRegionHandler +} + +func (o *CreateAWSRegion) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateAWSRegionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/create_a_w_s_region_parameters.go b/operations/service_discovery/create_a_w_s_region_parameters.go new file mode 100644 index 00000000..ecd3afb7 --- /dev/null +++ b/operations/service_discovery/create_a_w_s_region_parameters.go @@ -0,0 +1,93 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateAWSRegionParams creates a new CreateAWSRegionParams object +// +// There are no default values defined in the spec. +func NewCreateAWSRegionParams() CreateAWSRegionParams { + + return CreateAWSRegionParams{} +} + +// CreateAWSRegionParams contains all the bound params for the create a w s region operation +// typically these are obtained from a http.Request +// +// swagger:parameters createAWSRegion +type CreateAWSRegionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.AwsRegion +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateAWSRegionParams() beforehand. +func (o *CreateAWSRegionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.AwsRegion + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/service_discovery/create_a_w_s_region_responses.go b/operations/service_discovery/create_a_w_s_region_responses.go new file mode 100644 index 00000000..beea8307 --- /dev/null +++ b/operations/service_discovery/create_a_w_s_region_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateAWSRegionCreatedCode is the HTTP code returned for type CreateAWSRegionCreated +const CreateAWSRegionCreatedCode int = 201 + +/* +CreateAWSRegionCreated Resource created + +swagger:response createAWSRegionCreated +*/ +type CreateAWSRegionCreated struct { + + /* + In: Body + */ + Payload *models.AwsRegion `json:"body,omitempty"` +} + +// NewCreateAWSRegionCreated creates CreateAWSRegionCreated with default headers values +func NewCreateAWSRegionCreated() *CreateAWSRegionCreated { + + return &CreateAWSRegionCreated{} +} + +// WithPayload adds the payload to the create a w s region created response +func (o *CreateAWSRegionCreated) WithPayload(payload *models.AwsRegion) *CreateAWSRegionCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create a w s region created response +func (o *CreateAWSRegionCreated) SetPayload(payload *models.AwsRegion) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAWSRegionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateAWSRegionBadRequestCode is the HTTP code returned for type CreateAWSRegionBadRequest +const CreateAWSRegionBadRequestCode int = 400 + +/* +CreateAWSRegionBadRequest Bad request + +swagger:response createAWSRegionBadRequest +*/ +type CreateAWSRegionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateAWSRegionBadRequest creates CreateAWSRegionBadRequest with default headers values +func NewCreateAWSRegionBadRequest() *CreateAWSRegionBadRequest { + + return &CreateAWSRegionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create a w s region bad request response +func (o *CreateAWSRegionBadRequest) WithConfigurationVersion(configurationVersion string) *CreateAWSRegionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create a w s region bad request response +func (o *CreateAWSRegionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create a w s region bad request response +func (o *CreateAWSRegionBadRequest) WithPayload(payload *models.Error) *CreateAWSRegionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create a w s region bad request response +func (o *CreateAWSRegionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAWSRegionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateAWSRegionConflictCode is the HTTP code returned for type CreateAWSRegionConflict +const CreateAWSRegionConflictCode int = 409 + +/* +CreateAWSRegionConflict The specified resource already exists + +swagger:response createAWSRegionConflict +*/ +type CreateAWSRegionConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateAWSRegionConflict creates CreateAWSRegionConflict with default headers values +func NewCreateAWSRegionConflict() *CreateAWSRegionConflict { + + return &CreateAWSRegionConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create a w s region conflict response +func (o *CreateAWSRegionConflict) WithConfigurationVersion(configurationVersion string) *CreateAWSRegionConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create a w s region conflict response +func (o *CreateAWSRegionConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create a w s region conflict response +func (o *CreateAWSRegionConflict) WithPayload(payload *models.Error) *CreateAWSRegionConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create a w s region conflict response +func (o *CreateAWSRegionConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAWSRegionConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateAWSRegionDefault General Error + +swagger:response createAWSRegionDefault +*/ +type CreateAWSRegionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateAWSRegionDefault creates CreateAWSRegionDefault with default headers values +func NewCreateAWSRegionDefault(code int) *CreateAWSRegionDefault { + if code <= 0 { + code = 500 + } + + return &CreateAWSRegionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create a w s region default response +func (o *CreateAWSRegionDefault) WithStatusCode(code int) *CreateAWSRegionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create a w s region default response +func (o *CreateAWSRegionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create a w s region default response +func (o *CreateAWSRegionDefault) WithConfigurationVersion(configurationVersion string) *CreateAWSRegionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create a w s region default response +func (o *CreateAWSRegionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create a w s region default response +func (o *CreateAWSRegionDefault) WithPayload(payload *models.Error) *CreateAWSRegionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create a w s region default response +func (o *CreateAWSRegionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateAWSRegionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/create_a_w_s_region_urlbuilder.go b/operations/service_discovery/create_a_w_s_region_urlbuilder.go new file mode 100644 index 00000000..e346f5c8 --- /dev/null +++ b/operations/service_discovery/create_a_w_s_region_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateAWSRegionURL generates an URL for the create a w s region operation +type CreateAWSRegionURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateAWSRegionURL) WithBasePath(bp string) *CreateAWSRegionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateAWSRegionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateAWSRegionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/aws" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateAWSRegionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateAWSRegionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateAWSRegionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateAWSRegionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateAWSRegionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateAWSRegionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/create_consul.go b/operations/service_discovery/create_consul.go new file mode 100644 index 00000000..adf1a8db --- /dev/null +++ b/operations/service_discovery/create_consul.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateConsulHandlerFunc turns a function with the right signature into a create consul handler +type CreateConsulHandlerFunc func(CreateConsulParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateConsulHandlerFunc) Handle(params CreateConsulParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateConsulHandler interface for that can handle valid create consul params +type CreateConsulHandler interface { + Handle(CreateConsulParams, interface{}) middleware.Responder +} + +// NewCreateConsul creates a new http.Handler for the create consul operation +func NewCreateConsul(ctx *middleware.Context, handler CreateConsulHandler) *CreateConsul { + return &CreateConsul{Context: ctx, Handler: handler} +} + +/* + CreateConsul swagger:route POST /service_discovery/consul ServiceDiscovery createConsul + +# Add a new Consul server + +Adds a new Consul server. +*/ +type CreateConsul struct { + Context *middleware.Context + Handler CreateConsulHandler +} + +func (o *CreateConsul) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateConsulParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/create_consul_parameters.go b/operations/service_discovery/create_consul_parameters.go new file mode 100644 index 00000000..5ab49ad7 --- /dev/null +++ b/operations/service_discovery/create_consul_parameters.go @@ -0,0 +1,93 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateConsulParams creates a new CreateConsulParams object +// +// There are no default values defined in the spec. +func NewCreateConsulParams() CreateConsulParams { + + return CreateConsulParams{} +} + +// CreateConsulParams contains all the bound params for the create consul operation +// typically these are obtained from a http.Request +// +// swagger:parameters createConsul +type CreateConsulParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Consul +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateConsulParams() beforehand. +func (o *CreateConsulParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Consul + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/service_discovery/create_consul_responses.go b/operations/service_discovery/create_consul_responses.go new file mode 100644 index 00000000..1e1ec03c --- /dev/null +++ b/operations/service_discovery/create_consul_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateConsulCreatedCode is the HTTP code returned for type CreateConsulCreated +const CreateConsulCreatedCode int = 201 + +/* +CreateConsulCreated Consul created + +swagger:response createConsulCreated +*/ +type CreateConsulCreated struct { + + /* + In: Body + */ + Payload *models.Consul `json:"body,omitempty"` +} + +// NewCreateConsulCreated creates CreateConsulCreated with default headers values +func NewCreateConsulCreated() *CreateConsulCreated { + + return &CreateConsulCreated{} +} + +// WithPayload adds the payload to the create consul created response +func (o *CreateConsulCreated) WithPayload(payload *models.Consul) *CreateConsulCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create consul created response +func (o *CreateConsulCreated) SetPayload(payload *models.Consul) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateConsulCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateConsulBadRequestCode is the HTTP code returned for type CreateConsulBadRequest +const CreateConsulBadRequestCode int = 400 + +/* +CreateConsulBadRequest Bad request + +swagger:response createConsulBadRequest +*/ +type CreateConsulBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateConsulBadRequest creates CreateConsulBadRequest with default headers values +func NewCreateConsulBadRequest() *CreateConsulBadRequest { + + return &CreateConsulBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create consul bad request response +func (o *CreateConsulBadRequest) WithConfigurationVersion(configurationVersion string) *CreateConsulBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create consul bad request response +func (o *CreateConsulBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create consul bad request response +func (o *CreateConsulBadRequest) WithPayload(payload *models.Error) *CreateConsulBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create consul bad request response +func (o *CreateConsulBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateConsulBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateConsulConflictCode is the HTTP code returned for type CreateConsulConflict +const CreateConsulConflictCode int = 409 + +/* +CreateConsulConflict The specified resource already exists + +swagger:response createConsulConflict +*/ +type CreateConsulConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateConsulConflict creates CreateConsulConflict with default headers values +func NewCreateConsulConflict() *CreateConsulConflict { + + return &CreateConsulConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create consul conflict response +func (o *CreateConsulConflict) WithConfigurationVersion(configurationVersion string) *CreateConsulConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create consul conflict response +func (o *CreateConsulConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create consul conflict response +func (o *CreateConsulConflict) WithPayload(payload *models.Error) *CreateConsulConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create consul conflict response +func (o *CreateConsulConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateConsulConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateConsulDefault General Error + +swagger:response createConsulDefault +*/ +type CreateConsulDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateConsulDefault creates CreateConsulDefault with default headers values +func NewCreateConsulDefault(code int) *CreateConsulDefault { + if code <= 0 { + code = 500 + } + + return &CreateConsulDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create consul default response +func (o *CreateConsulDefault) WithStatusCode(code int) *CreateConsulDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create consul default response +func (o *CreateConsulDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create consul default response +func (o *CreateConsulDefault) WithConfigurationVersion(configurationVersion string) *CreateConsulDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create consul default response +func (o *CreateConsulDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create consul default response +func (o *CreateConsulDefault) WithPayload(payload *models.Error) *CreateConsulDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create consul default response +func (o *CreateConsulDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateConsulDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/create_consul_urlbuilder.go b/operations/service_discovery/create_consul_urlbuilder.go new file mode 100644 index 00000000..40a391ba --- /dev/null +++ b/operations/service_discovery/create_consul_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateConsulURL generates an URL for the create consul operation +type CreateConsulURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateConsulURL) WithBasePath(bp string) *CreateConsulURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateConsulURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateConsulURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/consul" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateConsulURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateConsulURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateConsulURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateConsulURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateConsulURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateConsulURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/delete_a_w_s_region.go b/operations/service_discovery/delete_a_w_s_region.go new file mode 100644 index 00000000..b77b07f5 --- /dev/null +++ b/operations/service_discovery/delete_a_w_s_region.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteAWSRegionHandlerFunc turns a function with the right signature into a delete a w s region handler +type DeleteAWSRegionHandlerFunc func(DeleteAWSRegionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteAWSRegionHandlerFunc) Handle(params DeleteAWSRegionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteAWSRegionHandler interface for that can handle valid delete a w s region params +type DeleteAWSRegionHandler interface { + Handle(DeleteAWSRegionParams, interface{}) middleware.Responder +} + +// NewDeleteAWSRegion creates a new http.Handler for the delete a w s region operation +func NewDeleteAWSRegion(ctx *middleware.Context, handler DeleteAWSRegionHandler) *DeleteAWSRegion { + return &DeleteAWSRegion{Context: ctx, Handler: handler} +} + +/* + DeleteAWSRegion swagger:route DELETE /service_discovery/aws/{id} ServiceDiscovery deleteAWSRegion + +# Delete an AWS region + +Delete an AWS region configuration by it's id. +*/ +type DeleteAWSRegion struct { + Context *middleware.Context + Handler DeleteAWSRegionHandler +} + +func (o *DeleteAWSRegion) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteAWSRegionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/delete_a_w_s_region_parameters.go b/operations/service_discovery/delete_a_w_s_region_parameters.go new file mode 100644 index 00000000..4af97dd3 --- /dev/null +++ b/operations/service_discovery/delete_a_w_s_region_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteAWSRegionParams creates a new DeleteAWSRegionParams object +// +// There are no default values defined in the spec. +func NewDeleteAWSRegionParams() DeleteAWSRegionParams { + + return DeleteAWSRegionParams{} +} + +// DeleteAWSRegionParams contains all the bound params for the delete a w s region operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteAWSRegion +type DeleteAWSRegionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*AWS region ID + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteAWSRegionParams() beforehand. +func (o *DeleteAWSRegionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteAWSRegionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/operations/service_discovery/delete_a_w_s_region_responses.go b/operations/service_discovery/delete_a_w_s_region_responses.go new file mode 100644 index 00000000..47364ebd --- /dev/null +++ b/operations/service_discovery/delete_a_w_s_region_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteAWSRegionNoContentCode is the HTTP code returned for type DeleteAWSRegionNoContent +const DeleteAWSRegionNoContentCode int = 204 + +/* +DeleteAWSRegionNoContent Resource deleted + +swagger:response deleteAWSRegionNoContent +*/ +type DeleteAWSRegionNoContent struct { +} + +// NewDeleteAWSRegionNoContent creates DeleteAWSRegionNoContent with default headers values +func NewDeleteAWSRegionNoContent() *DeleteAWSRegionNoContent { + + return &DeleteAWSRegionNoContent{} +} + +// WriteResponse to the client +func (o *DeleteAWSRegionNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteAWSRegionNotFoundCode is the HTTP code returned for type DeleteAWSRegionNotFound +const DeleteAWSRegionNotFoundCode int = 404 + +/* +DeleteAWSRegionNotFound The specified resource was not found + +swagger:response deleteAWSRegionNotFound +*/ +type DeleteAWSRegionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteAWSRegionNotFound creates DeleteAWSRegionNotFound with default headers values +func NewDeleteAWSRegionNotFound() *DeleteAWSRegionNotFound { + + return &DeleteAWSRegionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete a w s region not found response +func (o *DeleteAWSRegionNotFound) WithConfigurationVersion(configurationVersion string) *DeleteAWSRegionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete a w s region not found response +func (o *DeleteAWSRegionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete a w s region not found response +func (o *DeleteAWSRegionNotFound) WithPayload(payload *models.Error) *DeleteAWSRegionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete a w s region not found response +func (o *DeleteAWSRegionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteAWSRegionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteAWSRegionDefault General Error + +swagger:response deleteAWSRegionDefault +*/ +type DeleteAWSRegionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteAWSRegionDefault creates DeleteAWSRegionDefault with default headers values +func NewDeleteAWSRegionDefault(code int) *DeleteAWSRegionDefault { + if code <= 0 { + code = 500 + } + + return &DeleteAWSRegionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete a w s region default response +func (o *DeleteAWSRegionDefault) WithStatusCode(code int) *DeleteAWSRegionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete a w s region default response +func (o *DeleteAWSRegionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete a w s region default response +func (o *DeleteAWSRegionDefault) WithConfigurationVersion(configurationVersion string) *DeleteAWSRegionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete a w s region default response +func (o *DeleteAWSRegionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete a w s region default response +func (o *DeleteAWSRegionDefault) WithPayload(payload *models.Error) *DeleteAWSRegionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete a w s region default response +func (o *DeleteAWSRegionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteAWSRegionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/delete_a_w_s_region_urlbuilder.go b/operations/service_discovery/delete_a_w_s_region_urlbuilder.go new file mode 100644 index 00000000..5f00ecd8 --- /dev/null +++ b/operations/service_discovery/delete_a_w_s_region_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteAWSRegionURL generates an URL for the delete a w s region operation +type DeleteAWSRegionURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteAWSRegionURL) WithBasePath(bp string) *DeleteAWSRegionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteAWSRegionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteAWSRegionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/aws/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteAWSRegionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteAWSRegionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteAWSRegionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteAWSRegionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteAWSRegionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteAWSRegionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteAWSRegionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/delete_consul.go b/operations/service_discovery/delete_consul.go new file mode 100644 index 00000000..473a5f62 --- /dev/null +++ b/operations/service_discovery/delete_consul.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteConsulHandlerFunc turns a function with the right signature into a delete consul handler +type DeleteConsulHandlerFunc func(DeleteConsulParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteConsulHandlerFunc) Handle(params DeleteConsulParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteConsulHandler interface for that can handle valid delete consul params +type DeleteConsulHandler interface { + Handle(DeleteConsulParams, interface{}) middleware.Responder +} + +// NewDeleteConsul creates a new http.Handler for the delete consul operation +func NewDeleteConsul(ctx *middleware.Context, handler DeleteConsulHandler) *DeleteConsul { + return &DeleteConsul{Context: ctx, Handler: handler} +} + +/* + DeleteConsul swagger:route DELETE /service_discovery/consul/{id} ServiceDiscovery deleteConsul + +# Delete a Consul server + +Deletes a Consul server configuration by it's id. +*/ +type DeleteConsul struct { + Context *middleware.Context + Handler DeleteConsulHandler +} + +func (o *DeleteConsul) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteConsulParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/delete_consul_parameters.go b/operations/service_discovery/delete_consul_parameters.go new file mode 100644 index 00000000..6584bb65 --- /dev/null +++ b/operations/service_discovery/delete_consul_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteConsulParams creates a new DeleteConsulParams object +// +// There are no default values defined in the spec. +func NewDeleteConsulParams() DeleteConsulParams { + + return DeleteConsulParams{} +} + +// DeleteConsulParams contains all the bound params for the delete consul operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteConsul +type DeleteConsulParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Consul server Index + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteConsulParams() beforehand. +func (o *DeleteConsulParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteConsulParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/operations/service_discovery/delete_consul_responses.go b/operations/service_discovery/delete_consul_responses.go new file mode 100644 index 00000000..8641b0e8 --- /dev/null +++ b/operations/service_discovery/delete_consul_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteConsulNoContentCode is the HTTP code returned for type DeleteConsulNoContent +const DeleteConsulNoContentCode int = 204 + +/* +DeleteConsulNoContent Consul server deleted + +swagger:response deleteConsulNoContent +*/ +type DeleteConsulNoContent struct { +} + +// NewDeleteConsulNoContent creates DeleteConsulNoContent with default headers values +func NewDeleteConsulNoContent() *DeleteConsulNoContent { + + return &DeleteConsulNoContent{} +} + +// WriteResponse to the client +func (o *DeleteConsulNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteConsulNotFoundCode is the HTTP code returned for type DeleteConsulNotFound +const DeleteConsulNotFoundCode int = 404 + +/* +DeleteConsulNotFound The specified resource was not found + +swagger:response deleteConsulNotFound +*/ +type DeleteConsulNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConsulNotFound creates DeleteConsulNotFound with default headers values +func NewDeleteConsulNotFound() *DeleteConsulNotFound { + + return &DeleteConsulNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete consul not found response +func (o *DeleteConsulNotFound) WithConfigurationVersion(configurationVersion string) *DeleteConsulNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete consul not found response +func (o *DeleteConsulNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete consul not found response +func (o *DeleteConsulNotFound) WithPayload(payload *models.Error) *DeleteConsulNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete consul not found response +func (o *DeleteConsulNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConsulNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteConsulDefault General Error + +swagger:response deleteConsulDefault +*/ +type DeleteConsulDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConsulDefault creates DeleteConsulDefault with default headers values +func NewDeleteConsulDefault(code int) *DeleteConsulDefault { + if code <= 0 { + code = 500 + } + + return &DeleteConsulDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete consul default response +func (o *DeleteConsulDefault) WithStatusCode(code int) *DeleteConsulDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete consul default response +func (o *DeleteConsulDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete consul default response +func (o *DeleteConsulDefault) WithConfigurationVersion(configurationVersion string) *DeleteConsulDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete consul default response +func (o *DeleteConsulDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete consul default response +func (o *DeleteConsulDefault) WithPayload(payload *models.Error) *DeleteConsulDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete consul default response +func (o *DeleteConsulDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConsulDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/delete_consul_urlbuilder.go b/operations/service_discovery/delete_consul_urlbuilder.go new file mode 100644 index 00000000..8be789ed --- /dev/null +++ b/operations/service_discovery/delete_consul_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteConsulURL generates an URL for the delete consul operation +type DeleteConsulURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConsulURL) WithBasePath(bp string) *DeleteConsulURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConsulURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteConsulURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/consul/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteConsulURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteConsulURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteConsulURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteConsulURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteConsulURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteConsulURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteConsulURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/get_a_w_s_region.go b/operations/service_discovery/get_a_w_s_region.go new file mode 100644 index 00000000..c1126233 --- /dev/null +++ b/operations/service_discovery/get_a_w_s_region.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAWSRegionHandlerFunc turns a function with the right signature into a get a w s region handler +type GetAWSRegionHandlerFunc func(GetAWSRegionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAWSRegionHandlerFunc) Handle(params GetAWSRegionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAWSRegionHandler interface for that can handle valid get a w s region params +type GetAWSRegionHandler interface { + Handle(GetAWSRegionParams, interface{}) middleware.Responder +} + +// NewGetAWSRegion creates a new http.Handler for the get a w s region operation +func NewGetAWSRegion(ctx *middleware.Context, handler GetAWSRegionHandler) *GetAWSRegion { + return &GetAWSRegion{Context: ctx, Handler: handler} +} + +/* + GetAWSRegion swagger:route GET /service_discovery/aws/{id} ServiceDiscovery getAWSRegion + +# Return an AWS region + +Return one AWS Region configuration by it's id. +*/ +type GetAWSRegion struct { + Context *middleware.Context + Handler GetAWSRegionHandler +} + +func (o *GetAWSRegion) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAWSRegionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/get_a_w_s_region_parameters.go b/operations/service_discovery/get_a_w_s_region_parameters.go new file mode 100644 index 00000000..4f856613 --- /dev/null +++ b/operations/service_discovery/get_a_w_s_region_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAWSRegionParams creates a new GetAWSRegionParams object +// +// There are no default values defined in the spec. +func NewGetAWSRegionParams() GetAWSRegionParams { + + return GetAWSRegionParams{} +} + +// GetAWSRegionParams contains all the bound params for the get a w s region operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAWSRegion +type GetAWSRegionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*AWS region id + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAWSRegionParams() beforehand. +func (o *GetAWSRegionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetAWSRegionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/operations/service_discovery/get_a_w_s_region_responses.go b/operations/service_discovery/get_a_w_s_region_responses.go new file mode 100644 index 00000000..9383e63a --- /dev/null +++ b/operations/service_discovery/get_a_w_s_region_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAWSRegionOKCode is the HTTP code returned for type GetAWSRegionOK +const GetAWSRegionOKCode int = 200 + +/* +GetAWSRegionOK Successful operation + +swagger:response getAWSRegionOK +*/ +type GetAWSRegionOK struct { + + /* + In: Body + */ + Payload *models.AwsRegion `json:"body,omitempty"` +} + +// NewGetAWSRegionOK creates GetAWSRegionOK with default headers values +func NewGetAWSRegionOK() *GetAWSRegionOK { + + return &GetAWSRegionOK{} +} + +// WithPayload adds the payload to the get a w s region o k response +func (o *GetAWSRegionOK) WithPayload(payload *models.AwsRegion) *GetAWSRegionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get a w s region o k response +func (o *GetAWSRegionOK) SetPayload(payload *models.AwsRegion) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAWSRegionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetAWSRegionNotFoundCode is the HTTP code returned for type GetAWSRegionNotFound +const GetAWSRegionNotFoundCode int = 404 + +/* +GetAWSRegionNotFound The specified resource was not found + +swagger:response getAWSRegionNotFound +*/ +type GetAWSRegionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAWSRegionNotFound creates GetAWSRegionNotFound with default headers values +func NewGetAWSRegionNotFound() *GetAWSRegionNotFound { + + return &GetAWSRegionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get a w s region not found response +func (o *GetAWSRegionNotFound) WithConfigurationVersion(configurationVersion string) *GetAWSRegionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get a w s region not found response +func (o *GetAWSRegionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get a w s region not found response +func (o *GetAWSRegionNotFound) WithPayload(payload *models.Error) *GetAWSRegionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get a w s region not found response +func (o *GetAWSRegionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAWSRegionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAWSRegionDefault General Error + +swagger:response getAWSRegionDefault +*/ +type GetAWSRegionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAWSRegionDefault creates GetAWSRegionDefault with default headers values +func NewGetAWSRegionDefault(code int) *GetAWSRegionDefault { + if code <= 0 { + code = 500 + } + + return &GetAWSRegionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get a w s region default response +func (o *GetAWSRegionDefault) WithStatusCode(code int) *GetAWSRegionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get a w s region default response +func (o *GetAWSRegionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get a w s region default response +func (o *GetAWSRegionDefault) WithConfigurationVersion(configurationVersion string) *GetAWSRegionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get a w s region default response +func (o *GetAWSRegionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get a w s region default response +func (o *GetAWSRegionDefault) WithPayload(payload *models.Error) *GetAWSRegionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get a w s region default response +func (o *GetAWSRegionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAWSRegionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/get_a_w_s_region_urlbuilder.go b/operations/service_discovery/get_a_w_s_region_urlbuilder.go new file mode 100644 index 00000000..363cd8fd --- /dev/null +++ b/operations/service_discovery/get_a_w_s_region_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAWSRegionURL generates an URL for the get a w s region operation +type GetAWSRegionURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAWSRegionURL) WithBasePath(bp string) *GetAWSRegionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAWSRegionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAWSRegionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/aws/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetAWSRegionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAWSRegionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAWSRegionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAWSRegionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAWSRegionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAWSRegionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAWSRegionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/get_a_w_s_regions.go b/operations/service_discovery/get_a_w_s_regions.go new file mode 100644 index 00000000..81c8d0d2 --- /dev/null +++ b/operations/service_discovery/get_a_w_s_regions.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAWSRegionsHandlerFunc turns a function with the right signature into a get a w s regions handler +type GetAWSRegionsHandlerFunc func(GetAWSRegionsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAWSRegionsHandlerFunc) Handle(params GetAWSRegionsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAWSRegionsHandler interface for that can handle valid get a w s regions params +type GetAWSRegionsHandler interface { + Handle(GetAWSRegionsParams, interface{}) middleware.Responder +} + +// NewGetAWSRegions creates a new http.Handler for the get a w s regions operation +func NewGetAWSRegions(ctx *middleware.Context, handler GetAWSRegionsHandler) *GetAWSRegions { + return &GetAWSRegions{Context: ctx, Handler: handler} +} + +/* + GetAWSRegions swagger:route GET /service_discovery/aws ServiceDiscovery getAWSRegions + +# Return an array of all configured AWS regions + +Return all configured AWS regions. +*/ +type GetAWSRegions struct { + Context *middleware.Context + Handler GetAWSRegionsHandler +} + +func (o *GetAWSRegions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAWSRegionsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/get_a_w_s_regions_parameters.go b/operations/service_discovery/get_a_w_s_regions_parameters.go new file mode 100644 index 00000000..ad93d8be --- /dev/null +++ b/operations/service_discovery/get_a_w_s_regions_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAWSRegionsParams creates a new GetAWSRegionsParams object +// +// There are no default values defined in the spec. +func NewGetAWSRegionsParams() GetAWSRegionsParams { + + return GetAWSRegionsParams{} +} + +// GetAWSRegionsParams contains all the bound params for the get a w s regions operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAWSRegions +type GetAWSRegionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAWSRegionsParams() beforehand. +func (o *GetAWSRegionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/service_discovery/get_a_w_s_regions_responses.go b/operations/service_discovery/get_a_w_s_regions_responses.go new file mode 100644 index 00000000..9ee4e7ca --- /dev/null +++ b/operations/service_discovery/get_a_w_s_regions_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAWSRegionsOKCode is the HTTP code returned for type GetAWSRegionsOK +const GetAWSRegionsOKCode int = 200 + +/* +GetAWSRegionsOK Successful operation + +swagger:response getAWSRegionsOK +*/ +type GetAWSRegionsOK struct { + + /* + In: Body + */ + Payload models.AwsRegions `json:"body,omitempty"` +} + +// NewGetAWSRegionsOK creates GetAWSRegionsOK with default headers values +func NewGetAWSRegionsOK() *GetAWSRegionsOK { + + return &GetAWSRegionsOK{} +} + +// WithPayload adds the payload to the get a w s regions o k response +func (o *GetAWSRegionsOK) WithPayload(payload models.AwsRegions) *GetAWSRegionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get a w s regions o k response +func (o *GetAWSRegionsOK) SetPayload(payload models.AwsRegions) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAWSRegionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.AwsRegions{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAWSRegionsDefault General Error + +swagger:response getAWSRegionsDefault +*/ +type GetAWSRegionsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAWSRegionsDefault creates GetAWSRegionsDefault with default headers values +func NewGetAWSRegionsDefault(code int) *GetAWSRegionsDefault { + if code <= 0 { + code = 500 + } + + return &GetAWSRegionsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get a w s regions default response +func (o *GetAWSRegionsDefault) WithStatusCode(code int) *GetAWSRegionsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get a w s regions default response +func (o *GetAWSRegionsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get a w s regions default response +func (o *GetAWSRegionsDefault) WithConfigurationVersion(configurationVersion string) *GetAWSRegionsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get a w s regions default response +func (o *GetAWSRegionsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get a w s regions default response +func (o *GetAWSRegionsDefault) WithPayload(payload *models.Error) *GetAWSRegionsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get a w s regions default response +func (o *GetAWSRegionsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAWSRegionsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/get_a_w_s_regions_urlbuilder.go b/operations/service_discovery/get_a_w_s_regions_urlbuilder.go new file mode 100644 index 00000000..51369a4f --- /dev/null +++ b/operations/service_discovery/get_a_w_s_regions_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAWSRegionsURL generates an URL for the get a w s regions operation +type GetAWSRegionsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAWSRegionsURL) WithBasePath(bp string) *GetAWSRegionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAWSRegionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAWSRegionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/aws" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAWSRegionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAWSRegionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAWSRegionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAWSRegionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAWSRegionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAWSRegionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/get_consul.go b/operations/service_discovery/get_consul.go new file mode 100644 index 00000000..6dd839e7 --- /dev/null +++ b/operations/service_discovery/get_consul.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetConsulHandlerFunc turns a function with the right signature into a get consul handler +type GetConsulHandlerFunc func(GetConsulParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetConsulHandlerFunc) Handle(params GetConsulParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetConsulHandler interface for that can handle valid get consul params +type GetConsulHandler interface { + Handle(GetConsulParams, interface{}) middleware.Responder +} + +// NewGetConsul creates a new http.Handler for the get consul operation +func NewGetConsul(ctx *middleware.Context, handler GetConsulHandler) *GetConsul { + return &GetConsul{Context: ctx, Handler: handler} +} + +/* + GetConsul swagger:route GET /service_discovery/consul/{id} ServiceDiscovery getConsul + +# Return one Consul server + +Returns one Consul server configuration by it's id. +*/ +type GetConsul struct { + Context *middleware.Context + Handler GetConsulHandler +} + +func (o *GetConsul) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetConsulParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/get_consul_parameters.go b/operations/service_discovery/get_consul_parameters.go new file mode 100644 index 00000000..02938d18 --- /dev/null +++ b/operations/service_discovery/get_consul_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetConsulParams creates a new GetConsulParams object +// +// There are no default values defined in the spec. +func NewGetConsulParams() GetConsulParams { + + return GetConsulParams{} +} + +// GetConsulParams contains all the bound params for the get consul operation +// typically these are obtained from a http.Request +// +// swagger:parameters getConsul +type GetConsulParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Consul server id + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetConsulParams() beforehand. +func (o *GetConsulParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetConsulParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/operations/service_discovery/get_consul_responses.go b/operations/service_discovery/get_consul_responses.go new file mode 100644 index 00000000..69288298 --- /dev/null +++ b/operations/service_discovery/get_consul_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetConsulOKCode is the HTTP code returned for type GetConsulOK +const GetConsulOKCode int = 200 + +/* +GetConsulOK Successful operation + +swagger:response getConsulOK +*/ +type GetConsulOK struct { + + /* + In: Body + */ + Payload *models.Consul `json:"body,omitempty"` +} + +// NewGetConsulOK creates GetConsulOK with default headers values +func NewGetConsulOK() *GetConsulOK { + + return &GetConsulOK{} +} + +// WithPayload adds the payload to the get consul o k response +func (o *GetConsulOK) WithPayload(payload *models.Consul) *GetConsulOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get consul o k response +func (o *GetConsulOK) SetPayload(payload *models.Consul) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConsulOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConsulNotFoundCode is the HTTP code returned for type GetConsulNotFound +const GetConsulNotFoundCode int = 404 + +/* +GetConsulNotFound The specified resource was not found + +swagger:response getConsulNotFound +*/ +type GetConsulNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConsulNotFound creates GetConsulNotFound with default headers values +func NewGetConsulNotFound() *GetConsulNotFound { + + return &GetConsulNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get consul not found response +func (o *GetConsulNotFound) WithConfigurationVersion(configurationVersion string) *GetConsulNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get consul not found response +func (o *GetConsulNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get consul not found response +func (o *GetConsulNotFound) WithPayload(payload *models.Error) *GetConsulNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get consul not found response +func (o *GetConsulNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConsulNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetConsulDefault General Error + +swagger:response getConsulDefault +*/ +type GetConsulDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConsulDefault creates GetConsulDefault with default headers values +func NewGetConsulDefault(code int) *GetConsulDefault { + if code <= 0 { + code = 500 + } + + return &GetConsulDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get consul default response +func (o *GetConsulDefault) WithStatusCode(code int) *GetConsulDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get consul default response +func (o *GetConsulDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get consul default response +func (o *GetConsulDefault) WithConfigurationVersion(configurationVersion string) *GetConsulDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get consul default response +func (o *GetConsulDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get consul default response +func (o *GetConsulDefault) WithPayload(payload *models.Error) *GetConsulDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get consul default response +func (o *GetConsulDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConsulDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/get_consul_urlbuilder.go b/operations/service_discovery/get_consul_urlbuilder.go new file mode 100644 index 00000000..67b838ef --- /dev/null +++ b/operations/service_discovery/get_consul_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetConsulURL generates an URL for the get consul operation +type GetConsulURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConsulURL) WithBasePath(bp string) *GetConsulURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConsulURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetConsulURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/consul/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetConsulURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetConsulURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetConsulURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetConsulURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetConsulURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetConsulURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetConsulURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/get_consuls.go b/operations/service_discovery/get_consuls.go new file mode 100644 index 00000000..a05d187d --- /dev/null +++ b/operations/service_discovery/get_consuls.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetConsulsHandlerFunc turns a function with the right signature into a get consuls handler +type GetConsulsHandlerFunc func(GetConsulsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetConsulsHandlerFunc) Handle(params GetConsulsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetConsulsHandler interface for that can handle valid get consuls params +type GetConsulsHandler interface { + Handle(GetConsulsParams, interface{}) middleware.Responder +} + +// NewGetConsuls creates a new http.Handler for the get consuls operation +func NewGetConsuls(ctx *middleware.Context, handler GetConsulsHandler) *GetConsuls { + return &GetConsuls{Context: ctx, Handler: handler} +} + +/* + GetConsuls swagger:route GET /service_discovery/consul ServiceDiscovery getConsuls + +# Return an array of all configured Consul servers + +Returns all configured Consul servers. +*/ +type GetConsuls struct { + Context *middleware.Context + Handler GetConsulsHandler +} + +func (o *GetConsuls) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetConsulsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/get_consuls_parameters.go b/operations/service_discovery/get_consuls_parameters.go new file mode 100644 index 00000000..14c80468 --- /dev/null +++ b/operations/service_discovery/get_consuls_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetConsulsParams creates a new GetConsulsParams object +// +// There are no default values defined in the spec. +func NewGetConsulsParams() GetConsulsParams { + + return GetConsulsParams{} +} + +// GetConsulsParams contains all the bound params for the get consuls operation +// typically these are obtained from a http.Request +// +// swagger:parameters getConsuls +type GetConsulsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetConsulsParams() beforehand. +func (o *GetConsulsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/service_discovery/get_consuls_responses.go b/operations/service_discovery/get_consuls_responses.go new file mode 100644 index 00000000..b43fd2f3 --- /dev/null +++ b/operations/service_discovery/get_consuls_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetConsulsOKCode is the HTTP code returned for type GetConsulsOK +const GetConsulsOKCode int = 200 + +/* +GetConsulsOK Successful operation + +swagger:response getConsulsOK +*/ +type GetConsulsOK struct { + + /* + In: Body + */ + Payload models.Consuls `json:"body,omitempty"` +} + +// NewGetConsulsOK creates GetConsulsOK with default headers values +func NewGetConsulsOK() *GetConsulsOK { + + return &GetConsulsOK{} +} + +// WithPayload adds the payload to the get consuls o k response +func (o *GetConsulsOK) WithPayload(payload models.Consuls) *GetConsulsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get consuls o k response +func (o *GetConsulsOK) SetPayload(payload models.Consuls) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConsulsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Consuls{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetConsulsDefault General Error + +swagger:response getConsulsDefault +*/ +type GetConsulsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConsulsDefault creates GetConsulsDefault with default headers values +func NewGetConsulsDefault(code int) *GetConsulsDefault { + if code <= 0 { + code = 500 + } + + return &GetConsulsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get consuls default response +func (o *GetConsulsDefault) WithStatusCode(code int) *GetConsulsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get consuls default response +func (o *GetConsulsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get consuls default response +func (o *GetConsulsDefault) WithConfigurationVersion(configurationVersion string) *GetConsulsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get consuls default response +func (o *GetConsulsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get consuls default response +func (o *GetConsulsDefault) WithPayload(payload *models.Error) *GetConsulsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get consuls default response +func (o *GetConsulsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConsulsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/get_consuls_urlbuilder.go b/operations/service_discovery/get_consuls_urlbuilder.go new file mode 100644 index 00000000..7984adc2 --- /dev/null +++ b/operations/service_discovery/get_consuls_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetConsulsURL generates an URL for the get consuls operation +type GetConsulsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConsulsURL) WithBasePath(bp string) *GetConsulsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConsulsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetConsulsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/consul" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetConsulsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetConsulsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetConsulsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetConsulsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetConsulsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetConsulsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/replace_a_w_s_region.go b/operations/service_discovery/replace_a_w_s_region.go new file mode 100644 index 00000000..966351be --- /dev/null +++ b/operations/service_discovery/replace_a_w_s_region.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAWSRegionHandlerFunc turns a function with the right signature into a replace a w s region handler +type ReplaceAWSRegionHandlerFunc func(ReplaceAWSRegionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAWSRegionHandlerFunc) Handle(params ReplaceAWSRegionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAWSRegionHandler interface for that can handle valid replace a w s region params +type ReplaceAWSRegionHandler interface { + Handle(ReplaceAWSRegionParams, interface{}) middleware.Responder +} + +// NewReplaceAWSRegion creates a new http.Handler for the replace a w s region operation +func NewReplaceAWSRegion(ctx *middleware.Context, handler ReplaceAWSRegionHandler) *ReplaceAWSRegion { + return &ReplaceAWSRegion{Context: ctx, Handler: handler} +} + +/* + ReplaceAWSRegion swagger:route PUT /service_discovery/aws/{id} ServiceDiscovery replaceAWSRegion + +# Replace an AWS region + +Replace an AWS region configuration by its id. +*/ +type ReplaceAWSRegion struct { + Context *middleware.Context + Handler ReplaceAWSRegionHandler +} + +func (o *ReplaceAWSRegion) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAWSRegionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/replace_a_w_s_region_parameters.go b/operations/service_discovery/replace_a_w_s_region_parameters.go new file mode 100644 index 00000000..4420b391 --- /dev/null +++ b/operations/service_discovery/replace_a_w_s_region_parameters.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAWSRegionParams creates a new ReplaceAWSRegionParams object +// +// There are no default values defined in the spec. +func NewReplaceAWSRegionParams() ReplaceAWSRegionParams { + + return ReplaceAWSRegionParams{} +} + +// ReplaceAWSRegionParams contains all the bound params for the replace a w s region operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAWSRegion +type ReplaceAWSRegionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.AwsRegion + /*AWS Region ID + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAWSRegionParams() beforehand. +func (o *ReplaceAWSRegionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.AwsRegion + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ReplaceAWSRegionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/operations/service_discovery/replace_a_w_s_region_responses.go b/operations/service_discovery/replace_a_w_s_region_responses.go new file mode 100644 index 00000000..cd6441f3 --- /dev/null +++ b/operations/service_discovery/replace_a_w_s_region_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAWSRegionOKCode is the HTTP code returned for type ReplaceAWSRegionOK +const ReplaceAWSRegionOKCode int = 200 + +/* +ReplaceAWSRegionOK Resource updated + +swagger:response replaceAWSRegionOK +*/ +type ReplaceAWSRegionOK struct { + + /* + In: Body + */ + Payload *models.AwsRegion `json:"body,omitempty"` +} + +// NewReplaceAWSRegionOK creates ReplaceAWSRegionOK with default headers values +func NewReplaceAWSRegionOK() *ReplaceAWSRegionOK { + + return &ReplaceAWSRegionOK{} +} + +// WithPayload adds the payload to the replace a w s region o k response +func (o *ReplaceAWSRegionOK) WithPayload(payload *models.AwsRegion) *ReplaceAWSRegionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace a w s region o k response +func (o *ReplaceAWSRegionOK) SetPayload(payload *models.AwsRegion) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAWSRegionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceAWSRegionBadRequestCode is the HTTP code returned for type ReplaceAWSRegionBadRequest +const ReplaceAWSRegionBadRequestCode int = 400 + +/* +ReplaceAWSRegionBadRequest Bad request + +swagger:response replaceAWSRegionBadRequest +*/ +type ReplaceAWSRegionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAWSRegionBadRequest creates ReplaceAWSRegionBadRequest with default headers values +func NewReplaceAWSRegionBadRequest() *ReplaceAWSRegionBadRequest { + + return &ReplaceAWSRegionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace a w s region bad request response +func (o *ReplaceAWSRegionBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAWSRegionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace a w s region bad request response +func (o *ReplaceAWSRegionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace a w s region bad request response +func (o *ReplaceAWSRegionBadRequest) WithPayload(payload *models.Error) *ReplaceAWSRegionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace a w s region bad request response +func (o *ReplaceAWSRegionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAWSRegionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceAWSRegionNotFoundCode is the HTTP code returned for type ReplaceAWSRegionNotFound +const ReplaceAWSRegionNotFoundCode int = 404 + +/* +ReplaceAWSRegionNotFound The specified resource was not found + +swagger:response replaceAWSRegionNotFound +*/ +type ReplaceAWSRegionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAWSRegionNotFound creates ReplaceAWSRegionNotFound with default headers values +func NewReplaceAWSRegionNotFound() *ReplaceAWSRegionNotFound { + + return &ReplaceAWSRegionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace a w s region not found response +func (o *ReplaceAWSRegionNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceAWSRegionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace a w s region not found response +func (o *ReplaceAWSRegionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace a w s region not found response +func (o *ReplaceAWSRegionNotFound) WithPayload(payload *models.Error) *ReplaceAWSRegionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace a w s region not found response +func (o *ReplaceAWSRegionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAWSRegionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAWSRegionDefault General Error + +swagger:response replaceAWSRegionDefault +*/ +type ReplaceAWSRegionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAWSRegionDefault creates ReplaceAWSRegionDefault with default headers values +func NewReplaceAWSRegionDefault(code int) *ReplaceAWSRegionDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAWSRegionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace a w s region default response +func (o *ReplaceAWSRegionDefault) WithStatusCode(code int) *ReplaceAWSRegionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace a w s region default response +func (o *ReplaceAWSRegionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace a w s region default response +func (o *ReplaceAWSRegionDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAWSRegionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace a w s region default response +func (o *ReplaceAWSRegionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace a w s region default response +func (o *ReplaceAWSRegionDefault) WithPayload(payload *models.Error) *ReplaceAWSRegionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace a w s region default response +func (o *ReplaceAWSRegionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAWSRegionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/replace_a_w_s_region_urlbuilder.go b/operations/service_discovery/replace_a_w_s_region_urlbuilder.go new file mode 100644 index 00000000..7debc427 --- /dev/null +++ b/operations/service_discovery/replace_a_w_s_region_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ReplaceAWSRegionURL generates an URL for the replace a w s region operation +type ReplaceAWSRegionURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAWSRegionURL) WithBasePath(bp string) *ReplaceAWSRegionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAWSRegionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAWSRegionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/aws/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ReplaceAWSRegionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAWSRegionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAWSRegionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAWSRegionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAWSRegionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAWSRegionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAWSRegionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/service_discovery/replace_consul.go b/operations/service_discovery/replace_consul.go new file mode 100644 index 00000000..233083cb --- /dev/null +++ b/operations/service_discovery/replace_consul.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceConsulHandlerFunc turns a function with the right signature into a replace consul handler +type ReplaceConsulHandlerFunc func(ReplaceConsulParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceConsulHandlerFunc) Handle(params ReplaceConsulParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceConsulHandler interface for that can handle valid replace consul params +type ReplaceConsulHandler interface { + Handle(ReplaceConsulParams, interface{}) middleware.Responder +} + +// NewReplaceConsul creates a new http.Handler for the replace consul operation +func NewReplaceConsul(ctx *middleware.Context, handler ReplaceConsulHandler) *ReplaceConsul { + return &ReplaceConsul{Context: ctx, Handler: handler} +} + +/* + ReplaceConsul swagger:route PUT /service_discovery/consul/{id} ServiceDiscovery replaceConsul + +# Replace a Consul server + +Replaces a Consul server configuration by it's id. +*/ +type ReplaceConsul struct { + Context *middleware.Context + Handler ReplaceConsulHandler +} + +func (o *ReplaceConsul) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceConsulParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/service_discovery/replace_consul_parameters.go b/operations/service_discovery/replace_consul_parameters.go new file mode 100644 index 00000000..a583f78f --- /dev/null +++ b/operations/service_discovery/replace_consul_parameters.go @@ -0,0 +1,118 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceConsulParams creates a new ReplaceConsulParams object +// +// There are no default values defined in the spec. +func NewReplaceConsulParams() ReplaceConsulParams { + + return ReplaceConsulParams{} +} + +// ReplaceConsulParams contains all the bound params for the replace consul operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceConsul +type ReplaceConsulParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Consul + /*Consul Index + Required: true + In: path + */ + ID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceConsulParams() beforehand. +func (o *ReplaceConsulParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Consul + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *ReplaceConsulParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} diff --git a/operations/service_discovery/replace_consul_responses.go b/operations/service_discovery/replace_consul_responses.go new file mode 100644 index 00000000..24b08cb3 --- /dev/null +++ b/operations/service_discovery/replace_consul_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceConsulOKCode is the HTTP code returned for type ReplaceConsulOK +const ReplaceConsulOKCode int = 200 + +/* +ReplaceConsulOK Consul server replaced + +swagger:response replaceConsulOK +*/ +type ReplaceConsulOK struct { + + /* + In: Body + */ + Payload *models.Consul `json:"body,omitempty"` +} + +// NewReplaceConsulOK creates ReplaceConsulOK with default headers values +func NewReplaceConsulOK() *ReplaceConsulOK { + + return &ReplaceConsulOK{} +} + +// WithPayload adds the payload to the replace consul o k response +func (o *ReplaceConsulOK) WithPayload(payload *models.Consul) *ReplaceConsulOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace consul o k response +func (o *ReplaceConsulOK) SetPayload(payload *models.Consul) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceConsulOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceConsulBadRequestCode is the HTTP code returned for type ReplaceConsulBadRequest +const ReplaceConsulBadRequestCode int = 400 + +/* +ReplaceConsulBadRequest Bad request + +swagger:response replaceConsulBadRequest +*/ +type ReplaceConsulBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceConsulBadRequest creates ReplaceConsulBadRequest with default headers values +func NewReplaceConsulBadRequest() *ReplaceConsulBadRequest { + + return &ReplaceConsulBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace consul bad request response +func (o *ReplaceConsulBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceConsulBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace consul bad request response +func (o *ReplaceConsulBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace consul bad request response +func (o *ReplaceConsulBadRequest) WithPayload(payload *models.Error) *ReplaceConsulBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace consul bad request response +func (o *ReplaceConsulBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceConsulBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceConsulNotFoundCode is the HTTP code returned for type ReplaceConsulNotFound +const ReplaceConsulNotFoundCode int = 404 + +/* +ReplaceConsulNotFound The specified resource was not found + +swagger:response replaceConsulNotFound +*/ +type ReplaceConsulNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceConsulNotFound creates ReplaceConsulNotFound with default headers values +func NewReplaceConsulNotFound() *ReplaceConsulNotFound { + + return &ReplaceConsulNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace consul not found response +func (o *ReplaceConsulNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceConsulNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace consul not found response +func (o *ReplaceConsulNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace consul not found response +func (o *ReplaceConsulNotFound) WithPayload(payload *models.Error) *ReplaceConsulNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace consul not found response +func (o *ReplaceConsulNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceConsulNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceConsulDefault General Error + +swagger:response replaceConsulDefault +*/ +type ReplaceConsulDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceConsulDefault creates ReplaceConsulDefault with default headers values +func NewReplaceConsulDefault(code int) *ReplaceConsulDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceConsulDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace consul default response +func (o *ReplaceConsulDefault) WithStatusCode(code int) *ReplaceConsulDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace consul default response +func (o *ReplaceConsulDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace consul default response +func (o *ReplaceConsulDefault) WithConfigurationVersion(configurationVersion string) *ReplaceConsulDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace consul default response +func (o *ReplaceConsulDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace consul default response +func (o *ReplaceConsulDefault) WithPayload(payload *models.Error) *ReplaceConsulDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace consul default response +func (o *ReplaceConsulDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceConsulDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/service_discovery/replace_consul_urlbuilder.go b/operations/service_discovery/replace_consul_urlbuilder.go new file mode 100644 index 00000000..4b325830 --- /dev/null +++ b/operations/service_discovery/replace_consul_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package service_discovery + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// ReplaceConsulURL generates an URL for the replace consul operation +type ReplaceConsulURL struct { + ID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceConsulURL) WithBasePath(bp string) *ReplaceConsulURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceConsulURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceConsulURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/service_discovery/consul/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on ReplaceConsulURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceConsulURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceConsulURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceConsulURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceConsulURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceConsulURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceConsulURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/sites/create_site.go b/operations/sites/create_site.go index 07df65b1..d806c830 100644 --- a/operations/sites/create_site.go +++ b/operations/sites/create_site.go @@ -23,7 +23,7 @@ package sites import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // CreateSiteHandlerFunc turns a function with the right signature into a create site handler @@ -44,12 +44,12 @@ func NewCreateSite(ctx *middleware.Context, handler CreateSiteHandler) *CreateSi return &CreateSite{Context: ctx, Handler: handler} } -/*CreateSite swagger:route POST /services/haproxy/sites Sites createSite +/* + CreateSite swagger:route POST /services/haproxy/sites Sites createSite -Add a site +# Add a site Adds a new site to the configuration file. - */ type CreateSite struct { Context *middleware.Context @@ -59,21 +59,20 @@ type CreateSite struct { func (o *CreateSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewCreateSiteParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *CreateSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/sites/create_site_parameters.go b/operations/sites/create_site_parameters.go index 8c3a3cb4..d511ad29 100644 --- a/operations/sites/create_site_parameters.go +++ b/operations/sites/create_site_parameters.go @@ -27,11 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewCreateSiteParams creates a new CreateSiteParams object @@ -94,7 +93,7 @@ func (o *CreateSiteParams) BindRequest(r *http.Request, route *middleware.Matche var body models.Site if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -109,8 +108,9 @@ func (o *CreateSiteParams) BindRequest(r *http.Request, route *middleware.Matche } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) @@ -125,7 +125,6 @@ func (o *CreateSiteParams) BindRequest(r *http.Request, route *middleware.Matche if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -141,6 +140,7 @@ func (o *CreateSiteParams) bindForceReload(rawData []string, hasKey bool, format // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewCreateSiteParams() return nil @@ -164,10 +164,10 @@ func (o *CreateSiteParams) bindTransactionID(rawData []string, hasKey bool, form // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -182,6 +182,7 @@ func (o *CreateSiteParams) bindVersion(rawData []string, hasKey bool, formats st // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/sites/create_site_responses.go b/operations/sites/create_site_responses.go index 154b06aa..78297363 100644 --- a/operations/sites/create_site_responses.go +++ b/operations/sites/create_site_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // CreateSiteCreatedCode is the HTTP code returned for type CreateSiteCreated const CreateSiteCreatedCode int = 201 -/*CreateSiteCreated Site created +/* +CreateSiteCreated Site created swagger:response createSiteCreated */ @@ -76,7 +76,8 @@ func (o *CreateSiteCreated) WriteResponse(rw http.ResponseWriter, producer runti // CreateSiteAcceptedCode is the HTTP code returned for type CreateSiteAccepted const CreateSiteAcceptedCode int = 202 -/*CreateSiteAccepted Configuration change accepted and reload requested +/* +CreateSiteAccepted Configuration change accepted and reload requested swagger:response createSiteAccepted */ @@ -142,7 +143,8 @@ func (o *CreateSiteAccepted) WriteResponse(rw http.ResponseWriter, producer runt // CreateSiteBadRequestCode is the HTTP code returned for type CreateSiteBadRequest const CreateSiteBadRequestCode int = 400 -/*CreateSiteBadRequest Bad request +/* +CreateSiteBadRequest Bad request swagger:response createSiteBadRequest */ @@ -150,7 +152,7 @@ type CreateSiteBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewCreateSiteBadRequest() *CreateSiteBadRequest { } // WithConfigurationVersion adds the configurationVersion to the create site bad request response -func (o *CreateSiteBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateSiteBadRequest { +func (o *CreateSiteBadRequest) WithConfigurationVersion(configurationVersion string) *CreateSiteBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create site bad request response -func (o *CreateSiteBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateSiteBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *CreateSiteBadRequest) WriteResponse(rw http.ResponseWriter, producer ru // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *CreateSiteBadRequest) WriteResponse(rw http.ResponseWriter, producer ru // CreateSiteConflictCode is the HTTP code returned for type CreateSiteConflict const CreateSiteConflictCode int = 409 -/*CreateSiteConflict The specified resource already exists +/* +CreateSiteConflict The specified resource already exists swagger:response createSiteConflict */ @@ -216,7 +219,7 @@ type CreateSiteConflict struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewCreateSiteConflict() *CreateSiteConflict { } // WithConfigurationVersion adds the configurationVersion to the create site conflict response -func (o *CreateSiteConflict) WithConfigurationVersion(configurationVersion int64) *CreateSiteConflict { +func (o *CreateSiteConflict) WithConfigurationVersion(configurationVersion string) *CreateSiteConflict { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create site conflict response -func (o *CreateSiteConflict) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateSiteConflict) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *CreateSiteConflict) WriteResponse(rw http.ResponseWriter, producer runt // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *CreateSiteConflict) WriteResponse(rw http.ResponseWriter, producer runt } } -/*CreateSiteDefault General Error +/* +CreateSiteDefault General Error swagger:response createSiteDefault */ @@ -280,7 +284,7 @@ type CreateSiteDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *CreateSiteDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the create site default response -func (o *CreateSiteDefault) WithConfigurationVersion(configurationVersion int64) *CreateSiteDefault { +func (o *CreateSiteDefault) WithConfigurationVersion(configurationVersion string) *CreateSiteDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create site default response -func (o *CreateSiteDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateSiteDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *CreateSiteDefault) WriteResponse(rw http.ResponseWriter, producer runti // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/sites/create_site_urlbuilder.go b/operations/sites/create_site_urlbuilder.go index 13a8f413..9c9892d8 100644 --- a/operations/sites/create_site_urlbuilder.go +++ b/operations/sites/create_site_urlbuilder.go @@ -62,34 +62,34 @@ func (o *CreateSiteURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/sites/delete_site.go b/operations/sites/delete_site.go index f55a3dac..db8f6717 100644 --- a/operations/sites/delete_site.go +++ b/operations/sites/delete_site.go @@ -23,7 +23,7 @@ package sites import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // DeleteSiteHandlerFunc turns a function with the right signature into a delete site handler @@ -44,12 +44,12 @@ func NewDeleteSite(ctx *middleware.Context, handler DeleteSiteHandler) *DeleteSi return &DeleteSite{Context: ctx, Handler: handler} } -/*DeleteSite swagger:route DELETE /services/haproxy/sites/{name} Sites deleteSite +/* + DeleteSite swagger:route DELETE /services/haproxy/sites/{name} Sites deleteSite -Delete a site +# Delete a site Deletes a site from the configuration by it's name. - */ type DeleteSite struct { Context *middleware.Context @@ -59,21 +59,20 @@ type DeleteSite struct { func (o *DeleteSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewDeleteSiteParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *DeleteSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/sites/delete_site_parameters.go b/operations/sites/delete_site_parameters.go index 5b126d63..470df2f2 100644 --- a/operations/sites/delete_site_parameters.go +++ b/operations/sites/delete_site_parameters.go @@ -26,9 +26,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) // NewDeleteSiteParams creates a new DeleteSiteParams object @@ -105,7 +104,6 @@ func (o *DeleteSiteParams) BindRequest(r *http.Request, route *middleware.Matche if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -121,6 +119,7 @@ func (o *DeleteSiteParams) bindForceReload(rawData []string, hasKey bool, format // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewDeleteSiteParams() return nil @@ -144,7 +143,6 @@ func (o *DeleteSiteParams) bindName(rawData []string, hasKey bool, formats strfm // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -159,10 +157,10 @@ func (o *DeleteSiteParams) bindTransactionID(rawData []string, hasKey bool, form // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -177,6 +175,7 @@ func (o *DeleteSiteParams) bindVersion(rawData []string, hasKey bool, formats st // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/sites/delete_site_responses.go b/operations/sites/delete_site_responses.go index d93f0779..f9a50791 100644 --- a/operations/sites/delete_site_responses.go +++ b/operations/sites/delete_site_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // DeleteSiteAcceptedCode is the HTTP code returned for type DeleteSiteAccepted const DeleteSiteAcceptedCode int = 202 -/*DeleteSiteAccepted Configuration change accepted and reload requested +/* +DeleteSiteAccepted Configuration change accepted and reload requested swagger:response deleteSiteAccepted */ @@ -78,7 +78,8 @@ func (o *DeleteSiteAccepted) WriteResponse(rw http.ResponseWriter, producer runt // DeleteSiteNoContentCode is the HTTP code returned for type DeleteSiteNoContent const DeleteSiteNoContentCode int = 204 -/*DeleteSiteNoContent Site deleted +/* +DeleteSiteNoContent Site deleted swagger:response deleteSiteNoContent */ @@ -102,7 +103,8 @@ func (o *DeleteSiteNoContent) WriteResponse(rw http.ResponseWriter, producer run // DeleteSiteNotFoundCode is the HTTP code returned for type DeleteSiteNotFound const DeleteSiteNotFoundCode int = 404 -/*DeleteSiteNotFound The specified resource was not found +/* +DeleteSiteNotFound The specified resource was not found swagger:response deleteSiteNotFound */ @@ -110,7 +112,7 @@ type DeleteSiteNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -125,13 +127,13 @@ func NewDeleteSiteNotFound() *DeleteSiteNotFound { } // WithConfigurationVersion adds the configurationVersion to the delete site not found response -func (o *DeleteSiteNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteSiteNotFound { +func (o *DeleteSiteNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSiteNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete site not found response -func (o *DeleteSiteNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteSiteNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -151,7 +153,7 @@ func (o *DeleteSiteNotFound) WriteResponse(rw http.ResponseWriter, producer runt // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -165,7 +167,8 @@ func (o *DeleteSiteNotFound) WriteResponse(rw http.ResponseWriter, producer runt } } -/*DeleteSiteDefault General Error +/* +DeleteSiteDefault General Error swagger:response deleteSiteDefault */ @@ -174,7 +177,7 @@ type DeleteSiteDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -205,13 +208,13 @@ func (o *DeleteSiteDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the delete site default response -func (o *DeleteSiteDefault) WithConfigurationVersion(configurationVersion int64) *DeleteSiteDefault { +func (o *DeleteSiteDefault) WithConfigurationVersion(configurationVersion string) *DeleteSiteDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete site default response -func (o *DeleteSiteDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteSiteDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -231,7 +234,7 @@ func (o *DeleteSiteDefault) WriteResponse(rw http.ResponseWriter, producer runti // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/sites/delete_site_urlbuilder.go b/operations/sites/delete_site_urlbuilder.go index e0599079..c4370c31 100644 --- a/operations/sites/delete_site_urlbuilder.go +++ b/operations/sites/delete_site_urlbuilder.go @@ -72,34 +72,34 @@ func (o *DeleteSiteURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/sites/get_site.go b/operations/sites/get_site.go index 25455abe..61a9f5c4 100644 --- a/operations/sites/get_site.go +++ b/operations/sites/get_site.go @@ -23,12 +23,7 @@ package sites import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetSiteHandlerFunc turns a function with the right signature into a get site handler @@ -49,12 +44,12 @@ func NewGetSite(ctx *middleware.Context, handler GetSiteHandler) *GetSite { return &GetSite{Context: ctx, Handler: handler} } -/*GetSite swagger:route GET /services/haproxy/sites/{name} Sites getSite +/* + GetSite swagger:route GET /services/haproxy/sites/{name} Sites getSite -Return a site +# Return a site Returns one site configuration by it's name. - */ type GetSite struct { Context *middleware.Context @@ -64,21 +59,20 @@ type GetSite struct { func (o *GetSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetSiteParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -87,68 +81,6 @@ func (o *GetSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetSiteOKBody get site o k body -// swagger:model GetSiteOKBody -type GetSiteOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.Site `json:"data,omitempty"` -} - -// Validate validates this get site o k body -func (o *GetSiteOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetSiteOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getSiteOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetSiteOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetSiteOKBody) UnmarshalBinary(b []byte) error { - var res GetSiteOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/sites/get_site_parameters.go b/operations/sites/get_site_parameters.go index e6f6bed6..398b3fbb 100644 --- a/operations/sites/get_site_parameters.go +++ b/operations/sites/get_site_parameters.go @@ -26,12 +26,12 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewGetSiteParams creates a new GetSiteParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetSiteParams() GetSiteParams { return GetSiteParams{} @@ -77,7 +77,6 @@ func (o *GetSiteParams) BindRequest(r *http.Request, route *middleware.MatchedRo if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -93,7 +92,6 @@ func (o *GetSiteParams) bindName(rawData []string, hasKey bool, formats strfmt.R // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -108,10 +106,10 @@ func (o *GetSiteParams) bindTransactionID(rawData []string, hasKey bool, formats // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/sites/get_site_responses.go b/operations/sites/get_site_responses.go index 7c33efd0..7ef9d6f2 100644 --- a/operations/sites/get_site_responses.go +++ b/operations/sites/get_site_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetSiteOKCode is the HTTP code returned for type GetSiteOK const GetSiteOKCode int = 200 -/*GetSiteOK Successful operation +/* +GetSiteOK Successful operation swagger:response getSiteOK */ @@ -40,12 +40,12 @@ type GetSiteOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetSiteOKBody `json:"body,omitempty"` + Payload *models.Site `json:"body,omitempty"` } // NewGetSiteOK creates GetSiteOK with default headers values @@ -55,24 +55,24 @@ func NewGetSiteOK() *GetSiteOK { } // WithConfigurationVersion adds the configurationVersion to the get site o k response -func (o *GetSiteOK) WithConfigurationVersion(configurationVersion int64) *GetSiteOK { +func (o *GetSiteOK) WithConfigurationVersion(configurationVersion string) *GetSiteOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get site o k response -func (o *GetSiteOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetSiteOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get site o k response -func (o *GetSiteOK) WithPayload(payload *GetSiteOKBody) *GetSiteOK { +func (o *GetSiteOK) WithPayload(payload *models.Site) *GetSiteOK { o.Payload = payload return o } // SetPayload sets the payload to the get site o k response -func (o *GetSiteOK) SetPayload(payload *GetSiteOKBody) { +func (o *GetSiteOK) SetPayload(payload *models.Site) { o.Payload = payload } @@ -81,7 +81,7 @@ func (o *GetSiteOK) WriteResponse(rw http.ResponseWriter, producer runtime.Produ // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -98,7 +98,8 @@ func (o *GetSiteOK) WriteResponse(rw http.ResponseWriter, producer runtime.Produ // GetSiteNotFoundCode is the HTTP code returned for type GetSiteNotFound const GetSiteNotFoundCode int = 404 -/*GetSiteNotFound The specified resource was not found +/* +GetSiteNotFound The specified resource was not found swagger:response getSiteNotFound */ @@ -106,7 +107,7 @@ type GetSiteNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -121,13 +122,13 @@ func NewGetSiteNotFound() *GetSiteNotFound { } // WithConfigurationVersion adds the configurationVersion to the get site not found response -func (o *GetSiteNotFound) WithConfigurationVersion(configurationVersion int64) *GetSiteNotFound { +func (o *GetSiteNotFound) WithConfigurationVersion(configurationVersion string) *GetSiteNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get site not found response -func (o *GetSiteNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetSiteNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -147,7 +148,7 @@ func (o *GetSiteNotFound) WriteResponse(rw http.ResponseWriter, producer runtime // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -161,7 +162,8 @@ func (o *GetSiteNotFound) WriteResponse(rw http.ResponseWriter, producer runtime } } -/*GetSiteDefault General Error +/* +GetSiteDefault General Error swagger:response getSiteDefault */ @@ -170,7 +172,7 @@ type GetSiteDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -201,13 +203,13 @@ func (o *GetSiteDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get site default response -func (o *GetSiteDefault) WithConfigurationVersion(configurationVersion int64) *GetSiteDefault { +func (o *GetSiteDefault) WithConfigurationVersion(configurationVersion string) *GetSiteDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get site default response -func (o *GetSiteDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetSiteDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -227,7 +229,7 @@ func (o *GetSiteDefault) WriteResponse(rw http.ResponseWriter, producer runtime. // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/sites/get_site_urlbuilder.go b/operations/sites/get_site_urlbuilder.go index 4f392d39..368da85d 100644 --- a/operations/sites/get_site_urlbuilder.go +++ b/operations/sites/get_site_urlbuilder.go @@ -68,18 +68,18 @@ func (o *GetSiteURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/sites/get_sites.go b/operations/sites/get_sites.go index 93e8a171..92fefa95 100644 --- a/operations/sites/get_sites.go +++ b/operations/sites/get_sites.go @@ -23,13 +23,7 @@ package sites import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetSitesHandlerFunc turns a function with the right signature into a get sites handler @@ -50,12 +44,12 @@ func NewGetSites(ctx *middleware.Context, handler GetSitesHandler) *GetSites { return &GetSites{Context: ctx, Handler: handler} } -/*GetSites swagger:route GET /services/haproxy/sites Sites getSites +/* + GetSites swagger:route GET /services/haproxy/sites Sites getSites -Return an array of sites +# Return an array of sites Returns an array of all configured sites. - */ type GetSites struct { Context *middleware.Context @@ -65,21 +59,20 @@ type GetSites struct { func (o *GetSites) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetSitesParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -88,67 +81,6 @@ func (o *GetSites) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetSitesOKBody get sites o k body -// swagger:model GetSitesOKBody -type GetSitesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.Sites `json:"data"` -} - -// Validate validates this get sites o k body -func (o *GetSitesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetSitesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getSitesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getSitesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetSitesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetSitesOKBody) UnmarshalBinary(b []byte) error { - var res GetSitesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/sites/get_sites_parameters.go b/operations/sites/get_sites_parameters.go index 6b2bc77f..a517bd83 100644 --- a/operations/sites/get_sites_parameters.go +++ b/operations/sites/get_sites_parameters.go @@ -26,12 +26,12 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewGetSitesParams creates a new GetSitesParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetSitesParams() GetSitesParams { return GetSitesParams{} @@ -67,7 +67,6 @@ func (o *GetSitesParams) BindRequest(r *http.Request, route *middleware.MatchedR if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -83,10 +82,10 @@ func (o *GetSitesParams) bindTransactionID(rawData []string, hasKey bool, format // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/sites/get_sites_responses.go b/operations/sites/get_sites_responses.go index b4943bf2..fc23289c 100644 --- a/operations/sites/get_sites_responses.go +++ b/operations/sites/get_sites_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetSitesOKCode is the HTTP code returned for type GetSitesOK const GetSitesOKCode int = 200 -/*GetSitesOK Successful operation +/* +GetSitesOK Successful operation swagger:response getSitesOK */ @@ -40,12 +40,12 @@ type GetSitesOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetSitesOKBody `json:"body,omitempty"` + Payload models.Sites `json:"body,omitempty"` } // NewGetSitesOK creates GetSitesOK with default headers values @@ -55,24 +55,24 @@ func NewGetSitesOK() *GetSitesOK { } // WithConfigurationVersion adds the configurationVersion to the get sites o k response -func (o *GetSitesOK) WithConfigurationVersion(configurationVersion int64) *GetSitesOK { +func (o *GetSitesOK) WithConfigurationVersion(configurationVersion string) *GetSitesOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get sites o k response -func (o *GetSitesOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetSitesOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get sites o k response -func (o *GetSitesOK) WithPayload(payload *GetSitesOKBody) *GetSitesOK { +func (o *GetSitesOK) WithPayload(payload models.Sites) *GetSitesOK { o.Payload = payload return o } // SetPayload sets the payload to the get sites o k response -func (o *GetSitesOK) SetPayload(payload *GetSitesOKBody) { +func (o *GetSitesOK) SetPayload(payload models.Sites) { o.Payload = payload } @@ -81,21 +81,25 @@ func (o *GetSitesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Prod // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Sites{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*GetSitesDefault General Error +/* +GetSitesDefault General Error swagger:response getSitesDefault */ @@ -104,7 +108,7 @@ type GetSitesDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -135,13 +139,13 @@ func (o *GetSitesDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get sites default response -func (o *GetSitesDefault) WithConfigurationVersion(configurationVersion int64) *GetSitesDefault { +func (o *GetSitesDefault) WithConfigurationVersion(configurationVersion string) *GetSitesDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get sites default response -func (o *GetSitesDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetSitesDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -161,7 +165,7 @@ func (o *GetSitesDefault) WriteResponse(rw http.ResponseWriter, producer runtime // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/sites/get_sites_urlbuilder.go b/operations/sites/get_sites_urlbuilder.go index a6e61fab..bb73d878 100644 --- a/operations/sites/get_sites_urlbuilder.go +++ b/operations/sites/get_sites_urlbuilder.go @@ -58,18 +58,18 @@ func (o *GetSitesURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/sites/replace_site.go b/operations/sites/replace_site.go index f06ffd9f..b1e37e85 100644 --- a/operations/sites/replace_site.go +++ b/operations/sites/replace_site.go @@ -23,7 +23,7 @@ package sites import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // ReplaceSiteHandlerFunc turns a function with the right signature into a replace site handler @@ -44,12 +44,12 @@ func NewReplaceSite(ctx *middleware.Context, handler ReplaceSiteHandler) *Replac return &ReplaceSite{Context: ctx, Handler: handler} } -/*ReplaceSite swagger:route PUT /services/haproxy/sites/{name} Sites replaceSite +/* + ReplaceSite swagger:route PUT /services/haproxy/sites/{name} Sites replaceSite -Replace a site +# Replace a site Replaces a site configuration by it's name. - */ type ReplaceSite struct { Context *middleware.Context @@ -59,21 +59,20 @@ type ReplaceSite struct { func (o *ReplaceSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewReplaceSiteParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *ReplaceSite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/sites/replace_site_parameters.go b/operations/sites/replace_site_parameters.go index 7fed81ca..5b6a449a 100644 --- a/operations/sites/replace_site_parameters.go +++ b/operations/sites/replace_site_parameters.go @@ -27,11 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewReplaceSiteParams creates a new ReplaceSiteParams object @@ -99,7 +98,7 @@ func (o *ReplaceSiteParams) BindRequest(r *http.Request, route *middleware.Match var body models.Site if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -114,8 +113,9 @@ func (o *ReplaceSiteParams) BindRequest(r *http.Request, route *middleware.Match } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) @@ -135,7 +135,6 @@ func (o *ReplaceSiteParams) BindRequest(r *http.Request, route *middleware.Match if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -151,6 +150,7 @@ func (o *ReplaceSiteParams) bindForceReload(rawData []string, hasKey bool, forma // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewReplaceSiteParams() return nil @@ -174,7 +174,6 @@ func (o *ReplaceSiteParams) bindName(rawData []string, hasKey bool, formats strf // Required: true // Parameter is provided by construction from the route - o.Name = raw return nil @@ -189,10 +188,10 @@ func (o *ReplaceSiteParams) bindTransactionID(rawData []string, hasKey bool, for // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -207,6 +206,7 @@ func (o *ReplaceSiteParams) bindVersion(rawData []string, hasKey bool, formats s // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/sites/replace_site_responses.go b/operations/sites/replace_site_responses.go index 173a8098..08501e57 100644 --- a/operations/sites/replace_site_responses.go +++ b/operations/sites/replace_site_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // ReplaceSiteOKCode is the HTTP code returned for type ReplaceSiteOK const ReplaceSiteOKCode int = 200 -/*ReplaceSiteOK Site replaced +/* +ReplaceSiteOK Site replaced swagger:response replaceSiteOK */ @@ -76,7 +76,8 @@ func (o *ReplaceSiteOK) WriteResponse(rw http.ResponseWriter, producer runtime.P // ReplaceSiteAcceptedCode is the HTTP code returned for type ReplaceSiteAccepted const ReplaceSiteAcceptedCode int = 202 -/*ReplaceSiteAccepted Configuration change accepted and reload requested +/* +ReplaceSiteAccepted Configuration change accepted and reload requested swagger:response replaceSiteAccepted */ @@ -142,7 +143,8 @@ func (o *ReplaceSiteAccepted) WriteResponse(rw http.ResponseWriter, producer run // ReplaceSiteBadRequestCode is the HTTP code returned for type ReplaceSiteBadRequest const ReplaceSiteBadRequestCode int = 400 -/*ReplaceSiteBadRequest Bad request +/* +ReplaceSiteBadRequest Bad request swagger:response replaceSiteBadRequest */ @@ -150,7 +152,7 @@ type ReplaceSiteBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewReplaceSiteBadRequest() *ReplaceSiteBadRequest { } // WithConfigurationVersion adds the configurationVersion to the replace site bad request response -func (o *ReplaceSiteBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceSiteBadRequest { +func (o *ReplaceSiteBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceSiteBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace site bad request response -func (o *ReplaceSiteBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceSiteBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *ReplaceSiteBadRequest) WriteResponse(rw http.ResponseWriter, producer r // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *ReplaceSiteBadRequest) WriteResponse(rw http.ResponseWriter, producer r // ReplaceSiteNotFoundCode is the HTTP code returned for type ReplaceSiteNotFound const ReplaceSiteNotFoundCode int = 404 -/*ReplaceSiteNotFound The specified resource was not found +/* +ReplaceSiteNotFound The specified resource was not found swagger:response replaceSiteNotFound */ @@ -216,7 +219,7 @@ type ReplaceSiteNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewReplaceSiteNotFound() *ReplaceSiteNotFound { } // WithConfigurationVersion adds the configurationVersion to the replace site not found response -func (o *ReplaceSiteNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceSiteNotFound { +func (o *ReplaceSiteNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceSiteNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace site not found response -func (o *ReplaceSiteNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceSiteNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *ReplaceSiteNotFound) WriteResponse(rw http.ResponseWriter, producer run // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *ReplaceSiteNotFound) WriteResponse(rw http.ResponseWriter, producer run } } -/*ReplaceSiteDefault General Error +/* +ReplaceSiteDefault General Error swagger:response replaceSiteDefault */ @@ -280,7 +284,7 @@ type ReplaceSiteDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *ReplaceSiteDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the replace site default response -func (o *ReplaceSiteDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceSiteDefault { +func (o *ReplaceSiteDefault) WithConfigurationVersion(configurationVersion string) *ReplaceSiteDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace site default response -func (o *ReplaceSiteDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceSiteDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *ReplaceSiteDefault) WriteResponse(rw http.ResponseWriter, producer runt // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/sites/replace_site_urlbuilder.go b/operations/sites/replace_site_urlbuilder.go index 112f32e8..158a42aa 100644 --- a/operations/sites/replace_site_urlbuilder.go +++ b/operations/sites/replace_site_urlbuilder.go @@ -72,34 +72,34 @@ func (o *ReplaceSiteURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/specification/get_specification.go b/operations/specification/get_specification.go index 2f6e086d..d2098e5c 100644 --- a/operations/specification/get_specification.go +++ b/operations/specification/get_specification.go @@ -23,7 +23,7 @@ package specification import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetSpecificationHandlerFunc turns a function with the right signature into a get specification handler @@ -44,12 +44,12 @@ func NewGetSpecification(ctx *middleware.Context, handler GetSpecificationHandle return &GetSpecification{Context: ctx, Handler: handler} } -/*GetSpecification swagger:route GET /specification Specification getSpecification +/* + GetSpecification swagger:route GET /specification Specification getSpecification -Data Plane API Specification +# Data Plane API Specification Return Data Plane API OpenAPI specification - */ type GetSpecification struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetSpecification struct { func (o *GetSpecification) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetSpecificationParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetSpecification) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/specification/get_specification_parameters.go b/operations/specification/get_specification_parameters.go index 27f9c3a0..6fe336b6 100644 --- a/operations/specification/get_specification_parameters.go +++ b/operations/specification/get_specification_parameters.go @@ -28,7 +28,8 @@ import ( ) // NewGetSpecificationParams creates a new GetSpecificationParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetSpecificationParams() GetSpecificationParams { return GetSpecificationParams{} diff --git a/operations/specification/get_specification_responses.go b/operations/specification/get_specification_responses.go index ff927757..ac1bc547 100644 --- a/operations/specification/get_specification_responses.go +++ b/operations/specification/get_specification_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetSpecificationOKCode is the HTTP code returned for type GetSpecificationOK const GetSpecificationOKCode int = 200 -/*GetSpecificationOK Success +/* +GetSpecificationOK Success swagger:response getSpecificationOK */ @@ -71,7 +71,8 @@ func (o *GetSpecificationOK) WriteResponse(rw http.ResponseWriter, producer runt } } -/*GetSpecificationDefault General Error +/* +GetSpecificationDefault General Error swagger:response getSpecificationDefault */ @@ -80,7 +81,7 @@ type GetSpecificationDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -111,13 +112,13 @@ func (o *GetSpecificationDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get specification default response -func (o *GetSpecificationDefault) WithConfigurationVersion(configurationVersion int64) *GetSpecificationDefault { +func (o *GetSpecificationDefault) WithConfigurationVersion(configurationVersion string) *GetSpecificationDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get specification default response -func (o *GetSpecificationDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetSpecificationDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -137,7 +138,7 @@ func (o *GetSpecificationDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/specification/get_specification_urlbuilder.go b/operations/specification/get_specification_urlbuilder.go index 869d0f27..86e513da 100644 --- a/operations/specification/get_specification_urlbuilder.go +++ b/operations/specification/get_specification_urlbuilder.go @@ -54,7 +54,7 @@ func (o *GetSpecificationURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/specification_openapiv3/get_openapiv3_specification.go b/operations/specification_openapiv3/get_openapiv3_specification.go new file mode 100644 index 00000000..a230b44c --- /dev/null +++ b/operations/specification_openapiv3/get_openapiv3_specification.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package specification_openapiv3 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetOpenapiv3SpecificationHandlerFunc turns a function with the right signature into a get openapiv3 specification handler +type GetOpenapiv3SpecificationHandlerFunc func(GetOpenapiv3SpecificationParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetOpenapiv3SpecificationHandlerFunc) Handle(params GetOpenapiv3SpecificationParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetOpenapiv3SpecificationHandler interface for that can handle valid get openapiv3 specification params +type GetOpenapiv3SpecificationHandler interface { + Handle(GetOpenapiv3SpecificationParams, interface{}) middleware.Responder +} + +// NewGetOpenapiv3Specification creates a new http.Handler for the get openapiv3 specification operation +func NewGetOpenapiv3Specification(ctx *middleware.Context, handler GetOpenapiv3SpecificationHandler) *GetOpenapiv3Specification { + return &GetOpenapiv3Specification{Context: ctx, Handler: handler} +} + +/* + GetOpenapiv3Specification swagger:route GET /specification_openapiv3 SpecificationOpenapiv3 getOpenapiv3Specification + +# Data Plane API v3 Specification + +Return Data Plane API OpenAPI v3 specification +*/ +type GetOpenapiv3Specification struct { + Context *middleware.Context + Handler GetOpenapiv3SpecificationHandler +} + +func (o *GetOpenapiv3Specification) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetOpenapiv3SpecificationParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/specification_openapiv3/get_openapiv3_specification_parameters.go b/operations/specification_openapiv3/get_openapiv3_specification_parameters.go new file mode 100644 index 00000000..233ae5a3 --- /dev/null +++ b/operations/specification_openapiv3/get_openapiv3_specification_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package specification_openapiv3 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetOpenapiv3SpecificationParams creates a new GetOpenapiv3SpecificationParams object +// +// There are no default values defined in the spec. +func NewGetOpenapiv3SpecificationParams() GetOpenapiv3SpecificationParams { + + return GetOpenapiv3SpecificationParams{} +} + +// GetOpenapiv3SpecificationParams contains all the bound params for the get openapiv3 specification operation +// typically these are obtained from a http.Request +// +// swagger:parameters getOpenapiv3Specification +type GetOpenapiv3SpecificationParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetOpenapiv3SpecificationParams() beforehand. +func (o *GetOpenapiv3SpecificationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/specification_openapiv3/get_openapiv3_specification_responses.go b/operations/specification_openapiv3/get_openapiv3_specification_responses.go new file mode 100644 index 00000000..5dd2ac48 --- /dev/null +++ b/operations/specification_openapiv3/get_openapiv3_specification_responses.go @@ -0,0 +1,153 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package specification_openapiv3 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetOpenapiv3SpecificationOKCode is the HTTP code returned for type GetOpenapiv3SpecificationOK +const GetOpenapiv3SpecificationOKCode int = 200 + +/* +GetOpenapiv3SpecificationOK Success + +swagger:response getOpenapiv3SpecificationOK +*/ +type GetOpenapiv3SpecificationOK struct { + + /* + In: Body + */ + Payload interface{} `json:"body,omitempty"` +} + +// NewGetOpenapiv3SpecificationOK creates GetOpenapiv3SpecificationOK with default headers values +func NewGetOpenapiv3SpecificationOK() *GetOpenapiv3SpecificationOK { + + return &GetOpenapiv3SpecificationOK{} +} + +// WithPayload adds the payload to the get openapiv3 specification o k response +func (o *GetOpenapiv3SpecificationOK) WithPayload(payload interface{}) *GetOpenapiv3SpecificationOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get openapiv3 specification o k response +func (o *GetOpenapiv3SpecificationOK) SetPayload(payload interface{}) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOpenapiv3SpecificationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetOpenapiv3SpecificationDefault General Error + +swagger:response getOpenapiv3SpecificationDefault +*/ +type GetOpenapiv3SpecificationDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOpenapiv3SpecificationDefault creates GetOpenapiv3SpecificationDefault with default headers values +func NewGetOpenapiv3SpecificationDefault(code int) *GetOpenapiv3SpecificationDefault { + if code <= 0 { + code = 500 + } + + return &GetOpenapiv3SpecificationDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get openapiv3 specification default response +func (o *GetOpenapiv3SpecificationDefault) WithStatusCode(code int) *GetOpenapiv3SpecificationDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get openapiv3 specification default response +func (o *GetOpenapiv3SpecificationDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get openapiv3 specification default response +func (o *GetOpenapiv3SpecificationDefault) WithConfigurationVersion(configurationVersion string) *GetOpenapiv3SpecificationDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get openapiv3 specification default response +func (o *GetOpenapiv3SpecificationDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get openapiv3 specification default response +func (o *GetOpenapiv3SpecificationDefault) WithPayload(payload *models.Error) *GetOpenapiv3SpecificationDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get openapiv3 specification default response +func (o *GetOpenapiv3SpecificationDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOpenapiv3SpecificationDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/specification_openapiv3/get_openapiv3_specification_urlbuilder.go b/operations/specification_openapiv3/get_openapiv3_specification_urlbuilder.go new file mode 100644 index 00000000..b5ae907f --- /dev/null +++ b/operations/specification_openapiv3/get_openapiv3_specification_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package specification_openapiv3 + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetOpenapiv3SpecificationURL generates an URL for the get openapiv3 specification operation +type GetOpenapiv3SpecificationURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOpenapiv3SpecificationURL) WithBasePath(bp string) *GetOpenapiv3SpecificationURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOpenapiv3SpecificationURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetOpenapiv3SpecificationURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/specification_openapiv3" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetOpenapiv3SpecificationURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetOpenapiv3SpecificationURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetOpenapiv3SpecificationURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetOpenapiv3SpecificationURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetOpenapiv3SpecificationURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetOpenapiv3SpecificationURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/create_spoe.go b/operations/spoe/create_spoe.go new file mode 100644 index 00000000..4b2e2481 --- /dev/null +++ b/operations/spoe/create_spoe.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateSpoeHandlerFunc turns a function with the right signature into a create spoe handler +type CreateSpoeHandlerFunc func(CreateSpoeParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateSpoeHandlerFunc) Handle(params CreateSpoeParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateSpoeHandler interface for that can handle valid create spoe params +type CreateSpoeHandler interface { + Handle(CreateSpoeParams, interface{}) middleware.Responder +} + +// NewCreateSpoe creates a new http.Handler for the create spoe operation +func NewCreateSpoe(ctx *middleware.Context, handler CreateSpoeHandler) *CreateSpoe { + return &CreateSpoe{Context: ctx, Handler: handler} +} + +/* + CreateSpoe swagger:route POST /services/haproxy/spoe/spoe_files Spoe createSpoe + +# Creates SPOE file with its entries + +Creates SPOE file with its entries. +*/ +type CreateSpoe struct { + Context *middleware.Context + Handler CreateSpoeHandler +} + +func (o *CreateSpoe) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateSpoeParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/create_spoe_agent.go b/operations/spoe/create_spoe_agent.go new file mode 100644 index 00000000..6e770fbe --- /dev/null +++ b/operations/spoe/create_spoe_agent.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateSpoeAgentHandlerFunc turns a function with the right signature into a create spoe agent handler +type CreateSpoeAgentHandlerFunc func(CreateSpoeAgentParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateSpoeAgentHandlerFunc) Handle(params CreateSpoeAgentParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateSpoeAgentHandler interface for that can handle valid create spoe agent params +type CreateSpoeAgentHandler interface { + Handle(CreateSpoeAgentParams, interface{}) middleware.Responder +} + +// NewCreateSpoeAgent creates a new http.Handler for the create spoe agent operation +func NewCreateSpoeAgent(ctx *middleware.Context, handler CreateSpoeAgentHandler) *CreateSpoeAgent { + return &CreateSpoeAgent{Context: ctx, Handler: handler} +} + +/* + CreateSpoeAgent swagger:route POST /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents Spoe createSpoeAgent + +# Add a new spoe agent to scope + +Adds a new spoe agent to the spoe scope. +*/ +type CreateSpoeAgent struct { + Context *middleware.Context + Handler CreateSpoeAgentHandler +} + +func (o *CreateSpoeAgent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateSpoeAgentParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/create_spoe_agent_parameters.go b/operations/spoe/create_spoe_agent_parameters.go new file mode 100644 index 00000000..f5b6011f --- /dev/null +++ b/operations/spoe/create_spoe_agent_parameters.go @@ -0,0 +1,204 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateSpoeAgentParams creates a new CreateSpoeAgentParams object +// +// There are no default values defined in the spec. +func NewCreateSpoeAgentParams() CreateSpoeAgentParams { + + return CreateSpoeAgentParams{} +} + +// CreateSpoeAgentParams contains all the bound params for the create spoe agent operation +// typically these are obtained from a http.Request +// +// swagger:parameters createSpoeAgent +type CreateSpoeAgentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SpoeAgent + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateSpoeAgentParams() beforehand. +func (o *CreateSpoeAgentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SpoeAgent + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateSpoeAgentParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *CreateSpoeAgentParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateSpoeAgentParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateSpoeAgentParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/create_spoe_agent_responses.go b/operations/spoe/create_spoe_agent_responses.go new file mode 100644 index 00000000..d985d6fa --- /dev/null +++ b/operations/spoe/create_spoe_agent_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateSpoeAgentCreatedCode is the HTTP code returned for type CreateSpoeAgentCreated +const CreateSpoeAgentCreatedCode int = 201 + +/* +CreateSpoeAgentCreated Spoe agent created + +swagger:response createSpoeAgentCreated +*/ +type CreateSpoeAgentCreated struct { + + /* + In: Body + */ + Payload *models.SpoeAgent `json:"body,omitempty"` +} + +// NewCreateSpoeAgentCreated creates CreateSpoeAgentCreated with default headers values +func NewCreateSpoeAgentCreated() *CreateSpoeAgentCreated { + + return &CreateSpoeAgentCreated{} +} + +// WithPayload adds the payload to the create spoe agent created response +func (o *CreateSpoeAgentCreated) WithPayload(payload *models.SpoeAgent) *CreateSpoeAgentCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe agent created response +func (o *CreateSpoeAgentCreated) SetPayload(payload *models.SpoeAgent) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeAgentCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeAgentBadRequestCode is the HTTP code returned for type CreateSpoeAgentBadRequest +const CreateSpoeAgentBadRequestCode int = 400 + +/* +CreateSpoeAgentBadRequest Bad request + +swagger:response createSpoeAgentBadRequest +*/ +type CreateSpoeAgentBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeAgentBadRequest creates CreateSpoeAgentBadRequest with default headers values +func NewCreateSpoeAgentBadRequest() *CreateSpoeAgentBadRequest { + + return &CreateSpoeAgentBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe agent bad request response +func (o *CreateSpoeAgentBadRequest) WithConfigurationVersion(configurationVersion string) *CreateSpoeAgentBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe agent bad request response +func (o *CreateSpoeAgentBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe agent bad request response +func (o *CreateSpoeAgentBadRequest) WithPayload(payload *models.Error) *CreateSpoeAgentBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe agent bad request response +func (o *CreateSpoeAgentBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeAgentBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeAgentConflictCode is the HTTP code returned for type CreateSpoeAgentConflict +const CreateSpoeAgentConflictCode int = 409 + +/* +CreateSpoeAgentConflict The specified resource already exists + +swagger:response createSpoeAgentConflict +*/ +type CreateSpoeAgentConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeAgentConflict creates CreateSpoeAgentConflict with default headers values +func NewCreateSpoeAgentConflict() *CreateSpoeAgentConflict { + + return &CreateSpoeAgentConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe agent conflict response +func (o *CreateSpoeAgentConflict) WithConfigurationVersion(configurationVersion string) *CreateSpoeAgentConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe agent conflict response +func (o *CreateSpoeAgentConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe agent conflict response +func (o *CreateSpoeAgentConflict) WithPayload(payload *models.Error) *CreateSpoeAgentConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe agent conflict response +func (o *CreateSpoeAgentConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeAgentConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateSpoeAgentDefault General Error + +swagger:response createSpoeAgentDefault +*/ +type CreateSpoeAgentDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeAgentDefault creates CreateSpoeAgentDefault with default headers values +func NewCreateSpoeAgentDefault(code int) *CreateSpoeAgentDefault { + if code <= 0 { + code = 500 + } + + return &CreateSpoeAgentDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create spoe agent default response +func (o *CreateSpoeAgentDefault) WithStatusCode(code int) *CreateSpoeAgentDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create spoe agent default response +func (o *CreateSpoeAgentDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe agent default response +func (o *CreateSpoeAgentDefault) WithConfigurationVersion(configurationVersion string) *CreateSpoeAgentDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe agent default response +func (o *CreateSpoeAgentDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe agent default response +func (o *CreateSpoeAgentDefault) WithPayload(payload *models.Error) *CreateSpoeAgentDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe agent default response +func (o *CreateSpoeAgentDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeAgentDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/create_spoe_agent_urlbuilder.go b/operations/spoe/create_spoe_agent_urlbuilder.go new file mode 100644 index 00000000..60656fd5 --- /dev/null +++ b/operations/spoe/create_spoe_agent_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateSpoeAgentURL generates an URL for the create spoe agent operation +type CreateSpoeAgentURL struct { + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeAgentURL) WithBasePath(bp string) *CreateSpoeAgentURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeAgentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateSpoeAgentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateSpoeAgentURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on CreateSpoeAgentURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateSpoeAgentURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateSpoeAgentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateSpoeAgentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateSpoeAgentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateSpoeAgentURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateSpoeAgentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/create_spoe_group.go b/operations/spoe/create_spoe_group.go new file mode 100644 index 00000000..1b21e5a7 --- /dev/null +++ b/operations/spoe/create_spoe_group.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateSpoeGroupHandlerFunc turns a function with the right signature into a create spoe group handler +type CreateSpoeGroupHandlerFunc func(CreateSpoeGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateSpoeGroupHandlerFunc) Handle(params CreateSpoeGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateSpoeGroupHandler interface for that can handle valid create spoe group params +type CreateSpoeGroupHandler interface { + Handle(CreateSpoeGroupParams, interface{}) middleware.Responder +} + +// NewCreateSpoeGroup creates a new http.Handler for the create spoe group operation +func NewCreateSpoeGroup(ctx *middleware.Context, handler CreateSpoeGroupHandler) *CreateSpoeGroup { + return &CreateSpoeGroup{Context: ctx, Handler: handler} +} + +/* + CreateSpoeGroup swagger:route POST /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups Spoe createSpoeGroup + +# Add a new SPOE groups + +Adds a new SPOE groups to the SPOE scope. +*/ +type CreateSpoeGroup struct { + Context *middleware.Context + Handler CreateSpoeGroupHandler +} + +func (o *CreateSpoeGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateSpoeGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/create_spoe_group_parameters.go b/operations/spoe/create_spoe_group_parameters.go new file mode 100644 index 00000000..68c6fbd8 --- /dev/null +++ b/operations/spoe/create_spoe_group_parameters.go @@ -0,0 +1,204 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateSpoeGroupParams creates a new CreateSpoeGroupParams object +// +// There are no default values defined in the spec. +func NewCreateSpoeGroupParams() CreateSpoeGroupParams { + + return CreateSpoeGroupParams{} +} + +// CreateSpoeGroupParams contains all the bound params for the create spoe group operation +// typically these are obtained from a http.Request +// +// swagger:parameters createSpoeGroup +type CreateSpoeGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SpoeGroup + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateSpoeGroupParams() beforehand. +func (o *CreateSpoeGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SpoeGroup + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateSpoeGroupParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *CreateSpoeGroupParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateSpoeGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateSpoeGroupParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/create_spoe_group_responses.go b/operations/spoe/create_spoe_group_responses.go new file mode 100644 index 00000000..4dbd3592 --- /dev/null +++ b/operations/spoe/create_spoe_group_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateSpoeGroupCreatedCode is the HTTP code returned for type CreateSpoeGroupCreated +const CreateSpoeGroupCreatedCode int = 201 + +/* +CreateSpoeGroupCreated Spoe groups created + +swagger:response createSpoeGroupCreated +*/ +type CreateSpoeGroupCreated struct { + + /* + In: Body + */ + Payload *models.SpoeGroup `json:"body,omitempty"` +} + +// NewCreateSpoeGroupCreated creates CreateSpoeGroupCreated with default headers values +func NewCreateSpoeGroupCreated() *CreateSpoeGroupCreated { + + return &CreateSpoeGroupCreated{} +} + +// WithPayload adds the payload to the create spoe group created response +func (o *CreateSpoeGroupCreated) WithPayload(payload *models.SpoeGroup) *CreateSpoeGroupCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe group created response +func (o *CreateSpoeGroupCreated) SetPayload(payload *models.SpoeGroup) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeGroupCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeGroupBadRequestCode is the HTTP code returned for type CreateSpoeGroupBadRequest +const CreateSpoeGroupBadRequestCode int = 400 + +/* +CreateSpoeGroupBadRequest Bad request + +swagger:response createSpoeGroupBadRequest +*/ +type CreateSpoeGroupBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeGroupBadRequest creates CreateSpoeGroupBadRequest with default headers values +func NewCreateSpoeGroupBadRequest() *CreateSpoeGroupBadRequest { + + return &CreateSpoeGroupBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe group bad request response +func (o *CreateSpoeGroupBadRequest) WithConfigurationVersion(configurationVersion string) *CreateSpoeGroupBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe group bad request response +func (o *CreateSpoeGroupBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe group bad request response +func (o *CreateSpoeGroupBadRequest) WithPayload(payload *models.Error) *CreateSpoeGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe group bad request response +func (o *CreateSpoeGroupBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeGroupConflictCode is the HTTP code returned for type CreateSpoeGroupConflict +const CreateSpoeGroupConflictCode int = 409 + +/* +CreateSpoeGroupConflict The specified resource already exists + +swagger:response createSpoeGroupConflict +*/ +type CreateSpoeGroupConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeGroupConflict creates CreateSpoeGroupConflict with default headers values +func NewCreateSpoeGroupConflict() *CreateSpoeGroupConflict { + + return &CreateSpoeGroupConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe group conflict response +func (o *CreateSpoeGroupConflict) WithConfigurationVersion(configurationVersion string) *CreateSpoeGroupConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe group conflict response +func (o *CreateSpoeGroupConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe group conflict response +func (o *CreateSpoeGroupConflict) WithPayload(payload *models.Error) *CreateSpoeGroupConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe group conflict response +func (o *CreateSpoeGroupConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeGroupConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateSpoeGroupDefault General Error + +swagger:response createSpoeGroupDefault +*/ +type CreateSpoeGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeGroupDefault creates CreateSpoeGroupDefault with default headers values +func NewCreateSpoeGroupDefault(code int) *CreateSpoeGroupDefault { + if code <= 0 { + code = 500 + } + + return &CreateSpoeGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create spoe group default response +func (o *CreateSpoeGroupDefault) WithStatusCode(code int) *CreateSpoeGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create spoe group default response +func (o *CreateSpoeGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe group default response +func (o *CreateSpoeGroupDefault) WithConfigurationVersion(configurationVersion string) *CreateSpoeGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe group default response +func (o *CreateSpoeGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe group default response +func (o *CreateSpoeGroupDefault) WithPayload(payload *models.Error) *CreateSpoeGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe group default response +func (o *CreateSpoeGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/create_spoe_group_urlbuilder.go b/operations/spoe/create_spoe_group_urlbuilder.go new file mode 100644 index 00000000..6620d042 --- /dev/null +++ b/operations/spoe/create_spoe_group_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateSpoeGroupURL generates an URL for the create spoe group operation +type CreateSpoeGroupURL struct { + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeGroupURL) WithBasePath(bp string) *CreateSpoeGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateSpoeGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateSpoeGroupURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on CreateSpoeGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateSpoeGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateSpoeGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateSpoeGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateSpoeGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateSpoeGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateSpoeGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/create_spoe_message.go b/operations/spoe/create_spoe_message.go new file mode 100644 index 00000000..64bfb4c9 --- /dev/null +++ b/operations/spoe/create_spoe_message.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateSpoeMessageHandlerFunc turns a function with the right signature into a create spoe message handler +type CreateSpoeMessageHandlerFunc func(CreateSpoeMessageParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateSpoeMessageHandlerFunc) Handle(params CreateSpoeMessageParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateSpoeMessageHandler interface for that can handle valid create spoe message params +type CreateSpoeMessageHandler interface { + Handle(CreateSpoeMessageParams, interface{}) middleware.Responder +} + +// NewCreateSpoeMessage creates a new http.Handler for the create spoe message operation +func NewCreateSpoeMessage(ctx *middleware.Context, handler CreateSpoeMessageHandler) *CreateSpoeMessage { + return &CreateSpoeMessage{Context: ctx, Handler: handler} +} + +/* + CreateSpoeMessage swagger:route POST /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages Spoe createSpoeMessage + +# Add a new spoe message to scope + +Adds a new spoe message to the spoe scope. +*/ +type CreateSpoeMessage struct { + Context *middleware.Context + Handler CreateSpoeMessageHandler +} + +func (o *CreateSpoeMessage) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateSpoeMessageParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/create_spoe_message_parameters.go b/operations/spoe/create_spoe_message_parameters.go new file mode 100644 index 00000000..e40e8c7f --- /dev/null +++ b/operations/spoe/create_spoe_message_parameters.go @@ -0,0 +1,204 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateSpoeMessageParams creates a new CreateSpoeMessageParams object +// +// There are no default values defined in the spec. +func NewCreateSpoeMessageParams() CreateSpoeMessageParams { + + return CreateSpoeMessageParams{} +} + +// CreateSpoeMessageParams contains all the bound params for the create spoe message operation +// typically these are obtained from a http.Request +// +// swagger:parameters createSpoeMessage +type CreateSpoeMessageParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SpoeMessage + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateSpoeMessageParams() beforehand. +func (o *CreateSpoeMessageParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SpoeMessage + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateSpoeMessageParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *CreateSpoeMessageParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateSpoeMessageParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateSpoeMessageParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/create_spoe_message_responses.go b/operations/spoe/create_spoe_message_responses.go new file mode 100644 index 00000000..0a0c14d4 --- /dev/null +++ b/operations/spoe/create_spoe_message_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateSpoeMessageCreatedCode is the HTTP code returned for type CreateSpoeMessageCreated +const CreateSpoeMessageCreatedCode int = 201 + +/* +CreateSpoeMessageCreated Spoe message created + +swagger:response createSpoeMessageCreated +*/ +type CreateSpoeMessageCreated struct { + + /* + In: Body + */ + Payload *models.SpoeMessage `json:"body,omitempty"` +} + +// NewCreateSpoeMessageCreated creates CreateSpoeMessageCreated with default headers values +func NewCreateSpoeMessageCreated() *CreateSpoeMessageCreated { + + return &CreateSpoeMessageCreated{} +} + +// WithPayload adds the payload to the create spoe message created response +func (o *CreateSpoeMessageCreated) WithPayload(payload *models.SpoeMessage) *CreateSpoeMessageCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe message created response +func (o *CreateSpoeMessageCreated) SetPayload(payload *models.SpoeMessage) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeMessageCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeMessageBadRequestCode is the HTTP code returned for type CreateSpoeMessageBadRequest +const CreateSpoeMessageBadRequestCode int = 400 + +/* +CreateSpoeMessageBadRequest Bad request + +swagger:response createSpoeMessageBadRequest +*/ +type CreateSpoeMessageBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeMessageBadRequest creates CreateSpoeMessageBadRequest with default headers values +func NewCreateSpoeMessageBadRequest() *CreateSpoeMessageBadRequest { + + return &CreateSpoeMessageBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe message bad request response +func (o *CreateSpoeMessageBadRequest) WithConfigurationVersion(configurationVersion string) *CreateSpoeMessageBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe message bad request response +func (o *CreateSpoeMessageBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe message bad request response +func (o *CreateSpoeMessageBadRequest) WithPayload(payload *models.Error) *CreateSpoeMessageBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe message bad request response +func (o *CreateSpoeMessageBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeMessageBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeMessageConflictCode is the HTTP code returned for type CreateSpoeMessageConflict +const CreateSpoeMessageConflictCode int = 409 + +/* +CreateSpoeMessageConflict The specified resource already exists + +swagger:response createSpoeMessageConflict +*/ +type CreateSpoeMessageConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeMessageConflict creates CreateSpoeMessageConflict with default headers values +func NewCreateSpoeMessageConflict() *CreateSpoeMessageConflict { + + return &CreateSpoeMessageConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe message conflict response +func (o *CreateSpoeMessageConflict) WithConfigurationVersion(configurationVersion string) *CreateSpoeMessageConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe message conflict response +func (o *CreateSpoeMessageConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe message conflict response +func (o *CreateSpoeMessageConflict) WithPayload(payload *models.Error) *CreateSpoeMessageConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe message conflict response +func (o *CreateSpoeMessageConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeMessageConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateSpoeMessageDefault General Error + +swagger:response createSpoeMessageDefault +*/ +type CreateSpoeMessageDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeMessageDefault creates CreateSpoeMessageDefault with default headers values +func NewCreateSpoeMessageDefault(code int) *CreateSpoeMessageDefault { + if code <= 0 { + code = 500 + } + + return &CreateSpoeMessageDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create spoe message default response +func (o *CreateSpoeMessageDefault) WithStatusCode(code int) *CreateSpoeMessageDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create spoe message default response +func (o *CreateSpoeMessageDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe message default response +func (o *CreateSpoeMessageDefault) WithConfigurationVersion(configurationVersion string) *CreateSpoeMessageDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe message default response +func (o *CreateSpoeMessageDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe message default response +func (o *CreateSpoeMessageDefault) WithPayload(payload *models.Error) *CreateSpoeMessageDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe message default response +func (o *CreateSpoeMessageDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeMessageDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/create_spoe_message_urlbuilder.go b/operations/spoe/create_spoe_message_urlbuilder.go new file mode 100644 index 00000000..376beffd --- /dev/null +++ b/operations/spoe/create_spoe_message_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateSpoeMessageURL generates an URL for the create spoe message operation +type CreateSpoeMessageURL struct { + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeMessageURL) WithBasePath(bp string) *CreateSpoeMessageURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeMessageURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateSpoeMessageURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateSpoeMessageURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on CreateSpoeMessageURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateSpoeMessageURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateSpoeMessageURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateSpoeMessageURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateSpoeMessageURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateSpoeMessageURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateSpoeMessageURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/create_spoe_parameters.go b/operations/spoe/create_spoe_parameters.go new file mode 100644 index 00000000..ef69231d --- /dev/null +++ b/operations/spoe/create_spoe_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" +) + +// CreateSpoeMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateSpoeMaxParseMemory int64 = 32 << 20 + +// NewCreateSpoeParams creates a new CreateSpoeParams object +// +// There are no default values defined in the spec. +func NewCreateSpoeParams() CreateSpoeParams { + + return CreateSpoeParams{} +} + +// CreateSpoeParams contains all the bound params for the create spoe operation +// typically these are obtained from a http.Request +// +// swagger:parameters createSpoe +type CreateSpoeParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The spoe file to upload + In: formData + */ + FileUpload io.ReadCloser +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateSpoeParams() beforehand. +func (o *CreateSpoeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(CreateSpoeMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil && err != http.ErrMissingFile { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err == http.ErrMissingFile { + // no-op for missing but optional file parameter + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateSpoeParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} diff --git a/operations/spoe/create_spoe_responses.go b/operations/spoe/create_spoe_responses.go new file mode 100644 index 00000000..571bef79 --- /dev/null +++ b/operations/spoe/create_spoe_responses.go @@ -0,0 +1,287 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateSpoeCreatedCode is the HTTP code returned for type CreateSpoeCreated +const CreateSpoeCreatedCode int = 201 + +/* +CreateSpoeCreated SPOE file created with its entries + +swagger:response createSpoeCreated +*/ +type CreateSpoeCreated struct { + + /* + In: Body + */ + Payload string `json:"body,omitempty"` +} + +// NewCreateSpoeCreated creates CreateSpoeCreated with default headers values +func NewCreateSpoeCreated() *CreateSpoeCreated { + + return &CreateSpoeCreated{} +} + +// WithPayload adds the payload to the create spoe created response +func (o *CreateSpoeCreated) WithPayload(payload string) *CreateSpoeCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe created response +func (o *CreateSpoeCreated) SetPayload(payload string) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// CreateSpoeBadRequestCode is the HTTP code returned for type CreateSpoeBadRequest +const CreateSpoeBadRequestCode int = 400 + +/* +CreateSpoeBadRequest Bad request + +swagger:response createSpoeBadRequest +*/ +type CreateSpoeBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeBadRequest creates CreateSpoeBadRequest with default headers values +func NewCreateSpoeBadRequest() *CreateSpoeBadRequest { + + return &CreateSpoeBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe bad request response +func (o *CreateSpoeBadRequest) WithConfigurationVersion(configurationVersion string) *CreateSpoeBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe bad request response +func (o *CreateSpoeBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe bad request response +func (o *CreateSpoeBadRequest) WithPayload(payload *models.Error) *CreateSpoeBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe bad request response +func (o *CreateSpoeBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeConflictCode is the HTTP code returned for type CreateSpoeConflict +const CreateSpoeConflictCode int = 409 + +/* +CreateSpoeConflict The specified resource already exists + +swagger:response createSpoeConflict +*/ +type CreateSpoeConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeConflict creates CreateSpoeConflict with default headers values +func NewCreateSpoeConflict() *CreateSpoeConflict { + + return &CreateSpoeConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe conflict response +func (o *CreateSpoeConflict) WithConfigurationVersion(configurationVersion string) *CreateSpoeConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe conflict response +func (o *CreateSpoeConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe conflict response +func (o *CreateSpoeConflict) WithPayload(payload *models.Error) *CreateSpoeConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe conflict response +func (o *CreateSpoeConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateSpoeDefault General Error + +swagger:response createSpoeDefault +*/ +type CreateSpoeDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeDefault creates CreateSpoeDefault with default headers values +func NewCreateSpoeDefault(code int) *CreateSpoeDefault { + if code <= 0 { + code = 500 + } + + return &CreateSpoeDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create spoe default response +func (o *CreateSpoeDefault) WithStatusCode(code int) *CreateSpoeDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create spoe default response +func (o *CreateSpoeDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe default response +func (o *CreateSpoeDefault) WithConfigurationVersion(configurationVersion string) *CreateSpoeDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe default response +func (o *CreateSpoeDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe default response +func (o *CreateSpoeDefault) WithPayload(payload *models.Error) *CreateSpoeDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe default response +func (o *CreateSpoeDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/create_spoe_scope.go b/operations/spoe/create_spoe_scope.go new file mode 100644 index 00000000..43207283 --- /dev/null +++ b/operations/spoe/create_spoe_scope.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateSpoeScopeHandlerFunc turns a function with the right signature into a create spoe scope handler +type CreateSpoeScopeHandlerFunc func(CreateSpoeScopeParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateSpoeScopeHandlerFunc) Handle(params CreateSpoeScopeParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateSpoeScopeHandler interface for that can handle valid create spoe scope params +type CreateSpoeScopeHandler interface { + Handle(CreateSpoeScopeParams, interface{}) middleware.Responder +} + +// NewCreateSpoeScope creates a new http.Handler for the create spoe scope operation +func NewCreateSpoeScope(ctx *middleware.Context, handler CreateSpoeScopeHandler) *CreateSpoeScope { + return &CreateSpoeScope{Context: ctx, Handler: handler} +} + +/* + CreateSpoeScope swagger:route POST /services/haproxy/spoe/spoe_files/{parent_name}/scopes Spoe createSpoeScope + +# Add a new spoe scope + +Adds a new spoe scope. +*/ +type CreateSpoeScope struct { + Context *middleware.Context + Handler CreateSpoeScopeHandler +} + +func (o *CreateSpoeScope) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateSpoeScopeParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/create_spoe_scope_parameters.go b/operations/spoe/create_spoe_scope_parameters.go new file mode 100644 index 00000000..271c52db --- /dev/null +++ b/operations/spoe/create_spoe_scope_parameters.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateSpoeScopeParams creates a new CreateSpoeScopeParams object +// +// There are no default values defined in the spec. +func NewCreateSpoeScopeParams() CreateSpoeScopeParams { + + return CreateSpoeScopeParams{} +} + +// CreateSpoeScopeParams contains all the bound params for the create spoe scope operation +// typically these are obtained from a http.Request +// +// swagger:parameters createSpoeScope +type CreateSpoeScopeParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.SpoeScope + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateSpoeScopeParams() beforehand. +func (o *CreateSpoeScopeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SpoeScope + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateSpoeScopeParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateSpoeScopeParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateSpoeScopeParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/create_spoe_scope_responses.go b/operations/spoe/create_spoe_scope_responses.go new file mode 100644 index 00000000..48ea63c2 --- /dev/null +++ b/operations/spoe/create_spoe_scope_responses.go @@ -0,0 +1,287 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateSpoeScopeCreatedCode is the HTTP code returned for type CreateSpoeScopeCreated +const CreateSpoeScopeCreatedCode int = 201 + +/* +CreateSpoeScopeCreated Spoe scope created + +swagger:response createSpoeScopeCreated +*/ +type CreateSpoeScopeCreated struct { + + /* + In: Body + */ + Payload models.SpoeScope `json:"body,omitempty"` +} + +// NewCreateSpoeScopeCreated creates CreateSpoeScopeCreated with default headers values +func NewCreateSpoeScopeCreated() *CreateSpoeScopeCreated { + + return &CreateSpoeScopeCreated{} +} + +// WithPayload adds the payload to the create spoe scope created response +func (o *CreateSpoeScopeCreated) WithPayload(payload models.SpoeScope) *CreateSpoeScopeCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe scope created response +func (o *CreateSpoeScopeCreated) SetPayload(payload models.SpoeScope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeScopeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// CreateSpoeScopeBadRequestCode is the HTTP code returned for type CreateSpoeScopeBadRequest +const CreateSpoeScopeBadRequestCode int = 400 + +/* +CreateSpoeScopeBadRequest Bad request + +swagger:response createSpoeScopeBadRequest +*/ +type CreateSpoeScopeBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeScopeBadRequest creates CreateSpoeScopeBadRequest with default headers values +func NewCreateSpoeScopeBadRequest() *CreateSpoeScopeBadRequest { + + return &CreateSpoeScopeBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe scope bad request response +func (o *CreateSpoeScopeBadRequest) WithConfigurationVersion(configurationVersion string) *CreateSpoeScopeBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe scope bad request response +func (o *CreateSpoeScopeBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe scope bad request response +func (o *CreateSpoeScopeBadRequest) WithPayload(payload *models.Error) *CreateSpoeScopeBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe scope bad request response +func (o *CreateSpoeScopeBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeScopeBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateSpoeScopeConflictCode is the HTTP code returned for type CreateSpoeScopeConflict +const CreateSpoeScopeConflictCode int = 409 + +/* +CreateSpoeScopeConflict The specified resource already exists + +swagger:response createSpoeScopeConflict +*/ +type CreateSpoeScopeConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeScopeConflict creates CreateSpoeScopeConflict with default headers values +func NewCreateSpoeScopeConflict() *CreateSpoeScopeConflict { + + return &CreateSpoeScopeConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe scope conflict response +func (o *CreateSpoeScopeConflict) WithConfigurationVersion(configurationVersion string) *CreateSpoeScopeConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe scope conflict response +func (o *CreateSpoeScopeConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe scope conflict response +func (o *CreateSpoeScopeConflict) WithPayload(payload *models.Error) *CreateSpoeScopeConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe scope conflict response +func (o *CreateSpoeScopeConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeScopeConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateSpoeScopeDefault General Error + +swagger:response createSpoeScopeDefault +*/ +type CreateSpoeScopeDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateSpoeScopeDefault creates CreateSpoeScopeDefault with default headers values +func NewCreateSpoeScopeDefault(code int) *CreateSpoeScopeDefault { + if code <= 0 { + code = 500 + } + + return &CreateSpoeScopeDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create spoe scope default response +func (o *CreateSpoeScopeDefault) WithStatusCode(code int) *CreateSpoeScopeDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create spoe scope default response +func (o *CreateSpoeScopeDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create spoe scope default response +func (o *CreateSpoeScopeDefault) WithConfigurationVersion(configurationVersion string) *CreateSpoeScopeDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create spoe scope default response +func (o *CreateSpoeScopeDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create spoe scope default response +func (o *CreateSpoeScopeDefault) WithPayload(payload *models.Error) *CreateSpoeScopeDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create spoe scope default response +func (o *CreateSpoeScopeDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateSpoeScopeDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/create_spoe_scope_urlbuilder.go b/operations/spoe/create_spoe_scope_urlbuilder.go new file mode 100644 index 00000000..e26da246 --- /dev/null +++ b/operations/spoe/create_spoe_scope_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateSpoeScopeURL generates an URL for the create spoe scope operation +type CreateSpoeScopeURL struct { + ParentName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeScopeURL) WithBasePath(bp string) *CreateSpoeScopeURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeScopeURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateSpoeScopeURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateSpoeScopeURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateSpoeScopeURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateSpoeScopeURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateSpoeScopeURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateSpoeScopeURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateSpoeScopeURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateSpoeScopeURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/create_spoe_urlbuilder.go b/operations/spoe/create_spoe_urlbuilder.go new file mode 100644 index 00000000..a6b81d78 --- /dev/null +++ b/operations/spoe/create_spoe_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateSpoeURL generates an URL for the create spoe operation +type CreateSpoeURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeURL) WithBasePath(bp string) *CreateSpoeURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateSpoeURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateSpoeURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateSpoeURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateSpoeURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateSpoeURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateSpoeURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateSpoeURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateSpoeURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/delete_spoe_agent.go b/operations/spoe/delete_spoe_agent.go new file mode 100644 index 00000000..88384e38 --- /dev/null +++ b/operations/spoe/delete_spoe_agent.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteSpoeAgentHandlerFunc turns a function with the right signature into a delete spoe agent handler +type DeleteSpoeAgentHandlerFunc func(DeleteSpoeAgentParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteSpoeAgentHandlerFunc) Handle(params DeleteSpoeAgentParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteSpoeAgentHandler interface for that can handle valid delete spoe agent params +type DeleteSpoeAgentHandler interface { + Handle(DeleteSpoeAgentParams, interface{}) middleware.Responder +} + +// NewDeleteSpoeAgent creates a new http.Handler for the delete spoe agent operation +func NewDeleteSpoeAgent(ctx *middleware.Context, handler DeleteSpoeAgentHandler) *DeleteSpoeAgent { + return &DeleteSpoeAgent{Context: ctx, Handler: handler} +} + +/* + DeleteSpoeAgent swagger:route DELETE /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name} Spoe deleteSpoeAgent + +# Delete a SPOE agent + +Deletes a SPOE agent from the configuration in one SPOE scope. +*/ +type DeleteSpoeAgent struct { + Context *middleware.Context + Handler DeleteSpoeAgentHandler +} + +func (o *DeleteSpoeAgent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteSpoeAgentParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/delete_spoe_agent_parameters.go b/operations/spoe/delete_spoe_agent_parameters.go new file mode 100644 index 00000000..edd90454 --- /dev/null +++ b/operations/spoe/delete_spoe_agent_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteSpoeAgentParams creates a new DeleteSpoeAgentParams object +// +// There are no default values defined in the spec. +func NewDeleteSpoeAgentParams() DeleteSpoeAgentParams { + + return DeleteSpoeAgentParams{} +} + +// DeleteSpoeAgentParams contains all the bound params for the delete spoe agent operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteSpoeAgent +type DeleteSpoeAgentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe agent name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteSpoeAgentParams() beforehand. +func (o *DeleteSpoeAgentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteSpoeAgentParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteSpoeAgentParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *DeleteSpoeAgentParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteSpoeAgentParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteSpoeAgentParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/delete_spoe_agent_responses.go b/operations/spoe/delete_spoe_agent_responses.go new file mode 100644 index 00000000..afcf6277 --- /dev/null +++ b/operations/spoe/delete_spoe_agent_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteSpoeAgentNoContentCode is the HTTP code returned for type DeleteSpoeAgentNoContent +const DeleteSpoeAgentNoContentCode int = 204 + +/* +DeleteSpoeAgentNoContent Spoe agent deleted + +swagger:response deleteSpoeAgentNoContent +*/ +type DeleteSpoeAgentNoContent struct { +} + +// NewDeleteSpoeAgentNoContent creates DeleteSpoeAgentNoContent with default headers values +func NewDeleteSpoeAgentNoContent() *DeleteSpoeAgentNoContent { + + return &DeleteSpoeAgentNoContent{} +} + +// WriteResponse to the client +func (o *DeleteSpoeAgentNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteSpoeAgentNotFoundCode is the HTTP code returned for type DeleteSpoeAgentNotFound +const DeleteSpoeAgentNotFoundCode int = 404 + +/* +DeleteSpoeAgentNotFound The specified resource was not found + +swagger:response deleteSpoeAgentNotFound +*/ +type DeleteSpoeAgentNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeAgentNotFound creates DeleteSpoeAgentNotFound with default headers values +func NewDeleteSpoeAgentNotFound() *DeleteSpoeAgentNotFound { + + return &DeleteSpoeAgentNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe agent not found response +func (o *DeleteSpoeAgentNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSpoeAgentNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe agent not found response +func (o *DeleteSpoeAgentNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe agent not found response +func (o *DeleteSpoeAgentNotFound) WithPayload(payload *models.Error) *DeleteSpoeAgentNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe agent not found response +func (o *DeleteSpoeAgentNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeAgentNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteSpoeAgentDefault General Error + +swagger:response deleteSpoeAgentDefault +*/ +type DeleteSpoeAgentDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeAgentDefault creates DeleteSpoeAgentDefault with default headers values +func NewDeleteSpoeAgentDefault(code int) *DeleteSpoeAgentDefault { + if code <= 0 { + code = 500 + } + + return &DeleteSpoeAgentDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete spoe agent default response +func (o *DeleteSpoeAgentDefault) WithStatusCode(code int) *DeleteSpoeAgentDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete spoe agent default response +func (o *DeleteSpoeAgentDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe agent default response +func (o *DeleteSpoeAgentDefault) WithConfigurationVersion(configurationVersion string) *DeleteSpoeAgentDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe agent default response +func (o *DeleteSpoeAgentDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe agent default response +func (o *DeleteSpoeAgentDefault) WithPayload(payload *models.Error) *DeleteSpoeAgentDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe agent default response +func (o *DeleteSpoeAgentDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeAgentDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/delete_spoe_agent_urlbuilder.go b/operations/spoe/delete_spoe_agent_urlbuilder.go new file mode 100644 index 00000000..1db74430 --- /dev/null +++ b/operations/spoe/delete_spoe_agent_urlbuilder.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteSpoeAgentURL generates an URL for the delete spoe agent operation +type DeleteSpoeAgentURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeAgentURL) WithBasePath(bp string) *DeleteSpoeAgentURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeAgentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteSpoeAgentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteSpoeAgentURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteSpoeAgentURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on DeleteSpoeAgentURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteSpoeAgentURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteSpoeAgentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteSpoeAgentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteSpoeAgentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteSpoeAgentURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteSpoeAgentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/delete_spoe_file.go b/operations/spoe/delete_spoe_file.go new file mode 100644 index 00000000..f1acbd35 --- /dev/null +++ b/operations/spoe/delete_spoe_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteSpoeFileHandlerFunc turns a function with the right signature into a delete spoe file handler +type DeleteSpoeFileHandlerFunc func(DeleteSpoeFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteSpoeFileHandlerFunc) Handle(params DeleteSpoeFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteSpoeFileHandler interface for that can handle valid delete spoe file params +type DeleteSpoeFileHandler interface { + Handle(DeleteSpoeFileParams, interface{}) middleware.Responder +} + +// NewDeleteSpoeFile creates a new http.Handler for the delete spoe file operation +func NewDeleteSpoeFile(ctx *middleware.Context, handler DeleteSpoeFileHandler) *DeleteSpoeFile { + return &DeleteSpoeFile{Context: ctx, Handler: handler} +} + +/* + DeleteSpoeFile swagger:route DELETE /services/haproxy/spoe/spoe_files/{name} Spoe deleteSpoeFile + +# Delete SPOE file + +Deletes SPOE file. +*/ +type DeleteSpoeFile struct { + Context *middleware.Context + Handler DeleteSpoeFileHandler +} + +func (o *DeleteSpoeFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteSpoeFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/delete_spoe_file_parameters.go b/operations/spoe/delete_spoe_file_parameters.go new file mode 100644 index 00000000..bbc0a8ec --- /dev/null +++ b/operations/spoe/delete_spoe_file_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteSpoeFileParams creates a new DeleteSpoeFileParams object +// +// There are no default values defined in the spec. +func NewDeleteSpoeFileParams() DeleteSpoeFileParams { + + return DeleteSpoeFileParams{} +} + +// DeleteSpoeFileParams contains all the bound params for the delete spoe file operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteSpoeFile +type DeleteSpoeFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SPOE file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteSpoeFileParams() beforehand. +func (o *DeleteSpoeFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteSpoeFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/spoe/delete_spoe_file_responses.go b/operations/spoe/delete_spoe_file_responses.go new file mode 100644 index 00000000..cfd4a1ed --- /dev/null +++ b/operations/spoe/delete_spoe_file_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteSpoeFileNoContentCode is the HTTP code returned for type DeleteSpoeFileNoContent +const DeleteSpoeFileNoContentCode int = 204 + +/* +DeleteSpoeFileNoContent SPOE file deleted + +swagger:response deleteSpoeFileNoContent +*/ +type DeleteSpoeFileNoContent struct { +} + +// NewDeleteSpoeFileNoContent creates DeleteSpoeFileNoContent with default headers values +func NewDeleteSpoeFileNoContent() *DeleteSpoeFileNoContent { + + return &DeleteSpoeFileNoContent{} +} + +// WriteResponse to the client +func (o *DeleteSpoeFileNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteSpoeFileNotFoundCode is the HTTP code returned for type DeleteSpoeFileNotFound +const DeleteSpoeFileNotFoundCode int = 404 + +/* +DeleteSpoeFileNotFound The specified resource was not found + +swagger:response deleteSpoeFileNotFound +*/ +type DeleteSpoeFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeFileNotFound creates DeleteSpoeFileNotFound with default headers values +func NewDeleteSpoeFileNotFound() *DeleteSpoeFileNotFound { + + return &DeleteSpoeFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe file not found response +func (o *DeleteSpoeFileNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSpoeFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe file not found response +func (o *DeleteSpoeFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe file not found response +func (o *DeleteSpoeFileNotFound) WithPayload(payload *models.Error) *DeleteSpoeFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe file not found response +func (o *DeleteSpoeFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteSpoeFileDefault General Error + +swagger:response deleteSpoeFileDefault +*/ +type DeleteSpoeFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeFileDefault creates DeleteSpoeFileDefault with default headers values +func NewDeleteSpoeFileDefault(code int) *DeleteSpoeFileDefault { + if code <= 0 { + code = 500 + } + + return &DeleteSpoeFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete spoe file default response +func (o *DeleteSpoeFileDefault) WithStatusCode(code int) *DeleteSpoeFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete spoe file default response +func (o *DeleteSpoeFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe file default response +func (o *DeleteSpoeFileDefault) WithConfigurationVersion(configurationVersion string) *DeleteSpoeFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe file default response +func (o *DeleteSpoeFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe file default response +func (o *DeleteSpoeFileDefault) WithPayload(payload *models.Error) *DeleteSpoeFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe file default response +func (o *DeleteSpoeFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/delete_spoe_file_urlbuilder.go b/operations/spoe/delete_spoe_file_urlbuilder.go new file mode 100644 index 00000000..f88e4dee --- /dev/null +++ b/operations/spoe/delete_spoe_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteSpoeFileURL generates an URL for the delete spoe file operation +type DeleteSpoeFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeFileURL) WithBasePath(bp string) *DeleteSpoeFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteSpoeFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteSpoeFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteSpoeFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteSpoeFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteSpoeFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteSpoeFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteSpoeFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteSpoeFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/delete_spoe_group.go b/operations/spoe/delete_spoe_group.go new file mode 100644 index 00000000..42260916 --- /dev/null +++ b/operations/spoe/delete_spoe_group.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteSpoeGroupHandlerFunc turns a function with the right signature into a delete spoe group handler +type DeleteSpoeGroupHandlerFunc func(DeleteSpoeGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteSpoeGroupHandlerFunc) Handle(params DeleteSpoeGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteSpoeGroupHandler interface for that can handle valid delete spoe group params +type DeleteSpoeGroupHandler interface { + Handle(DeleteSpoeGroupParams, interface{}) middleware.Responder +} + +// NewDeleteSpoeGroup creates a new http.Handler for the delete spoe group operation +func NewDeleteSpoeGroup(ctx *middleware.Context, handler DeleteSpoeGroupHandler) *DeleteSpoeGroup { + return &DeleteSpoeGroup{Context: ctx, Handler: handler} +} + +/* + DeleteSpoeGroup swagger:route DELETE /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name} Spoe deleteSpoeGroup + +# Delete a SPOE groups + +Deletes a SPOE groups from the one SPOE scope. +*/ +type DeleteSpoeGroup struct { + Context *middleware.Context + Handler DeleteSpoeGroupHandler +} + +func (o *DeleteSpoeGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteSpoeGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/delete_spoe_group_parameters.go b/operations/spoe/delete_spoe_group_parameters.go new file mode 100644 index 00000000..640fffbf --- /dev/null +++ b/operations/spoe/delete_spoe_group_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteSpoeGroupParams creates a new DeleteSpoeGroupParams object +// +// There are no default values defined in the spec. +func NewDeleteSpoeGroupParams() DeleteSpoeGroupParams { + + return DeleteSpoeGroupParams{} +} + +// DeleteSpoeGroupParams contains all the bound params for the delete spoe group operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteSpoeGroup +type DeleteSpoeGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe group name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteSpoeGroupParams() beforehand. +func (o *DeleteSpoeGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteSpoeGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteSpoeGroupParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *DeleteSpoeGroupParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteSpoeGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteSpoeGroupParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/delete_spoe_group_responses.go b/operations/spoe/delete_spoe_group_responses.go new file mode 100644 index 00000000..cf39598e --- /dev/null +++ b/operations/spoe/delete_spoe_group_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteSpoeGroupNoContentCode is the HTTP code returned for type DeleteSpoeGroupNoContent +const DeleteSpoeGroupNoContentCode int = 204 + +/* +DeleteSpoeGroupNoContent Spoe group deleted + +swagger:response deleteSpoeGroupNoContent +*/ +type DeleteSpoeGroupNoContent struct { +} + +// NewDeleteSpoeGroupNoContent creates DeleteSpoeGroupNoContent with default headers values +func NewDeleteSpoeGroupNoContent() *DeleteSpoeGroupNoContent { + + return &DeleteSpoeGroupNoContent{} +} + +// WriteResponse to the client +func (o *DeleteSpoeGroupNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteSpoeGroupNotFoundCode is the HTTP code returned for type DeleteSpoeGroupNotFound +const DeleteSpoeGroupNotFoundCode int = 404 + +/* +DeleteSpoeGroupNotFound The specified resource was not found + +swagger:response deleteSpoeGroupNotFound +*/ +type DeleteSpoeGroupNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeGroupNotFound creates DeleteSpoeGroupNotFound with default headers values +func NewDeleteSpoeGroupNotFound() *DeleteSpoeGroupNotFound { + + return &DeleteSpoeGroupNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe group not found response +func (o *DeleteSpoeGroupNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSpoeGroupNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe group not found response +func (o *DeleteSpoeGroupNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe group not found response +func (o *DeleteSpoeGroupNotFound) WithPayload(payload *models.Error) *DeleteSpoeGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe group not found response +func (o *DeleteSpoeGroupNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteSpoeGroupDefault General Error + +swagger:response deleteSpoeGroupDefault +*/ +type DeleteSpoeGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeGroupDefault creates DeleteSpoeGroupDefault with default headers values +func NewDeleteSpoeGroupDefault(code int) *DeleteSpoeGroupDefault { + if code <= 0 { + code = 500 + } + + return &DeleteSpoeGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete spoe group default response +func (o *DeleteSpoeGroupDefault) WithStatusCode(code int) *DeleteSpoeGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete spoe group default response +func (o *DeleteSpoeGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe group default response +func (o *DeleteSpoeGroupDefault) WithConfigurationVersion(configurationVersion string) *DeleteSpoeGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe group default response +func (o *DeleteSpoeGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe group default response +func (o *DeleteSpoeGroupDefault) WithPayload(payload *models.Error) *DeleteSpoeGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe group default response +func (o *DeleteSpoeGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/delete_spoe_group_urlbuilder.go b/operations/spoe/delete_spoe_group_urlbuilder.go new file mode 100644 index 00000000..952be1a9 --- /dev/null +++ b/operations/spoe/delete_spoe_group_urlbuilder.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteSpoeGroupURL generates an URL for the delete spoe group operation +type DeleteSpoeGroupURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeGroupURL) WithBasePath(bp string) *DeleteSpoeGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteSpoeGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteSpoeGroupURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteSpoeGroupURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on DeleteSpoeGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteSpoeGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteSpoeGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteSpoeGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteSpoeGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteSpoeGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteSpoeGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/delete_spoe_message.go b/operations/spoe/delete_spoe_message.go new file mode 100644 index 00000000..7bcbe5b8 --- /dev/null +++ b/operations/spoe/delete_spoe_message.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteSpoeMessageHandlerFunc turns a function with the right signature into a delete spoe message handler +type DeleteSpoeMessageHandlerFunc func(DeleteSpoeMessageParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteSpoeMessageHandlerFunc) Handle(params DeleteSpoeMessageParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteSpoeMessageHandler interface for that can handle valid delete spoe message params +type DeleteSpoeMessageHandler interface { + Handle(DeleteSpoeMessageParams, interface{}) middleware.Responder +} + +// NewDeleteSpoeMessage creates a new http.Handler for the delete spoe message operation +func NewDeleteSpoeMessage(ctx *middleware.Context, handler DeleteSpoeMessageHandler) *DeleteSpoeMessage { + return &DeleteSpoeMessage{Context: ctx, Handler: handler} +} + +/* + DeleteSpoeMessage swagger:route DELETE /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name} Spoe deleteSpoeMessage + +# Delete a spoe message + +Deletes a spoe message from the SPOE scope. +*/ +type DeleteSpoeMessage struct { + Context *middleware.Context + Handler DeleteSpoeMessageHandler +} + +func (o *DeleteSpoeMessage) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteSpoeMessageParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/delete_spoe_message_parameters.go b/operations/spoe/delete_spoe_message_parameters.go new file mode 100644 index 00000000..b5d25b11 --- /dev/null +++ b/operations/spoe/delete_spoe_message_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteSpoeMessageParams creates a new DeleteSpoeMessageParams object +// +// There are no default values defined in the spec. +func NewDeleteSpoeMessageParams() DeleteSpoeMessageParams { + + return DeleteSpoeMessageParams{} +} + +// DeleteSpoeMessageParams contains all the bound params for the delete spoe message operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteSpoeMessage +type DeleteSpoeMessageParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe message name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteSpoeMessageParams() beforehand. +func (o *DeleteSpoeMessageParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteSpoeMessageParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteSpoeMessageParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *DeleteSpoeMessageParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteSpoeMessageParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteSpoeMessageParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/delete_spoe_message_responses.go b/operations/spoe/delete_spoe_message_responses.go new file mode 100644 index 00000000..0283771d --- /dev/null +++ b/operations/spoe/delete_spoe_message_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteSpoeMessageNoContentCode is the HTTP code returned for type DeleteSpoeMessageNoContent +const DeleteSpoeMessageNoContentCode int = 204 + +/* +DeleteSpoeMessageNoContent Spoe message deleted + +swagger:response deleteSpoeMessageNoContent +*/ +type DeleteSpoeMessageNoContent struct { +} + +// NewDeleteSpoeMessageNoContent creates DeleteSpoeMessageNoContent with default headers values +func NewDeleteSpoeMessageNoContent() *DeleteSpoeMessageNoContent { + + return &DeleteSpoeMessageNoContent{} +} + +// WriteResponse to the client +func (o *DeleteSpoeMessageNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteSpoeMessageNotFoundCode is the HTTP code returned for type DeleteSpoeMessageNotFound +const DeleteSpoeMessageNotFoundCode int = 404 + +/* +DeleteSpoeMessageNotFound The specified resource was not found + +swagger:response deleteSpoeMessageNotFound +*/ +type DeleteSpoeMessageNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeMessageNotFound creates DeleteSpoeMessageNotFound with default headers values +func NewDeleteSpoeMessageNotFound() *DeleteSpoeMessageNotFound { + + return &DeleteSpoeMessageNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe message not found response +func (o *DeleteSpoeMessageNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSpoeMessageNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe message not found response +func (o *DeleteSpoeMessageNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe message not found response +func (o *DeleteSpoeMessageNotFound) WithPayload(payload *models.Error) *DeleteSpoeMessageNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe message not found response +func (o *DeleteSpoeMessageNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeMessageNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteSpoeMessageDefault General Error + +swagger:response deleteSpoeMessageDefault +*/ +type DeleteSpoeMessageDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeMessageDefault creates DeleteSpoeMessageDefault with default headers values +func NewDeleteSpoeMessageDefault(code int) *DeleteSpoeMessageDefault { + if code <= 0 { + code = 500 + } + + return &DeleteSpoeMessageDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete spoe message default response +func (o *DeleteSpoeMessageDefault) WithStatusCode(code int) *DeleteSpoeMessageDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete spoe message default response +func (o *DeleteSpoeMessageDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe message default response +func (o *DeleteSpoeMessageDefault) WithConfigurationVersion(configurationVersion string) *DeleteSpoeMessageDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe message default response +func (o *DeleteSpoeMessageDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe message default response +func (o *DeleteSpoeMessageDefault) WithPayload(payload *models.Error) *DeleteSpoeMessageDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe message default response +func (o *DeleteSpoeMessageDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeMessageDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/delete_spoe_message_urlbuilder.go b/operations/spoe/delete_spoe_message_urlbuilder.go new file mode 100644 index 00000000..42a83772 --- /dev/null +++ b/operations/spoe/delete_spoe_message_urlbuilder.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteSpoeMessageURL generates an URL for the delete spoe message operation +type DeleteSpoeMessageURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeMessageURL) WithBasePath(bp string) *DeleteSpoeMessageURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeMessageURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteSpoeMessageURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteSpoeMessageURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteSpoeMessageURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on DeleteSpoeMessageURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteSpoeMessageURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteSpoeMessageURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteSpoeMessageURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteSpoeMessageURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteSpoeMessageURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteSpoeMessageURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/delete_spoe_scope.go b/operations/spoe/delete_spoe_scope.go new file mode 100644 index 00000000..b6758424 --- /dev/null +++ b/operations/spoe/delete_spoe_scope.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteSpoeScopeHandlerFunc turns a function with the right signature into a delete spoe scope handler +type DeleteSpoeScopeHandlerFunc func(DeleteSpoeScopeParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteSpoeScopeHandlerFunc) Handle(params DeleteSpoeScopeParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteSpoeScopeHandler interface for that can handle valid delete spoe scope params +type DeleteSpoeScopeHandler interface { + Handle(DeleteSpoeScopeParams, interface{}) middleware.Responder +} + +// NewDeleteSpoeScope creates a new http.Handler for the delete spoe scope operation +func NewDeleteSpoeScope(ctx *middleware.Context, handler DeleteSpoeScopeHandler) *DeleteSpoeScope { + return &DeleteSpoeScope{Context: ctx, Handler: handler} +} + +/* + DeleteSpoeScope swagger:route DELETE /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name} Spoe deleteSpoeScope + +# Delete a SPOE scope + +Deletes a SPOE scope from the configuration file. +*/ +type DeleteSpoeScope struct { + Context *middleware.Context + Handler DeleteSpoeScopeHandler +} + +func (o *DeleteSpoeScope) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteSpoeScopeParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/delete_spoe_scope_parameters.go b/operations/spoe/delete_spoe_scope_parameters.go new file mode 100644 index 00000000..d4a3423b --- /dev/null +++ b/operations/spoe/delete_spoe_scope_parameters.go @@ -0,0 +1,173 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteSpoeScopeParams creates a new DeleteSpoeScopeParams object +// +// There are no default values defined in the spec. +func NewDeleteSpoeScopeParams() DeleteSpoeScopeParams { + + return DeleteSpoeScopeParams{} +} + +// DeleteSpoeScopeParams contains all the bound params for the delete spoe scope operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteSpoeScope +type DeleteSpoeScopeParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe scope name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteSpoeScopeParams() beforehand. +func (o *DeleteSpoeScopeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteSpoeScopeParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteSpoeScopeParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteSpoeScopeParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteSpoeScopeParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/delete_spoe_scope_responses.go b/operations/spoe/delete_spoe_scope_responses.go new file mode 100644 index 00000000..d58df513 --- /dev/null +++ b/operations/spoe/delete_spoe_scope_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteSpoeScopeNoContentCode is the HTTP code returned for type DeleteSpoeScopeNoContent +const DeleteSpoeScopeNoContentCode int = 204 + +/* +DeleteSpoeScopeNoContent Spoe scope deleted + +swagger:response deleteSpoeScopeNoContent +*/ +type DeleteSpoeScopeNoContent struct { +} + +// NewDeleteSpoeScopeNoContent creates DeleteSpoeScopeNoContent with default headers values +func NewDeleteSpoeScopeNoContent() *DeleteSpoeScopeNoContent { + + return &DeleteSpoeScopeNoContent{} +} + +// WriteResponse to the client +func (o *DeleteSpoeScopeNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteSpoeScopeNotFoundCode is the HTTP code returned for type DeleteSpoeScopeNotFound +const DeleteSpoeScopeNotFoundCode int = 404 + +/* +DeleteSpoeScopeNotFound The specified resource was not found + +swagger:response deleteSpoeScopeNotFound +*/ +type DeleteSpoeScopeNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeScopeNotFound creates DeleteSpoeScopeNotFound with default headers values +func NewDeleteSpoeScopeNotFound() *DeleteSpoeScopeNotFound { + + return &DeleteSpoeScopeNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe scope not found response +func (o *DeleteSpoeScopeNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSpoeScopeNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe scope not found response +func (o *DeleteSpoeScopeNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe scope not found response +func (o *DeleteSpoeScopeNotFound) WithPayload(payload *models.Error) *DeleteSpoeScopeNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe scope not found response +func (o *DeleteSpoeScopeNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeScopeNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteSpoeScopeDefault General Error + +swagger:response deleteSpoeScopeDefault +*/ +type DeleteSpoeScopeDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeScopeDefault creates DeleteSpoeScopeDefault with default headers values +func NewDeleteSpoeScopeDefault(code int) *DeleteSpoeScopeDefault { + if code <= 0 { + code = 500 + } + + return &DeleteSpoeScopeDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete spoe scope default response +func (o *DeleteSpoeScopeDefault) WithStatusCode(code int) *DeleteSpoeScopeDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete spoe scope default response +func (o *DeleteSpoeScopeDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe scope default response +func (o *DeleteSpoeScopeDefault) WithConfigurationVersion(configurationVersion string) *DeleteSpoeScopeDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe scope default response +func (o *DeleteSpoeScopeDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe scope default response +func (o *DeleteSpoeScopeDefault) WithPayload(payload *models.Error) *DeleteSpoeScopeDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe scope default response +func (o *DeleteSpoeScopeDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeScopeDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/delete_spoe_scope_urlbuilder.go b/operations/spoe/delete_spoe_scope_urlbuilder.go new file mode 100644 index 00000000..67ae59e9 --- /dev/null +++ b/operations/spoe/delete_spoe_scope_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteSpoeScopeURL generates an URL for the delete spoe scope operation +type DeleteSpoeScopeURL struct { + Name string + ParentName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeScopeURL) WithBasePath(bp string) *DeleteSpoeScopeURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeScopeURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteSpoeScopeURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteSpoeScopeURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteSpoeScopeURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteSpoeScopeURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteSpoeScopeURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteSpoeScopeURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteSpoeScopeURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteSpoeScopeURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteSpoeScopeURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_all_spoe_agent.go b/operations/spoe/get_all_spoe_agent.go new file mode 100644 index 00000000..595eb914 --- /dev/null +++ b/operations/spoe/get_all_spoe_agent.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllSpoeAgentHandlerFunc turns a function with the right signature into a get all spoe agent handler +type GetAllSpoeAgentHandlerFunc func(GetAllSpoeAgentParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllSpoeAgentHandlerFunc) Handle(params GetAllSpoeAgentParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllSpoeAgentHandler interface for that can handle valid get all spoe agent params +type GetAllSpoeAgentHandler interface { + Handle(GetAllSpoeAgentParams, interface{}) middleware.Responder +} + +// NewGetAllSpoeAgent creates a new http.Handler for the get all spoe agent operation +func NewGetAllSpoeAgent(ctx *middleware.Context, handler GetAllSpoeAgentHandler) *GetAllSpoeAgent { + return &GetAllSpoeAgent{Context: ctx, Handler: handler} +} + +/* + GetAllSpoeAgent swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents Spoe getAllSpoeAgent + +# Return an array of spoe agents in one scope + +Returns an array of all configured spoe agents in one scope. +*/ +type GetAllSpoeAgent struct { + Context *middleware.Context + Handler GetAllSpoeAgentHandler +} + +func (o *GetAllSpoeAgent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllSpoeAgentParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_all_spoe_agent_parameters.go b/operations/spoe/get_all_spoe_agent_parameters.go new file mode 100644 index 00000000..2d3c4e52 --- /dev/null +++ b/operations/spoe/get_all_spoe_agent_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllSpoeAgentParams creates a new GetAllSpoeAgentParams object +// +// There are no default values defined in the spec. +func NewGetAllSpoeAgentParams() GetAllSpoeAgentParams { + + return GetAllSpoeAgentParams{} +} + +// GetAllSpoeAgentParams contains all the bound params for the get all spoe agent operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllSpoeAgent +type GetAllSpoeAgentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllSpoeAgentParams() beforehand. +func (o *GetAllSpoeAgentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllSpoeAgentParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *GetAllSpoeAgentParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllSpoeAgentParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_all_spoe_agent_responses.go b/operations/spoe/get_all_spoe_agent_responses.go new file mode 100644 index 00000000..f109dd09 --- /dev/null +++ b/operations/spoe/get_all_spoe_agent_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllSpoeAgentOKCode is the HTTP code returned for type GetAllSpoeAgentOK +const GetAllSpoeAgentOKCode int = 200 + +/* +GetAllSpoeAgentOK Successful operation + +swagger:response getAllSpoeAgentOK +*/ +type GetAllSpoeAgentOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.SpoeAgents `json:"body,omitempty"` +} + +// NewGetAllSpoeAgentOK creates GetAllSpoeAgentOK with default headers values +func NewGetAllSpoeAgentOK() *GetAllSpoeAgentOK { + + return &GetAllSpoeAgentOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe agent o k response +func (o *GetAllSpoeAgentOK) WithConfigurationVersion(configurationVersion string) *GetAllSpoeAgentOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe agent o k response +func (o *GetAllSpoeAgentOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe agent o k response +func (o *GetAllSpoeAgentOK) WithPayload(payload models.SpoeAgents) *GetAllSpoeAgentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe agent o k response +func (o *GetAllSpoeAgentOK) SetPayload(payload models.SpoeAgents) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeAgentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SpoeAgents{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllSpoeAgentDefault General Error + +swagger:response getAllSpoeAgentDefault +*/ +type GetAllSpoeAgentDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSpoeAgentDefault creates GetAllSpoeAgentDefault with default headers values +func NewGetAllSpoeAgentDefault(code int) *GetAllSpoeAgentDefault { + if code <= 0 { + code = 500 + } + + return &GetAllSpoeAgentDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all spoe agent default response +func (o *GetAllSpoeAgentDefault) WithStatusCode(code int) *GetAllSpoeAgentDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all spoe agent default response +func (o *GetAllSpoeAgentDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe agent default response +func (o *GetAllSpoeAgentDefault) WithConfigurationVersion(configurationVersion string) *GetAllSpoeAgentDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe agent default response +func (o *GetAllSpoeAgentDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe agent default response +func (o *GetAllSpoeAgentDefault) WithPayload(payload *models.Error) *GetAllSpoeAgentDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe agent default response +func (o *GetAllSpoeAgentDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeAgentDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_all_spoe_agent_urlbuilder.go b/operations/spoe/get_all_spoe_agent_urlbuilder.go new file mode 100644 index 00000000..36307a31 --- /dev/null +++ b/operations/spoe/get_all_spoe_agent_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllSpoeAgentURL generates an URL for the get all spoe agent operation +type GetAllSpoeAgentURL struct { + ParentName string + ScopeName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeAgentURL) WithBasePath(bp string) *GetAllSpoeAgentURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeAgentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllSpoeAgentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllSpoeAgentURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on GetAllSpoeAgentURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllSpoeAgentURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllSpoeAgentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllSpoeAgentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllSpoeAgentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllSpoeAgentURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllSpoeAgentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_all_spoe_files.go b/operations/spoe/get_all_spoe_files.go new file mode 100644 index 00000000..f8e69826 --- /dev/null +++ b/operations/spoe/get_all_spoe_files.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllSpoeFilesHandlerFunc turns a function with the right signature into a get all spoe files handler +type GetAllSpoeFilesHandlerFunc func(GetAllSpoeFilesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllSpoeFilesHandlerFunc) Handle(params GetAllSpoeFilesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllSpoeFilesHandler interface for that can handle valid get all spoe files params +type GetAllSpoeFilesHandler interface { + Handle(GetAllSpoeFilesParams, interface{}) middleware.Responder +} + +// NewGetAllSpoeFiles creates a new http.Handler for the get all spoe files operation +func NewGetAllSpoeFiles(ctx *middleware.Context, handler GetAllSpoeFilesHandler) *GetAllSpoeFiles { + return &GetAllSpoeFiles{Context: ctx, Handler: handler} +} + +/* + GetAllSpoeFiles swagger:route GET /services/haproxy/spoe/spoe_files Spoe getAllSpoeFiles + +# Return all available SPOE files + +Returns all available SPOE files. +*/ +type GetAllSpoeFiles struct { + Context *middleware.Context + Handler GetAllSpoeFilesHandler +} + +func (o *GetAllSpoeFiles) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllSpoeFilesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_all_spoe_files_parameters.go b/operations/spoe/get_all_spoe_files_parameters.go new file mode 100644 index 00000000..56f50c8a --- /dev/null +++ b/operations/spoe/get_all_spoe_files_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllSpoeFilesParams creates a new GetAllSpoeFilesParams object +// +// There are no default values defined in the spec. +func NewGetAllSpoeFilesParams() GetAllSpoeFilesParams { + + return GetAllSpoeFilesParams{} +} + +// GetAllSpoeFilesParams contains all the bound params for the get all spoe files operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllSpoeFiles +type GetAllSpoeFilesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllSpoeFilesParams() beforehand. +func (o *GetAllSpoeFilesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/spoe/get_all_spoe_files_responses.go b/operations/spoe/get_all_spoe_files_responses.go new file mode 100644 index 00000000..18d90136 --- /dev/null +++ b/operations/spoe/get_all_spoe_files_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllSpoeFilesOKCode is the HTTP code returned for type GetAllSpoeFilesOK +const GetAllSpoeFilesOKCode int = 200 + +/* +GetAllSpoeFilesOK Successful operation + +swagger:response getAllSpoeFilesOK +*/ +type GetAllSpoeFilesOK struct { + + /* + In: Body + */ + Payload models.SpoeFiles `json:"body,omitempty"` +} + +// NewGetAllSpoeFilesOK creates GetAllSpoeFilesOK with default headers values +func NewGetAllSpoeFilesOK() *GetAllSpoeFilesOK { + + return &GetAllSpoeFilesOK{} +} + +// WithPayload adds the payload to the get all spoe files o k response +func (o *GetAllSpoeFilesOK) WithPayload(payload models.SpoeFiles) *GetAllSpoeFilesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe files o k response +func (o *GetAllSpoeFilesOK) SetPayload(payload models.SpoeFiles) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeFilesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SpoeFiles{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAllSpoeFilesNotFoundCode is the HTTP code returned for type GetAllSpoeFilesNotFound +const GetAllSpoeFilesNotFoundCode int = 404 + +/* +GetAllSpoeFilesNotFound The specified resource was not found + +swagger:response getAllSpoeFilesNotFound +*/ +type GetAllSpoeFilesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSpoeFilesNotFound creates GetAllSpoeFilesNotFound with default headers values +func NewGetAllSpoeFilesNotFound() *GetAllSpoeFilesNotFound { + + return &GetAllSpoeFilesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe files not found response +func (o *GetAllSpoeFilesNotFound) WithConfigurationVersion(configurationVersion string) *GetAllSpoeFilesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe files not found response +func (o *GetAllSpoeFilesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe files not found response +func (o *GetAllSpoeFilesNotFound) WithPayload(payload *models.Error) *GetAllSpoeFilesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe files not found response +func (o *GetAllSpoeFilesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeFilesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAllSpoeFilesDefault General Error + +swagger:response getAllSpoeFilesDefault +*/ +type GetAllSpoeFilesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSpoeFilesDefault creates GetAllSpoeFilesDefault with default headers values +func NewGetAllSpoeFilesDefault(code int) *GetAllSpoeFilesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllSpoeFilesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all spoe files default response +func (o *GetAllSpoeFilesDefault) WithStatusCode(code int) *GetAllSpoeFilesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all spoe files default response +func (o *GetAllSpoeFilesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe files default response +func (o *GetAllSpoeFilesDefault) WithConfigurationVersion(configurationVersion string) *GetAllSpoeFilesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe files default response +func (o *GetAllSpoeFilesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe files default response +func (o *GetAllSpoeFilesDefault) WithPayload(payload *models.Error) *GetAllSpoeFilesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe files default response +func (o *GetAllSpoeFilesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeFilesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_all_spoe_files_urlbuilder.go b/operations/spoe/get_all_spoe_files_urlbuilder.go new file mode 100644 index 00000000..0eb2ce03 --- /dev/null +++ b/operations/spoe/get_all_spoe_files_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllSpoeFilesURL generates an URL for the get all spoe files operation +type GetAllSpoeFilesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeFilesURL) WithBasePath(bp string) *GetAllSpoeFilesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeFilesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllSpoeFilesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllSpoeFilesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllSpoeFilesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllSpoeFilesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllSpoeFilesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllSpoeFilesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllSpoeFilesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_all_spoe_group.go b/operations/spoe/get_all_spoe_group.go new file mode 100644 index 00000000..40dcbd62 --- /dev/null +++ b/operations/spoe/get_all_spoe_group.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllSpoeGroupHandlerFunc turns a function with the right signature into a get all spoe group handler +type GetAllSpoeGroupHandlerFunc func(GetAllSpoeGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllSpoeGroupHandlerFunc) Handle(params GetAllSpoeGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllSpoeGroupHandler interface for that can handle valid get all spoe group params +type GetAllSpoeGroupHandler interface { + Handle(GetAllSpoeGroupParams, interface{}) middleware.Responder +} + +// NewGetAllSpoeGroup creates a new http.Handler for the get all spoe group operation +func NewGetAllSpoeGroup(ctx *middleware.Context, handler GetAllSpoeGroupHandler) *GetAllSpoeGroup { + return &GetAllSpoeGroup{Context: ctx, Handler: handler} +} + +/* + GetAllSpoeGroup swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups Spoe getAllSpoeGroup + +# Return an array of SPOE groups + +Returns an array of all configured SPOE groups in one SPOE scope. +*/ +type GetAllSpoeGroup struct { + Context *middleware.Context + Handler GetAllSpoeGroupHandler +} + +func (o *GetAllSpoeGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllSpoeGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_all_spoe_group_parameters.go b/operations/spoe/get_all_spoe_group_parameters.go new file mode 100644 index 00000000..115dc82c --- /dev/null +++ b/operations/spoe/get_all_spoe_group_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllSpoeGroupParams creates a new GetAllSpoeGroupParams object +// +// There are no default values defined in the spec. +func NewGetAllSpoeGroupParams() GetAllSpoeGroupParams { + + return GetAllSpoeGroupParams{} +} + +// GetAllSpoeGroupParams contains all the bound params for the get all spoe group operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllSpoeGroup +type GetAllSpoeGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllSpoeGroupParams() beforehand. +func (o *GetAllSpoeGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllSpoeGroupParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *GetAllSpoeGroupParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllSpoeGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_all_spoe_group_responses.go b/operations/spoe/get_all_spoe_group_responses.go new file mode 100644 index 00000000..dbb51061 --- /dev/null +++ b/operations/spoe/get_all_spoe_group_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllSpoeGroupOKCode is the HTTP code returned for type GetAllSpoeGroupOK +const GetAllSpoeGroupOKCode int = 200 + +/* +GetAllSpoeGroupOK Successful operation + +swagger:response getAllSpoeGroupOK +*/ +type GetAllSpoeGroupOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.SpoeGroups `json:"body,omitempty"` +} + +// NewGetAllSpoeGroupOK creates GetAllSpoeGroupOK with default headers values +func NewGetAllSpoeGroupOK() *GetAllSpoeGroupOK { + + return &GetAllSpoeGroupOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe group o k response +func (o *GetAllSpoeGroupOK) WithConfigurationVersion(configurationVersion string) *GetAllSpoeGroupOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe group o k response +func (o *GetAllSpoeGroupOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe group o k response +func (o *GetAllSpoeGroupOK) WithPayload(payload models.SpoeGroups) *GetAllSpoeGroupOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe group o k response +func (o *GetAllSpoeGroupOK) SetPayload(payload models.SpoeGroups) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SpoeGroups{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllSpoeGroupDefault General Error + +swagger:response getAllSpoeGroupDefault +*/ +type GetAllSpoeGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSpoeGroupDefault creates GetAllSpoeGroupDefault with default headers values +func NewGetAllSpoeGroupDefault(code int) *GetAllSpoeGroupDefault { + if code <= 0 { + code = 500 + } + + return &GetAllSpoeGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all spoe group default response +func (o *GetAllSpoeGroupDefault) WithStatusCode(code int) *GetAllSpoeGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all spoe group default response +func (o *GetAllSpoeGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe group default response +func (o *GetAllSpoeGroupDefault) WithConfigurationVersion(configurationVersion string) *GetAllSpoeGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe group default response +func (o *GetAllSpoeGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe group default response +func (o *GetAllSpoeGroupDefault) WithPayload(payload *models.Error) *GetAllSpoeGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe group default response +func (o *GetAllSpoeGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_all_spoe_group_urlbuilder.go b/operations/spoe/get_all_spoe_group_urlbuilder.go new file mode 100644 index 00000000..a9a75290 --- /dev/null +++ b/operations/spoe/get_all_spoe_group_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllSpoeGroupURL generates an URL for the get all spoe group operation +type GetAllSpoeGroupURL struct { + ParentName string + ScopeName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeGroupURL) WithBasePath(bp string) *GetAllSpoeGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllSpoeGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllSpoeGroupURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on GetAllSpoeGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllSpoeGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllSpoeGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllSpoeGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllSpoeGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllSpoeGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllSpoeGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_all_spoe_message.go b/operations/spoe/get_all_spoe_message.go new file mode 100644 index 00000000..7e43bd68 --- /dev/null +++ b/operations/spoe/get_all_spoe_message.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllSpoeMessageHandlerFunc turns a function with the right signature into a get all spoe message handler +type GetAllSpoeMessageHandlerFunc func(GetAllSpoeMessageParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllSpoeMessageHandlerFunc) Handle(params GetAllSpoeMessageParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllSpoeMessageHandler interface for that can handle valid get all spoe message params +type GetAllSpoeMessageHandler interface { + Handle(GetAllSpoeMessageParams, interface{}) middleware.Responder +} + +// NewGetAllSpoeMessage creates a new http.Handler for the get all spoe message operation +func NewGetAllSpoeMessage(ctx *middleware.Context, handler GetAllSpoeMessageHandler) *GetAllSpoeMessage { + return &GetAllSpoeMessage{Context: ctx, Handler: handler} +} + +/* + GetAllSpoeMessage swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages Spoe getAllSpoeMessage + +# Return an array of spoe messages in one scope + +Returns an array of all configured spoe messages in one scope. +*/ +type GetAllSpoeMessage struct { + Context *middleware.Context + Handler GetAllSpoeMessageHandler +} + +func (o *GetAllSpoeMessage) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllSpoeMessageParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_all_spoe_message_parameters.go b/operations/spoe/get_all_spoe_message_parameters.go new file mode 100644 index 00000000..97d1f285 --- /dev/null +++ b/operations/spoe/get_all_spoe_message_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllSpoeMessageParams creates a new GetAllSpoeMessageParams object +// +// There are no default values defined in the spec. +func NewGetAllSpoeMessageParams() GetAllSpoeMessageParams { + + return GetAllSpoeMessageParams{} +} + +// GetAllSpoeMessageParams contains all the bound params for the get all spoe message operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllSpoeMessage +type GetAllSpoeMessageParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllSpoeMessageParams() beforehand. +func (o *GetAllSpoeMessageParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllSpoeMessageParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *GetAllSpoeMessageParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllSpoeMessageParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_all_spoe_message_responses.go b/operations/spoe/get_all_spoe_message_responses.go new file mode 100644 index 00000000..228aec2c --- /dev/null +++ b/operations/spoe/get_all_spoe_message_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllSpoeMessageOKCode is the HTTP code returned for type GetAllSpoeMessageOK +const GetAllSpoeMessageOKCode int = 200 + +/* +GetAllSpoeMessageOK Successful operation + +swagger:response getAllSpoeMessageOK +*/ +type GetAllSpoeMessageOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.SpoeMessages `json:"body,omitempty"` +} + +// NewGetAllSpoeMessageOK creates GetAllSpoeMessageOK with default headers values +func NewGetAllSpoeMessageOK() *GetAllSpoeMessageOK { + + return &GetAllSpoeMessageOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe message o k response +func (o *GetAllSpoeMessageOK) WithConfigurationVersion(configurationVersion string) *GetAllSpoeMessageOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe message o k response +func (o *GetAllSpoeMessageOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe message o k response +func (o *GetAllSpoeMessageOK) WithPayload(payload models.SpoeMessages) *GetAllSpoeMessageOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe message o k response +func (o *GetAllSpoeMessageOK) SetPayload(payload models.SpoeMessages) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeMessageOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SpoeMessages{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllSpoeMessageDefault General Error + +swagger:response getAllSpoeMessageDefault +*/ +type GetAllSpoeMessageDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSpoeMessageDefault creates GetAllSpoeMessageDefault with default headers values +func NewGetAllSpoeMessageDefault(code int) *GetAllSpoeMessageDefault { + if code <= 0 { + code = 500 + } + + return &GetAllSpoeMessageDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all spoe message default response +func (o *GetAllSpoeMessageDefault) WithStatusCode(code int) *GetAllSpoeMessageDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all spoe message default response +func (o *GetAllSpoeMessageDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe message default response +func (o *GetAllSpoeMessageDefault) WithConfigurationVersion(configurationVersion string) *GetAllSpoeMessageDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe message default response +func (o *GetAllSpoeMessageDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe message default response +func (o *GetAllSpoeMessageDefault) WithPayload(payload *models.Error) *GetAllSpoeMessageDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe message default response +func (o *GetAllSpoeMessageDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeMessageDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_all_spoe_message_urlbuilder.go b/operations/spoe/get_all_spoe_message_urlbuilder.go new file mode 100644 index 00000000..f02a68ff --- /dev/null +++ b/operations/spoe/get_all_spoe_message_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllSpoeMessageURL generates an URL for the get all spoe message operation +type GetAllSpoeMessageURL struct { + ParentName string + ScopeName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeMessageURL) WithBasePath(bp string) *GetAllSpoeMessageURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeMessageURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllSpoeMessageURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllSpoeMessageURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on GetAllSpoeMessageURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllSpoeMessageURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllSpoeMessageURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllSpoeMessageURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllSpoeMessageURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllSpoeMessageURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllSpoeMessageURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_all_spoe_scope.go b/operations/spoe/get_all_spoe_scope.go new file mode 100644 index 00000000..0c63ef39 --- /dev/null +++ b/operations/spoe/get_all_spoe_scope.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllSpoeScopeHandlerFunc turns a function with the right signature into a get all spoe scope handler +type GetAllSpoeScopeHandlerFunc func(GetAllSpoeScopeParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllSpoeScopeHandlerFunc) Handle(params GetAllSpoeScopeParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllSpoeScopeHandler interface for that can handle valid get all spoe scope params +type GetAllSpoeScopeHandler interface { + Handle(GetAllSpoeScopeParams, interface{}) middleware.Responder +} + +// NewGetAllSpoeScope creates a new http.Handler for the get all spoe scope operation +func NewGetAllSpoeScope(ctx *middleware.Context, handler GetAllSpoeScopeHandler) *GetAllSpoeScope { + return &GetAllSpoeScope{Context: ctx, Handler: handler} +} + +/* + GetAllSpoeScope swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes Spoe getAllSpoeScope + +# Return an array of spoe scopes + +Returns an array of all configured spoe scopes. +*/ +type GetAllSpoeScope struct { + Context *middleware.Context + Handler GetAllSpoeScopeHandler +} + +func (o *GetAllSpoeScope) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllSpoeScopeParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_all_spoe_scope_parameters.go b/operations/spoe/get_all_spoe_scope_parameters.go new file mode 100644 index 00000000..7a59fb33 --- /dev/null +++ b/operations/spoe/get_all_spoe_scope_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllSpoeScopeParams creates a new GetAllSpoeScopeParams object +// +// There are no default values defined in the spec. +func NewGetAllSpoeScopeParams() GetAllSpoeScopeParams { + + return GetAllSpoeScopeParams{} +} + +// GetAllSpoeScopeParams contains all the bound params for the get all spoe scope operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllSpoeScope +type GetAllSpoeScopeParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllSpoeScopeParams() beforehand. +func (o *GetAllSpoeScopeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllSpoeScopeParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllSpoeScopeParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_all_spoe_scope_responses.go b/operations/spoe/get_all_spoe_scope_responses.go new file mode 100644 index 00000000..5db10935 --- /dev/null +++ b/operations/spoe/get_all_spoe_scope_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllSpoeScopeOKCode is the HTTP code returned for type GetAllSpoeScopeOK +const GetAllSpoeScopeOKCode int = 200 + +/* +GetAllSpoeScopeOK Successful operation + +swagger:response getAllSpoeScopeOK +*/ +type GetAllSpoeScopeOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.SpoeScopes `json:"body,omitempty"` +} + +// NewGetAllSpoeScopeOK creates GetAllSpoeScopeOK with default headers values +func NewGetAllSpoeScopeOK() *GetAllSpoeScopeOK { + + return &GetAllSpoeScopeOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe scope o k response +func (o *GetAllSpoeScopeOK) WithConfigurationVersion(configurationVersion string) *GetAllSpoeScopeOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe scope o k response +func (o *GetAllSpoeScopeOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe scope o k response +func (o *GetAllSpoeScopeOK) WithPayload(payload models.SpoeScopes) *GetAllSpoeScopeOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe scope o k response +func (o *GetAllSpoeScopeOK) SetPayload(payload models.SpoeScopes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeScopeOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SpoeScopes{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllSpoeScopeDefault General Error + +swagger:response getAllSpoeScopeDefault +*/ +type GetAllSpoeScopeDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSpoeScopeDefault creates GetAllSpoeScopeDefault with default headers values +func NewGetAllSpoeScopeDefault(code int) *GetAllSpoeScopeDefault { + if code <= 0 { + code = 500 + } + + return &GetAllSpoeScopeDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all spoe scope default response +func (o *GetAllSpoeScopeDefault) WithStatusCode(code int) *GetAllSpoeScopeDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all spoe scope default response +func (o *GetAllSpoeScopeDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe scope default response +func (o *GetAllSpoeScopeDefault) WithConfigurationVersion(configurationVersion string) *GetAllSpoeScopeDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe scope default response +func (o *GetAllSpoeScopeDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe scope default response +func (o *GetAllSpoeScopeDefault) WithPayload(payload *models.Error) *GetAllSpoeScopeDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe scope default response +func (o *GetAllSpoeScopeDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeScopeDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_all_spoe_scope_urlbuilder.go b/operations/spoe/get_all_spoe_scope_urlbuilder.go new file mode 100644 index 00000000..dc863bf1 --- /dev/null +++ b/operations/spoe/get_all_spoe_scope_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllSpoeScopeURL generates an URL for the get all spoe scope operation +type GetAllSpoeScopeURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeScopeURL) WithBasePath(bp string) *GetAllSpoeScopeURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeScopeURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllSpoeScopeURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllSpoeScopeURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllSpoeScopeURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllSpoeScopeURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllSpoeScopeURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllSpoeScopeURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllSpoeScopeURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllSpoeScopeURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_one_spoe_file.go b/operations/spoe/get_one_spoe_file.go new file mode 100644 index 00000000..109cb75d --- /dev/null +++ b/operations/spoe/get_one_spoe_file.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// GetOneSpoeFileHandlerFunc turns a function with the right signature into a get one spoe file handler +type GetOneSpoeFileHandlerFunc func(GetOneSpoeFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetOneSpoeFileHandlerFunc) Handle(params GetOneSpoeFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetOneSpoeFileHandler interface for that can handle valid get one spoe file params +type GetOneSpoeFileHandler interface { + Handle(GetOneSpoeFileParams, interface{}) middleware.Responder +} + +// NewGetOneSpoeFile creates a new http.Handler for the get one spoe file operation +func NewGetOneSpoeFile(ctx *middleware.Context, handler GetOneSpoeFileHandler) *GetOneSpoeFile { + return &GetOneSpoeFile{Context: ctx, Handler: handler} +} + +/* + GetOneSpoeFile swagger:route GET /services/haproxy/spoe/spoe_files/{name} Spoe getOneSpoeFile + +# Return one SPOE file + +Returns one SPOE file. +*/ +type GetOneSpoeFile struct { + Context *middleware.Context + Handler GetOneSpoeFileHandler +} + +func (o *GetOneSpoeFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetOneSpoeFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// GetOneSpoeFileOKBody get one spoe file o k body +// +// swagger:model GetOneSpoeFileOKBody +type GetOneSpoeFileOKBody struct { + + // data + Data string `json:"data,omitempty"` +} + +// Validate validates this get one spoe file o k body +func (o *GetOneSpoeFileOKBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this get one spoe file o k body based on context it is used +func (o *GetOneSpoeFileOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetOneSpoeFileOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetOneSpoeFileOKBody) UnmarshalBinary(b []byte) error { + var res GetOneSpoeFileOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/operations/spoe/get_one_spoe_file_parameters.go b/operations/spoe/get_one_spoe_file_parameters.go new file mode 100644 index 00000000..e73dffab --- /dev/null +++ b/operations/spoe/get_one_spoe_file_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetOneSpoeFileParams creates a new GetOneSpoeFileParams object +// +// There are no default values defined in the spec. +func NewGetOneSpoeFileParams() GetOneSpoeFileParams { + + return GetOneSpoeFileParams{} +} + +// GetOneSpoeFileParams contains all the bound params for the get one spoe file operation +// typically these are obtained from a http.Request +// +// swagger:parameters getOneSpoeFile +type GetOneSpoeFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SPOE file name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetOneSpoeFileParams() beforehand. +func (o *GetOneSpoeFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetOneSpoeFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/spoe/get_one_spoe_file_responses.go b/operations/spoe/get_one_spoe_file_responses.go new file mode 100644 index 00000000..e4cedce3 --- /dev/null +++ b/operations/spoe/get_one_spoe_file_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetOneSpoeFileOKCode is the HTTP code returned for type GetOneSpoeFileOK +const GetOneSpoeFileOKCode int = 200 + +/* +GetOneSpoeFileOK Successful operation + +swagger:response getOneSpoeFileOK +*/ +type GetOneSpoeFileOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *GetOneSpoeFileOKBody `json:"body,omitempty"` +} + +// NewGetOneSpoeFileOK creates GetOneSpoeFileOK with default headers values +func NewGetOneSpoeFileOK() *GetOneSpoeFileOK { + + return &GetOneSpoeFileOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get one spoe file o k response +func (o *GetOneSpoeFileOK) WithConfigurationVersion(configurationVersion string) *GetOneSpoeFileOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one spoe file o k response +func (o *GetOneSpoeFileOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one spoe file o k response +func (o *GetOneSpoeFileOK) WithPayload(payload *GetOneSpoeFileOKBody) *GetOneSpoeFileOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one spoe file o k response +func (o *GetOneSpoeFileOK) SetPayload(payload *GetOneSpoeFileOKBody) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneSpoeFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetOneSpoeFileNotFoundCode is the HTTP code returned for type GetOneSpoeFileNotFound +const GetOneSpoeFileNotFoundCode int = 404 + +/* +GetOneSpoeFileNotFound The specified resource was not found + +swagger:response getOneSpoeFileNotFound +*/ +type GetOneSpoeFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneSpoeFileNotFound creates GetOneSpoeFileNotFound with default headers values +func NewGetOneSpoeFileNotFound() *GetOneSpoeFileNotFound { + + return &GetOneSpoeFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get one spoe file not found response +func (o *GetOneSpoeFileNotFound) WithConfigurationVersion(configurationVersion string) *GetOneSpoeFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one spoe file not found response +func (o *GetOneSpoeFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one spoe file not found response +func (o *GetOneSpoeFileNotFound) WithPayload(payload *models.Error) *GetOneSpoeFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one spoe file not found response +func (o *GetOneSpoeFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneSpoeFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetOneSpoeFileDefault General Error + +swagger:response getOneSpoeFileDefault +*/ +type GetOneSpoeFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneSpoeFileDefault creates GetOneSpoeFileDefault with default headers values +func NewGetOneSpoeFileDefault(code int) *GetOneSpoeFileDefault { + if code <= 0 { + code = 500 + } + + return &GetOneSpoeFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get one spoe file default response +func (o *GetOneSpoeFileDefault) WithStatusCode(code int) *GetOneSpoeFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get one spoe file default response +func (o *GetOneSpoeFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get one spoe file default response +func (o *GetOneSpoeFileDefault) WithConfigurationVersion(configurationVersion string) *GetOneSpoeFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one spoe file default response +func (o *GetOneSpoeFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one spoe file default response +func (o *GetOneSpoeFileDefault) WithPayload(payload *models.Error) *GetOneSpoeFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one spoe file default response +func (o *GetOneSpoeFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneSpoeFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_one_spoe_file_urlbuilder.go b/operations/spoe/get_one_spoe_file_urlbuilder.go new file mode 100644 index 00000000..e31af6d4 --- /dev/null +++ b/operations/spoe/get_one_spoe_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetOneSpoeFileURL generates an URL for the get one spoe file operation +type GetOneSpoeFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneSpoeFileURL) WithBasePath(bp string) *GetOneSpoeFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneSpoeFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetOneSpoeFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetOneSpoeFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetOneSpoeFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetOneSpoeFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetOneSpoeFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetOneSpoeFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetOneSpoeFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetOneSpoeFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_spoe_agent.go b/operations/spoe/get_spoe_agent.go new file mode 100644 index 00000000..19248c89 --- /dev/null +++ b/operations/spoe/get_spoe_agent.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSpoeAgentHandlerFunc turns a function with the right signature into a get spoe agent handler +type GetSpoeAgentHandlerFunc func(GetSpoeAgentParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSpoeAgentHandlerFunc) Handle(params GetSpoeAgentParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSpoeAgentHandler interface for that can handle valid get spoe agent params +type GetSpoeAgentHandler interface { + Handle(GetSpoeAgentParams, interface{}) middleware.Responder +} + +// NewGetSpoeAgent creates a new http.Handler for the get spoe agent operation +func NewGetSpoeAgent(ctx *middleware.Context, handler GetSpoeAgentHandler) *GetSpoeAgent { + return &GetSpoeAgent{Context: ctx, Handler: handler} +} + +/* + GetSpoeAgent swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name} Spoe getSpoeAgent + +# Return a spoe agent + +Returns one spoe agent configuration in one SPOE scope. +*/ +type GetSpoeAgent struct { + Context *middleware.Context + Handler GetSpoeAgentHandler +} + +func (o *GetSpoeAgent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSpoeAgentParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_spoe_agent_parameters.go b/operations/spoe/get_spoe_agent_parameters.go new file mode 100644 index 00000000..1b3115bf --- /dev/null +++ b/operations/spoe/get_spoe_agent_parameters.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetSpoeAgentParams creates a new GetSpoeAgentParams object +// +// There are no default values defined in the spec. +func NewGetSpoeAgentParams() GetSpoeAgentParams { + + return GetSpoeAgentParams{} +} + +// GetSpoeAgentParams contains all the bound params for the get spoe agent operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSpoeAgent +type GetSpoeAgentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe agent name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSpoeAgentParams() beforehand. +func (o *GetSpoeAgentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetSpoeAgentParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetSpoeAgentParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *GetSpoeAgentParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetSpoeAgentParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_spoe_agent_responses.go b/operations/spoe/get_spoe_agent_responses.go new file mode 100644 index 00000000..73f2ef72 --- /dev/null +++ b/operations/spoe/get_spoe_agent_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSpoeAgentOKCode is the HTTP code returned for type GetSpoeAgentOK +const GetSpoeAgentOKCode int = 200 + +/* +GetSpoeAgentOK Successful operation + +swagger:response getSpoeAgentOK +*/ +type GetSpoeAgentOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.SpoeAgent `json:"body,omitempty"` +} + +// NewGetSpoeAgentOK creates GetSpoeAgentOK with default headers values +func NewGetSpoeAgentOK() *GetSpoeAgentOK { + + return &GetSpoeAgentOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe agent o k response +func (o *GetSpoeAgentOK) WithConfigurationVersion(configurationVersion string) *GetSpoeAgentOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe agent o k response +func (o *GetSpoeAgentOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe agent o k response +func (o *GetSpoeAgentOK) WithPayload(payload *models.SpoeAgent) *GetSpoeAgentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe agent o k response +func (o *GetSpoeAgentOK) SetPayload(payload *models.SpoeAgent) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeAgentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSpoeAgentNotFoundCode is the HTTP code returned for type GetSpoeAgentNotFound +const GetSpoeAgentNotFoundCode int = 404 + +/* +GetSpoeAgentNotFound The specified resource was not found + +swagger:response getSpoeAgentNotFound +*/ +type GetSpoeAgentNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeAgentNotFound creates GetSpoeAgentNotFound with default headers values +func NewGetSpoeAgentNotFound() *GetSpoeAgentNotFound { + + return &GetSpoeAgentNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe agent not found response +func (o *GetSpoeAgentNotFound) WithConfigurationVersion(configurationVersion string) *GetSpoeAgentNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe agent not found response +func (o *GetSpoeAgentNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe agent not found response +func (o *GetSpoeAgentNotFound) WithPayload(payload *models.Error) *GetSpoeAgentNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe agent not found response +func (o *GetSpoeAgentNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeAgentNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetSpoeAgentDefault General Error + +swagger:response getSpoeAgentDefault +*/ +type GetSpoeAgentDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeAgentDefault creates GetSpoeAgentDefault with default headers values +func NewGetSpoeAgentDefault(code int) *GetSpoeAgentDefault { + if code <= 0 { + code = 500 + } + + return &GetSpoeAgentDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get spoe agent default response +func (o *GetSpoeAgentDefault) WithStatusCode(code int) *GetSpoeAgentDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get spoe agent default response +func (o *GetSpoeAgentDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe agent default response +func (o *GetSpoeAgentDefault) WithConfigurationVersion(configurationVersion string) *GetSpoeAgentDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe agent default response +func (o *GetSpoeAgentDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe agent default response +func (o *GetSpoeAgentDefault) WithPayload(payload *models.Error) *GetSpoeAgentDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe agent default response +func (o *GetSpoeAgentDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeAgentDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_spoe_agent_urlbuilder.go b/operations/spoe/get_spoe_agent_urlbuilder.go new file mode 100644 index 00000000..2e955eaf --- /dev/null +++ b/operations/spoe/get_spoe_agent_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSpoeAgentURL generates an URL for the get spoe agent operation +type GetSpoeAgentURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeAgentURL) WithBasePath(bp string) *GetSpoeAgentURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeAgentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSpoeAgentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetSpoeAgentURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetSpoeAgentURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on GetSpoeAgentURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSpoeAgentURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSpoeAgentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSpoeAgentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSpoeAgentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSpoeAgentURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSpoeAgentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_spoe_configuration_version.go b/operations/spoe/get_spoe_configuration_version.go new file mode 100644 index 00000000..3e180ff9 --- /dev/null +++ b/operations/spoe/get_spoe_configuration_version.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSpoeConfigurationVersionHandlerFunc turns a function with the right signature into a get spoe configuration version handler +type GetSpoeConfigurationVersionHandlerFunc func(GetSpoeConfigurationVersionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSpoeConfigurationVersionHandlerFunc) Handle(params GetSpoeConfigurationVersionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSpoeConfigurationVersionHandler interface for that can handle valid get spoe configuration version params +type GetSpoeConfigurationVersionHandler interface { + Handle(GetSpoeConfigurationVersionParams, interface{}) middleware.Responder +} + +// NewGetSpoeConfigurationVersion creates a new http.Handler for the get spoe configuration version operation +func NewGetSpoeConfigurationVersion(ctx *middleware.Context, handler GetSpoeConfigurationVersionHandler) *GetSpoeConfigurationVersion { + return &GetSpoeConfigurationVersion{Context: ctx, Handler: handler} +} + +/* + GetSpoeConfigurationVersion swagger:route GET /services/haproxy/spoe/{parent_name}/version Spoe getSpoeConfigurationVersion + +# Return a SPOE configuration version + +Returns SPOE configuration version. +*/ +type GetSpoeConfigurationVersion struct { + Context *middleware.Context + Handler GetSpoeConfigurationVersionHandler +} + +func (o *GetSpoeConfigurationVersion) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSpoeConfigurationVersionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_spoe_configuration_version_parameters.go b/operations/spoe/get_spoe_configuration_version_parameters.go new file mode 100644 index 00000000..b1fe0cb0 --- /dev/null +++ b/operations/spoe/get_spoe_configuration_version_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetSpoeConfigurationVersionParams creates a new GetSpoeConfigurationVersionParams object +// +// There are no default values defined in the spec. +func NewGetSpoeConfigurationVersionParams() GetSpoeConfigurationVersionParams { + + return GetSpoeConfigurationVersionParams{} +} + +// GetSpoeConfigurationVersionParams contains all the bound params for the get spoe configuration version operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSpoeConfigurationVersion +type GetSpoeConfigurationVersionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSpoeConfigurationVersionParams() beforehand. +func (o *GetSpoeConfigurationVersionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetSpoeConfigurationVersionParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetSpoeConfigurationVersionParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_spoe_configuration_version_responses.go b/operations/spoe/get_spoe_configuration_version_responses.go new file mode 100644 index 00000000..a1233690 --- /dev/null +++ b/operations/spoe/get_spoe_configuration_version_responses.go @@ -0,0 +1,220 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSpoeConfigurationVersionOKCode is the HTTP code returned for type GetSpoeConfigurationVersionOK +const GetSpoeConfigurationVersionOKCode int = 200 + +/* +GetSpoeConfigurationVersionOK SPOE configuration version + +swagger:response getSpoeConfigurationVersionOK +*/ +type GetSpoeConfigurationVersionOK struct { + + /* + In: Body + */ + Payload int64 `json:"body,omitempty"` +} + +// NewGetSpoeConfigurationVersionOK creates GetSpoeConfigurationVersionOK with default headers values +func NewGetSpoeConfigurationVersionOK() *GetSpoeConfigurationVersionOK { + + return &GetSpoeConfigurationVersionOK{} +} + +// WithPayload adds the payload to the get spoe configuration version o k response +func (o *GetSpoeConfigurationVersionOK) WithPayload(payload int64) *GetSpoeConfigurationVersionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe configuration version o k response +func (o *GetSpoeConfigurationVersionOK) SetPayload(payload int64) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeConfigurationVersionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetSpoeConfigurationVersionNotFoundCode is the HTTP code returned for type GetSpoeConfigurationVersionNotFound +const GetSpoeConfigurationVersionNotFoundCode int = 404 + +/* +GetSpoeConfigurationVersionNotFound The specified resource was not found + +swagger:response getSpoeConfigurationVersionNotFound +*/ +type GetSpoeConfigurationVersionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeConfigurationVersionNotFound creates GetSpoeConfigurationVersionNotFound with default headers values +func NewGetSpoeConfigurationVersionNotFound() *GetSpoeConfigurationVersionNotFound { + + return &GetSpoeConfigurationVersionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe configuration version not found response +func (o *GetSpoeConfigurationVersionNotFound) WithConfigurationVersion(configurationVersion string) *GetSpoeConfigurationVersionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe configuration version not found response +func (o *GetSpoeConfigurationVersionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe configuration version not found response +func (o *GetSpoeConfigurationVersionNotFound) WithPayload(payload *models.Error) *GetSpoeConfigurationVersionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe configuration version not found response +func (o *GetSpoeConfigurationVersionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeConfigurationVersionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetSpoeConfigurationVersionDefault General Error + +swagger:response getSpoeConfigurationVersionDefault +*/ +type GetSpoeConfigurationVersionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeConfigurationVersionDefault creates GetSpoeConfigurationVersionDefault with default headers values +func NewGetSpoeConfigurationVersionDefault(code int) *GetSpoeConfigurationVersionDefault { + if code <= 0 { + code = 500 + } + + return &GetSpoeConfigurationVersionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get spoe configuration version default response +func (o *GetSpoeConfigurationVersionDefault) WithStatusCode(code int) *GetSpoeConfigurationVersionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get spoe configuration version default response +func (o *GetSpoeConfigurationVersionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe configuration version default response +func (o *GetSpoeConfigurationVersionDefault) WithConfigurationVersion(configurationVersion string) *GetSpoeConfigurationVersionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe configuration version default response +func (o *GetSpoeConfigurationVersionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe configuration version default response +func (o *GetSpoeConfigurationVersionDefault) WithPayload(payload *models.Error) *GetSpoeConfigurationVersionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe configuration version default response +func (o *GetSpoeConfigurationVersionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeConfigurationVersionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_spoe_configuration_version_urlbuilder.go b/operations/spoe/get_spoe_configuration_version_urlbuilder.go new file mode 100644 index 00000000..392cf1d1 --- /dev/null +++ b/operations/spoe/get_spoe_configuration_version_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSpoeConfigurationVersionURL generates an URL for the get spoe configuration version operation +type GetSpoeConfigurationVersionURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeConfigurationVersionURL) WithBasePath(bp string) *GetSpoeConfigurationVersionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeConfigurationVersionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSpoeConfigurationVersionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/{parent_name}/version" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetSpoeConfigurationVersionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSpoeConfigurationVersionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSpoeConfigurationVersionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSpoeConfigurationVersionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSpoeConfigurationVersionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSpoeConfigurationVersionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSpoeConfigurationVersionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_spoe_group.go b/operations/spoe/get_spoe_group.go new file mode 100644 index 00000000..361f9dec --- /dev/null +++ b/operations/spoe/get_spoe_group.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSpoeGroupHandlerFunc turns a function with the right signature into a get spoe group handler +type GetSpoeGroupHandlerFunc func(GetSpoeGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSpoeGroupHandlerFunc) Handle(params GetSpoeGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSpoeGroupHandler interface for that can handle valid get spoe group params +type GetSpoeGroupHandler interface { + Handle(GetSpoeGroupParams, interface{}) middleware.Responder +} + +// NewGetSpoeGroup creates a new http.Handler for the get spoe group operation +func NewGetSpoeGroup(ctx *middleware.Context, handler GetSpoeGroupHandler) *GetSpoeGroup { + return &GetSpoeGroup{Context: ctx, Handler: handler} +} + +/* + GetSpoeGroup swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name} Spoe getSpoeGroup + +# Return a SPOE groups + +Returns one SPOE groups configuration in one SPOE scope. +*/ +type GetSpoeGroup struct { + Context *middleware.Context + Handler GetSpoeGroupHandler +} + +func (o *GetSpoeGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSpoeGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_spoe_group_parameters.go b/operations/spoe/get_spoe_group_parameters.go new file mode 100644 index 00000000..e239498b --- /dev/null +++ b/operations/spoe/get_spoe_group_parameters.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetSpoeGroupParams creates a new GetSpoeGroupParams object +// +// There are no default values defined in the spec. +func NewGetSpoeGroupParams() GetSpoeGroupParams { + + return GetSpoeGroupParams{} +} + +// GetSpoeGroupParams contains all the bound params for the get spoe group operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSpoeGroup +type GetSpoeGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe group name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSpoeGroupParams() beforehand. +func (o *GetSpoeGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetSpoeGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetSpoeGroupParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *GetSpoeGroupParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetSpoeGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_spoe_group_responses.go b/operations/spoe/get_spoe_group_responses.go new file mode 100644 index 00000000..2528f0fb --- /dev/null +++ b/operations/spoe/get_spoe_group_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSpoeGroupOKCode is the HTTP code returned for type GetSpoeGroupOK +const GetSpoeGroupOKCode int = 200 + +/* +GetSpoeGroupOK Successful operation + +swagger:response getSpoeGroupOK +*/ +type GetSpoeGroupOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.SpoeGroup `json:"body,omitempty"` +} + +// NewGetSpoeGroupOK creates GetSpoeGroupOK with default headers values +func NewGetSpoeGroupOK() *GetSpoeGroupOK { + + return &GetSpoeGroupOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe group o k response +func (o *GetSpoeGroupOK) WithConfigurationVersion(configurationVersion string) *GetSpoeGroupOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe group o k response +func (o *GetSpoeGroupOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe group o k response +func (o *GetSpoeGroupOK) WithPayload(payload *models.SpoeGroup) *GetSpoeGroupOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe group o k response +func (o *GetSpoeGroupOK) SetPayload(payload *models.SpoeGroup) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSpoeGroupNotFoundCode is the HTTP code returned for type GetSpoeGroupNotFound +const GetSpoeGroupNotFoundCode int = 404 + +/* +GetSpoeGroupNotFound The specified resource was not found + +swagger:response getSpoeGroupNotFound +*/ +type GetSpoeGroupNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeGroupNotFound creates GetSpoeGroupNotFound with default headers values +func NewGetSpoeGroupNotFound() *GetSpoeGroupNotFound { + + return &GetSpoeGroupNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe group not found response +func (o *GetSpoeGroupNotFound) WithConfigurationVersion(configurationVersion string) *GetSpoeGroupNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe group not found response +func (o *GetSpoeGroupNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe group not found response +func (o *GetSpoeGroupNotFound) WithPayload(payload *models.Error) *GetSpoeGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe group not found response +func (o *GetSpoeGroupNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetSpoeGroupDefault General Error + +swagger:response getSpoeGroupDefault +*/ +type GetSpoeGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeGroupDefault creates GetSpoeGroupDefault with default headers values +func NewGetSpoeGroupDefault(code int) *GetSpoeGroupDefault { + if code <= 0 { + code = 500 + } + + return &GetSpoeGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get spoe group default response +func (o *GetSpoeGroupDefault) WithStatusCode(code int) *GetSpoeGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get spoe group default response +func (o *GetSpoeGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe group default response +func (o *GetSpoeGroupDefault) WithConfigurationVersion(configurationVersion string) *GetSpoeGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe group default response +func (o *GetSpoeGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe group default response +func (o *GetSpoeGroupDefault) WithPayload(payload *models.Error) *GetSpoeGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe group default response +func (o *GetSpoeGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_spoe_group_urlbuilder.go b/operations/spoe/get_spoe_group_urlbuilder.go new file mode 100644 index 00000000..40f01fba --- /dev/null +++ b/operations/spoe/get_spoe_group_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSpoeGroupURL generates an URL for the get spoe group operation +type GetSpoeGroupURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeGroupURL) WithBasePath(bp string) *GetSpoeGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSpoeGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetSpoeGroupURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetSpoeGroupURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on GetSpoeGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSpoeGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSpoeGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSpoeGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSpoeGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSpoeGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSpoeGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_spoe_message.go b/operations/spoe/get_spoe_message.go new file mode 100644 index 00000000..98ebe832 --- /dev/null +++ b/operations/spoe/get_spoe_message.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSpoeMessageHandlerFunc turns a function with the right signature into a get spoe message handler +type GetSpoeMessageHandlerFunc func(GetSpoeMessageParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSpoeMessageHandlerFunc) Handle(params GetSpoeMessageParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSpoeMessageHandler interface for that can handle valid get spoe message params +type GetSpoeMessageHandler interface { + Handle(GetSpoeMessageParams, interface{}) middleware.Responder +} + +// NewGetSpoeMessage creates a new http.Handler for the get spoe message operation +func NewGetSpoeMessage(ctx *middleware.Context, handler GetSpoeMessageHandler) *GetSpoeMessage { + return &GetSpoeMessage{Context: ctx, Handler: handler} +} + +/* + GetSpoeMessage swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name} Spoe getSpoeMessage + +# Return a spoe message + +Returns one spoe message configuration in SPOE scope. +*/ +type GetSpoeMessage struct { + Context *middleware.Context + Handler GetSpoeMessageHandler +} + +func (o *GetSpoeMessage) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSpoeMessageParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_spoe_message_parameters.go b/operations/spoe/get_spoe_message_parameters.go new file mode 100644 index 00000000..adc0c956 --- /dev/null +++ b/operations/spoe/get_spoe_message_parameters.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetSpoeMessageParams creates a new GetSpoeMessageParams object +// +// There are no default values defined in the spec. +func NewGetSpoeMessageParams() GetSpoeMessageParams { + + return GetSpoeMessageParams{} +} + +// GetSpoeMessageParams contains all the bound params for the get spoe message operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSpoeMessage +type GetSpoeMessageParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe message name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSpoeMessageParams() beforehand. +func (o *GetSpoeMessageParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetSpoeMessageParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetSpoeMessageParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *GetSpoeMessageParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetSpoeMessageParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_spoe_message_responses.go b/operations/spoe/get_spoe_message_responses.go new file mode 100644 index 00000000..223008aa --- /dev/null +++ b/operations/spoe/get_spoe_message_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSpoeMessageOKCode is the HTTP code returned for type GetSpoeMessageOK +const GetSpoeMessageOKCode int = 200 + +/* +GetSpoeMessageOK Successful operation + +swagger:response getSpoeMessageOK +*/ +type GetSpoeMessageOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.SpoeMessage `json:"body,omitempty"` +} + +// NewGetSpoeMessageOK creates GetSpoeMessageOK with default headers values +func NewGetSpoeMessageOK() *GetSpoeMessageOK { + + return &GetSpoeMessageOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe message o k response +func (o *GetSpoeMessageOK) WithConfigurationVersion(configurationVersion string) *GetSpoeMessageOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe message o k response +func (o *GetSpoeMessageOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe message o k response +func (o *GetSpoeMessageOK) WithPayload(payload *models.SpoeMessage) *GetSpoeMessageOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe message o k response +func (o *GetSpoeMessageOK) SetPayload(payload *models.SpoeMessage) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeMessageOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSpoeMessageNotFoundCode is the HTTP code returned for type GetSpoeMessageNotFound +const GetSpoeMessageNotFoundCode int = 404 + +/* +GetSpoeMessageNotFound The specified resource was not found + +swagger:response getSpoeMessageNotFound +*/ +type GetSpoeMessageNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeMessageNotFound creates GetSpoeMessageNotFound with default headers values +func NewGetSpoeMessageNotFound() *GetSpoeMessageNotFound { + + return &GetSpoeMessageNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe message not found response +func (o *GetSpoeMessageNotFound) WithConfigurationVersion(configurationVersion string) *GetSpoeMessageNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe message not found response +func (o *GetSpoeMessageNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe message not found response +func (o *GetSpoeMessageNotFound) WithPayload(payload *models.Error) *GetSpoeMessageNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe message not found response +func (o *GetSpoeMessageNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeMessageNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetSpoeMessageDefault General Error + +swagger:response getSpoeMessageDefault +*/ +type GetSpoeMessageDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeMessageDefault creates GetSpoeMessageDefault with default headers values +func NewGetSpoeMessageDefault(code int) *GetSpoeMessageDefault { + if code <= 0 { + code = 500 + } + + return &GetSpoeMessageDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get spoe message default response +func (o *GetSpoeMessageDefault) WithStatusCode(code int) *GetSpoeMessageDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get spoe message default response +func (o *GetSpoeMessageDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe message default response +func (o *GetSpoeMessageDefault) WithConfigurationVersion(configurationVersion string) *GetSpoeMessageDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe message default response +func (o *GetSpoeMessageDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe message default response +func (o *GetSpoeMessageDefault) WithPayload(payload *models.Error) *GetSpoeMessageDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe message default response +func (o *GetSpoeMessageDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeMessageDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_spoe_message_urlbuilder.go b/operations/spoe/get_spoe_message_urlbuilder.go new file mode 100644 index 00000000..ba57414b --- /dev/null +++ b/operations/spoe/get_spoe_message_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSpoeMessageURL generates an URL for the get spoe message operation +type GetSpoeMessageURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeMessageURL) WithBasePath(bp string) *GetSpoeMessageURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeMessageURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSpoeMessageURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetSpoeMessageURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetSpoeMessageURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on GetSpoeMessageURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSpoeMessageURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSpoeMessageURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSpoeMessageURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSpoeMessageURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSpoeMessageURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSpoeMessageURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/get_spoe_scope.go b/operations/spoe/get_spoe_scope.go new file mode 100644 index 00000000..f339d42b --- /dev/null +++ b/operations/spoe/get_spoe_scope.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSpoeScopeHandlerFunc turns a function with the right signature into a get spoe scope handler +type GetSpoeScopeHandlerFunc func(GetSpoeScopeParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSpoeScopeHandlerFunc) Handle(params GetSpoeScopeParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSpoeScopeHandler interface for that can handle valid get spoe scope params +type GetSpoeScopeHandler interface { + Handle(GetSpoeScopeParams, interface{}) middleware.Responder +} + +// NewGetSpoeScope creates a new http.Handler for the get spoe scope operation +func NewGetSpoeScope(ctx *middleware.Context, handler GetSpoeScopeHandler) *GetSpoeScope { + return &GetSpoeScope{Context: ctx, Handler: handler} +} + +/* + GetSpoeScope swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name} Spoe getSpoeScope + +# Return one SPOE scope + +Returns one SPOE scope in one SPOE file. +*/ +type GetSpoeScope struct { + Context *middleware.Context + Handler GetSpoeScopeHandler +} + +func (o *GetSpoeScope) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSpoeScopeParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/get_spoe_scope_parameters.go b/operations/spoe/get_spoe_scope_parameters.go new file mode 100644 index 00000000..9de86820 --- /dev/null +++ b/operations/spoe/get_spoe_scope_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetSpoeScopeParams creates a new GetSpoeScopeParams object +// +// There are no default values defined in the spec. +func NewGetSpoeScopeParams() GetSpoeScopeParams { + + return GetSpoeScopeParams{} +} + +// GetSpoeScopeParams contains all the bound params for the get spoe scope operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSpoeScope +type GetSpoeScopeParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Spoe scope + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSpoeScopeParams() beforehand. +func (o *GetSpoeScopeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetSpoeScopeParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetSpoeScopeParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetSpoeScopeParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/spoe/get_spoe_scope_responses.go b/operations/spoe/get_spoe_scope_responses.go new file mode 100644 index 00000000..e0647ed2 --- /dev/null +++ b/operations/spoe/get_spoe_scope_responses.go @@ -0,0 +1,242 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSpoeScopeOKCode is the HTTP code returned for type GetSpoeScopeOK +const GetSpoeScopeOKCode int = 200 + +/* +GetSpoeScopeOK Successful operation + +swagger:response getSpoeScopeOK +*/ +type GetSpoeScopeOK struct { + /*Spoe configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.SpoeScope `json:"body,omitempty"` +} + +// NewGetSpoeScopeOK creates GetSpoeScopeOK with default headers values +func NewGetSpoeScopeOK() *GetSpoeScopeOK { + + return &GetSpoeScopeOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe scope o k response +func (o *GetSpoeScopeOK) WithConfigurationVersion(configurationVersion string) *GetSpoeScopeOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe scope o k response +func (o *GetSpoeScopeOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe scope o k response +func (o *GetSpoeScopeOK) WithPayload(payload models.SpoeScope) *GetSpoeScopeOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe scope o k response +func (o *GetSpoeScopeOK) SetPayload(payload models.SpoeScope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeScopeOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetSpoeScopeNotFoundCode is the HTTP code returned for type GetSpoeScopeNotFound +const GetSpoeScopeNotFoundCode int = 404 + +/* +GetSpoeScopeNotFound The specified resource was not found + +swagger:response getSpoeScopeNotFound +*/ +type GetSpoeScopeNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeScopeNotFound creates GetSpoeScopeNotFound with default headers values +func NewGetSpoeScopeNotFound() *GetSpoeScopeNotFound { + + return &GetSpoeScopeNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe scope not found response +func (o *GetSpoeScopeNotFound) WithConfigurationVersion(configurationVersion string) *GetSpoeScopeNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe scope not found response +func (o *GetSpoeScopeNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe scope not found response +func (o *GetSpoeScopeNotFound) WithPayload(payload *models.Error) *GetSpoeScopeNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe scope not found response +func (o *GetSpoeScopeNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeScopeNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetSpoeScopeDefault General Error + +swagger:response getSpoeScopeDefault +*/ +type GetSpoeScopeDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeScopeDefault creates GetSpoeScopeDefault with default headers values +func NewGetSpoeScopeDefault(code int) *GetSpoeScopeDefault { + if code <= 0 { + code = 500 + } + + return &GetSpoeScopeDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get spoe scope default response +func (o *GetSpoeScopeDefault) WithStatusCode(code int) *GetSpoeScopeDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get spoe scope default response +func (o *GetSpoeScopeDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe scope default response +func (o *GetSpoeScopeDefault) WithConfigurationVersion(configurationVersion string) *GetSpoeScopeDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe scope default response +func (o *GetSpoeScopeDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe scope default response +func (o *GetSpoeScopeDefault) WithPayload(payload *models.Error) *GetSpoeScopeDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe scope default response +func (o *GetSpoeScopeDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeScopeDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/get_spoe_scope_urlbuilder.go b/operations/spoe/get_spoe_scope_urlbuilder.go new file mode 100644 index 00000000..45711774 --- /dev/null +++ b/operations/spoe/get_spoe_scope_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSpoeScopeURL generates an URL for the get spoe scope operation +type GetSpoeScopeURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeScopeURL) WithBasePath(bp string) *GetSpoeScopeURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeScopeURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSpoeScopeURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetSpoeScopeURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetSpoeScopeURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSpoeScopeURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSpoeScopeURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSpoeScopeURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSpoeScopeURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSpoeScopeURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSpoeScopeURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/replace_spoe_agent.go b/operations/spoe/replace_spoe_agent.go new file mode 100644 index 00000000..99c8bf82 --- /dev/null +++ b/operations/spoe/replace_spoe_agent.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceSpoeAgentHandlerFunc turns a function with the right signature into a replace spoe agent handler +type ReplaceSpoeAgentHandlerFunc func(ReplaceSpoeAgentParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceSpoeAgentHandlerFunc) Handle(params ReplaceSpoeAgentParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceSpoeAgentHandler interface for that can handle valid replace spoe agent params +type ReplaceSpoeAgentHandler interface { + Handle(ReplaceSpoeAgentParams, interface{}) middleware.Responder +} + +// NewReplaceSpoeAgent creates a new http.Handler for the replace spoe agent operation +func NewReplaceSpoeAgent(ctx *middleware.Context, handler ReplaceSpoeAgentHandler) *ReplaceSpoeAgent { + return &ReplaceSpoeAgent{Context: ctx, Handler: handler} +} + +/* + ReplaceSpoeAgent swagger:route PUT /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name} Spoe replaceSpoeAgent + +# Replace a SPOE agent + +Replaces a SPOE agent configuration in one SPOE scope. +*/ +type ReplaceSpoeAgent struct { + Context *middleware.Context + Handler ReplaceSpoeAgentHandler +} + +func (o *ReplaceSpoeAgent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceSpoeAgentParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/replace_spoe_agent_parameters.go b/operations/spoe/replace_spoe_agent_parameters.go new file mode 100644 index 00000000..c75dd592 --- /dev/null +++ b/operations/spoe/replace_spoe_agent_parameters.go @@ -0,0 +1,228 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceSpoeAgentParams creates a new ReplaceSpoeAgentParams object +// +// There are no default values defined in the spec. +func NewReplaceSpoeAgentParams() ReplaceSpoeAgentParams { + + return ReplaceSpoeAgentParams{} +} + +// ReplaceSpoeAgentParams contains all the bound params for the replace spoe agent operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceSpoeAgent +type ReplaceSpoeAgentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SpoeAgent + /*Spoe agent name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceSpoeAgentParams() beforehand. +func (o *ReplaceSpoeAgentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SpoeAgent + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceSpoeAgentParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceSpoeAgentParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *ReplaceSpoeAgentParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceSpoeAgentParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceSpoeAgentParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/replace_spoe_agent_responses.go b/operations/spoe/replace_spoe_agent_responses.go new file mode 100644 index 00000000..74af8f21 --- /dev/null +++ b/operations/spoe/replace_spoe_agent_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceSpoeAgentOKCode is the HTTP code returned for type ReplaceSpoeAgentOK +const ReplaceSpoeAgentOKCode int = 200 + +/* +ReplaceSpoeAgentOK Spoe agent replaced + +swagger:response replaceSpoeAgentOK +*/ +type ReplaceSpoeAgentOK struct { + + /* + In: Body + */ + Payload *models.SpoeAgent `json:"body,omitempty"` +} + +// NewReplaceSpoeAgentOK creates ReplaceSpoeAgentOK with default headers values +func NewReplaceSpoeAgentOK() *ReplaceSpoeAgentOK { + + return &ReplaceSpoeAgentOK{} +} + +// WithPayload adds the payload to the replace spoe agent o k response +func (o *ReplaceSpoeAgentOK) WithPayload(payload *models.SpoeAgent) *ReplaceSpoeAgentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe agent o k response +func (o *ReplaceSpoeAgentOK) SetPayload(payload *models.SpoeAgent) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeAgentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSpoeAgentBadRequestCode is the HTTP code returned for type ReplaceSpoeAgentBadRequest +const ReplaceSpoeAgentBadRequestCode int = 400 + +/* +ReplaceSpoeAgentBadRequest Bad request + +swagger:response replaceSpoeAgentBadRequest +*/ +type ReplaceSpoeAgentBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeAgentBadRequest creates ReplaceSpoeAgentBadRequest with default headers values +func NewReplaceSpoeAgentBadRequest() *ReplaceSpoeAgentBadRequest { + + return &ReplaceSpoeAgentBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe agent bad request response +func (o *ReplaceSpoeAgentBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeAgentBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe agent bad request response +func (o *ReplaceSpoeAgentBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe agent bad request response +func (o *ReplaceSpoeAgentBadRequest) WithPayload(payload *models.Error) *ReplaceSpoeAgentBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe agent bad request response +func (o *ReplaceSpoeAgentBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeAgentBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSpoeAgentNotFoundCode is the HTTP code returned for type ReplaceSpoeAgentNotFound +const ReplaceSpoeAgentNotFoundCode int = 404 + +/* +ReplaceSpoeAgentNotFound The specified resource was not found + +swagger:response replaceSpoeAgentNotFound +*/ +type ReplaceSpoeAgentNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeAgentNotFound creates ReplaceSpoeAgentNotFound with default headers values +func NewReplaceSpoeAgentNotFound() *ReplaceSpoeAgentNotFound { + + return &ReplaceSpoeAgentNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe agent not found response +func (o *ReplaceSpoeAgentNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeAgentNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe agent not found response +func (o *ReplaceSpoeAgentNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe agent not found response +func (o *ReplaceSpoeAgentNotFound) WithPayload(payload *models.Error) *ReplaceSpoeAgentNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe agent not found response +func (o *ReplaceSpoeAgentNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeAgentNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceSpoeAgentDefault General Error + +swagger:response replaceSpoeAgentDefault +*/ +type ReplaceSpoeAgentDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeAgentDefault creates ReplaceSpoeAgentDefault with default headers values +func NewReplaceSpoeAgentDefault(code int) *ReplaceSpoeAgentDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceSpoeAgentDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace spoe agent default response +func (o *ReplaceSpoeAgentDefault) WithStatusCode(code int) *ReplaceSpoeAgentDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace spoe agent default response +func (o *ReplaceSpoeAgentDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe agent default response +func (o *ReplaceSpoeAgentDefault) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeAgentDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe agent default response +func (o *ReplaceSpoeAgentDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe agent default response +func (o *ReplaceSpoeAgentDefault) WithPayload(payload *models.Error) *ReplaceSpoeAgentDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe agent default response +func (o *ReplaceSpoeAgentDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeAgentDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/replace_spoe_agent_urlbuilder.go b/operations/spoe/replace_spoe_agent_urlbuilder.go new file mode 100644 index 00000000..2dfa8935 --- /dev/null +++ b/operations/spoe/replace_spoe_agent_urlbuilder.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceSpoeAgentURL generates an URL for the replace spoe agent operation +type ReplaceSpoeAgentURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSpoeAgentURL) WithBasePath(bp string) *ReplaceSpoeAgentURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSpoeAgentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceSpoeAgentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/agents/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceSpoeAgentURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceSpoeAgentURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on ReplaceSpoeAgentURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceSpoeAgentURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceSpoeAgentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceSpoeAgentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceSpoeAgentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceSpoeAgentURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceSpoeAgentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/replace_spoe_group.go b/operations/spoe/replace_spoe_group.go new file mode 100644 index 00000000..88c3cffe --- /dev/null +++ b/operations/spoe/replace_spoe_group.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceSpoeGroupHandlerFunc turns a function with the right signature into a replace spoe group handler +type ReplaceSpoeGroupHandlerFunc func(ReplaceSpoeGroupParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceSpoeGroupHandlerFunc) Handle(params ReplaceSpoeGroupParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceSpoeGroupHandler interface for that can handle valid replace spoe group params +type ReplaceSpoeGroupHandler interface { + Handle(ReplaceSpoeGroupParams, interface{}) middleware.Responder +} + +// NewReplaceSpoeGroup creates a new http.Handler for the replace spoe group operation +func NewReplaceSpoeGroup(ctx *middleware.Context, handler ReplaceSpoeGroupHandler) *ReplaceSpoeGroup { + return &ReplaceSpoeGroup{Context: ctx, Handler: handler} +} + +/* + ReplaceSpoeGroup swagger:route PUT /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name} Spoe replaceSpoeGroup + +# Replace a SPOE groups + +Replaces a SPOE groups configuration in one SPOE scope. +*/ +type ReplaceSpoeGroup struct { + Context *middleware.Context + Handler ReplaceSpoeGroupHandler +} + +func (o *ReplaceSpoeGroup) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceSpoeGroupParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/replace_spoe_group_parameters.go b/operations/spoe/replace_spoe_group_parameters.go new file mode 100644 index 00000000..886eb744 --- /dev/null +++ b/operations/spoe/replace_spoe_group_parameters.go @@ -0,0 +1,228 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceSpoeGroupParams creates a new ReplaceSpoeGroupParams object +// +// There are no default values defined in the spec. +func NewReplaceSpoeGroupParams() ReplaceSpoeGroupParams { + + return ReplaceSpoeGroupParams{} +} + +// ReplaceSpoeGroupParams contains all the bound params for the replace spoe group operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceSpoeGroup +type ReplaceSpoeGroupParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SpoeGroup + /*Spoe group name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceSpoeGroupParams() beforehand. +func (o *ReplaceSpoeGroupParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SpoeGroup + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceSpoeGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceSpoeGroupParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *ReplaceSpoeGroupParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceSpoeGroupParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceSpoeGroupParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/replace_spoe_group_responses.go b/operations/spoe/replace_spoe_group_responses.go new file mode 100644 index 00000000..32d47ac5 --- /dev/null +++ b/operations/spoe/replace_spoe_group_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceSpoeGroupOKCode is the HTTP code returned for type ReplaceSpoeGroupOK +const ReplaceSpoeGroupOKCode int = 200 + +/* +ReplaceSpoeGroupOK Spoe groups replaced + +swagger:response replaceSpoeGroupOK +*/ +type ReplaceSpoeGroupOK struct { + + /* + In: Body + */ + Payload *models.SpoeGroup `json:"body,omitempty"` +} + +// NewReplaceSpoeGroupOK creates ReplaceSpoeGroupOK with default headers values +func NewReplaceSpoeGroupOK() *ReplaceSpoeGroupOK { + + return &ReplaceSpoeGroupOK{} +} + +// WithPayload adds the payload to the replace spoe group o k response +func (o *ReplaceSpoeGroupOK) WithPayload(payload *models.SpoeGroup) *ReplaceSpoeGroupOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe group o k response +func (o *ReplaceSpoeGroupOK) SetPayload(payload *models.SpoeGroup) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeGroupOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSpoeGroupBadRequestCode is the HTTP code returned for type ReplaceSpoeGroupBadRequest +const ReplaceSpoeGroupBadRequestCode int = 400 + +/* +ReplaceSpoeGroupBadRequest Bad request + +swagger:response replaceSpoeGroupBadRequest +*/ +type ReplaceSpoeGroupBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeGroupBadRequest creates ReplaceSpoeGroupBadRequest with default headers values +func NewReplaceSpoeGroupBadRequest() *ReplaceSpoeGroupBadRequest { + + return &ReplaceSpoeGroupBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe group bad request response +func (o *ReplaceSpoeGroupBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeGroupBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe group bad request response +func (o *ReplaceSpoeGroupBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe group bad request response +func (o *ReplaceSpoeGroupBadRequest) WithPayload(payload *models.Error) *ReplaceSpoeGroupBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe group bad request response +func (o *ReplaceSpoeGroupBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeGroupBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSpoeGroupNotFoundCode is the HTTP code returned for type ReplaceSpoeGroupNotFound +const ReplaceSpoeGroupNotFoundCode int = 404 + +/* +ReplaceSpoeGroupNotFound The specified resource was not found + +swagger:response replaceSpoeGroupNotFound +*/ +type ReplaceSpoeGroupNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeGroupNotFound creates ReplaceSpoeGroupNotFound with default headers values +func NewReplaceSpoeGroupNotFound() *ReplaceSpoeGroupNotFound { + + return &ReplaceSpoeGroupNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe group not found response +func (o *ReplaceSpoeGroupNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeGroupNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe group not found response +func (o *ReplaceSpoeGroupNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe group not found response +func (o *ReplaceSpoeGroupNotFound) WithPayload(payload *models.Error) *ReplaceSpoeGroupNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe group not found response +func (o *ReplaceSpoeGroupNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeGroupNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceSpoeGroupDefault General Error + +swagger:response replaceSpoeGroupDefault +*/ +type ReplaceSpoeGroupDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeGroupDefault creates ReplaceSpoeGroupDefault with default headers values +func NewReplaceSpoeGroupDefault(code int) *ReplaceSpoeGroupDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceSpoeGroupDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace spoe group default response +func (o *ReplaceSpoeGroupDefault) WithStatusCode(code int) *ReplaceSpoeGroupDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace spoe group default response +func (o *ReplaceSpoeGroupDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe group default response +func (o *ReplaceSpoeGroupDefault) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeGroupDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe group default response +func (o *ReplaceSpoeGroupDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe group default response +func (o *ReplaceSpoeGroupDefault) WithPayload(payload *models.Error) *ReplaceSpoeGroupDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe group default response +func (o *ReplaceSpoeGroupDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeGroupDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/replace_spoe_group_urlbuilder.go b/operations/spoe/replace_spoe_group_urlbuilder.go new file mode 100644 index 00000000..a226f5a1 --- /dev/null +++ b/operations/spoe/replace_spoe_group_urlbuilder.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceSpoeGroupURL generates an URL for the replace spoe group operation +type ReplaceSpoeGroupURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSpoeGroupURL) WithBasePath(bp string) *ReplaceSpoeGroupURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSpoeGroupURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceSpoeGroupURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/groups/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceSpoeGroupURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceSpoeGroupURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on ReplaceSpoeGroupURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceSpoeGroupURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceSpoeGroupURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceSpoeGroupURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceSpoeGroupURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceSpoeGroupURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceSpoeGroupURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe/replace_spoe_message.go b/operations/spoe/replace_spoe_message.go new file mode 100644 index 00000000..275934b0 --- /dev/null +++ b/operations/spoe/replace_spoe_message.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceSpoeMessageHandlerFunc turns a function with the right signature into a replace spoe message handler +type ReplaceSpoeMessageHandlerFunc func(ReplaceSpoeMessageParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceSpoeMessageHandlerFunc) Handle(params ReplaceSpoeMessageParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceSpoeMessageHandler interface for that can handle valid replace spoe message params +type ReplaceSpoeMessageHandler interface { + Handle(ReplaceSpoeMessageParams, interface{}) middleware.Responder +} + +// NewReplaceSpoeMessage creates a new http.Handler for the replace spoe message operation +func NewReplaceSpoeMessage(ctx *middleware.Context, handler ReplaceSpoeMessageHandler) *ReplaceSpoeMessage { + return &ReplaceSpoeMessage{Context: ctx, Handler: handler} +} + +/* + ReplaceSpoeMessage swagger:route PUT /services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name} Spoe replaceSpoeMessage + +# Replace a spoe message + +Replaces a spoe message configuration in one SPOE scope. +*/ +type ReplaceSpoeMessage struct { + Context *middleware.Context + Handler ReplaceSpoeMessageHandler +} + +func (o *ReplaceSpoeMessage) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceSpoeMessageParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe/replace_spoe_message_parameters.go b/operations/spoe/replace_spoe_message_parameters.go new file mode 100644 index 00000000..62ff7eff --- /dev/null +++ b/operations/spoe/replace_spoe_message_parameters.go @@ -0,0 +1,228 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceSpoeMessageParams creates a new ReplaceSpoeMessageParams object +// +// There are no default values defined in the spec. +func NewReplaceSpoeMessageParams() ReplaceSpoeMessageParams { + + return ReplaceSpoeMessageParams{} +} + +// ReplaceSpoeMessageParams contains all the bound params for the replace spoe message operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceSpoeMessage +type ReplaceSpoeMessageParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.SpoeMessage + /*Spoe message name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*Spoe scope name + Required: true + In: path + */ + ScopeName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceSpoeMessageParams() beforehand. +func (o *ReplaceSpoeMessageParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SpoeMessage + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + rScopeName, rhkScopeName, _ := route.Params.GetOK("scope_name") + if err := o.bindScopeName(rScopeName, rhkScopeName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceSpoeMessageParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceSpoeMessageParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindScopeName binds and validates parameter ScopeName from path. +func (o *ReplaceSpoeMessageParams) bindScopeName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ScopeName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceSpoeMessageParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceSpoeMessageParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/spoe/replace_spoe_message_responses.go b/operations/spoe/replace_spoe_message_responses.go new file mode 100644 index 00000000..1fc8352e --- /dev/null +++ b/operations/spoe/replace_spoe_message_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceSpoeMessageOKCode is the HTTP code returned for type ReplaceSpoeMessageOK +const ReplaceSpoeMessageOKCode int = 200 + +/* +ReplaceSpoeMessageOK Spoe message replaced + +swagger:response replaceSpoeMessageOK +*/ +type ReplaceSpoeMessageOK struct { + + /* + In: Body + */ + Payload *models.SpoeMessage `json:"body,omitempty"` +} + +// NewReplaceSpoeMessageOK creates ReplaceSpoeMessageOK with default headers values +func NewReplaceSpoeMessageOK() *ReplaceSpoeMessageOK { + + return &ReplaceSpoeMessageOK{} +} + +// WithPayload adds the payload to the replace spoe message o k response +func (o *ReplaceSpoeMessageOK) WithPayload(payload *models.SpoeMessage) *ReplaceSpoeMessageOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe message o k response +func (o *ReplaceSpoeMessageOK) SetPayload(payload *models.SpoeMessage) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeMessageOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSpoeMessageBadRequestCode is the HTTP code returned for type ReplaceSpoeMessageBadRequest +const ReplaceSpoeMessageBadRequestCode int = 400 + +/* +ReplaceSpoeMessageBadRequest Bad request + +swagger:response replaceSpoeMessageBadRequest +*/ +type ReplaceSpoeMessageBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeMessageBadRequest creates ReplaceSpoeMessageBadRequest with default headers values +func NewReplaceSpoeMessageBadRequest() *ReplaceSpoeMessageBadRequest { + + return &ReplaceSpoeMessageBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe message bad request response +func (o *ReplaceSpoeMessageBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeMessageBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe message bad request response +func (o *ReplaceSpoeMessageBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe message bad request response +func (o *ReplaceSpoeMessageBadRequest) WithPayload(payload *models.Error) *ReplaceSpoeMessageBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe message bad request response +func (o *ReplaceSpoeMessageBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeMessageBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceSpoeMessageNotFoundCode is the HTTP code returned for type ReplaceSpoeMessageNotFound +const ReplaceSpoeMessageNotFoundCode int = 404 + +/* +ReplaceSpoeMessageNotFound The specified resource was not found + +swagger:response replaceSpoeMessageNotFound +*/ +type ReplaceSpoeMessageNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeMessageNotFound creates ReplaceSpoeMessageNotFound with default headers values +func NewReplaceSpoeMessageNotFound() *ReplaceSpoeMessageNotFound { + + return &ReplaceSpoeMessageNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe message not found response +func (o *ReplaceSpoeMessageNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeMessageNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe message not found response +func (o *ReplaceSpoeMessageNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe message not found response +func (o *ReplaceSpoeMessageNotFound) WithPayload(payload *models.Error) *ReplaceSpoeMessageNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe message not found response +func (o *ReplaceSpoeMessageNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeMessageNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceSpoeMessageDefault General Error + +swagger:response replaceSpoeMessageDefault +*/ +type ReplaceSpoeMessageDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceSpoeMessageDefault creates ReplaceSpoeMessageDefault with default headers values +func NewReplaceSpoeMessageDefault(code int) *ReplaceSpoeMessageDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceSpoeMessageDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace spoe message default response +func (o *ReplaceSpoeMessageDefault) WithStatusCode(code int) *ReplaceSpoeMessageDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace spoe message default response +func (o *ReplaceSpoeMessageDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace spoe message default response +func (o *ReplaceSpoeMessageDefault) WithConfigurationVersion(configurationVersion string) *ReplaceSpoeMessageDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace spoe message default response +func (o *ReplaceSpoeMessageDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace spoe message default response +func (o *ReplaceSpoeMessageDefault) WithPayload(payload *models.Error) *ReplaceSpoeMessageDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace spoe message default response +func (o *ReplaceSpoeMessageDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceSpoeMessageDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe/replace_spoe_message_urlbuilder.go b/operations/spoe/replace_spoe_message_urlbuilder.go new file mode 100644 index 00000000..cb2cdcc0 --- /dev/null +++ b/operations/spoe/replace_spoe_message_urlbuilder.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceSpoeMessageURL generates an URL for the replace spoe message operation +type ReplaceSpoeMessageURL struct { + Name string + ParentName string + ScopeName string + + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSpoeMessageURL) WithBasePath(bp string) *ReplaceSpoeMessageURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceSpoeMessageURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceSpoeMessageURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/scopes/{scope_name}/messages/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceSpoeMessageURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceSpoeMessageURL") + } + + scopeName := o.ScopeName + if scopeName != "" { + _path = strings.Replace(_path, "{scope_name}", scopeName, -1) + } else { + return nil, errors.New("scopeName is required on ReplaceSpoeMessageURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceSpoeMessageURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceSpoeMessageURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceSpoeMessageURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceSpoeMessageURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceSpoeMessageURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceSpoeMessageURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe_transactions/commit_spoe_transaction.go b/operations/spoe_transactions/commit_spoe_transaction.go new file mode 100644 index 00000000..eb92d560 --- /dev/null +++ b/operations/spoe_transactions/commit_spoe_transaction.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CommitSpoeTransactionHandlerFunc turns a function with the right signature into a commit spoe transaction handler +type CommitSpoeTransactionHandlerFunc func(CommitSpoeTransactionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CommitSpoeTransactionHandlerFunc) Handle(params CommitSpoeTransactionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CommitSpoeTransactionHandler interface for that can handle valid commit spoe transaction params +type CommitSpoeTransactionHandler interface { + Handle(CommitSpoeTransactionParams, interface{}) middleware.Responder +} + +// NewCommitSpoeTransaction creates a new http.Handler for the commit spoe transaction operation +func NewCommitSpoeTransaction(ctx *middleware.Context, handler CommitSpoeTransactionHandler) *CommitSpoeTransaction { + return &CommitSpoeTransaction{Context: ctx, Handler: handler} +} + +/* + CommitSpoeTransaction swagger:route PUT /services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id} SpoeTransactions commitSpoeTransaction + +# Commit transaction + +Commit transaction, execute all operations in transaction and return msg +*/ +type CommitSpoeTransaction struct { + Context *middleware.Context + Handler CommitSpoeTransactionHandler +} + +func (o *CommitSpoeTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCommitSpoeTransactionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe_transactions/commit_spoe_transaction_parameters.go b/operations/spoe_transactions/commit_spoe_transaction_parameters.go new file mode 100644 index 00000000..4b800638 --- /dev/null +++ b/operations/spoe_transactions/commit_spoe_transaction_parameters.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewCommitSpoeTransactionParams creates a new CommitSpoeTransactionParams object +// with the default values initialized. +func NewCommitSpoeTransactionParams() CommitSpoeTransactionParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CommitSpoeTransactionParams{ + ForceReload: &forceReloadDefault, + } +} + +// CommitSpoeTransactionParams contains all the bound params for the commit spoe transaction operation +// typically these are obtained from a http.Request +// +// swagger:parameters commitSpoeTransaction +type CommitSpoeTransactionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Transaction id + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCommitSpoeTransactionParams() beforehand. +func (o *CommitSpoeTransactionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CommitSpoeTransactionParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCommitSpoeTransactionParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *CommitSpoeTransactionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CommitSpoeTransactionParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/spoe_transactions/commit_spoe_transaction_responses.go b/operations/spoe_transactions/commit_spoe_transaction_responses.go new file mode 100644 index 00000000..3efa6a27 --- /dev/null +++ b/operations/spoe_transactions/commit_spoe_transaction_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CommitSpoeTransactionOKCode is the HTTP code returned for type CommitSpoeTransactionOK +const CommitSpoeTransactionOKCode int = 200 + +/* +CommitSpoeTransactionOK Transaction successfully committed + +swagger:response commitSpoeTransactionOK +*/ +type CommitSpoeTransactionOK struct { + + /* + In: Body + */ + Payload *models.SpoeTransaction `json:"body,omitempty"` +} + +// NewCommitSpoeTransactionOK creates CommitSpoeTransactionOK with default headers values +func NewCommitSpoeTransactionOK() *CommitSpoeTransactionOK { + + return &CommitSpoeTransactionOK{} +} + +// WithPayload adds the payload to the commit spoe transaction o k response +func (o *CommitSpoeTransactionOK) WithPayload(payload *models.SpoeTransaction) *CommitSpoeTransactionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the commit spoe transaction o k response +func (o *CommitSpoeTransactionOK) SetPayload(payload *models.SpoeTransaction) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CommitSpoeTransactionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CommitSpoeTransactionAcceptedCode is the HTTP code returned for type CommitSpoeTransactionAccepted +const CommitSpoeTransactionAcceptedCode int = 202 + +/* +CommitSpoeTransactionAccepted Configuration change accepted and reload requested + +swagger:response commitSpoeTransactionAccepted +*/ +type CommitSpoeTransactionAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.SpoeTransaction `json:"body,omitempty"` +} + +// NewCommitSpoeTransactionAccepted creates CommitSpoeTransactionAccepted with default headers values +func NewCommitSpoeTransactionAccepted() *CommitSpoeTransactionAccepted { + + return &CommitSpoeTransactionAccepted{} +} + +// WithReloadID adds the reloadId to the commit spoe transaction accepted response +func (o *CommitSpoeTransactionAccepted) WithReloadID(reloadID string) *CommitSpoeTransactionAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the commit spoe transaction accepted response +func (o *CommitSpoeTransactionAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the commit spoe transaction accepted response +func (o *CommitSpoeTransactionAccepted) WithPayload(payload *models.SpoeTransaction) *CommitSpoeTransactionAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the commit spoe transaction accepted response +func (o *CommitSpoeTransactionAccepted) SetPayload(payload *models.SpoeTransaction) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CommitSpoeTransactionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CommitSpoeTransactionBadRequestCode is the HTTP code returned for type CommitSpoeTransactionBadRequest +const CommitSpoeTransactionBadRequestCode int = 400 + +/* +CommitSpoeTransactionBadRequest Bad request + +swagger:response commitSpoeTransactionBadRequest +*/ +type CommitSpoeTransactionBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCommitSpoeTransactionBadRequest creates CommitSpoeTransactionBadRequest with default headers values +func NewCommitSpoeTransactionBadRequest() *CommitSpoeTransactionBadRequest { + + return &CommitSpoeTransactionBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the commit spoe transaction bad request response +func (o *CommitSpoeTransactionBadRequest) WithConfigurationVersion(configurationVersion string) *CommitSpoeTransactionBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the commit spoe transaction bad request response +func (o *CommitSpoeTransactionBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the commit spoe transaction bad request response +func (o *CommitSpoeTransactionBadRequest) WithPayload(payload *models.Error) *CommitSpoeTransactionBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the commit spoe transaction bad request response +func (o *CommitSpoeTransactionBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CommitSpoeTransactionBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CommitSpoeTransactionNotFoundCode is the HTTP code returned for type CommitSpoeTransactionNotFound +const CommitSpoeTransactionNotFoundCode int = 404 + +/* +CommitSpoeTransactionNotFound The specified resource was not found + +swagger:response commitSpoeTransactionNotFound +*/ +type CommitSpoeTransactionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCommitSpoeTransactionNotFound creates CommitSpoeTransactionNotFound with default headers values +func NewCommitSpoeTransactionNotFound() *CommitSpoeTransactionNotFound { + + return &CommitSpoeTransactionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the commit spoe transaction not found response +func (o *CommitSpoeTransactionNotFound) WithConfigurationVersion(configurationVersion string) *CommitSpoeTransactionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the commit spoe transaction not found response +func (o *CommitSpoeTransactionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the commit spoe transaction not found response +func (o *CommitSpoeTransactionNotFound) WithPayload(payload *models.Error) *CommitSpoeTransactionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the commit spoe transaction not found response +func (o *CommitSpoeTransactionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CommitSpoeTransactionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CommitSpoeTransactionDefault General Error + +swagger:response commitSpoeTransactionDefault +*/ +type CommitSpoeTransactionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCommitSpoeTransactionDefault creates CommitSpoeTransactionDefault with default headers values +func NewCommitSpoeTransactionDefault(code int) *CommitSpoeTransactionDefault { + if code <= 0 { + code = 500 + } + + return &CommitSpoeTransactionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the commit spoe transaction default response +func (o *CommitSpoeTransactionDefault) WithStatusCode(code int) *CommitSpoeTransactionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the commit spoe transaction default response +func (o *CommitSpoeTransactionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the commit spoe transaction default response +func (o *CommitSpoeTransactionDefault) WithConfigurationVersion(configurationVersion string) *CommitSpoeTransactionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the commit spoe transaction default response +func (o *CommitSpoeTransactionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the commit spoe transaction default response +func (o *CommitSpoeTransactionDefault) WithPayload(payload *models.Error) *CommitSpoeTransactionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the commit spoe transaction default response +func (o *CommitSpoeTransactionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CommitSpoeTransactionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe_transactions/commit_spoe_transaction_urlbuilder.go b/operations/spoe_transactions/commit_spoe_transaction_urlbuilder.go new file mode 100644 index 00000000..93f7dda5 --- /dev/null +++ b/operations/spoe_transactions/commit_spoe_transaction_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CommitSpoeTransactionURL generates an URL for the commit spoe transaction operation +type CommitSpoeTransactionURL struct { + ID string + ParentName string + + ForceReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CommitSpoeTransactionURL) WithBasePath(bp string) *CommitSpoeTransactionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CommitSpoeTransactionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CommitSpoeTransactionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on CommitSpoeTransactionURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CommitSpoeTransactionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CommitSpoeTransactionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CommitSpoeTransactionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CommitSpoeTransactionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CommitSpoeTransactionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CommitSpoeTransactionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CommitSpoeTransactionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe_transactions/delete_spoe_transaction.go b/operations/spoe_transactions/delete_spoe_transaction.go new file mode 100644 index 00000000..b27eb73e --- /dev/null +++ b/operations/spoe_transactions/delete_spoe_transaction.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteSpoeTransactionHandlerFunc turns a function with the right signature into a delete spoe transaction handler +type DeleteSpoeTransactionHandlerFunc func(DeleteSpoeTransactionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteSpoeTransactionHandlerFunc) Handle(params DeleteSpoeTransactionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteSpoeTransactionHandler interface for that can handle valid delete spoe transaction params +type DeleteSpoeTransactionHandler interface { + Handle(DeleteSpoeTransactionParams, interface{}) middleware.Responder +} + +// NewDeleteSpoeTransaction creates a new http.Handler for the delete spoe transaction operation +func NewDeleteSpoeTransaction(ctx *middleware.Context, handler DeleteSpoeTransactionHandler) *DeleteSpoeTransaction { + return &DeleteSpoeTransaction{Context: ctx, Handler: handler} +} + +/* + DeleteSpoeTransaction swagger:route DELETE /services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id} SpoeTransactions deleteSpoeTransaction + +# Delete a transaction + +Deletes a transaction. +*/ +type DeleteSpoeTransaction struct { + Context *middleware.Context + Handler DeleteSpoeTransactionHandler +} + +func (o *DeleteSpoeTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteSpoeTransactionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe_transactions/delete_spoe_transaction_parameters.go b/operations/spoe_transactions/delete_spoe_transaction_parameters.go new file mode 100644 index 00000000..87e2a78f --- /dev/null +++ b/operations/spoe_transactions/delete_spoe_transaction_parameters.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteSpoeTransactionParams creates a new DeleteSpoeTransactionParams object +// +// There are no default values defined in the spec. +func NewDeleteSpoeTransactionParams() DeleteSpoeTransactionParams { + + return DeleteSpoeTransactionParams{} +} + +// DeleteSpoeTransactionParams contains all the bound params for the delete spoe transaction operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteSpoeTransaction +type DeleteSpoeTransactionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Transaction id + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteSpoeTransactionParams() beforehand. +func (o *DeleteSpoeTransactionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *DeleteSpoeTransactionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteSpoeTransactionParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/spoe_transactions/delete_spoe_transaction_responses.go b/operations/spoe_transactions/delete_spoe_transaction_responses.go new file mode 100644 index 00000000..f4968d67 --- /dev/null +++ b/operations/spoe_transactions/delete_spoe_transaction_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteSpoeTransactionNoContentCode is the HTTP code returned for type DeleteSpoeTransactionNoContent +const DeleteSpoeTransactionNoContentCode int = 204 + +/* +DeleteSpoeTransactionNoContent Transaction deleted + +swagger:response deleteSpoeTransactionNoContent +*/ +type DeleteSpoeTransactionNoContent struct { +} + +// NewDeleteSpoeTransactionNoContent creates DeleteSpoeTransactionNoContent with default headers values +func NewDeleteSpoeTransactionNoContent() *DeleteSpoeTransactionNoContent { + + return &DeleteSpoeTransactionNoContent{} +} + +// WriteResponse to the client +func (o *DeleteSpoeTransactionNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteSpoeTransactionNotFoundCode is the HTTP code returned for type DeleteSpoeTransactionNotFound +const DeleteSpoeTransactionNotFoundCode int = 404 + +/* +DeleteSpoeTransactionNotFound The specified resource was not found + +swagger:response deleteSpoeTransactionNotFound +*/ +type DeleteSpoeTransactionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeTransactionNotFound creates DeleteSpoeTransactionNotFound with default headers values +func NewDeleteSpoeTransactionNotFound() *DeleteSpoeTransactionNotFound { + + return &DeleteSpoeTransactionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe transaction not found response +func (o *DeleteSpoeTransactionNotFound) WithConfigurationVersion(configurationVersion string) *DeleteSpoeTransactionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe transaction not found response +func (o *DeleteSpoeTransactionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe transaction not found response +func (o *DeleteSpoeTransactionNotFound) WithPayload(payload *models.Error) *DeleteSpoeTransactionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe transaction not found response +func (o *DeleteSpoeTransactionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeTransactionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteSpoeTransactionDefault General Error + +swagger:response deleteSpoeTransactionDefault +*/ +type DeleteSpoeTransactionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteSpoeTransactionDefault creates DeleteSpoeTransactionDefault with default headers values +func NewDeleteSpoeTransactionDefault(code int) *DeleteSpoeTransactionDefault { + if code <= 0 { + code = 500 + } + + return &DeleteSpoeTransactionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete spoe transaction default response +func (o *DeleteSpoeTransactionDefault) WithStatusCode(code int) *DeleteSpoeTransactionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete spoe transaction default response +func (o *DeleteSpoeTransactionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete spoe transaction default response +func (o *DeleteSpoeTransactionDefault) WithConfigurationVersion(configurationVersion string) *DeleteSpoeTransactionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete spoe transaction default response +func (o *DeleteSpoeTransactionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete spoe transaction default response +func (o *DeleteSpoeTransactionDefault) WithPayload(payload *models.Error) *DeleteSpoeTransactionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete spoe transaction default response +func (o *DeleteSpoeTransactionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteSpoeTransactionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe_transactions/delete_spoe_transaction_urlbuilder.go b/operations/spoe_transactions/delete_spoe_transaction_urlbuilder.go new file mode 100644 index 00000000..ae56a5ee --- /dev/null +++ b/operations/spoe_transactions/delete_spoe_transaction_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteSpoeTransactionURL generates an URL for the delete spoe transaction operation +type DeleteSpoeTransactionURL struct { + ID string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeTransactionURL) WithBasePath(bp string) *DeleteSpoeTransactionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteSpoeTransactionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteSpoeTransactionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on DeleteSpoeTransactionURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteSpoeTransactionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteSpoeTransactionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteSpoeTransactionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteSpoeTransactionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteSpoeTransactionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteSpoeTransactionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteSpoeTransactionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe_transactions/get_all_spoe_transaction.go b/operations/spoe_transactions/get_all_spoe_transaction.go new file mode 100644 index 00000000..599e3432 --- /dev/null +++ b/operations/spoe_transactions/get_all_spoe_transaction.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllSpoeTransactionHandlerFunc turns a function with the right signature into a get all spoe transaction handler +type GetAllSpoeTransactionHandlerFunc func(GetAllSpoeTransactionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllSpoeTransactionHandlerFunc) Handle(params GetAllSpoeTransactionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllSpoeTransactionHandler interface for that can handle valid get all spoe transaction params +type GetAllSpoeTransactionHandler interface { + Handle(GetAllSpoeTransactionParams, interface{}) middleware.Responder +} + +// NewGetAllSpoeTransaction creates a new http.Handler for the get all spoe transaction operation +func NewGetAllSpoeTransaction(ctx *middleware.Context, handler GetAllSpoeTransactionHandler) *GetAllSpoeTransaction { + return &GetAllSpoeTransaction{Context: ctx, Handler: handler} +} + +/* + GetAllSpoeTransaction swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/transactions SpoeTransactions getAllSpoeTransaction + +Return list of SPOE configuration transactions. + +Returns a list of SPOE configuration transactions. Transactions can be filtered by their status. +*/ +type GetAllSpoeTransaction struct { + Context *middleware.Context + Handler GetAllSpoeTransactionHandler +} + +func (o *GetAllSpoeTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllSpoeTransactionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe_transactions/get_all_spoe_transaction_parameters.go b/operations/spoe_transactions/get_all_spoe_transaction_parameters.go new file mode 100644 index 00000000..a8f271ce --- /dev/null +++ b/operations/spoe_transactions/get_all_spoe_transaction_parameters.go @@ -0,0 +1,131 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetAllSpoeTransactionParams creates a new GetAllSpoeTransactionParams object +// +// There are no default values defined in the spec. +func NewGetAllSpoeTransactionParams() GetAllSpoeTransactionParams { + + return GetAllSpoeTransactionParams{} +} + +// GetAllSpoeTransactionParams contains all the bound params for the get all spoe transaction operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllSpoeTransaction +type GetAllSpoeTransactionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*Filter by transaction status + In: query + */ + Status *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllSpoeTransactionParams() beforehand. +func (o *GetAllSpoeTransactionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qStatus, qhkStatus, _ := qs.GetOK("status") + if err := o.bindStatus(qStatus, qhkStatus, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllSpoeTransactionParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindStatus binds and validates parameter Status from query. +func (o *GetAllSpoeTransactionParams) bindStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Status = &raw + + if err := o.validateStatus(formats); err != nil { + return err + } + + return nil +} + +// validateStatus carries on validations for parameter Status +func (o *GetAllSpoeTransactionParams) validateStatus(formats strfmt.Registry) error { + + if err := validate.EnumCase("status", "query", *o.Status, []interface{}{"failed", "in_progress"}, true); err != nil { + return err + } + + return nil +} diff --git a/operations/spoe_transactions/get_all_spoe_transaction_responses.go b/operations/spoe_transactions/get_all_spoe_transaction_responses.go new file mode 100644 index 00000000..563c6b05 --- /dev/null +++ b/operations/spoe_transactions/get_all_spoe_transaction_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllSpoeTransactionOKCode is the HTTP code returned for type GetAllSpoeTransactionOK +const GetAllSpoeTransactionOKCode int = 200 + +/* +GetAllSpoeTransactionOK Success + +swagger:response getAllSpoeTransactionOK +*/ +type GetAllSpoeTransactionOK struct { + + /* + In: Body + */ + Payload models.SpoeTransactions `json:"body,omitempty"` +} + +// NewGetAllSpoeTransactionOK creates GetAllSpoeTransactionOK with default headers values +func NewGetAllSpoeTransactionOK() *GetAllSpoeTransactionOK { + + return &GetAllSpoeTransactionOK{} +} + +// WithPayload adds the payload to the get all spoe transaction o k response +func (o *GetAllSpoeTransactionOK) WithPayload(payload models.SpoeTransactions) *GetAllSpoeTransactionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe transaction o k response +func (o *GetAllSpoeTransactionOK) SetPayload(payload models.SpoeTransactions) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeTransactionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SpoeTransactions{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllSpoeTransactionDefault General Error + +swagger:response getAllSpoeTransactionDefault +*/ +type GetAllSpoeTransactionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllSpoeTransactionDefault creates GetAllSpoeTransactionDefault with default headers values +func NewGetAllSpoeTransactionDefault(code int) *GetAllSpoeTransactionDefault { + if code <= 0 { + code = 500 + } + + return &GetAllSpoeTransactionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all spoe transaction default response +func (o *GetAllSpoeTransactionDefault) WithStatusCode(code int) *GetAllSpoeTransactionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all spoe transaction default response +func (o *GetAllSpoeTransactionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all spoe transaction default response +func (o *GetAllSpoeTransactionDefault) WithConfigurationVersion(configurationVersion string) *GetAllSpoeTransactionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all spoe transaction default response +func (o *GetAllSpoeTransactionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all spoe transaction default response +func (o *GetAllSpoeTransactionDefault) WithPayload(payload *models.Error) *GetAllSpoeTransactionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all spoe transaction default response +func (o *GetAllSpoeTransactionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllSpoeTransactionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe_transactions/get_all_spoe_transaction_urlbuilder.go b/operations/spoe_transactions/get_all_spoe_transaction_urlbuilder.go new file mode 100644 index 00000000..c4c43bd6 --- /dev/null +++ b/operations/spoe_transactions/get_all_spoe_transaction_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllSpoeTransactionURL generates an URL for the get all spoe transaction operation +type GetAllSpoeTransactionURL struct { + ParentName string + + Status *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeTransactionURL) WithBasePath(bp string) *GetAllSpoeTransactionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllSpoeTransactionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllSpoeTransactionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/transactions" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllSpoeTransactionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var statusQ string + if o.Status != nil { + statusQ = *o.Status + } + if statusQ != "" { + qs.Set("status", statusQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllSpoeTransactionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllSpoeTransactionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllSpoeTransactionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllSpoeTransactionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllSpoeTransactionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllSpoeTransactionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe_transactions/get_spoe_transaction.go b/operations/spoe_transactions/get_spoe_transaction.go new file mode 100644 index 00000000..d0a2000c --- /dev/null +++ b/operations/spoe_transactions/get_spoe_transaction.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetSpoeTransactionHandlerFunc turns a function with the right signature into a get spoe transaction handler +type GetSpoeTransactionHandlerFunc func(GetSpoeTransactionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetSpoeTransactionHandlerFunc) Handle(params GetSpoeTransactionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetSpoeTransactionHandler interface for that can handle valid get spoe transaction params +type GetSpoeTransactionHandler interface { + Handle(GetSpoeTransactionParams, interface{}) middleware.Responder +} + +// NewGetSpoeTransaction creates a new http.Handler for the get spoe transaction operation +func NewGetSpoeTransaction(ctx *middleware.Context, handler GetSpoeTransactionHandler) *GetSpoeTransaction { + return &GetSpoeTransaction{Context: ctx, Handler: handler} +} + +/* + GetSpoeTransaction swagger:route GET /services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id} SpoeTransactions getSpoeTransaction + +# Return one SPOE configuration transactions + +Returns one SPOE configuration transactions. +*/ +type GetSpoeTransaction struct { + Context *middleware.Context + Handler GetSpoeTransactionHandler +} + +func (o *GetSpoeTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetSpoeTransactionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/spoe_transactions/get_spoe_transaction_parameters.go b/operations/spoe_transactions/get_spoe_transaction_parameters.go new file mode 100644 index 00000000..57e33f8d --- /dev/null +++ b/operations/spoe_transactions/get_spoe_transaction_parameters.go @@ -0,0 +1,110 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetSpoeTransactionParams creates a new GetSpoeTransactionParams object +// +// There are no default values defined in the spec. +func NewGetSpoeTransactionParams() GetSpoeTransactionParams { + + return GetSpoeTransactionParams{} +} + +// GetSpoeTransactionParams contains all the bound params for the get spoe transaction operation +// typically these are obtained from a http.Request +// +// swagger:parameters getSpoeTransaction +type GetSpoeTransactionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Transaction id + Required: true + In: path + */ + ID string + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetSpoeTransactionParams() beforehand. +func (o *GetSpoeTransactionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rID, rhkID, _ := route.Params.GetOK("id") + if err := o.bindID(rID, rhkID, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindID binds and validates parameter ID from path. +func (o *GetSpoeTransactionParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ID = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetSpoeTransactionParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/spoe_transactions/get_spoe_transaction_responses.go b/operations/spoe_transactions/get_spoe_transaction_responses.go new file mode 100644 index 00000000..c83facaf --- /dev/null +++ b/operations/spoe_transactions/get_spoe_transaction_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetSpoeTransactionOKCode is the HTTP code returned for type GetSpoeTransactionOK +const GetSpoeTransactionOKCode int = 200 + +/* +GetSpoeTransactionOK Successful operation + +swagger:response getSpoeTransactionOK +*/ +type GetSpoeTransactionOK struct { + + /* + In: Body + */ + Payload *models.SpoeTransaction `json:"body,omitempty"` +} + +// NewGetSpoeTransactionOK creates GetSpoeTransactionOK with default headers values +func NewGetSpoeTransactionOK() *GetSpoeTransactionOK { + + return &GetSpoeTransactionOK{} +} + +// WithPayload adds the payload to the get spoe transaction o k response +func (o *GetSpoeTransactionOK) WithPayload(payload *models.SpoeTransaction) *GetSpoeTransactionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe transaction o k response +func (o *GetSpoeTransactionOK) SetPayload(payload *models.SpoeTransaction) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeTransactionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetSpoeTransactionNotFoundCode is the HTTP code returned for type GetSpoeTransactionNotFound +const GetSpoeTransactionNotFoundCode int = 404 + +/* +GetSpoeTransactionNotFound The specified resource was not found + +swagger:response getSpoeTransactionNotFound +*/ +type GetSpoeTransactionNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeTransactionNotFound creates GetSpoeTransactionNotFound with default headers values +func NewGetSpoeTransactionNotFound() *GetSpoeTransactionNotFound { + + return &GetSpoeTransactionNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe transaction not found response +func (o *GetSpoeTransactionNotFound) WithConfigurationVersion(configurationVersion string) *GetSpoeTransactionNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe transaction not found response +func (o *GetSpoeTransactionNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe transaction not found response +func (o *GetSpoeTransactionNotFound) WithPayload(payload *models.Error) *GetSpoeTransactionNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe transaction not found response +func (o *GetSpoeTransactionNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeTransactionNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetSpoeTransactionDefault General Error + +swagger:response getSpoeTransactionDefault +*/ +type GetSpoeTransactionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetSpoeTransactionDefault creates GetSpoeTransactionDefault with default headers values +func NewGetSpoeTransactionDefault(code int) *GetSpoeTransactionDefault { + if code <= 0 { + code = 500 + } + + return &GetSpoeTransactionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get spoe transaction default response +func (o *GetSpoeTransactionDefault) WithStatusCode(code int) *GetSpoeTransactionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get spoe transaction default response +func (o *GetSpoeTransactionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get spoe transaction default response +func (o *GetSpoeTransactionDefault) WithConfigurationVersion(configurationVersion string) *GetSpoeTransactionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get spoe transaction default response +func (o *GetSpoeTransactionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get spoe transaction default response +func (o *GetSpoeTransactionDefault) WithPayload(payload *models.Error) *GetSpoeTransactionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get spoe transaction default response +func (o *GetSpoeTransactionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetSpoeTransactionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe_transactions/get_spoe_transaction_urlbuilder.go b/operations/spoe_transactions/get_spoe_transaction_urlbuilder.go new file mode 100644 index 00000000..1c002f4b --- /dev/null +++ b/operations/spoe_transactions/get_spoe_transaction_urlbuilder.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetSpoeTransactionURL generates an URL for the get spoe transaction operation +type GetSpoeTransactionURL struct { + ID string + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeTransactionURL) WithBasePath(bp string) *GetSpoeTransactionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetSpoeTransactionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetSpoeTransactionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/transactions/{id}" + + id := o.ID + if id != "" { + _path = strings.Replace(_path, "{id}", id, -1) + } else { + return nil, errors.New("id is required on GetSpoeTransactionURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetSpoeTransactionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetSpoeTransactionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetSpoeTransactionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetSpoeTransactionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetSpoeTransactionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetSpoeTransactionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetSpoeTransactionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/spoe_transactions/start_spoe_transaction.go b/operations/spoe_transactions/start_spoe_transaction.go new file mode 100644 index 00000000..0b8e63da --- /dev/null +++ b/operations/spoe_transactions/start_spoe_transaction.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// StartSpoeTransactionHandlerFunc turns a function with the right signature into a start spoe transaction handler +type StartSpoeTransactionHandlerFunc func(StartSpoeTransactionParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn StartSpoeTransactionHandlerFunc) Handle(params StartSpoeTransactionParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// StartSpoeTransactionHandler interface for that can handle valid start spoe transaction params +type StartSpoeTransactionHandler interface { + Handle(StartSpoeTransactionParams, interface{}) middleware.Responder +} + +// NewStartSpoeTransaction creates a new http.Handler for the start spoe transaction operation +func NewStartSpoeTransaction(ctx *middleware.Context, handler StartSpoeTransactionHandler) *StartSpoeTransaction { + return &StartSpoeTransaction{Context: ctx, Handler: handler} +} + +/* + StartSpoeTransaction swagger:route POST /services/haproxy/spoe/spoe_files/{parent_name}/transactions SpoeTransactions startSpoeTransaction + +# Start a new transaction + +Starts a new transaction and returns it's id +*/ +type StartSpoeTransaction struct { + Context *middleware.Context + Handler StartSpoeTransactionHandler +} + +func (o *StartSpoeTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewStartSpoeTransactionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// StartSpoeTransactionTooManyRequestsBody start spoe transaction too many requests body +// Example: {"code":429,"message":"cannot start a new transaction, reached the maximum amount of 20 active transactions available"} +// +// swagger:model StartSpoeTransactionTooManyRequestsBody +type StartSpoeTransactionTooManyRequestsBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this start spoe transaction too many requests body +func (o *StartSpoeTransactionTooManyRequestsBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this start spoe transaction too many requests body based on context it is used +func (o *StartSpoeTransactionTooManyRequestsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *StartSpoeTransactionTooManyRequestsBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *StartSpoeTransactionTooManyRequestsBody) UnmarshalBinary(b []byte) error { + var res StartSpoeTransactionTooManyRequestsBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/operations/spoe_transactions/start_spoe_transaction_parameters.go b/operations/spoe_transactions/start_spoe_transaction_parameters.go new file mode 100644 index 00000000..17791634 --- /dev/null +++ b/operations/spoe_transactions/start_spoe_transaction_parameters.go @@ -0,0 +1,127 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewStartSpoeTransactionParams creates a new StartSpoeTransactionParams object +// +// There are no default values defined in the spec. +func NewStartSpoeTransactionParams() StartSpoeTransactionParams { + + return StartSpoeTransactionParams{} +} + +// StartSpoeTransactionParams contains all the bound params for the start spoe transaction operation +// typically these are obtained from a http.Request +// +// swagger:parameters startSpoeTransaction +type StartSpoeTransactionParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*Configuration version on which to work on + Required: true + In: query + */ + Version int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewStartSpoeTransactionParams() beforehand. +func (o *StartSpoeTransactionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *StartSpoeTransactionParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *StartSpoeTransactionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("version", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("version", "query", raw); err != nil { + return err + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = value + + return nil +} diff --git a/operations/spoe_transactions/start_spoe_transaction_responses.go b/operations/spoe_transactions/start_spoe_transaction_responses.go new file mode 100644 index 00000000..816cc982 --- /dev/null +++ b/operations/spoe_transactions/start_spoe_transaction_responses.go @@ -0,0 +1,200 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// StartSpoeTransactionCreatedCode is the HTTP code returned for type StartSpoeTransactionCreated +const StartSpoeTransactionCreatedCode int = 201 + +/* +StartSpoeTransactionCreated Transaction started + +swagger:response startSpoeTransactionCreated +*/ +type StartSpoeTransactionCreated struct { + + /* + In: Body + */ + Payload *models.SpoeTransaction `json:"body,omitempty"` +} + +// NewStartSpoeTransactionCreated creates StartSpoeTransactionCreated with default headers values +func NewStartSpoeTransactionCreated() *StartSpoeTransactionCreated { + + return &StartSpoeTransactionCreated{} +} + +// WithPayload adds the payload to the start spoe transaction created response +func (o *StartSpoeTransactionCreated) WithPayload(payload *models.SpoeTransaction) *StartSpoeTransactionCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start spoe transaction created response +func (o *StartSpoeTransactionCreated) SetPayload(payload *models.SpoeTransaction) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartSpoeTransactionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// StartSpoeTransactionTooManyRequestsCode is the HTTP code returned for type StartSpoeTransactionTooManyRequests +const StartSpoeTransactionTooManyRequestsCode int = 429 + +/* +StartSpoeTransactionTooManyRequests Too many open transactions + +swagger:response startSpoeTransactionTooManyRequests +*/ +type StartSpoeTransactionTooManyRequests struct { + + /* + In: Body + */ + Payload *StartSpoeTransactionTooManyRequestsBody `json:"body,omitempty"` +} + +// NewStartSpoeTransactionTooManyRequests creates StartSpoeTransactionTooManyRequests with default headers values +func NewStartSpoeTransactionTooManyRequests() *StartSpoeTransactionTooManyRequests { + + return &StartSpoeTransactionTooManyRequests{} +} + +// WithPayload adds the payload to the start spoe transaction too many requests response +func (o *StartSpoeTransactionTooManyRequests) WithPayload(payload *StartSpoeTransactionTooManyRequestsBody) *StartSpoeTransactionTooManyRequests { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start spoe transaction too many requests response +func (o *StartSpoeTransactionTooManyRequests) SetPayload(payload *StartSpoeTransactionTooManyRequestsBody) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartSpoeTransactionTooManyRequests) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(429) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +StartSpoeTransactionDefault General Error + +swagger:response startSpoeTransactionDefault +*/ +type StartSpoeTransactionDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewStartSpoeTransactionDefault creates StartSpoeTransactionDefault with default headers values +func NewStartSpoeTransactionDefault(code int) *StartSpoeTransactionDefault { + if code <= 0 { + code = 500 + } + + return &StartSpoeTransactionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the start spoe transaction default response +func (o *StartSpoeTransactionDefault) WithStatusCode(code int) *StartSpoeTransactionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the start spoe transaction default response +func (o *StartSpoeTransactionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the start spoe transaction default response +func (o *StartSpoeTransactionDefault) WithConfigurationVersion(configurationVersion string) *StartSpoeTransactionDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the start spoe transaction default response +func (o *StartSpoeTransactionDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the start spoe transaction default response +func (o *StartSpoeTransactionDefault) WithPayload(payload *models.Error) *StartSpoeTransactionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start spoe transaction default response +func (o *StartSpoeTransactionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartSpoeTransactionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/spoe_transactions/start_spoe_transaction_urlbuilder.go b/operations/spoe_transactions/start_spoe_transaction_urlbuilder.go new file mode 100644 index 00000000..093f9110 --- /dev/null +++ b/operations/spoe_transactions/start_spoe_transaction_urlbuilder.go @@ -0,0 +1,127 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package spoe_transactions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// StartSpoeTransactionURL generates an URL for the start spoe transaction operation +type StartSpoeTransactionURL struct { + ParentName string + + Version int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StartSpoeTransactionURL) WithBasePath(bp string) *StartSpoeTransactionURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *StartSpoeTransactionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *StartSpoeTransactionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/spoe/spoe_files/{parent_name}/transactions" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on StartSpoeTransactionURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + versionQ := swag.FormatInt64(o.Version) + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *StartSpoeTransactionURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *StartSpoeTransactionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *StartSpoeTransactionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on StartSpoeTransactionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on StartSpoeTransactionURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *StartSpoeTransactionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/stats/get_stats.go b/operations/stats/get_stats.go index 5fd55be2..0772c39a 100644 --- a/operations/stats/get_stats.go +++ b/operations/stats/get_stats.go @@ -23,7 +23,7 @@ package stats import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetStatsHandlerFunc turns a function with the right signature into a get stats handler @@ -44,12 +44,12 @@ func NewGetStats(ctx *middleware.Context, handler GetStatsHandler) *GetStats { return &GetStats{Context: ctx, Handler: handler} } -/*GetStats swagger:route GET /services/haproxy/stats/native Stats getStats +/* + GetStats swagger:route GET /services/haproxy/stats/native Stats getStats -Gets stats +# Gets stats Getting stats from the HAProxy. - */ type GetStats struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetStats struct { func (o *GetStats) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetStatsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetStats) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/stats/get_stats_parameters.go b/operations/stats/get_stats_parameters.go index 09901dee..5185684c 100644 --- a/operations/stats/get_stats_parameters.go +++ b/operations/stats/get_stats_parameters.go @@ -26,13 +26,13 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewGetStatsParams creates a new GetStatsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetStatsParams() GetStatsParams { return GetStatsParams{} @@ -86,7 +86,6 @@ func (o *GetStatsParams) BindRequest(r *http.Request, route *middleware.MatchedR if err := o.bindType(qType, qhkType, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -102,10 +101,10 @@ func (o *GetStatsParams) bindName(rawData []string, hasKey bool, formats strfmt. // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.Name = &raw return nil @@ -120,10 +119,10 @@ func (o *GetStatsParams) bindParent(rawData []string, hasKey bool, formats strfm // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.Parent = &raw return nil @@ -138,10 +137,10 @@ func (o *GetStatsParams) bindType(rawData []string, hasKey bool, formats strfmt. // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.Type = &raw if err := o.validateType(formats); err != nil { @@ -154,7 +153,7 @@ func (o *GetStatsParams) bindType(rawData []string, hasKey bool, formats strfmt. // validateType carries on validations for parameter Type func (o *GetStatsParams) validateType(formats strfmt.Registry) error { - if err := validate.Enum("type", "query", *o.Type, []interface{}{"frontend", "backend", "server"}); err != nil { + if err := validate.EnumCase("type", "query", *o.Type, []interface{}{"frontend", "backend", "server"}, true); err != nil { return err } diff --git a/operations/stats/get_stats_responses.go b/operations/stats/get_stats_responses.go index de384c4c..906b95d1 100644 --- a/operations/stats/get_stats_responses.go +++ b/operations/stats/get_stats_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetStatsOKCode is the HTTP code returned for type GetStatsOK const GetStatsOKCode int = 200 -/*GetStatsOK Success +/* +GetStatsOK Success swagger:response getStatsOK */ @@ -41,7 +41,7 @@ type GetStatsOK struct { /* In: Body */ - Payload models.NativeStats `json:"body,omitempty"` + Payload *models.NativeStats `json:"body,omitempty"` } // NewGetStatsOK creates GetStatsOK with default headers values @@ -51,13 +51,13 @@ func NewGetStatsOK() *GetStatsOK { } // WithPayload adds the payload to the get stats o k response -func (o *GetStatsOK) WithPayload(payload models.NativeStats) *GetStatsOK { +func (o *GetStatsOK) WithPayload(payload *models.NativeStats) *GetStatsOK { o.Payload = payload return o } // SetPayload sets the payload to the get stats o k response -func (o *GetStatsOK) SetPayload(payload models.NativeStats) { +func (o *GetStatsOK) SetPayload(payload *models.NativeStats) { o.Payload = payload } @@ -65,21 +65,19 @@ func (o *GetStatsOK) SetPayload(payload models.NativeStats) { func (o *GetStatsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { rw.WriteHeader(200) - payload := o.Payload - if payload == nil { - // return empty array - payload = models.NativeStats{} - } - - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } } } // GetStatsInternalServerErrorCode is the HTTP code returned for type GetStatsInternalServerError const GetStatsInternalServerErrorCode int = 500 -/*GetStatsInternalServerError Internal Server Error +/* +GetStatsInternalServerError Internal Server Error swagger:response getStatsInternalServerError */ @@ -88,7 +86,7 @@ type GetStatsInternalServerError struct { /* In: Body */ - Payload models.NativeStats `json:"body,omitempty"` + Payload *models.NativeStats `json:"body,omitempty"` } // NewGetStatsInternalServerError creates GetStatsInternalServerError with default headers values @@ -98,13 +96,13 @@ func NewGetStatsInternalServerError() *GetStatsInternalServerError { } // WithPayload adds the payload to the get stats internal server error response -func (o *GetStatsInternalServerError) WithPayload(payload models.NativeStats) *GetStatsInternalServerError { +func (o *GetStatsInternalServerError) WithPayload(payload *models.NativeStats) *GetStatsInternalServerError { o.Payload = payload return o } // SetPayload sets the payload to the get stats internal server error response -func (o *GetStatsInternalServerError) SetPayload(payload models.NativeStats) { +func (o *GetStatsInternalServerError) SetPayload(payload *models.NativeStats) { o.Payload = payload } @@ -112,18 +110,16 @@ func (o *GetStatsInternalServerError) SetPayload(payload models.NativeStats) { func (o *GetStatsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { rw.WriteHeader(500) - payload := o.Payload - if payload == nil { - // return empty array - payload = models.NativeStats{} - } - - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } } } -/*GetStatsDefault General Error +/* +GetStatsDefault General Error swagger:response getStatsDefault */ @@ -132,7 +128,7 @@ type GetStatsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -163,13 +159,13 @@ func (o *GetStatsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get stats default response -func (o *GetStatsDefault) WithConfigurationVersion(configurationVersion int64) *GetStatsDefault { +func (o *GetStatsDefault) WithConfigurationVersion(configurationVersion string) *GetStatsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get stats default response -func (o *GetStatsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetStatsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -189,7 +185,7 @@ func (o *GetStatsDefault) WriteResponse(rw http.ResponseWriter, producer runtime // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/stats/get_stats_urlbuilder.go b/operations/stats/get_stats_urlbuilder.go index 5dcaad33..fc30b406 100644 --- a/operations/stats/get_stats_urlbuilder.go +++ b/operations/stats/get_stats_urlbuilder.go @@ -60,34 +60,34 @@ func (o *GetStatsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var name string + var nameQ string if o.Name != nil { - name = *o.Name + nameQ = *o.Name } - if name != "" { - qs.Set("name", name) + if nameQ != "" { + qs.Set("name", nameQ) } - var parent string + var parentQ string if o.Parent != nil { - parent = *o.Parent + parentQ = *o.Parent } - if parent != "" { - qs.Set("parent", parent) + if parentQ != "" { + qs.Set("parent", parentQ) } - var typeVar string + var typeVarQ string if o.Type != nil { - typeVar = *o.Type + typeVarQ = *o.Type } - if typeVar != "" { - qs.Set("type", typeVar) + if typeVarQ != "" { + qs.Set("type", typeVarQ) } _result.RawQuery = qs.Encode() diff --git a/operations/stick_rule/create_stick_rule.go b/operations/stick_rule/create_stick_rule.go index 0f4b9d66..53db16f9 100644 --- a/operations/stick_rule/create_stick_rule.go +++ b/operations/stick_rule/create_stick_rule.go @@ -23,7 +23,7 @@ package stick_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // CreateStickRuleHandlerFunc turns a function with the right signature into a create stick rule handler @@ -44,12 +44,12 @@ func NewCreateStickRule(ctx *middleware.Context, handler CreateStickRuleHandler) return &CreateStickRule{Context: ctx, Handler: handler} } -/*CreateStickRule swagger:route POST /services/haproxy/configuration/stick_rules StickRule createStickRule +/* + CreateStickRule swagger:route POST /services/haproxy/configuration/backends/{parent_name}/stick_rules/{index} StickRule createStickRule -Add a new Stick Rule +# Add a new Stick Rule Adds a new Stick Rule of the specified type in the specified backend. - */ type CreateStickRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type CreateStickRule struct { func (o *CreateStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewCreateStickRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *CreateStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/stick_rule/create_stick_rule_parameters.go b/operations/stick_rule/create_stick_rule_parameters.go index 7af0b8d9..e24c1b04 100644 --- a/operations/stick_rule/create_stick_rule_parameters.go +++ b/operations/stick_rule/create_stick_rule_parameters.go @@ -27,12 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewCreateStickRuleParams creates a new CreateStickRuleParams object @@ -59,11 +57,6 @@ type CreateStickRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name - Required: true - In: query - */ - Backend string /* Required: true In: body @@ -74,6 +67,16 @@ type CreateStickRuleParams struct { Default: false */ ForceReload *bool + /*Stick Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -95,17 +98,12 @@ func (o *CreateStickRuleParams) BindRequest(r *http.Request, route *middleware.M qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - if runtime.HasBody(r) { defer r.Body.Close() var body models.StickRule if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -120,13 +118,24 @@ func (o *CreateStickRuleParams) BindRequest(r *http.Request, route *middleware.M } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) @@ -136,53 +145,65 @@ func (o *CreateStickRuleParams) BindRequest(r *http.Request, route *middleware.M if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *CreateStickRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateStickRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } - // Required: true + // Required: false // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateStickRuleParams() + return nil } - o.Backend = raw + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value return nil } -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateStickRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindIndex binds and validates parameter Index from path. +func (o *CreateStickRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateStickRuleParams() - return nil - } + // Required: true + // Parameter is provided by construction from the route - value, err := swag.ConvertBool(raw) + value, err := swag.ConvertInt64(raw) if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) + return errors.InvalidType("index", "path", "int64", raw) } - o.ForceReload = &value + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateStickRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -196,10 +217,10 @@ func (o *CreateStickRuleParams) bindTransactionID(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -214,6 +235,7 @@ func (o *CreateStickRuleParams) bindVersion(rawData []string, hasKey bool, forma // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/stick_rule/create_stick_rule_responses.go b/operations/stick_rule/create_stick_rule_responses.go index 97b62683..62251213 100644 --- a/operations/stick_rule/create_stick_rule_responses.go +++ b/operations/stick_rule/create_stick_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // CreateStickRuleCreatedCode is the HTTP code returned for type CreateStickRuleCreated const CreateStickRuleCreatedCode int = 201 -/*CreateStickRuleCreated Stick Rule created +/* +CreateStickRuleCreated Stick Rule created swagger:response createStickRuleCreated */ @@ -76,7 +76,8 @@ func (o *CreateStickRuleCreated) WriteResponse(rw http.ResponseWriter, producer // CreateStickRuleAcceptedCode is the HTTP code returned for type CreateStickRuleAccepted const CreateStickRuleAcceptedCode int = 202 -/*CreateStickRuleAccepted Configuration change accepted and reload requested +/* +CreateStickRuleAccepted Configuration change accepted and reload requested swagger:response createStickRuleAccepted */ @@ -142,7 +143,8 @@ func (o *CreateStickRuleAccepted) WriteResponse(rw http.ResponseWriter, producer // CreateStickRuleBadRequestCode is the HTTP code returned for type CreateStickRuleBadRequest const CreateStickRuleBadRequestCode int = 400 -/*CreateStickRuleBadRequest Bad request +/* +CreateStickRuleBadRequest Bad request swagger:response createStickRuleBadRequest */ @@ -150,7 +152,7 @@ type CreateStickRuleBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewCreateStickRuleBadRequest() *CreateStickRuleBadRequest { } // WithConfigurationVersion adds the configurationVersion to the create stick rule bad request response -func (o *CreateStickRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateStickRuleBadRequest { +func (o *CreateStickRuleBadRequest) WithConfigurationVersion(configurationVersion string) *CreateStickRuleBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create stick rule bad request response -func (o *CreateStickRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateStickRuleBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *CreateStickRuleBadRequest) WriteResponse(rw http.ResponseWriter, produc // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *CreateStickRuleBadRequest) WriteResponse(rw http.ResponseWriter, produc // CreateStickRuleConflictCode is the HTTP code returned for type CreateStickRuleConflict const CreateStickRuleConflictCode int = 409 -/*CreateStickRuleConflict The specified resource already exists +/* +CreateStickRuleConflict The specified resource already exists swagger:response createStickRuleConflict */ @@ -216,7 +219,7 @@ type CreateStickRuleConflict struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewCreateStickRuleConflict() *CreateStickRuleConflict { } // WithConfigurationVersion adds the configurationVersion to the create stick rule conflict response -func (o *CreateStickRuleConflict) WithConfigurationVersion(configurationVersion int64) *CreateStickRuleConflict { +func (o *CreateStickRuleConflict) WithConfigurationVersion(configurationVersion string) *CreateStickRuleConflict { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create stick rule conflict response -func (o *CreateStickRuleConflict) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateStickRuleConflict) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *CreateStickRuleConflict) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *CreateStickRuleConflict) WriteResponse(rw http.ResponseWriter, producer } } -/*CreateStickRuleDefault General Error +/* +CreateStickRuleDefault General Error swagger:response createStickRuleDefault */ @@ -280,7 +284,7 @@ type CreateStickRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *CreateStickRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the create stick rule default response -func (o *CreateStickRuleDefault) WithConfigurationVersion(configurationVersion int64) *CreateStickRuleDefault { +func (o *CreateStickRuleDefault) WithConfigurationVersion(configurationVersion string) *CreateStickRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the create stick rule default response -func (o *CreateStickRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *CreateStickRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *CreateStickRuleDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/stick_rule/create_stick_rule_urlbuilder.go b/operations/stick_rule/create_stick_rule_urlbuilder.go index d025b13a..afe672ee 100644 --- a/operations/stick_rule/create_stick_rule_urlbuilder.go +++ b/operations/stick_rule/create_stick_rule_urlbuilder.go @@ -24,13 +24,16 @@ import ( "errors" "net/url" golangswaggerpaths "path" + "strings" "github.com/go-openapi/swag" ) // CreateStickRuleURL generates an URL for the create stick rule operation type CreateStickRuleURL struct { - Backend string + Index int64 + ParentName string + ForceReload *bool TransactionID *string Version *int64 @@ -59,43 +62,52 @@ func (o *CreateStickRuleURL) SetBasePath(bp string) { func (o *CreateStickRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/stick_rules" + var _path = "/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateStickRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateStickRuleURL") + } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/stick_rule/delete_stick_rule.go b/operations/stick_rule/delete_stick_rule.go index a2f3364e..8cbfb2bf 100644 --- a/operations/stick_rule/delete_stick_rule.go +++ b/operations/stick_rule/delete_stick_rule.go @@ -23,7 +23,7 @@ package stick_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // DeleteStickRuleHandlerFunc turns a function with the right signature into a delete stick rule handler @@ -44,12 +44,12 @@ func NewDeleteStickRule(ctx *middleware.Context, handler DeleteStickRuleHandler) return &DeleteStickRule{Context: ctx, Handler: handler} } -/*DeleteStickRule swagger:route DELETE /services/haproxy/configuration/stick_rules/{id} StickRule deleteStickRule +/* + DeleteStickRule swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/stick_rules/{index} StickRule deleteStickRule -Delete a Stick Rule - -Deletes a Stick Rule configuration by it's ID from the specified backend. +# Delete a Stick Rule +Deletes a Stick Rule configuration by it's index from the specified backend. */ type DeleteStickRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type DeleteStickRule struct { func (o *DeleteStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewDeleteStickRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *DeleteStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/stick_rule/delete_stick_rule_parameters.go b/operations/stick_rule/delete_stick_rule_parameters.go index 9002265c..bff42efe 100644 --- a/operations/stick_rule/delete_stick_rule_parameters.go +++ b/operations/stick_rule/delete_stick_rule_parameters.go @@ -26,10 +26,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewDeleteStickRuleParams creates a new DeleteStickRuleParams object @@ -56,21 +54,21 @@ type DeleteStickRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name - Required: true - In: query - */ - Backend string /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. In: query Default: false */ ForceReload *bool - /*Stick Rule ID + /*Stick Rule Index Required: true In: path */ - ID int64 + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -92,18 +90,18 @@ func (o *DeleteStickRuleParams) BindRequest(r *http.Request, route *middleware.M qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -116,34 +114,12 @@ func (o *DeleteStickRuleParams) BindRequest(r *http.Request, route *middleware.M if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *DeleteStickRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - // bindForceReload binds and validates parameter ForceReload from query. func (o *DeleteStickRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -153,6 +129,7 @@ func (o *DeleteStickRuleParams) bindForceReload(rawData []string, hasKey bool, f // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewDeleteStickRuleParams() return nil @@ -167,8 +144,8 @@ func (o *DeleteStickRuleParams) bindForceReload(rawData []string, hasKey bool, f return nil } -// bindID binds and validates parameter ID from path. -func (o *DeleteStickRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindIndex binds and validates parameter Index from path. +func (o *DeleteStickRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -179,9 +156,23 @@ func (o *DeleteStickRuleParams) bindID(rawData []string, hasKey bool, formats st value, err := swag.ConvertInt64(raw) if err != nil { - return errors.InvalidType("id", "path", "int64", raw) + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteStickRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] } - o.ID = value + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -195,10 +186,10 @@ func (o *DeleteStickRuleParams) bindTransactionID(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -213,6 +204,7 @@ func (o *DeleteStickRuleParams) bindVersion(rawData []string, hasKey bool, forma // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/stick_rule/delete_stick_rule_responses.go b/operations/stick_rule/delete_stick_rule_responses.go index 5052f4e4..3d63ae0b 100644 --- a/operations/stick_rule/delete_stick_rule_responses.go +++ b/operations/stick_rule/delete_stick_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // DeleteStickRuleAcceptedCode is the HTTP code returned for type DeleteStickRuleAccepted const DeleteStickRuleAcceptedCode int = 202 -/*DeleteStickRuleAccepted Configuration change accepted and reload requested +/* +DeleteStickRuleAccepted Configuration change accepted and reload requested swagger:response deleteStickRuleAccepted */ @@ -78,7 +78,8 @@ func (o *DeleteStickRuleAccepted) WriteResponse(rw http.ResponseWriter, producer // DeleteStickRuleNoContentCode is the HTTP code returned for type DeleteStickRuleNoContent const DeleteStickRuleNoContentCode int = 204 -/*DeleteStickRuleNoContent Stick Rule deleted +/* +DeleteStickRuleNoContent Stick Rule deleted swagger:response deleteStickRuleNoContent */ @@ -102,7 +103,8 @@ func (o *DeleteStickRuleNoContent) WriteResponse(rw http.ResponseWriter, produce // DeleteStickRuleNotFoundCode is the HTTP code returned for type DeleteStickRuleNotFound const DeleteStickRuleNotFoundCode int = 404 -/*DeleteStickRuleNotFound The specified resource was not found +/* +DeleteStickRuleNotFound The specified resource was not found swagger:response deleteStickRuleNotFound */ @@ -110,7 +112,7 @@ type DeleteStickRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -125,13 +127,13 @@ func NewDeleteStickRuleNotFound() *DeleteStickRuleNotFound { } // WithConfigurationVersion adds the configurationVersion to the delete stick rule not found response -func (o *DeleteStickRuleNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteStickRuleNotFound { +func (o *DeleteStickRuleNotFound) WithConfigurationVersion(configurationVersion string) *DeleteStickRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete stick rule not found response -func (o *DeleteStickRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteStickRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -151,7 +153,7 @@ func (o *DeleteStickRuleNotFound) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -165,7 +167,8 @@ func (o *DeleteStickRuleNotFound) WriteResponse(rw http.ResponseWriter, producer } } -/*DeleteStickRuleDefault General Error +/* +DeleteStickRuleDefault General Error swagger:response deleteStickRuleDefault */ @@ -174,7 +177,7 @@ type DeleteStickRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -205,13 +208,13 @@ func (o *DeleteStickRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the delete stick rule default response -func (o *DeleteStickRuleDefault) WithConfigurationVersion(configurationVersion int64) *DeleteStickRuleDefault { +func (o *DeleteStickRuleDefault) WithConfigurationVersion(configurationVersion string) *DeleteStickRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete stick rule default response -func (o *DeleteStickRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteStickRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -231,7 +234,7 @@ func (o *DeleteStickRuleDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/stick_rule/delete_stick_rule_urlbuilder.go b/operations/stick_rule/delete_stick_rule_urlbuilder.go index 4d07535d..75582b5c 100644 --- a/operations/stick_rule/delete_stick_rule_urlbuilder.go +++ b/operations/stick_rule/delete_stick_rule_urlbuilder.go @@ -31,9 +31,9 @@ import ( // DeleteStickRuleURL generates an URL for the delete stick rule operation type DeleteStickRuleURL struct { - ID int64 + Index int64 + ParentName string - Backend string ForceReload *bool TransactionID *string Version *int64 @@ -62,50 +62,52 @@ func (o *DeleteStickRuleURL) SetBasePath(bp string) { func (o *DeleteStickRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/stick_rules/{id}" + var _path = "/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on DeleteStickRuleURL") + return nil, errors.New("index is required on DeleteStickRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteStickRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/stick_rule/get_stick_rule.go b/operations/stick_rule/get_stick_rule.go index c5010f1f..b11ebc47 100644 --- a/operations/stick_rule/get_stick_rule.go +++ b/operations/stick_rule/get_stick_rule.go @@ -23,12 +23,7 @@ package stick_rule import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetStickRuleHandlerFunc turns a function with the right signature into a get stick rule handler @@ -49,12 +44,12 @@ func NewGetStickRule(ctx *middleware.Context, handler GetStickRuleHandler) *GetS return &GetStickRule{Context: ctx, Handler: handler} } -/*GetStickRule swagger:route GET /services/haproxy/configuration/stick_rules/{id} StickRule getStickRule - -Return one Stick Rule +/* + GetStickRule swagger:route GET /services/haproxy/configuration/backends/{parent_name}/stick_rules/{index} StickRule getStickRule -Returns one Stick Rule configuration by it's ID in the specified backend. +# Return one Stick Rule +Returns one Stick Rule configuration by it's index in the specified backend. */ type GetStickRule struct { Context *middleware.Context @@ -64,21 +59,20 @@ type GetStickRule struct { func (o *GetStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetStickRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -87,68 +81,6 @@ func (o *GetStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetStickRuleOKBody get stick rule o k body -// swagger:model GetStickRuleOKBody -type GetStickRuleOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.StickRule `json:"data,omitempty"` -} - -// Validate validates this get stick rule o k body -func (o *GetStickRuleOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetStickRuleOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getStickRuleOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetStickRuleOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetStickRuleOKBody) UnmarshalBinary(b []byte) error { - var res GetStickRuleOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/stick_rule/get_stick_rule_parameters.go b/operations/stick_rule/get_stick_rule_parameters.go index 18f46491..952dfd31 100644 --- a/operations/stick_rule/get_stick_rule_parameters.go +++ b/operations/stick_rule/get_stick_rule_parameters.go @@ -26,14 +26,13 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewGetStickRuleParams creates a new GetStickRuleParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetStickRuleParams() GetStickRuleParams { return GetStickRuleParams{} @@ -48,16 +47,16 @@ type GetStickRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name + /*Stick Rule Index Required: true - In: query + In: path */ - Backend string - /*Stick Rule ID + Index int64 + /*Parent name Required: true In: path */ - ID int64 + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -75,13 +74,13 @@ func (o *GetStickRuleParams) BindRequest(r *http.Request, route *middleware.Matc qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -89,36 +88,33 @@ func (o *GetStickRuleParams) BindRequest(r *http.Request, route *middleware.Matc if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *GetStickRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } +// bindIndex binds and validates parameter Index from path. +func (o *GetStickRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } + // Parameter is provided by construction from the route - o.Backend = raw + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value return nil } -// bindID binds and validates parameter ID from path. -func (o *GetStickRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindParentName binds and validates parameter ParentName from path. +func (o *GetStickRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -126,12 +122,7 @@ func (o *GetStickRuleParams) bindID(rawData []string, hasKey bool, formats strfm // Required: true // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value + o.ParentName = raw return nil } @@ -145,10 +136,10 @@ func (o *GetStickRuleParams) bindTransactionID(rawData []string, hasKey bool, fo // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/stick_rule/get_stick_rule_responses.go b/operations/stick_rule/get_stick_rule_responses.go index 6fca37cf..e2815da5 100644 --- a/operations/stick_rule/get_stick_rule_responses.go +++ b/operations/stick_rule/get_stick_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetStickRuleOKCode is the HTTP code returned for type GetStickRuleOK const GetStickRuleOKCode int = 200 -/*GetStickRuleOK Successful operation +/* +GetStickRuleOK Successful operation swagger:response getStickRuleOK */ @@ -40,12 +40,12 @@ type GetStickRuleOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetStickRuleOKBody `json:"body,omitempty"` + Payload *models.StickRule `json:"body,omitempty"` } // NewGetStickRuleOK creates GetStickRuleOK with default headers values @@ -55,24 +55,24 @@ func NewGetStickRuleOK() *GetStickRuleOK { } // WithConfigurationVersion adds the configurationVersion to the get stick rule o k response -func (o *GetStickRuleOK) WithConfigurationVersion(configurationVersion int64) *GetStickRuleOK { +func (o *GetStickRuleOK) WithConfigurationVersion(configurationVersion string) *GetStickRuleOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get stick rule o k response -func (o *GetStickRuleOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetStickRuleOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get stick rule o k response -func (o *GetStickRuleOK) WithPayload(payload *GetStickRuleOKBody) *GetStickRuleOK { +func (o *GetStickRuleOK) WithPayload(payload *models.StickRule) *GetStickRuleOK { o.Payload = payload return o } // SetPayload sets the payload to the get stick rule o k response -func (o *GetStickRuleOK) SetPayload(payload *GetStickRuleOKBody) { +func (o *GetStickRuleOK) SetPayload(payload *models.StickRule) { o.Payload = payload } @@ -81,7 +81,7 @@ func (o *GetStickRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime. // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -98,7 +98,8 @@ func (o *GetStickRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime. // GetStickRuleNotFoundCode is the HTTP code returned for type GetStickRuleNotFound const GetStickRuleNotFoundCode int = 404 -/*GetStickRuleNotFound The specified resource was not found +/* +GetStickRuleNotFound The specified resource was not found swagger:response getStickRuleNotFound */ @@ -106,7 +107,7 @@ type GetStickRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -121,13 +122,13 @@ func NewGetStickRuleNotFound() *GetStickRuleNotFound { } // WithConfigurationVersion adds the configurationVersion to the get stick rule not found response -func (o *GetStickRuleNotFound) WithConfigurationVersion(configurationVersion int64) *GetStickRuleNotFound { +func (o *GetStickRuleNotFound) WithConfigurationVersion(configurationVersion string) *GetStickRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get stick rule not found response -func (o *GetStickRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetStickRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -147,7 +148,7 @@ func (o *GetStickRuleNotFound) WriteResponse(rw http.ResponseWriter, producer ru // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -161,7 +162,8 @@ func (o *GetStickRuleNotFound) WriteResponse(rw http.ResponseWriter, producer ru } } -/*GetStickRuleDefault General Error +/* +GetStickRuleDefault General Error swagger:response getStickRuleDefault */ @@ -170,7 +172,7 @@ type GetStickRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -201,13 +203,13 @@ func (o *GetStickRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get stick rule default response -func (o *GetStickRuleDefault) WithConfigurationVersion(configurationVersion int64) *GetStickRuleDefault { +func (o *GetStickRuleDefault) WithConfigurationVersion(configurationVersion string) *GetStickRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get stick rule default response -func (o *GetStickRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetStickRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -227,7 +229,7 @@ func (o *GetStickRuleDefault) WriteResponse(rw http.ResponseWriter, producer run // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/stick_rule/get_stick_rule_urlbuilder.go b/operations/stick_rule/get_stick_rule_urlbuilder.go index 66314a77..9e35ed36 100644 --- a/operations/stick_rule/get_stick_rule_urlbuilder.go +++ b/operations/stick_rule/get_stick_rule_urlbuilder.go @@ -31,9 +31,9 @@ import ( // GetStickRuleURL generates an URL for the get stick rule operation type GetStickRuleURL struct { - ID int64 + Index int64 + ParentName string - Backend string TransactionID *string _basePath string @@ -60,34 +60,36 @@ func (o *GetStickRuleURL) SetBasePath(bp string) { func (o *GetStickRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/stick_rules/{id}" + var _path = "/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on GetStickRuleURL") + return nil, errors.New("index is required on GetStickRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetStickRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/stick_rule/get_stick_rules.go b/operations/stick_rule/get_stick_rules.go index b37bc952..0010a595 100644 --- a/operations/stick_rule/get_stick_rules.go +++ b/operations/stick_rule/get_stick_rules.go @@ -23,13 +23,7 @@ package stick_rule import ( "net/http" - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" + "github.com/go-openapi/runtime/middleware" ) // GetStickRulesHandlerFunc turns a function with the right signature into a get stick rules handler @@ -50,12 +44,12 @@ func NewGetStickRules(ctx *middleware.Context, handler GetStickRulesHandler) *Ge return &GetStickRules{Context: ctx, Handler: handler} } -/*GetStickRules swagger:route GET /services/haproxy/configuration/stick_rules StickRule getStickRules +/* + GetStickRules swagger:route GET /services/haproxy/configuration/backends/{parent_name}/stick_rules StickRule getStickRules -Return an array of all Stick Rules +# Return an array of all Stick Rules Returns all Stick Rules that are configured in specified backend. - */ type GetStickRules struct { Context *middleware.Context @@ -65,21 +59,20 @@ type GetStickRules struct { func (o *GetStickRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetStickRulesParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -88,67 +81,6 @@ func (o *GetStickRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } - -// GetStickRulesOKBody get stick rules o k body -// swagger:model GetStickRulesOKBody -type GetStickRulesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.StickRules `json:"data"` -} - -// Validate validates this get stick rules o k body -func (o *GetStickRulesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetStickRulesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getStickRulesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getStickRulesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetStickRulesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetStickRulesOKBody) UnmarshalBinary(b []byte) error { - var res GetStickRulesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/stick_rule/get_stick_rules_parameters.go b/operations/stick_rule/get_stick_rules_parameters.go index 4d59c548..0e77aeb3 100644 --- a/operations/stick_rule/get_stick_rules_parameters.go +++ b/operations/stick_rule/get_stick_rules_parameters.go @@ -26,13 +26,12 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewGetStickRulesParams creates a new GetStickRulesParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetStickRulesParams() GetStickRulesParams { return GetStickRulesParams{} @@ -47,11 +46,11 @@ type GetStickRulesParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name + /*Parent name Required: true - In: query + In: path */ - Backend string + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -69,8 +68,8 @@ func (o *GetStickRulesParams) BindRequest(r *http.Request, route *middleware.Mat qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -78,30 +77,22 @@ func (o *GetStickRulesParams) BindRequest(r *http.Request, route *middleware.Mat if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *GetStickRulesParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } +// bindParentName binds and validates parameter ParentName from path. +func (o *GetStickRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -115,10 +106,10 @@ func (o *GetStickRulesParams) bindTransactionID(rawData []string, hasKey bool, f // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil diff --git a/operations/stick_rule/get_stick_rules_responses.go b/operations/stick_rule/get_stick_rules_responses.go index db4c45d0..4458caa4 100644 --- a/operations/stick_rule/get_stick_rules_responses.go +++ b/operations/stick_rule/get_stick_rules_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetStickRulesOKCode is the HTTP code returned for type GetStickRulesOK const GetStickRulesOKCode int = 200 -/*GetStickRulesOK Successful operation +/* +GetStickRulesOK Successful operation swagger:response getStickRulesOK */ @@ -40,12 +40,12 @@ type GetStickRulesOK struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body */ - Payload *GetStickRulesOKBody `json:"body,omitempty"` + Payload models.StickRules `json:"body,omitempty"` } // NewGetStickRulesOK creates GetStickRulesOK with default headers values @@ -55,24 +55,24 @@ func NewGetStickRulesOK() *GetStickRulesOK { } // WithConfigurationVersion adds the configurationVersion to the get stick rules o k response -func (o *GetStickRulesOK) WithConfigurationVersion(configurationVersion int64) *GetStickRulesOK { +func (o *GetStickRulesOK) WithConfigurationVersion(configurationVersion string) *GetStickRulesOK { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get stick rules o k response -func (o *GetStickRulesOK) SetConfigurationVersion(configurationVersion int64) { +func (o *GetStickRulesOK) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } // WithPayload adds the payload to the get stick rules o k response -func (o *GetStickRulesOK) WithPayload(payload *GetStickRulesOKBody) *GetStickRulesOK { +func (o *GetStickRulesOK) WithPayload(payload models.StickRules) *GetStickRulesOK { o.Payload = payload return o } // SetPayload sets the payload to the get stick rules o k response -func (o *GetStickRulesOK) SetPayload(payload *GetStickRulesOKBody) { +func (o *GetStickRulesOK) SetPayload(payload models.StickRules) { o.Payload = payload } @@ -81,21 +81,25 @@ func (o *GetStickRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } + payload := o.Payload + if payload == nil { + // return empty array + payload = models.StickRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this } } -/*GetStickRulesDefault General Error +/* +GetStickRulesDefault General Error swagger:response getStickRulesDefault */ @@ -104,7 +108,7 @@ type GetStickRulesDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -135,13 +139,13 @@ func (o *GetStickRulesDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get stick rules default response -func (o *GetStickRulesDefault) WithConfigurationVersion(configurationVersion int64) *GetStickRulesDefault { +func (o *GetStickRulesDefault) WithConfigurationVersion(configurationVersion string) *GetStickRulesDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get stick rules default response -func (o *GetStickRulesDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetStickRulesDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -161,7 +165,7 @@ func (o *GetStickRulesDefault) WriteResponse(rw http.ResponseWriter, producer ru // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/stick_rule/get_stick_rules_urlbuilder.go b/operations/stick_rule/get_stick_rules_urlbuilder.go index eb8da6c4..bae1f9ed 100644 --- a/operations/stick_rule/get_stick_rules_urlbuilder.go +++ b/operations/stick_rule/get_stick_rules_urlbuilder.go @@ -24,11 +24,13 @@ import ( "errors" "net/url" golangswaggerpaths "path" + "strings" ) // GetStickRulesURL generates an URL for the get stick rules operation type GetStickRulesURL struct { - Backend string + ParentName string + TransactionID *string _basePath string @@ -55,27 +57,29 @@ func (o *GetStickRulesURL) SetBasePath(bp string) { func (o *GetStickRulesURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/stick_rules" + var _path = "/services/haproxy/configuration/backends/{parent_name}/stick_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetStickRulesURL") + } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } _result.RawQuery = qs.Encode() diff --git a/operations/stick_rule/replace_stick_rule.go b/operations/stick_rule/replace_stick_rule.go index 00e59e07..2f2df077 100644 --- a/operations/stick_rule/replace_stick_rule.go +++ b/operations/stick_rule/replace_stick_rule.go @@ -23,7 +23,7 @@ package stick_rule import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // ReplaceStickRuleHandlerFunc turns a function with the right signature into a replace stick rule handler @@ -44,12 +44,12 @@ func NewReplaceStickRule(ctx *middleware.Context, handler ReplaceStickRuleHandle return &ReplaceStickRule{Context: ctx, Handler: handler} } -/*ReplaceStickRule swagger:route PUT /services/haproxy/configuration/stick_rules/{id} StickRule replaceStickRule +/* + ReplaceStickRule swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/stick_rules/{index} StickRule replaceStickRule -Replace a Stick Rule - -Replaces a Stick Rule configuration by it's ID in the specified backend. +# Replace a Stick Rule +Replaces a Stick Rule configuration by it's index in the specified backend. */ type ReplaceStickRule struct { Context *middleware.Context @@ -59,21 +59,20 @@ type ReplaceStickRule struct { func (o *ReplaceStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewReplaceStickRuleParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *ReplaceStickRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/stick_rule/replace_stick_rule_parameters.go b/operations/stick_rule/replace_stick_rule_parameters.go index 1e68b462..4bab91a9 100644 --- a/operations/stick_rule/replace_stick_rule_parameters.go +++ b/operations/stick_rule/replace_stick_rule_parameters.go @@ -27,12 +27,10 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // NewReplaceStickRuleParams creates a new ReplaceStickRuleParams object @@ -59,11 +57,6 @@ type ReplaceStickRuleParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` - /*Backend name - Required: true - In: query - */ - Backend string /* Required: true In: body @@ -74,11 +67,16 @@ type ReplaceStickRuleParams struct { Default: false */ ForceReload *bool - /*Stick Rule ID + /*Stick Rule Index Required: true In: path */ - ID int64 + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. In: query */ @@ -100,17 +98,12 @@ func (o *ReplaceStickRuleParams) BindRequest(r *http.Request, route *middleware. qs := runtime.Values(r.URL.Query()) - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - if runtime.HasBody(r) { defer r.Body.Close() var body models.StickRule if err := route.Consumer.Consume(r.Body, &body); err != nil { if err == io.EOF { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } else { res = append(res, errors.NewParseError("data", "body", "", err)) } @@ -125,15 +118,21 @@ func (o *ReplaceStickRuleParams) BindRequest(r *http.Request, route *middleware. } } } else { - res = append(res, errors.Required("data", "body")) + res = append(res, errors.Required("data", "body", "")) } + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { res = append(res, err) } - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { res = append(res, err) } @@ -146,34 +145,12 @@ func (o *ReplaceStickRuleParams) BindRequest(r *http.Request, route *middleware. if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } -// bindBackend binds and validates parameter Backend from query. -func (o *ReplaceStickRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - // bindForceReload binds and validates parameter ForceReload from query. func (o *ReplaceStickRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string @@ -183,6 +160,7 @@ func (o *ReplaceStickRuleParams) bindForceReload(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewReplaceStickRuleParams() return nil @@ -197,8 +175,8 @@ func (o *ReplaceStickRuleParams) bindForceReload(rawData []string, hasKey bool, return nil } -// bindID binds and validates parameter ID from path. -func (o *ReplaceStickRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceStickRuleParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -209,9 +187,23 @@ func (o *ReplaceStickRuleParams) bindID(rawData []string, hasKey bool, formats s value, err := swag.ConvertInt64(raw) if err != nil { - return errors.InvalidType("id", "path", "int64", raw) + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceStickRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] } - o.ID = value + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw return nil } @@ -225,10 +217,10 @@ func (o *ReplaceStickRuleParams) bindTransactionID(rawData []string, hasKey bool // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.TransactionID = &raw return nil @@ -243,6 +235,7 @@ func (o *ReplaceStickRuleParams) bindVersion(rawData []string, hasKey bool, form // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } diff --git a/operations/stick_rule/replace_stick_rule_responses.go b/operations/stick_rule/replace_stick_rule_responses.go index c62c61f5..ff3a2140 100644 --- a/operations/stick_rule/replace_stick_rule_responses.go +++ b/operations/stick_rule/replace_stick_rule_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // ReplaceStickRuleOKCode is the HTTP code returned for type ReplaceStickRuleOK const ReplaceStickRuleOKCode int = 200 -/*ReplaceStickRuleOK Stick Rule replaced +/* +ReplaceStickRuleOK Stick Rule replaced swagger:response replaceStickRuleOK */ @@ -76,7 +76,8 @@ func (o *ReplaceStickRuleOK) WriteResponse(rw http.ResponseWriter, producer runt // ReplaceStickRuleAcceptedCode is the HTTP code returned for type ReplaceStickRuleAccepted const ReplaceStickRuleAcceptedCode int = 202 -/*ReplaceStickRuleAccepted Configuration change accepted and reload requested +/* +ReplaceStickRuleAccepted Configuration change accepted and reload requested swagger:response replaceStickRuleAccepted */ @@ -142,7 +143,8 @@ func (o *ReplaceStickRuleAccepted) WriteResponse(rw http.ResponseWriter, produce // ReplaceStickRuleBadRequestCode is the HTTP code returned for type ReplaceStickRuleBadRequest const ReplaceStickRuleBadRequestCode int = 400 -/*ReplaceStickRuleBadRequest Bad request +/* +ReplaceStickRuleBadRequest Bad request swagger:response replaceStickRuleBadRequest */ @@ -150,7 +152,7 @@ type ReplaceStickRuleBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +167,13 @@ func NewReplaceStickRuleBadRequest() *ReplaceStickRuleBadRequest { } // WithConfigurationVersion adds the configurationVersion to the replace stick rule bad request response -func (o *ReplaceStickRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceStickRuleBadRequest { +func (o *ReplaceStickRuleBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceStickRuleBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace stick rule bad request response -func (o *ReplaceStickRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceStickRuleBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +193,7 @@ func (o *ReplaceStickRuleBadRequest) WriteResponse(rw http.ResponseWriter, produ // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +210,8 @@ func (o *ReplaceStickRuleBadRequest) WriteResponse(rw http.ResponseWriter, produ // ReplaceStickRuleNotFoundCode is the HTTP code returned for type ReplaceStickRuleNotFound const ReplaceStickRuleNotFoundCode int = 404 -/*ReplaceStickRuleNotFound The specified resource was not found +/* +ReplaceStickRuleNotFound The specified resource was not found swagger:response replaceStickRuleNotFound */ @@ -216,7 +219,7 @@ type ReplaceStickRuleNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +234,13 @@ func NewReplaceStickRuleNotFound() *ReplaceStickRuleNotFound { } // WithConfigurationVersion adds the configurationVersion to the replace stick rule not found response -func (o *ReplaceStickRuleNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceStickRuleNotFound { +func (o *ReplaceStickRuleNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceStickRuleNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace stick rule not found response -func (o *ReplaceStickRuleNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceStickRuleNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +260,7 @@ func (o *ReplaceStickRuleNotFound) WriteResponse(rw http.ResponseWriter, produce // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +274,8 @@ func (o *ReplaceStickRuleNotFound) WriteResponse(rw http.ResponseWriter, produce } } -/*ReplaceStickRuleDefault General Error +/* +ReplaceStickRuleDefault General Error swagger:response replaceStickRuleDefault */ @@ -280,7 +284,7 @@ type ReplaceStickRuleDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +315,13 @@ func (o *ReplaceStickRuleDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the replace stick rule default response -func (o *ReplaceStickRuleDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceStickRuleDefault { +func (o *ReplaceStickRuleDefault) WithConfigurationVersion(configurationVersion string) *ReplaceStickRuleDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the replace stick rule default response -func (o *ReplaceStickRuleDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *ReplaceStickRuleDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +341,7 @@ func (o *ReplaceStickRuleDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/stick_rule/replace_stick_rule_urlbuilder.go b/operations/stick_rule/replace_stick_rule_urlbuilder.go index c2631873..fc7ecd37 100644 --- a/operations/stick_rule/replace_stick_rule_urlbuilder.go +++ b/operations/stick_rule/replace_stick_rule_urlbuilder.go @@ -31,9 +31,9 @@ import ( // ReplaceStickRuleURL generates an URL for the replace stick rule operation type ReplaceStickRuleURL struct { - ID int64 + Index int64 + ParentName string - Backend string ForceReload *bool TransactionID *string Version *int64 @@ -62,50 +62,52 @@ func (o *ReplaceStickRuleURL) SetBasePath(bp string) { func (o *ReplaceStickRuleURL) Build() (*url.URL, error) { var _result url.URL - var _path = "/services/haproxy/configuration/stick_rules/{id}" + var _path = "/services/haproxy/configuration/backends/{parent_name}/stick_rules/{index}" - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) } else { - return nil, errors.New("id is required on ReplaceStickRuleURL") + return nil, errors.New("index is required on ReplaceStickRuleURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceStickRuleURL") } _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } - var transactionID string + var transactionIDQ string if o.TransactionID != nil { - transactionID = *o.TransactionID + transactionIDQ = *o.TransactionID } - if transactionID != "" { - qs.Set("transaction_id", transactionID) + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) } - var version string + var versionQ string if o.Version != nil { - version = swag.FormatInt64(*o.Version) + versionQ = swag.FormatInt64(*o.Version) } - if version != "" { - qs.Set("version", version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/stick_rule/replace_stick_rules.go b/operations/stick_rule/replace_stick_rules.go new file mode 100644 index 00000000..9f94ca19 --- /dev/null +++ b/operations/stick_rule/replace_stick_rules.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceStickRulesHandlerFunc turns a function with the right signature into a replace stick rules handler +type ReplaceStickRulesHandlerFunc func(ReplaceStickRulesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceStickRulesHandlerFunc) Handle(params ReplaceStickRulesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceStickRulesHandler interface for that can handle valid replace stick rules params +type ReplaceStickRulesHandler interface { + Handle(ReplaceStickRulesParams, interface{}) middleware.Responder +} + +// NewReplaceStickRules creates a new http.Handler for the replace stick rules operation +func NewReplaceStickRules(ctx *middleware.Context, handler ReplaceStickRulesHandler) *ReplaceStickRules { + return &ReplaceStickRules{Context: ctx, Handler: handler} +} + +/* + ReplaceStickRules swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/stick_rules StickRule replaceStickRules + +# Replace a Stick Rule list + +Replaces a whole list of Stick Rules with the list given in parameter +*/ +type ReplaceStickRules struct { + Context *middleware.Context + Handler ReplaceStickRulesHandler +} + +func (o *ReplaceStickRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceStickRulesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/stick_rule/replace_stick_rules_parameters.go b/operations/stick_rule/replace_stick_rules_parameters.go new file mode 100644 index 00000000..58ba13f6 --- /dev/null +++ b/operations/stick_rule/replace_stick_rules_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceStickRulesParams creates a new ReplaceStickRulesParams object +// with the default values initialized. +func NewReplaceStickRulesParams() ReplaceStickRulesParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceStickRulesParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceStickRulesParams contains all the bound params for the replace stick rules operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceStickRules +type ReplaceStickRulesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.StickRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceStickRulesParams() beforehand. +func (o *ReplaceStickRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.StickRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceStickRulesParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStickRulesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceStickRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceStickRulesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceStickRulesParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/stick_rule/replace_stick_rules_responses.go b/operations/stick_rule/replace_stick_rules_responses.go new file mode 100644 index 00000000..a79fee69 --- /dev/null +++ b/operations/stick_rule/replace_stick_rules_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceStickRulesOKCode is the HTTP code returned for type ReplaceStickRulesOK +const ReplaceStickRulesOKCode int = 200 + +/* +ReplaceStickRulesOK All Stick Rule lines replaced + +swagger:response replaceStickRulesOK +*/ +type ReplaceStickRulesOK struct { + + /* + In: Body + */ + Payload models.StickRules `json:"body,omitempty"` +} + +// NewReplaceStickRulesOK creates ReplaceStickRulesOK with default headers values +func NewReplaceStickRulesOK() *ReplaceStickRulesOK { + + return &ReplaceStickRulesOK{} +} + +// WithPayload adds the payload to the replace stick rules o k response +func (o *ReplaceStickRulesOK) WithPayload(payload models.StickRules) *ReplaceStickRulesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace stick rules o k response +func (o *ReplaceStickRulesOK) SetPayload(payload models.StickRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStickRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.StickRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceStickRulesAcceptedCode is the HTTP code returned for type ReplaceStickRulesAccepted +const ReplaceStickRulesAcceptedCode int = 202 + +/* +ReplaceStickRulesAccepted Configuration change accepted and reload requested + +swagger:response replaceStickRulesAccepted +*/ +type ReplaceStickRulesAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.StickRules `json:"body,omitempty"` +} + +// NewReplaceStickRulesAccepted creates ReplaceStickRulesAccepted with default headers values +func NewReplaceStickRulesAccepted() *ReplaceStickRulesAccepted { + + return &ReplaceStickRulesAccepted{} +} + +// WithReloadID adds the reloadId to the replace stick rules accepted response +func (o *ReplaceStickRulesAccepted) WithReloadID(reloadID string) *ReplaceStickRulesAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace stick rules accepted response +func (o *ReplaceStickRulesAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace stick rules accepted response +func (o *ReplaceStickRulesAccepted) WithPayload(payload models.StickRules) *ReplaceStickRulesAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace stick rules accepted response +func (o *ReplaceStickRulesAccepted) SetPayload(payload models.StickRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStickRulesAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.StickRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceStickRulesBadRequestCode is the HTTP code returned for type ReplaceStickRulesBadRequest +const ReplaceStickRulesBadRequestCode int = 400 + +/* +ReplaceStickRulesBadRequest Bad request + +swagger:response replaceStickRulesBadRequest +*/ +type ReplaceStickRulesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStickRulesBadRequest creates ReplaceStickRulesBadRequest with default headers values +func NewReplaceStickRulesBadRequest() *ReplaceStickRulesBadRequest { + + return &ReplaceStickRulesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace stick rules bad request response +func (o *ReplaceStickRulesBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceStickRulesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace stick rules bad request response +func (o *ReplaceStickRulesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace stick rules bad request response +func (o *ReplaceStickRulesBadRequest) WithPayload(payload *models.Error) *ReplaceStickRulesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace stick rules bad request response +func (o *ReplaceStickRulesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStickRulesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceStickRulesDefault General Error + +swagger:response replaceStickRulesDefault +*/ +type ReplaceStickRulesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStickRulesDefault creates ReplaceStickRulesDefault with default headers values +func NewReplaceStickRulesDefault(code int) *ReplaceStickRulesDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceStickRulesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace stick rules default response +func (o *ReplaceStickRulesDefault) WithStatusCode(code int) *ReplaceStickRulesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace stick rules default response +func (o *ReplaceStickRulesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace stick rules default response +func (o *ReplaceStickRulesDefault) WithConfigurationVersion(configurationVersion string) *ReplaceStickRulesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace stick rules default response +func (o *ReplaceStickRulesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace stick rules default response +func (o *ReplaceStickRulesDefault) WithPayload(payload *models.Error) *ReplaceStickRulesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace stick rules default response +func (o *ReplaceStickRulesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStickRulesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/stick_rule/replace_stick_rules_urlbuilder.go b/operations/stick_rule/replace_stick_rules_urlbuilder.go new file mode 100644 index 00000000..c03b9b82 --- /dev/null +++ b/operations/stick_rule/replace_stick_rules_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceStickRulesURL generates an URL for the replace stick rules operation +type ReplaceStickRulesURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStickRulesURL) WithBasePath(bp string) *ReplaceStickRulesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStickRulesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceStickRulesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/stick_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceStickRulesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceStickRulesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceStickRulesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceStickRulesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceStickRulesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceStickRulesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceStickRulesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/stick_table/get_stick_table.go b/operations/stick_table/get_stick_table.go new file mode 100644 index 00000000..9efdd169 --- /dev/null +++ b/operations/stick_table/get_stick_table.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetStickTableHandlerFunc turns a function with the right signature into a get stick table handler +type GetStickTableHandlerFunc func(GetStickTableParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetStickTableHandlerFunc) Handle(params GetStickTableParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetStickTableHandler interface for that can handle valid get stick table params +type GetStickTableHandler interface { + Handle(GetStickTableParams, interface{}) middleware.Responder +} + +// NewGetStickTable creates a new http.Handler for the get stick table operation +func NewGetStickTable(ctx *middleware.Context, handler GetStickTableHandler) *GetStickTable { + return &GetStickTable{Context: ctx, Handler: handler} +} + +/* + GetStickTable swagger:route GET /services/haproxy/runtime/stick_tables/{name} StickTable getStickTable + +# Return Stick Table + +Returns one stick table from runtime. +*/ +type GetStickTable struct { + Context *middleware.Context + Handler GetStickTableHandler +} + +func (o *GetStickTable) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetStickTableParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/stick_table/get_stick_table_entries.go b/operations/stick_table/get_stick_table_entries.go new file mode 100644 index 00000000..5d96d830 --- /dev/null +++ b/operations/stick_table/get_stick_table_entries.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetStickTableEntriesHandlerFunc turns a function with the right signature into a get stick table entries handler +type GetStickTableEntriesHandlerFunc func(GetStickTableEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetStickTableEntriesHandlerFunc) Handle(params GetStickTableEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetStickTableEntriesHandler interface for that can handle valid get stick table entries params +type GetStickTableEntriesHandler interface { + Handle(GetStickTableEntriesParams, interface{}) middleware.Responder +} + +// NewGetStickTableEntries creates a new http.Handler for the get stick table entries operation +func NewGetStickTableEntries(ctx *middleware.Context, handler GetStickTableEntriesHandler) *GetStickTableEntries { + return &GetStickTableEntries{Context: ctx, Handler: handler} +} + +/* + GetStickTableEntries swagger:route GET /services/haproxy/runtime/stick_tables/{parent_name}/entries StickTable getStickTableEntries + +# Return Stick Table Entries + +Returns an array of all entries in a given stick tables. +*/ +type GetStickTableEntries struct { + Context *middleware.Context + Handler GetStickTableEntriesHandler +} + +func (o *GetStickTableEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetStickTableEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/stick_table/get_stick_table_entries_parameters.go b/operations/stick_table/get_stick_table_entries_parameters.go new file mode 100644 index 00000000..f214233f --- /dev/null +++ b/operations/stick_table/get_stick_table_entries_parameters.go @@ -0,0 +1,208 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetStickTableEntriesParams creates a new GetStickTableEntriesParams object +// +// There are no default values defined in the spec. +func NewGetStickTableEntriesParams() GetStickTableEntriesParams { + + return GetStickTableEntriesParams{} +} + +// GetStickTableEntriesParams contains all the bound params for the get stick table entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters getStickTableEntries +type GetStickTableEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Max number of entries to be returned for pagination + In: query + */ + Count *int64 + /*A list of filters in format data.<type> <operator> <value> separated by comma + In: query + */ + Filter *string + /*Key which we want the entries for + In: query + */ + Key *string + /*Offset which indicates how many items we skip in pagination + In: query + */ + Offset *int64 + /*Parent name + Required: true + In: path + */ + ParentName string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetStickTableEntriesParams() beforehand. +func (o *GetStickTableEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qCount, qhkCount, _ := qs.GetOK("count") + if err := o.bindCount(qCount, qhkCount, route.Formats); err != nil { + res = append(res, err) + } + + qFilter, qhkFilter, _ := qs.GetOK("filter") + if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil { + res = append(res, err) + } + + qKey, qhkKey, _ := qs.GetOK("key") + if err := o.bindKey(qKey, qhkKey, route.Formats); err != nil { + res = append(res, err) + } + + qOffset, qhkOffset, _ := qs.GetOK("offset") + if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCount binds and validates parameter Count from query. +func (o *GetStickTableEntriesParams) bindCount(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("count", "query", "int64", raw) + } + o.Count = &value + + return nil +} + +// bindFilter binds and validates parameter Filter from query. +func (o *GetStickTableEntriesParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Filter = &raw + + return nil +} + +// bindKey binds and validates parameter Key from query. +func (o *GetStickTableEntriesParams) bindKey(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.Key = &raw + + return nil +} + +// bindOffset binds and validates parameter Offset from query. +func (o *GetStickTableEntriesParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("offset", "query", "int64", raw) + } + o.Offset = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetStickTableEntriesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/stick_table/get_stick_table_entries_responses.go b/operations/stick_table/get_stick_table_entries_responses.go new file mode 100644 index 00000000..a2f9aa6f --- /dev/null +++ b/operations/stick_table/get_stick_table_entries_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetStickTableEntriesOKCode is the HTTP code returned for type GetStickTableEntriesOK +const GetStickTableEntriesOKCode int = 200 + +/* +GetStickTableEntriesOK Successful operation + +swagger:response getStickTableEntriesOK +*/ +type GetStickTableEntriesOK struct { + + /* + In: Body + */ + Payload models.StickTableEntries `json:"body,omitempty"` +} + +// NewGetStickTableEntriesOK creates GetStickTableEntriesOK with default headers values +func NewGetStickTableEntriesOK() *GetStickTableEntriesOK { + + return &GetStickTableEntriesOK{} +} + +// WithPayload adds the payload to the get stick table entries o k response +func (o *GetStickTableEntriesOK) WithPayload(payload models.StickTableEntries) *GetStickTableEntriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get stick table entries o k response +func (o *GetStickTableEntriesOK) SetPayload(payload models.StickTableEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStickTableEntriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.StickTableEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetStickTableEntriesDefault General Error + +swagger:response getStickTableEntriesDefault +*/ +type GetStickTableEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetStickTableEntriesDefault creates GetStickTableEntriesDefault with default headers values +func NewGetStickTableEntriesDefault(code int) *GetStickTableEntriesDefault { + if code <= 0 { + code = 500 + } + + return &GetStickTableEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get stick table entries default response +func (o *GetStickTableEntriesDefault) WithStatusCode(code int) *GetStickTableEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get stick table entries default response +func (o *GetStickTableEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get stick table entries default response +func (o *GetStickTableEntriesDefault) WithConfigurationVersion(configurationVersion string) *GetStickTableEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get stick table entries default response +func (o *GetStickTableEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get stick table entries default response +func (o *GetStickTableEntriesDefault) WithPayload(payload *models.Error) *GetStickTableEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get stick table entries default response +func (o *GetStickTableEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStickTableEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/stick_table/get_stick_table_entries_urlbuilder.go b/operations/stick_table/get_stick_table_entries_urlbuilder.go new file mode 100644 index 00000000..1c9f5b5b --- /dev/null +++ b/operations/stick_table/get_stick_table_entries_urlbuilder.go @@ -0,0 +1,157 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetStickTableEntriesURL generates an URL for the get stick table entries operation +type GetStickTableEntriesURL struct { + ParentName string + + Count *int64 + Filter *string + Key *string + Offset *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStickTableEntriesURL) WithBasePath(bp string) *GetStickTableEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStickTableEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetStickTableEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/stick_tables/{parent_name}/entries" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetStickTableEntriesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var countQ string + if o.Count != nil { + countQ = swag.FormatInt64(*o.Count) + } + if countQ != "" { + qs.Set("count", countQ) + } + + var filterQ string + if o.Filter != nil { + filterQ = *o.Filter + } + if filterQ != "" { + qs.Set("filter", filterQ) + } + + var keyQ string + if o.Key != nil { + keyQ = *o.Key + } + if keyQ != "" { + qs.Set("key", keyQ) + } + + var offsetQ string + if o.Offset != nil { + offsetQ = swag.FormatInt64(*o.Offset) + } + if offsetQ != "" { + qs.Set("offset", offsetQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetStickTableEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetStickTableEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetStickTableEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetStickTableEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetStickTableEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetStickTableEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/stick_table/get_stick_table_parameters.go b/operations/stick_table/get_stick_table_parameters.go new file mode 100644 index 00000000..dc7b61e4 --- /dev/null +++ b/operations/stick_table/get_stick_table_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetStickTableParams creates a new GetStickTableParams object +// +// There are no default values defined in the spec. +func NewGetStickTableParams() GetStickTableParams { + + return GetStickTableParams{} +} + +// GetStickTableParams contains all the bound params for the get stick table operation +// typically these are obtained from a http.Request +// +// swagger:parameters getStickTable +type GetStickTableParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Stick table name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetStickTableParams() beforehand. +func (o *GetStickTableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetStickTableParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/stick_table/get_stick_table_responses.go b/operations/stick_table/get_stick_table_responses.go new file mode 100644 index 00000000..789c7db1 --- /dev/null +++ b/operations/stick_table/get_stick_table_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetStickTableOKCode is the HTTP code returned for type GetStickTableOK +const GetStickTableOKCode int = 200 + +/* +GetStickTableOK Successful operation + +swagger:response getStickTableOK +*/ +type GetStickTableOK struct { + + /* + In: Body + */ + Payload *models.StickTable `json:"body,omitempty"` +} + +// NewGetStickTableOK creates GetStickTableOK with default headers values +func NewGetStickTableOK() *GetStickTableOK { + + return &GetStickTableOK{} +} + +// WithPayload adds the payload to the get stick table o k response +func (o *GetStickTableOK) WithPayload(payload *models.StickTable) *GetStickTableOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get stick table o k response +func (o *GetStickTableOK) SetPayload(payload *models.StickTable) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStickTableOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetStickTableNotFoundCode is the HTTP code returned for type GetStickTableNotFound +const GetStickTableNotFoundCode int = 404 + +/* +GetStickTableNotFound The specified resource was not found + +swagger:response getStickTableNotFound +*/ +type GetStickTableNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetStickTableNotFound creates GetStickTableNotFound with default headers values +func NewGetStickTableNotFound() *GetStickTableNotFound { + + return &GetStickTableNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get stick table not found response +func (o *GetStickTableNotFound) WithConfigurationVersion(configurationVersion string) *GetStickTableNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get stick table not found response +func (o *GetStickTableNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get stick table not found response +func (o *GetStickTableNotFound) WithPayload(payload *models.Error) *GetStickTableNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get stick table not found response +func (o *GetStickTableNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStickTableNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetStickTableDefault General Error + +swagger:response getStickTableDefault +*/ +type GetStickTableDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetStickTableDefault creates GetStickTableDefault with default headers values +func NewGetStickTableDefault(code int) *GetStickTableDefault { + if code <= 0 { + code = 500 + } + + return &GetStickTableDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get stick table default response +func (o *GetStickTableDefault) WithStatusCode(code int) *GetStickTableDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get stick table default response +func (o *GetStickTableDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get stick table default response +func (o *GetStickTableDefault) WithConfigurationVersion(configurationVersion string) *GetStickTableDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get stick table default response +func (o *GetStickTableDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get stick table default response +func (o *GetStickTableDefault) WithPayload(payload *models.Error) *GetStickTableDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get stick table default response +func (o *GetStickTableDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStickTableDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/stick_table/get_stick_table_urlbuilder.go b/operations/stick_table/get_stick_table_urlbuilder.go new file mode 100644 index 00000000..7118ea1b --- /dev/null +++ b/operations/stick_table/get_stick_table_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetStickTableURL generates an URL for the get stick table operation +type GetStickTableURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStickTableURL) WithBasePath(bp string) *GetStickTableURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStickTableURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetStickTableURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/stick_tables/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetStickTableURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetStickTableURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetStickTableURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetStickTableURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetStickTableURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetStickTableURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetStickTableURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/stick_table/get_stick_tables.go b/operations/stick_table/get_stick_tables.go new file mode 100644 index 00000000..6b6507aa --- /dev/null +++ b/operations/stick_table/get_stick_tables.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetStickTablesHandlerFunc turns a function with the right signature into a get stick tables handler +type GetStickTablesHandlerFunc func(GetStickTablesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetStickTablesHandlerFunc) Handle(params GetStickTablesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetStickTablesHandler interface for that can handle valid get stick tables params +type GetStickTablesHandler interface { + Handle(GetStickTablesParams, interface{}) middleware.Responder +} + +// NewGetStickTables creates a new http.Handler for the get stick tables operation +func NewGetStickTables(ctx *middleware.Context, handler GetStickTablesHandler) *GetStickTables { + return &GetStickTables{Context: ctx, Handler: handler} +} + +/* + GetStickTables swagger:route GET /services/haproxy/runtime/stick_tables StickTable getStickTables + +# Return Stick Tables + +Returns an array of all stick tables. +*/ +type GetStickTables struct { + Context *middleware.Context + Handler GetStickTablesHandler +} + +func (o *GetStickTables) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetStickTablesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/stick_table/get_stick_tables_parameters.go b/operations/stick_table/get_stick_tables_parameters.go new file mode 100644 index 00000000..8f48c92a --- /dev/null +++ b/operations/stick_table/get_stick_tables_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetStickTablesParams creates a new GetStickTablesParams object +// +// There are no default values defined in the spec. +func NewGetStickTablesParams() GetStickTablesParams { + + return GetStickTablesParams{} +} + +// GetStickTablesParams contains all the bound params for the get stick tables operation +// typically these are obtained from a http.Request +// +// swagger:parameters getStickTables +type GetStickTablesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetStickTablesParams() beforehand. +func (o *GetStickTablesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/stick_table/get_stick_tables_responses.go b/operations/stick_table/get_stick_tables_responses.go new file mode 100644 index 00000000..19b87552 --- /dev/null +++ b/operations/stick_table/get_stick_tables_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetStickTablesOKCode is the HTTP code returned for type GetStickTablesOK +const GetStickTablesOKCode int = 200 + +/* +GetStickTablesOK Successful operation + +swagger:response getStickTablesOK +*/ +type GetStickTablesOK struct { + + /* + In: Body + */ + Payload models.StickTables `json:"body,omitempty"` +} + +// NewGetStickTablesOK creates GetStickTablesOK with default headers values +func NewGetStickTablesOK() *GetStickTablesOK { + + return &GetStickTablesOK{} +} + +// WithPayload adds the payload to the get stick tables o k response +func (o *GetStickTablesOK) WithPayload(payload models.StickTables) *GetStickTablesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get stick tables o k response +func (o *GetStickTablesOK) SetPayload(payload models.StickTables) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStickTablesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.StickTables{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetStickTablesDefault General Error + +swagger:response getStickTablesDefault +*/ +type GetStickTablesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetStickTablesDefault creates GetStickTablesDefault with default headers values +func NewGetStickTablesDefault(code int) *GetStickTablesDefault { + if code <= 0 { + code = 500 + } + + return &GetStickTablesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get stick tables default response +func (o *GetStickTablesDefault) WithStatusCode(code int) *GetStickTablesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get stick tables default response +func (o *GetStickTablesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get stick tables default response +func (o *GetStickTablesDefault) WithConfigurationVersion(configurationVersion string) *GetStickTablesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get stick tables default response +func (o *GetStickTablesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get stick tables default response +func (o *GetStickTablesDefault) WithPayload(payload *models.Error) *GetStickTablesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get stick tables default response +func (o *GetStickTablesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStickTablesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/stick_table/get_stick_tables_urlbuilder.go b/operations/stick_table/get_stick_tables_urlbuilder.go new file mode 100644 index 00000000..0e8b0d7e --- /dev/null +++ b/operations/stick_table/get_stick_tables_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetStickTablesURL generates an URL for the get stick tables operation +type GetStickTablesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStickTablesURL) WithBasePath(bp string) *GetStickTablesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStickTablesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetStickTablesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/stick_tables" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetStickTablesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetStickTablesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetStickTablesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetStickTablesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetStickTablesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetStickTablesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/stick_table/set_stick_table_entries.go b/operations/stick_table/set_stick_table_entries.go new file mode 100644 index 00000000..71d0a195 --- /dev/null +++ b/operations/stick_table/set_stick_table_entries.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "context" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// SetStickTableEntriesHandlerFunc turns a function with the right signature into a set stick table entries handler +type SetStickTableEntriesHandlerFunc func(SetStickTableEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn SetStickTableEntriesHandlerFunc) Handle(params SetStickTableEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// SetStickTableEntriesHandler interface for that can handle valid set stick table entries params +type SetStickTableEntriesHandler interface { + Handle(SetStickTableEntriesParams, interface{}) middleware.Responder +} + +// NewSetStickTableEntries creates a new http.Handler for the set stick table entries operation +func NewSetStickTableEntries(ctx *middleware.Context, handler SetStickTableEntriesHandler) *SetStickTableEntries { + return &SetStickTableEntries{Context: ctx, Handler: handler} +} + +/* + SetStickTableEntries swagger:route POST /services/haproxy/runtime/stick_tables/{parent_name}/entries StickTable setStickTableEntries + +# Set Entry to Stick Table + +Create or update a stick-table entry in the table. +*/ +type SetStickTableEntries struct { + Context *middleware.Context + Handler SetStickTableEntriesHandler +} + +func (o *SetStickTableEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewSetStickTableEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} + +// SetStickTableEntriesBody set stick table entries body +// +// swagger:model SetStickTableEntriesBody +type SetStickTableEntriesBody struct { + + // data type + // Required: true + DataType *models.StickTableEntry `json:"data_type"` + + // key + // Required: true + Key *string `json:"key"` +} + +// Validate validates this set stick table entries body +func (o *SetStickTableEntriesBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDataType(formats); err != nil { + res = append(res, err) + } + + if err := o.validateKey(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *SetStickTableEntriesBody) validateDataType(formats strfmt.Registry) error { + + if err := validate.Required("stick_table_entry"+"."+"data_type", "body", o.DataType); err != nil { + return err + } + + if o.DataType != nil { + if err := o.DataType.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("stick_table_entry" + "." + "data_type") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("stick_table_entry" + "." + "data_type") + } + return err + } + } + + return nil +} + +func (o *SetStickTableEntriesBody) validateKey(formats strfmt.Registry) error { + + if err := validate.Required("stick_table_entry"+"."+"key", "body", o.Key); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this set stick table entries body based on the context it is used +func (o *SetStickTableEntriesBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDataType(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *SetStickTableEntriesBody) contextValidateDataType(ctx context.Context, formats strfmt.Registry) error { + + if o.DataType != nil { + + if err := o.DataType.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("stick_table_entry" + "." + "data_type") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("stick_table_entry" + "." + "data_type") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *SetStickTableEntriesBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *SetStickTableEntriesBody) UnmarshalBinary(b []byte) error { + var res SetStickTableEntriesBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/operations/stick_table/set_stick_table_entries_parameters.go b/operations/stick_table/set_stick_table_entries_parameters.go new file mode 100644 index 00000000..f6067e32 --- /dev/null +++ b/operations/stick_table/set_stick_table_entries_parameters.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewSetStickTableEntriesParams creates a new SetStickTableEntriesParams object +// +// There are no default values defined in the spec. +func NewSetStickTableEntriesParams() SetStickTableEntriesParams { + + return SetStickTableEntriesParams{} +} + +// SetStickTableEntriesParams contains all the bound params for the set stick table entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters setStickTableEntries +type SetStickTableEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*Stick table entry + In: body + */ + StickTableEntry SetStickTableEntriesBody +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewSetStickTableEntriesParams() beforehand. +func (o *SetStickTableEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body SetStickTableEntriesBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("stickTableEntry", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.StickTableEntry = body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *SetStickTableEntriesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} diff --git a/operations/stick_table/set_stick_table_entries_responses.go b/operations/stick_table/set_stick_table_entries_responses.go new file mode 100644 index 00000000..8a16c9b7 --- /dev/null +++ b/operations/stick_table/set_stick_table_entries_responses.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// SetStickTableEntriesNoContentCode is the HTTP code returned for type SetStickTableEntriesNoContent +const SetStickTableEntriesNoContentCode int = 204 + +/* +SetStickTableEntriesNoContent Successful operation + +swagger:response setStickTableEntriesNoContent +*/ +type SetStickTableEntriesNoContent struct { +} + +// NewSetStickTableEntriesNoContent creates SetStickTableEntriesNoContent with default headers values +func NewSetStickTableEntriesNoContent() *SetStickTableEntriesNoContent { + + return &SetStickTableEntriesNoContent{} +} + +// WriteResponse to the client +func (o *SetStickTableEntriesNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +/* +SetStickTableEntriesDefault General Error + +swagger:response setStickTableEntriesDefault +*/ +type SetStickTableEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewSetStickTableEntriesDefault creates SetStickTableEntriesDefault with default headers values +func NewSetStickTableEntriesDefault(code int) *SetStickTableEntriesDefault { + if code <= 0 { + code = 500 + } + + return &SetStickTableEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the set stick table entries default response +func (o *SetStickTableEntriesDefault) WithStatusCode(code int) *SetStickTableEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the set stick table entries default response +func (o *SetStickTableEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the set stick table entries default response +func (o *SetStickTableEntriesDefault) WithConfigurationVersion(configurationVersion string) *SetStickTableEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the set stick table entries default response +func (o *SetStickTableEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the set stick table entries default response +func (o *SetStickTableEntriesDefault) WithPayload(payload *models.Error) *SetStickTableEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the set stick table entries default response +func (o *SetStickTableEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *SetStickTableEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/stick_table/set_stick_table_entries_urlbuilder.go b/operations/stick_table/set_stick_table_entries_urlbuilder.go new file mode 100644 index 00000000..e5add852 --- /dev/null +++ b/operations/stick_table/set_stick_table_entries_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package stick_table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// SetStickTableEntriesURL generates an URL for the set stick table entries operation +type SetStickTableEntriesURL struct { + ParentName string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetStickTableEntriesURL) WithBasePath(bp string) *SetStickTableEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *SetStickTableEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *SetStickTableEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/runtime/stick_tables/{parent_name}/entries" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on SetStickTableEntriesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *SetStickTableEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *SetStickTableEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *SetStickTableEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on SetStickTableEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on SetStickTableEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *SetStickTableEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/create_storage_general_file.go b/operations/storage/create_storage_general_file.go new file mode 100644 index 00000000..16c07bb9 --- /dev/null +++ b/operations/storage/create_storage_general_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateStorageGeneralFileHandlerFunc turns a function with the right signature into a create storage general file handler +type CreateStorageGeneralFileHandlerFunc func(CreateStorageGeneralFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateStorageGeneralFileHandlerFunc) Handle(params CreateStorageGeneralFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateStorageGeneralFileHandler interface for that can handle valid create storage general file params +type CreateStorageGeneralFileHandler interface { + Handle(CreateStorageGeneralFileParams, interface{}) middleware.Responder +} + +// NewCreateStorageGeneralFile creates a new http.Handler for the create storage general file operation +func NewCreateStorageGeneralFile(ctx *middleware.Context, handler CreateStorageGeneralFileHandler) *CreateStorageGeneralFile { + return &CreateStorageGeneralFile{Context: ctx, Handler: handler} +} + +/* + CreateStorageGeneralFile swagger:route POST /services/haproxy/storage/general Storage createStorageGeneralFile + +# Creates a managed storage general use file with contents + +Creates a managed storage general use file with contents. +*/ +type CreateStorageGeneralFile struct { + Context *middleware.Context + Handler CreateStorageGeneralFileHandler +} + +func (o *CreateStorageGeneralFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateStorageGeneralFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/create_storage_general_file_parameters.go b/operations/storage/create_storage_general_file_parameters.go new file mode 100644 index 00000000..6149e352 --- /dev/null +++ b/operations/storage/create_storage_general_file_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" +) + +// CreateStorageGeneralFileMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateStorageGeneralFileMaxParseMemory int64 = 32 << 20 + +// NewCreateStorageGeneralFileParams creates a new CreateStorageGeneralFileParams object +// +// There are no default values defined in the spec. +func NewCreateStorageGeneralFileParams() CreateStorageGeneralFileParams { + + return CreateStorageGeneralFileParams{} +} + +// CreateStorageGeneralFileParams contains all the bound params for the create storage general file operation +// typically these are obtained from a http.Request +// +// swagger:parameters createStorageGeneralFile +type CreateStorageGeneralFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*General use file content + In: formData + */ + FileUpload io.ReadCloser +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateStorageGeneralFileParams() beforehand. +func (o *CreateStorageGeneralFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(CreateStorageGeneralFileMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil && err != http.ErrMissingFile { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err == http.ErrMissingFile { + // no-op for missing but optional file parameter + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateStorageGeneralFileParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} diff --git a/operations/storage/create_storage_general_file_responses.go b/operations/storage/create_storage_general_file_responses.go new file mode 100644 index 00000000..df2bef87 --- /dev/null +++ b/operations/storage/create_storage_general_file_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateStorageGeneralFileCreatedCode is the HTTP code returned for type CreateStorageGeneralFileCreated +const CreateStorageGeneralFileCreatedCode int = 201 + +/* +CreateStorageGeneralFileCreated General use file created with its contents + +swagger:response createStorageGeneralFileCreated +*/ +type CreateStorageGeneralFileCreated struct { + + /* + In: Body + */ + Payload *models.GeneralFile `json:"body,omitempty"` +} + +// NewCreateStorageGeneralFileCreated creates CreateStorageGeneralFileCreated with default headers values +func NewCreateStorageGeneralFileCreated() *CreateStorageGeneralFileCreated { + + return &CreateStorageGeneralFileCreated{} +} + +// WithPayload adds the payload to the create storage general file created response +func (o *CreateStorageGeneralFileCreated) WithPayload(payload *models.GeneralFile) *CreateStorageGeneralFileCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage general file created response +func (o *CreateStorageGeneralFileCreated) SetPayload(payload *models.GeneralFile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageGeneralFileCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageGeneralFileBadRequestCode is the HTTP code returned for type CreateStorageGeneralFileBadRequest +const CreateStorageGeneralFileBadRequestCode int = 400 + +/* +CreateStorageGeneralFileBadRequest Bad request + +swagger:response createStorageGeneralFileBadRequest +*/ +type CreateStorageGeneralFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageGeneralFileBadRequest creates CreateStorageGeneralFileBadRequest with default headers values +func NewCreateStorageGeneralFileBadRequest() *CreateStorageGeneralFileBadRequest { + + return &CreateStorageGeneralFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage general file bad request response +func (o *CreateStorageGeneralFileBadRequest) WithConfigurationVersion(configurationVersion string) *CreateStorageGeneralFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage general file bad request response +func (o *CreateStorageGeneralFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage general file bad request response +func (o *CreateStorageGeneralFileBadRequest) WithPayload(payload *models.Error) *CreateStorageGeneralFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage general file bad request response +func (o *CreateStorageGeneralFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageGeneralFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageGeneralFileConflictCode is the HTTP code returned for type CreateStorageGeneralFileConflict +const CreateStorageGeneralFileConflictCode int = 409 + +/* +CreateStorageGeneralFileConflict The specified resource already exists + +swagger:response createStorageGeneralFileConflict +*/ +type CreateStorageGeneralFileConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageGeneralFileConflict creates CreateStorageGeneralFileConflict with default headers values +func NewCreateStorageGeneralFileConflict() *CreateStorageGeneralFileConflict { + + return &CreateStorageGeneralFileConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage general file conflict response +func (o *CreateStorageGeneralFileConflict) WithConfigurationVersion(configurationVersion string) *CreateStorageGeneralFileConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage general file conflict response +func (o *CreateStorageGeneralFileConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage general file conflict response +func (o *CreateStorageGeneralFileConflict) WithPayload(payload *models.Error) *CreateStorageGeneralFileConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage general file conflict response +func (o *CreateStorageGeneralFileConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageGeneralFileConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateStorageGeneralFileDefault General Error + +swagger:response createStorageGeneralFileDefault +*/ +type CreateStorageGeneralFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageGeneralFileDefault creates CreateStorageGeneralFileDefault with default headers values +func NewCreateStorageGeneralFileDefault(code int) *CreateStorageGeneralFileDefault { + if code <= 0 { + code = 500 + } + + return &CreateStorageGeneralFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create storage general file default response +func (o *CreateStorageGeneralFileDefault) WithStatusCode(code int) *CreateStorageGeneralFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create storage general file default response +func (o *CreateStorageGeneralFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create storage general file default response +func (o *CreateStorageGeneralFileDefault) WithConfigurationVersion(configurationVersion string) *CreateStorageGeneralFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage general file default response +func (o *CreateStorageGeneralFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage general file default response +func (o *CreateStorageGeneralFileDefault) WithPayload(payload *models.Error) *CreateStorageGeneralFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage general file default response +func (o *CreateStorageGeneralFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageGeneralFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/create_storage_general_file_urlbuilder.go b/operations/storage/create_storage_general_file_urlbuilder.go new file mode 100644 index 00000000..5f4bbf0c --- /dev/null +++ b/operations/storage/create_storage_general_file_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateStorageGeneralFileURL generates an URL for the create storage general file operation +type CreateStorageGeneralFileURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageGeneralFileURL) WithBasePath(bp string) *CreateStorageGeneralFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageGeneralFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateStorageGeneralFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/general" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateStorageGeneralFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateStorageGeneralFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateStorageGeneralFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateStorageGeneralFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateStorageGeneralFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateStorageGeneralFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/create_storage_map_file.go b/operations/storage/create_storage_map_file.go new file mode 100644 index 00000000..07efb0de --- /dev/null +++ b/operations/storage/create_storage_map_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateStorageMapFileHandlerFunc turns a function with the right signature into a create storage map file handler +type CreateStorageMapFileHandlerFunc func(CreateStorageMapFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateStorageMapFileHandlerFunc) Handle(params CreateStorageMapFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateStorageMapFileHandler interface for that can handle valid create storage map file params +type CreateStorageMapFileHandler interface { + Handle(CreateStorageMapFileParams, interface{}) middleware.Responder +} + +// NewCreateStorageMapFile creates a new http.Handler for the create storage map file operation +func NewCreateStorageMapFile(ctx *middleware.Context, handler CreateStorageMapFileHandler) *CreateStorageMapFile { + return &CreateStorageMapFile{Context: ctx, Handler: handler} +} + +/* + CreateStorageMapFile swagger:route POST /services/haproxy/storage/maps Storage createStorageMapFile + +# Creates a managed storage map file with its entries + +Creates a managed storage map file with its entries. +*/ +type CreateStorageMapFile struct { + Context *middleware.Context + Handler CreateStorageMapFileHandler +} + +func (o *CreateStorageMapFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateStorageMapFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/create_storage_map_file_parameters.go b/operations/storage/create_storage_map_file_parameters.go new file mode 100644 index 00000000..a58a38b4 --- /dev/null +++ b/operations/storage/create_storage_map_file_parameters.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" +) + +// CreateStorageMapFileMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateStorageMapFileMaxParseMemory int64 = 32 << 20 + +// NewCreateStorageMapFileParams creates a new CreateStorageMapFileParams object +// +// There are no default values defined in the spec. +func NewCreateStorageMapFileParams() CreateStorageMapFileParams { + + return CreateStorageMapFileParams{} +} + +// CreateStorageMapFileParams contains all the bound params for the create storage map file operation +// typically these are obtained from a http.Request +// +// swagger:parameters createStorageMapFile +type CreateStorageMapFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The map file contents + In: formData + */ + FileUpload io.ReadCloser +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateStorageMapFileParams() beforehand. +func (o *CreateStorageMapFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if err := r.ParseMultipartForm(CreateStorageMapFileMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil && err != http.ErrMissingFile { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err == http.ErrMissingFile { + // no-op for missing but optional file parameter + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateStorageMapFileParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} diff --git a/operations/storage/create_storage_map_file_responses.go b/operations/storage/create_storage_map_file_responses.go new file mode 100644 index 00000000..03971ad5 --- /dev/null +++ b/operations/storage/create_storage_map_file_responses.go @@ -0,0 +1,289 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateStorageMapFileCreatedCode is the HTTP code returned for type CreateStorageMapFileCreated +const CreateStorageMapFileCreatedCode int = 201 + +/* +CreateStorageMapFileCreated Map file created with its entries + +swagger:response createStorageMapFileCreated +*/ +type CreateStorageMapFileCreated struct { + + /* + In: Body + */ + Payload *models.Map `json:"body,omitempty"` +} + +// NewCreateStorageMapFileCreated creates CreateStorageMapFileCreated with default headers values +func NewCreateStorageMapFileCreated() *CreateStorageMapFileCreated { + + return &CreateStorageMapFileCreated{} +} + +// WithPayload adds the payload to the create storage map file created response +func (o *CreateStorageMapFileCreated) WithPayload(payload *models.Map) *CreateStorageMapFileCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage map file created response +func (o *CreateStorageMapFileCreated) SetPayload(payload *models.Map) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageMapFileCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageMapFileBadRequestCode is the HTTP code returned for type CreateStorageMapFileBadRequest +const CreateStorageMapFileBadRequestCode int = 400 + +/* +CreateStorageMapFileBadRequest Bad request + +swagger:response createStorageMapFileBadRequest +*/ +type CreateStorageMapFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageMapFileBadRequest creates CreateStorageMapFileBadRequest with default headers values +func NewCreateStorageMapFileBadRequest() *CreateStorageMapFileBadRequest { + + return &CreateStorageMapFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage map file bad request response +func (o *CreateStorageMapFileBadRequest) WithConfigurationVersion(configurationVersion string) *CreateStorageMapFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage map file bad request response +func (o *CreateStorageMapFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage map file bad request response +func (o *CreateStorageMapFileBadRequest) WithPayload(payload *models.Error) *CreateStorageMapFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage map file bad request response +func (o *CreateStorageMapFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageMapFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageMapFileConflictCode is the HTTP code returned for type CreateStorageMapFileConflict +const CreateStorageMapFileConflictCode int = 409 + +/* +CreateStorageMapFileConflict The specified resource already exists + +swagger:response createStorageMapFileConflict +*/ +type CreateStorageMapFileConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageMapFileConflict creates CreateStorageMapFileConflict with default headers values +func NewCreateStorageMapFileConflict() *CreateStorageMapFileConflict { + + return &CreateStorageMapFileConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage map file conflict response +func (o *CreateStorageMapFileConflict) WithConfigurationVersion(configurationVersion string) *CreateStorageMapFileConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage map file conflict response +func (o *CreateStorageMapFileConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage map file conflict response +func (o *CreateStorageMapFileConflict) WithPayload(payload *models.Error) *CreateStorageMapFileConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage map file conflict response +func (o *CreateStorageMapFileConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageMapFileConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateStorageMapFileDefault General Error + +swagger:response createStorageMapFileDefault +*/ +type CreateStorageMapFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageMapFileDefault creates CreateStorageMapFileDefault with default headers values +func NewCreateStorageMapFileDefault(code int) *CreateStorageMapFileDefault { + if code <= 0 { + code = 500 + } + + return &CreateStorageMapFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create storage map file default response +func (o *CreateStorageMapFileDefault) WithStatusCode(code int) *CreateStorageMapFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create storage map file default response +func (o *CreateStorageMapFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create storage map file default response +func (o *CreateStorageMapFileDefault) WithConfigurationVersion(configurationVersion string) *CreateStorageMapFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage map file default response +func (o *CreateStorageMapFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage map file default response +func (o *CreateStorageMapFileDefault) WithPayload(payload *models.Error) *CreateStorageMapFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage map file default response +func (o *CreateStorageMapFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageMapFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/create_storage_map_file_urlbuilder.go b/operations/storage/create_storage_map_file_urlbuilder.go new file mode 100644 index 00000000..0792a5fc --- /dev/null +++ b/operations/storage/create_storage_map_file_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// CreateStorageMapFileURL generates an URL for the create storage map file operation +type CreateStorageMapFileURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageMapFileURL) WithBasePath(bp string) *CreateStorageMapFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageMapFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateStorageMapFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/maps" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateStorageMapFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateStorageMapFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateStorageMapFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateStorageMapFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateStorageMapFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateStorageMapFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/create_storage_s_s_l_certificate.go b/operations/storage/create_storage_s_s_l_certificate.go new file mode 100644 index 00000000..d414feff --- /dev/null +++ b/operations/storage/create_storage_s_s_l_certificate.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateStorageSSLCertificateHandlerFunc turns a function with the right signature into a create storage s s l certificate handler +type CreateStorageSSLCertificateHandlerFunc func(CreateStorageSSLCertificateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateStorageSSLCertificateHandlerFunc) Handle(params CreateStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateStorageSSLCertificateHandler interface for that can handle valid create storage s s l certificate params +type CreateStorageSSLCertificateHandler interface { + Handle(CreateStorageSSLCertificateParams, interface{}) middleware.Responder +} + +// NewCreateStorageSSLCertificate creates a new http.Handler for the create storage s s l certificate operation +func NewCreateStorageSSLCertificate(ctx *middleware.Context, handler CreateStorageSSLCertificateHandler) *CreateStorageSSLCertificate { + return &CreateStorageSSLCertificate{Context: ctx, Handler: handler} +} + +/* + CreateStorageSSLCertificate swagger:route POST /services/haproxy/storage/ssl_certificates Storage createStorageSSLCertificate + +# Create SSL certificate + +Creates SSL certificate. +*/ +type CreateStorageSSLCertificate struct { + Context *middleware.Context + Handler CreateStorageSSLCertificateHandler +} + +func (o *CreateStorageSSLCertificate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateStorageSSLCertificateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/create_storage_s_s_l_certificate_parameters.go b/operations/storage/create_storage_s_s_l_certificate_parameters.go new file mode 100644 index 00000000..b552602d --- /dev/null +++ b/operations/storage/create_storage_s_s_l_certificate_parameters.go @@ -0,0 +1,183 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CreateStorageSSLCertificateMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateStorageSSLCertificateMaxParseMemory int64 = 32 << 20 + +// NewCreateStorageSSLCertificateParams creates a new CreateStorageSSLCertificateParams object +// with the default values initialized. +func NewCreateStorageSSLCertificateParams() CreateStorageSSLCertificateParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + skipReloadDefault = bool(false) + ) + + return CreateStorageSSLCertificateParams{ + ForceReload: &forceReloadDefault, + + SkipReload: &skipReloadDefault, + } +} + +// CreateStorageSSLCertificateParams contains all the bound params for the create storage s s l certificate operation +// typically these are obtained from a http.Request +// +// swagger:parameters createStorageSSLCertificate +type CreateStorageSSLCertificateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The SSL certificate to upload + In: formData + */ + FileUpload io.ReadCloser + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*If set, no reload will be initiated after update + In: query + Default: false + */ + SkipReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateStorageSSLCertificateParams() beforehand. +func (o *CreateStorageSSLCertificateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := r.ParseMultipartForm(CreateStorageSSLCertificateMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil && err != http.ErrMissingFile { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err == http.ErrMissingFile { + // no-op for missing but optional file parameter + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateStorageSSLCertificateParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateStorageSSLCertificateParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateStorageSSLCertificateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *CreateStorageSSLCertificateParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateStorageSSLCertificateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} diff --git a/operations/storage/create_storage_s_s_l_certificate_responses.go b/operations/storage/create_storage_s_s_l_certificate_responses.go new file mode 100644 index 00000000..b4417c05 --- /dev/null +++ b/operations/storage/create_storage_s_s_l_certificate_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateStorageSSLCertificateCreatedCode is the HTTP code returned for type CreateStorageSSLCertificateCreated +const CreateStorageSSLCertificateCreatedCode int = 201 + +/* +CreateStorageSSLCertificateCreated SSL certificate created + +swagger:response createStorageSSLCertificateCreated +*/ +type CreateStorageSSLCertificateCreated struct { + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewCreateStorageSSLCertificateCreated creates CreateStorageSSLCertificateCreated with default headers values +func NewCreateStorageSSLCertificateCreated() *CreateStorageSSLCertificateCreated { + + return &CreateStorageSSLCertificateCreated{} +} + +// WithPayload adds the payload to the create storage s s l certificate created response +func (o *CreateStorageSSLCertificateCreated) WithPayload(payload *models.SslCertificate) *CreateStorageSSLCertificateCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l certificate created response +func (o *CreateStorageSSLCertificateCreated) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCertificateCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCertificateAcceptedCode is the HTTP code returned for type CreateStorageSSLCertificateAccepted +const CreateStorageSSLCertificateAcceptedCode int = 202 + +/* +CreateStorageSSLCertificateAccepted SSL certificate created requested + +swagger:response createStorageSSLCertificateAccepted +*/ +type CreateStorageSSLCertificateAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewCreateStorageSSLCertificateAccepted creates CreateStorageSSLCertificateAccepted with default headers values +func NewCreateStorageSSLCertificateAccepted() *CreateStorageSSLCertificateAccepted { + + return &CreateStorageSSLCertificateAccepted{} +} + +// WithReloadID adds the reloadId to the create storage s s l certificate accepted response +func (o *CreateStorageSSLCertificateAccepted) WithReloadID(reloadID string) *CreateStorageSSLCertificateAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create storage s s l certificate accepted response +func (o *CreateStorageSSLCertificateAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create storage s s l certificate accepted response +func (o *CreateStorageSSLCertificateAccepted) WithPayload(payload *models.SslCertificate) *CreateStorageSSLCertificateAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l certificate accepted response +func (o *CreateStorageSSLCertificateAccepted) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCertificateAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCertificateBadRequestCode is the HTTP code returned for type CreateStorageSSLCertificateBadRequest +const CreateStorageSSLCertificateBadRequestCode int = 400 + +/* +CreateStorageSSLCertificateBadRequest Bad request + +swagger:response createStorageSSLCertificateBadRequest +*/ +type CreateStorageSSLCertificateBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCertificateBadRequest creates CreateStorageSSLCertificateBadRequest with default headers values +func NewCreateStorageSSLCertificateBadRequest() *CreateStorageSSLCertificateBadRequest { + + return &CreateStorageSSLCertificateBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l certificate bad request response +func (o *CreateStorageSSLCertificateBadRequest) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCertificateBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l certificate bad request response +func (o *CreateStorageSSLCertificateBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l certificate bad request response +func (o *CreateStorageSSLCertificateBadRequest) WithPayload(payload *models.Error) *CreateStorageSSLCertificateBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l certificate bad request response +func (o *CreateStorageSSLCertificateBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCertificateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCertificateConflictCode is the HTTP code returned for type CreateStorageSSLCertificateConflict +const CreateStorageSSLCertificateConflictCode int = 409 + +/* +CreateStorageSSLCertificateConflict The specified resource already exists + +swagger:response createStorageSSLCertificateConflict +*/ +type CreateStorageSSLCertificateConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCertificateConflict creates CreateStorageSSLCertificateConflict with default headers values +func NewCreateStorageSSLCertificateConflict() *CreateStorageSSLCertificateConflict { + + return &CreateStorageSSLCertificateConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l certificate conflict response +func (o *CreateStorageSSLCertificateConflict) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCertificateConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l certificate conflict response +func (o *CreateStorageSSLCertificateConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l certificate conflict response +func (o *CreateStorageSSLCertificateConflict) WithPayload(payload *models.Error) *CreateStorageSSLCertificateConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l certificate conflict response +func (o *CreateStorageSSLCertificateConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCertificateConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateStorageSSLCertificateDefault General Error + +swagger:response createStorageSSLCertificateDefault +*/ +type CreateStorageSSLCertificateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCertificateDefault creates CreateStorageSSLCertificateDefault with default headers values +func NewCreateStorageSSLCertificateDefault(code int) *CreateStorageSSLCertificateDefault { + if code <= 0 { + code = 500 + } + + return &CreateStorageSSLCertificateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create storage s s l certificate default response +func (o *CreateStorageSSLCertificateDefault) WithStatusCode(code int) *CreateStorageSSLCertificateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create storage s s l certificate default response +func (o *CreateStorageSSLCertificateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l certificate default response +func (o *CreateStorageSSLCertificateDefault) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCertificateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l certificate default response +func (o *CreateStorageSSLCertificateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l certificate default response +func (o *CreateStorageSSLCertificateDefault) WithPayload(payload *models.Error) *CreateStorageSSLCertificateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l certificate default response +func (o *CreateStorageSSLCertificateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCertificateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/create_storage_s_s_l_certificate_urlbuilder.go b/operations/storage/create_storage_s_s_l_certificate_urlbuilder.go new file mode 100644 index 00000000..63a14ad2 --- /dev/null +++ b/operations/storage/create_storage_s_s_l_certificate_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateStorageSSLCertificateURL generates an URL for the create storage s s l certificate operation +type CreateStorageSSLCertificateURL struct { + ForceReload *bool + SkipReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageSSLCertificateURL) WithBasePath(bp string) *CreateStorageSSLCertificateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageSSLCertificateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateStorageSSLCertificateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_certificates" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateStorageSSLCertificateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateStorageSSLCertificateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateStorageSSLCertificateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateStorageSSLCertificateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateStorageSSLCertificateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateStorageSSLCertificateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_entry.go b/operations/storage/create_storage_s_s_l_crt_list_entry.go new file mode 100644 index 00000000..13790d08 --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateStorageSSLCrtListEntryHandlerFunc turns a function with the right signature into a create storage s s l crt list entry handler +type CreateStorageSSLCrtListEntryHandlerFunc func(CreateStorageSSLCrtListEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateStorageSSLCrtListEntryHandlerFunc) Handle(params CreateStorageSSLCrtListEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateStorageSSLCrtListEntryHandler interface for that can handle valid create storage s s l crt list entry params +type CreateStorageSSLCrtListEntryHandler interface { + Handle(CreateStorageSSLCrtListEntryParams, interface{}) middleware.Responder +} + +// NewCreateStorageSSLCrtListEntry creates a new http.Handler for the create storage s s l crt list entry operation +func NewCreateStorageSSLCrtListEntry(ctx *middleware.Context, handler CreateStorageSSLCrtListEntryHandler) *CreateStorageSSLCrtListEntry { + return &CreateStorageSSLCrtListEntry{Context: ctx, Handler: handler} +} + +/* + CreateStorageSSLCrtListEntry swagger:route POST /services/haproxy/storage/ssl_crt_lists/{name}/entries Storage createStorageSSLCrtListEntry + +# Creates a new entry in a CrtList + +Creates a new entry in a certificate list. +*/ +type CreateStorageSSLCrtListEntry struct { + Context *middleware.Context + Handler CreateStorageSSLCrtListEntryHandler +} + +func (o *CreateStorageSSLCrtListEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateStorageSSLCrtListEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_entry_parameters.go b/operations/storage/create_storage_s_s_l_crt_list_entry_parameters.go new file mode 100644 index 00000000..c02e10de --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_entry_parameters.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateStorageSSLCrtListEntryParams creates a new CreateStorageSSLCrtListEntryParams object +// with the default values initialized. +func NewCreateStorageSSLCrtListEntryParams() CreateStorageSSLCrtListEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateStorageSSLCrtListEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateStorageSSLCrtListEntryParams contains all the bound params for the create storage s s l crt list entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters CreateStorageSSLCrtListEntry +type CreateStorageSSLCrtListEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL crt-list entry + Required: true + In: body + */ + Data *models.SslCrtListEntry + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*SSL crt-list file + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateStorageSSLCrtListEntryParams() beforehand. +func (o *CreateStorageSSLCrtListEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SslCrtListEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateStorageSSLCrtListEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateStorageSSLCrtListEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *CreateStorageSSLCrtListEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_entry_responses.go b/operations/storage/create_storage_s_s_l_crt_list_entry_responses.go new file mode 100644 index 00000000..80b613e9 --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_entry_responses.go @@ -0,0 +1,336 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateStorageSSLCrtListEntryCreatedCode is the HTTP code returned for type CreateStorageSSLCrtListEntryCreated +const CreateStorageSSLCrtListEntryCreatedCode int = 201 + +/* +CreateStorageSSLCrtListEntryCreated New entry added + +swagger:response createStorageSSLCrtListEntryCreated +*/ +type CreateStorageSSLCrtListEntryCreated struct { + + /* + In: Body + */ + Payload *models.SslCrtListEntry `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListEntryCreated creates CreateStorageSSLCrtListEntryCreated with default headers values +func NewCreateStorageSSLCrtListEntryCreated() *CreateStorageSSLCrtListEntryCreated { + + return &CreateStorageSSLCrtListEntryCreated{} +} + +// WithPayload adds the payload to the create storage s s l crt list entry created response +func (o *CreateStorageSSLCrtListEntryCreated) WithPayload(payload *models.SslCrtListEntry) *CreateStorageSSLCrtListEntryCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list entry created response +func (o *CreateStorageSSLCrtListEntryCreated) SetPayload(payload *models.SslCrtListEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCrtListEntryAcceptedCode is the HTTP code returned for type CreateStorageSSLCrtListEntryAccepted +const CreateStorageSSLCrtListEntryAcceptedCode int = 202 + +/* +CreateStorageSSLCrtListEntryAccepted Configuration change accepted and reload requested + +swagger:response createStorageSSLCrtListEntryAccepted +*/ +type CreateStorageSSLCrtListEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewCreateStorageSSLCrtListEntryAccepted creates CreateStorageSSLCrtListEntryAccepted with default headers values +func NewCreateStorageSSLCrtListEntryAccepted() *CreateStorageSSLCrtListEntryAccepted { + + return &CreateStorageSSLCrtListEntryAccepted{} +} + +// WithReloadID adds the reloadId to the create storage s s l crt list entry accepted response +func (o *CreateStorageSSLCrtListEntryAccepted) WithReloadID(reloadID string) *CreateStorageSSLCrtListEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create storage s s l crt list entry accepted response +func (o *CreateStorageSSLCrtListEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// CreateStorageSSLCrtListEntryBadRequestCode is the HTTP code returned for type CreateStorageSSLCrtListEntryBadRequest +const CreateStorageSSLCrtListEntryBadRequestCode int = 400 + +/* +CreateStorageSSLCrtListEntryBadRequest Bad request + +swagger:response createStorageSSLCrtListEntryBadRequest +*/ +type CreateStorageSSLCrtListEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListEntryBadRequest creates CreateStorageSSLCrtListEntryBadRequest with default headers values +func NewCreateStorageSSLCrtListEntryBadRequest() *CreateStorageSSLCrtListEntryBadRequest { + + return &CreateStorageSSLCrtListEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l crt list entry bad request response +func (o *CreateStorageSSLCrtListEntryBadRequest) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCrtListEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l crt list entry bad request response +func (o *CreateStorageSSLCrtListEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l crt list entry bad request response +func (o *CreateStorageSSLCrtListEntryBadRequest) WithPayload(payload *models.Error) *CreateStorageSSLCrtListEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list entry bad request response +func (o *CreateStorageSSLCrtListEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCrtListEntryConflictCode is the HTTP code returned for type CreateStorageSSLCrtListEntryConflict +const CreateStorageSSLCrtListEntryConflictCode int = 409 + +/* +CreateStorageSSLCrtListEntryConflict The specified resource already exists + +swagger:response createStorageSSLCrtListEntryConflict +*/ +type CreateStorageSSLCrtListEntryConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListEntryConflict creates CreateStorageSSLCrtListEntryConflict with default headers values +func NewCreateStorageSSLCrtListEntryConflict() *CreateStorageSSLCrtListEntryConflict { + + return &CreateStorageSSLCrtListEntryConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l crt list entry conflict response +func (o *CreateStorageSSLCrtListEntryConflict) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCrtListEntryConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l crt list entry conflict response +func (o *CreateStorageSSLCrtListEntryConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l crt list entry conflict response +func (o *CreateStorageSSLCrtListEntryConflict) WithPayload(payload *models.Error) *CreateStorageSSLCrtListEntryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list entry conflict response +func (o *CreateStorageSSLCrtListEntryConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListEntryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateStorageSSLCrtListEntryDefault General Error + +swagger:response createStorageSSLCrtListEntryDefault +*/ +type CreateStorageSSLCrtListEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListEntryDefault creates CreateStorageSSLCrtListEntryDefault with default headers values +func NewCreateStorageSSLCrtListEntryDefault(code int) *CreateStorageSSLCrtListEntryDefault { + if code <= 0 { + code = 500 + } + + return &CreateStorageSSLCrtListEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create storage s s l crt list entry default response +func (o *CreateStorageSSLCrtListEntryDefault) WithStatusCode(code int) *CreateStorageSSLCrtListEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create storage s s l crt list entry default response +func (o *CreateStorageSSLCrtListEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l crt list entry default response +func (o *CreateStorageSSLCrtListEntryDefault) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCrtListEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l crt list entry default response +func (o *CreateStorageSSLCrtListEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l crt list entry default response +func (o *CreateStorageSSLCrtListEntryDefault) WithPayload(payload *models.Error) *CreateStorageSSLCrtListEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list entry default response +func (o *CreateStorageSSLCrtListEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_entry_urlbuilder.go b/operations/storage/create_storage_s_s_l_crt_list_entry_urlbuilder.go new file mode 100644 index 00000000..ffb27b7a --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_entry_urlbuilder.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateStorageSSLCrtListEntryURL generates an URL for the create storage s s l crt list entry operation +type CreateStorageSSLCrtListEntryURL struct { + Name string + + ForceReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageSSLCrtListEntryURL) WithBasePath(bp string) *CreateStorageSSLCrtListEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageSSLCrtListEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateStorageSSLCrtListEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists/{name}/entries" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on CreateStorageSSLCrtListEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateStorageSSLCrtListEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateStorageSSLCrtListEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateStorageSSLCrtListEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateStorageSSLCrtListEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateStorageSSLCrtListEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateStorageSSLCrtListEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_file.go b/operations/storage/create_storage_s_s_l_crt_list_file.go new file mode 100644 index 00000000..ccf0808b --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateStorageSSLCrtListFileHandlerFunc turns a function with the right signature into a create storage s s l crt list file handler +type CreateStorageSSLCrtListFileHandlerFunc func(CreateStorageSSLCrtListFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateStorageSSLCrtListFileHandlerFunc) Handle(params CreateStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateStorageSSLCrtListFileHandler interface for that can handle valid create storage s s l crt list file params +type CreateStorageSSLCrtListFileHandler interface { + Handle(CreateStorageSSLCrtListFileParams, interface{}) middleware.Responder +} + +// NewCreateStorageSSLCrtListFile creates a new http.Handler for the create storage s s l crt list file operation +func NewCreateStorageSSLCrtListFile(ctx *middleware.Context, handler CreateStorageSSLCrtListFileHandler) *CreateStorageSSLCrtListFile { + return &CreateStorageSSLCrtListFile{Context: ctx, Handler: handler} +} + +/* + CreateStorageSSLCrtListFile swagger:route POST /services/haproxy/storage/ssl_crt_lists Storage createStorageSSLCrtListFile + +# Create a certificate list + +Creates a certificate list. +*/ +type CreateStorageSSLCrtListFile struct { + Context *middleware.Context + Handler CreateStorageSSLCrtListFileHandler +} + +func (o *CreateStorageSSLCrtListFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateStorageSSLCrtListFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_file_parameters.go b/operations/storage/create_storage_s_s_l_crt_list_file_parameters.go new file mode 100644 index 00000000..782f4468 --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_file_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CreateStorageSSLCrtListFileMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var CreateStorageSSLCrtListFileMaxParseMemory int64 = 32 << 20 + +// NewCreateStorageSSLCrtListFileParams creates a new CreateStorageSSLCrtListFileParams object +// with the default values initialized. +func NewCreateStorageSSLCrtListFileParams() CreateStorageSSLCrtListFileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateStorageSSLCrtListFileParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateStorageSSLCrtListFileParams contains all the bound params for the create storage s s l crt list file operation +// typically these are obtained from a http.Request +// +// swagger:parameters createStorageSSLCrtListFile +type CreateStorageSSLCrtListFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*The certificate list to upload + In: formData + */ + FileUpload io.ReadCloser + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateStorageSSLCrtListFileParams() beforehand. +func (o *CreateStorageSSLCrtListFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := r.ParseMultipartForm(CreateStorageSSLCrtListFileMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil && err != http.ErrMissingFile { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err == http.ErrMissingFile { + // no-op for missing but optional file parameter + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *CreateStorageSSLCrtListFileParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateStorageSSLCrtListFileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateStorageSSLCrtListFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_file_responses.go b/operations/storage/create_storage_s_s_l_crt_list_file_responses.go new file mode 100644 index 00000000..e0e5ce4e --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_file_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateStorageSSLCrtListFileCreatedCode is the HTTP code returned for type CreateStorageSSLCrtListFileCreated +const CreateStorageSSLCrtListFileCreatedCode int = 201 + +/* +CreateStorageSSLCrtListFileCreated Certificate list created + +swagger:response createStorageSSLCrtListFileCreated +*/ +type CreateStorageSSLCrtListFileCreated struct { + + /* + In: Body + */ + Payload *models.SslCrtListFile `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListFileCreated creates CreateStorageSSLCrtListFileCreated with default headers values +func NewCreateStorageSSLCrtListFileCreated() *CreateStorageSSLCrtListFileCreated { + + return &CreateStorageSSLCrtListFileCreated{} +} + +// WithPayload adds the payload to the create storage s s l crt list file created response +func (o *CreateStorageSSLCrtListFileCreated) WithPayload(payload *models.SslCrtListFile) *CreateStorageSSLCrtListFileCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list file created response +func (o *CreateStorageSSLCrtListFileCreated) SetPayload(payload *models.SslCrtListFile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListFileCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCrtListFileAcceptedCode is the HTTP code returned for type CreateStorageSSLCrtListFileAccepted +const CreateStorageSSLCrtListFileAcceptedCode int = 202 + +/* +CreateStorageSSLCrtListFileAccepted Certificate list created requested + +swagger:response createStorageSSLCrtListFileAccepted +*/ +type CreateStorageSSLCrtListFileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.SslCrtListFile `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListFileAccepted creates CreateStorageSSLCrtListFileAccepted with default headers values +func NewCreateStorageSSLCrtListFileAccepted() *CreateStorageSSLCrtListFileAccepted { + + return &CreateStorageSSLCrtListFileAccepted{} +} + +// WithReloadID adds the reloadId to the create storage s s l crt list file accepted response +func (o *CreateStorageSSLCrtListFileAccepted) WithReloadID(reloadID string) *CreateStorageSSLCrtListFileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create storage s s l crt list file accepted response +func (o *CreateStorageSSLCrtListFileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create storage s s l crt list file accepted response +func (o *CreateStorageSSLCrtListFileAccepted) WithPayload(payload *models.SslCrtListFile) *CreateStorageSSLCrtListFileAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list file accepted response +func (o *CreateStorageSSLCrtListFileAccepted) SetPayload(payload *models.SslCrtListFile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListFileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCrtListFileBadRequestCode is the HTTP code returned for type CreateStorageSSLCrtListFileBadRequest +const CreateStorageSSLCrtListFileBadRequestCode int = 400 + +/* +CreateStorageSSLCrtListFileBadRequest Bad request + +swagger:response createStorageSSLCrtListFileBadRequest +*/ +type CreateStorageSSLCrtListFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListFileBadRequest creates CreateStorageSSLCrtListFileBadRequest with default headers values +func NewCreateStorageSSLCrtListFileBadRequest() *CreateStorageSSLCrtListFileBadRequest { + + return &CreateStorageSSLCrtListFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l crt list file bad request response +func (o *CreateStorageSSLCrtListFileBadRequest) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCrtListFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l crt list file bad request response +func (o *CreateStorageSSLCrtListFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l crt list file bad request response +func (o *CreateStorageSSLCrtListFileBadRequest) WithPayload(payload *models.Error) *CreateStorageSSLCrtListFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list file bad request response +func (o *CreateStorageSSLCrtListFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateStorageSSLCrtListFileConflictCode is the HTTP code returned for type CreateStorageSSLCrtListFileConflict +const CreateStorageSSLCrtListFileConflictCode int = 409 + +/* +CreateStorageSSLCrtListFileConflict The specified resource already exists + +swagger:response createStorageSSLCrtListFileConflict +*/ +type CreateStorageSSLCrtListFileConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListFileConflict creates CreateStorageSSLCrtListFileConflict with default headers values +func NewCreateStorageSSLCrtListFileConflict() *CreateStorageSSLCrtListFileConflict { + + return &CreateStorageSSLCrtListFileConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l crt list file conflict response +func (o *CreateStorageSSLCrtListFileConflict) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCrtListFileConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l crt list file conflict response +func (o *CreateStorageSSLCrtListFileConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l crt list file conflict response +func (o *CreateStorageSSLCrtListFileConflict) WithPayload(payload *models.Error) *CreateStorageSSLCrtListFileConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list file conflict response +func (o *CreateStorageSSLCrtListFileConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListFileConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateStorageSSLCrtListFileDefault General Error + +swagger:response createStorageSSLCrtListFileDefault +*/ +type CreateStorageSSLCrtListFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateStorageSSLCrtListFileDefault creates CreateStorageSSLCrtListFileDefault with default headers values +func NewCreateStorageSSLCrtListFileDefault(code int) *CreateStorageSSLCrtListFileDefault { + if code <= 0 { + code = 500 + } + + return &CreateStorageSSLCrtListFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create storage s s l crt list file default response +func (o *CreateStorageSSLCrtListFileDefault) WithStatusCode(code int) *CreateStorageSSLCrtListFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create storage s s l crt list file default response +func (o *CreateStorageSSLCrtListFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create storage s s l crt list file default response +func (o *CreateStorageSSLCrtListFileDefault) WithConfigurationVersion(configurationVersion string) *CreateStorageSSLCrtListFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create storage s s l crt list file default response +func (o *CreateStorageSSLCrtListFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create storage s s l crt list file default response +func (o *CreateStorageSSLCrtListFileDefault) WithPayload(payload *models.Error) *CreateStorageSSLCrtListFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create storage s s l crt list file default response +func (o *CreateStorageSSLCrtListFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateStorageSSLCrtListFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/create_storage_s_s_l_crt_list_file_urlbuilder.go b/operations/storage/create_storage_s_s_l_crt_list_file_urlbuilder.go new file mode 100644 index 00000000..818b5d92 --- /dev/null +++ b/operations/storage/create_storage_s_s_l_crt_list_file_urlbuilder.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateStorageSSLCrtListFileURL generates an URL for the create storage s s l crt list file operation +type CreateStorageSSLCrtListFileURL struct { + ForceReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageSSLCrtListFileURL) WithBasePath(bp string) *CreateStorageSSLCrtListFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateStorageSSLCrtListFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateStorageSSLCrtListFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateStorageSSLCrtListFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateStorageSSLCrtListFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateStorageSSLCrtListFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateStorageSSLCrtListFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateStorageSSLCrtListFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateStorageSSLCrtListFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/delete_storage_general_file.go b/operations/storage/delete_storage_general_file.go new file mode 100644 index 00000000..0f5abcec --- /dev/null +++ b/operations/storage/delete_storage_general_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteStorageGeneralFileHandlerFunc turns a function with the right signature into a delete storage general file handler +type DeleteStorageGeneralFileHandlerFunc func(DeleteStorageGeneralFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteStorageGeneralFileHandlerFunc) Handle(params DeleteStorageGeneralFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteStorageGeneralFileHandler interface for that can handle valid delete storage general file params +type DeleteStorageGeneralFileHandler interface { + Handle(DeleteStorageGeneralFileParams, interface{}) middleware.Responder +} + +// NewDeleteStorageGeneralFile creates a new http.Handler for the delete storage general file operation +func NewDeleteStorageGeneralFile(ctx *middleware.Context, handler DeleteStorageGeneralFileHandler) *DeleteStorageGeneralFile { + return &DeleteStorageGeneralFile{Context: ctx, Handler: handler} +} + +/* + DeleteStorageGeneralFile swagger:route DELETE /services/haproxy/storage/general/{name} Storage deleteStorageGeneralFile + +# Deletes a managed general use file from disk + +Deletes a managed general use file from disk. +*/ +type DeleteStorageGeneralFile struct { + Context *middleware.Context + Handler DeleteStorageGeneralFileHandler +} + +func (o *DeleteStorageGeneralFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteStorageGeneralFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/delete_storage_general_file_parameters.go b/operations/storage/delete_storage_general_file_parameters.go new file mode 100644 index 00000000..1dd2ca6e --- /dev/null +++ b/operations/storage/delete_storage_general_file_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteStorageGeneralFileParams creates a new DeleteStorageGeneralFileParams object +// +// There are no default values defined in the spec. +func NewDeleteStorageGeneralFileParams() DeleteStorageGeneralFileParams { + + return DeleteStorageGeneralFileParams{} +} + +// DeleteStorageGeneralFileParams contains all the bound params for the delete storage general file operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteStorageGeneralFile +type DeleteStorageGeneralFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*General use file storage_name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteStorageGeneralFileParams() beforehand. +func (o *DeleteStorageGeneralFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteStorageGeneralFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/delete_storage_general_file_responses.go b/operations/storage/delete_storage_general_file_responses.go new file mode 100644 index 00000000..38ca3318 --- /dev/null +++ b/operations/storage/delete_storage_general_file_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteStorageGeneralFileNoContentCode is the HTTP code returned for type DeleteStorageGeneralFileNoContent +const DeleteStorageGeneralFileNoContentCode int = 204 + +/* +DeleteStorageGeneralFileNoContent General use file deleted + +swagger:response deleteStorageGeneralFileNoContent +*/ +type DeleteStorageGeneralFileNoContent struct { +} + +// NewDeleteStorageGeneralFileNoContent creates DeleteStorageGeneralFileNoContent with default headers values +func NewDeleteStorageGeneralFileNoContent() *DeleteStorageGeneralFileNoContent { + + return &DeleteStorageGeneralFileNoContent{} +} + +// WriteResponse to the client +func (o *DeleteStorageGeneralFileNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteStorageGeneralFileNotFoundCode is the HTTP code returned for type DeleteStorageGeneralFileNotFound +const DeleteStorageGeneralFileNotFoundCode int = 404 + +/* +DeleteStorageGeneralFileNotFound The specified resource was not found + +swagger:response deleteStorageGeneralFileNotFound +*/ +type DeleteStorageGeneralFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageGeneralFileNotFound creates DeleteStorageGeneralFileNotFound with default headers values +func NewDeleteStorageGeneralFileNotFound() *DeleteStorageGeneralFileNotFound { + + return &DeleteStorageGeneralFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage general file not found response +func (o *DeleteStorageGeneralFileNotFound) WithConfigurationVersion(configurationVersion string) *DeleteStorageGeneralFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage general file not found response +func (o *DeleteStorageGeneralFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage general file not found response +func (o *DeleteStorageGeneralFileNotFound) WithPayload(payload *models.Error) *DeleteStorageGeneralFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage general file not found response +func (o *DeleteStorageGeneralFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageGeneralFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteStorageGeneralFileDefault General Error + +swagger:response deleteStorageGeneralFileDefault +*/ +type DeleteStorageGeneralFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageGeneralFileDefault creates DeleteStorageGeneralFileDefault with default headers values +func NewDeleteStorageGeneralFileDefault(code int) *DeleteStorageGeneralFileDefault { + if code <= 0 { + code = 500 + } + + return &DeleteStorageGeneralFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete storage general file default response +func (o *DeleteStorageGeneralFileDefault) WithStatusCode(code int) *DeleteStorageGeneralFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete storage general file default response +func (o *DeleteStorageGeneralFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage general file default response +func (o *DeleteStorageGeneralFileDefault) WithConfigurationVersion(configurationVersion string) *DeleteStorageGeneralFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage general file default response +func (o *DeleteStorageGeneralFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage general file default response +func (o *DeleteStorageGeneralFileDefault) WithPayload(payload *models.Error) *DeleteStorageGeneralFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage general file default response +func (o *DeleteStorageGeneralFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageGeneralFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/delete_storage_general_file_urlbuilder.go b/operations/storage/delete_storage_general_file_urlbuilder.go new file mode 100644 index 00000000..ef6e4d24 --- /dev/null +++ b/operations/storage/delete_storage_general_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteStorageGeneralFileURL generates an URL for the delete storage general file operation +type DeleteStorageGeneralFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageGeneralFileURL) WithBasePath(bp string) *DeleteStorageGeneralFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageGeneralFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteStorageGeneralFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/general/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteStorageGeneralFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteStorageGeneralFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteStorageGeneralFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteStorageGeneralFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteStorageGeneralFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteStorageGeneralFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteStorageGeneralFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/delete_storage_map.go b/operations/storage/delete_storage_map.go new file mode 100644 index 00000000..47f3bcb3 --- /dev/null +++ b/operations/storage/delete_storage_map.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteStorageMapHandlerFunc turns a function with the right signature into a delete storage map handler +type DeleteStorageMapHandlerFunc func(DeleteStorageMapParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteStorageMapHandlerFunc) Handle(params DeleteStorageMapParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteStorageMapHandler interface for that can handle valid delete storage map params +type DeleteStorageMapHandler interface { + Handle(DeleteStorageMapParams, interface{}) middleware.Responder +} + +// NewDeleteStorageMap creates a new http.Handler for the delete storage map operation +func NewDeleteStorageMap(ctx *middleware.Context, handler DeleteStorageMapHandler) *DeleteStorageMap { + return &DeleteStorageMap{Context: ctx, Handler: handler} +} + +/* + DeleteStorageMap swagger:route DELETE /services/haproxy/storage/maps/{name} Storage deleteStorageMap + +# Deletes a managed map file from disk + +Deletes a managed map file from disk. +*/ +type DeleteStorageMap struct { + Context *middleware.Context + Handler DeleteStorageMapHandler +} + +func (o *DeleteStorageMap) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteStorageMapParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/delete_storage_map_parameters.go b/operations/storage/delete_storage_map_parameters.go new file mode 100644 index 00000000..40c2b65d --- /dev/null +++ b/operations/storage/delete_storage_map_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDeleteStorageMapParams creates a new DeleteStorageMapParams object +// +// There are no default values defined in the spec. +func NewDeleteStorageMapParams() DeleteStorageMapParams { + + return DeleteStorageMapParams{} +} + +// DeleteStorageMapParams contains all the bound params for the delete storage map operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteStorageMap +type DeleteStorageMapParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Map file storage_name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteStorageMapParams() beforehand. +func (o *DeleteStorageMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteStorageMapParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/delete_storage_map_responses.go b/operations/storage/delete_storage_map_responses.go new file mode 100644 index 00000000..786c6f54 --- /dev/null +++ b/operations/storage/delete_storage_map_responses.go @@ -0,0 +1,202 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteStorageMapNoContentCode is the HTTP code returned for type DeleteStorageMapNoContent +const DeleteStorageMapNoContentCode int = 204 + +/* +DeleteStorageMapNoContent Map file deleted + +swagger:response deleteStorageMapNoContent +*/ +type DeleteStorageMapNoContent struct { +} + +// NewDeleteStorageMapNoContent creates DeleteStorageMapNoContent with default headers values +func NewDeleteStorageMapNoContent() *DeleteStorageMapNoContent { + + return &DeleteStorageMapNoContent{} +} + +// WriteResponse to the client +func (o *DeleteStorageMapNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteStorageMapNotFoundCode is the HTTP code returned for type DeleteStorageMapNotFound +const DeleteStorageMapNotFoundCode int = 404 + +/* +DeleteStorageMapNotFound The specified resource was not found + +swagger:response deleteStorageMapNotFound +*/ +type DeleteStorageMapNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageMapNotFound creates DeleteStorageMapNotFound with default headers values +func NewDeleteStorageMapNotFound() *DeleteStorageMapNotFound { + + return &DeleteStorageMapNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage map not found response +func (o *DeleteStorageMapNotFound) WithConfigurationVersion(configurationVersion string) *DeleteStorageMapNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage map not found response +func (o *DeleteStorageMapNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage map not found response +func (o *DeleteStorageMapNotFound) WithPayload(payload *models.Error) *DeleteStorageMapNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage map not found response +func (o *DeleteStorageMapNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageMapNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteStorageMapDefault General Error + +swagger:response deleteStorageMapDefault +*/ +type DeleteStorageMapDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageMapDefault creates DeleteStorageMapDefault with default headers values +func NewDeleteStorageMapDefault(code int) *DeleteStorageMapDefault { + if code <= 0 { + code = 500 + } + + return &DeleteStorageMapDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete storage map default response +func (o *DeleteStorageMapDefault) WithStatusCode(code int) *DeleteStorageMapDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete storage map default response +func (o *DeleteStorageMapDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage map default response +func (o *DeleteStorageMapDefault) WithConfigurationVersion(configurationVersion string) *DeleteStorageMapDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage map default response +func (o *DeleteStorageMapDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage map default response +func (o *DeleteStorageMapDefault) WithPayload(payload *models.Error) *DeleteStorageMapDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage map default response +func (o *DeleteStorageMapDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageMapDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/delete_storage_map_urlbuilder.go b/operations/storage/delete_storage_map_urlbuilder.go new file mode 100644 index 00000000..7d8f9dd4 --- /dev/null +++ b/operations/storage/delete_storage_map_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DeleteStorageMapURL generates an URL for the delete storage map operation +type DeleteStorageMapURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageMapURL) WithBasePath(bp string) *DeleteStorageMapURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageMapURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteStorageMapURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/maps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteStorageMapURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteStorageMapURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteStorageMapURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteStorageMapURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteStorageMapURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteStorageMapURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteStorageMapURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/delete_storage_s_s_l_certificate.go b/operations/storage/delete_storage_s_s_l_certificate.go new file mode 100644 index 00000000..42f923fe --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_certificate.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteStorageSSLCertificateHandlerFunc turns a function with the right signature into a delete storage s s l certificate handler +type DeleteStorageSSLCertificateHandlerFunc func(DeleteStorageSSLCertificateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteStorageSSLCertificateHandlerFunc) Handle(params DeleteStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteStorageSSLCertificateHandler interface for that can handle valid delete storage s s l certificate params +type DeleteStorageSSLCertificateHandler interface { + Handle(DeleteStorageSSLCertificateParams, interface{}) middleware.Responder +} + +// NewDeleteStorageSSLCertificate creates a new http.Handler for the delete storage s s l certificate operation +func NewDeleteStorageSSLCertificate(ctx *middleware.Context, handler DeleteStorageSSLCertificateHandler) *DeleteStorageSSLCertificate { + return &DeleteStorageSSLCertificate{Context: ctx, Handler: handler} +} + +/* + DeleteStorageSSLCertificate swagger:route DELETE /services/haproxy/storage/ssl_certificates/{name} Storage deleteStorageSSLCertificate + +# Delete SSL certificate from disk + +Deletes SSL certificate from disk. +*/ +type DeleteStorageSSLCertificate struct { + Context *middleware.Context + Handler DeleteStorageSSLCertificateHandler +} + +func (o *DeleteStorageSSLCertificate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteStorageSSLCertificateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/delete_storage_s_s_l_certificate_parameters.go b/operations/storage/delete_storage_s_s_l_certificate_parameters.go new file mode 100644 index 00000000..bd524de1 --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_certificate_parameters.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteStorageSSLCertificateParams creates a new DeleteStorageSSLCertificateParams object +// with the default values initialized. +func NewDeleteStorageSSLCertificateParams() DeleteStorageSSLCertificateParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + + skipReloadDefault = bool(false) + ) + + return DeleteStorageSSLCertificateParams{ + ForceReload: &forceReloadDefault, + + SkipReload: &skipReloadDefault, + } +} + +// DeleteStorageSSLCertificateParams contains all the bound params for the delete storage s s l certificate operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteStorageSSLCertificate +type DeleteStorageSSLCertificateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*SSL certificate name + Required: true + In: path + */ + Name string + /*If set, no reload will be initiated after update + In: query + Default: false + */ + SkipReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteStorageSSLCertificateParams() beforehand. +func (o *DeleteStorageSSLCertificateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteStorageSSLCertificateParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteStorageSSLCertificateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteStorageSSLCertificateParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *DeleteStorageSSLCertificateParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteStorageSSLCertificateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} diff --git a/operations/storage/delete_storage_s_s_l_certificate_responses.go b/operations/storage/delete_storage_s_s_l_certificate_responses.go new file mode 100644 index 00000000..c50c912d --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_certificate_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteStorageSSLCertificateAcceptedCode is the HTTP code returned for type DeleteStorageSSLCertificateAccepted +const DeleteStorageSSLCertificateAcceptedCode int = 202 + +/* +DeleteStorageSSLCertificateAccepted SSL certificate deleted and reload requested + +swagger:response deleteStorageSSLCertificateAccepted +*/ +type DeleteStorageSSLCertificateAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteStorageSSLCertificateAccepted creates DeleteStorageSSLCertificateAccepted with default headers values +func NewDeleteStorageSSLCertificateAccepted() *DeleteStorageSSLCertificateAccepted { + + return &DeleteStorageSSLCertificateAccepted{} +} + +// WithReloadID adds the reloadId to the delete storage s s l certificate accepted response +func (o *DeleteStorageSSLCertificateAccepted) WithReloadID(reloadID string) *DeleteStorageSSLCertificateAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete storage s s l certificate accepted response +func (o *DeleteStorageSSLCertificateAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCertificateAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteStorageSSLCertificateNoContentCode is the HTTP code returned for type DeleteStorageSSLCertificateNoContent +const DeleteStorageSSLCertificateNoContentCode int = 204 + +/* +DeleteStorageSSLCertificateNoContent SSL certificate deleted + +swagger:response deleteStorageSSLCertificateNoContent +*/ +type DeleteStorageSSLCertificateNoContent struct { +} + +// NewDeleteStorageSSLCertificateNoContent creates DeleteStorageSSLCertificateNoContent with default headers values +func NewDeleteStorageSSLCertificateNoContent() *DeleteStorageSSLCertificateNoContent { + + return &DeleteStorageSSLCertificateNoContent{} +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCertificateNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteStorageSSLCertificateNotFoundCode is the HTTP code returned for type DeleteStorageSSLCertificateNotFound +const DeleteStorageSSLCertificateNotFoundCode int = 404 + +/* +DeleteStorageSSLCertificateNotFound The specified resource was not found + +swagger:response deleteStorageSSLCertificateNotFound +*/ +type DeleteStorageSSLCertificateNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageSSLCertificateNotFound creates DeleteStorageSSLCertificateNotFound with default headers values +func NewDeleteStorageSSLCertificateNotFound() *DeleteStorageSSLCertificateNotFound { + + return &DeleteStorageSSLCertificateNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage s s l certificate not found response +func (o *DeleteStorageSSLCertificateNotFound) WithConfigurationVersion(configurationVersion string) *DeleteStorageSSLCertificateNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage s s l certificate not found response +func (o *DeleteStorageSSLCertificateNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage s s l certificate not found response +func (o *DeleteStorageSSLCertificateNotFound) WithPayload(payload *models.Error) *DeleteStorageSSLCertificateNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage s s l certificate not found response +func (o *DeleteStorageSSLCertificateNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCertificateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteStorageSSLCertificateDefault General Error + +swagger:response deleteStorageSSLCertificateDefault +*/ +type DeleteStorageSSLCertificateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageSSLCertificateDefault creates DeleteStorageSSLCertificateDefault with default headers values +func NewDeleteStorageSSLCertificateDefault(code int) *DeleteStorageSSLCertificateDefault { + if code <= 0 { + code = 500 + } + + return &DeleteStorageSSLCertificateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete storage s s l certificate default response +func (o *DeleteStorageSSLCertificateDefault) WithStatusCode(code int) *DeleteStorageSSLCertificateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete storage s s l certificate default response +func (o *DeleteStorageSSLCertificateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage s s l certificate default response +func (o *DeleteStorageSSLCertificateDefault) WithConfigurationVersion(configurationVersion string) *DeleteStorageSSLCertificateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage s s l certificate default response +func (o *DeleteStorageSSLCertificateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage s s l certificate default response +func (o *DeleteStorageSSLCertificateDefault) WithPayload(payload *models.Error) *DeleteStorageSSLCertificateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage s s l certificate default response +func (o *DeleteStorageSSLCertificateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCertificateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/delete_storage_s_s_l_certificate_urlbuilder.go b/operations/storage/delete_storage_s_s_l_certificate_urlbuilder.go new file mode 100644 index 00000000..9a83b9ef --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_certificate_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteStorageSSLCertificateURL generates an URL for the delete storage s s l certificate operation +type DeleteStorageSSLCertificateURL struct { + Name string + + ForceReload *bool + SkipReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageSSLCertificateURL) WithBasePath(bp string) *DeleteStorageSSLCertificateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageSSLCertificateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteStorageSSLCertificateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_certificates/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteStorageSSLCertificateURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteStorageSSLCertificateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteStorageSSLCertificateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteStorageSSLCertificateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteStorageSSLCertificateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteStorageSSLCertificateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteStorageSSLCertificateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_entry.go b/operations/storage/delete_storage_s_s_l_crt_list_entry.go new file mode 100644 index 00000000..31dd4275 --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteStorageSSLCrtListEntryHandlerFunc turns a function with the right signature into a delete storage s s l crt list entry handler +type DeleteStorageSSLCrtListEntryHandlerFunc func(DeleteStorageSSLCrtListEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteStorageSSLCrtListEntryHandlerFunc) Handle(params DeleteStorageSSLCrtListEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteStorageSSLCrtListEntryHandler interface for that can handle valid delete storage s s l crt list entry params +type DeleteStorageSSLCrtListEntryHandler interface { + Handle(DeleteStorageSSLCrtListEntryParams, interface{}) middleware.Responder +} + +// NewDeleteStorageSSLCrtListEntry creates a new http.Handler for the delete storage s s l crt list entry operation +func NewDeleteStorageSSLCrtListEntry(ctx *middleware.Context, handler DeleteStorageSSLCrtListEntryHandler) *DeleteStorageSSLCrtListEntry { + return &DeleteStorageSSLCrtListEntry{Context: ctx, Handler: handler} +} + +/* + DeleteStorageSSLCrtListEntry swagger:route DELETE /services/haproxy/storage/ssl_crt_lists/{name}/entries Storage deleteStorageSSLCrtListEntry + +# Deletes an entry from CrtList file + +Deletes an entry from a certificate list. +*/ +type DeleteStorageSSLCrtListEntry struct { + Context *middleware.Context + Handler DeleteStorageSSLCrtListEntryHandler +} + +func (o *DeleteStorageSSLCrtListEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteStorageSSLCrtListEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_entry_parameters.go b/operations/storage/delete_storage_s_s_l_crt_list_entry_parameters.go new file mode 100644 index 00000000..936c5042 --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_entry_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteStorageSSLCrtListEntryParams creates a new DeleteStorageSSLCrtListEntryParams object +// with the default values initialized. +func NewDeleteStorageSSLCrtListEntryParams() DeleteStorageSSLCrtListEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteStorageSSLCrtListEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteStorageSSLCrtListEntryParams contains all the bound params for the delete storage s s l crt list entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteStorageSSLCrtListEntry +type DeleteStorageSSLCrtListEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL certificate filename + Required: true + In: query + */ + Certificate string + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*The line number in the crt-list + Required: true + Minimum: 0 + In: query + */ + LineNumber int64 + /*SSL crt list name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteStorageSSLCrtListEntryParams() beforehand. +func (o *DeleteStorageSSLCrtListEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qCertificate, qhkCertificate, _ := qs.GetOK("certificate") + if err := o.bindCertificate(qCertificate, qhkCertificate, route.Formats); err != nil { + res = append(res, err) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qLineNumber, qhkLineNumber, _ := qs.GetOK("line_number") + if err := o.bindLineNumber(qLineNumber, qhkLineNumber, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindCertificate binds and validates parameter Certificate from query. +func (o *DeleteStorageSSLCrtListEntryParams) bindCertificate(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("certificate", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("certificate", "query", raw); err != nil { + return err + } + o.Certificate = raw + + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteStorageSSLCrtListEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteStorageSSLCrtListEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindLineNumber binds and validates parameter LineNumber from query. +func (o *DeleteStorageSSLCrtListEntryParams) bindLineNumber(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("line_number", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("line_number", "query", raw); err != nil { + return err + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("line_number", "query", "int64", raw) + } + o.LineNumber = value + + if err := o.validateLineNumber(formats); err != nil { + return err + } + + return nil +} + +// validateLineNumber carries on validations for parameter LineNumber +func (o *DeleteStorageSSLCrtListEntryParams) validateLineNumber(formats strfmt.Registry) error { + + if err := validate.MinimumInt("line_number", "query", o.LineNumber, 0, false); err != nil { + return err + } + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteStorageSSLCrtListEntryParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_entry_responses.go b/operations/storage/delete_storage_s_s_l_crt_list_entry_responses.go new file mode 100644 index 00000000..4c9ecdac --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_entry_responses.go @@ -0,0 +1,316 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteStorageSSLCrtListEntryAcceptedCode is the HTTP code returned for type DeleteStorageSSLCrtListEntryAccepted +const DeleteStorageSSLCrtListEntryAcceptedCode int = 202 + +/* +DeleteStorageSSLCrtListEntryAccepted Configuration change accepted and reload requested + +swagger:response deleteStorageSSLCrtListEntryAccepted +*/ +type DeleteStorageSSLCrtListEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteStorageSSLCrtListEntryAccepted creates DeleteStorageSSLCrtListEntryAccepted with default headers values +func NewDeleteStorageSSLCrtListEntryAccepted() *DeleteStorageSSLCrtListEntryAccepted { + + return &DeleteStorageSSLCrtListEntryAccepted{} +} + +// WithReloadID adds the reloadId to the delete storage s s l crt list entry accepted response +func (o *DeleteStorageSSLCrtListEntryAccepted) WithReloadID(reloadID string) *DeleteStorageSSLCrtListEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete storage s s l crt list entry accepted response +func (o *DeleteStorageSSLCrtListEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteStorageSSLCrtListEntryNoContentCode is the HTTP code returned for type DeleteStorageSSLCrtListEntryNoContent +const DeleteStorageSSLCrtListEntryNoContentCode int = 204 + +/* +DeleteStorageSSLCrtListEntryNoContent Successful operation + +swagger:response deleteStorageSSLCrtListEntryNoContent +*/ +type DeleteStorageSSLCrtListEntryNoContent struct { +} + +// NewDeleteStorageSSLCrtListEntryNoContent creates DeleteStorageSSLCrtListEntryNoContent with default headers values +func NewDeleteStorageSSLCrtListEntryNoContent() *DeleteStorageSSLCrtListEntryNoContent { + + return &DeleteStorageSSLCrtListEntryNoContent{} +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListEntryNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteStorageSSLCrtListEntryBadRequestCode is the HTTP code returned for type DeleteStorageSSLCrtListEntryBadRequest +const DeleteStorageSSLCrtListEntryBadRequestCode int = 400 + +/* +DeleteStorageSSLCrtListEntryBadRequest Bad request + +swagger:response deleteStorageSSLCrtListEntryBadRequest +*/ +type DeleteStorageSSLCrtListEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageSSLCrtListEntryBadRequest creates DeleteStorageSSLCrtListEntryBadRequest with default headers values +func NewDeleteStorageSSLCrtListEntryBadRequest() *DeleteStorageSSLCrtListEntryBadRequest { + + return &DeleteStorageSSLCrtListEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage s s l crt list entry bad request response +func (o *DeleteStorageSSLCrtListEntryBadRequest) WithConfigurationVersion(configurationVersion string) *DeleteStorageSSLCrtListEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage s s l crt list entry bad request response +func (o *DeleteStorageSSLCrtListEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage s s l crt list entry bad request response +func (o *DeleteStorageSSLCrtListEntryBadRequest) WithPayload(payload *models.Error) *DeleteStorageSSLCrtListEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage s s l crt list entry bad request response +func (o *DeleteStorageSSLCrtListEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteStorageSSLCrtListEntryNotFoundCode is the HTTP code returned for type DeleteStorageSSLCrtListEntryNotFound +const DeleteStorageSSLCrtListEntryNotFoundCode int = 404 + +/* +DeleteStorageSSLCrtListEntryNotFound The specified resource was not found + +swagger:response deleteStorageSSLCrtListEntryNotFound +*/ +type DeleteStorageSSLCrtListEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageSSLCrtListEntryNotFound creates DeleteStorageSSLCrtListEntryNotFound with default headers values +func NewDeleteStorageSSLCrtListEntryNotFound() *DeleteStorageSSLCrtListEntryNotFound { + + return &DeleteStorageSSLCrtListEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage s s l crt list entry not found response +func (o *DeleteStorageSSLCrtListEntryNotFound) WithConfigurationVersion(configurationVersion string) *DeleteStorageSSLCrtListEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage s s l crt list entry not found response +func (o *DeleteStorageSSLCrtListEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage s s l crt list entry not found response +func (o *DeleteStorageSSLCrtListEntryNotFound) WithPayload(payload *models.Error) *DeleteStorageSSLCrtListEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage s s l crt list entry not found response +func (o *DeleteStorageSSLCrtListEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteStorageSSLCrtListEntryDefault General Error + +swagger:response deleteStorageSSLCrtListEntryDefault +*/ +type DeleteStorageSSLCrtListEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageSSLCrtListEntryDefault creates DeleteStorageSSLCrtListEntryDefault with default headers values +func NewDeleteStorageSSLCrtListEntryDefault(code int) *DeleteStorageSSLCrtListEntryDefault { + if code <= 0 { + code = 500 + } + + return &DeleteStorageSSLCrtListEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete storage s s l crt list entry default response +func (o *DeleteStorageSSLCrtListEntryDefault) WithStatusCode(code int) *DeleteStorageSSLCrtListEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete storage s s l crt list entry default response +func (o *DeleteStorageSSLCrtListEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage s s l crt list entry default response +func (o *DeleteStorageSSLCrtListEntryDefault) WithConfigurationVersion(configurationVersion string) *DeleteStorageSSLCrtListEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage s s l crt list entry default response +func (o *DeleteStorageSSLCrtListEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage s s l crt list entry default response +func (o *DeleteStorageSSLCrtListEntryDefault) WithPayload(payload *models.Error) *DeleteStorageSSLCrtListEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage s s l crt list entry default response +func (o *DeleteStorageSSLCrtListEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_entry_urlbuilder.go b/operations/storage/delete_storage_s_s_l_crt_list_entry_urlbuilder.go new file mode 100644 index 00000000..3e5bc136 --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_entry_urlbuilder.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteStorageSSLCrtListEntryURL generates an URL for the delete storage s s l crt list entry operation +type DeleteStorageSSLCrtListEntryURL struct { + Name string + + Certificate string + ForceReload *bool + LineNumber int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageSSLCrtListEntryURL) WithBasePath(bp string) *DeleteStorageSSLCrtListEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageSSLCrtListEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteStorageSSLCrtListEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists/{name}/entries" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteStorageSSLCrtListEntryURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + certificateQ := o.Certificate + if certificateQ != "" { + qs.Set("certificate", certificateQ) + } + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + lineNumberQ := swag.FormatInt64(o.LineNumber) + if lineNumberQ != "" { + qs.Set("line_number", lineNumberQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteStorageSSLCrtListEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteStorageSSLCrtListEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteStorageSSLCrtListEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteStorageSSLCrtListEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteStorageSSLCrtListEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteStorageSSLCrtListEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_file.go b/operations/storage/delete_storage_s_s_l_crt_list_file.go new file mode 100644 index 00000000..35223114 --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteStorageSSLCrtListFileHandlerFunc turns a function with the right signature into a delete storage s s l crt list file handler +type DeleteStorageSSLCrtListFileHandlerFunc func(DeleteStorageSSLCrtListFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteStorageSSLCrtListFileHandlerFunc) Handle(params DeleteStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteStorageSSLCrtListFileHandler interface for that can handle valid delete storage s s l crt list file params +type DeleteStorageSSLCrtListFileHandler interface { + Handle(DeleteStorageSSLCrtListFileParams, interface{}) middleware.Responder +} + +// NewDeleteStorageSSLCrtListFile creates a new http.Handler for the delete storage s s l crt list file operation +func NewDeleteStorageSSLCrtListFile(ctx *middleware.Context, handler DeleteStorageSSLCrtListFileHandler) *DeleteStorageSSLCrtListFile { + return &DeleteStorageSSLCrtListFile{Context: ctx, Handler: handler} +} + +/* + DeleteStorageSSLCrtListFile swagger:route DELETE /services/haproxy/storage/ssl_crt_lists/{name} Storage deleteStorageSSLCrtListFile + +# Delete a certificate list from disk + +Deletes a certificate list from disk. +*/ +type DeleteStorageSSLCrtListFile struct { + Context *middleware.Context + Handler DeleteStorageSSLCrtListFileHandler +} + +func (o *DeleteStorageSSLCrtListFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteStorageSSLCrtListFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_file_parameters.go b/operations/storage/delete_storage_s_s_l_crt_list_file_parameters.go new file mode 100644 index 00000000..aad62fca --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_file_parameters.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteStorageSSLCrtListFileParams creates a new DeleteStorageSSLCrtListFileParams object +// with the default values initialized. +func NewDeleteStorageSSLCrtListFileParams() DeleteStorageSSLCrtListFileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + + skipReloadDefault = bool(false) + ) + + return DeleteStorageSSLCrtListFileParams{ + ForceReload: &forceReloadDefault, + + SkipReload: &skipReloadDefault, + } +} + +// DeleteStorageSSLCrtListFileParams contains all the bound params for the delete storage s s l crt list file operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteStorageSSLCrtListFile +type DeleteStorageSSLCrtListFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Certificate list name + Required: true + In: path + */ + Name string + /*If set, no reload will be initiated after update + In: query + Default: false + */ + SkipReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteStorageSSLCrtListFileParams() beforehand. +func (o *DeleteStorageSSLCrtListFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteStorageSSLCrtListFileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteStorageSSLCrtListFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteStorageSSLCrtListFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *DeleteStorageSSLCrtListFileParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteStorageSSLCrtListFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_file_responses.go b/operations/storage/delete_storage_s_s_l_crt_list_file_responses.go new file mode 100644 index 00000000..592c99e9 --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_file_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteStorageSSLCrtListFileAcceptedCode is the HTTP code returned for type DeleteStorageSSLCrtListFileAccepted +const DeleteStorageSSLCrtListFileAcceptedCode int = 202 + +/* +DeleteStorageSSLCrtListFileAccepted Certificate list deleted and reload requested + +swagger:response deleteStorageSSLCrtListFileAccepted +*/ +type DeleteStorageSSLCrtListFileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteStorageSSLCrtListFileAccepted creates DeleteStorageSSLCrtListFileAccepted with default headers values +func NewDeleteStorageSSLCrtListFileAccepted() *DeleteStorageSSLCrtListFileAccepted { + + return &DeleteStorageSSLCrtListFileAccepted{} +} + +// WithReloadID adds the reloadId to the delete storage s s l crt list file accepted response +func (o *DeleteStorageSSLCrtListFileAccepted) WithReloadID(reloadID string) *DeleteStorageSSLCrtListFileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete storage s s l crt list file accepted response +func (o *DeleteStorageSSLCrtListFileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListFileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteStorageSSLCrtListFileNoContentCode is the HTTP code returned for type DeleteStorageSSLCrtListFileNoContent +const DeleteStorageSSLCrtListFileNoContentCode int = 204 + +/* +DeleteStorageSSLCrtListFileNoContent Certificate list deleted + +swagger:response deleteStorageSSLCrtListFileNoContent +*/ +type DeleteStorageSSLCrtListFileNoContent struct { +} + +// NewDeleteStorageSSLCrtListFileNoContent creates DeleteStorageSSLCrtListFileNoContent with default headers values +func NewDeleteStorageSSLCrtListFileNoContent() *DeleteStorageSSLCrtListFileNoContent { + + return &DeleteStorageSSLCrtListFileNoContent{} +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListFileNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteStorageSSLCrtListFileNotFoundCode is the HTTP code returned for type DeleteStorageSSLCrtListFileNotFound +const DeleteStorageSSLCrtListFileNotFoundCode int = 404 + +/* +DeleteStorageSSLCrtListFileNotFound The specified resource was not found + +swagger:response deleteStorageSSLCrtListFileNotFound +*/ +type DeleteStorageSSLCrtListFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageSSLCrtListFileNotFound creates DeleteStorageSSLCrtListFileNotFound with default headers values +func NewDeleteStorageSSLCrtListFileNotFound() *DeleteStorageSSLCrtListFileNotFound { + + return &DeleteStorageSSLCrtListFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage s s l crt list file not found response +func (o *DeleteStorageSSLCrtListFileNotFound) WithConfigurationVersion(configurationVersion string) *DeleteStorageSSLCrtListFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage s s l crt list file not found response +func (o *DeleteStorageSSLCrtListFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage s s l crt list file not found response +func (o *DeleteStorageSSLCrtListFileNotFound) WithPayload(payload *models.Error) *DeleteStorageSSLCrtListFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage s s l crt list file not found response +func (o *DeleteStorageSSLCrtListFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteStorageSSLCrtListFileDefault General Error + +swagger:response deleteStorageSSLCrtListFileDefault +*/ +type DeleteStorageSSLCrtListFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteStorageSSLCrtListFileDefault creates DeleteStorageSSLCrtListFileDefault with default headers values +func NewDeleteStorageSSLCrtListFileDefault(code int) *DeleteStorageSSLCrtListFileDefault { + if code <= 0 { + code = 500 + } + + return &DeleteStorageSSLCrtListFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete storage s s l crt list file default response +func (o *DeleteStorageSSLCrtListFileDefault) WithStatusCode(code int) *DeleteStorageSSLCrtListFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete storage s s l crt list file default response +func (o *DeleteStorageSSLCrtListFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete storage s s l crt list file default response +func (o *DeleteStorageSSLCrtListFileDefault) WithConfigurationVersion(configurationVersion string) *DeleteStorageSSLCrtListFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete storage s s l crt list file default response +func (o *DeleteStorageSSLCrtListFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete storage s s l crt list file default response +func (o *DeleteStorageSSLCrtListFileDefault) WithPayload(payload *models.Error) *DeleteStorageSSLCrtListFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete storage s s l crt list file default response +func (o *DeleteStorageSSLCrtListFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteStorageSSLCrtListFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/delete_storage_s_s_l_crt_list_file_urlbuilder.go b/operations/storage/delete_storage_s_s_l_crt_list_file_urlbuilder.go new file mode 100644 index 00000000..15c446f5 --- /dev/null +++ b/operations/storage/delete_storage_s_s_l_crt_list_file_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteStorageSSLCrtListFileURL generates an URL for the delete storage s s l crt list file operation +type DeleteStorageSSLCrtListFileURL struct { + Name string + + ForceReload *bool + SkipReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageSSLCrtListFileURL) WithBasePath(bp string) *DeleteStorageSSLCrtListFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteStorageSSLCrtListFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteStorageSSLCrtListFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteStorageSSLCrtListFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteStorageSSLCrtListFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteStorageSSLCrtListFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteStorageSSLCrtListFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteStorageSSLCrtListFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteStorageSSLCrtListFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteStorageSSLCrtListFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_all_storage_general_files.go b/operations/storage/get_all_storage_general_files.go new file mode 100644 index 00000000..448534ef --- /dev/null +++ b/operations/storage/get_all_storage_general_files.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllStorageGeneralFilesHandlerFunc turns a function with the right signature into a get all storage general files handler +type GetAllStorageGeneralFilesHandlerFunc func(GetAllStorageGeneralFilesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllStorageGeneralFilesHandlerFunc) Handle(params GetAllStorageGeneralFilesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllStorageGeneralFilesHandler interface for that can handle valid get all storage general files params +type GetAllStorageGeneralFilesHandler interface { + Handle(GetAllStorageGeneralFilesParams, interface{}) middleware.Responder +} + +// NewGetAllStorageGeneralFiles creates a new http.Handler for the get all storage general files operation +func NewGetAllStorageGeneralFiles(ctx *middleware.Context, handler GetAllStorageGeneralFilesHandler) *GetAllStorageGeneralFiles { + return &GetAllStorageGeneralFiles{Context: ctx, Handler: handler} +} + +/* + GetAllStorageGeneralFiles swagger:route GET /services/haproxy/storage/general Storage getAllStorageGeneralFiles + +# Return a list of all managed general use files + +Returns a list of all managed general use files +*/ +type GetAllStorageGeneralFiles struct { + Context *middleware.Context + Handler GetAllStorageGeneralFilesHandler +} + +func (o *GetAllStorageGeneralFiles) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllStorageGeneralFilesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_all_storage_general_files_parameters.go b/operations/storage/get_all_storage_general_files_parameters.go new file mode 100644 index 00000000..22678508 --- /dev/null +++ b/operations/storage/get_all_storage_general_files_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllStorageGeneralFilesParams creates a new GetAllStorageGeneralFilesParams object +// +// There are no default values defined in the spec. +func NewGetAllStorageGeneralFilesParams() GetAllStorageGeneralFilesParams { + + return GetAllStorageGeneralFilesParams{} +} + +// GetAllStorageGeneralFilesParams contains all the bound params for the get all storage general files operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllStorageGeneralFiles +type GetAllStorageGeneralFilesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllStorageGeneralFilesParams() beforehand. +func (o *GetAllStorageGeneralFilesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/storage/get_all_storage_general_files_responses.go b/operations/storage/get_all_storage_general_files_responses.go new file mode 100644 index 00000000..1bd7b8c2 --- /dev/null +++ b/operations/storage/get_all_storage_general_files_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllStorageGeneralFilesOKCode is the HTTP code returned for type GetAllStorageGeneralFilesOK +const GetAllStorageGeneralFilesOKCode int = 200 + +/* +GetAllStorageGeneralFilesOK Successful operation + +swagger:response getAllStorageGeneralFilesOK +*/ +type GetAllStorageGeneralFilesOK struct { + + /* + In: Body + */ + Payload models.GeneralFiles `json:"body,omitempty"` +} + +// NewGetAllStorageGeneralFilesOK creates GetAllStorageGeneralFilesOK with default headers values +func NewGetAllStorageGeneralFilesOK() *GetAllStorageGeneralFilesOK { + + return &GetAllStorageGeneralFilesOK{} +} + +// WithPayload adds the payload to the get all storage general files o k response +func (o *GetAllStorageGeneralFilesOK) WithPayload(payload models.GeneralFiles) *GetAllStorageGeneralFilesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage general files o k response +func (o *GetAllStorageGeneralFilesOK) SetPayload(payload models.GeneralFiles) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageGeneralFilesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.GeneralFiles{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAllStorageGeneralFilesNotFoundCode is the HTTP code returned for type GetAllStorageGeneralFilesNotFound +const GetAllStorageGeneralFilesNotFoundCode int = 404 + +/* +GetAllStorageGeneralFilesNotFound The specified resource was not found + +swagger:response getAllStorageGeneralFilesNotFound +*/ +type GetAllStorageGeneralFilesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageGeneralFilesNotFound creates GetAllStorageGeneralFilesNotFound with default headers values +func NewGetAllStorageGeneralFilesNotFound() *GetAllStorageGeneralFilesNotFound { + + return &GetAllStorageGeneralFilesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage general files not found response +func (o *GetAllStorageGeneralFilesNotFound) WithConfigurationVersion(configurationVersion string) *GetAllStorageGeneralFilesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage general files not found response +func (o *GetAllStorageGeneralFilesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage general files not found response +func (o *GetAllStorageGeneralFilesNotFound) WithPayload(payload *models.Error) *GetAllStorageGeneralFilesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage general files not found response +func (o *GetAllStorageGeneralFilesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageGeneralFilesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAllStorageGeneralFilesDefault General Error + +swagger:response getAllStorageGeneralFilesDefault +*/ +type GetAllStorageGeneralFilesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageGeneralFilesDefault creates GetAllStorageGeneralFilesDefault with default headers values +func NewGetAllStorageGeneralFilesDefault(code int) *GetAllStorageGeneralFilesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllStorageGeneralFilesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all storage general files default response +func (o *GetAllStorageGeneralFilesDefault) WithStatusCode(code int) *GetAllStorageGeneralFilesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all storage general files default response +func (o *GetAllStorageGeneralFilesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage general files default response +func (o *GetAllStorageGeneralFilesDefault) WithConfigurationVersion(configurationVersion string) *GetAllStorageGeneralFilesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage general files default response +func (o *GetAllStorageGeneralFilesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage general files default response +func (o *GetAllStorageGeneralFilesDefault) WithPayload(payload *models.Error) *GetAllStorageGeneralFilesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage general files default response +func (o *GetAllStorageGeneralFilesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageGeneralFilesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_all_storage_general_files_urlbuilder.go b/operations/storage/get_all_storage_general_files_urlbuilder.go new file mode 100644 index 00000000..be00a5a9 --- /dev/null +++ b/operations/storage/get_all_storage_general_files_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllStorageGeneralFilesURL generates an URL for the get all storage general files operation +type GetAllStorageGeneralFilesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageGeneralFilesURL) WithBasePath(bp string) *GetAllStorageGeneralFilesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageGeneralFilesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllStorageGeneralFilesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/general" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllStorageGeneralFilesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllStorageGeneralFilesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllStorageGeneralFilesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllStorageGeneralFilesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllStorageGeneralFilesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllStorageGeneralFilesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_all_storage_map_files.go b/operations/storage/get_all_storage_map_files.go new file mode 100644 index 00000000..f3f3cd93 --- /dev/null +++ b/operations/storage/get_all_storage_map_files.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllStorageMapFilesHandlerFunc turns a function with the right signature into a get all storage map files handler +type GetAllStorageMapFilesHandlerFunc func(GetAllStorageMapFilesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllStorageMapFilesHandlerFunc) Handle(params GetAllStorageMapFilesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllStorageMapFilesHandler interface for that can handle valid get all storage map files params +type GetAllStorageMapFilesHandler interface { + Handle(GetAllStorageMapFilesParams, interface{}) middleware.Responder +} + +// NewGetAllStorageMapFiles creates a new http.Handler for the get all storage map files operation +func NewGetAllStorageMapFiles(ctx *middleware.Context, handler GetAllStorageMapFilesHandler) *GetAllStorageMapFiles { + return &GetAllStorageMapFiles{Context: ctx, Handler: handler} +} + +/* + GetAllStorageMapFiles swagger:route GET /services/haproxy/storage/maps Storage getAllStorageMapFiles + +# Return a list of all managed map files + +Returns a list of all managed map files +*/ +type GetAllStorageMapFiles struct { + Context *middleware.Context + Handler GetAllStorageMapFilesHandler +} + +func (o *GetAllStorageMapFiles) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllStorageMapFilesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_all_storage_map_files_parameters.go b/operations/storage/get_all_storage_map_files_parameters.go new file mode 100644 index 00000000..ff9c5707 --- /dev/null +++ b/operations/storage/get_all_storage_map_files_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllStorageMapFilesParams creates a new GetAllStorageMapFilesParams object +// +// There are no default values defined in the spec. +func NewGetAllStorageMapFilesParams() GetAllStorageMapFilesParams { + + return GetAllStorageMapFilesParams{} +} + +// GetAllStorageMapFilesParams contains all the bound params for the get all storage map files operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllStorageMapFiles +type GetAllStorageMapFilesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllStorageMapFilesParams() beforehand. +func (o *GetAllStorageMapFilesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/storage/get_all_storage_map_files_responses.go b/operations/storage/get_all_storage_map_files_responses.go new file mode 100644 index 00000000..9d647a2c --- /dev/null +++ b/operations/storage/get_all_storage_map_files_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllStorageMapFilesOKCode is the HTTP code returned for type GetAllStorageMapFilesOK +const GetAllStorageMapFilesOKCode int = 200 + +/* +GetAllStorageMapFilesOK Successful operation + +swagger:response getAllStorageMapFilesOK +*/ +type GetAllStorageMapFilesOK struct { + + /* + In: Body + */ + Payload models.Maps `json:"body,omitempty"` +} + +// NewGetAllStorageMapFilesOK creates GetAllStorageMapFilesOK with default headers values +func NewGetAllStorageMapFilesOK() *GetAllStorageMapFilesOK { + + return &GetAllStorageMapFilesOK{} +} + +// WithPayload adds the payload to the get all storage map files o k response +func (o *GetAllStorageMapFilesOK) WithPayload(payload models.Maps) *GetAllStorageMapFilesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage map files o k response +func (o *GetAllStorageMapFilesOK) SetPayload(payload models.Maps) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageMapFilesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Maps{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAllStorageMapFilesNotFoundCode is the HTTP code returned for type GetAllStorageMapFilesNotFound +const GetAllStorageMapFilesNotFoundCode int = 404 + +/* +GetAllStorageMapFilesNotFound The specified resource was not found + +swagger:response getAllStorageMapFilesNotFound +*/ +type GetAllStorageMapFilesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageMapFilesNotFound creates GetAllStorageMapFilesNotFound with default headers values +func NewGetAllStorageMapFilesNotFound() *GetAllStorageMapFilesNotFound { + + return &GetAllStorageMapFilesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage map files not found response +func (o *GetAllStorageMapFilesNotFound) WithConfigurationVersion(configurationVersion string) *GetAllStorageMapFilesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage map files not found response +func (o *GetAllStorageMapFilesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage map files not found response +func (o *GetAllStorageMapFilesNotFound) WithPayload(payload *models.Error) *GetAllStorageMapFilesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage map files not found response +func (o *GetAllStorageMapFilesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageMapFilesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAllStorageMapFilesDefault General Error + +swagger:response getAllStorageMapFilesDefault +*/ +type GetAllStorageMapFilesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageMapFilesDefault creates GetAllStorageMapFilesDefault with default headers values +func NewGetAllStorageMapFilesDefault(code int) *GetAllStorageMapFilesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllStorageMapFilesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all storage map files default response +func (o *GetAllStorageMapFilesDefault) WithStatusCode(code int) *GetAllStorageMapFilesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all storage map files default response +func (o *GetAllStorageMapFilesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage map files default response +func (o *GetAllStorageMapFilesDefault) WithConfigurationVersion(configurationVersion string) *GetAllStorageMapFilesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage map files default response +func (o *GetAllStorageMapFilesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage map files default response +func (o *GetAllStorageMapFilesDefault) WithPayload(payload *models.Error) *GetAllStorageMapFilesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage map files default response +func (o *GetAllStorageMapFilesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageMapFilesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_all_storage_map_files_urlbuilder.go b/operations/storage/get_all_storage_map_files_urlbuilder.go new file mode 100644 index 00000000..76cf0b2b --- /dev/null +++ b/operations/storage/get_all_storage_map_files_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllStorageMapFilesURL generates an URL for the get all storage map files operation +type GetAllStorageMapFilesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageMapFilesURL) WithBasePath(bp string) *GetAllStorageMapFilesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageMapFilesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllStorageMapFilesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/maps" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllStorageMapFilesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllStorageMapFilesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllStorageMapFilesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllStorageMapFilesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllStorageMapFilesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllStorageMapFilesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_all_storage_s_s_l_certificates.go b/operations/storage/get_all_storage_s_s_l_certificates.go new file mode 100644 index 00000000..ddd95628 --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_certificates.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllStorageSSLCertificatesHandlerFunc turns a function with the right signature into a get all storage s s l certificates handler +type GetAllStorageSSLCertificatesHandlerFunc func(GetAllStorageSSLCertificatesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllStorageSSLCertificatesHandlerFunc) Handle(params GetAllStorageSSLCertificatesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllStorageSSLCertificatesHandler interface for that can handle valid get all storage s s l certificates params +type GetAllStorageSSLCertificatesHandler interface { + Handle(GetAllStorageSSLCertificatesParams, interface{}) middleware.Responder +} + +// NewGetAllStorageSSLCertificates creates a new http.Handler for the get all storage s s l certificates operation +func NewGetAllStorageSSLCertificates(ctx *middleware.Context, handler GetAllStorageSSLCertificatesHandler) *GetAllStorageSSLCertificates { + return &GetAllStorageSSLCertificates{Context: ctx, Handler: handler} +} + +/* + GetAllStorageSSLCertificates swagger:route GET /services/haproxy/storage/ssl_certificates Storage getAllStorageSSLCertificates + +# Return all available SSL certificates on disk + +Returns all available SSL certificates on disk. +*/ +type GetAllStorageSSLCertificates struct { + Context *middleware.Context + Handler GetAllStorageSSLCertificatesHandler +} + +func (o *GetAllStorageSSLCertificates) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllStorageSSLCertificatesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_all_storage_s_s_l_certificates_parameters.go b/operations/storage/get_all_storage_s_s_l_certificates_parameters.go new file mode 100644 index 00000000..7855f026 --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_certificates_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllStorageSSLCertificatesParams creates a new GetAllStorageSSLCertificatesParams object +// +// There are no default values defined in the spec. +func NewGetAllStorageSSLCertificatesParams() GetAllStorageSSLCertificatesParams { + + return GetAllStorageSSLCertificatesParams{} +} + +// GetAllStorageSSLCertificatesParams contains all the bound params for the get all storage s s l certificates operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllStorageSSLCertificates +type GetAllStorageSSLCertificatesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllStorageSSLCertificatesParams() beforehand. +func (o *GetAllStorageSSLCertificatesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/storage/get_all_storage_s_s_l_certificates_responses.go b/operations/storage/get_all_storage_s_s_l_certificates_responses.go new file mode 100644 index 00000000..a430027d --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_certificates_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllStorageSSLCertificatesOKCode is the HTTP code returned for type GetAllStorageSSLCertificatesOK +const GetAllStorageSSLCertificatesOKCode int = 200 + +/* +GetAllStorageSSLCertificatesOK Successful operation + +swagger:response getAllStorageSSLCertificatesOK +*/ +type GetAllStorageSSLCertificatesOK struct { + + /* + In: Body + */ + Payload models.SslCertificates `json:"body,omitempty"` +} + +// NewGetAllStorageSSLCertificatesOK creates GetAllStorageSSLCertificatesOK with default headers values +func NewGetAllStorageSSLCertificatesOK() *GetAllStorageSSLCertificatesOK { + + return &GetAllStorageSSLCertificatesOK{} +} + +// WithPayload adds the payload to the get all storage s s l certificates o k response +func (o *GetAllStorageSSLCertificatesOK) WithPayload(payload models.SslCertificates) *GetAllStorageSSLCertificatesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage s s l certificates o k response +func (o *GetAllStorageSSLCertificatesOK) SetPayload(payload models.SslCertificates) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageSSLCertificatesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCertificates{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAllStorageSSLCertificatesNotFoundCode is the HTTP code returned for type GetAllStorageSSLCertificatesNotFound +const GetAllStorageSSLCertificatesNotFoundCode int = 404 + +/* +GetAllStorageSSLCertificatesNotFound The specified resource was not found + +swagger:response getAllStorageSSLCertificatesNotFound +*/ +type GetAllStorageSSLCertificatesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageSSLCertificatesNotFound creates GetAllStorageSSLCertificatesNotFound with default headers values +func NewGetAllStorageSSLCertificatesNotFound() *GetAllStorageSSLCertificatesNotFound { + + return &GetAllStorageSSLCertificatesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage s s l certificates not found response +func (o *GetAllStorageSSLCertificatesNotFound) WithConfigurationVersion(configurationVersion string) *GetAllStorageSSLCertificatesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage s s l certificates not found response +func (o *GetAllStorageSSLCertificatesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage s s l certificates not found response +func (o *GetAllStorageSSLCertificatesNotFound) WithPayload(payload *models.Error) *GetAllStorageSSLCertificatesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage s s l certificates not found response +func (o *GetAllStorageSSLCertificatesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageSSLCertificatesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAllStorageSSLCertificatesDefault General Error + +swagger:response getAllStorageSSLCertificatesDefault +*/ +type GetAllStorageSSLCertificatesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageSSLCertificatesDefault creates GetAllStorageSSLCertificatesDefault with default headers values +func NewGetAllStorageSSLCertificatesDefault(code int) *GetAllStorageSSLCertificatesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllStorageSSLCertificatesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all storage s s l certificates default response +func (o *GetAllStorageSSLCertificatesDefault) WithStatusCode(code int) *GetAllStorageSSLCertificatesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all storage s s l certificates default response +func (o *GetAllStorageSSLCertificatesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage s s l certificates default response +func (o *GetAllStorageSSLCertificatesDefault) WithConfigurationVersion(configurationVersion string) *GetAllStorageSSLCertificatesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage s s l certificates default response +func (o *GetAllStorageSSLCertificatesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage s s l certificates default response +func (o *GetAllStorageSSLCertificatesDefault) WithPayload(payload *models.Error) *GetAllStorageSSLCertificatesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage s s l certificates default response +func (o *GetAllStorageSSLCertificatesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageSSLCertificatesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_all_storage_s_s_l_certificates_urlbuilder.go b/operations/storage/get_all_storage_s_s_l_certificates_urlbuilder.go new file mode 100644 index 00000000..9fefc422 --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_certificates_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllStorageSSLCertificatesURL generates an URL for the get all storage s s l certificates operation +type GetAllStorageSSLCertificatesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageSSLCertificatesURL) WithBasePath(bp string) *GetAllStorageSSLCertificatesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageSSLCertificatesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllStorageSSLCertificatesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_certificates" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllStorageSSLCertificatesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllStorageSSLCertificatesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllStorageSSLCertificatesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllStorageSSLCertificatesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllStorageSSLCertificatesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllStorageSSLCertificatesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_all_storage_s_s_l_crt_list_files.go b/operations/storage/get_all_storage_s_s_l_crt_list_files.go new file mode 100644 index 00000000..665b4aea --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_crt_list_files.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllStorageSSLCrtListFilesHandlerFunc turns a function with the right signature into a get all storage s s l crt list files handler +type GetAllStorageSSLCrtListFilesHandlerFunc func(GetAllStorageSSLCrtListFilesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllStorageSSLCrtListFilesHandlerFunc) Handle(params GetAllStorageSSLCrtListFilesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllStorageSSLCrtListFilesHandler interface for that can handle valid get all storage s s l crt list files params +type GetAllStorageSSLCrtListFilesHandler interface { + Handle(GetAllStorageSSLCrtListFilesParams, interface{}) middleware.Responder +} + +// NewGetAllStorageSSLCrtListFiles creates a new http.Handler for the get all storage s s l crt list files operation +func NewGetAllStorageSSLCrtListFiles(ctx *middleware.Context, handler GetAllStorageSSLCrtListFilesHandler) *GetAllStorageSSLCrtListFiles { + return &GetAllStorageSSLCrtListFiles{Context: ctx, Handler: handler} +} + +/* + GetAllStorageSSLCrtListFiles swagger:route GET /services/haproxy/storage/ssl_crt_lists Storage getAllStorageSSLCrtListFiles + +# Return all available certificate lists on disk + +Returns all available certificate lists on disk. +*/ +type GetAllStorageSSLCrtListFiles struct { + Context *middleware.Context + Handler GetAllStorageSSLCrtListFilesHandler +} + +func (o *GetAllStorageSSLCrtListFiles) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllStorageSSLCrtListFilesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_all_storage_s_s_l_crt_list_files_parameters.go b/operations/storage/get_all_storage_s_s_l_crt_list_files_parameters.go new file mode 100644 index 00000000..523303ac --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_crt_list_files_parameters.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetAllStorageSSLCrtListFilesParams creates a new GetAllStorageSSLCrtListFilesParams object +// +// There are no default values defined in the spec. +func NewGetAllStorageSSLCrtListFilesParams() GetAllStorageSSLCrtListFilesParams { + + return GetAllStorageSSLCrtListFilesParams{} +} + +// GetAllStorageSSLCrtListFilesParams contains all the bound params for the get all storage s s l crt list files operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllStorageSSLCrtListFiles +type GetAllStorageSSLCrtListFilesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllStorageSSLCrtListFilesParams() beforehand. +func (o *GetAllStorageSSLCrtListFilesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/operations/storage/get_all_storage_s_s_l_crt_list_files_responses.go b/operations/storage/get_all_storage_s_s_l_crt_list_files_responses.go new file mode 100644 index 00000000..fcc9cc04 --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_crt_list_files_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllStorageSSLCrtListFilesOKCode is the HTTP code returned for type GetAllStorageSSLCrtListFilesOK +const GetAllStorageSSLCrtListFilesOKCode int = 200 + +/* +GetAllStorageSSLCrtListFilesOK Successful operation + +swagger:response getAllStorageSSLCrtListFilesOK +*/ +type GetAllStorageSSLCrtListFilesOK struct { + + /* + In: Body + */ + Payload models.SslCrtListFiles `json:"body,omitempty"` +} + +// NewGetAllStorageSSLCrtListFilesOK creates GetAllStorageSSLCrtListFilesOK with default headers values +func NewGetAllStorageSSLCrtListFilesOK() *GetAllStorageSSLCrtListFilesOK { + + return &GetAllStorageSSLCrtListFilesOK{} +} + +// WithPayload adds the payload to the get all storage s s l crt list files o k response +func (o *GetAllStorageSSLCrtListFilesOK) WithPayload(payload models.SslCrtListFiles) *GetAllStorageSSLCrtListFilesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage s s l crt list files o k response +func (o *GetAllStorageSSLCrtListFilesOK) SetPayload(payload models.SslCrtListFiles) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageSSLCrtListFilesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCrtListFiles{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetAllStorageSSLCrtListFilesNotFoundCode is the HTTP code returned for type GetAllStorageSSLCrtListFilesNotFound +const GetAllStorageSSLCrtListFilesNotFoundCode int = 404 + +/* +GetAllStorageSSLCrtListFilesNotFound The specified resource was not found + +swagger:response getAllStorageSSLCrtListFilesNotFound +*/ +type GetAllStorageSSLCrtListFilesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageSSLCrtListFilesNotFound creates GetAllStorageSSLCrtListFilesNotFound with default headers values +func NewGetAllStorageSSLCrtListFilesNotFound() *GetAllStorageSSLCrtListFilesNotFound { + + return &GetAllStorageSSLCrtListFilesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage s s l crt list files not found response +func (o *GetAllStorageSSLCrtListFilesNotFound) WithConfigurationVersion(configurationVersion string) *GetAllStorageSSLCrtListFilesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage s s l crt list files not found response +func (o *GetAllStorageSSLCrtListFilesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage s s l crt list files not found response +func (o *GetAllStorageSSLCrtListFilesNotFound) WithPayload(payload *models.Error) *GetAllStorageSSLCrtListFilesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage s s l crt list files not found response +func (o *GetAllStorageSSLCrtListFilesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageSSLCrtListFilesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetAllStorageSSLCrtListFilesDefault General Error + +swagger:response getAllStorageSSLCrtListFilesDefault +*/ +type GetAllStorageSSLCrtListFilesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllStorageSSLCrtListFilesDefault creates GetAllStorageSSLCrtListFilesDefault with default headers values +func NewGetAllStorageSSLCrtListFilesDefault(code int) *GetAllStorageSSLCrtListFilesDefault { + if code <= 0 { + code = 500 + } + + return &GetAllStorageSSLCrtListFilesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all storage s s l crt list files default response +func (o *GetAllStorageSSLCrtListFilesDefault) WithStatusCode(code int) *GetAllStorageSSLCrtListFilesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all storage s s l crt list files default response +func (o *GetAllStorageSSLCrtListFilesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all storage s s l crt list files default response +func (o *GetAllStorageSSLCrtListFilesDefault) WithConfigurationVersion(configurationVersion string) *GetAllStorageSSLCrtListFilesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all storage s s l crt list files default response +func (o *GetAllStorageSSLCrtListFilesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all storage s s l crt list files default response +func (o *GetAllStorageSSLCrtListFilesDefault) WithPayload(payload *models.Error) *GetAllStorageSSLCrtListFilesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all storage s s l crt list files default response +func (o *GetAllStorageSSLCrtListFilesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllStorageSSLCrtListFilesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_all_storage_s_s_l_crt_list_files_urlbuilder.go b/operations/storage/get_all_storage_s_s_l_crt_list_files_urlbuilder.go new file mode 100644 index 00000000..3205d184 --- /dev/null +++ b/operations/storage/get_all_storage_s_s_l_crt_list_files_urlbuilder.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetAllStorageSSLCrtListFilesURL generates an URL for the get all storage s s l crt list files operation +type GetAllStorageSSLCrtListFilesURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageSSLCrtListFilesURL) WithBasePath(bp string) *GetAllStorageSSLCrtListFilesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllStorageSSLCrtListFilesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllStorageSSLCrtListFilesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllStorageSSLCrtListFilesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllStorageSSLCrtListFilesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllStorageSSLCrtListFilesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllStorageSSLCrtListFilesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllStorageSSLCrtListFilesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllStorageSSLCrtListFilesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_one_storage_general_file.go b/operations/storage/get_one_storage_general_file.go new file mode 100644 index 00000000..e22c4aa7 --- /dev/null +++ b/operations/storage/get_one_storage_general_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetOneStorageGeneralFileHandlerFunc turns a function with the right signature into a get one storage general file handler +type GetOneStorageGeneralFileHandlerFunc func(GetOneStorageGeneralFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetOneStorageGeneralFileHandlerFunc) Handle(params GetOneStorageGeneralFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetOneStorageGeneralFileHandler interface for that can handle valid get one storage general file params +type GetOneStorageGeneralFileHandler interface { + Handle(GetOneStorageGeneralFileParams, interface{}) middleware.Responder +} + +// NewGetOneStorageGeneralFile creates a new http.Handler for the get one storage general file operation +func NewGetOneStorageGeneralFile(ctx *middleware.Context, handler GetOneStorageGeneralFileHandler) *GetOneStorageGeneralFile { + return &GetOneStorageGeneralFile{Context: ctx, Handler: handler} +} + +/* + GetOneStorageGeneralFile swagger:route GET /services/haproxy/storage/general/{name} Storage getOneStorageGeneralFile + +# Return the contents of one managed general use file from disk + +Returns the contents of one managed general use file from disk +*/ +type GetOneStorageGeneralFile struct { + Context *middleware.Context + Handler GetOneStorageGeneralFileHandler +} + +func (o *GetOneStorageGeneralFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetOneStorageGeneralFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_one_storage_general_file_parameters.go b/operations/storage/get_one_storage_general_file_parameters.go new file mode 100644 index 00000000..d12cb8d6 --- /dev/null +++ b/operations/storage/get_one_storage_general_file_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetOneStorageGeneralFileParams creates a new GetOneStorageGeneralFileParams object +// +// There are no default values defined in the spec. +func NewGetOneStorageGeneralFileParams() GetOneStorageGeneralFileParams { + + return GetOneStorageGeneralFileParams{} +} + +// GetOneStorageGeneralFileParams contains all the bound params for the get one storage general file operation +// typically these are obtained from a http.Request +// +// swagger:parameters getOneStorageGeneralFile +type GetOneStorageGeneralFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*General use file storage_name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetOneStorageGeneralFileParams() beforehand. +func (o *GetOneStorageGeneralFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetOneStorageGeneralFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/get_one_storage_general_file_responses.go b/operations/storage/get_one_storage_general_file_responses.go new file mode 100644 index 00000000..6800e3aa --- /dev/null +++ b/operations/storage/get_one_storage_general_file_responses.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetOneStorageGeneralFileOKCode is the HTTP code returned for type GetOneStorageGeneralFileOK +const GetOneStorageGeneralFileOKCode int = 200 + +/* +GetOneStorageGeneralFileOK Successful operation + +swagger:response getOneStorageGeneralFileOK +*/ +type GetOneStorageGeneralFileOK struct { + + /* + In: Body + */ + Payload io.ReadCloser `json:"body,omitempty"` +} + +// NewGetOneStorageGeneralFileOK creates GetOneStorageGeneralFileOK with default headers values +func NewGetOneStorageGeneralFileOK() *GetOneStorageGeneralFileOK { + + return &GetOneStorageGeneralFileOK{} +} + +// WithPayload adds the payload to the get one storage general file o k response +func (o *GetOneStorageGeneralFileOK) WithPayload(payload io.ReadCloser) *GetOneStorageGeneralFileOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage general file o k response +func (o *GetOneStorageGeneralFileOK) SetPayload(payload io.ReadCloser) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageGeneralFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetOneStorageGeneralFileNotFoundCode is the HTTP code returned for type GetOneStorageGeneralFileNotFound +const GetOneStorageGeneralFileNotFoundCode int = 404 + +/* +GetOneStorageGeneralFileNotFound The specified resource was not found + +swagger:response getOneStorageGeneralFileNotFound +*/ +type GetOneStorageGeneralFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageGeneralFileNotFound creates GetOneStorageGeneralFileNotFound with default headers values +func NewGetOneStorageGeneralFileNotFound() *GetOneStorageGeneralFileNotFound { + + return &GetOneStorageGeneralFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage general file not found response +func (o *GetOneStorageGeneralFileNotFound) WithConfigurationVersion(configurationVersion string) *GetOneStorageGeneralFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage general file not found response +func (o *GetOneStorageGeneralFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage general file not found response +func (o *GetOneStorageGeneralFileNotFound) WithPayload(payload *models.Error) *GetOneStorageGeneralFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage general file not found response +func (o *GetOneStorageGeneralFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageGeneralFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetOneStorageGeneralFileDefault General Error + +swagger:response getOneStorageGeneralFileDefault +*/ +type GetOneStorageGeneralFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageGeneralFileDefault creates GetOneStorageGeneralFileDefault with default headers values +func NewGetOneStorageGeneralFileDefault(code int) *GetOneStorageGeneralFileDefault { + if code <= 0 { + code = 500 + } + + return &GetOneStorageGeneralFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get one storage general file default response +func (o *GetOneStorageGeneralFileDefault) WithStatusCode(code int) *GetOneStorageGeneralFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get one storage general file default response +func (o *GetOneStorageGeneralFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage general file default response +func (o *GetOneStorageGeneralFileDefault) WithConfigurationVersion(configurationVersion string) *GetOneStorageGeneralFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage general file default response +func (o *GetOneStorageGeneralFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage general file default response +func (o *GetOneStorageGeneralFileDefault) WithPayload(payload *models.Error) *GetOneStorageGeneralFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage general file default response +func (o *GetOneStorageGeneralFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageGeneralFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_one_storage_general_file_urlbuilder.go b/operations/storage/get_one_storage_general_file_urlbuilder.go new file mode 100644 index 00000000..08983005 --- /dev/null +++ b/operations/storage/get_one_storage_general_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetOneStorageGeneralFileURL generates an URL for the get one storage general file operation +type GetOneStorageGeneralFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageGeneralFileURL) WithBasePath(bp string) *GetOneStorageGeneralFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageGeneralFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetOneStorageGeneralFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/general/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetOneStorageGeneralFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetOneStorageGeneralFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetOneStorageGeneralFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetOneStorageGeneralFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetOneStorageGeneralFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetOneStorageGeneralFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetOneStorageGeneralFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_one_storage_map.go b/operations/storage/get_one_storage_map.go new file mode 100644 index 00000000..592cacd2 --- /dev/null +++ b/operations/storage/get_one_storage_map.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetOneStorageMapHandlerFunc turns a function with the right signature into a get one storage map handler +type GetOneStorageMapHandlerFunc func(GetOneStorageMapParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetOneStorageMapHandlerFunc) Handle(params GetOneStorageMapParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetOneStorageMapHandler interface for that can handle valid get one storage map params +type GetOneStorageMapHandler interface { + Handle(GetOneStorageMapParams, interface{}) middleware.Responder +} + +// NewGetOneStorageMap creates a new http.Handler for the get one storage map operation +func NewGetOneStorageMap(ctx *middleware.Context, handler GetOneStorageMapHandler) *GetOneStorageMap { + return &GetOneStorageMap{Context: ctx, Handler: handler} +} + +/* + GetOneStorageMap swagger:route GET /services/haproxy/storage/maps/{name} Storage getOneStorageMap + +# Return the contents of one managed map file from disk + +Returns the contents of one managed map file from disk +*/ +type GetOneStorageMap struct { + Context *middleware.Context + Handler GetOneStorageMapHandler +} + +func (o *GetOneStorageMap) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetOneStorageMapParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_one_storage_map_parameters.go b/operations/storage/get_one_storage_map_parameters.go new file mode 100644 index 00000000..551543f4 --- /dev/null +++ b/operations/storage/get_one_storage_map_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetOneStorageMapParams creates a new GetOneStorageMapParams object +// +// There are no default values defined in the spec. +func NewGetOneStorageMapParams() GetOneStorageMapParams { + + return GetOneStorageMapParams{} +} + +// GetOneStorageMapParams contains all the bound params for the get one storage map operation +// typically these are obtained from a http.Request +// +// swagger:parameters getOneStorageMap +type GetOneStorageMapParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Map file storage_name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetOneStorageMapParams() beforehand. +func (o *GetOneStorageMapParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetOneStorageMapParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/get_one_storage_map_responses.go b/operations/storage/get_one_storage_map_responses.go new file mode 100644 index 00000000..3d2f90ff --- /dev/null +++ b/operations/storage/get_one_storage_map_responses.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetOneStorageMapOKCode is the HTTP code returned for type GetOneStorageMapOK +const GetOneStorageMapOKCode int = 200 + +/* +GetOneStorageMapOK Successful operation + +swagger:response getOneStorageMapOK +*/ +type GetOneStorageMapOK struct { + + /* + In: Body + */ + Payload io.ReadCloser `json:"body,omitempty"` +} + +// NewGetOneStorageMapOK creates GetOneStorageMapOK with default headers values +func NewGetOneStorageMapOK() *GetOneStorageMapOK { + + return &GetOneStorageMapOK{} +} + +// WithPayload adds the payload to the get one storage map o k response +func (o *GetOneStorageMapOK) WithPayload(payload io.ReadCloser) *GetOneStorageMapOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage map o k response +func (o *GetOneStorageMapOK) SetPayload(payload io.ReadCloser) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageMapOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetOneStorageMapNotFoundCode is the HTTP code returned for type GetOneStorageMapNotFound +const GetOneStorageMapNotFoundCode int = 404 + +/* +GetOneStorageMapNotFound The specified resource was not found + +swagger:response getOneStorageMapNotFound +*/ +type GetOneStorageMapNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageMapNotFound creates GetOneStorageMapNotFound with default headers values +func NewGetOneStorageMapNotFound() *GetOneStorageMapNotFound { + + return &GetOneStorageMapNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage map not found response +func (o *GetOneStorageMapNotFound) WithConfigurationVersion(configurationVersion string) *GetOneStorageMapNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage map not found response +func (o *GetOneStorageMapNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage map not found response +func (o *GetOneStorageMapNotFound) WithPayload(payload *models.Error) *GetOneStorageMapNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage map not found response +func (o *GetOneStorageMapNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageMapNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetOneStorageMapDefault General Error + +swagger:response getOneStorageMapDefault +*/ +type GetOneStorageMapDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageMapDefault creates GetOneStorageMapDefault with default headers values +func NewGetOneStorageMapDefault(code int) *GetOneStorageMapDefault { + if code <= 0 { + code = 500 + } + + return &GetOneStorageMapDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get one storage map default response +func (o *GetOneStorageMapDefault) WithStatusCode(code int) *GetOneStorageMapDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get one storage map default response +func (o *GetOneStorageMapDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage map default response +func (o *GetOneStorageMapDefault) WithConfigurationVersion(configurationVersion string) *GetOneStorageMapDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage map default response +func (o *GetOneStorageMapDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage map default response +func (o *GetOneStorageMapDefault) WithPayload(payload *models.Error) *GetOneStorageMapDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage map default response +func (o *GetOneStorageMapDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageMapDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_one_storage_map_urlbuilder.go b/operations/storage/get_one_storage_map_urlbuilder.go new file mode 100644 index 00000000..95692e05 --- /dev/null +++ b/operations/storage/get_one_storage_map_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetOneStorageMapURL generates an URL for the get one storage map operation +type GetOneStorageMapURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageMapURL) WithBasePath(bp string) *GetOneStorageMapURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageMapURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetOneStorageMapURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/maps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetOneStorageMapURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetOneStorageMapURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetOneStorageMapURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetOneStorageMapURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetOneStorageMapURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetOneStorageMapURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetOneStorageMapURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_one_storage_s_s_l_certificate.go b/operations/storage/get_one_storage_s_s_l_certificate.go new file mode 100644 index 00000000..1ea58439 --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_certificate.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetOneStorageSSLCertificateHandlerFunc turns a function with the right signature into a get one storage s s l certificate handler +type GetOneStorageSSLCertificateHandlerFunc func(GetOneStorageSSLCertificateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetOneStorageSSLCertificateHandlerFunc) Handle(params GetOneStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetOneStorageSSLCertificateHandler interface for that can handle valid get one storage s s l certificate params +type GetOneStorageSSLCertificateHandler interface { + Handle(GetOneStorageSSLCertificateParams, interface{}) middleware.Responder +} + +// NewGetOneStorageSSLCertificate creates a new http.Handler for the get one storage s s l certificate operation +func NewGetOneStorageSSLCertificate(ctx *middleware.Context, handler GetOneStorageSSLCertificateHandler) *GetOneStorageSSLCertificate { + return &GetOneStorageSSLCertificate{Context: ctx, Handler: handler} +} + +/* + GetOneStorageSSLCertificate swagger:route GET /services/haproxy/storage/ssl_certificates/{name} Storage getOneStorageSSLCertificate + +# Return one SSL certificate from disk + +Returns one SSL certificate from disk. +*/ +type GetOneStorageSSLCertificate struct { + Context *middleware.Context + Handler GetOneStorageSSLCertificateHandler +} + +func (o *GetOneStorageSSLCertificate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetOneStorageSSLCertificateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_one_storage_s_s_l_certificate_parameters.go b/operations/storage/get_one_storage_s_s_l_certificate_parameters.go new file mode 100644 index 00000000..f83f0e51 --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_certificate_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetOneStorageSSLCertificateParams creates a new GetOneStorageSSLCertificateParams object +// +// There are no default values defined in the spec. +func NewGetOneStorageSSLCertificateParams() GetOneStorageSSLCertificateParams { + + return GetOneStorageSSLCertificateParams{} +} + +// GetOneStorageSSLCertificateParams contains all the bound params for the get one storage s s l certificate operation +// typically these are obtained from a http.Request +// +// swagger:parameters getOneStorageSSLCertificate +type GetOneStorageSSLCertificateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL certificate name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetOneStorageSSLCertificateParams() beforehand. +func (o *GetOneStorageSSLCertificateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetOneStorageSSLCertificateParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/get_one_storage_s_s_l_certificate_responses.go b/operations/storage/get_one_storage_s_s_l_certificate_responses.go new file mode 100644 index 00000000..5bacf8ed --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_certificate_responses.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetOneStorageSSLCertificateOKCode is the HTTP code returned for type GetOneStorageSSLCertificateOK +const GetOneStorageSSLCertificateOKCode int = 200 + +/* +GetOneStorageSSLCertificateOK Successful operation + +swagger:response getOneStorageSSLCertificateOK +*/ +type GetOneStorageSSLCertificateOK struct { + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewGetOneStorageSSLCertificateOK creates GetOneStorageSSLCertificateOK with default headers values +func NewGetOneStorageSSLCertificateOK() *GetOneStorageSSLCertificateOK { + + return &GetOneStorageSSLCertificateOK{} +} + +// WithPayload adds the payload to the get one storage s s l certificate o k response +func (o *GetOneStorageSSLCertificateOK) WithPayload(payload *models.SslCertificate) *GetOneStorageSSLCertificateOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage s s l certificate o k response +func (o *GetOneStorageSSLCertificateOK) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageSSLCertificateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetOneStorageSSLCertificateNotFoundCode is the HTTP code returned for type GetOneStorageSSLCertificateNotFound +const GetOneStorageSSLCertificateNotFoundCode int = 404 + +/* +GetOneStorageSSLCertificateNotFound The specified resource was not found + +swagger:response getOneStorageSSLCertificateNotFound +*/ +type GetOneStorageSSLCertificateNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageSSLCertificateNotFound creates GetOneStorageSSLCertificateNotFound with default headers values +func NewGetOneStorageSSLCertificateNotFound() *GetOneStorageSSLCertificateNotFound { + + return &GetOneStorageSSLCertificateNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage s s l certificate not found response +func (o *GetOneStorageSSLCertificateNotFound) WithConfigurationVersion(configurationVersion string) *GetOneStorageSSLCertificateNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage s s l certificate not found response +func (o *GetOneStorageSSLCertificateNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage s s l certificate not found response +func (o *GetOneStorageSSLCertificateNotFound) WithPayload(payload *models.Error) *GetOneStorageSSLCertificateNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage s s l certificate not found response +func (o *GetOneStorageSSLCertificateNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageSSLCertificateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetOneStorageSSLCertificateDefault General Error + +swagger:response getOneStorageSSLCertificateDefault +*/ +type GetOneStorageSSLCertificateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageSSLCertificateDefault creates GetOneStorageSSLCertificateDefault with default headers values +func NewGetOneStorageSSLCertificateDefault(code int) *GetOneStorageSSLCertificateDefault { + if code <= 0 { + code = 500 + } + + return &GetOneStorageSSLCertificateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get one storage s s l certificate default response +func (o *GetOneStorageSSLCertificateDefault) WithStatusCode(code int) *GetOneStorageSSLCertificateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get one storage s s l certificate default response +func (o *GetOneStorageSSLCertificateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage s s l certificate default response +func (o *GetOneStorageSSLCertificateDefault) WithConfigurationVersion(configurationVersion string) *GetOneStorageSSLCertificateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage s s l certificate default response +func (o *GetOneStorageSSLCertificateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage s s l certificate default response +func (o *GetOneStorageSSLCertificateDefault) WithPayload(payload *models.Error) *GetOneStorageSSLCertificateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage s s l certificate default response +func (o *GetOneStorageSSLCertificateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageSSLCertificateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_one_storage_s_s_l_certificate_urlbuilder.go b/operations/storage/get_one_storage_s_s_l_certificate_urlbuilder.go new file mode 100644 index 00000000..7433e883 --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_certificate_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetOneStorageSSLCertificateURL generates an URL for the get one storage s s l certificate operation +type GetOneStorageSSLCertificateURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageSSLCertificateURL) WithBasePath(bp string) *GetOneStorageSSLCertificateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageSSLCertificateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetOneStorageSSLCertificateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_certificates/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetOneStorageSSLCertificateURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetOneStorageSSLCertificateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetOneStorageSSLCertificateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetOneStorageSSLCertificateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetOneStorageSSLCertificateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetOneStorageSSLCertificateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetOneStorageSSLCertificateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_one_storage_s_s_l_crt_list_file.go b/operations/storage/get_one_storage_s_s_l_crt_list_file.go new file mode 100644 index 00000000..03e272e0 --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_crt_list_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetOneStorageSSLCrtListFileHandlerFunc turns a function with the right signature into a get one storage s s l crt list file handler +type GetOneStorageSSLCrtListFileHandlerFunc func(GetOneStorageSSLCrtListFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetOneStorageSSLCrtListFileHandlerFunc) Handle(params GetOneStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetOneStorageSSLCrtListFileHandler interface for that can handle valid get one storage s s l crt list file params +type GetOneStorageSSLCrtListFileHandler interface { + Handle(GetOneStorageSSLCrtListFileParams, interface{}) middleware.Responder +} + +// NewGetOneStorageSSLCrtListFile creates a new http.Handler for the get one storage s s l crt list file operation +func NewGetOneStorageSSLCrtListFile(ctx *middleware.Context, handler GetOneStorageSSLCrtListFileHandler) *GetOneStorageSSLCrtListFile { + return &GetOneStorageSSLCrtListFile{Context: ctx, Handler: handler} +} + +/* + GetOneStorageSSLCrtListFile swagger:route GET /services/haproxy/storage/ssl_crt_lists/{name} Storage getOneStorageSSLCrtListFile + +# Return one certificate list from disk + +Returns one certificate list from disk. +*/ +type GetOneStorageSSLCrtListFile struct { + Context *middleware.Context + Handler GetOneStorageSSLCrtListFileHandler +} + +func (o *GetOneStorageSSLCrtListFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetOneStorageSSLCrtListFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_one_storage_s_s_l_crt_list_file_parameters.go b/operations/storage/get_one_storage_s_s_l_crt_list_file_parameters.go new file mode 100644 index 00000000..1ecaf089 --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_crt_list_file_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetOneStorageSSLCrtListFileParams creates a new GetOneStorageSSLCrtListFileParams object +// +// There are no default values defined in the spec. +func NewGetOneStorageSSLCrtListFileParams() GetOneStorageSSLCrtListFileParams { + + return GetOneStorageSSLCrtListFileParams{} +} + +// GetOneStorageSSLCrtListFileParams contains all the bound params for the get one storage s s l crt list file operation +// typically these are obtained from a http.Request +// +// swagger:parameters getOneStorageSSLCrtListFile +type GetOneStorageSSLCrtListFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Certificate list name + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetOneStorageSSLCrtListFileParams() beforehand. +func (o *GetOneStorageSSLCrtListFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetOneStorageSSLCrtListFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/get_one_storage_s_s_l_crt_list_file_responses.go b/operations/storage/get_one_storage_s_s_l_crt_list_file_responses.go new file mode 100644 index 00000000..6847a95a --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_crt_list_file_responses.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetOneStorageSSLCrtListFileOKCode is the HTTP code returned for type GetOneStorageSSLCrtListFileOK +const GetOneStorageSSLCrtListFileOKCode int = 200 + +/* +GetOneStorageSSLCrtListFileOK Successful operation + +swagger:response getOneStorageSSLCrtListFileOK +*/ +type GetOneStorageSSLCrtListFileOK struct { + + /* + In: Body + */ + Payload io.ReadCloser `json:"body,omitempty"` +} + +// NewGetOneStorageSSLCrtListFileOK creates GetOneStorageSSLCrtListFileOK with default headers values +func NewGetOneStorageSSLCrtListFileOK() *GetOneStorageSSLCrtListFileOK { + + return &GetOneStorageSSLCrtListFileOK{} +} + +// WithPayload adds the payload to the get one storage s s l crt list file o k response +func (o *GetOneStorageSSLCrtListFileOK) WithPayload(payload io.ReadCloser) *GetOneStorageSSLCrtListFileOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage s s l crt list file o k response +func (o *GetOneStorageSSLCrtListFileOK) SetPayload(payload io.ReadCloser) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageSSLCrtListFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetOneStorageSSLCrtListFileNotFoundCode is the HTTP code returned for type GetOneStorageSSLCrtListFileNotFound +const GetOneStorageSSLCrtListFileNotFoundCode int = 404 + +/* +GetOneStorageSSLCrtListFileNotFound The specified resource was not found + +swagger:response getOneStorageSSLCrtListFileNotFound +*/ +type GetOneStorageSSLCrtListFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageSSLCrtListFileNotFound creates GetOneStorageSSLCrtListFileNotFound with default headers values +func NewGetOneStorageSSLCrtListFileNotFound() *GetOneStorageSSLCrtListFileNotFound { + + return &GetOneStorageSSLCrtListFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage s s l crt list file not found response +func (o *GetOneStorageSSLCrtListFileNotFound) WithConfigurationVersion(configurationVersion string) *GetOneStorageSSLCrtListFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage s s l crt list file not found response +func (o *GetOneStorageSSLCrtListFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage s s l crt list file not found response +func (o *GetOneStorageSSLCrtListFileNotFound) WithPayload(payload *models.Error) *GetOneStorageSSLCrtListFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage s s l crt list file not found response +func (o *GetOneStorageSSLCrtListFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageSSLCrtListFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetOneStorageSSLCrtListFileDefault General Error + +swagger:response getOneStorageSSLCrtListFileDefault +*/ +type GetOneStorageSSLCrtListFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetOneStorageSSLCrtListFileDefault creates GetOneStorageSSLCrtListFileDefault with default headers values +func NewGetOneStorageSSLCrtListFileDefault(code int) *GetOneStorageSSLCrtListFileDefault { + if code <= 0 { + code = 500 + } + + return &GetOneStorageSSLCrtListFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get one storage s s l crt list file default response +func (o *GetOneStorageSSLCrtListFileDefault) WithStatusCode(code int) *GetOneStorageSSLCrtListFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get one storage s s l crt list file default response +func (o *GetOneStorageSSLCrtListFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get one storage s s l crt list file default response +func (o *GetOneStorageSSLCrtListFileDefault) WithConfigurationVersion(configurationVersion string) *GetOneStorageSSLCrtListFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get one storage s s l crt list file default response +func (o *GetOneStorageSSLCrtListFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get one storage s s l crt list file default response +func (o *GetOneStorageSSLCrtListFileDefault) WithPayload(payload *models.Error) *GetOneStorageSSLCrtListFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get one storage s s l crt list file default response +func (o *GetOneStorageSSLCrtListFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetOneStorageSSLCrtListFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_one_storage_s_s_l_crt_list_file_urlbuilder.go b/operations/storage/get_one_storage_s_s_l_crt_list_file_urlbuilder.go new file mode 100644 index 00000000..1b664e40 --- /dev/null +++ b/operations/storage/get_one_storage_s_s_l_crt_list_file_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetOneStorageSSLCrtListFileURL generates an URL for the get one storage s s l crt list file operation +type GetOneStorageSSLCrtListFileURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageSSLCrtListFileURL) WithBasePath(bp string) *GetOneStorageSSLCrtListFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetOneStorageSSLCrtListFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetOneStorageSSLCrtListFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetOneStorageSSLCrtListFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetOneStorageSSLCrtListFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetOneStorageSSLCrtListFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetOneStorageSSLCrtListFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetOneStorageSSLCrtListFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetOneStorageSSLCrtListFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetOneStorageSSLCrtListFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/get_storage_s_s_l_crt_list_entries.go b/operations/storage/get_storage_s_s_l_crt_list_entries.go new file mode 100644 index 00000000..e795550a --- /dev/null +++ b/operations/storage/get_storage_s_s_l_crt_list_entries.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetStorageSSLCrtListEntriesHandlerFunc turns a function with the right signature into a get storage s s l crt list entries handler +type GetStorageSSLCrtListEntriesHandlerFunc func(GetStorageSSLCrtListEntriesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetStorageSSLCrtListEntriesHandlerFunc) Handle(params GetStorageSSLCrtListEntriesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetStorageSSLCrtListEntriesHandler interface for that can handle valid get storage s s l crt list entries params +type GetStorageSSLCrtListEntriesHandler interface { + Handle(GetStorageSSLCrtListEntriesParams, interface{}) middleware.Responder +} + +// NewGetStorageSSLCrtListEntries creates a new http.Handler for the get storage s s l crt list entries operation +func NewGetStorageSSLCrtListEntries(ctx *middleware.Context, handler GetStorageSSLCrtListEntriesHandler) *GetStorageSSLCrtListEntries { + return &GetStorageSSLCrtListEntries{Context: ctx, Handler: handler} +} + +/* + GetStorageSSLCrtListEntries swagger:route GET /services/haproxy/storage/ssl_crt_lists/{name}/entries Storage getStorageSSLCrtListEntries + +# Returns all the entries in a CrtList + +Returns all the entries in a certificate list. +*/ +type GetStorageSSLCrtListEntries struct { + Context *middleware.Context + Handler GetStorageSSLCrtListEntriesHandler +} + +func (o *GetStorageSSLCrtListEntries) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetStorageSSLCrtListEntriesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/get_storage_s_s_l_crt_list_entries_parameters.go b/operations/storage/get_storage_s_s_l_crt_list_entries_parameters.go new file mode 100644 index 00000000..20be6659 --- /dev/null +++ b/operations/storage/get_storage_s_s_l_crt_list_entries_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetStorageSSLCrtListEntriesParams creates a new GetStorageSSLCrtListEntriesParams object +// +// There are no default values defined in the spec. +func NewGetStorageSSLCrtListEntriesParams() GetStorageSSLCrtListEntriesParams { + + return GetStorageSSLCrtListEntriesParams{} +} + +// GetStorageSSLCrtListEntriesParams contains all the bound params for the get storage s s l crt list entries operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetStorageSSLCrtListEntries +type GetStorageSSLCrtListEntriesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*SSL crt-list file + Required: true + In: path + */ + Name string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetStorageSSLCrtListEntriesParams() beforehand. +func (o *GetStorageSSLCrtListEntriesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetStorageSSLCrtListEntriesParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} diff --git a/operations/storage/get_storage_s_s_l_crt_list_entries_responses.go b/operations/storage/get_storage_s_s_l_crt_list_entries_responses.go new file mode 100644 index 00000000..6e06bf68 --- /dev/null +++ b/operations/storage/get_storage_s_s_l_crt_list_entries_responses.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetStorageSSLCrtListEntriesOKCode is the HTTP code returned for type GetStorageSSLCrtListEntriesOK +const GetStorageSSLCrtListEntriesOKCode int = 200 + +/* +GetStorageSSLCrtListEntriesOK Successful operation + +swagger:response getStorageSSLCrtListEntriesOK +*/ +type GetStorageSSLCrtListEntriesOK struct { + + /* + In: Body + */ + Payload models.SslCrtListEntries `json:"body,omitempty"` +} + +// NewGetStorageSSLCrtListEntriesOK creates GetStorageSSLCrtListEntriesOK with default headers values +func NewGetStorageSSLCrtListEntriesOK() *GetStorageSSLCrtListEntriesOK { + + return &GetStorageSSLCrtListEntriesOK{} +} + +// WithPayload adds the payload to the get storage s s l crt list entries o k response +func (o *GetStorageSSLCrtListEntriesOK) WithPayload(payload models.SslCrtListEntries) *GetStorageSSLCrtListEntriesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get storage s s l crt list entries o k response +func (o *GetStorageSSLCrtListEntriesOK) SetPayload(payload models.SslCrtListEntries) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStorageSSLCrtListEntriesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.SslCrtListEntries{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// GetStorageSSLCrtListEntriesNotFoundCode is the HTTP code returned for type GetStorageSSLCrtListEntriesNotFound +const GetStorageSSLCrtListEntriesNotFoundCode int = 404 + +/* +GetStorageSSLCrtListEntriesNotFound The specified resource was not found + +swagger:response getStorageSSLCrtListEntriesNotFound +*/ +type GetStorageSSLCrtListEntriesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetStorageSSLCrtListEntriesNotFound creates GetStorageSSLCrtListEntriesNotFound with default headers values +func NewGetStorageSSLCrtListEntriesNotFound() *GetStorageSSLCrtListEntriesNotFound { + + return &GetStorageSSLCrtListEntriesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get storage s s l crt list entries not found response +func (o *GetStorageSSLCrtListEntriesNotFound) WithConfigurationVersion(configurationVersion string) *GetStorageSSLCrtListEntriesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get storage s s l crt list entries not found response +func (o *GetStorageSSLCrtListEntriesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get storage s s l crt list entries not found response +func (o *GetStorageSSLCrtListEntriesNotFound) WithPayload(payload *models.Error) *GetStorageSSLCrtListEntriesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get storage s s l crt list entries not found response +func (o *GetStorageSSLCrtListEntriesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStorageSSLCrtListEntriesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetStorageSSLCrtListEntriesDefault General Error + +swagger:response getStorageSSLCrtListEntriesDefault +*/ +type GetStorageSSLCrtListEntriesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetStorageSSLCrtListEntriesDefault creates GetStorageSSLCrtListEntriesDefault with default headers values +func NewGetStorageSSLCrtListEntriesDefault(code int) *GetStorageSSLCrtListEntriesDefault { + if code <= 0 { + code = 500 + } + + return &GetStorageSSLCrtListEntriesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get storage s s l crt list entries default response +func (o *GetStorageSSLCrtListEntriesDefault) WithStatusCode(code int) *GetStorageSSLCrtListEntriesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get storage s s l crt list entries default response +func (o *GetStorageSSLCrtListEntriesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get storage s s l crt list entries default response +func (o *GetStorageSSLCrtListEntriesDefault) WithConfigurationVersion(configurationVersion string) *GetStorageSSLCrtListEntriesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get storage s s l crt list entries default response +func (o *GetStorageSSLCrtListEntriesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get storage s s l crt list entries default response +func (o *GetStorageSSLCrtListEntriesDefault) WithPayload(payload *models.Error) *GetStorageSSLCrtListEntriesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get storage s s l crt list entries default response +func (o *GetStorageSSLCrtListEntriesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetStorageSSLCrtListEntriesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/get_storage_s_s_l_crt_list_entries_urlbuilder.go b/operations/storage/get_storage_s_s_l_crt_list_entries_urlbuilder.go new file mode 100644 index 00000000..ed4452ea --- /dev/null +++ b/operations/storage/get_storage_s_s_l_crt_list_entries_urlbuilder.go @@ -0,0 +1,114 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetStorageSSLCrtListEntriesURL generates an URL for the get storage s s l crt list entries operation +type GetStorageSSLCrtListEntriesURL struct { + Name string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStorageSSLCrtListEntriesURL) WithBasePath(bp string) *GetStorageSSLCrtListEntriesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetStorageSSLCrtListEntriesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetStorageSSLCrtListEntriesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists/{name}/entries" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetStorageSSLCrtListEntriesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetStorageSSLCrtListEntriesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetStorageSSLCrtListEntriesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetStorageSSLCrtListEntriesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetStorageSSLCrtListEntriesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetStorageSSLCrtListEntriesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetStorageSSLCrtListEntriesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/replace_storage_general_file.go b/operations/storage/replace_storage_general_file.go new file mode 100644 index 00000000..55743f99 --- /dev/null +++ b/operations/storage/replace_storage_general_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceStorageGeneralFileHandlerFunc turns a function with the right signature into a replace storage general file handler +type ReplaceStorageGeneralFileHandlerFunc func(ReplaceStorageGeneralFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceStorageGeneralFileHandlerFunc) Handle(params ReplaceStorageGeneralFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceStorageGeneralFileHandler interface for that can handle valid replace storage general file params +type ReplaceStorageGeneralFileHandler interface { + Handle(ReplaceStorageGeneralFileParams, interface{}) middleware.Responder +} + +// NewReplaceStorageGeneralFile creates a new http.Handler for the replace storage general file operation +func NewReplaceStorageGeneralFile(ctx *middleware.Context, handler ReplaceStorageGeneralFileHandler) *ReplaceStorageGeneralFile { + return &ReplaceStorageGeneralFile{Context: ctx, Handler: handler} +} + +/* + ReplaceStorageGeneralFile swagger:route PUT /services/haproxy/storage/general/{name} Storage replaceStorageGeneralFile + +# Replace contents of a managed general use file on disk + +Replaces the contents of a managed general use file on disk +*/ +type ReplaceStorageGeneralFile struct { + Context *middleware.Context + Handler ReplaceStorageGeneralFileHandler +} + +func (o *ReplaceStorageGeneralFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceStorageGeneralFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/replace_storage_general_file_parameters.go b/operations/storage/replace_storage_general_file_parameters.go new file mode 100644 index 00000000..7d0db4c7 --- /dev/null +++ b/operations/storage/replace_storage_general_file_parameters.go @@ -0,0 +1,208 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "mime/multipart" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ReplaceStorageGeneralFileMaxParseMemory sets the maximum size in bytes for +// the multipart form parser for this operation. +// +// The default value is 32 MB. +// The multipart parser stores up to this + 10MB. +var ReplaceStorageGeneralFileMaxParseMemory int64 = 32 << 20 + +// NewReplaceStorageGeneralFileParams creates a new ReplaceStorageGeneralFileParams object +// with the default values initialized. +func NewReplaceStorageGeneralFileParams() ReplaceStorageGeneralFileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + + skipReloadDefault = bool(false) + ) + + return ReplaceStorageGeneralFileParams{ + ForceReload: &forceReloadDefault, + + SkipReload: &skipReloadDefault, + } +} + +// ReplaceStorageGeneralFileParams contains all the bound params for the replace storage general file operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceStorageGeneralFile +type ReplaceStorageGeneralFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*General use file content + In: formData + */ + FileUpload io.ReadCloser + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*General use file storage_name + Required: true + In: path + */ + Name string + /*If set, no reload will be initiated after update + In: query + Default: false + */ + SkipReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceStorageGeneralFileParams() beforehand. +func (o *ReplaceStorageGeneralFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if err := r.ParseMultipartForm(ReplaceStorageGeneralFileMaxParseMemory); err != nil { + if err != http.ErrNotMultipart { + return errors.New(400, "%v", err) + } else if err := r.ParseForm(); err != nil { + return errors.New(400, "%v", err) + } + } + + fileUpload, fileUploadHeader, err := r.FormFile("file_upload") + if err != nil && err != http.ErrMissingFile { + res = append(res, errors.New(400, "reading file %q failed: %v", "fileUpload", err)) + } else if err == http.ErrMissingFile { + // no-op for missing but optional file parameter + } else if err := o.bindFileUpload(fileUpload, fileUploadHeader); err != nil { + res = append(res, err) + } else { + o.FileUpload = &runtime.File{Data: fileUpload, Header: fileUploadHeader} + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFileUpload binds file parameter FileUpload. +// +// The only supported validations on files are MinLength and MaxLength +func (o *ReplaceStorageGeneralFileParams) bindFileUpload(file multipart.File, header *multipart.FileHeader) error { + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceStorageGeneralFileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageGeneralFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceStorageGeneralFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *ReplaceStorageGeneralFileParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageGeneralFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} diff --git a/operations/storage/replace_storage_general_file_responses.go b/operations/storage/replace_storage_general_file_responses.go new file mode 100644 index 00000000..464bdfa3 --- /dev/null +++ b/operations/storage/replace_storage_general_file_responses.go @@ -0,0 +1,316 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceStorageGeneralFileAcceptedCode is the HTTP code returned for type ReplaceStorageGeneralFileAccepted +const ReplaceStorageGeneralFileAcceptedCode int = 202 + +/* +ReplaceStorageGeneralFileAccepted Configuration change accepted and reload requested + +swagger:response replaceStorageGeneralFileAccepted +*/ +type ReplaceStorageGeneralFileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewReplaceStorageGeneralFileAccepted creates ReplaceStorageGeneralFileAccepted with default headers values +func NewReplaceStorageGeneralFileAccepted() *ReplaceStorageGeneralFileAccepted { + + return &ReplaceStorageGeneralFileAccepted{} +} + +// WithReloadID adds the reloadId to the replace storage general file accepted response +func (o *ReplaceStorageGeneralFileAccepted) WithReloadID(reloadID string) *ReplaceStorageGeneralFileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace storage general file accepted response +func (o *ReplaceStorageGeneralFileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *ReplaceStorageGeneralFileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// ReplaceStorageGeneralFileNoContentCode is the HTTP code returned for type ReplaceStorageGeneralFileNoContent +const ReplaceStorageGeneralFileNoContentCode int = 204 + +/* +ReplaceStorageGeneralFileNoContent General use file replaced + +swagger:response replaceStorageGeneralFileNoContent +*/ +type ReplaceStorageGeneralFileNoContent struct { +} + +// NewReplaceStorageGeneralFileNoContent creates ReplaceStorageGeneralFileNoContent with default headers values +func NewReplaceStorageGeneralFileNoContent() *ReplaceStorageGeneralFileNoContent { + + return &ReplaceStorageGeneralFileNoContent{} +} + +// WriteResponse to the client +func (o *ReplaceStorageGeneralFileNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// ReplaceStorageGeneralFileBadRequestCode is the HTTP code returned for type ReplaceStorageGeneralFileBadRequest +const ReplaceStorageGeneralFileBadRequestCode int = 400 + +/* +ReplaceStorageGeneralFileBadRequest Bad request + +swagger:response replaceStorageGeneralFileBadRequest +*/ +type ReplaceStorageGeneralFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageGeneralFileBadRequest creates ReplaceStorageGeneralFileBadRequest with default headers values +func NewReplaceStorageGeneralFileBadRequest() *ReplaceStorageGeneralFileBadRequest { + + return &ReplaceStorageGeneralFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage general file bad request response +func (o *ReplaceStorageGeneralFileBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceStorageGeneralFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage general file bad request response +func (o *ReplaceStorageGeneralFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage general file bad request response +func (o *ReplaceStorageGeneralFileBadRequest) WithPayload(payload *models.Error) *ReplaceStorageGeneralFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage general file bad request response +func (o *ReplaceStorageGeneralFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageGeneralFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageGeneralFileNotFoundCode is the HTTP code returned for type ReplaceStorageGeneralFileNotFound +const ReplaceStorageGeneralFileNotFoundCode int = 404 + +/* +ReplaceStorageGeneralFileNotFound The specified resource was not found + +swagger:response replaceStorageGeneralFileNotFound +*/ +type ReplaceStorageGeneralFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageGeneralFileNotFound creates ReplaceStorageGeneralFileNotFound with default headers values +func NewReplaceStorageGeneralFileNotFound() *ReplaceStorageGeneralFileNotFound { + + return &ReplaceStorageGeneralFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage general file not found response +func (o *ReplaceStorageGeneralFileNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceStorageGeneralFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage general file not found response +func (o *ReplaceStorageGeneralFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage general file not found response +func (o *ReplaceStorageGeneralFileNotFound) WithPayload(payload *models.Error) *ReplaceStorageGeneralFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage general file not found response +func (o *ReplaceStorageGeneralFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageGeneralFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceStorageGeneralFileDefault General Error + +swagger:response replaceStorageGeneralFileDefault +*/ +type ReplaceStorageGeneralFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageGeneralFileDefault creates ReplaceStorageGeneralFileDefault with default headers values +func NewReplaceStorageGeneralFileDefault(code int) *ReplaceStorageGeneralFileDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceStorageGeneralFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace storage general file default response +func (o *ReplaceStorageGeneralFileDefault) WithStatusCode(code int) *ReplaceStorageGeneralFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace storage general file default response +func (o *ReplaceStorageGeneralFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage general file default response +func (o *ReplaceStorageGeneralFileDefault) WithConfigurationVersion(configurationVersion string) *ReplaceStorageGeneralFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage general file default response +func (o *ReplaceStorageGeneralFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage general file default response +func (o *ReplaceStorageGeneralFileDefault) WithPayload(payload *models.Error) *ReplaceStorageGeneralFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage general file default response +func (o *ReplaceStorageGeneralFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageGeneralFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/replace_storage_general_file_urlbuilder.go b/operations/storage/replace_storage_general_file_urlbuilder.go new file mode 100644 index 00000000..878d6435 --- /dev/null +++ b/operations/storage/replace_storage_general_file_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceStorageGeneralFileURL generates an URL for the replace storage general file operation +type ReplaceStorageGeneralFileURL struct { + Name string + + ForceReload *bool + SkipReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageGeneralFileURL) WithBasePath(bp string) *ReplaceStorageGeneralFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageGeneralFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceStorageGeneralFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/general/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceStorageGeneralFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceStorageGeneralFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceStorageGeneralFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceStorageGeneralFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceStorageGeneralFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceStorageGeneralFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceStorageGeneralFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/replace_storage_map_file.go b/operations/storage/replace_storage_map_file.go new file mode 100644 index 00000000..51e8daa8 --- /dev/null +++ b/operations/storage/replace_storage_map_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceStorageMapFileHandlerFunc turns a function with the right signature into a replace storage map file handler +type ReplaceStorageMapFileHandlerFunc func(ReplaceStorageMapFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceStorageMapFileHandlerFunc) Handle(params ReplaceStorageMapFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceStorageMapFileHandler interface for that can handle valid replace storage map file params +type ReplaceStorageMapFileHandler interface { + Handle(ReplaceStorageMapFileParams, interface{}) middleware.Responder +} + +// NewReplaceStorageMapFile creates a new http.Handler for the replace storage map file operation +func NewReplaceStorageMapFile(ctx *middleware.Context, handler ReplaceStorageMapFileHandler) *ReplaceStorageMapFile { + return &ReplaceStorageMapFile{Context: ctx, Handler: handler} +} + +/* + ReplaceStorageMapFile swagger:route PUT /services/haproxy/storage/maps/{name} Storage replaceStorageMapFile + +# Replace contents of a managed map file on disk + +Replaces the contents of a managed map file on disk +*/ +type ReplaceStorageMapFile struct { + Context *middleware.Context + Handler ReplaceStorageMapFileHandler +} + +func (o *ReplaceStorageMapFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceStorageMapFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/replace_storage_map_file_parameters.go b/operations/storage/replace_storage_map_file_parameters.go new file mode 100644 index 00000000..761ac80c --- /dev/null +++ b/operations/storage/replace_storage_map_file_parameters.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewReplaceStorageMapFileParams creates a new ReplaceStorageMapFileParams object +// with the default values initialized. +func NewReplaceStorageMapFileParams() ReplaceStorageMapFileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + + skipReloadDefault = bool(false) + ) + + return ReplaceStorageMapFileParams{ + ForceReload: &forceReloadDefault, + + SkipReload: &skipReloadDefault, + } +} + +// ReplaceStorageMapFileParams contains all the bound params for the replace storage map file operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceStorageMapFile +type ReplaceStorageMapFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data string + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Map file storage_name + Required: true + In: path + */ + Name string + /*If set, no reload will be initiated after update + In: query + Default: false + */ + SkipReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceStorageMapFileParams() beforehand. +func (o *ReplaceStorageMapFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body string + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // no validation required on inline body + o.Data = body + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceStorageMapFileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageMapFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceStorageMapFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *ReplaceStorageMapFileParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageMapFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} diff --git a/operations/storage/replace_storage_map_file_responses.go b/operations/storage/replace_storage_map_file_responses.go new file mode 100644 index 00000000..30884fb1 --- /dev/null +++ b/operations/storage/replace_storage_map_file_responses.go @@ -0,0 +1,316 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceStorageMapFileAcceptedCode is the HTTP code returned for type ReplaceStorageMapFileAccepted +const ReplaceStorageMapFileAcceptedCode int = 202 + +/* +ReplaceStorageMapFileAccepted Configuration change accepted and reload requested + +swagger:response replaceStorageMapFileAccepted +*/ +type ReplaceStorageMapFileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewReplaceStorageMapFileAccepted creates ReplaceStorageMapFileAccepted with default headers values +func NewReplaceStorageMapFileAccepted() *ReplaceStorageMapFileAccepted { + + return &ReplaceStorageMapFileAccepted{} +} + +// WithReloadID adds the reloadId to the replace storage map file accepted response +func (o *ReplaceStorageMapFileAccepted) WithReloadID(reloadID string) *ReplaceStorageMapFileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace storage map file accepted response +func (o *ReplaceStorageMapFileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *ReplaceStorageMapFileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// ReplaceStorageMapFileNoContentCode is the HTTP code returned for type ReplaceStorageMapFileNoContent +const ReplaceStorageMapFileNoContentCode int = 204 + +/* +ReplaceStorageMapFileNoContent Map file replaced + +swagger:response replaceStorageMapFileNoContent +*/ +type ReplaceStorageMapFileNoContent struct { +} + +// NewReplaceStorageMapFileNoContent creates ReplaceStorageMapFileNoContent with default headers values +func NewReplaceStorageMapFileNoContent() *ReplaceStorageMapFileNoContent { + + return &ReplaceStorageMapFileNoContent{} +} + +// WriteResponse to the client +func (o *ReplaceStorageMapFileNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// ReplaceStorageMapFileBadRequestCode is the HTTP code returned for type ReplaceStorageMapFileBadRequest +const ReplaceStorageMapFileBadRequestCode int = 400 + +/* +ReplaceStorageMapFileBadRequest Bad request + +swagger:response replaceStorageMapFileBadRequest +*/ +type ReplaceStorageMapFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageMapFileBadRequest creates ReplaceStorageMapFileBadRequest with default headers values +func NewReplaceStorageMapFileBadRequest() *ReplaceStorageMapFileBadRequest { + + return &ReplaceStorageMapFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage map file bad request response +func (o *ReplaceStorageMapFileBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceStorageMapFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage map file bad request response +func (o *ReplaceStorageMapFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage map file bad request response +func (o *ReplaceStorageMapFileBadRequest) WithPayload(payload *models.Error) *ReplaceStorageMapFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage map file bad request response +func (o *ReplaceStorageMapFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageMapFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageMapFileNotFoundCode is the HTTP code returned for type ReplaceStorageMapFileNotFound +const ReplaceStorageMapFileNotFoundCode int = 404 + +/* +ReplaceStorageMapFileNotFound The specified resource was not found + +swagger:response replaceStorageMapFileNotFound +*/ +type ReplaceStorageMapFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageMapFileNotFound creates ReplaceStorageMapFileNotFound with default headers values +func NewReplaceStorageMapFileNotFound() *ReplaceStorageMapFileNotFound { + + return &ReplaceStorageMapFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage map file not found response +func (o *ReplaceStorageMapFileNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceStorageMapFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage map file not found response +func (o *ReplaceStorageMapFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage map file not found response +func (o *ReplaceStorageMapFileNotFound) WithPayload(payload *models.Error) *ReplaceStorageMapFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage map file not found response +func (o *ReplaceStorageMapFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageMapFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceStorageMapFileDefault General Error + +swagger:response replaceStorageMapFileDefault +*/ +type ReplaceStorageMapFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageMapFileDefault creates ReplaceStorageMapFileDefault with default headers values +func NewReplaceStorageMapFileDefault(code int) *ReplaceStorageMapFileDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceStorageMapFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace storage map file default response +func (o *ReplaceStorageMapFileDefault) WithStatusCode(code int) *ReplaceStorageMapFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace storage map file default response +func (o *ReplaceStorageMapFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage map file default response +func (o *ReplaceStorageMapFileDefault) WithConfigurationVersion(configurationVersion string) *ReplaceStorageMapFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage map file default response +func (o *ReplaceStorageMapFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage map file default response +func (o *ReplaceStorageMapFileDefault) WithPayload(payload *models.Error) *ReplaceStorageMapFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage map file default response +func (o *ReplaceStorageMapFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageMapFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/replace_storage_map_file_urlbuilder.go b/operations/storage/replace_storage_map_file_urlbuilder.go new file mode 100644 index 00000000..6ed2f527 --- /dev/null +++ b/operations/storage/replace_storage_map_file_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceStorageMapFileURL generates an URL for the replace storage map file operation +type ReplaceStorageMapFileURL struct { + Name string + + ForceReload *bool + SkipReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageMapFileURL) WithBasePath(bp string) *ReplaceStorageMapFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageMapFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceStorageMapFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/maps/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceStorageMapFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceStorageMapFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceStorageMapFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceStorageMapFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceStorageMapFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceStorageMapFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceStorageMapFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/replace_storage_s_s_l_certificate.go b/operations/storage/replace_storage_s_s_l_certificate.go new file mode 100644 index 00000000..858c718c --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_certificate.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceStorageSSLCertificateHandlerFunc turns a function with the right signature into a replace storage s s l certificate handler +type ReplaceStorageSSLCertificateHandlerFunc func(ReplaceStorageSSLCertificateParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceStorageSSLCertificateHandlerFunc) Handle(params ReplaceStorageSSLCertificateParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceStorageSSLCertificateHandler interface for that can handle valid replace storage s s l certificate params +type ReplaceStorageSSLCertificateHandler interface { + Handle(ReplaceStorageSSLCertificateParams, interface{}) middleware.Responder +} + +// NewReplaceStorageSSLCertificate creates a new http.Handler for the replace storage s s l certificate operation +func NewReplaceStorageSSLCertificate(ctx *middleware.Context, handler ReplaceStorageSSLCertificateHandler) *ReplaceStorageSSLCertificate { + return &ReplaceStorageSSLCertificate{Context: ctx, Handler: handler} +} + +/* + ReplaceStorageSSLCertificate swagger:route PUT /services/haproxy/storage/ssl_certificates/{name} Storage replaceStorageSSLCertificate + +# Replace SSL certificates on disk + +Replaces SSL certificate on disk. +*/ +type ReplaceStorageSSLCertificate struct { + Context *middleware.Context + Handler ReplaceStorageSSLCertificateHandler +} + +func (o *ReplaceStorageSSLCertificate) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceStorageSSLCertificateParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/replace_storage_s_s_l_certificate_parameters.go b/operations/storage/replace_storage_s_s_l_certificate_parameters.go new file mode 100644 index 00000000..75daa74c --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_certificate_parameters.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewReplaceStorageSSLCertificateParams creates a new ReplaceStorageSSLCertificateParams object +// with the default values initialized. +func NewReplaceStorageSSLCertificateParams() ReplaceStorageSSLCertificateParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + + skipReloadDefault = bool(false) + ) + + return ReplaceStorageSSLCertificateParams{ + ForceReload: &forceReloadDefault, + + SkipReload: &skipReloadDefault, + } +} + +// ReplaceStorageSSLCertificateParams contains all the bound params for the replace storage s s l certificate operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceStorageSSLCertificate +type ReplaceStorageSSLCertificateParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data string + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*SSL certificate name + Required: true + In: path + */ + Name string + /*If set, no reload will be initiated after update + In: query + Default: false + */ + SkipReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceStorageSSLCertificateParams() beforehand. +func (o *ReplaceStorageSSLCertificateParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body string + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // no validation required on inline body + o.Data = body + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceStorageSSLCertificateParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageSSLCertificateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceStorageSSLCertificateParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *ReplaceStorageSSLCertificateParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageSSLCertificateParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} diff --git a/operations/storage/replace_storage_s_s_l_certificate_responses.go b/operations/storage/replace_storage_s_s_l_certificate_responses.go new file mode 100644 index 00000000..a5472616 --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_certificate_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceStorageSSLCertificateOKCode is the HTTP code returned for type ReplaceStorageSSLCertificateOK +const ReplaceStorageSSLCertificateOKCode int = 200 + +/* +ReplaceStorageSSLCertificateOK SSL certificate replaced + +swagger:response replaceStorageSSLCertificateOK +*/ +type ReplaceStorageSSLCertificateOK struct { + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCertificateOK creates ReplaceStorageSSLCertificateOK with default headers values +func NewReplaceStorageSSLCertificateOK() *ReplaceStorageSSLCertificateOK { + + return &ReplaceStorageSSLCertificateOK{} +} + +// WithPayload adds the payload to the replace storage s s l certificate o k response +func (o *ReplaceStorageSSLCertificateOK) WithPayload(payload *models.SslCertificate) *ReplaceStorageSSLCertificateOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l certificate o k response +func (o *ReplaceStorageSSLCertificateOK) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCertificateOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageSSLCertificateAcceptedCode is the HTTP code returned for type ReplaceStorageSSLCertificateAccepted +const ReplaceStorageSSLCertificateAcceptedCode int = 202 + +/* +ReplaceStorageSSLCertificateAccepted SSL certificate replaced and reload requested + +swagger:response replaceStorageSSLCertificateAccepted +*/ +type ReplaceStorageSSLCertificateAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.SslCertificate `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCertificateAccepted creates ReplaceStorageSSLCertificateAccepted with default headers values +func NewReplaceStorageSSLCertificateAccepted() *ReplaceStorageSSLCertificateAccepted { + + return &ReplaceStorageSSLCertificateAccepted{} +} + +// WithReloadID adds the reloadId to the replace storage s s l certificate accepted response +func (o *ReplaceStorageSSLCertificateAccepted) WithReloadID(reloadID string) *ReplaceStorageSSLCertificateAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace storage s s l certificate accepted response +func (o *ReplaceStorageSSLCertificateAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace storage s s l certificate accepted response +func (o *ReplaceStorageSSLCertificateAccepted) WithPayload(payload *models.SslCertificate) *ReplaceStorageSSLCertificateAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l certificate accepted response +func (o *ReplaceStorageSSLCertificateAccepted) SetPayload(payload *models.SslCertificate) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCertificateAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageSSLCertificateBadRequestCode is the HTTP code returned for type ReplaceStorageSSLCertificateBadRequest +const ReplaceStorageSSLCertificateBadRequestCode int = 400 + +/* +ReplaceStorageSSLCertificateBadRequest Bad request + +swagger:response replaceStorageSSLCertificateBadRequest +*/ +type ReplaceStorageSSLCertificateBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCertificateBadRequest creates ReplaceStorageSSLCertificateBadRequest with default headers values +func NewReplaceStorageSSLCertificateBadRequest() *ReplaceStorageSSLCertificateBadRequest { + + return &ReplaceStorageSSLCertificateBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage s s l certificate bad request response +func (o *ReplaceStorageSSLCertificateBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceStorageSSLCertificateBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage s s l certificate bad request response +func (o *ReplaceStorageSSLCertificateBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage s s l certificate bad request response +func (o *ReplaceStorageSSLCertificateBadRequest) WithPayload(payload *models.Error) *ReplaceStorageSSLCertificateBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l certificate bad request response +func (o *ReplaceStorageSSLCertificateBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCertificateBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageSSLCertificateNotFoundCode is the HTTP code returned for type ReplaceStorageSSLCertificateNotFound +const ReplaceStorageSSLCertificateNotFoundCode int = 404 + +/* +ReplaceStorageSSLCertificateNotFound The specified resource was not found + +swagger:response replaceStorageSSLCertificateNotFound +*/ +type ReplaceStorageSSLCertificateNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCertificateNotFound creates ReplaceStorageSSLCertificateNotFound with default headers values +func NewReplaceStorageSSLCertificateNotFound() *ReplaceStorageSSLCertificateNotFound { + + return &ReplaceStorageSSLCertificateNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage s s l certificate not found response +func (o *ReplaceStorageSSLCertificateNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceStorageSSLCertificateNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage s s l certificate not found response +func (o *ReplaceStorageSSLCertificateNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage s s l certificate not found response +func (o *ReplaceStorageSSLCertificateNotFound) WithPayload(payload *models.Error) *ReplaceStorageSSLCertificateNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l certificate not found response +func (o *ReplaceStorageSSLCertificateNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCertificateNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceStorageSSLCertificateDefault General Error + +swagger:response replaceStorageSSLCertificateDefault +*/ +type ReplaceStorageSSLCertificateDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCertificateDefault creates ReplaceStorageSSLCertificateDefault with default headers values +func NewReplaceStorageSSLCertificateDefault(code int) *ReplaceStorageSSLCertificateDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceStorageSSLCertificateDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace storage s s l certificate default response +func (o *ReplaceStorageSSLCertificateDefault) WithStatusCode(code int) *ReplaceStorageSSLCertificateDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace storage s s l certificate default response +func (o *ReplaceStorageSSLCertificateDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage s s l certificate default response +func (o *ReplaceStorageSSLCertificateDefault) WithConfigurationVersion(configurationVersion string) *ReplaceStorageSSLCertificateDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage s s l certificate default response +func (o *ReplaceStorageSSLCertificateDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage s s l certificate default response +func (o *ReplaceStorageSSLCertificateDefault) WithPayload(payload *models.Error) *ReplaceStorageSSLCertificateDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l certificate default response +func (o *ReplaceStorageSSLCertificateDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCertificateDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/replace_storage_s_s_l_certificate_urlbuilder.go b/operations/storage/replace_storage_s_s_l_certificate_urlbuilder.go new file mode 100644 index 00000000..9a3edd7d --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_certificate_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceStorageSSLCertificateURL generates an URL for the replace storage s s l certificate operation +type ReplaceStorageSSLCertificateURL struct { + Name string + + ForceReload *bool + SkipReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageSSLCertificateURL) WithBasePath(bp string) *ReplaceStorageSSLCertificateURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageSSLCertificateURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceStorageSSLCertificateURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_certificates/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceStorageSSLCertificateURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceStorageSSLCertificateURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceStorageSSLCertificateURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceStorageSSLCertificateURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceStorageSSLCertificateURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceStorageSSLCertificateURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceStorageSSLCertificateURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/storage/replace_storage_s_s_l_crt_list_file.go b/operations/storage/replace_storage_s_s_l_crt_list_file.go new file mode 100644 index 00000000..6d379f7e --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_crt_list_file.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceStorageSSLCrtListFileHandlerFunc turns a function with the right signature into a replace storage s s l crt list file handler +type ReplaceStorageSSLCrtListFileHandlerFunc func(ReplaceStorageSSLCrtListFileParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceStorageSSLCrtListFileHandlerFunc) Handle(params ReplaceStorageSSLCrtListFileParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceStorageSSLCrtListFileHandler interface for that can handle valid replace storage s s l crt list file params +type ReplaceStorageSSLCrtListFileHandler interface { + Handle(ReplaceStorageSSLCrtListFileParams, interface{}) middleware.Responder +} + +// NewReplaceStorageSSLCrtListFile creates a new http.Handler for the replace storage s s l crt list file operation +func NewReplaceStorageSSLCrtListFile(ctx *middleware.Context, handler ReplaceStorageSSLCrtListFileHandler) *ReplaceStorageSSLCrtListFile { + return &ReplaceStorageSSLCrtListFile{Context: ctx, Handler: handler} +} + +/* + ReplaceStorageSSLCrtListFile swagger:route PUT /services/haproxy/storage/ssl_crt_lists/{name} Storage replaceStorageSSLCrtListFile + +# Replace a certificate lists on disk + +Replaces a certificate list on disk. +*/ +type ReplaceStorageSSLCrtListFile struct { + Context *middleware.Context + Handler ReplaceStorageSSLCrtListFileHandler +} + +func (o *ReplaceStorageSSLCrtListFile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceStorageSSLCrtListFileParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/storage/replace_storage_s_s_l_crt_list_file_parameters.go b/operations/storage/replace_storage_s_s_l_crt_list_file_parameters.go new file mode 100644 index 00000000..d7c4f4f0 --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_crt_list_file_parameters.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewReplaceStorageSSLCrtListFileParams creates a new ReplaceStorageSSLCrtListFileParams object +// with the default values initialized. +func NewReplaceStorageSSLCrtListFileParams() ReplaceStorageSSLCrtListFileParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + + skipReloadDefault = bool(false) + ) + + return ReplaceStorageSSLCrtListFileParams{ + ForceReload: &forceReloadDefault, + + SkipReload: &skipReloadDefault, + } +} + +// ReplaceStorageSSLCrtListFileParams contains all the bound params for the replace storage s s l crt list file operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceStorageSSLCrtListFile +type ReplaceStorageSSLCrtListFileParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data string + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Certificate list name + Required: true + In: path + */ + Name string + /*If set, no reload will be initiated after update + In: query + Default: false + */ + SkipReload *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceStorageSSLCrtListFileParams() beforehand. +func (o *ReplaceStorageSSLCrtListFileParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body string + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // no validation required on inline body + o.Data = body + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qSkipReload, qhkSkipReload, _ := qs.GetOK("skip_reload") + if err := o.bindSkipReload(qSkipReload, qhkSkipReload, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceStorageSSLCrtListFileParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageSSLCrtListFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceStorageSSLCrtListFileParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindSkipReload binds and validates parameter SkipReload from query. +func (o *ReplaceStorageSSLCrtListFileParams) bindSkipReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceStorageSSLCrtListFileParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("skip_reload", "query", "bool", raw) + } + o.SkipReload = &value + + return nil +} diff --git a/operations/storage/replace_storage_s_s_l_crt_list_file_responses.go b/operations/storage/replace_storage_s_s_l_crt_list_file_responses.go new file mode 100644 index 00000000..25ad7941 --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_crt_list_file_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceStorageSSLCrtListFileOKCode is the HTTP code returned for type ReplaceStorageSSLCrtListFileOK +const ReplaceStorageSSLCrtListFileOKCode int = 200 + +/* +ReplaceStorageSSLCrtListFileOK Certificate list replaced + +swagger:response replaceStorageSSLCrtListFileOK +*/ +type ReplaceStorageSSLCrtListFileOK struct { + + /* + In: Body + */ + Payload *models.SslCrtListFile `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCrtListFileOK creates ReplaceStorageSSLCrtListFileOK with default headers values +func NewReplaceStorageSSLCrtListFileOK() *ReplaceStorageSSLCrtListFileOK { + + return &ReplaceStorageSSLCrtListFileOK{} +} + +// WithPayload adds the payload to the replace storage s s l crt list file o k response +func (o *ReplaceStorageSSLCrtListFileOK) WithPayload(payload *models.SslCrtListFile) *ReplaceStorageSSLCrtListFileOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l crt list file o k response +func (o *ReplaceStorageSSLCrtListFileOK) SetPayload(payload *models.SslCrtListFile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCrtListFileOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageSSLCrtListFileAcceptedCode is the HTTP code returned for type ReplaceStorageSSLCrtListFileAccepted +const ReplaceStorageSSLCrtListFileAcceptedCode int = 202 + +/* +ReplaceStorageSSLCrtListFileAccepted Certificate list replaced and reload requested + +swagger:response replaceStorageSSLCrtListFileAccepted +*/ +type ReplaceStorageSSLCrtListFileAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.SslCrtListFile `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCrtListFileAccepted creates ReplaceStorageSSLCrtListFileAccepted with default headers values +func NewReplaceStorageSSLCrtListFileAccepted() *ReplaceStorageSSLCrtListFileAccepted { + + return &ReplaceStorageSSLCrtListFileAccepted{} +} + +// WithReloadID adds the reloadId to the replace storage s s l crt list file accepted response +func (o *ReplaceStorageSSLCrtListFileAccepted) WithReloadID(reloadID string) *ReplaceStorageSSLCrtListFileAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace storage s s l crt list file accepted response +func (o *ReplaceStorageSSLCrtListFileAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace storage s s l crt list file accepted response +func (o *ReplaceStorageSSLCrtListFileAccepted) WithPayload(payload *models.SslCrtListFile) *ReplaceStorageSSLCrtListFileAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l crt list file accepted response +func (o *ReplaceStorageSSLCrtListFileAccepted) SetPayload(payload *models.SslCrtListFile) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCrtListFileAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageSSLCrtListFileBadRequestCode is the HTTP code returned for type ReplaceStorageSSLCrtListFileBadRequest +const ReplaceStorageSSLCrtListFileBadRequestCode int = 400 + +/* +ReplaceStorageSSLCrtListFileBadRequest Bad request + +swagger:response replaceStorageSSLCrtListFileBadRequest +*/ +type ReplaceStorageSSLCrtListFileBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCrtListFileBadRequest creates ReplaceStorageSSLCrtListFileBadRequest with default headers values +func NewReplaceStorageSSLCrtListFileBadRequest() *ReplaceStorageSSLCrtListFileBadRequest { + + return &ReplaceStorageSSLCrtListFileBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage s s l crt list file bad request response +func (o *ReplaceStorageSSLCrtListFileBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceStorageSSLCrtListFileBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage s s l crt list file bad request response +func (o *ReplaceStorageSSLCrtListFileBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage s s l crt list file bad request response +func (o *ReplaceStorageSSLCrtListFileBadRequest) WithPayload(payload *models.Error) *ReplaceStorageSSLCrtListFileBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l crt list file bad request response +func (o *ReplaceStorageSSLCrtListFileBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCrtListFileBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceStorageSSLCrtListFileNotFoundCode is the HTTP code returned for type ReplaceStorageSSLCrtListFileNotFound +const ReplaceStorageSSLCrtListFileNotFoundCode int = 404 + +/* +ReplaceStorageSSLCrtListFileNotFound The specified resource was not found + +swagger:response replaceStorageSSLCrtListFileNotFound +*/ +type ReplaceStorageSSLCrtListFileNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCrtListFileNotFound creates ReplaceStorageSSLCrtListFileNotFound with default headers values +func NewReplaceStorageSSLCrtListFileNotFound() *ReplaceStorageSSLCrtListFileNotFound { + + return &ReplaceStorageSSLCrtListFileNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage s s l crt list file not found response +func (o *ReplaceStorageSSLCrtListFileNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceStorageSSLCrtListFileNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage s s l crt list file not found response +func (o *ReplaceStorageSSLCrtListFileNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage s s l crt list file not found response +func (o *ReplaceStorageSSLCrtListFileNotFound) WithPayload(payload *models.Error) *ReplaceStorageSSLCrtListFileNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l crt list file not found response +func (o *ReplaceStorageSSLCrtListFileNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCrtListFileNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceStorageSSLCrtListFileDefault General Error + +swagger:response replaceStorageSSLCrtListFileDefault +*/ +type ReplaceStorageSSLCrtListFileDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceStorageSSLCrtListFileDefault creates ReplaceStorageSSLCrtListFileDefault with default headers values +func NewReplaceStorageSSLCrtListFileDefault(code int) *ReplaceStorageSSLCrtListFileDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceStorageSSLCrtListFileDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace storage s s l crt list file default response +func (o *ReplaceStorageSSLCrtListFileDefault) WithStatusCode(code int) *ReplaceStorageSSLCrtListFileDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace storage s s l crt list file default response +func (o *ReplaceStorageSSLCrtListFileDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace storage s s l crt list file default response +func (o *ReplaceStorageSSLCrtListFileDefault) WithConfigurationVersion(configurationVersion string) *ReplaceStorageSSLCrtListFileDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace storage s s l crt list file default response +func (o *ReplaceStorageSSLCrtListFileDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace storage s s l crt list file default response +func (o *ReplaceStorageSSLCrtListFileDefault) WithPayload(payload *models.Error) *ReplaceStorageSSLCrtListFileDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace storage s s l crt list file default response +func (o *ReplaceStorageSSLCrtListFileDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceStorageSSLCrtListFileDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/storage/replace_storage_s_s_l_crt_list_file_urlbuilder.go b/operations/storage/replace_storage_s_s_l_crt_list_file_urlbuilder.go new file mode 100644 index 00000000..f0480ff0 --- /dev/null +++ b/operations/storage/replace_storage_s_s_l_crt_list_file_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storage + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceStorageSSLCrtListFileURL generates an URL for the replace storage s s l crt list file operation +type ReplaceStorageSSLCrtListFileURL struct { + Name string + + ForceReload *bool + SkipReload *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageSSLCrtListFileURL) WithBasePath(bp string) *ReplaceStorageSSLCrtListFileURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceStorageSSLCrtListFileURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceStorageSSLCrtListFileURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/storage/ssl_crt_lists/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceStorageSSLCrtListFileURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var skipReloadQ string + if o.SkipReload != nil { + skipReloadQ = swag.FormatBool(*o.SkipReload) + } + if skipReloadQ != "" { + qs.Set("skip_reload", skipReloadQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceStorageSSLCrtListFileURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceStorageSSLCrtListFileURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceStorageSSLCrtListFileURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceStorageSSLCrtListFileURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceStorageSSLCrtListFileURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceStorageSSLCrtListFileURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/table/create_table.go b/operations/table/create_table.go new file mode 100644 index 00000000..8a98a93c --- /dev/null +++ b/operations/table/create_table.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTableHandlerFunc turns a function with the right signature into a create table handler +type CreateTableHandlerFunc func(CreateTableParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTableHandlerFunc) Handle(params CreateTableParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTableHandler interface for that can handle valid create table params +type CreateTableHandler interface { + Handle(CreateTableParams, interface{}) middleware.Responder +} + +// NewCreateTable creates a new http.Handler for the create table operation +func NewCreateTable(ctx *middleware.Context, handler CreateTableHandler) *CreateTable { + return &CreateTable{Context: ctx, Handler: handler} +} + +/* + CreateTable swagger:route POST /services/haproxy/configuration/peers/{parent_name}/tables Table createTable + +# Add a new table + +Adds a new table in the specified peer section in the configuration file. +*/ +type CreateTable struct { + Context *middleware.Context + Handler CreateTableHandler +} + +func (o *CreateTable) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTableParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/table/create_table_parameters.go b/operations/table/create_table_parameters.go new file mode 100644 index 00000000..722a4edc --- /dev/null +++ b/operations/table/create_table_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTableParams creates a new CreateTableParams object +// with the default values initialized. +func NewCreateTableParams() CreateTableParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTableParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTableParams contains all the bound params for the create table operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTable +type CreateTableParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Table + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTableParams() beforehand. +func (o *CreateTableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Table + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTableParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTableParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTableParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTableParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTableParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/table/create_table_responses.go b/operations/table/create_table_responses.go new file mode 100644 index 00000000..c0662b00 --- /dev/null +++ b/operations/table/create_table_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTableCreatedCode is the HTTP code returned for type CreateTableCreated +const CreateTableCreatedCode int = 201 + +/* +CreateTableCreated Table created + +swagger:response createTableCreated +*/ +type CreateTableCreated struct { + + /* + In: Body + */ + Payload *models.Table `json:"body,omitempty"` +} + +// NewCreateTableCreated creates CreateTableCreated with default headers values +func NewCreateTableCreated() *CreateTableCreated { + + return &CreateTableCreated{} +} + +// WithPayload adds the payload to the create table created response +func (o *CreateTableCreated) WithPayload(payload *models.Table) *CreateTableCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create table created response +func (o *CreateTableCreated) SetPayload(payload *models.Table) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTableCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTableAcceptedCode is the HTTP code returned for type CreateTableAccepted +const CreateTableAcceptedCode int = 202 + +/* +CreateTableAccepted Configuration change accepted and reload requested + +swagger:response createTableAccepted +*/ +type CreateTableAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Table `json:"body,omitempty"` +} + +// NewCreateTableAccepted creates CreateTableAccepted with default headers values +func NewCreateTableAccepted() *CreateTableAccepted { + + return &CreateTableAccepted{} +} + +// WithReloadID adds the reloadId to the create table accepted response +func (o *CreateTableAccepted) WithReloadID(reloadID string) *CreateTableAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create table accepted response +func (o *CreateTableAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create table accepted response +func (o *CreateTableAccepted) WithPayload(payload *models.Table) *CreateTableAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create table accepted response +func (o *CreateTableAccepted) SetPayload(payload *models.Table) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTableAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTableBadRequestCode is the HTTP code returned for type CreateTableBadRequest +const CreateTableBadRequestCode int = 400 + +/* +CreateTableBadRequest Bad request + +swagger:response createTableBadRequest +*/ +type CreateTableBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTableBadRequest creates CreateTableBadRequest with default headers values +func NewCreateTableBadRequest() *CreateTableBadRequest { + + return &CreateTableBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create table bad request response +func (o *CreateTableBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTableBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create table bad request response +func (o *CreateTableBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create table bad request response +func (o *CreateTableBadRequest) WithPayload(payload *models.Error) *CreateTableBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create table bad request response +func (o *CreateTableBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTableBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTableConflictCode is the HTTP code returned for type CreateTableConflict +const CreateTableConflictCode int = 409 + +/* +CreateTableConflict The specified resource already exists + +swagger:response createTableConflict +*/ +type CreateTableConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTableConflict creates CreateTableConflict with default headers values +func NewCreateTableConflict() *CreateTableConflict { + + return &CreateTableConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create table conflict response +func (o *CreateTableConflict) WithConfigurationVersion(configurationVersion string) *CreateTableConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create table conflict response +func (o *CreateTableConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create table conflict response +func (o *CreateTableConflict) WithPayload(payload *models.Error) *CreateTableConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create table conflict response +func (o *CreateTableConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTableConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTableDefault General Error + +swagger:response createTableDefault +*/ +type CreateTableDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTableDefault creates CreateTableDefault with default headers values +func NewCreateTableDefault(code int) *CreateTableDefault { + if code <= 0 { + code = 500 + } + + return &CreateTableDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create table default response +func (o *CreateTableDefault) WithStatusCode(code int) *CreateTableDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create table default response +func (o *CreateTableDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create table default response +func (o *CreateTableDefault) WithConfigurationVersion(configurationVersion string) *CreateTableDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create table default response +func (o *CreateTableDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create table default response +func (o *CreateTableDefault) WithPayload(payload *models.Error) *CreateTableDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create table default response +func (o *CreateTableDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTableDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/table/create_table_urlbuilder.go b/operations/table/create_table_urlbuilder.go new file mode 100644 index 00000000..d0baf20c --- /dev/null +++ b/operations/table/create_table_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTableURL generates an URL for the create table operation +type CreateTableURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTableURL) WithBasePath(bp string) *CreateTableURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTableURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTableURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/tables" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTableURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTableURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTableURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTableURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTableURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTableURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTableURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/table/delete_table.go b/operations/table/delete_table.go new file mode 100644 index 00000000..a5d99c8e --- /dev/null +++ b/operations/table/delete_table.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTableHandlerFunc turns a function with the right signature into a delete table handler +type DeleteTableHandlerFunc func(DeleteTableParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTableHandlerFunc) Handle(params DeleteTableParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTableHandler interface for that can handle valid delete table params +type DeleteTableHandler interface { + Handle(DeleteTableParams, interface{}) middleware.Responder +} + +// NewDeleteTable creates a new http.Handler for the delete table operation +func NewDeleteTable(ctx *middleware.Context, handler DeleteTableHandler) *DeleteTable { + return &DeleteTable{Context: ctx, Handler: handler} +} + +/* + DeleteTable swagger:route DELETE /services/haproxy/configuration/peers/{parent_name}/tables/{name} Table deleteTable + +# Delete a table + +Deletes a table configuration by it's name in the specified peer section. +*/ +type DeleteTable struct { + Context *middleware.Context + Handler DeleteTableHandler +} + +func (o *DeleteTable) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTableParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/table/delete_table_parameters.go b/operations/table/delete_table_parameters.go new file mode 100644 index 00000000..6e3a5fc6 --- /dev/null +++ b/operations/table/delete_table_parameters.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTableParams creates a new DeleteTableParams object +// with the default values initialized. +func NewDeleteTableParams() DeleteTableParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTableParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTableParams contains all the bound params for the delete table operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTable +type DeleteTableParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Table name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTableParams() beforehand. +func (o *DeleteTableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTableParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTableParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteTableParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTableParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTableParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTableParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/table/delete_table_responses.go b/operations/table/delete_table_responses.go new file mode 100644 index 00000000..4c897b95 --- /dev/null +++ b/operations/table/delete_table_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTableAcceptedCode is the HTTP code returned for type DeleteTableAccepted +const DeleteTableAcceptedCode int = 202 + +/* +DeleteTableAccepted Configuration change accepted and reload requested + +swagger:response deleteTableAccepted +*/ +type DeleteTableAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTableAccepted creates DeleteTableAccepted with default headers values +func NewDeleteTableAccepted() *DeleteTableAccepted { + + return &DeleteTableAccepted{} +} + +// WithReloadID adds the reloadId to the delete table accepted response +func (o *DeleteTableAccepted) WithReloadID(reloadID string) *DeleteTableAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete table accepted response +func (o *DeleteTableAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTableAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTableNoContentCode is the HTTP code returned for type DeleteTableNoContent +const DeleteTableNoContentCode int = 204 + +/* +DeleteTableNoContent Table deleted + +swagger:response deleteTableNoContent +*/ +type DeleteTableNoContent struct { +} + +// NewDeleteTableNoContent creates DeleteTableNoContent with default headers values +func NewDeleteTableNoContent() *DeleteTableNoContent { + + return &DeleteTableNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTableNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTableNotFoundCode is the HTTP code returned for type DeleteTableNotFound +const DeleteTableNotFoundCode int = 404 + +/* +DeleteTableNotFound The specified resource was not found + +swagger:response deleteTableNotFound +*/ +type DeleteTableNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTableNotFound creates DeleteTableNotFound with default headers values +func NewDeleteTableNotFound() *DeleteTableNotFound { + + return &DeleteTableNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete table not found response +func (o *DeleteTableNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTableNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete table not found response +func (o *DeleteTableNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete table not found response +func (o *DeleteTableNotFound) WithPayload(payload *models.Error) *DeleteTableNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete table not found response +func (o *DeleteTableNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTableNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTableDefault General Error + +swagger:response deleteTableDefault +*/ +type DeleteTableDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTableDefault creates DeleteTableDefault with default headers values +func NewDeleteTableDefault(code int) *DeleteTableDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTableDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete table default response +func (o *DeleteTableDefault) WithStatusCode(code int) *DeleteTableDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete table default response +func (o *DeleteTableDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete table default response +func (o *DeleteTableDefault) WithConfigurationVersion(configurationVersion string) *DeleteTableDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete table default response +func (o *DeleteTableDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete table default response +func (o *DeleteTableDefault) WithPayload(payload *models.Error) *DeleteTableDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete table default response +func (o *DeleteTableDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTableDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/table/delete_table_urlbuilder.go b/operations/table/delete_table_urlbuilder.go new file mode 100644 index 00000000..232bae37 --- /dev/null +++ b/operations/table/delete_table_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTableURL generates an URL for the delete table operation +type DeleteTableURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTableURL) WithBasePath(bp string) *DeleteTableURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTableURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTableURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/tables/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteTableURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTableURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTableURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTableURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTableURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTableURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTableURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTableURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/table/get_table.go b/operations/table/get_table.go new file mode 100644 index 00000000..f6225cec --- /dev/null +++ b/operations/table/get_table.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTableHandlerFunc turns a function with the right signature into a get table handler +type GetTableHandlerFunc func(GetTableParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTableHandlerFunc) Handle(params GetTableParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTableHandler interface for that can handle valid get table params +type GetTableHandler interface { + Handle(GetTableParams, interface{}) middleware.Responder +} + +// NewGetTable creates a new http.Handler for the get table operation +func NewGetTable(ctx *middleware.Context, handler GetTableHandler) *GetTable { + return &GetTable{Context: ctx, Handler: handler} +} + +/* + GetTable swagger:route GET /services/haproxy/configuration/peers/{parent_name}/tables/{name} Table getTable + +# Return one table + +Returns one table configuration by it's name in the specified peer section. +*/ +type GetTable struct { + Context *middleware.Context + Handler GetTableHandler +} + +func (o *GetTable) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTableParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/table/get_table_parameters.go b/operations/table/get_table_parameters.go new file mode 100644 index 00000000..3e4d1ae9 --- /dev/null +++ b/operations/table/get_table_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetTableParams creates a new GetTableParams object +// +// There are no default values defined in the spec. +func NewGetTableParams() GetTableParams { + + return GetTableParams{} +} + +// GetTableParams contains all the bound params for the get table operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTable +type GetTableParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Table name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTableParams() beforehand. +func (o *GetTableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetTableParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTableParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTableParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/table/get_table_responses.go b/operations/table/get_table_responses.go new file mode 100644 index 00000000..8e9879c6 --- /dev/null +++ b/operations/table/get_table_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTableOKCode is the HTTP code returned for type GetTableOK +const GetTableOKCode int = 200 + +/* +GetTableOK Successful operation + +swagger:response getTableOK +*/ +type GetTableOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Table `json:"body,omitempty"` +} + +// NewGetTableOK creates GetTableOK with default headers values +func NewGetTableOK() *GetTableOK { + + return &GetTableOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get table o k response +func (o *GetTableOK) WithConfigurationVersion(configurationVersion string) *GetTableOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get table o k response +func (o *GetTableOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get table o k response +func (o *GetTableOK) WithPayload(payload *models.Table) *GetTableOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get table o k response +func (o *GetTableOK) SetPayload(payload *models.Table) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTableOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTableNotFoundCode is the HTTP code returned for type GetTableNotFound +const GetTableNotFoundCode int = 404 + +/* +GetTableNotFound The specified resource already exists + +swagger:response getTableNotFound +*/ +type GetTableNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTableNotFound creates GetTableNotFound with default headers values +func NewGetTableNotFound() *GetTableNotFound { + + return &GetTableNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get table not found response +func (o *GetTableNotFound) WithConfigurationVersion(configurationVersion string) *GetTableNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get table not found response +func (o *GetTableNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get table not found response +func (o *GetTableNotFound) WithPayload(payload *models.Error) *GetTableNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get table not found response +func (o *GetTableNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTableNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTableDefault General Error + +swagger:response getTableDefault +*/ +type GetTableDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTableDefault creates GetTableDefault with default headers values +func NewGetTableDefault(code int) *GetTableDefault { + if code <= 0 { + code = 500 + } + + return &GetTableDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get table default response +func (o *GetTableDefault) WithStatusCode(code int) *GetTableDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get table default response +func (o *GetTableDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get table default response +func (o *GetTableDefault) WithConfigurationVersion(configurationVersion string) *GetTableDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get table default response +func (o *GetTableDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get table default response +func (o *GetTableDefault) WithPayload(payload *models.Error) *GetTableDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get table default response +func (o *GetTableDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTableDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/table/get_table_urlbuilder.go b/operations/table/get_table_urlbuilder.go new file mode 100644 index 00000000..9bdf840b --- /dev/null +++ b/operations/table/get_table_urlbuilder.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetTableURL generates an URL for the get table operation +type GetTableURL struct { + Name string + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTableURL) WithBasePath(bp string) *GetTableURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTableURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTableURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/tables/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetTableURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTableURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTableURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTableURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTableURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTableURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTableURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTableURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/table/get_tables.go b/operations/table/get_tables.go new file mode 100644 index 00000000..34266841 --- /dev/null +++ b/operations/table/get_tables.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTablesHandlerFunc turns a function with the right signature into a get tables handler +type GetTablesHandlerFunc func(GetTablesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTablesHandlerFunc) Handle(params GetTablesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTablesHandler interface for that can handle valid get tables params +type GetTablesHandler interface { + Handle(GetTablesParams, interface{}) middleware.Responder +} + +// NewGetTables creates a new http.Handler for the get tables operation +func NewGetTables(ctx *middleware.Context, handler GetTablesHandler) *GetTables { + return &GetTables{Context: ctx, Handler: handler} +} + +/* + GetTables swagger:route GET /services/haproxy/configuration/peers/{parent_name}/tables Table getTables + +# Return an array of tables + +Returns an array of all tables that are configured in specified peer section. +*/ +type GetTables struct { + Context *middleware.Context + Handler GetTablesHandler +} + +func (o *GetTables) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTablesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/table/get_tables_parameters.go b/operations/table/get_tables_parameters.go new file mode 100644 index 00000000..cdf2856d --- /dev/null +++ b/operations/table/get_tables_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetTablesParams creates a new GetTablesParams object +// +// There are no default values defined in the spec. +func NewGetTablesParams() GetTablesParams { + + return GetTablesParams{} +} + +// GetTablesParams contains all the bound params for the get tables operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTables +type GetTablesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTablesParams() beforehand. +func (o *GetTablesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTablesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTablesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/table/get_tables_responses.go b/operations/table/get_tables_responses.go new file mode 100644 index 00000000..cbccfb8f --- /dev/null +++ b/operations/table/get_tables_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTablesOKCode is the HTTP code returned for type GetTablesOK +const GetTablesOKCode int = 200 + +/* +GetTablesOK Successful operation + +swagger:response getTablesOK +*/ +type GetTablesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Tables `json:"body,omitempty"` +} + +// NewGetTablesOK creates GetTablesOK with default headers values +func NewGetTablesOK() *GetTablesOK { + + return &GetTablesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get tables o k response +func (o *GetTablesOK) WithConfigurationVersion(configurationVersion string) *GetTablesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get tables o k response +func (o *GetTablesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get tables o k response +func (o *GetTablesOK) WithPayload(payload models.Tables) *GetTablesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get tables o k response +func (o *GetTablesOK) SetPayload(payload models.Tables) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTablesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Tables{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetTablesDefault General Error + +swagger:response getTablesDefault +*/ +type GetTablesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTablesDefault creates GetTablesDefault with default headers values +func NewGetTablesDefault(code int) *GetTablesDefault { + if code <= 0 { + code = 500 + } + + return &GetTablesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get tables default response +func (o *GetTablesDefault) WithStatusCode(code int) *GetTablesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get tables default response +func (o *GetTablesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get tables default response +func (o *GetTablesDefault) WithConfigurationVersion(configurationVersion string) *GetTablesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get tables default response +func (o *GetTablesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get tables default response +func (o *GetTablesDefault) WithPayload(payload *models.Error) *GetTablesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get tables default response +func (o *GetTablesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTablesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/table/get_tables_urlbuilder.go b/operations/table/get_tables_urlbuilder.go new file mode 100644 index 00000000..002844ce --- /dev/null +++ b/operations/table/get_tables_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetTablesURL generates an URL for the get tables operation +type GetTablesURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTablesURL) WithBasePath(bp string) *GetTablesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTablesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTablesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/tables" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTablesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTablesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTablesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTablesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTablesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTablesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTablesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/table/replace_table.go b/operations/table/replace_table.go new file mode 100644 index 00000000..b801d344 --- /dev/null +++ b/operations/table/replace_table.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTableHandlerFunc turns a function with the right signature into a replace table handler +type ReplaceTableHandlerFunc func(ReplaceTableParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTableHandlerFunc) Handle(params ReplaceTableParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTableHandler interface for that can handle valid replace table params +type ReplaceTableHandler interface { + Handle(ReplaceTableParams, interface{}) middleware.Responder +} + +// NewReplaceTable creates a new http.Handler for the replace table operation +func NewReplaceTable(ctx *middleware.Context, handler ReplaceTableHandler) *ReplaceTable { + return &ReplaceTable{Context: ctx, Handler: handler} +} + +/* + ReplaceTable swagger:route PUT /services/haproxy/configuration/peers/{parent_name}/tables/{name} Table replaceTable + +# Replace a table + +Replaces a table configuration by it's name in the specified peer section. +*/ +type ReplaceTable struct { + Context *middleware.Context + Handler ReplaceTableHandler +} + +func (o *ReplaceTable) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTableParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/table/replace_table_parameters.go b/operations/table/replace_table_parameters.go new file mode 100644 index 00000000..257018ce --- /dev/null +++ b/operations/table/replace_table_parameters.go @@ -0,0 +1,245 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTableParams creates a new ReplaceTableParams object +// with the default values initialized. +func NewReplaceTableParams() ReplaceTableParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTableParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTableParams contains all the bound params for the replace table operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTable +type ReplaceTableParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Table + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Table name + Required: true + In: path + */ + Name string + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTableParams() beforehand. +func (o *ReplaceTableParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Table + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTableParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTableParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *ReplaceTableParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTableParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTableParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTableParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/table/replace_table_responses.go b/operations/table/replace_table_responses.go new file mode 100644 index 00000000..8c395dc5 --- /dev/null +++ b/operations/table/replace_table_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTableOKCode is the HTTP code returned for type ReplaceTableOK +const ReplaceTableOKCode int = 200 + +/* +ReplaceTableOK Table replaced + +swagger:response replaceTableOK +*/ +type ReplaceTableOK struct { + + /* + In: Body + */ + Payload *models.Table `json:"body,omitempty"` +} + +// NewReplaceTableOK creates ReplaceTableOK with default headers values +func NewReplaceTableOK() *ReplaceTableOK { + + return &ReplaceTableOK{} +} + +// WithPayload adds the payload to the replace table o k response +func (o *ReplaceTableOK) WithPayload(payload *models.Table) *ReplaceTableOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace table o k response +func (o *ReplaceTableOK) SetPayload(payload *models.Table) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTableOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTableAcceptedCode is the HTTP code returned for type ReplaceTableAccepted +const ReplaceTableAcceptedCode int = 202 + +/* +ReplaceTableAccepted Configuration change accepted and reload requested + +swagger:response replaceTableAccepted +*/ +type ReplaceTableAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Table `json:"body,omitempty"` +} + +// NewReplaceTableAccepted creates ReplaceTableAccepted with default headers values +func NewReplaceTableAccepted() *ReplaceTableAccepted { + + return &ReplaceTableAccepted{} +} + +// WithReloadID adds the reloadId to the replace table accepted response +func (o *ReplaceTableAccepted) WithReloadID(reloadID string) *ReplaceTableAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace table accepted response +func (o *ReplaceTableAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace table accepted response +func (o *ReplaceTableAccepted) WithPayload(payload *models.Table) *ReplaceTableAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace table accepted response +func (o *ReplaceTableAccepted) SetPayload(payload *models.Table) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTableAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTableBadRequestCode is the HTTP code returned for type ReplaceTableBadRequest +const ReplaceTableBadRequestCode int = 400 + +/* +ReplaceTableBadRequest Bad request + +swagger:response replaceTableBadRequest +*/ +type ReplaceTableBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTableBadRequest creates ReplaceTableBadRequest with default headers values +func NewReplaceTableBadRequest() *ReplaceTableBadRequest { + + return &ReplaceTableBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace table bad request response +func (o *ReplaceTableBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTableBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace table bad request response +func (o *ReplaceTableBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace table bad request response +func (o *ReplaceTableBadRequest) WithPayload(payload *models.Error) *ReplaceTableBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace table bad request response +func (o *ReplaceTableBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTableBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTableNotFoundCode is the HTTP code returned for type ReplaceTableNotFound +const ReplaceTableNotFoundCode int = 404 + +/* +ReplaceTableNotFound The specified resource was not found + +swagger:response replaceTableNotFound +*/ +type ReplaceTableNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTableNotFound creates ReplaceTableNotFound with default headers values +func NewReplaceTableNotFound() *ReplaceTableNotFound { + + return &ReplaceTableNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace table not found response +func (o *ReplaceTableNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTableNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace table not found response +func (o *ReplaceTableNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace table not found response +func (o *ReplaceTableNotFound) WithPayload(payload *models.Error) *ReplaceTableNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace table not found response +func (o *ReplaceTableNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTableNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTableDefault General Error + +swagger:response replaceTableDefault +*/ +type ReplaceTableDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTableDefault creates ReplaceTableDefault with default headers values +func NewReplaceTableDefault(code int) *ReplaceTableDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTableDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace table default response +func (o *ReplaceTableDefault) WithStatusCode(code int) *ReplaceTableDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace table default response +func (o *ReplaceTableDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace table default response +func (o *ReplaceTableDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTableDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace table default response +func (o *ReplaceTableDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace table default response +func (o *ReplaceTableDefault) WithPayload(payload *models.Error) *ReplaceTableDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace table default response +func (o *ReplaceTableDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTableDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/table/replace_table_urlbuilder.go b/operations/table/replace_table_urlbuilder.go new file mode 100644 index 00000000..d9465c72 --- /dev/null +++ b/operations/table/replace_table_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package table + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTableURL generates an URL for the replace table operation +type ReplaceTableURL struct { + Name string + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTableURL) WithBasePath(bp string) *ReplaceTableURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTableURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTableURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/peers/{parent_name}/tables/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on ReplaceTableURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTableURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTableURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTableURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTableURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTableURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTableURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTableURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/create_tcp_check_backend.go b/operations/tcp_check/create_tcp_check_backend.go new file mode 100644 index 00000000..c977c25c --- /dev/null +++ b/operations/tcp_check/create_tcp_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTCPCheckBackendHandlerFunc turns a function with the right signature into a create TCP check backend handler +type CreateTCPCheckBackendHandlerFunc func(CreateTCPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTCPCheckBackendHandlerFunc) Handle(params CreateTCPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTCPCheckBackendHandler interface for that can handle valid create TCP check backend params +type CreateTCPCheckBackendHandler interface { + Handle(CreateTCPCheckBackendParams, interface{}) middleware.Responder +} + +// NewCreateTCPCheckBackend creates a new http.Handler for the create TCP check backend operation +func NewCreateTCPCheckBackend(ctx *middleware.Context, handler CreateTCPCheckBackendHandler) *CreateTCPCheckBackend { + return &CreateTCPCheckBackend{Context: ctx, Handler: handler} +} + +/* + CreateTCPCheckBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index} TCPCheck createTcpCheckBackend + +# Add a new TCP check + +Adds a new TCP check of the specified type in the specified parent. +*/ +type CreateTCPCheckBackend struct { + Context *middleware.Context + Handler CreateTCPCheckBackendHandler +} + +func (o *CreateTCPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTCPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/create_tcp_check_backend_parameters.go b/operations/tcp_check/create_tcp_check_backend_parameters.go new file mode 100644 index 00000000..eccb3a07 --- /dev/null +++ b/operations/tcp_check/create_tcp_check_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTCPCheckBackendParams creates a new CreateTCPCheckBackendParams object +// with the default values initialized. +func NewCreateTCPCheckBackendParams() CreateTCPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTCPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTCPCheckBackendParams contains all the bound params for the create TCP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTCPCheckBackend +type CreateTCPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTCPCheckBackendParams() beforehand. +func (o *CreateTCPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTCPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTCPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateTCPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTCPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTCPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTCPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/create_tcp_check_backend_responses.go b/operations/tcp_check/create_tcp_check_backend_responses.go new file mode 100644 index 00000000..a69f46b6 --- /dev/null +++ b/operations/tcp_check/create_tcp_check_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTCPCheckBackendCreatedCode is the HTTP code returned for type CreateTCPCheckBackendCreated +const CreateTCPCheckBackendCreatedCode int = 201 + +/* +CreateTCPCheckBackendCreated TCP check created + +swagger:response createTcpCheckBackendCreated +*/ +type CreateTCPCheckBackendCreated struct { + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewCreateTCPCheckBackendCreated creates CreateTCPCheckBackendCreated with default headers values +func NewCreateTCPCheckBackendCreated() *CreateTCPCheckBackendCreated { + + return &CreateTCPCheckBackendCreated{} +} + +// WithPayload adds the payload to the create Tcp check backend created response +func (o *CreateTCPCheckBackendCreated) WithPayload(payload *models.TCPCheck) *CreateTCPCheckBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check backend created response +func (o *CreateTCPCheckBackendCreated) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPCheckBackendAcceptedCode is the HTTP code returned for type CreateTCPCheckBackendAccepted +const CreateTCPCheckBackendAcceptedCode int = 202 + +/* +CreateTCPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response createTcpCheckBackendAccepted +*/ +type CreateTCPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewCreateTCPCheckBackendAccepted creates CreateTCPCheckBackendAccepted with default headers values +func NewCreateTCPCheckBackendAccepted() *CreateTCPCheckBackendAccepted { + + return &CreateTCPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Tcp check backend accepted response +func (o *CreateTCPCheckBackendAccepted) WithReloadID(reloadID string) *CreateTCPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Tcp check backend accepted response +func (o *CreateTCPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Tcp check backend accepted response +func (o *CreateTCPCheckBackendAccepted) WithPayload(payload *models.TCPCheck) *CreateTCPCheckBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check backend accepted response +func (o *CreateTCPCheckBackendAccepted) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPCheckBackendBadRequestCode is the HTTP code returned for type CreateTCPCheckBackendBadRequest +const CreateTCPCheckBackendBadRequestCode int = 400 + +/* +CreateTCPCheckBackendBadRequest Bad request + +swagger:response createTcpCheckBackendBadRequest +*/ +type CreateTCPCheckBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPCheckBackendBadRequest creates CreateTCPCheckBackendBadRequest with default headers values +func NewCreateTCPCheckBackendBadRequest() *CreateTCPCheckBackendBadRequest { + + return &CreateTCPCheckBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp check backend bad request response +func (o *CreateTCPCheckBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTCPCheckBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp check backend bad request response +func (o *CreateTCPCheckBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp check backend bad request response +func (o *CreateTCPCheckBackendBadRequest) WithPayload(payload *models.Error) *CreateTCPCheckBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check backend bad request response +func (o *CreateTCPCheckBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPCheckBackendConflictCode is the HTTP code returned for type CreateTCPCheckBackendConflict +const CreateTCPCheckBackendConflictCode int = 409 + +/* +CreateTCPCheckBackendConflict The specified resource already exists + +swagger:response createTcpCheckBackendConflict +*/ +type CreateTCPCheckBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPCheckBackendConflict creates CreateTCPCheckBackendConflict with default headers values +func NewCreateTCPCheckBackendConflict() *CreateTCPCheckBackendConflict { + + return &CreateTCPCheckBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp check backend conflict response +func (o *CreateTCPCheckBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateTCPCheckBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp check backend conflict response +func (o *CreateTCPCheckBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp check backend conflict response +func (o *CreateTCPCheckBackendConflict) WithPayload(payload *models.Error) *CreateTCPCheckBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check backend conflict response +func (o *CreateTCPCheckBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTCPCheckBackendDefault General Error + +swagger:response createTcpCheckBackendDefault +*/ +type CreateTCPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPCheckBackendDefault creates CreateTCPCheckBackendDefault with default headers values +func NewCreateTCPCheckBackendDefault(code int) *CreateTCPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateTCPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create TCP check backend default response +func (o *CreateTCPCheckBackendDefault) WithStatusCode(code int) *CreateTCPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create TCP check backend default response +func (o *CreateTCPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create TCP check backend default response +func (o *CreateTCPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateTCPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create TCP check backend default response +func (o *CreateTCPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create TCP check backend default response +func (o *CreateTCPCheckBackendDefault) WithPayload(payload *models.Error) *CreateTCPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create TCP check backend default response +func (o *CreateTCPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/create_tcp_check_backend_urlbuilder.go b/operations/tcp_check/create_tcp_check_backend_urlbuilder.go new file mode 100644 index 00000000..c6ab6dfd --- /dev/null +++ b/operations/tcp_check/create_tcp_check_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTCPCheckBackendURL generates an URL for the create TCP check backend operation +type CreateTCPCheckBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPCheckBackendURL) WithBasePath(bp string) *CreateTCPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTCPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateTCPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTCPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTCPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTCPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTCPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTCPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTCPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTCPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/create_tcp_check_defaults.go b/operations/tcp_check/create_tcp_check_defaults.go new file mode 100644 index 00000000..9c0351e3 --- /dev/null +++ b/operations/tcp_check/create_tcp_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTCPCheckDefaultsHandlerFunc turns a function with the right signature into a create TCP check defaults handler +type CreateTCPCheckDefaultsHandlerFunc func(CreateTCPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTCPCheckDefaultsHandlerFunc) Handle(params CreateTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTCPCheckDefaultsHandler interface for that can handle valid create TCP check defaults params +type CreateTCPCheckDefaultsHandler interface { + Handle(CreateTCPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateTCPCheckDefaults creates a new http.Handler for the create TCP check defaults operation +func NewCreateTCPCheckDefaults(ctx *middleware.Context, handler CreateTCPCheckDefaultsHandler) *CreateTCPCheckDefaults { + return &CreateTCPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + CreateTCPCheckDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index} TCPCheck createTcpCheckDefaults + +# Add a new TCP check + +Adds a new TCP check of the specified type in the specified parent. +*/ +type CreateTCPCheckDefaults struct { + Context *middleware.Context + Handler CreateTCPCheckDefaultsHandler +} + +func (o *CreateTCPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTCPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/create_tcp_check_defaults_parameters.go b/operations/tcp_check/create_tcp_check_defaults_parameters.go new file mode 100644 index 00000000..44fb6302 --- /dev/null +++ b/operations/tcp_check/create_tcp_check_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTCPCheckDefaultsParams creates a new CreateTCPCheckDefaultsParams object +// with the default values initialized. +func NewCreateTCPCheckDefaultsParams() CreateTCPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTCPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTCPCheckDefaultsParams contains all the bound params for the create TCP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTCPCheckDefaults +type CreateTCPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTCPCheckDefaultsParams() beforehand. +func (o *CreateTCPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTCPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTCPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateTCPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTCPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTCPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTCPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/create_tcp_check_defaults_responses.go b/operations/tcp_check/create_tcp_check_defaults_responses.go new file mode 100644 index 00000000..a666aba2 --- /dev/null +++ b/operations/tcp_check/create_tcp_check_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTCPCheckDefaultsCreatedCode is the HTTP code returned for type CreateTCPCheckDefaultsCreated +const CreateTCPCheckDefaultsCreatedCode int = 201 + +/* +CreateTCPCheckDefaultsCreated TCP check created + +swagger:response createTcpCheckDefaultsCreated +*/ +type CreateTCPCheckDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewCreateTCPCheckDefaultsCreated creates CreateTCPCheckDefaultsCreated with default headers values +func NewCreateTCPCheckDefaultsCreated() *CreateTCPCheckDefaultsCreated { + + return &CreateTCPCheckDefaultsCreated{} +} + +// WithPayload adds the payload to the create Tcp check defaults created response +func (o *CreateTCPCheckDefaultsCreated) WithPayload(payload *models.TCPCheck) *CreateTCPCheckDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check defaults created response +func (o *CreateTCPCheckDefaultsCreated) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPCheckDefaultsAcceptedCode is the HTTP code returned for type CreateTCPCheckDefaultsAccepted +const CreateTCPCheckDefaultsAcceptedCode int = 202 + +/* +CreateTCPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createTcpCheckDefaultsAccepted +*/ +type CreateTCPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewCreateTCPCheckDefaultsAccepted creates CreateTCPCheckDefaultsAccepted with default headers values +func NewCreateTCPCheckDefaultsAccepted() *CreateTCPCheckDefaultsAccepted { + + return &CreateTCPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Tcp check defaults accepted response +func (o *CreateTCPCheckDefaultsAccepted) WithReloadID(reloadID string) *CreateTCPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Tcp check defaults accepted response +func (o *CreateTCPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Tcp check defaults accepted response +func (o *CreateTCPCheckDefaultsAccepted) WithPayload(payload *models.TCPCheck) *CreateTCPCheckDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check defaults accepted response +func (o *CreateTCPCheckDefaultsAccepted) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPCheckDefaultsBadRequestCode is the HTTP code returned for type CreateTCPCheckDefaultsBadRequest +const CreateTCPCheckDefaultsBadRequestCode int = 400 + +/* +CreateTCPCheckDefaultsBadRequest Bad request + +swagger:response createTcpCheckDefaultsBadRequest +*/ +type CreateTCPCheckDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPCheckDefaultsBadRequest creates CreateTCPCheckDefaultsBadRequest with default headers values +func NewCreateTCPCheckDefaultsBadRequest() *CreateTCPCheckDefaultsBadRequest { + + return &CreateTCPCheckDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp check defaults bad request response +func (o *CreateTCPCheckDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTCPCheckDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp check defaults bad request response +func (o *CreateTCPCheckDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp check defaults bad request response +func (o *CreateTCPCheckDefaultsBadRequest) WithPayload(payload *models.Error) *CreateTCPCheckDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check defaults bad request response +func (o *CreateTCPCheckDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPCheckDefaultsConflictCode is the HTTP code returned for type CreateTCPCheckDefaultsConflict +const CreateTCPCheckDefaultsConflictCode int = 409 + +/* +CreateTCPCheckDefaultsConflict The specified resource already exists + +swagger:response createTcpCheckDefaultsConflict +*/ +type CreateTCPCheckDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPCheckDefaultsConflict creates CreateTCPCheckDefaultsConflict with default headers values +func NewCreateTCPCheckDefaultsConflict() *CreateTCPCheckDefaultsConflict { + + return &CreateTCPCheckDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp check defaults conflict response +func (o *CreateTCPCheckDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateTCPCheckDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp check defaults conflict response +func (o *CreateTCPCheckDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp check defaults conflict response +func (o *CreateTCPCheckDefaultsConflict) WithPayload(payload *models.Error) *CreateTCPCheckDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp check defaults conflict response +func (o *CreateTCPCheckDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTCPCheckDefaultsDefault General Error + +swagger:response createTcpCheckDefaultsDefault +*/ +type CreateTCPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPCheckDefaultsDefault creates CreateTCPCheckDefaultsDefault with default headers values +func NewCreateTCPCheckDefaultsDefault(code int) *CreateTCPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateTCPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create TCP check defaults default response +func (o *CreateTCPCheckDefaultsDefault) WithStatusCode(code int) *CreateTCPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create TCP check defaults default response +func (o *CreateTCPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create TCP check defaults default response +func (o *CreateTCPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateTCPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create TCP check defaults default response +func (o *CreateTCPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create TCP check defaults default response +func (o *CreateTCPCheckDefaultsDefault) WithPayload(payload *models.Error) *CreateTCPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create TCP check defaults default response +func (o *CreateTCPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/create_tcp_check_defaults_urlbuilder.go b/operations/tcp_check/create_tcp_check_defaults_urlbuilder.go new file mode 100644 index 00000000..de6e6266 --- /dev/null +++ b/operations/tcp_check/create_tcp_check_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTCPCheckDefaultsURL generates an URL for the create TCP check defaults operation +type CreateTCPCheckDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPCheckDefaultsURL) WithBasePath(bp string) *CreateTCPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTCPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateTCPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTCPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTCPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTCPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTCPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTCPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTCPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTCPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/delete_tcp_check_backend.go b/operations/tcp_check/delete_tcp_check_backend.go new file mode 100644 index 00000000..ebdd057e --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTCPCheckBackendHandlerFunc turns a function with the right signature into a delete TCP check backend handler +type DeleteTCPCheckBackendHandlerFunc func(DeleteTCPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTCPCheckBackendHandlerFunc) Handle(params DeleteTCPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTCPCheckBackendHandler interface for that can handle valid delete TCP check backend params +type DeleteTCPCheckBackendHandler interface { + Handle(DeleteTCPCheckBackendParams, interface{}) middleware.Responder +} + +// NewDeleteTCPCheckBackend creates a new http.Handler for the delete TCP check backend operation +func NewDeleteTCPCheckBackend(ctx *middleware.Context, handler DeleteTCPCheckBackendHandler) *DeleteTCPCheckBackend { + return &DeleteTCPCheckBackend{Context: ctx, Handler: handler} +} + +/* + DeleteTCPCheckBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index} TCPCheck deleteTcpCheckBackend + +# Delete a TCP check + +Deletes a TCP check configuration by it's index from the specified parent. +*/ +type DeleteTCPCheckBackend struct { + Context *middleware.Context + Handler DeleteTCPCheckBackendHandler +} + +func (o *DeleteTCPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTCPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/delete_tcp_check_backend_parameters.go b/operations/tcp_check/delete_tcp_check_backend_parameters.go new file mode 100644 index 00000000..e3a771cf --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTCPCheckBackendParams creates a new DeleteTCPCheckBackendParams object +// with the default values initialized. +func NewDeleteTCPCheckBackendParams() DeleteTCPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTCPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTCPCheckBackendParams contains all the bound params for the delete TCP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTCPCheckBackend +type DeleteTCPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTCPCheckBackendParams() beforehand. +func (o *DeleteTCPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTCPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTCPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteTCPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTCPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTCPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTCPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/delete_tcp_check_backend_responses.go b/operations/tcp_check/delete_tcp_check_backend_responses.go new file mode 100644 index 00000000..2586c358 --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTCPCheckBackendAcceptedCode is the HTTP code returned for type DeleteTCPCheckBackendAccepted +const DeleteTCPCheckBackendAcceptedCode int = 202 + +/* +DeleteTCPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteTcpCheckBackendAccepted +*/ +type DeleteTCPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTCPCheckBackendAccepted creates DeleteTCPCheckBackendAccepted with default headers values +func NewDeleteTCPCheckBackendAccepted() *DeleteTCPCheckBackendAccepted { + + return &DeleteTCPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Tcp check backend accepted response +func (o *DeleteTCPCheckBackendAccepted) WithReloadID(reloadID string) *DeleteTCPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Tcp check backend accepted response +func (o *DeleteTCPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTCPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTCPCheckBackendNoContentCode is the HTTP code returned for type DeleteTCPCheckBackendNoContent +const DeleteTCPCheckBackendNoContentCode int = 204 + +/* +DeleteTCPCheckBackendNoContent TCP check deleted + +swagger:response deleteTcpCheckBackendNoContent +*/ +type DeleteTCPCheckBackendNoContent struct { +} + +// NewDeleteTCPCheckBackendNoContent creates DeleteTCPCheckBackendNoContent with default headers values +func NewDeleteTCPCheckBackendNoContent() *DeleteTCPCheckBackendNoContent { + + return &DeleteTCPCheckBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTCPCheckBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTCPCheckBackendNotFoundCode is the HTTP code returned for type DeleteTCPCheckBackendNotFound +const DeleteTCPCheckBackendNotFoundCode int = 404 + +/* +DeleteTCPCheckBackendNotFound The specified resource was not found + +swagger:response deleteTcpCheckBackendNotFound +*/ +type DeleteTCPCheckBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPCheckBackendNotFound creates DeleteTCPCheckBackendNotFound with default headers values +func NewDeleteTCPCheckBackendNotFound() *DeleteTCPCheckBackendNotFound { + + return &DeleteTCPCheckBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Tcp check backend not found response +func (o *DeleteTCPCheckBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTCPCheckBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Tcp check backend not found response +func (o *DeleteTCPCheckBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Tcp check backend not found response +func (o *DeleteTCPCheckBackendNotFound) WithPayload(payload *models.Error) *DeleteTCPCheckBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Tcp check backend not found response +func (o *DeleteTCPCheckBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPCheckBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTCPCheckBackendDefault General Error + +swagger:response deleteTcpCheckBackendDefault +*/ +type DeleteTCPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPCheckBackendDefault creates DeleteTCPCheckBackendDefault with default headers values +func NewDeleteTCPCheckBackendDefault(code int) *DeleteTCPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTCPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete TCP check backend default response +func (o *DeleteTCPCheckBackendDefault) WithStatusCode(code int) *DeleteTCPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete TCP check backend default response +func (o *DeleteTCPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete TCP check backend default response +func (o *DeleteTCPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteTCPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete TCP check backend default response +func (o *DeleteTCPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete TCP check backend default response +func (o *DeleteTCPCheckBackendDefault) WithPayload(payload *models.Error) *DeleteTCPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete TCP check backend default response +func (o *DeleteTCPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/delete_tcp_check_backend_urlbuilder.go b/operations/tcp_check/delete_tcp_check_backend_urlbuilder.go new file mode 100644 index 00000000..80ee8b38 --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTCPCheckBackendURL generates an URL for the delete TCP check backend operation +type DeleteTCPCheckBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPCheckBackendURL) WithBasePath(bp string) *DeleteTCPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTCPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteTCPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTCPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTCPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTCPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTCPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTCPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTCPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTCPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/delete_tcp_check_defaults.go b/operations/tcp_check/delete_tcp_check_defaults.go new file mode 100644 index 00000000..8f10dee7 --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTCPCheckDefaultsHandlerFunc turns a function with the right signature into a delete TCP check defaults handler +type DeleteTCPCheckDefaultsHandlerFunc func(DeleteTCPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTCPCheckDefaultsHandlerFunc) Handle(params DeleteTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTCPCheckDefaultsHandler interface for that can handle valid delete TCP check defaults params +type DeleteTCPCheckDefaultsHandler interface { + Handle(DeleteTCPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteTCPCheckDefaults creates a new http.Handler for the delete TCP check defaults operation +func NewDeleteTCPCheckDefaults(ctx *middleware.Context, handler DeleteTCPCheckDefaultsHandler) *DeleteTCPCheckDefaults { + return &DeleteTCPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteTCPCheckDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index} TCPCheck deleteTcpCheckDefaults + +# Delete a TCP check + +Deletes a TCP check configuration by it's index from the specified parent. +*/ +type DeleteTCPCheckDefaults struct { + Context *middleware.Context + Handler DeleteTCPCheckDefaultsHandler +} + +func (o *DeleteTCPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTCPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/delete_tcp_check_defaults_parameters.go b/operations/tcp_check/delete_tcp_check_defaults_parameters.go new file mode 100644 index 00000000..16582b44 --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTCPCheckDefaultsParams creates a new DeleteTCPCheckDefaultsParams object +// with the default values initialized. +func NewDeleteTCPCheckDefaultsParams() DeleteTCPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTCPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTCPCheckDefaultsParams contains all the bound params for the delete TCP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTCPCheckDefaults +type DeleteTCPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTCPCheckDefaultsParams() beforehand. +func (o *DeleteTCPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTCPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTCPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteTCPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTCPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTCPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTCPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/delete_tcp_check_defaults_responses.go b/operations/tcp_check/delete_tcp_check_defaults_responses.go new file mode 100644 index 00000000..083463c0 --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTCPCheckDefaultsAcceptedCode is the HTTP code returned for type DeleteTCPCheckDefaultsAccepted +const DeleteTCPCheckDefaultsAcceptedCode int = 202 + +/* +DeleteTCPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteTcpCheckDefaultsAccepted +*/ +type DeleteTCPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTCPCheckDefaultsAccepted creates DeleteTCPCheckDefaultsAccepted with default headers values +func NewDeleteTCPCheckDefaultsAccepted() *DeleteTCPCheckDefaultsAccepted { + + return &DeleteTCPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Tcp check defaults accepted response +func (o *DeleteTCPCheckDefaultsAccepted) WithReloadID(reloadID string) *DeleteTCPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Tcp check defaults accepted response +func (o *DeleteTCPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTCPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTCPCheckDefaultsNoContentCode is the HTTP code returned for type DeleteTCPCheckDefaultsNoContent +const DeleteTCPCheckDefaultsNoContentCode int = 204 + +/* +DeleteTCPCheckDefaultsNoContent TCP check deleted + +swagger:response deleteTcpCheckDefaultsNoContent +*/ +type DeleteTCPCheckDefaultsNoContent struct { +} + +// NewDeleteTCPCheckDefaultsNoContent creates DeleteTCPCheckDefaultsNoContent with default headers values +func NewDeleteTCPCheckDefaultsNoContent() *DeleteTCPCheckDefaultsNoContent { + + return &DeleteTCPCheckDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTCPCheckDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTCPCheckDefaultsNotFoundCode is the HTTP code returned for type DeleteTCPCheckDefaultsNotFound +const DeleteTCPCheckDefaultsNotFoundCode int = 404 + +/* +DeleteTCPCheckDefaultsNotFound The specified resource was not found + +swagger:response deleteTcpCheckDefaultsNotFound +*/ +type DeleteTCPCheckDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPCheckDefaultsNotFound creates DeleteTCPCheckDefaultsNotFound with default headers values +func NewDeleteTCPCheckDefaultsNotFound() *DeleteTCPCheckDefaultsNotFound { + + return &DeleteTCPCheckDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Tcp check defaults not found response +func (o *DeleteTCPCheckDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTCPCheckDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Tcp check defaults not found response +func (o *DeleteTCPCheckDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Tcp check defaults not found response +func (o *DeleteTCPCheckDefaultsNotFound) WithPayload(payload *models.Error) *DeleteTCPCheckDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Tcp check defaults not found response +func (o *DeleteTCPCheckDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPCheckDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTCPCheckDefaultsDefault General Error + +swagger:response deleteTcpCheckDefaultsDefault +*/ +type DeleteTCPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPCheckDefaultsDefault creates DeleteTCPCheckDefaultsDefault with default headers values +func NewDeleteTCPCheckDefaultsDefault(code int) *DeleteTCPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTCPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete TCP check defaults default response +func (o *DeleteTCPCheckDefaultsDefault) WithStatusCode(code int) *DeleteTCPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete TCP check defaults default response +func (o *DeleteTCPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete TCP check defaults default response +func (o *DeleteTCPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteTCPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete TCP check defaults default response +func (o *DeleteTCPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete TCP check defaults default response +func (o *DeleteTCPCheckDefaultsDefault) WithPayload(payload *models.Error) *DeleteTCPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete TCP check defaults default response +func (o *DeleteTCPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/delete_tcp_check_defaults_urlbuilder.go b/operations/tcp_check/delete_tcp_check_defaults_urlbuilder.go new file mode 100644 index 00000000..833c21e8 --- /dev/null +++ b/operations/tcp_check/delete_tcp_check_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTCPCheckDefaultsURL generates an URL for the delete TCP check defaults operation +type DeleteTCPCheckDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPCheckDefaultsURL) WithBasePath(bp string) *DeleteTCPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTCPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteTCPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTCPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTCPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTCPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTCPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTCPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTCPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTCPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/get_all_tcp_check_backend.go b/operations/tcp_check/get_all_tcp_check_backend.go new file mode 100644 index 00000000..aa4ce745 --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllTCPCheckBackendHandlerFunc turns a function with the right signature into a get all TCP check backend handler +type GetAllTCPCheckBackendHandlerFunc func(GetAllTCPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllTCPCheckBackendHandlerFunc) Handle(params GetAllTCPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllTCPCheckBackendHandler interface for that can handle valid get all TCP check backend params +type GetAllTCPCheckBackendHandler interface { + Handle(GetAllTCPCheckBackendParams, interface{}) middleware.Responder +} + +// NewGetAllTCPCheckBackend creates a new http.Handler for the get all TCP check backend operation +func NewGetAllTCPCheckBackend(ctx *middleware.Context, handler GetAllTCPCheckBackendHandler) *GetAllTCPCheckBackend { + return &GetAllTCPCheckBackend{Context: ctx, Handler: handler} +} + +/* + GetAllTCPCheckBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/tcp_checks TCPCheck getAllTcpCheckBackend + +# Return an array of TCP checks + +Returns all TCP checks that are configured in specified parent. +*/ +type GetAllTCPCheckBackend struct { + Context *middleware.Context + Handler GetAllTCPCheckBackendHandler +} + +func (o *GetAllTCPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllTCPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/get_all_tcp_check_backend_parameters.go b/operations/tcp_check/get_all_tcp_check_backend_parameters.go new file mode 100644 index 00000000..2871e6f8 --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllTCPCheckBackendParams creates a new GetAllTCPCheckBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllTCPCheckBackendParams() GetAllTCPCheckBackendParams { + + return GetAllTCPCheckBackendParams{} +} + +// GetAllTCPCheckBackendParams contains all the bound params for the get all TCP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllTCPCheckBackend +type GetAllTCPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllTCPCheckBackendParams() beforehand. +func (o *GetAllTCPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllTCPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllTCPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_check/get_all_tcp_check_backend_responses.go b/operations/tcp_check/get_all_tcp_check_backend_responses.go new file mode 100644 index 00000000..3a3d7624 --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllTCPCheckBackendOKCode is the HTTP code returned for type GetAllTCPCheckBackendOK +const GetAllTCPCheckBackendOKCode int = 200 + +/* +GetAllTCPCheckBackendOK Successful operation + +swagger:response getAllTcpCheckBackendOK +*/ +type GetAllTCPCheckBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.TCPChecks `json:"body,omitempty"` +} + +// NewGetAllTCPCheckBackendOK creates GetAllTCPCheckBackendOK with default headers values +func NewGetAllTCPCheckBackendOK() *GetAllTCPCheckBackendOK { + + return &GetAllTCPCheckBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Tcp check backend o k response +func (o *GetAllTCPCheckBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllTCPCheckBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Tcp check backend o k response +func (o *GetAllTCPCheckBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Tcp check backend o k response +func (o *GetAllTCPCheckBackendOK) WithPayload(payload models.TCPChecks) *GetAllTCPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Tcp check backend o k response +func (o *GetAllTCPCheckBackendOK) SetPayload(payload models.TCPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllTCPCheckBackendDefault General Error + +swagger:response getAllTcpCheckBackendDefault +*/ +type GetAllTCPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllTCPCheckBackendDefault creates GetAllTCPCheckBackendDefault with default headers values +func NewGetAllTCPCheckBackendDefault(code int) *GetAllTCPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllTCPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all TCP check backend default response +func (o *GetAllTCPCheckBackendDefault) WithStatusCode(code int) *GetAllTCPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all TCP check backend default response +func (o *GetAllTCPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all TCP check backend default response +func (o *GetAllTCPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllTCPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all TCP check backend default response +func (o *GetAllTCPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all TCP check backend default response +func (o *GetAllTCPCheckBackendDefault) WithPayload(payload *models.Error) *GetAllTCPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all TCP check backend default response +func (o *GetAllTCPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/get_all_tcp_check_backend_urlbuilder.go b/operations/tcp_check/get_all_tcp_check_backend_urlbuilder.go new file mode 100644 index 00000000..4885180a --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllTCPCheckBackendURL generates an URL for the get all TCP check backend operation +type GetAllTCPCheckBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPCheckBackendURL) WithBasePath(bp string) *GetAllTCPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllTCPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllTCPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllTCPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllTCPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllTCPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllTCPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllTCPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllTCPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/get_all_tcp_check_defaults.go b/operations/tcp_check/get_all_tcp_check_defaults.go new file mode 100644 index 00000000..fb234eec --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllTCPCheckDefaultsHandlerFunc turns a function with the right signature into a get all TCP check defaults handler +type GetAllTCPCheckDefaultsHandlerFunc func(GetAllTCPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllTCPCheckDefaultsHandlerFunc) Handle(params GetAllTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllTCPCheckDefaultsHandler interface for that can handle valid get all TCP check defaults params +type GetAllTCPCheckDefaultsHandler interface { + Handle(GetAllTCPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllTCPCheckDefaults creates a new http.Handler for the get all TCP check defaults operation +func NewGetAllTCPCheckDefaults(ctx *middleware.Context, handler GetAllTCPCheckDefaultsHandler) *GetAllTCPCheckDefaults { + return &GetAllTCPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllTCPCheckDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/tcp_checks TCPCheck getAllTcpCheckDefaults + +# Return an array of TCP checks + +Returns all TCP checks that are configured in specified parent. +*/ +type GetAllTCPCheckDefaults struct { + Context *middleware.Context + Handler GetAllTCPCheckDefaultsHandler +} + +func (o *GetAllTCPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllTCPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/get_all_tcp_check_defaults_parameters.go b/operations/tcp_check/get_all_tcp_check_defaults_parameters.go new file mode 100644 index 00000000..3001d2e3 --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllTCPCheckDefaultsParams creates a new GetAllTCPCheckDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllTCPCheckDefaultsParams() GetAllTCPCheckDefaultsParams { + + return GetAllTCPCheckDefaultsParams{} +} + +// GetAllTCPCheckDefaultsParams contains all the bound params for the get all TCP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllTCPCheckDefaults +type GetAllTCPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllTCPCheckDefaultsParams() beforehand. +func (o *GetAllTCPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllTCPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllTCPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_check/get_all_tcp_check_defaults_responses.go b/operations/tcp_check/get_all_tcp_check_defaults_responses.go new file mode 100644 index 00000000..f8f03c9d --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllTCPCheckDefaultsOKCode is the HTTP code returned for type GetAllTCPCheckDefaultsOK +const GetAllTCPCheckDefaultsOKCode int = 200 + +/* +GetAllTCPCheckDefaultsOK Successful operation + +swagger:response getAllTcpCheckDefaultsOK +*/ +type GetAllTCPCheckDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.TCPChecks `json:"body,omitempty"` +} + +// NewGetAllTCPCheckDefaultsOK creates GetAllTCPCheckDefaultsOK with default headers values +func NewGetAllTCPCheckDefaultsOK() *GetAllTCPCheckDefaultsOK { + + return &GetAllTCPCheckDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Tcp check defaults o k response +func (o *GetAllTCPCheckDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllTCPCheckDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Tcp check defaults o k response +func (o *GetAllTCPCheckDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Tcp check defaults o k response +func (o *GetAllTCPCheckDefaultsOK) WithPayload(payload models.TCPChecks) *GetAllTCPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Tcp check defaults o k response +func (o *GetAllTCPCheckDefaultsOK) SetPayload(payload models.TCPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllTCPCheckDefaultsDefault General Error + +swagger:response getAllTcpCheckDefaultsDefault +*/ +type GetAllTCPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllTCPCheckDefaultsDefault creates GetAllTCPCheckDefaultsDefault with default headers values +func NewGetAllTCPCheckDefaultsDefault(code int) *GetAllTCPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllTCPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all TCP check defaults default response +func (o *GetAllTCPCheckDefaultsDefault) WithStatusCode(code int) *GetAllTCPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all TCP check defaults default response +func (o *GetAllTCPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all TCP check defaults default response +func (o *GetAllTCPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllTCPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all TCP check defaults default response +func (o *GetAllTCPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all TCP check defaults default response +func (o *GetAllTCPCheckDefaultsDefault) WithPayload(payload *models.Error) *GetAllTCPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all TCP check defaults default response +func (o *GetAllTCPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/get_all_tcp_check_defaults_urlbuilder.go b/operations/tcp_check/get_all_tcp_check_defaults_urlbuilder.go new file mode 100644 index 00000000..587fdcd0 --- /dev/null +++ b/operations/tcp_check/get_all_tcp_check_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllTCPCheckDefaultsURL generates an URL for the get all TCP check defaults operation +type GetAllTCPCheckDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPCheckDefaultsURL) WithBasePath(bp string) *GetAllTCPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllTCPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllTCPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllTCPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllTCPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllTCPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllTCPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllTCPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllTCPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/get_tcp_check_backend.go b/operations/tcp_check/get_tcp_check_backend.go new file mode 100644 index 00000000..a6f040b9 --- /dev/null +++ b/operations/tcp_check/get_tcp_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTCPCheckBackendHandlerFunc turns a function with the right signature into a get TCP check backend handler +type GetTCPCheckBackendHandlerFunc func(GetTCPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTCPCheckBackendHandlerFunc) Handle(params GetTCPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTCPCheckBackendHandler interface for that can handle valid get TCP check backend params +type GetTCPCheckBackendHandler interface { + Handle(GetTCPCheckBackendParams, interface{}) middleware.Responder +} + +// NewGetTCPCheckBackend creates a new http.Handler for the get TCP check backend operation +func NewGetTCPCheckBackend(ctx *middleware.Context, handler GetTCPCheckBackendHandler) *GetTCPCheckBackend { + return &GetTCPCheckBackend{Context: ctx, Handler: handler} +} + +/* + GetTCPCheckBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index} TCPCheck getTcpCheckBackend + +# Return one TCP check + +Returns one TCP check configuration by it's index in the specified parent. +*/ +type GetTCPCheckBackend struct { + Context *middleware.Context + Handler GetTCPCheckBackendHandler +} + +func (o *GetTCPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTCPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/get_tcp_check_backend_parameters.go b/operations/tcp_check/get_tcp_check_backend_parameters.go new file mode 100644 index 00000000..499447cc --- /dev/null +++ b/operations/tcp_check/get_tcp_check_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTCPCheckBackendParams creates a new GetTCPCheckBackendParams object +// +// There are no default values defined in the spec. +func NewGetTCPCheckBackendParams() GetTCPCheckBackendParams { + + return GetTCPCheckBackendParams{} +} + +// GetTCPCheckBackendParams contains all the bound params for the get TCP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTCPCheckBackend +type GetTCPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*TCP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTCPCheckBackendParams() beforehand. +func (o *GetTCPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetTCPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTCPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTCPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_check/get_tcp_check_backend_responses.go b/operations/tcp_check/get_tcp_check_backend_responses.go new file mode 100644 index 00000000..19e87168 --- /dev/null +++ b/operations/tcp_check/get_tcp_check_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTCPCheckBackendOKCode is the HTTP code returned for type GetTCPCheckBackendOK +const GetTCPCheckBackendOKCode int = 200 + +/* +GetTCPCheckBackendOK Successful operation + +swagger:response getTcpCheckBackendOK +*/ +type GetTCPCheckBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewGetTCPCheckBackendOK creates GetTCPCheckBackendOK with default headers values +func NewGetTCPCheckBackendOK() *GetTCPCheckBackendOK { + + return &GetTCPCheckBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp check backend o k response +func (o *GetTCPCheckBackendOK) WithConfigurationVersion(configurationVersion string) *GetTCPCheckBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp check backend o k response +func (o *GetTCPCheckBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp check backend o k response +func (o *GetTCPCheckBackendOK) WithPayload(payload *models.TCPCheck) *GetTCPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp check backend o k response +func (o *GetTCPCheckBackendOK) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTCPCheckBackendNotFoundCode is the HTTP code returned for type GetTCPCheckBackendNotFound +const GetTCPCheckBackendNotFoundCode int = 404 + +/* +GetTCPCheckBackendNotFound The specified resource was not found + +swagger:response getTcpCheckBackendNotFound +*/ +type GetTCPCheckBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPCheckBackendNotFound creates GetTCPCheckBackendNotFound with default headers values +func NewGetTCPCheckBackendNotFound() *GetTCPCheckBackendNotFound { + + return &GetTCPCheckBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp check backend not found response +func (o *GetTCPCheckBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetTCPCheckBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp check backend not found response +func (o *GetTCPCheckBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp check backend not found response +func (o *GetTCPCheckBackendNotFound) WithPayload(payload *models.Error) *GetTCPCheckBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp check backend not found response +func (o *GetTCPCheckBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPCheckBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTCPCheckBackendDefault General Error + +swagger:response getTcpCheckBackendDefault +*/ +type GetTCPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPCheckBackendDefault creates GetTCPCheckBackendDefault with default headers values +func NewGetTCPCheckBackendDefault(code int) *GetTCPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetTCPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get TCP check backend default response +func (o *GetTCPCheckBackendDefault) WithStatusCode(code int) *GetTCPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get TCP check backend default response +func (o *GetTCPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get TCP check backend default response +func (o *GetTCPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *GetTCPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get TCP check backend default response +func (o *GetTCPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get TCP check backend default response +func (o *GetTCPCheckBackendDefault) WithPayload(payload *models.Error) *GetTCPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get TCP check backend default response +func (o *GetTCPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/get_tcp_check_backend_urlbuilder.go b/operations/tcp_check/get_tcp_check_backend_urlbuilder.go new file mode 100644 index 00000000..579e6e30 --- /dev/null +++ b/operations/tcp_check/get_tcp_check_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetTCPCheckBackendURL generates an URL for the get TCP check backend operation +type GetTCPCheckBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPCheckBackendURL) WithBasePath(bp string) *GetTCPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTCPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetTCPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTCPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTCPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTCPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTCPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTCPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTCPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTCPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/get_tcp_check_defaults.go b/operations/tcp_check/get_tcp_check_defaults.go new file mode 100644 index 00000000..4383d688 --- /dev/null +++ b/operations/tcp_check/get_tcp_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTCPCheckDefaultsHandlerFunc turns a function with the right signature into a get TCP check defaults handler +type GetTCPCheckDefaultsHandlerFunc func(GetTCPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTCPCheckDefaultsHandlerFunc) Handle(params GetTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTCPCheckDefaultsHandler interface for that can handle valid get TCP check defaults params +type GetTCPCheckDefaultsHandler interface { + Handle(GetTCPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewGetTCPCheckDefaults creates a new http.Handler for the get TCP check defaults operation +func NewGetTCPCheckDefaults(ctx *middleware.Context, handler GetTCPCheckDefaultsHandler) *GetTCPCheckDefaults { + return &GetTCPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + GetTCPCheckDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index} TCPCheck getTcpCheckDefaults + +# Return one TCP check + +Returns one TCP check configuration by it's index in the specified parent. +*/ +type GetTCPCheckDefaults struct { + Context *middleware.Context + Handler GetTCPCheckDefaultsHandler +} + +func (o *GetTCPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTCPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/get_tcp_check_defaults_parameters.go b/operations/tcp_check/get_tcp_check_defaults_parameters.go new file mode 100644 index 00000000..8ea37fff --- /dev/null +++ b/operations/tcp_check/get_tcp_check_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTCPCheckDefaultsParams creates a new GetTCPCheckDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetTCPCheckDefaultsParams() GetTCPCheckDefaultsParams { + + return GetTCPCheckDefaultsParams{} +} + +// GetTCPCheckDefaultsParams contains all the bound params for the get TCP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTCPCheckDefaults +type GetTCPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*TCP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTCPCheckDefaultsParams() beforehand. +func (o *GetTCPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetTCPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTCPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTCPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_check/get_tcp_check_defaults_responses.go b/operations/tcp_check/get_tcp_check_defaults_responses.go new file mode 100644 index 00000000..81cbd560 --- /dev/null +++ b/operations/tcp_check/get_tcp_check_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTCPCheckDefaultsOKCode is the HTTP code returned for type GetTCPCheckDefaultsOK +const GetTCPCheckDefaultsOKCode int = 200 + +/* +GetTCPCheckDefaultsOK Successful operation + +swagger:response getTcpCheckDefaultsOK +*/ +type GetTCPCheckDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewGetTCPCheckDefaultsOK creates GetTCPCheckDefaultsOK with default headers values +func NewGetTCPCheckDefaultsOK() *GetTCPCheckDefaultsOK { + + return &GetTCPCheckDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp check defaults o k response +func (o *GetTCPCheckDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetTCPCheckDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp check defaults o k response +func (o *GetTCPCheckDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp check defaults o k response +func (o *GetTCPCheckDefaultsOK) WithPayload(payload *models.TCPCheck) *GetTCPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp check defaults o k response +func (o *GetTCPCheckDefaultsOK) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTCPCheckDefaultsNotFoundCode is the HTTP code returned for type GetTCPCheckDefaultsNotFound +const GetTCPCheckDefaultsNotFoundCode int = 404 + +/* +GetTCPCheckDefaultsNotFound The specified resource was not found + +swagger:response getTcpCheckDefaultsNotFound +*/ +type GetTCPCheckDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPCheckDefaultsNotFound creates GetTCPCheckDefaultsNotFound with default headers values +func NewGetTCPCheckDefaultsNotFound() *GetTCPCheckDefaultsNotFound { + + return &GetTCPCheckDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp check defaults not found response +func (o *GetTCPCheckDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetTCPCheckDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp check defaults not found response +func (o *GetTCPCheckDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp check defaults not found response +func (o *GetTCPCheckDefaultsNotFound) WithPayload(payload *models.Error) *GetTCPCheckDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp check defaults not found response +func (o *GetTCPCheckDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPCheckDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTCPCheckDefaultsDefault General Error + +swagger:response getTcpCheckDefaultsDefault +*/ +type GetTCPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPCheckDefaultsDefault creates GetTCPCheckDefaultsDefault with default headers values +func NewGetTCPCheckDefaultsDefault(code int) *GetTCPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetTCPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get TCP check defaults default response +func (o *GetTCPCheckDefaultsDefault) WithStatusCode(code int) *GetTCPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get TCP check defaults default response +func (o *GetTCPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get TCP check defaults default response +func (o *GetTCPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetTCPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get TCP check defaults default response +func (o *GetTCPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get TCP check defaults default response +func (o *GetTCPCheckDefaultsDefault) WithPayload(payload *models.Error) *GetTCPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get TCP check defaults default response +func (o *GetTCPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/get_tcp_check_defaults_urlbuilder.go b/operations/tcp_check/get_tcp_check_defaults_urlbuilder.go new file mode 100644 index 00000000..2ca0cf04 --- /dev/null +++ b/operations/tcp_check/get_tcp_check_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetTCPCheckDefaultsURL generates an URL for the get TCP check defaults operation +type GetTCPCheckDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPCheckDefaultsURL) WithBasePath(bp string) *GetTCPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTCPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetTCPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTCPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTCPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTCPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTCPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTCPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTCPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTCPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/replace_all_tcp_check_backend.go b/operations/tcp_check/replace_all_tcp_check_backend.go new file mode 100644 index 00000000..3e57fcb3 --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllTCPCheckBackendHandlerFunc turns a function with the right signature into a replace all TCP check backend handler +type ReplaceAllTCPCheckBackendHandlerFunc func(ReplaceAllTCPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllTCPCheckBackendHandlerFunc) Handle(params ReplaceAllTCPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllTCPCheckBackendHandler interface for that can handle valid replace all TCP check backend params +type ReplaceAllTCPCheckBackendHandler interface { + Handle(ReplaceAllTCPCheckBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllTCPCheckBackend creates a new http.Handler for the replace all TCP check backend operation +func NewReplaceAllTCPCheckBackend(ctx *middleware.Context, handler ReplaceAllTCPCheckBackendHandler) *ReplaceAllTCPCheckBackend { + return &ReplaceAllTCPCheckBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllTCPCheckBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/tcp_checks TCPCheck replaceAllTcpCheckBackend + +# Replace an TCP Check list + +Replaces a whole list of TCP Checks with the list given in parameter +*/ +type ReplaceAllTCPCheckBackend struct { + Context *middleware.Context + Handler ReplaceAllTCPCheckBackendHandler +} + +func (o *ReplaceAllTCPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllTCPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/replace_all_tcp_check_backend_parameters.go b/operations/tcp_check/replace_all_tcp_check_backend_parameters.go new file mode 100644 index 00000000..16c59bed --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllTCPCheckBackendParams creates a new ReplaceAllTCPCheckBackendParams object +// with the default values initialized. +func NewReplaceAllTCPCheckBackendParams() ReplaceAllTCPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllTCPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllTCPCheckBackendParams contains all the bound params for the replace all TCP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllTCPCheckBackend +type ReplaceAllTCPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.TCPChecks + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllTCPCheckBackendParams() beforehand. +func (o *ReplaceAllTCPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPChecks + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllTCPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllTCPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllTCPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllTCPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllTCPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/replace_all_tcp_check_backend_responses.go b/operations/tcp_check/replace_all_tcp_check_backend_responses.go new file mode 100644 index 00000000..c6f7950b --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllTCPCheckBackendOKCode is the HTTP code returned for type ReplaceAllTCPCheckBackendOK +const ReplaceAllTCPCheckBackendOKCode int = 200 + +/* +ReplaceAllTCPCheckBackendOK All TCP Check lines replaced + +swagger:response replaceAllTcpCheckBackendOK +*/ +type ReplaceAllTCPCheckBackendOK struct { + + /* + In: Body + */ + Payload models.TCPChecks `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckBackendOK creates ReplaceAllTCPCheckBackendOK with default headers values +func NewReplaceAllTCPCheckBackendOK() *ReplaceAllTCPCheckBackendOK { + + return &ReplaceAllTCPCheckBackendOK{} +} + +// WithPayload adds the payload to the replace all Tcp check backend o k response +func (o *ReplaceAllTCPCheckBackendOK) WithPayload(payload models.TCPChecks) *ReplaceAllTCPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp check backend o k response +func (o *ReplaceAllTCPCheckBackendOK) SetPayload(payload models.TCPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPCheckBackendAcceptedCode is the HTTP code returned for type ReplaceAllTCPCheckBackendAccepted +const ReplaceAllTCPCheckBackendAcceptedCode int = 202 + +/* +ReplaceAllTCPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllTcpCheckBackendAccepted +*/ +type ReplaceAllTCPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.TCPChecks `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckBackendAccepted creates ReplaceAllTCPCheckBackendAccepted with default headers values +func NewReplaceAllTCPCheckBackendAccepted() *ReplaceAllTCPCheckBackendAccepted { + + return &ReplaceAllTCPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Tcp check backend accepted response +func (o *ReplaceAllTCPCheckBackendAccepted) WithReloadID(reloadID string) *ReplaceAllTCPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Tcp check backend accepted response +func (o *ReplaceAllTCPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Tcp check backend accepted response +func (o *ReplaceAllTCPCheckBackendAccepted) WithPayload(payload models.TCPChecks) *ReplaceAllTCPCheckBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp check backend accepted response +func (o *ReplaceAllTCPCheckBackendAccepted) SetPayload(payload models.TCPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPCheckBackendBadRequestCode is the HTTP code returned for type ReplaceAllTCPCheckBackendBadRequest +const ReplaceAllTCPCheckBackendBadRequestCode int = 400 + +/* +ReplaceAllTCPCheckBackendBadRequest Bad request + +swagger:response replaceAllTcpCheckBackendBadRequest +*/ +type ReplaceAllTCPCheckBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckBackendBadRequest creates ReplaceAllTCPCheckBackendBadRequest with default headers values +func NewReplaceAllTCPCheckBackendBadRequest() *ReplaceAllTCPCheckBackendBadRequest { + + return &ReplaceAllTCPCheckBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Tcp check backend bad request response +func (o *ReplaceAllTCPCheckBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPCheckBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Tcp check backend bad request response +func (o *ReplaceAllTCPCheckBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Tcp check backend bad request response +func (o *ReplaceAllTCPCheckBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllTCPCheckBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp check backend bad request response +func (o *ReplaceAllTCPCheckBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllTCPCheckBackendDefault General Error + +swagger:response replaceAllTcpCheckBackendDefault +*/ +type ReplaceAllTCPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckBackendDefault creates ReplaceAllTCPCheckBackendDefault with default headers values +func NewReplaceAllTCPCheckBackendDefault(code int) *ReplaceAllTCPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllTCPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all TCP check backend default response +func (o *ReplaceAllTCPCheckBackendDefault) WithStatusCode(code int) *ReplaceAllTCPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all TCP check backend default response +func (o *ReplaceAllTCPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all TCP check backend default response +func (o *ReplaceAllTCPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all TCP check backend default response +func (o *ReplaceAllTCPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all TCP check backend default response +func (o *ReplaceAllTCPCheckBackendDefault) WithPayload(payload *models.Error) *ReplaceAllTCPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all TCP check backend default response +func (o *ReplaceAllTCPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/replace_all_tcp_check_backend_urlbuilder.go b/operations/tcp_check/replace_all_tcp_check_backend_urlbuilder.go new file mode 100644 index 00000000..2bf293fe --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllTCPCheckBackendURL generates an URL for the replace all TCP check backend operation +type ReplaceAllTCPCheckBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPCheckBackendURL) WithBasePath(bp string) *ReplaceAllTCPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllTCPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllTCPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllTCPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllTCPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllTCPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllTCPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllTCPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllTCPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/replace_all_tcp_check_defaults.go b/operations/tcp_check/replace_all_tcp_check_defaults.go new file mode 100644 index 00000000..bff0b866 --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllTCPCheckDefaultsHandlerFunc turns a function with the right signature into a replace all TCP check defaults handler +type ReplaceAllTCPCheckDefaultsHandlerFunc func(ReplaceAllTCPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllTCPCheckDefaultsHandlerFunc) Handle(params ReplaceAllTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllTCPCheckDefaultsHandler interface for that can handle valid replace all TCP check defaults params +type ReplaceAllTCPCheckDefaultsHandler interface { + Handle(ReplaceAllTCPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllTCPCheckDefaults creates a new http.Handler for the replace all TCP check defaults operation +func NewReplaceAllTCPCheckDefaults(ctx *middleware.Context, handler ReplaceAllTCPCheckDefaultsHandler) *ReplaceAllTCPCheckDefaults { + return &ReplaceAllTCPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllTCPCheckDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/tcp_checks TCPCheck replaceAllTcpCheckDefaults + +# Replace an TCP Check list + +Replaces a whole list of TCP Checks with the list given in parameter +*/ +type ReplaceAllTCPCheckDefaults struct { + Context *middleware.Context + Handler ReplaceAllTCPCheckDefaultsHandler +} + +func (o *ReplaceAllTCPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllTCPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/replace_all_tcp_check_defaults_parameters.go b/operations/tcp_check/replace_all_tcp_check_defaults_parameters.go new file mode 100644 index 00000000..6bad0a9c --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllTCPCheckDefaultsParams creates a new ReplaceAllTCPCheckDefaultsParams object +// with the default values initialized. +func NewReplaceAllTCPCheckDefaultsParams() ReplaceAllTCPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllTCPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllTCPCheckDefaultsParams contains all the bound params for the replace all TCP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllTCPCheckDefaults +type ReplaceAllTCPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.TCPChecks + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllTCPCheckDefaultsParams() beforehand. +func (o *ReplaceAllTCPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPChecks + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllTCPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllTCPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllTCPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllTCPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllTCPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/replace_all_tcp_check_defaults_responses.go b/operations/tcp_check/replace_all_tcp_check_defaults_responses.go new file mode 100644 index 00000000..008c61db --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllTCPCheckDefaultsOKCode is the HTTP code returned for type ReplaceAllTCPCheckDefaultsOK +const ReplaceAllTCPCheckDefaultsOKCode int = 200 + +/* +ReplaceAllTCPCheckDefaultsOK All TCP Check lines replaced + +swagger:response replaceAllTcpCheckDefaultsOK +*/ +type ReplaceAllTCPCheckDefaultsOK struct { + + /* + In: Body + */ + Payload models.TCPChecks `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckDefaultsOK creates ReplaceAllTCPCheckDefaultsOK with default headers values +func NewReplaceAllTCPCheckDefaultsOK() *ReplaceAllTCPCheckDefaultsOK { + + return &ReplaceAllTCPCheckDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Tcp check defaults o k response +func (o *ReplaceAllTCPCheckDefaultsOK) WithPayload(payload models.TCPChecks) *ReplaceAllTCPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp check defaults o k response +func (o *ReplaceAllTCPCheckDefaultsOK) SetPayload(payload models.TCPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPCheckDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllTCPCheckDefaultsAccepted +const ReplaceAllTCPCheckDefaultsAcceptedCode int = 202 + +/* +ReplaceAllTCPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllTcpCheckDefaultsAccepted +*/ +type ReplaceAllTCPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.TCPChecks `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckDefaultsAccepted creates ReplaceAllTCPCheckDefaultsAccepted with default headers values +func NewReplaceAllTCPCheckDefaultsAccepted() *ReplaceAllTCPCheckDefaultsAccepted { + + return &ReplaceAllTCPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Tcp check defaults accepted response +func (o *ReplaceAllTCPCheckDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllTCPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Tcp check defaults accepted response +func (o *ReplaceAllTCPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Tcp check defaults accepted response +func (o *ReplaceAllTCPCheckDefaultsAccepted) WithPayload(payload models.TCPChecks) *ReplaceAllTCPCheckDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp check defaults accepted response +func (o *ReplaceAllTCPCheckDefaultsAccepted) SetPayload(payload models.TCPChecks) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPChecks{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPCheckDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllTCPCheckDefaultsBadRequest +const ReplaceAllTCPCheckDefaultsBadRequestCode int = 400 + +/* +ReplaceAllTCPCheckDefaultsBadRequest Bad request + +swagger:response replaceAllTcpCheckDefaultsBadRequest +*/ +type ReplaceAllTCPCheckDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckDefaultsBadRequest creates ReplaceAllTCPCheckDefaultsBadRequest with default headers values +func NewReplaceAllTCPCheckDefaultsBadRequest() *ReplaceAllTCPCheckDefaultsBadRequest { + + return &ReplaceAllTCPCheckDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Tcp check defaults bad request response +func (o *ReplaceAllTCPCheckDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPCheckDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Tcp check defaults bad request response +func (o *ReplaceAllTCPCheckDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Tcp check defaults bad request response +func (o *ReplaceAllTCPCheckDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllTCPCheckDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp check defaults bad request response +func (o *ReplaceAllTCPCheckDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllTCPCheckDefaultsDefault General Error + +swagger:response replaceAllTcpCheckDefaultsDefault +*/ +type ReplaceAllTCPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPCheckDefaultsDefault creates ReplaceAllTCPCheckDefaultsDefault with default headers values +func NewReplaceAllTCPCheckDefaultsDefault(code int) *ReplaceAllTCPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllTCPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all TCP check defaults default response +func (o *ReplaceAllTCPCheckDefaultsDefault) WithStatusCode(code int) *ReplaceAllTCPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all TCP check defaults default response +func (o *ReplaceAllTCPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all TCP check defaults default response +func (o *ReplaceAllTCPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all TCP check defaults default response +func (o *ReplaceAllTCPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all TCP check defaults default response +func (o *ReplaceAllTCPCheckDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllTCPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all TCP check defaults default response +func (o *ReplaceAllTCPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/replace_all_tcp_check_defaults_urlbuilder.go b/operations/tcp_check/replace_all_tcp_check_defaults_urlbuilder.go new file mode 100644 index 00000000..cf078214 --- /dev/null +++ b/operations/tcp_check/replace_all_tcp_check_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllTCPCheckDefaultsURL generates an URL for the replace all TCP check defaults operation +type ReplaceAllTCPCheckDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPCheckDefaultsURL) WithBasePath(bp string) *ReplaceAllTCPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllTCPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllTCPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllTCPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllTCPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllTCPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllTCPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllTCPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllTCPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/replace_tcp_check_backend.go b/operations/tcp_check/replace_tcp_check_backend.go new file mode 100644 index 00000000..7fc779fd --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTCPCheckBackendHandlerFunc turns a function with the right signature into a replace TCP check backend handler +type ReplaceTCPCheckBackendHandlerFunc func(ReplaceTCPCheckBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTCPCheckBackendHandlerFunc) Handle(params ReplaceTCPCheckBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTCPCheckBackendHandler interface for that can handle valid replace TCP check backend params +type ReplaceTCPCheckBackendHandler interface { + Handle(ReplaceTCPCheckBackendParams, interface{}) middleware.Responder +} + +// NewReplaceTCPCheckBackend creates a new http.Handler for the replace TCP check backend operation +func NewReplaceTCPCheckBackend(ctx *middleware.Context, handler ReplaceTCPCheckBackendHandler) *ReplaceTCPCheckBackend { + return &ReplaceTCPCheckBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceTCPCheckBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index} TCPCheck replaceTcpCheckBackend + +# Replace a TCP check + +Replaces a TCP Check configuration by it's index in the specified parent. +*/ +type ReplaceTCPCheckBackend struct { + Context *middleware.Context + Handler ReplaceTCPCheckBackendHandler +} + +func (o *ReplaceTCPCheckBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTCPCheckBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/replace_tcp_check_backend_parameters.go b/operations/tcp_check/replace_tcp_check_backend_parameters.go new file mode 100644 index 00000000..2519c621 --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTCPCheckBackendParams creates a new ReplaceTCPCheckBackendParams object +// with the default values initialized. +func NewReplaceTCPCheckBackendParams() ReplaceTCPCheckBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTCPCheckBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTCPCheckBackendParams contains all the bound params for the replace TCP check backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTCPCheckBackend +type ReplaceTCPCheckBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTCPCheckBackendParams() beforehand. +func (o *ReplaceTCPCheckBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTCPCheckBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTCPCheckBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceTCPCheckBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTCPCheckBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTCPCheckBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTCPCheckBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/replace_tcp_check_backend_responses.go b/operations/tcp_check/replace_tcp_check_backend_responses.go new file mode 100644 index 00000000..b8ff8e80 --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTCPCheckBackendOKCode is the HTTP code returned for type ReplaceTCPCheckBackendOK +const ReplaceTCPCheckBackendOKCode int = 200 + +/* +ReplaceTCPCheckBackendOK TCP check replaced + +swagger:response replaceTcpCheckBackendOK +*/ +type ReplaceTCPCheckBackendOK struct { + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewReplaceTCPCheckBackendOK creates ReplaceTCPCheckBackendOK with default headers values +func NewReplaceTCPCheckBackendOK() *ReplaceTCPCheckBackendOK { + + return &ReplaceTCPCheckBackendOK{} +} + +// WithPayload adds the payload to the replace Tcp check backend o k response +func (o *ReplaceTCPCheckBackendOK) WithPayload(payload *models.TCPCheck) *ReplaceTCPCheckBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check backend o k response +func (o *ReplaceTCPCheckBackendOK) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPCheckBackendAcceptedCode is the HTTP code returned for type ReplaceTCPCheckBackendAccepted +const ReplaceTCPCheckBackendAcceptedCode int = 202 + +/* +ReplaceTCPCheckBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceTcpCheckBackendAccepted +*/ +type ReplaceTCPCheckBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewReplaceTCPCheckBackendAccepted creates ReplaceTCPCheckBackendAccepted with default headers values +func NewReplaceTCPCheckBackendAccepted() *ReplaceTCPCheckBackendAccepted { + + return &ReplaceTCPCheckBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Tcp check backend accepted response +func (o *ReplaceTCPCheckBackendAccepted) WithReloadID(reloadID string) *ReplaceTCPCheckBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Tcp check backend accepted response +func (o *ReplaceTCPCheckBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Tcp check backend accepted response +func (o *ReplaceTCPCheckBackendAccepted) WithPayload(payload *models.TCPCheck) *ReplaceTCPCheckBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check backend accepted response +func (o *ReplaceTCPCheckBackendAccepted) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPCheckBackendBadRequestCode is the HTTP code returned for type ReplaceTCPCheckBackendBadRequest +const ReplaceTCPCheckBackendBadRequestCode int = 400 + +/* +ReplaceTCPCheckBackendBadRequest Bad request + +swagger:response replaceTcpCheckBackendBadRequest +*/ +type ReplaceTCPCheckBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPCheckBackendBadRequest creates ReplaceTCPCheckBackendBadRequest with default headers values +func NewReplaceTCPCheckBackendBadRequest() *ReplaceTCPCheckBackendBadRequest { + + return &ReplaceTCPCheckBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp check backend bad request response +func (o *ReplaceTCPCheckBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTCPCheckBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp check backend bad request response +func (o *ReplaceTCPCheckBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp check backend bad request response +func (o *ReplaceTCPCheckBackendBadRequest) WithPayload(payload *models.Error) *ReplaceTCPCheckBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check backend bad request response +func (o *ReplaceTCPCheckBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPCheckBackendNotFoundCode is the HTTP code returned for type ReplaceTCPCheckBackendNotFound +const ReplaceTCPCheckBackendNotFoundCode int = 404 + +/* +ReplaceTCPCheckBackendNotFound The specified resource was not found + +swagger:response replaceTcpCheckBackendNotFound +*/ +type ReplaceTCPCheckBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPCheckBackendNotFound creates ReplaceTCPCheckBackendNotFound with default headers values +func NewReplaceTCPCheckBackendNotFound() *ReplaceTCPCheckBackendNotFound { + + return &ReplaceTCPCheckBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp check backend not found response +func (o *ReplaceTCPCheckBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTCPCheckBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp check backend not found response +func (o *ReplaceTCPCheckBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp check backend not found response +func (o *ReplaceTCPCheckBackendNotFound) WithPayload(payload *models.Error) *ReplaceTCPCheckBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check backend not found response +func (o *ReplaceTCPCheckBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTCPCheckBackendDefault General Error + +swagger:response replaceTcpCheckBackendDefault +*/ +type ReplaceTCPCheckBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPCheckBackendDefault creates ReplaceTCPCheckBackendDefault with default headers values +func NewReplaceTCPCheckBackendDefault(code int) *ReplaceTCPCheckBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTCPCheckBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace TCP check backend default response +func (o *ReplaceTCPCheckBackendDefault) WithStatusCode(code int) *ReplaceTCPCheckBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace TCP check backend default response +func (o *ReplaceTCPCheckBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace TCP check backend default response +func (o *ReplaceTCPCheckBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTCPCheckBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace TCP check backend default response +func (o *ReplaceTCPCheckBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace TCP check backend default response +func (o *ReplaceTCPCheckBackendDefault) WithPayload(payload *models.Error) *ReplaceTCPCheckBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace TCP check backend default response +func (o *ReplaceTCPCheckBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/replace_tcp_check_backend_urlbuilder.go b/operations/tcp_check/replace_tcp_check_backend_urlbuilder.go new file mode 100644 index 00000000..a2e09e77 --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTCPCheckBackendURL generates an URL for the replace TCP check backend operation +type ReplaceTCPCheckBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPCheckBackendURL) WithBasePath(bp string) *ReplaceTCPCheckBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPCheckBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTCPCheckBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceTCPCheckBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTCPCheckBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTCPCheckBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTCPCheckBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTCPCheckBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTCPCheckBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTCPCheckBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTCPCheckBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_check/replace_tcp_check_defaults.go b/operations/tcp_check/replace_tcp_check_defaults.go new file mode 100644 index 00000000..bf0bef23 --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTCPCheckDefaultsHandlerFunc turns a function with the right signature into a replace TCP check defaults handler +type ReplaceTCPCheckDefaultsHandlerFunc func(ReplaceTCPCheckDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTCPCheckDefaultsHandlerFunc) Handle(params ReplaceTCPCheckDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTCPCheckDefaultsHandler interface for that can handle valid replace TCP check defaults params +type ReplaceTCPCheckDefaultsHandler interface { + Handle(ReplaceTCPCheckDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceTCPCheckDefaults creates a new http.Handler for the replace TCP check defaults operation +func NewReplaceTCPCheckDefaults(ctx *middleware.Context, handler ReplaceTCPCheckDefaultsHandler) *ReplaceTCPCheckDefaults { + return &ReplaceTCPCheckDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceTCPCheckDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index} TCPCheck replaceTcpCheckDefaults + +# Replace a TCP check + +Replaces a TCP Check configuration by it's index in the specified parent. +*/ +type ReplaceTCPCheckDefaults struct { + Context *middleware.Context + Handler ReplaceTCPCheckDefaultsHandler +} + +func (o *ReplaceTCPCheckDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTCPCheckDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_check/replace_tcp_check_defaults_parameters.go b/operations/tcp_check/replace_tcp_check_defaults_parameters.go new file mode 100644 index 00000000..9e1bd36b --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTCPCheckDefaultsParams creates a new ReplaceTCPCheckDefaultsParams object +// with the default values initialized. +func NewReplaceTCPCheckDefaultsParams() ReplaceTCPCheckDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTCPCheckDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTCPCheckDefaultsParams contains all the bound params for the replace TCP check defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTCPCheckDefaults +type ReplaceTCPCheckDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPCheck + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Check Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTCPCheckDefaultsParams() beforehand. +func (o *ReplaceTCPCheckDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPCheck + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTCPCheckDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTCPCheckDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceTCPCheckDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTCPCheckDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTCPCheckDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTCPCheckDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_check/replace_tcp_check_defaults_responses.go b/operations/tcp_check/replace_tcp_check_defaults_responses.go new file mode 100644 index 00000000..94c78881 --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTCPCheckDefaultsOKCode is the HTTP code returned for type ReplaceTCPCheckDefaultsOK +const ReplaceTCPCheckDefaultsOKCode int = 200 + +/* +ReplaceTCPCheckDefaultsOK TCP check replaced + +swagger:response replaceTcpCheckDefaultsOK +*/ +type ReplaceTCPCheckDefaultsOK struct { + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewReplaceTCPCheckDefaultsOK creates ReplaceTCPCheckDefaultsOK with default headers values +func NewReplaceTCPCheckDefaultsOK() *ReplaceTCPCheckDefaultsOK { + + return &ReplaceTCPCheckDefaultsOK{} +} + +// WithPayload adds the payload to the replace Tcp check defaults o k response +func (o *ReplaceTCPCheckDefaultsOK) WithPayload(payload *models.TCPCheck) *ReplaceTCPCheckDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check defaults o k response +func (o *ReplaceTCPCheckDefaultsOK) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPCheckDefaultsAcceptedCode is the HTTP code returned for type ReplaceTCPCheckDefaultsAccepted +const ReplaceTCPCheckDefaultsAcceptedCode int = 202 + +/* +ReplaceTCPCheckDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceTcpCheckDefaultsAccepted +*/ +type ReplaceTCPCheckDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPCheck `json:"body,omitempty"` +} + +// NewReplaceTCPCheckDefaultsAccepted creates ReplaceTCPCheckDefaultsAccepted with default headers values +func NewReplaceTCPCheckDefaultsAccepted() *ReplaceTCPCheckDefaultsAccepted { + + return &ReplaceTCPCheckDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Tcp check defaults accepted response +func (o *ReplaceTCPCheckDefaultsAccepted) WithReloadID(reloadID string) *ReplaceTCPCheckDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Tcp check defaults accepted response +func (o *ReplaceTCPCheckDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Tcp check defaults accepted response +func (o *ReplaceTCPCheckDefaultsAccepted) WithPayload(payload *models.TCPCheck) *ReplaceTCPCheckDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check defaults accepted response +func (o *ReplaceTCPCheckDefaultsAccepted) SetPayload(payload *models.TCPCheck) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPCheckDefaultsBadRequestCode is the HTTP code returned for type ReplaceTCPCheckDefaultsBadRequest +const ReplaceTCPCheckDefaultsBadRequestCode int = 400 + +/* +ReplaceTCPCheckDefaultsBadRequest Bad request + +swagger:response replaceTcpCheckDefaultsBadRequest +*/ +type ReplaceTCPCheckDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPCheckDefaultsBadRequest creates ReplaceTCPCheckDefaultsBadRequest with default headers values +func NewReplaceTCPCheckDefaultsBadRequest() *ReplaceTCPCheckDefaultsBadRequest { + + return &ReplaceTCPCheckDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp check defaults bad request response +func (o *ReplaceTCPCheckDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTCPCheckDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp check defaults bad request response +func (o *ReplaceTCPCheckDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp check defaults bad request response +func (o *ReplaceTCPCheckDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceTCPCheckDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check defaults bad request response +func (o *ReplaceTCPCheckDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPCheckDefaultsNotFoundCode is the HTTP code returned for type ReplaceTCPCheckDefaultsNotFound +const ReplaceTCPCheckDefaultsNotFoundCode int = 404 + +/* +ReplaceTCPCheckDefaultsNotFound The specified resource was not found + +swagger:response replaceTcpCheckDefaultsNotFound +*/ +type ReplaceTCPCheckDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPCheckDefaultsNotFound creates ReplaceTCPCheckDefaultsNotFound with default headers values +func NewReplaceTCPCheckDefaultsNotFound() *ReplaceTCPCheckDefaultsNotFound { + + return &ReplaceTCPCheckDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp check defaults not found response +func (o *ReplaceTCPCheckDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTCPCheckDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp check defaults not found response +func (o *ReplaceTCPCheckDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp check defaults not found response +func (o *ReplaceTCPCheckDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceTCPCheckDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp check defaults not found response +func (o *ReplaceTCPCheckDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTCPCheckDefaultsDefault General Error + +swagger:response replaceTcpCheckDefaultsDefault +*/ +type ReplaceTCPCheckDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPCheckDefaultsDefault creates ReplaceTCPCheckDefaultsDefault with default headers values +func NewReplaceTCPCheckDefaultsDefault(code int) *ReplaceTCPCheckDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTCPCheckDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace TCP check defaults default response +func (o *ReplaceTCPCheckDefaultsDefault) WithStatusCode(code int) *ReplaceTCPCheckDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace TCP check defaults default response +func (o *ReplaceTCPCheckDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace TCP check defaults default response +func (o *ReplaceTCPCheckDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTCPCheckDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace TCP check defaults default response +func (o *ReplaceTCPCheckDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace TCP check defaults default response +func (o *ReplaceTCPCheckDefaultsDefault) WithPayload(payload *models.Error) *ReplaceTCPCheckDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace TCP check defaults default response +func (o *ReplaceTCPCheckDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPCheckDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_check/replace_tcp_check_defaults_urlbuilder.go b/operations/tcp_check/replace_tcp_check_defaults_urlbuilder.go new file mode 100644 index 00000000..846bdd9c --- /dev/null +++ b/operations/tcp_check/replace_tcp_check_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_check + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTCPCheckDefaultsURL generates an URL for the replace TCP check defaults operation +type ReplaceTCPCheckDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPCheckDefaultsURL) WithBasePath(bp string) *ReplaceTCPCheckDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPCheckDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTCPCheckDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_checks/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceTCPCheckDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTCPCheckDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTCPCheckDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTCPCheckDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTCPCheckDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTCPCheckDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTCPCheckDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTCPCheckDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule.go b/operations/tcp_request_rule/create_tcp_request_rule.go deleted file mode 100644 index c9e41b62..00000000 --- a/operations/tcp_request_rule/create_tcp_request_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateTCPRequestRuleHandlerFunc turns a function with the right signature into a create TCP request rule handler -type CreateTCPRequestRuleHandlerFunc func(CreateTCPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateTCPRequestRuleHandlerFunc) Handle(params CreateTCPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateTCPRequestRuleHandler interface for that can handle valid create TCP request rule params -type CreateTCPRequestRuleHandler interface { - Handle(CreateTCPRequestRuleParams, interface{}) middleware.Responder -} - -// NewCreateTCPRequestRule creates a new http.Handler for the create TCP request rule operation -func NewCreateTCPRequestRule(ctx *middleware.Context, handler CreateTCPRequestRuleHandler) *CreateTCPRequestRule { - return &CreateTCPRequestRule{Context: ctx, Handler: handler} -} - -/*CreateTCPRequestRule swagger:route POST /services/haproxy/configuration/tcp_request_rules TCPRequestRule createTcpRequestRule - -Add a new TCP Request Rule - -Adds a new TCP Request Rule of the specified type in the specified parent. - -*/ -type CreateTCPRequestRule struct { - Context *middleware.Context - Handler CreateTCPRequestRuleHandler -} - -func (o *CreateTCPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateTCPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_backend.go b/operations/tcp_request_rule/create_tcp_request_rule_backend.go new file mode 100644 index 00000000..cadc24e4 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTCPRequestRuleBackendHandlerFunc turns a function with the right signature into a create TCP request rule backend handler +type CreateTCPRequestRuleBackendHandlerFunc func(CreateTCPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTCPRequestRuleBackendHandlerFunc) Handle(params CreateTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTCPRequestRuleBackendHandler interface for that can handle valid create TCP request rule backend params +type CreateTCPRequestRuleBackendHandler interface { + Handle(CreateTCPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewCreateTCPRequestRuleBackend creates a new http.Handler for the create TCP request rule backend operation +func NewCreateTCPRequestRuleBackend(ctx *middleware.Context, handler CreateTCPRequestRuleBackendHandler) *CreateTCPRequestRuleBackend { + return &CreateTCPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + CreateTCPRequestRuleBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index} TCPRequestRule createTcpRequestRuleBackend + +# Add a new TCP Request Rule + +Adds a new TCP Request Rule of the specified type in the specified parent. +*/ +type CreateTCPRequestRuleBackend struct { + Context *middleware.Context + Handler CreateTCPRequestRuleBackendHandler +} + +func (o *CreateTCPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTCPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_backend_parameters.go b/operations/tcp_request_rule/create_tcp_request_rule_backend_parameters.go new file mode 100644 index 00000000..d26e46fe --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTCPRequestRuleBackendParams creates a new CreateTCPRequestRuleBackendParams object +// with the default values initialized. +func NewCreateTCPRequestRuleBackendParams() CreateTCPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTCPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTCPRequestRuleBackendParams contains all the bound params for the create TCP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTCPRequestRuleBackend +type CreateTCPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTCPRequestRuleBackendParams() beforehand. +func (o *CreateTCPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTCPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTCPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateTCPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTCPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTCPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTCPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_backend_responses.go b/operations/tcp_request_rule/create_tcp_request_rule_backend_responses.go new file mode 100644 index 00000000..4931504a --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTCPRequestRuleBackendCreatedCode is the HTTP code returned for type CreateTCPRequestRuleBackendCreated +const CreateTCPRequestRuleBackendCreatedCode int = 201 + +/* +CreateTCPRequestRuleBackendCreated TCP Request Rule created + +swagger:response createTcpRequestRuleBackendCreated +*/ +type CreateTCPRequestRuleBackendCreated struct { + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleBackendCreated creates CreateTCPRequestRuleBackendCreated with default headers values +func NewCreateTCPRequestRuleBackendCreated() *CreateTCPRequestRuleBackendCreated { + + return &CreateTCPRequestRuleBackendCreated{} +} + +// WithPayload adds the payload to the create Tcp request rule backend created response +func (o *CreateTCPRequestRuleBackendCreated) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule backend created response +func (o *CreateTCPRequestRuleBackendCreated) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleBackendAcceptedCode is the HTTP code returned for type CreateTCPRequestRuleBackendAccepted +const CreateTCPRequestRuleBackendAcceptedCode int = 202 + +/* +CreateTCPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response createTcpRequestRuleBackendAccepted +*/ +type CreateTCPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleBackendAccepted creates CreateTCPRequestRuleBackendAccepted with default headers values +func NewCreateTCPRequestRuleBackendAccepted() *CreateTCPRequestRuleBackendAccepted { + + return &CreateTCPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Tcp request rule backend accepted response +func (o *CreateTCPRequestRuleBackendAccepted) WithReloadID(reloadID string) *CreateTCPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Tcp request rule backend accepted response +func (o *CreateTCPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Tcp request rule backend accepted response +func (o *CreateTCPRequestRuleBackendAccepted) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule backend accepted response +func (o *CreateTCPRequestRuleBackendAccepted) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleBackendBadRequestCode is the HTTP code returned for type CreateTCPRequestRuleBackendBadRequest +const CreateTCPRequestRuleBackendBadRequestCode int = 400 + +/* +CreateTCPRequestRuleBackendBadRequest Bad request + +swagger:response createTcpRequestRuleBackendBadRequest +*/ +type CreateTCPRequestRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleBackendBadRequest creates CreateTCPRequestRuleBackendBadRequest with default headers values +func NewCreateTCPRequestRuleBackendBadRequest() *CreateTCPRequestRuleBackendBadRequest { + + return &CreateTCPRequestRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule backend bad request response +func (o *CreateTCPRequestRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule backend bad request response +func (o *CreateTCPRequestRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp request rule backend bad request response +func (o *CreateTCPRequestRuleBackendBadRequest) WithPayload(payload *models.Error) *CreateTCPRequestRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule backend bad request response +func (o *CreateTCPRequestRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleBackendConflictCode is the HTTP code returned for type CreateTCPRequestRuleBackendConflict +const CreateTCPRequestRuleBackendConflictCode int = 409 + +/* +CreateTCPRequestRuleBackendConflict The specified resource already exists + +swagger:response createTcpRequestRuleBackendConflict +*/ +type CreateTCPRequestRuleBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleBackendConflict creates CreateTCPRequestRuleBackendConflict with default headers values +func NewCreateTCPRequestRuleBackendConflict() *CreateTCPRequestRuleBackendConflict { + + return &CreateTCPRequestRuleBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule backend conflict response +func (o *CreateTCPRequestRuleBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule backend conflict response +func (o *CreateTCPRequestRuleBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp request rule backend conflict response +func (o *CreateTCPRequestRuleBackendConflict) WithPayload(payload *models.Error) *CreateTCPRequestRuleBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule backend conflict response +func (o *CreateTCPRequestRuleBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTCPRequestRuleBackendDefault General Error + +swagger:response createTcpRequestRuleBackendDefault +*/ +type CreateTCPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleBackendDefault creates CreateTCPRequestRuleBackendDefault with default headers values +func NewCreateTCPRequestRuleBackendDefault(code int) *CreateTCPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateTCPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create TCP request rule backend default response +func (o *CreateTCPRequestRuleBackendDefault) WithStatusCode(code int) *CreateTCPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create TCP request rule backend default response +func (o *CreateTCPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create TCP request rule backend default response +func (o *CreateTCPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create TCP request rule backend default response +func (o *CreateTCPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create TCP request rule backend default response +func (o *CreateTCPRequestRuleBackendDefault) WithPayload(payload *models.Error) *CreateTCPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create TCP request rule backend default response +func (o *CreateTCPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_backend_urlbuilder.go b/operations/tcp_request_rule/create_tcp_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..46c154c2 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTCPRequestRuleBackendURL generates an URL for the create TCP request rule backend operation +type CreateTCPRequestRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPRequestRuleBackendURL) WithBasePath(bp string) *CreateTCPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTCPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateTCPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTCPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTCPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTCPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTCPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTCPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTCPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTCPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_defaults.go b/operations/tcp_request_rule/create_tcp_request_rule_defaults.go new file mode 100644 index 00000000..7f3eee00 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTCPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a create TCP request rule defaults handler +type CreateTCPRequestRuleDefaultsHandlerFunc func(CreateTCPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTCPRequestRuleDefaultsHandlerFunc) Handle(params CreateTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTCPRequestRuleDefaultsHandler interface for that can handle valid create TCP request rule defaults params +type CreateTCPRequestRuleDefaultsHandler interface { + Handle(CreateTCPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateTCPRequestRuleDefaults creates a new http.Handler for the create TCP request rule defaults operation +func NewCreateTCPRequestRuleDefaults(ctx *middleware.Context, handler CreateTCPRequestRuleDefaultsHandler) *CreateTCPRequestRuleDefaults { + return &CreateTCPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + CreateTCPRequestRuleDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index} TCPRequestRule createTcpRequestRuleDefaults + +# Add a new TCP Request Rule + +Adds a new TCP Request Rule of the specified type in the specified parent. +*/ +type CreateTCPRequestRuleDefaults struct { + Context *middleware.Context + Handler CreateTCPRequestRuleDefaultsHandler +} + +func (o *CreateTCPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTCPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_defaults_parameters.go b/operations/tcp_request_rule/create_tcp_request_rule_defaults_parameters.go new file mode 100644 index 00000000..67b0f6d1 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTCPRequestRuleDefaultsParams creates a new CreateTCPRequestRuleDefaultsParams object +// with the default values initialized. +func NewCreateTCPRequestRuleDefaultsParams() CreateTCPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTCPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTCPRequestRuleDefaultsParams contains all the bound params for the create TCP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTCPRequestRuleDefaults +type CreateTCPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTCPRequestRuleDefaultsParams() beforehand. +func (o *CreateTCPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTCPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTCPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateTCPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTCPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTCPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTCPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_defaults_responses.go b/operations/tcp_request_rule/create_tcp_request_rule_defaults_responses.go new file mode 100644 index 00000000..acf568d6 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTCPRequestRuleDefaultsCreatedCode is the HTTP code returned for type CreateTCPRequestRuleDefaultsCreated +const CreateTCPRequestRuleDefaultsCreatedCode int = 201 + +/* +CreateTCPRequestRuleDefaultsCreated TCP Request Rule created + +swagger:response createTcpRequestRuleDefaultsCreated +*/ +type CreateTCPRequestRuleDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleDefaultsCreated creates CreateTCPRequestRuleDefaultsCreated with default headers values +func NewCreateTCPRequestRuleDefaultsCreated() *CreateTCPRequestRuleDefaultsCreated { + + return &CreateTCPRequestRuleDefaultsCreated{} +} + +// WithPayload adds the payload to the create Tcp request rule defaults created response +func (o *CreateTCPRequestRuleDefaultsCreated) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule defaults created response +func (o *CreateTCPRequestRuleDefaultsCreated) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type CreateTCPRequestRuleDefaultsAccepted +const CreateTCPRequestRuleDefaultsAcceptedCode int = 202 + +/* +CreateTCPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createTcpRequestRuleDefaultsAccepted +*/ +type CreateTCPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleDefaultsAccepted creates CreateTCPRequestRuleDefaultsAccepted with default headers values +func NewCreateTCPRequestRuleDefaultsAccepted() *CreateTCPRequestRuleDefaultsAccepted { + + return &CreateTCPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Tcp request rule defaults accepted response +func (o *CreateTCPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *CreateTCPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Tcp request rule defaults accepted response +func (o *CreateTCPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Tcp request rule defaults accepted response +func (o *CreateTCPRequestRuleDefaultsAccepted) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule defaults accepted response +func (o *CreateTCPRequestRuleDefaultsAccepted) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleDefaultsBadRequestCode is the HTTP code returned for type CreateTCPRequestRuleDefaultsBadRequest +const CreateTCPRequestRuleDefaultsBadRequestCode int = 400 + +/* +CreateTCPRequestRuleDefaultsBadRequest Bad request + +swagger:response createTcpRequestRuleDefaultsBadRequest +*/ +type CreateTCPRequestRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleDefaultsBadRequest creates CreateTCPRequestRuleDefaultsBadRequest with default headers values +func NewCreateTCPRequestRuleDefaultsBadRequest() *CreateTCPRequestRuleDefaultsBadRequest { + + return &CreateTCPRequestRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule defaults bad request response +func (o *CreateTCPRequestRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule defaults bad request response +func (o *CreateTCPRequestRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp request rule defaults bad request response +func (o *CreateTCPRequestRuleDefaultsBadRequest) WithPayload(payload *models.Error) *CreateTCPRequestRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule defaults bad request response +func (o *CreateTCPRequestRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleDefaultsConflictCode is the HTTP code returned for type CreateTCPRequestRuleDefaultsConflict +const CreateTCPRequestRuleDefaultsConflictCode int = 409 + +/* +CreateTCPRequestRuleDefaultsConflict The specified resource already exists + +swagger:response createTcpRequestRuleDefaultsConflict +*/ +type CreateTCPRequestRuleDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleDefaultsConflict creates CreateTCPRequestRuleDefaultsConflict with default headers values +func NewCreateTCPRequestRuleDefaultsConflict() *CreateTCPRequestRuleDefaultsConflict { + + return &CreateTCPRequestRuleDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule defaults conflict response +func (o *CreateTCPRequestRuleDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule defaults conflict response +func (o *CreateTCPRequestRuleDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp request rule defaults conflict response +func (o *CreateTCPRequestRuleDefaultsConflict) WithPayload(payload *models.Error) *CreateTCPRequestRuleDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule defaults conflict response +func (o *CreateTCPRequestRuleDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTCPRequestRuleDefaultsDefault General Error + +swagger:response createTcpRequestRuleDefaultsDefault +*/ +type CreateTCPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleDefaultsDefault creates CreateTCPRequestRuleDefaultsDefault with default headers values +func NewCreateTCPRequestRuleDefaultsDefault(code int) *CreateTCPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateTCPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create TCP request rule defaults default response +func (o *CreateTCPRequestRuleDefaultsDefault) WithStatusCode(code int) *CreateTCPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create TCP request rule defaults default response +func (o *CreateTCPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create TCP request rule defaults default response +func (o *CreateTCPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create TCP request rule defaults default response +func (o *CreateTCPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create TCP request rule defaults default response +func (o *CreateTCPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *CreateTCPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create TCP request rule defaults default response +func (o *CreateTCPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_defaults_urlbuilder.go b/operations/tcp_request_rule/create_tcp_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..57f17d15 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTCPRequestRuleDefaultsURL generates an URL for the create TCP request rule defaults operation +type CreateTCPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPRequestRuleDefaultsURL) WithBasePath(bp string) *CreateTCPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTCPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateTCPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTCPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTCPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTCPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTCPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTCPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTCPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTCPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_frontend.go b/operations/tcp_request_rule/create_tcp_request_rule_frontend.go new file mode 100644 index 00000000..e2a45b59 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTCPRequestRuleFrontendHandlerFunc turns a function with the right signature into a create TCP request rule frontend handler +type CreateTCPRequestRuleFrontendHandlerFunc func(CreateTCPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTCPRequestRuleFrontendHandlerFunc) Handle(params CreateTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTCPRequestRuleFrontendHandler interface for that can handle valid create TCP request rule frontend params +type CreateTCPRequestRuleFrontendHandler interface { + Handle(CreateTCPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewCreateTCPRequestRuleFrontend creates a new http.Handler for the create TCP request rule frontend operation +func NewCreateTCPRequestRuleFrontend(ctx *middleware.Context, handler CreateTCPRequestRuleFrontendHandler) *CreateTCPRequestRuleFrontend { + return &CreateTCPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + CreateTCPRequestRuleFrontend swagger:route POST /services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index} TCPRequestRule createTcpRequestRuleFrontend + +# Add a new TCP Request Rule + +Adds a new TCP Request Rule of the specified type in the specified parent. +*/ +type CreateTCPRequestRuleFrontend struct { + Context *middleware.Context + Handler CreateTCPRequestRuleFrontendHandler +} + +func (o *CreateTCPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTCPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_frontend_parameters.go b/operations/tcp_request_rule/create_tcp_request_rule_frontend_parameters.go new file mode 100644 index 00000000..1bb09dc4 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTCPRequestRuleFrontendParams creates a new CreateTCPRequestRuleFrontendParams object +// with the default values initialized. +func NewCreateTCPRequestRuleFrontendParams() CreateTCPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTCPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTCPRequestRuleFrontendParams contains all the bound params for the create TCP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTCPRequestRuleFrontend +type CreateTCPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTCPRequestRuleFrontendParams() beforehand. +func (o *CreateTCPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTCPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTCPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateTCPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTCPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTCPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTCPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_frontend_responses.go b/operations/tcp_request_rule/create_tcp_request_rule_frontend_responses.go new file mode 100644 index 00000000..fb362a83 --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTCPRequestRuleFrontendCreatedCode is the HTTP code returned for type CreateTCPRequestRuleFrontendCreated +const CreateTCPRequestRuleFrontendCreatedCode int = 201 + +/* +CreateTCPRequestRuleFrontendCreated TCP Request Rule created + +swagger:response createTcpRequestRuleFrontendCreated +*/ +type CreateTCPRequestRuleFrontendCreated struct { + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleFrontendCreated creates CreateTCPRequestRuleFrontendCreated with default headers values +func NewCreateTCPRequestRuleFrontendCreated() *CreateTCPRequestRuleFrontendCreated { + + return &CreateTCPRequestRuleFrontendCreated{} +} + +// WithPayload adds the payload to the create Tcp request rule frontend created response +func (o *CreateTCPRequestRuleFrontendCreated) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleFrontendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule frontend created response +func (o *CreateTCPRequestRuleFrontendCreated) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleFrontendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleFrontendAcceptedCode is the HTTP code returned for type CreateTCPRequestRuleFrontendAccepted +const CreateTCPRequestRuleFrontendAcceptedCode int = 202 + +/* +CreateTCPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response createTcpRequestRuleFrontendAccepted +*/ +type CreateTCPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleFrontendAccepted creates CreateTCPRequestRuleFrontendAccepted with default headers values +func NewCreateTCPRequestRuleFrontendAccepted() *CreateTCPRequestRuleFrontendAccepted { + + return &CreateTCPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the create Tcp request rule frontend accepted response +func (o *CreateTCPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *CreateTCPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Tcp request rule frontend accepted response +func (o *CreateTCPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Tcp request rule frontend accepted response +func (o *CreateTCPRequestRuleFrontendAccepted) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule frontend accepted response +func (o *CreateTCPRequestRuleFrontendAccepted) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleFrontendBadRequestCode is the HTTP code returned for type CreateTCPRequestRuleFrontendBadRequest +const CreateTCPRequestRuleFrontendBadRequestCode int = 400 + +/* +CreateTCPRequestRuleFrontendBadRequest Bad request + +swagger:response createTcpRequestRuleFrontendBadRequest +*/ +type CreateTCPRequestRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleFrontendBadRequest creates CreateTCPRequestRuleFrontendBadRequest with default headers values +func NewCreateTCPRequestRuleFrontendBadRequest() *CreateTCPRequestRuleFrontendBadRequest { + + return &CreateTCPRequestRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule frontend bad request response +func (o *CreateTCPRequestRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule frontend bad request response +func (o *CreateTCPRequestRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp request rule frontend bad request response +func (o *CreateTCPRequestRuleFrontendBadRequest) WithPayload(payload *models.Error) *CreateTCPRequestRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule frontend bad request response +func (o *CreateTCPRequestRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPRequestRuleFrontendConflictCode is the HTTP code returned for type CreateTCPRequestRuleFrontendConflict +const CreateTCPRequestRuleFrontendConflictCode int = 409 + +/* +CreateTCPRequestRuleFrontendConflict The specified resource already exists + +swagger:response createTcpRequestRuleFrontendConflict +*/ +type CreateTCPRequestRuleFrontendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleFrontendConflict creates CreateTCPRequestRuleFrontendConflict with default headers values +func NewCreateTCPRequestRuleFrontendConflict() *CreateTCPRequestRuleFrontendConflict { + + return &CreateTCPRequestRuleFrontendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule frontend conflict response +func (o *CreateTCPRequestRuleFrontendConflict) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleFrontendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule frontend conflict response +func (o *CreateTCPRequestRuleFrontendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp request rule frontend conflict response +func (o *CreateTCPRequestRuleFrontendConflict) WithPayload(payload *models.Error) *CreateTCPRequestRuleFrontendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp request rule frontend conflict response +func (o *CreateTCPRequestRuleFrontendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleFrontendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTCPRequestRuleFrontendDefault General Error + +swagger:response createTcpRequestRuleFrontendDefault +*/ +type CreateTCPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPRequestRuleFrontendDefault creates CreateTCPRequestRuleFrontendDefault with default headers values +func NewCreateTCPRequestRuleFrontendDefault(code int) *CreateTCPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &CreateTCPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create TCP request rule frontend default response +func (o *CreateTCPRequestRuleFrontendDefault) WithStatusCode(code int) *CreateTCPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create TCP request rule frontend default response +func (o *CreateTCPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create TCP request rule frontend default response +func (o *CreateTCPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *CreateTCPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create TCP request rule frontend default response +func (o *CreateTCPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create TCP request rule frontend default response +func (o *CreateTCPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *CreateTCPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create TCP request rule frontend default response +func (o *CreateTCPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_frontend_urlbuilder.go b/operations/tcp_request_rule/create_tcp_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..8f8ab37b --- /dev/null +++ b/operations/tcp_request_rule/create_tcp_request_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTCPRequestRuleFrontendURL generates an URL for the create TCP request rule frontend operation +type CreateTCPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPRequestRuleFrontendURL) WithBasePath(bp string) *CreateTCPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTCPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateTCPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTCPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTCPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTCPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTCPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTCPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTCPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTCPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_parameters.go b/operations/tcp_request_rule/create_tcp_request_rule_parameters.go deleted file mode 100644 index 44f9b49c..00000000 --- a/operations/tcp_request_rule/create_tcp_request_rule_parameters.go +++ /dev/null @@ -1,273 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateTCPRequestRuleParams creates a new CreateTCPRequestRuleParams object -// with the default values initialized. -func NewCreateTCPRequestRuleParams() CreateTCPRequestRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateTCPRequestRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateTCPRequestRuleParams contains all the bound params for the create TCP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters createTCPRequestRule -type CreateTCPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.TCPRequestRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateTCPRequestRuleParams() beforehand. -func (o *CreateTCPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.TCPRequestRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateTCPRequestRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateTCPRequestRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *CreateTCPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *CreateTCPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *CreateTCPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateTCPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateTCPRequestRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_responses.go b/operations/tcp_request_rule/create_tcp_request_rule_responses.go deleted file mode 100644 index c3139312..00000000 --- a/operations/tcp_request_rule/create_tcp_request_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateTCPRequestRuleCreatedCode is the HTTP code returned for type CreateTCPRequestRuleCreated -const CreateTCPRequestRuleCreatedCode int = 201 - -/*CreateTCPRequestRuleCreated TCP Request Rule created - -swagger:response createTcpRequestRuleCreated -*/ -type CreateTCPRequestRuleCreated struct { - - /* - In: Body - */ - Payload *models.TCPRequestRule `json:"body,omitempty"` -} - -// NewCreateTCPRequestRuleCreated creates CreateTCPRequestRuleCreated with default headers values -func NewCreateTCPRequestRuleCreated() *CreateTCPRequestRuleCreated { - - return &CreateTCPRequestRuleCreated{} -} - -// WithPayload adds the payload to the create Tcp request rule created response -func (o *CreateTCPRequestRuleCreated) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp request rule created response -func (o *CreateTCPRequestRuleCreated) SetPayload(payload *models.TCPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPRequestRuleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateTCPRequestRuleAcceptedCode is the HTTP code returned for type CreateTCPRequestRuleAccepted -const CreateTCPRequestRuleAcceptedCode int = 202 - -/*CreateTCPRequestRuleAccepted Configuration change accepted and reload requested - -swagger:response createTcpRequestRuleAccepted -*/ -type CreateTCPRequestRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.TCPRequestRule `json:"body,omitempty"` -} - -// NewCreateTCPRequestRuleAccepted creates CreateTCPRequestRuleAccepted with default headers values -func NewCreateTCPRequestRuleAccepted() *CreateTCPRequestRuleAccepted { - - return &CreateTCPRequestRuleAccepted{} -} - -// WithReloadID adds the reloadId to the create Tcp request rule accepted response -func (o *CreateTCPRequestRuleAccepted) WithReloadID(reloadID string) *CreateTCPRequestRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create Tcp request rule accepted response -func (o *CreateTCPRequestRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create Tcp request rule accepted response -func (o *CreateTCPRequestRuleAccepted) WithPayload(payload *models.TCPRequestRule) *CreateTCPRequestRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp request rule accepted response -func (o *CreateTCPRequestRuleAccepted) SetPayload(payload *models.TCPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPRequestRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateTCPRequestRuleBadRequestCode is the HTTP code returned for type CreateTCPRequestRuleBadRequest -const CreateTCPRequestRuleBadRequestCode int = 400 - -/*CreateTCPRequestRuleBadRequest Bad request - -swagger:response createTcpRequestRuleBadRequest -*/ -type CreateTCPRequestRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateTCPRequestRuleBadRequest creates CreateTCPRequestRuleBadRequest with default headers values -func NewCreateTCPRequestRuleBadRequest() *CreateTCPRequestRuleBadRequest { - - return &CreateTCPRequestRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule bad request response -func (o *CreateTCPRequestRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateTCPRequestRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule bad request response -func (o *CreateTCPRequestRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Tcp request rule bad request response -func (o *CreateTCPRequestRuleBadRequest) WithPayload(payload *models.Error) *CreateTCPRequestRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp request rule bad request response -func (o *CreateTCPRequestRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPRequestRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateTCPRequestRuleConflictCode is the HTTP code returned for type CreateTCPRequestRuleConflict -const CreateTCPRequestRuleConflictCode int = 409 - -/*CreateTCPRequestRuleConflict The specified resource already exists - -swagger:response createTcpRequestRuleConflict -*/ -type CreateTCPRequestRuleConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateTCPRequestRuleConflict creates CreateTCPRequestRuleConflict with default headers values -func NewCreateTCPRequestRuleConflict() *CreateTCPRequestRuleConflict { - - return &CreateTCPRequestRuleConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Tcp request rule conflict response -func (o *CreateTCPRequestRuleConflict) WithConfigurationVersion(configurationVersion int64) *CreateTCPRequestRuleConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Tcp request rule conflict response -func (o *CreateTCPRequestRuleConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Tcp request rule conflict response -func (o *CreateTCPRequestRuleConflict) WithPayload(payload *models.Error) *CreateTCPRequestRuleConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp request rule conflict response -func (o *CreateTCPRequestRuleConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPRequestRuleConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateTCPRequestRuleDefault General Error - -swagger:response createTcpRequestRuleDefault -*/ -type CreateTCPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateTCPRequestRuleDefault creates CreateTCPRequestRuleDefault with default headers values -func NewCreateTCPRequestRuleDefault(code int) *CreateTCPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &CreateTCPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create TCP request rule default response -func (o *CreateTCPRequestRuleDefault) WithStatusCode(code int) *CreateTCPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create TCP request rule default response -func (o *CreateTCPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create TCP request rule default response -func (o *CreateTCPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *CreateTCPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create TCP request rule default response -func (o *CreateTCPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create TCP request rule default response -func (o *CreateTCPRequestRuleDefault) WithPayload(payload *models.Error) *CreateTCPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create TCP request rule default response -func (o *CreateTCPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_request_rule/create_tcp_request_rule_urlbuilder.go b/operations/tcp_request_rule/create_tcp_request_rule_urlbuilder.go deleted file mode 100644 index 2bab752b..00000000 --- a/operations/tcp_request_rule/create_tcp_request_rule_urlbuilder.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateTCPRequestRuleURL generates an URL for the create TCP request rule operation -type CreateTCPRequestRuleURL struct { - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateTCPRequestRuleURL) WithBasePath(bp string) *CreateTCPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateTCPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateTCPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_request_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateTCPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateTCPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateTCPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateTCPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateTCPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateTCPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule.go b/operations/tcp_request_rule/delete_tcp_request_rule.go deleted file mode 100644 index dd60f51f..00000000 --- a/operations/tcp_request_rule/delete_tcp_request_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteTCPRequestRuleHandlerFunc turns a function with the right signature into a delete TCP request rule handler -type DeleteTCPRequestRuleHandlerFunc func(DeleteTCPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteTCPRequestRuleHandlerFunc) Handle(params DeleteTCPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteTCPRequestRuleHandler interface for that can handle valid delete TCP request rule params -type DeleteTCPRequestRuleHandler interface { - Handle(DeleteTCPRequestRuleParams, interface{}) middleware.Responder -} - -// NewDeleteTCPRequestRule creates a new http.Handler for the delete TCP request rule operation -func NewDeleteTCPRequestRule(ctx *middleware.Context, handler DeleteTCPRequestRuleHandler) *DeleteTCPRequestRule { - return &DeleteTCPRequestRule{Context: ctx, Handler: handler} -} - -/*DeleteTCPRequestRule swagger:route DELETE /services/haproxy/configuration/tcp_request_rules/{id} TCPRequestRule deleteTcpRequestRule - -Delete a TCP Request Rule - -Deletes a TCP Request Rule configuration by it's ID from the specified parent. - -*/ -type DeleteTCPRequestRule struct { - Context *middleware.Context - Handler DeleteTCPRequestRuleHandler -} - -func (o *DeleteTCPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteTCPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_backend.go b/operations/tcp_request_rule/delete_tcp_request_rule_backend.go new file mode 100644 index 00000000..d5594d77 --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTCPRequestRuleBackendHandlerFunc turns a function with the right signature into a delete TCP request rule backend handler +type DeleteTCPRequestRuleBackendHandlerFunc func(DeleteTCPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTCPRequestRuleBackendHandlerFunc) Handle(params DeleteTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTCPRequestRuleBackendHandler interface for that can handle valid delete TCP request rule backend params +type DeleteTCPRequestRuleBackendHandler interface { + Handle(DeleteTCPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewDeleteTCPRequestRuleBackend creates a new http.Handler for the delete TCP request rule backend operation +func NewDeleteTCPRequestRuleBackend(ctx *middleware.Context, handler DeleteTCPRequestRuleBackendHandler) *DeleteTCPRequestRuleBackend { + return &DeleteTCPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + DeleteTCPRequestRuleBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index} TCPRequestRule deleteTcpRequestRuleBackend + +# Delete a TCP Request Rule + +Deletes a TCP Request Rule configuration by it's index from the specified parent. +*/ +type DeleteTCPRequestRuleBackend struct { + Context *middleware.Context + Handler DeleteTCPRequestRuleBackendHandler +} + +func (o *DeleteTCPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTCPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_backend_parameters.go b/operations/tcp_request_rule/delete_tcp_request_rule_backend_parameters.go new file mode 100644 index 00000000..a91a9ade --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTCPRequestRuleBackendParams creates a new DeleteTCPRequestRuleBackendParams object +// with the default values initialized. +func NewDeleteTCPRequestRuleBackendParams() DeleteTCPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTCPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTCPRequestRuleBackendParams contains all the bound params for the delete TCP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTCPRequestRuleBackend +type DeleteTCPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTCPRequestRuleBackendParams() beforehand. +func (o *DeleteTCPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTCPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTCPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteTCPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTCPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTCPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTCPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_backend_responses.go b/operations/tcp_request_rule/delete_tcp_request_rule_backend_responses.go new file mode 100644 index 00000000..4608b23c --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTCPRequestRuleBackendAcceptedCode is the HTTP code returned for type DeleteTCPRequestRuleBackendAccepted +const DeleteTCPRequestRuleBackendAcceptedCode int = 202 + +/* +DeleteTCPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteTcpRequestRuleBackendAccepted +*/ +type DeleteTCPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTCPRequestRuleBackendAccepted creates DeleteTCPRequestRuleBackendAccepted with default headers values +func NewDeleteTCPRequestRuleBackendAccepted() *DeleteTCPRequestRuleBackendAccepted { + + return &DeleteTCPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Tcp request rule backend accepted response +func (o *DeleteTCPRequestRuleBackendAccepted) WithReloadID(reloadID string) *DeleteTCPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Tcp request rule backend accepted response +func (o *DeleteTCPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTCPRequestRuleBackendNoContentCode is the HTTP code returned for type DeleteTCPRequestRuleBackendNoContent +const DeleteTCPRequestRuleBackendNoContentCode int = 204 + +/* +DeleteTCPRequestRuleBackendNoContent TCP Request Rule deleted + +swagger:response deleteTcpRequestRuleBackendNoContent +*/ +type DeleteTCPRequestRuleBackendNoContent struct { +} + +// NewDeleteTCPRequestRuleBackendNoContent creates DeleteTCPRequestRuleBackendNoContent with default headers values +func NewDeleteTCPRequestRuleBackendNoContent() *DeleteTCPRequestRuleBackendNoContent { + + return &DeleteTCPRequestRuleBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTCPRequestRuleBackendNotFoundCode is the HTTP code returned for type DeleteTCPRequestRuleBackendNotFound +const DeleteTCPRequestRuleBackendNotFoundCode int = 404 + +/* +DeleteTCPRequestRuleBackendNotFound The specified resource was not found + +swagger:response deleteTcpRequestRuleBackendNotFound +*/ +type DeleteTCPRequestRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPRequestRuleBackendNotFound creates DeleteTCPRequestRuleBackendNotFound with default headers values +func NewDeleteTCPRequestRuleBackendNotFound() *DeleteTCPRequestRuleBackendNotFound { + + return &DeleteTCPRequestRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Tcp request rule backend not found response +func (o *DeleteTCPRequestRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTCPRequestRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Tcp request rule backend not found response +func (o *DeleteTCPRequestRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Tcp request rule backend not found response +func (o *DeleteTCPRequestRuleBackendNotFound) WithPayload(payload *models.Error) *DeleteTCPRequestRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Tcp request rule backend not found response +func (o *DeleteTCPRequestRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTCPRequestRuleBackendDefault General Error + +swagger:response deleteTcpRequestRuleBackendDefault +*/ +type DeleteTCPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPRequestRuleBackendDefault creates DeleteTCPRequestRuleBackendDefault with default headers values +func NewDeleteTCPRequestRuleBackendDefault(code int) *DeleteTCPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTCPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete TCP request rule backend default response +func (o *DeleteTCPRequestRuleBackendDefault) WithStatusCode(code int) *DeleteTCPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete TCP request rule backend default response +func (o *DeleteTCPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete TCP request rule backend default response +func (o *DeleteTCPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteTCPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete TCP request rule backend default response +func (o *DeleteTCPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete TCP request rule backend default response +func (o *DeleteTCPRequestRuleBackendDefault) WithPayload(payload *models.Error) *DeleteTCPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete TCP request rule backend default response +func (o *DeleteTCPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_backend_urlbuilder.go b/operations/tcp_request_rule/delete_tcp_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..4ec6022e --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTCPRequestRuleBackendURL generates an URL for the delete TCP request rule backend operation +type DeleteTCPRequestRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPRequestRuleBackendURL) WithBasePath(bp string) *DeleteTCPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTCPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteTCPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTCPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTCPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTCPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTCPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTCPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTCPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTCPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_defaults.go b/operations/tcp_request_rule/delete_tcp_request_rule_defaults.go new file mode 100644 index 00000000..7419e5ce --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTCPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a delete TCP request rule defaults handler +type DeleteTCPRequestRuleDefaultsHandlerFunc func(DeleteTCPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTCPRequestRuleDefaultsHandlerFunc) Handle(params DeleteTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTCPRequestRuleDefaultsHandler interface for that can handle valid delete TCP request rule defaults params +type DeleteTCPRequestRuleDefaultsHandler interface { + Handle(DeleteTCPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteTCPRequestRuleDefaults creates a new http.Handler for the delete TCP request rule defaults operation +func NewDeleteTCPRequestRuleDefaults(ctx *middleware.Context, handler DeleteTCPRequestRuleDefaultsHandler) *DeleteTCPRequestRuleDefaults { + return &DeleteTCPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteTCPRequestRuleDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index} TCPRequestRule deleteTcpRequestRuleDefaults + +# Delete a TCP Request Rule + +Deletes a TCP Request Rule configuration by it's index from the specified parent. +*/ +type DeleteTCPRequestRuleDefaults struct { + Context *middleware.Context + Handler DeleteTCPRequestRuleDefaultsHandler +} + +func (o *DeleteTCPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTCPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_defaults_parameters.go b/operations/tcp_request_rule/delete_tcp_request_rule_defaults_parameters.go new file mode 100644 index 00000000..6aafb50f --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTCPRequestRuleDefaultsParams creates a new DeleteTCPRequestRuleDefaultsParams object +// with the default values initialized. +func NewDeleteTCPRequestRuleDefaultsParams() DeleteTCPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTCPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTCPRequestRuleDefaultsParams contains all the bound params for the delete TCP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTCPRequestRuleDefaults +type DeleteTCPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTCPRequestRuleDefaultsParams() beforehand. +func (o *DeleteTCPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTCPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTCPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteTCPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTCPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTCPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTCPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_defaults_responses.go b/operations/tcp_request_rule/delete_tcp_request_rule_defaults_responses.go new file mode 100644 index 00000000..5b04ff17 --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTCPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type DeleteTCPRequestRuleDefaultsAccepted +const DeleteTCPRequestRuleDefaultsAcceptedCode int = 202 + +/* +DeleteTCPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteTcpRequestRuleDefaultsAccepted +*/ +type DeleteTCPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTCPRequestRuleDefaultsAccepted creates DeleteTCPRequestRuleDefaultsAccepted with default headers values +func NewDeleteTCPRequestRuleDefaultsAccepted() *DeleteTCPRequestRuleDefaultsAccepted { + + return &DeleteTCPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Tcp request rule defaults accepted response +func (o *DeleteTCPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *DeleteTCPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Tcp request rule defaults accepted response +func (o *DeleteTCPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTCPRequestRuleDefaultsNoContentCode is the HTTP code returned for type DeleteTCPRequestRuleDefaultsNoContent +const DeleteTCPRequestRuleDefaultsNoContentCode int = 204 + +/* +DeleteTCPRequestRuleDefaultsNoContent TCP Request Rule deleted + +swagger:response deleteTcpRequestRuleDefaultsNoContent +*/ +type DeleteTCPRequestRuleDefaultsNoContent struct { +} + +// NewDeleteTCPRequestRuleDefaultsNoContent creates DeleteTCPRequestRuleDefaultsNoContent with default headers values +func NewDeleteTCPRequestRuleDefaultsNoContent() *DeleteTCPRequestRuleDefaultsNoContent { + + return &DeleteTCPRequestRuleDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTCPRequestRuleDefaultsNotFoundCode is the HTTP code returned for type DeleteTCPRequestRuleDefaultsNotFound +const DeleteTCPRequestRuleDefaultsNotFoundCode int = 404 + +/* +DeleteTCPRequestRuleDefaultsNotFound The specified resource was not found + +swagger:response deleteTcpRequestRuleDefaultsNotFound +*/ +type DeleteTCPRequestRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPRequestRuleDefaultsNotFound creates DeleteTCPRequestRuleDefaultsNotFound with default headers values +func NewDeleteTCPRequestRuleDefaultsNotFound() *DeleteTCPRequestRuleDefaultsNotFound { + + return &DeleteTCPRequestRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Tcp request rule defaults not found response +func (o *DeleteTCPRequestRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTCPRequestRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Tcp request rule defaults not found response +func (o *DeleteTCPRequestRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Tcp request rule defaults not found response +func (o *DeleteTCPRequestRuleDefaultsNotFound) WithPayload(payload *models.Error) *DeleteTCPRequestRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Tcp request rule defaults not found response +func (o *DeleteTCPRequestRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTCPRequestRuleDefaultsDefault General Error + +swagger:response deleteTcpRequestRuleDefaultsDefault +*/ +type DeleteTCPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPRequestRuleDefaultsDefault creates DeleteTCPRequestRuleDefaultsDefault with default headers values +func NewDeleteTCPRequestRuleDefaultsDefault(code int) *DeleteTCPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTCPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete TCP request rule defaults default response +func (o *DeleteTCPRequestRuleDefaultsDefault) WithStatusCode(code int) *DeleteTCPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete TCP request rule defaults default response +func (o *DeleteTCPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete TCP request rule defaults default response +func (o *DeleteTCPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteTCPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete TCP request rule defaults default response +func (o *DeleteTCPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete TCP request rule defaults default response +func (o *DeleteTCPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *DeleteTCPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete TCP request rule defaults default response +func (o *DeleteTCPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_defaults_urlbuilder.go b/operations/tcp_request_rule/delete_tcp_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..a728fda9 --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTCPRequestRuleDefaultsURL generates an URL for the delete TCP request rule defaults operation +type DeleteTCPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPRequestRuleDefaultsURL) WithBasePath(bp string) *DeleteTCPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTCPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteTCPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTCPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTCPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTCPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTCPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTCPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTCPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTCPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_frontend.go b/operations/tcp_request_rule/delete_tcp_request_rule_frontend.go new file mode 100644 index 00000000..4690df67 --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTCPRequestRuleFrontendHandlerFunc turns a function with the right signature into a delete TCP request rule frontend handler +type DeleteTCPRequestRuleFrontendHandlerFunc func(DeleteTCPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTCPRequestRuleFrontendHandlerFunc) Handle(params DeleteTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTCPRequestRuleFrontendHandler interface for that can handle valid delete TCP request rule frontend params +type DeleteTCPRequestRuleFrontendHandler interface { + Handle(DeleteTCPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewDeleteTCPRequestRuleFrontend creates a new http.Handler for the delete TCP request rule frontend operation +func NewDeleteTCPRequestRuleFrontend(ctx *middleware.Context, handler DeleteTCPRequestRuleFrontendHandler) *DeleteTCPRequestRuleFrontend { + return &DeleteTCPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + DeleteTCPRequestRuleFrontend swagger:route DELETE /services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index} TCPRequestRule deleteTcpRequestRuleFrontend + +# Delete a TCP Request Rule + +Deletes a TCP Request Rule configuration by it's index from the specified parent. +*/ +type DeleteTCPRequestRuleFrontend struct { + Context *middleware.Context + Handler DeleteTCPRequestRuleFrontendHandler +} + +func (o *DeleteTCPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTCPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_frontend_parameters.go b/operations/tcp_request_rule/delete_tcp_request_rule_frontend_parameters.go new file mode 100644 index 00000000..f08d511b --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_frontend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTCPRequestRuleFrontendParams creates a new DeleteTCPRequestRuleFrontendParams object +// with the default values initialized. +func NewDeleteTCPRequestRuleFrontendParams() DeleteTCPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTCPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTCPRequestRuleFrontendParams contains all the bound params for the delete TCP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTCPRequestRuleFrontend +type DeleteTCPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTCPRequestRuleFrontendParams() beforehand. +func (o *DeleteTCPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTCPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTCPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteTCPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTCPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTCPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTCPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_frontend_responses.go b/operations/tcp_request_rule/delete_tcp_request_rule_frontend_responses.go new file mode 100644 index 00000000..e2cb9ea6 --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_frontend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTCPRequestRuleFrontendAcceptedCode is the HTTP code returned for type DeleteTCPRequestRuleFrontendAccepted +const DeleteTCPRequestRuleFrontendAcceptedCode int = 202 + +/* +DeleteTCPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response deleteTcpRequestRuleFrontendAccepted +*/ +type DeleteTCPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTCPRequestRuleFrontendAccepted creates DeleteTCPRequestRuleFrontendAccepted with default headers values +func NewDeleteTCPRequestRuleFrontendAccepted() *DeleteTCPRequestRuleFrontendAccepted { + + return &DeleteTCPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Tcp request rule frontend accepted response +func (o *DeleteTCPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *DeleteTCPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Tcp request rule frontend accepted response +func (o *DeleteTCPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTCPRequestRuleFrontendNoContentCode is the HTTP code returned for type DeleteTCPRequestRuleFrontendNoContent +const DeleteTCPRequestRuleFrontendNoContentCode int = 204 + +/* +DeleteTCPRequestRuleFrontendNoContent TCP Request Rule deleted + +swagger:response deleteTcpRequestRuleFrontendNoContent +*/ +type DeleteTCPRequestRuleFrontendNoContent struct { +} + +// NewDeleteTCPRequestRuleFrontendNoContent creates DeleteTCPRequestRuleFrontendNoContent with default headers values +func NewDeleteTCPRequestRuleFrontendNoContent() *DeleteTCPRequestRuleFrontendNoContent { + + return &DeleteTCPRequestRuleFrontendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleFrontendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTCPRequestRuleFrontendNotFoundCode is the HTTP code returned for type DeleteTCPRequestRuleFrontendNotFound +const DeleteTCPRequestRuleFrontendNotFoundCode int = 404 + +/* +DeleteTCPRequestRuleFrontendNotFound The specified resource was not found + +swagger:response deleteTcpRequestRuleFrontendNotFound +*/ +type DeleteTCPRequestRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPRequestRuleFrontendNotFound creates DeleteTCPRequestRuleFrontendNotFound with default headers values +func NewDeleteTCPRequestRuleFrontendNotFound() *DeleteTCPRequestRuleFrontendNotFound { + + return &DeleteTCPRequestRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Tcp request rule frontend not found response +func (o *DeleteTCPRequestRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTCPRequestRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Tcp request rule frontend not found response +func (o *DeleteTCPRequestRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Tcp request rule frontend not found response +func (o *DeleteTCPRequestRuleFrontendNotFound) WithPayload(payload *models.Error) *DeleteTCPRequestRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Tcp request rule frontend not found response +func (o *DeleteTCPRequestRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTCPRequestRuleFrontendDefault General Error + +swagger:response deleteTcpRequestRuleFrontendDefault +*/ +type DeleteTCPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPRequestRuleFrontendDefault creates DeleteTCPRequestRuleFrontendDefault with default headers values +func NewDeleteTCPRequestRuleFrontendDefault(code int) *DeleteTCPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTCPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete TCP request rule frontend default response +func (o *DeleteTCPRequestRuleFrontendDefault) WithStatusCode(code int) *DeleteTCPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete TCP request rule frontend default response +func (o *DeleteTCPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete TCP request rule frontend default response +func (o *DeleteTCPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *DeleteTCPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete TCP request rule frontend default response +func (o *DeleteTCPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete TCP request rule frontend default response +func (o *DeleteTCPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *DeleteTCPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete TCP request rule frontend default response +func (o *DeleteTCPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_frontend_urlbuilder.go b/operations/tcp_request_rule/delete_tcp_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..a55d46d8 --- /dev/null +++ b/operations/tcp_request_rule/delete_tcp_request_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTCPRequestRuleFrontendURL generates an URL for the delete TCP request rule frontend operation +type DeleteTCPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPRequestRuleFrontendURL) WithBasePath(bp string) *DeleteTCPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTCPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteTCPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTCPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTCPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTCPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTCPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTCPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTCPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTCPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_parameters.go b/operations/tcp_request_rule/delete_tcp_request_rule_parameters.go deleted file mode 100644 index 3d0e6194..00000000 --- a/operations/tcp_request_rule/delete_tcp_request_rule_parameters.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteTCPRequestRuleParams creates a new DeleteTCPRequestRuleParams object -// with the default values initialized. -func NewDeleteTCPRequestRuleParams() DeleteTCPRequestRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteTCPRequestRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteTCPRequestRuleParams contains all the bound params for the delete TCP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteTCPRequestRule -type DeleteTCPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*TCP Request Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteTCPRequestRuleParams() beforehand. -func (o *DeleteTCPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteTCPRequestRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteTCPRequestRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *DeleteTCPRequestRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *DeleteTCPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *DeleteTCPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *DeleteTCPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteTCPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteTCPRequestRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_responses.go b/operations/tcp_request_rule/delete_tcp_request_rule_responses.go deleted file mode 100644 index 4db35a3d..00000000 --- a/operations/tcp_request_rule/delete_tcp_request_rule_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteTCPRequestRuleAcceptedCode is the HTTP code returned for type DeleteTCPRequestRuleAccepted -const DeleteTCPRequestRuleAcceptedCode int = 202 - -/*DeleteTCPRequestRuleAccepted Configuration change accepted and reload requested - -swagger:response deleteTcpRequestRuleAccepted -*/ -type DeleteTCPRequestRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteTCPRequestRuleAccepted creates DeleteTCPRequestRuleAccepted with default headers values -func NewDeleteTCPRequestRuleAccepted() *DeleteTCPRequestRuleAccepted { - - return &DeleteTCPRequestRuleAccepted{} -} - -// WithReloadID adds the reloadId to the delete Tcp request rule accepted response -func (o *DeleteTCPRequestRuleAccepted) WithReloadID(reloadID string) *DeleteTCPRequestRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete Tcp request rule accepted response -func (o *DeleteTCPRequestRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteTCPRequestRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteTCPRequestRuleNoContentCode is the HTTP code returned for type DeleteTCPRequestRuleNoContent -const DeleteTCPRequestRuleNoContentCode int = 204 - -/*DeleteTCPRequestRuleNoContent TCP Request Rule deleted - -swagger:response deleteTcpRequestRuleNoContent -*/ -type DeleteTCPRequestRuleNoContent struct { -} - -// NewDeleteTCPRequestRuleNoContent creates DeleteTCPRequestRuleNoContent with default headers values -func NewDeleteTCPRequestRuleNoContent() *DeleteTCPRequestRuleNoContent { - - return &DeleteTCPRequestRuleNoContent{} -} - -// WriteResponse to the client -func (o *DeleteTCPRequestRuleNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteTCPRequestRuleNotFoundCode is the HTTP code returned for type DeleteTCPRequestRuleNotFound -const DeleteTCPRequestRuleNotFoundCode int = 404 - -/*DeleteTCPRequestRuleNotFound The specified resource was not found - -swagger:response deleteTcpRequestRuleNotFound -*/ -type DeleteTCPRequestRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteTCPRequestRuleNotFound creates DeleteTCPRequestRuleNotFound with default headers values -func NewDeleteTCPRequestRuleNotFound() *DeleteTCPRequestRuleNotFound { - - return &DeleteTCPRequestRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete Tcp request rule not found response -func (o *DeleteTCPRequestRuleNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteTCPRequestRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete Tcp request rule not found response -func (o *DeleteTCPRequestRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete Tcp request rule not found response -func (o *DeleteTCPRequestRuleNotFound) WithPayload(payload *models.Error) *DeleteTCPRequestRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete Tcp request rule not found response -func (o *DeleteTCPRequestRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteTCPRequestRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteTCPRequestRuleDefault General Error - -swagger:response deleteTcpRequestRuleDefault -*/ -type DeleteTCPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteTCPRequestRuleDefault creates DeleteTCPRequestRuleDefault with default headers values -func NewDeleteTCPRequestRuleDefault(code int) *DeleteTCPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &DeleteTCPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete TCP request rule default response -func (o *DeleteTCPRequestRuleDefault) WithStatusCode(code int) *DeleteTCPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete TCP request rule default response -func (o *DeleteTCPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete TCP request rule default response -func (o *DeleteTCPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *DeleteTCPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete TCP request rule default response -func (o *DeleteTCPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete TCP request rule default response -func (o *DeleteTCPRequestRuleDefault) WithPayload(payload *models.Error) *DeleteTCPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete TCP request rule default response -func (o *DeleteTCPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteTCPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_request_rule/delete_tcp_request_rule_urlbuilder.go b/operations/tcp_request_rule/delete_tcp_request_rule_urlbuilder.go deleted file mode 100644 index 2e213910..00000000 --- a/operations/tcp_request_rule/delete_tcp_request_rule_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteTCPRequestRuleURL generates an URL for the delete TCP request rule operation -type DeleteTCPRequestRuleURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteTCPRequestRuleURL) WithBasePath(bp string) *DeleteTCPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteTCPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteTCPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_request_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on DeleteTCPRequestRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteTCPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteTCPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteTCPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteTCPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteTCPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteTCPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_backend.go b/operations/tcp_request_rule/get_all_tcp_request_rule_backend.go new file mode 100644 index 00000000..266d7567 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllTCPRequestRuleBackendHandlerFunc turns a function with the right signature into a get all TCP request rule backend handler +type GetAllTCPRequestRuleBackendHandlerFunc func(GetAllTCPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllTCPRequestRuleBackendHandlerFunc) Handle(params GetAllTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllTCPRequestRuleBackendHandler interface for that can handle valid get all TCP request rule backend params +type GetAllTCPRequestRuleBackendHandler interface { + Handle(GetAllTCPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetAllTCPRequestRuleBackend creates a new http.Handler for the get all TCP request rule backend operation +func NewGetAllTCPRequestRuleBackend(ctx *middleware.Context, handler GetAllTCPRequestRuleBackendHandler) *GetAllTCPRequestRuleBackend { + return &GetAllTCPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetAllTCPRequestRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/tcp_request_rules TCPRequestRule getAllTcpRequestRuleBackend + +# Return an array of all TCP Request Rules + +Returns all TCP Request Rules that are configured in specified parent and parent type. +*/ +type GetAllTCPRequestRuleBackend struct { + Context *middleware.Context + Handler GetAllTCPRequestRuleBackendHandler +} + +func (o *GetAllTCPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllTCPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_backend_parameters.go b/operations/tcp_request_rule/get_all_tcp_request_rule_backend_parameters.go new file mode 100644 index 00000000..4b5640fb --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllTCPRequestRuleBackendParams creates a new GetAllTCPRequestRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllTCPRequestRuleBackendParams() GetAllTCPRequestRuleBackendParams { + + return GetAllTCPRequestRuleBackendParams{} +} + +// GetAllTCPRequestRuleBackendParams contains all the bound params for the get all TCP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllTCPRequestRuleBackend +type GetAllTCPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllTCPRequestRuleBackendParams() beforehand. +func (o *GetAllTCPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllTCPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllTCPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_backend_responses.go b/operations/tcp_request_rule/get_all_tcp_request_rule_backend_responses.go new file mode 100644 index 00000000..4b904e53 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllTCPRequestRuleBackendOKCode is the HTTP code returned for type GetAllTCPRequestRuleBackendOK +const GetAllTCPRequestRuleBackendOKCode int = 200 + +/* +GetAllTCPRequestRuleBackendOK Successful operation + +swagger:response getAllTcpRequestRuleBackendOK +*/ +type GetAllTCPRequestRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewGetAllTCPRequestRuleBackendOK creates GetAllTCPRequestRuleBackendOK with default headers values +func NewGetAllTCPRequestRuleBackendOK() *GetAllTCPRequestRuleBackendOK { + + return &GetAllTCPRequestRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Tcp request rule backend o k response +func (o *GetAllTCPRequestRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllTCPRequestRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Tcp request rule backend o k response +func (o *GetAllTCPRequestRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Tcp request rule backend o k response +func (o *GetAllTCPRequestRuleBackendOK) WithPayload(payload models.TCPRequestRules) *GetAllTCPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Tcp request rule backend o k response +func (o *GetAllTCPRequestRuleBackendOK) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllTCPRequestRuleBackendDefault General Error + +swagger:response getAllTcpRequestRuleBackendDefault +*/ +type GetAllTCPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllTCPRequestRuleBackendDefault creates GetAllTCPRequestRuleBackendDefault with default headers values +func NewGetAllTCPRequestRuleBackendDefault(code int) *GetAllTCPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllTCPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all TCP request rule backend default response +func (o *GetAllTCPRequestRuleBackendDefault) WithStatusCode(code int) *GetAllTCPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all TCP request rule backend default response +func (o *GetAllTCPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all TCP request rule backend default response +func (o *GetAllTCPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllTCPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all TCP request rule backend default response +func (o *GetAllTCPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all TCP request rule backend default response +func (o *GetAllTCPRequestRuleBackendDefault) WithPayload(payload *models.Error) *GetAllTCPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all TCP request rule backend default response +func (o *GetAllTCPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_backend_urlbuilder.go b/operations/tcp_request_rule/get_all_tcp_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..8f65a488 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllTCPRequestRuleBackendURL generates an URL for the get all TCP request rule backend operation +type GetAllTCPRequestRuleBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPRequestRuleBackendURL) WithBasePath(bp string) *GetAllTCPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllTCPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllTCPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllTCPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllTCPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllTCPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllTCPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllTCPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllTCPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_defaults.go b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults.go new file mode 100644 index 00000000..e6a48ee7 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllTCPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a get all TCP request rule defaults handler +type GetAllTCPRequestRuleDefaultsHandlerFunc func(GetAllTCPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllTCPRequestRuleDefaultsHandlerFunc) Handle(params GetAllTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllTCPRequestRuleDefaultsHandler interface for that can handle valid get all TCP request rule defaults params +type GetAllTCPRequestRuleDefaultsHandler interface { + Handle(GetAllTCPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllTCPRequestRuleDefaults creates a new http.Handler for the get all TCP request rule defaults operation +func NewGetAllTCPRequestRuleDefaults(ctx *middleware.Context, handler GetAllTCPRequestRuleDefaultsHandler) *GetAllTCPRequestRuleDefaults { + return &GetAllTCPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllTCPRequestRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules TCPRequestRule getAllTcpRequestRuleDefaults + +# Return an array of all TCP Request Rules + +Returns all TCP Request Rules that are configured in specified parent and parent type. +*/ +type GetAllTCPRequestRuleDefaults struct { + Context *middleware.Context + Handler GetAllTCPRequestRuleDefaultsHandler +} + +func (o *GetAllTCPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllTCPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_parameters.go b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_parameters.go new file mode 100644 index 00000000..0c5b28dc --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllTCPRequestRuleDefaultsParams creates a new GetAllTCPRequestRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllTCPRequestRuleDefaultsParams() GetAllTCPRequestRuleDefaultsParams { + + return GetAllTCPRequestRuleDefaultsParams{} +} + +// GetAllTCPRequestRuleDefaultsParams contains all the bound params for the get all TCP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllTCPRequestRuleDefaults +type GetAllTCPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllTCPRequestRuleDefaultsParams() beforehand. +func (o *GetAllTCPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllTCPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllTCPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_responses.go b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_responses.go new file mode 100644 index 00000000..31e52326 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllTCPRequestRuleDefaultsOKCode is the HTTP code returned for type GetAllTCPRequestRuleDefaultsOK +const GetAllTCPRequestRuleDefaultsOKCode int = 200 + +/* +GetAllTCPRequestRuleDefaultsOK Successful operation + +swagger:response getAllTcpRequestRuleDefaultsOK +*/ +type GetAllTCPRequestRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewGetAllTCPRequestRuleDefaultsOK creates GetAllTCPRequestRuleDefaultsOK with default headers values +func NewGetAllTCPRequestRuleDefaultsOK() *GetAllTCPRequestRuleDefaultsOK { + + return &GetAllTCPRequestRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Tcp request rule defaults o k response +func (o *GetAllTCPRequestRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllTCPRequestRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Tcp request rule defaults o k response +func (o *GetAllTCPRequestRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Tcp request rule defaults o k response +func (o *GetAllTCPRequestRuleDefaultsOK) WithPayload(payload models.TCPRequestRules) *GetAllTCPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Tcp request rule defaults o k response +func (o *GetAllTCPRequestRuleDefaultsOK) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllTCPRequestRuleDefaultsDefault General Error + +swagger:response getAllTcpRequestRuleDefaultsDefault +*/ +type GetAllTCPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllTCPRequestRuleDefaultsDefault creates GetAllTCPRequestRuleDefaultsDefault with default headers values +func NewGetAllTCPRequestRuleDefaultsDefault(code int) *GetAllTCPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllTCPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all TCP request rule defaults default response +func (o *GetAllTCPRequestRuleDefaultsDefault) WithStatusCode(code int) *GetAllTCPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all TCP request rule defaults default response +func (o *GetAllTCPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all TCP request rule defaults default response +func (o *GetAllTCPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllTCPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all TCP request rule defaults default response +func (o *GetAllTCPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all TCP request rule defaults default response +func (o *GetAllTCPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *GetAllTCPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all TCP request rule defaults default response +func (o *GetAllTCPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_urlbuilder.go b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..bfe6cee8 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllTCPRequestRuleDefaultsURL generates an URL for the get all TCP request rule defaults operation +type GetAllTCPRequestRuleDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPRequestRuleDefaultsURL) WithBasePath(bp string) *GetAllTCPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllTCPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllTCPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllTCPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllTCPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllTCPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllTCPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllTCPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllTCPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_frontend.go b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend.go new file mode 100644 index 00000000..2bc6b7b7 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllTCPRequestRuleFrontendHandlerFunc turns a function with the right signature into a get all TCP request rule frontend handler +type GetAllTCPRequestRuleFrontendHandlerFunc func(GetAllTCPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllTCPRequestRuleFrontendHandlerFunc) Handle(params GetAllTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllTCPRequestRuleFrontendHandler interface for that can handle valid get all TCP request rule frontend params +type GetAllTCPRequestRuleFrontendHandler interface { + Handle(GetAllTCPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetAllTCPRequestRuleFrontend creates a new http.Handler for the get all TCP request rule frontend operation +func NewGetAllTCPRequestRuleFrontend(ctx *middleware.Context, handler GetAllTCPRequestRuleFrontendHandler) *GetAllTCPRequestRuleFrontend { + return &GetAllTCPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetAllTCPRequestRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules TCPRequestRule getAllTcpRequestRuleFrontend + +# Return an array of all TCP Request Rules + +Returns all TCP Request Rules that are configured in specified parent and parent type. +*/ +type GetAllTCPRequestRuleFrontend struct { + Context *middleware.Context + Handler GetAllTCPRequestRuleFrontendHandler +} + +func (o *GetAllTCPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllTCPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_parameters.go b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_parameters.go new file mode 100644 index 00000000..41f2eda9 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllTCPRequestRuleFrontendParams creates a new GetAllTCPRequestRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetAllTCPRequestRuleFrontendParams() GetAllTCPRequestRuleFrontendParams { + + return GetAllTCPRequestRuleFrontendParams{} +} + +// GetAllTCPRequestRuleFrontendParams contains all the bound params for the get all TCP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllTCPRequestRuleFrontend +type GetAllTCPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllTCPRequestRuleFrontendParams() beforehand. +func (o *GetAllTCPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllTCPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllTCPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_responses.go b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_responses.go new file mode 100644 index 00000000..9e22a57f --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllTCPRequestRuleFrontendOKCode is the HTTP code returned for type GetAllTCPRequestRuleFrontendOK +const GetAllTCPRequestRuleFrontendOKCode int = 200 + +/* +GetAllTCPRequestRuleFrontendOK Successful operation + +swagger:response getAllTcpRequestRuleFrontendOK +*/ +type GetAllTCPRequestRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewGetAllTCPRequestRuleFrontendOK creates GetAllTCPRequestRuleFrontendOK with default headers values +func NewGetAllTCPRequestRuleFrontendOK() *GetAllTCPRequestRuleFrontendOK { + + return &GetAllTCPRequestRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Tcp request rule frontend o k response +func (o *GetAllTCPRequestRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetAllTCPRequestRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Tcp request rule frontend o k response +func (o *GetAllTCPRequestRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Tcp request rule frontend o k response +func (o *GetAllTCPRequestRuleFrontendOK) WithPayload(payload models.TCPRequestRules) *GetAllTCPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Tcp request rule frontend o k response +func (o *GetAllTCPRequestRuleFrontendOK) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllTCPRequestRuleFrontendDefault General Error + +swagger:response getAllTcpRequestRuleFrontendDefault +*/ +type GetAllTCPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllTCPRequestRuleFrontendDefault creates GetAllTCPRequestRuleFrontendDefault with default headers values +func NewGetAllTCPRequestRuleFrontendDefault(code int) *GetAllTCPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllTCPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all TCP request rule frontend default response +func (o *GetAllTCPRequestRuleFrontendDefault) WithStatusCode(code int) *GetAllTCPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all TCP request rule frontend default response +func (o *GetAllTCPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all TCP request rule frontend default response +func (o *GetAllTCPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetAllTCPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all TCP request rule frontend default response +func (o *GetAllTCPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all TCP request rule frontend default response +func (o *GetAllTCPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *GetAllTCPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all TCP request rule frontend default response +func (o *GetAllTCPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_urlbuilder.go b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..3eb7fb81 --- /dev/null +++ b/operations/tcp_request_rule/get_all_tcp_request_rule_frontend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllTCPRequestRuleFrontendURL generates an URL for the get all TCP request rule frontend operation +type GetAllTCPRequestRuleFrontendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPRequestRuleFrontendURL) WithBasePath(bp string) *GetAllTCPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllTCPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllTCPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllTCPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllTCPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllTCPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllTCPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllTCPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllTCPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule.go b/operations/tcp_request_rule/get_tcp_request_rule.go deleted file mode 100644 index f250a302..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rule.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetTCPRequestRuleHandlerFunc turns a function with the right signature into a get TCP request rule handler -type GetTCPRequestRuleHandlerFunc func(GetTCPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetTCPRequestRuleHandlerFunc) Handle(params GetTCPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetTCPRequestRuleHandler interface for that can handle valid get TCP request rule params -type GetTCPRequestRuleHandler interface { - Handle(GetTCPRequestRuleParams, interface{}) middleware.Responder -} - -// NewGetTCPRequestRule creates a new http.Handler for the get TCP request rule operation -func NewGetTCPRequestRule(ctx *middleware.Context, handler GetTCPRequestRuleHandler) *GetTCPRequestRule { - return &GetTCPRequestRule{Context: ctx, Handler: handler} -} - -/*GetTCPRequestRule swagger:route GET /services/haproxy/configuration/tcp_request_rules/{id} TCPRequestRule getTcpRequestRule - -Return one TCP Request Rule - -Returns one TCP Request Rule configuration by it's ID in the specified parent. - -*/ -type GetTCPRequestRule struct { - Context *middleware.Context - Handler GetTCPRequestRuleHandler -} - -func (o *GetTCPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetTCPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetTCPRequestRuleOKBody get TCP request rule o k body -// swagger:model GetTCPRequestRuleOKBody -type GetTCPRequestRuleOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.TCPRequestRule `json:"data,omitempty"` -} - -// Validate validates this get TCP request rule o k body -func (o *GetTCPRequestRuleOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetTCPRequestRuleOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getTcpRequestRuleOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetTCPRequestRuleOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetTCPRequestRuleOKBody) UnmarshalBinary(b []byte) error { - var res GetTCPRequestRuleOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_backend.go b/operations/tcp_request_rule/get_tcp_request_rule_backend.go new file mode 100644 index 00000000..ccb9a6a0 --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTCPRequestRuleBackendHandlerFunc turns a function with the right signature into a get TCP request rule backend handler +type GetTCPRequestRuleBackendHandlerFunc func(GetTCPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTCPRequestRuleBackendHandlerFunc) Handle(params GetTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTCPRequestRuleBackendHandler interface for that can handle valid get TCP request rule backend params +type GetTCPRequestRuleBackendHandler interface { + Handle(GetTCPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetTCPRequestRuleBackend creates a new http.Handler for the get TCP request rule backend operation +func NewGetTCPRequestRuleBackend(ctx *middleware.Context, handler GetTCPRequestRuleBackendHandler) *GetTCPRequestRuleBackend { + return &GetTCPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetTCPRequestRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index} TCPRequestRule getTcpRequestRuleBackend + +# Return one TCP Request Rule + +Returns one TCP Request Rule configuration by it's index in the specified parent. +*/ +type GetTCPRequestRuleBackend struct { + Context *middleware.Context + Handler GetTCPRequestRuleBackendHandler +} + +func (o *GetTCPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTCPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_backend_parameters.go b/operations/tcp_request_rule/get_tcp_request_rule_backend_parameters.go new file mode 100644 index 00000000..7eef7832 --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTCPRequestRuleBackendParams creates a new GetTCPRequestRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetTCPRequestRuleBackendParams() GetTCPRequestRuleBackendParams { + + return GetTCPRequestRuleBackendParams{} +} + +// GetTCPRequestRuleBackendParams contains all the bound params for the get TCP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTCPRequestRuleBackend +type GetTCPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTCPRequestRuleBackendParams() beforehand. +func (o *GetTCPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetTCPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTCPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTCPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_backend_responses.go b/operations/tcp_request_rule/get_tcp_request_rule_backend_responses.go new file mode 100644 index 00000000..f2f5640e --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTCPRequestRuleBackendOKCode is the HTTP code returned for type GetTCPRequestRuleBackendOK +const GetTCPRequestRuleBackendOKCode int = 200 + +/* +GetTCPRequestRuleBackendOK Successful operation + +swagger:response getTcpRequestRuleBackendOK +*/ +type GetTCPRequestRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleBackendOK creates GetTCPRequestRuleBackendOK with default headers values +func NewGetTCPRequestRuleBackendOK() *GetTCPRequestRuleBackendOK { + + return &GetTCPRequestRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule backend o k response +func (o *GetTCPRequestRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule backend o k response +func (o *GetTCPRequestRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp request rule backend o k response +func (o *GetTCPRequestRuleBackendOK) WithPayload(payload *models.TCPRequestRule) *GetTCPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp request rule backend o k response +func (o *GetTCPRequestRuleBackendOK) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTCPRequestRuleBackendNotFoundCode is the HTTP code returned for type GetTCPRequestRuleBackendNotFound +const GetTCPRequestRuleBackendNotFoundCode int = 404 + +/* +GetTCPRequestRuleBackendNotFound The specified resource was not found + +swagger:response getTcpRequestRuleBackendNotFound +*/ +type GetTCPRequestRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleBackendNotFound creates GetTCPRequestRuleBackendNotFound with default headers values +func NewGetTCPRequestRuleBackendNotFound() *GetTCPRequestRuleBackendNotFound { + + return &GetTCPRequestRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule backend not found response +func (o *GetTCPRequestRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule backend not found response +func (o *GetTCPRequestRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp request rule backend not found response +func (o *GetTCPRequestRuleBackendNotFound) WithPayload(payload *models.Error) *GetTCPRequestRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp request rule backend not found response +func (o *GetTCPRequestRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTCPRequestRuleBackendDefault General Error + +swagger:response getTcpRequestRuleBackendDefault +*/ +type GetTCPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleBackendDefault creates GetTCPRequestRuleBackendDefault with default headers values +func NewGetTCPRequestRuleBackendDefault(code int) *GetTCPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetTCPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get TCP request rule backend default response +func (o *GetTCPRequestRuleBackendDefault) WithStatusCode(code int) *GetTCPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get TCP request rule backend default response +func (o *GetTCPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get TCP request rule backend default response +func (o *GetTCPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get TCP request rule backend default response +func (o *GetTCPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get TCP request rule backend default response +func (o *GetTCPRequestRuleBackendDefault) WithPayload(payload *models.Error) *GetTCPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get TCP request rule backend default response +func (o *GetTCPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_backend_urlbuilder.go b/operations/tcp_request_rule/get_tcp_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..b6c7026b --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetTCPRequestRuleBackendURL generates an URL for the get TCP request rule backend operation +type GetTCPRequestRuleBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPRequestRuleBackendURL) WithBasePath(bp string) *GetTCPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTCPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetTCPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTCPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTCPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTCPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTCPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTCPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTCPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTCPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_defaults.go b/operations/tcp_request_rule/get_tcp_request_rule_defaults.go new file mode 100644 index 00000000..0d557a7f --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTCPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a get TCP request rule defaults handler +type GetTCPRequestRuleDefaultsHandlerFunc func(GetTCPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTCPRequestRuleDefaultsHandlerFunc) Handle(params GetTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTCPRequestRuleDefaultsHandler interface for that can handle valid get TCP request rule defaults params +type GetTCPRequestRuleDefaultsHandler interface { + Handle(GetTCPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetTCPRequestRuleDefaults creates a new http.Handler for the get TCP request rule defaults operation +func NewGetTCPRequestRuleDefaults(ctx *middleware.Context, handler GetTCPRequestRuleDefaultsHandler) *GetTCPRequestRuleDefaults { + return &GetTCPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetTCPRequestRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index} TCPRequestRule getTcpRequestRuleDefaults + +# Return one TCP Request Rule + +Returns one TCP Request Rule configuration by it's index in the specified parent. +*/ +type GetTCPRequestRuleDefaults struct { + Context *middleware.Context + Handler GetTCPRequestRuleDefaultsHandler +} + +func (o *GetTCPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTCPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_defaults_parameters.go b/operations/tcp_request_rule/get_tcp_request_rule_defaults_parameters.go new file mode 100644 index 00000000..181d7b1f --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTCPRequestRuleDefaultsParams creates a new GetTCPRequestRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetTCPRequestRuleDefaultsParams() GetTCPRequestRuleDefaultsParams { + + return GetTCPRequestRuleDefaultsParams{} +} + +// GetTCPRequestRuleDefaultsParams contains all the bound params for the get TCP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTCPRequestRuleDefaults +type GetTCPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTCPRequestRuleDefaultsParams() beforehand. +func (o *GetTCPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetTCPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTCPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTCPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_defaults_responses.go b/operations/tcp_request_rule/get_tcp_request_rule_defaults_responses.go new file mode 100644 index 00000000..ad0957f5 --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTCPRequestRuleDefaultsOKCode is the HTTP code returned for type GetTCPRequestRuleDefaultsOK +const GetTCPRequestRuleDefaultsOKCode int = 200 + +/* +GetTCPRequestRuleDefaultsOK Successful operation + +swagger:response getTcpRequestRuleDefaultsOK +*/ +type GetTCPRequestRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleDefaultsOK creates GetTCPRequestRuleDefaultsOK with default headers values +func NewGetTCPRequestRuleDefaultsOK() *GetTCPRequestRuleDefaultsOK { + + return &GetTCPRequestRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule defaults o k response +func (o *GetTCPRequestRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule defaults o k response +func (o *GetTCPRequestRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp request rule defaults o k response +func (o *GetTCPRequestRuleDefaultsOK) WithPayload(payload *models.TCPRequestRule) *GetTCPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp request rule defaults o k response +func (o *GetTCPRequestRuleDefaultsOK) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTCPRequestRuleDefaultsNotFoundCode is the HTTP code returned for type GetTCPRequestRuleDefaultsNotFound +const GetTCPRequestRuleDefaultsNotFoundCode int = 404 + +/* +GetTCPRequestRuleDefaultsNotFound The specified resource was not found + +swagger:response getTcpRequestRuleDefaultsNotFound +*/ +type GetTCPRequestRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleDefaultsNotFound creates GetTCPRequestRuleDefaultsNotFound with default headers values +func NewGetTCPRequestRuleDefaultsNotFound() *GetTCPRequestRuleDefaultsNotFound { + + return &GetTCPRequestRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule defaults not found response +func (o *GetTCPRequestRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule defaults not found response +func (o *GetTCPRequestRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp request rule defaults not found response +func (o *GetTCPRequestRuleDefaultsNotFound) WithPayload(payload *models.Error) *GetTCPRequestRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp request rule defaults not found response +func (o *GetTCPRequestRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTCPRequestRuleDefaultsDefault General Error + +swagger:response getTcpRequestRuleDefaultsDefault +*/ +type GetTCPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleDefaultsDefault creates GetTCPRequestRuleDefaultsDefault with default headers values +func NewGetTCPRequestRuleDefaultsDefault(code int) *GetTCPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetTCPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get TCP request rule defaults default response +func (o *GetTCPRequestRuleDefaultsDefault) WithStatusCode(code int) *GetTCPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get TCP request rule defaults default response +func (o *GetTCPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get TCP request rule defaults default response +func (o *GetTCPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get TCP request rule defaults default response +func (o *GetTCPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get TCP request rule defaults default response +func (o *GetTCPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *GetTCPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get TCP request rule defaults default response +func (o *GetTCPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_defaults_urlbuilder.go b/operations/tcp_request_rule/get_tcp_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..5e4bfc6e --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetTCPRequestRuleDefaultsURL generates an URL for the get TCP request rule defaults operation +type GetTCPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPRequestRuleDefaultsURL) WithBasePath(bp string) *GetTCPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTCPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetTCPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTCPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTCPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTCPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTCPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTCPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTCPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTCPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_frontend.go b/operations/tcp_request_rule/get_tcp_request_rule_frontend.go new file mode 100644 index 00000000..931e805d --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTCPRequestRuleFrontendHandlerFunc turns a function with the right signature into a get TCP request rule frontend handler +type GetTCPRequestRuleFrontendHandlerFunc func(GetTCPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTCPRequestRuleFrontendHandlerFunc) Handle(params GetTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTCPRequestRuleFrontendHandler interface for that can handle valid get TCP request rule frontend params +type GetTCPRequestRuleFrontendHandler interface { + Handle(GetTCPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewGetTCPRequestRuleFrontend creates a new http.Handler for the get TCP request rule frontend operation +func NewGetTCPRequestRuleFrontend(ctx *middleware.Context, handler GetTCPRequestRuleFrontendHandler) *GetTCPRequestRuleFrontend { + return &GetTCPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + GetTCPRequestRuleFrontend swagger:route GET /services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index} TCPRequestRule getTcpRequestRuleFrontend + +# Return one TCP Request Rule + +Returns one TCP Request Rule configuration by it's index in the specified parent. +*/ +type GetTCPRequestRuleFrontend struct { + Context *middleware.Context + Handler GetTCPRequestRuleFrontendHandler +} + +func (o *GetTCPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTCPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_frontend_parameters.go b/operations/tcp_request_rule/get_tcp_request_rule_frontend_parameters.go new file mode 100644 index 00000000..96e8b0f6 --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_frontend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTCPRequestRuleFrontendParams creates a new GetTCPRequestRuleFrontendParams object +// +// There are no default values defined in the spec. +func NewGetTCPRequestRuleFrontendParams() GetTCPRequestRuleFrontendParams { + + return GetTCPRequestRuleFrontendParams{} +} + +// GetTCPRequestRuleFrontendParams contains all the bound params for the get TCP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTCPRequestRuleFrontend +type GetTCPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTCPRequestRuleFrontendParams() beforehand. +func (o *GetTCPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetTCPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTCPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTCPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_frontend_responses.go b/operations/tcp_request_rule/get_tcp_request_rule_frontend_responses.go new file mode 100644 index 00000000..74207aee --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_frontend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTCPRequestRuleFrontendOKCode is the HTTP code returned for type GetTCPRequestRuleFrontendOK +const GetTCPRequestRuleFrontendOKCode int = 200 + +/* +GetTCPRequestRuleFrontendOK Successful operation + +swagger:response getTcpRequestRuleFrontendOK +*/ +type GetTCPRequestRuleFrontendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleFrontendOK creates GetTCPRequestRuleFrontendOK with default headers values +func NewGetTCPRequestRuleFrontendOK() *GetTCPRequestRuleFrontendOK { + + return &GetTCPRequestRuleFrontendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule frontend o k response +func (o *GetTCPRequestRuleFrontendOK) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleFrontendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule frontend o k response +func (o *GetTCPRequestRuleFrontendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp request rule frontend o k response +func (o *GetTCPRequestRuleFrontendOK) WithPayload(payload *models.TCPRequestRule) *GetTCPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp request rule frontend o k response +func (o *GetTCPRequestRuleFrontendOK) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTCPRequestRuleFrontendNotFoundCode is the HTTP code returned for type GetTCPRequestRuleFrontendNotFound +const GetTCPRequestRuleFrontendNotFoundCode int = 404 + +/* +GetTCPRequestRuleFrontendNotFound The specified resource was not found + +swagger:response getTcpRequestRuleFrontendNotFound +*/ +type GetTCPRequestRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleFrontendNotFound creates GetTCPRequestRuleFrontendNotFound with default headers values +func NewGetTCPRequestRuleFrontendNotFound() *GetTCPRequestRuleFrontendNotFound { + + return &GetTCPRequestRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule frontend not found response +func (o *GetTCPRequestRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule frontend not found response +func (o *GetTCPRequestRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp request rule frontend not found response +func (o *GetTCPRequestRuleFrontendNotFound) WithPayload(payload *models.Error) *GetTCPRequestRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp request rule frontend not found response +func (o *GetTCPRequestRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTCPRequestRuleFrontendDefault General Error + +swagger:response getTcpRequestRuleFrontendDefault +*/ +type GetTCPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPRequestRuleFrontendDefault creates GetTCPRequestRuleFrontendDefault with default headers values +func NewGetTCPRequestRuleFrontendDefault(code int) *GetTCPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &GetTCPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get TCP request rule frontend default response +func (o *GetTCPRequestRuleFrontendDefault) WithStatusCode(code int) *GetTCPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get TCP request rule frontend default response +func (o *GetTCPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get TCP request rule frontend default response +func (o *GetTCPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *GetTCPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get TCP request rule frontend default response +func (o *GetTCPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get TCP request rule frontend default response +func (o *GetTCPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *GetTCPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get TCP request rule frontend default response +func (o *GetTCPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_frontend_urlbuilder.go b/operations/tcp_request_rule/get_tcp_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..2118c125 --- /dev/null +++ b/operations/tcp_request_rule/get_tcp_request_rule_frontend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetTCPRequestRuleFrontendURL generates an URL for the get TCP request rule frontend operation +type GetTCPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPRequestRuleFrontendURL) WithBasePath(bp string) *GetTCPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTCPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetTCPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTCPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTCPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTCPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTCPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTCPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTCPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTCPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_parameters.go b/operations/tcp_request_rule/get_tcp_request_rule_parameters.go deleted file mode 100644 index e0e99c4a..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rule_parameters.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetTCPRequestRuleParams creates a new GetTCPRequestRuleParams object -// no default values defined in spec. -func NewGetTCPRequestRuleParams() GetTCPRequestRuleParams { - - return GetTCPRequestRuleParams{} -} - -// GetTCPRequestRuleParams contains all the bound params for the get TCP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters getTCPRequestRule -type GetTCPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*TCP Request Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetTCPRequestRuleParams() beforehand. -func (o *GetTCPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *GetTCPRequestRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetTCPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetTCPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetTCPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetTCPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_responses.go b/operations/tcp_request_rule/get_tcp_request_rule_responses.go deleted file mode 100644 index 2bcc9306..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rule_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetTCPRequestRuleOKCode is the HTTP code returned for type GetTCPRequestRuleOK -const GetTCPRequestRuleOKCode int = 200 - -/*GetTCPRequestRuleOK Successful operation - -swagger:response getTcpRequestRuleOK -*/ -type GetTCPRequestRuleOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetTCPRequestRuleOKBody `json:"body,omitempty"` -} - -// NewGetTCPRequestRuleOK creates GetTCPRequestRuleOK with default headers values -func NewGetTCPRequestRuleOK() *GetTCPRequestRuleOK { - - return &GetTCPRequestRuleOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule o k response -func (o *GetTCPRequestRuleOK) WithConfigurationVersion(configurationVersion int64) *GetTCPRequestRuleOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule o k response -func (o *GetTCPRequestRuleOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Tcp request rule o k response -func (o *GetTCPRequestRuleOK) WithPayload(payload *GetTCPRequestRuleOKBody) *GetTCPRequestRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Tcp request rule o k response -func (o *GetTCPRequestRuleOK) SetPayload(payload *GetTCPRequestRuleOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPRequestRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetTCPRequestRuleNotFoundCode is the HTTP code returned for type GetTCPRequestRuleNotFound -const GetTCPRequestRuleNotFoundCode int = 404 - -/*GetTCPRequestRuleNotFound The specified resource was not found - -swagger:response getTcpRequestRuleNotFound -*/ -type GetTCPRequestRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetTCPRequestRuleNotFound creates GetTCPRequestRuleNotFound with default headers values -func NewGetTCPRequestRuleNotFound() *GetTCPRequestRuleNotFound { - - return &GetTCPRequestRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Tcp request rule not found response -func (o *GetTCPRequestRuleNotFound) WithConfigurationVersion(configurationVersion int64) *GetTCPRequestRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Tcp request rule not found response -func (o *GetTCPRequestRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Tcp request rule not found response -func (o *GetTCPRequestRuleNotFound) WithPayload(payload *models.Error) *GetTCPRequestRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Tcp request rule not found response -func (o *GetTCPRequestRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPRequestRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetTCPRequestRuleDefault General Error - -swagger:response getTcpRequestRuleDefault -*/ -type GetTCPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetTCPRequestRuleDefault creates GetTCPRequestRuleDefault with default headers values -func NewGetTCPRequestRuleDefault(code int) *GetTCPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &GetTCPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get TCP request rule default response -func (o *GetTCPRequestRuleDefault) WithStatusCode(code int) *GetTCPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get TCP request rule default response -func (o *GetTCPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get TCP request rule default response -func (o *GetTCPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *GetTCPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get TCP request rule default response -func (o *GetTCPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get TCP request rule default response -func (o *GetTCPRequestRuleDefault) WithPayload(payload *models.Error) *GetTCPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get TCP request rule default response -func (o *GetTCPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_request_rule/get_tcp_request_rule_urlbuilder.go b/operations/tcp_request_rule/get_tcp_request_rule_urlbuilder.go deleted file mode 100644 index e79d2be5..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rule_urlbuilder.go +++ /dev/null @@ -1,142 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// GetTCPRequestRuleURL generates an URL for the get TCP request rule operation -type GetTCPRequestRuleURL struct { - ID int64 - - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPRequestRuleURL) WithBasePath(bp string) *GetTCPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetTCPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_request_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on GetTCPRequestRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetTCPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetTCPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetTCPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetTCPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetTCPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetTCPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_request_rule/get_tcp_request_rules.go b/operations/tcp_request_rule/get_tcp_request_rules.go deleted file mode 100644 index a2a285a4..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rules.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetTCPRequestRulesHandlerFunc turns a function with the right signature into a get TCP request rules handler -type GetTCPRequestRulesHandlerFunc func(GetTCPRequestRulesParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetTCPRequestRulesHandlerFunc) Handle(params GetTCPRequestRulesParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetTCPRequestRulesHandler interface for that can handle valid get TCP request rules params -type GetTCPRequestRulesHandler interface { - Handle(GetTCPRequestRulesParams, interface{}) middleware.Responder -} - -// NewGetTCPRequestRules creates a new http.Handler for the get TCP request rules operation -func NewGetTCPRequestRules(ctx *middleware.Context, handler GetTCPRequestRulesHandler) *GetTCPRequestRules { - return &GetTCPRequestRules{Context: ctx, Handler: handler} -} - -/*GetTCPRequestRules swagger:route GET /services/haproxy/configuration/tcp_request_rules TCPRequestRule getTcpRequestRules - -Return an array of all TCP Request Rules - -Returns all TCP Request Rules that are configured in specified parent and parent type. - -*/ -type GetTCPRequestRules struct { - Context *middleware.Context - Handler GetTCPRequestRulesHandler -} - -func (o *GetTCPRequestRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetTCPRequestRulesParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetTCPRequestRulesOKBody get TCP request rules o k body -// swagger:model GetTCPRequestRulesOKBody -type GetTCPRequestRulesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.TCPRequestRules `json:"data"` -} - -// Validate validates this get TCP request rules o k body -func (o *GetTCPRequestRulesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetTCPRequestRulesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getTcpRequestRulesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getTcpRequestRulesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetTCPRequestRulesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetTCPRequestRulesOKBody) UnmarshalBinary(b []byte) error { - var res GetTCPRequestRulesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/tcp_request_rule/get_tcp_request_rules_parameters.go b/operations/tcp_request_rule/get_tcp_request_rules_parameters.go deleted file mode 100644 index 4c64293c..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rules_parameters.go +++ /dev/null @@ -1,170 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetTCPRequestRulesParams creates a new GetTCPRequestRulesParams object -// no default values defined in spec. -func NewGetTCPRequestRulesParams() GetTCPRequestRulesParams { - - return GetTCPRequestRulesParams{} -} - -// GetTCPRequestRulesParams contains all the bound params for the get TCP request rules operation -// typically these are obtained from a http.Request -// -// swagger:parameters getTCPRequestRules -type GetTCPRequestRulesParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetTCPRequestRulesParams() beforehand. -func (o *GetTCPRequestRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *GetTCPRequestRulesParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *GetTCPRequestRulesParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *GetTCPRequestRulesParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetTCPRequestRulesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/tcp_request_rule/get_tcp_request_rules_responses.go b/operations/tcp_request_rule/get_tcp_request_rules_responses.go deleted file mode 100644 index 3ff59e15..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rules_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetTCPRequestRulesOKCode is the HTTP code returned for type GetTCPRequestRulesOK -const GetTCPRequestRulesOKCode int = 200 - -/*GetTCPRequestRulesOK Successful operation - -swagger:response getTcpRequestRulesOK -*/ -type GetTCPRequestRulesOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetTCPRequestRulesOKBody `json:"body,omitempty"` -} - -// NewGetTCPRequestRulesOK creates GetTCPRequestRulesOK with default headers values -func NewGetTCPRequestRulesOK() *GetTCPRequestRulesOK { - - return &GetTCPRequestRulesOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Tcp request rules o k response -func (o *GetTCPRequestRulesOK) WithConfigurationVersion(configurationVersion int64) *GetTCPRequestRulesOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Tcp request rules o k response -func (o *GetTCPRequestRulesOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Tcp request rules o k response -func (o *GetTCPRequestRulesOK) WithPayload(payload *GetTCPRequestRulesOKBody) *GetTCPRequestRulesOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Tcp request rules o k response -func (o *GetTCPRequestRulesOK) SetPayload(payload *GetTCPRequestRulesOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPRequestRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetTCPRequestRulesDefault General Error - -swagger:response getTcpRequestRulesDefault -*/ -type GetTCPRequestRulesDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetTCPRequestRulesDefault creates GetTCPRequestRulesDefault with default headers values -func NewGetTCPRequestRulesDefault(code int) *GetTCPRequestRulesDefault { - if code <= 0 { - code = 500 - } - - return &GetTCPRequestRulesDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get TCP request rules default response -func (o *GetTCPRequestRulesDefault) WithStatusCode(code int) *GetTCPRequestRulesDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get TCP request rules default response -func (o *GetTCPRequestRulesDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get TCP request rules default response -func (o *GetTCPRequestRulesDefault) WithConfigurationVersion(configurationVersion int64) *GetTCPRequestRulesDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get TCP request rules default response -func (o *GetTCPRequestRulesDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get TCP request rules default response -func (o *GetTCPRequestRulesDefault) WithPayload(payload *models.Error) *GetTCPRequestRulesDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get TCP request rules default response -func (o *GetTCPRequestRulesDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPRequestRulesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_request_rule/get_tcp_request_rules_urlbuilder.go b/operations/tcp_request_rule/get_tcp_request_rules_urlbuilder.go deleted file mode 100644 index 9aadbab1..00000000 --- a/operations/tcp_request_rule/get_tcp_request_rules_urlbuilder.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetTCPRequestRulesURL generates an URL for the get TCP request rules operation -type GetTCPRequestRulesURL struct { - ParentName string - ParentType string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPRequestRulesURL) WithBasePath(bp string) *GetTCPRequestRulesURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPRequestRulesURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetTCPRequestRulesURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_request_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetTCPRequestRulesURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetTCPRequestRulesURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetTCPRequestRulesURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetTCPRequestRulesURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetTCPRequestRulesURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetTCPRequestRulesURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_backend.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend.go new file mode 100644 index 00000000..343ec95d --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllTCPRequestRuleBackendHandlerFunc turns a function with the right signature into a replace all TCP request rule backend handler +type ReplaceAllTCPRequestRuleBackendHandlerFunc func(ReplaceAllTCPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllTCPRequestRuleBackendHandlerFunc) Handle(params ReplaceAllTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllTCPRequestRuleBackendHandler interface for that can handle valid replace all TCP request rule backend params +type ReplaceAllTCPRequestRuleBackendHandler interface { + Handle(ReplaceAllTCPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllTCPRequestRuleBackend creates a new http.Handler for the replace all TCP request rule backend operation +func NewReplaceAllTCPRequestRuleBackend(ctx *middleware.Context, handler ReplaceAllTCPRequestRuleBackendHandler) *ReplaceAllTCPRequestRuleBackend { + return &ReplaceAllTCPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllTCPRequestRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/tcp_request_rules TCPRequestRule replaceAllTcpRequestRuleBackend + +# Replace an TCP Request Rule list + +Replaces a whole list of TCP Request Rules with the list given in parameter +*/ +type ReplaceAllTCPRequestRuleBackend struct { + Context *middleware.Context + Handler ReplaceAllTCPRequestRuleBackendHandler +} + +func (o *ReplaceAllTCPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllTCPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_parameters.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_parameters.go new file mode 100644 index 00000000..92bedea6 --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllTCPRequestRuleBackendParams creates a new ReplaceAllTCPRequestRuleBackendParams object +// with the default values initialized. +func NewReplaceAllTCPRequestRuleBackendParams() ReplaceAllTCPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllTCPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllTCPRequestRuleBackendParams contains all the bound params for the replace all TCP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllTCPRequestRuleBackend +type ReplaceAllTCPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.TCPRequestRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllTCPRequestRuleBackendParams() beforehand. +func (o *ReplaceAllTCPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllTCPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllTCPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllTCPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllTCPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllTCPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_responses.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_responses.go new file mode 100644 index 00000000..0a8d5b96 --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllTCPRequestRuleBackendOKCode is the HTTP code returned for type ReplaceAllTCPRequestRuleBackendOK +const ReplaceAllTCPRequestRuleBackendOKCode int = 200 + +/* +ReplaceAllTCPRequestRuleBackendOK All TCP Request Rule lines replaced + +swagger:response replaceAllTcpRequestRuleBackendOK +*/ +type ReplaceAllTCPRequestRuleBackendOK struct { + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleBackendOK creates ReplaceAllTCPRequestRuleBackendOK with default headers values +func NewReplaceAllTCPRequestRuleBackendOK() *ReplaceAllTCPRequestRuleBackendOK { + + return &ReplaceAllTCPRequestRuleBackendOK{} +} + +// WithPayload adds the payload to the replace all Tcp request rule backend o k response +func (o *ReplaceAllTCPRequestRuleBackendOK) WithPayload(payload models.TCPRequestRules) *ReplaceAllTCPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule backend o k response +func (o *ReplaceAllTCPRequestRuleBackendOK) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPRequestRuleBackendAcceptedCode is the HTTP code returned for type ReplaceAllTCPRequestRuleBackendAccepted +const ReplaceAllTCPRequestRuleBackendAcceptedCode int = 202 + +/* +ReplaceAllTCPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllTcpRequestRuleBackendAccepted +*/ +type ReplaceAllTCPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleBackendAccepted creates ReplaceAllTCPRequestRuleBackendAccepted with default headers values +func NewReplaceAllTCPRequestRuleBackendAccepted() *ReplaceAllTCPRequestRuleBackendAccepted { + + return &ReplaceAllTCPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Tcp request rule backend accepted response +func (o *ReplaceAllTCPRequestRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceAllTCPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Tcp request rule backend accepted response +func (o *ReplaceAllTCPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Tcp request rule backend accepted response +func (o *ReplaceAllTCPRequestRuleBackendAccepted) WithPayload(payload models.TCPRequestRules) *ReplaceAllTCPRequestRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule backend accepted response +func (o *ReplaceAllTCPRequestRuleBackendAccepted) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPRequestRuleBackendBadRequestCode is the HTTP code returned for type ReplaceAllTCPRequestRuleBackendBadRequest +const ReplaceAllTCPRequestRuleBackendBadRequestCode int = 400 + +/* +ReplaceAllTCPRequestRuleBackendBadRequest Bad request + +swagger:response replaceAllTcpRequestRuleBackendBadRequest +*/ +type ReplaceAllTCPRequestRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleBackendBadRequest creates ReplaceAllTCPRequestRuleBackendBadRequest with default headers values +func NewReplaceAllTCPRequestRuleBackendBadRequest() *ReplaceAllTCPRequestRuleBackendBadRequest { + + return &ReplaceAllTCPRequestRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Tcp request rule backend bad request response +func (o *ReplaceAllTCPRequestRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPRequestRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Tcp request rule backend bad request response +func (o *ReplaceAllTCPRequestRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Tcp request rule backend bad request response +func (o *ReplaceAllTCPRequestRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllTCPRequestRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule backend bad request response +func (o *ReplaceAllTCPRequestRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllTCPRequestRuleBackendDefault General Error + +swagger:response replaceAllTcpRequestRuleBackendDefault +*/ +type ReplaceAllTCPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleBackendDefault creates ReplaceAllTCPRequestRuleBackendDefault with default headers values +func NewReplaceAllTCPRequestRuleBackendDefault(code int) *ReplaceAllTCPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllTCPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all TCP request rule backend default response +func (o *ReplaceAllTCPRequestRuleBackendDefault) WithStatusCode(code int) *ReplaceAllTCPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all TCP request rule backend default response +func (o *ReplaceAllTCPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all TCP request rule backend default response +func (o *ReplaceAllTCPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all TCP request rule backend default response +func (o *ReplaceAllTCPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all TCP request rule backend default response +func (o *ReplaceAllTCPRequestRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceAllTCPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all TCP request rule backend default response +func (o *ReplaceAllTCPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_urlbuilder.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..91d9636f --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllTCPRequestRuleBackendURL generates an URL for the replace all TCP request rule backend operation +type ReplaceAllTCPRequestRuleBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPRequestRuleBackendURL) WithBasePath(bp string) *ReplaceAllTCPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllTCPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllTCPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllTCPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllTCPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllTCPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllTCPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllTCPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllTCPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults.go new file mode 100644 index 00000000..dbc65bc6 --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllTCPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a replace all TCP request rule defaults handler +type ReplaceAllTCPRequestRuleDefaultsHandlerFunc func(ReplaceAllTCPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllTCPRequestRuleDefaultsHandlerFunc) Handle(params ReplaceAllTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllTCPRequestRuleDefaultsHandler interface for that can handle valid replace all TCP request rule defaults params +type ReplaceAllTCPRequestRuleDefaultsHandler interface { + Handle(ReplaceAllTCPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllTCPRequestRuleDefaults creates a new http.Handler for the replace all TCP request rule defaults operation +func NewReplaceAllTCPRequestRuleDefaults(ctx *middleware.Context, handler ReplaceAllTCPRequestRuleDefaultsHandler) *ReplaceAllTCPRequestRuleDefaults { + return &ReplaceAllTCPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllTCPRequestRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules TCPRequestRule replaceAllTcpRequestRuleDefaults + +# Replace an TCP Request Rule list + +Replaces a whole list of TCP Request Rules with the list given in parameter +*/ +type ReplaceAllTCPRequestRuleDefaults struct { + Context *middleware.Context + Handler ReplaceAllTCPRequestRuleDefaultsHandler +} + +func (o *ReplaceAllTCPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllTCPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_parameters.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_parameters.go new file mode 100644 index 00000000..4795742a --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllTCPRequestRuleDefaultsParams creates a new ReplaceAllTCPRequestRuleDefaultsParams object +// with the default values initialized. +func NewReplaceAllTCPRequestRuleDefaultsParams() ReplaceAllTCPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllTCPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllTCPRequestRuleDefaultsParams contains all the bound params for the replace all TCP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllTCPRequestRuleDefaults +type ReplaceAllTCPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.TCPRequestRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllTCPRequestRuleDefaultsParams() beforehand. +func (o *ReplaceAllTCPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllTCPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllTCPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllTCPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllTCPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllTCPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_responses.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_responses.go new file mode 100644 index 00000000..063a6d0c --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllTCPRequestRuleDefaultsOKCode is the HTTP code returned for type ReplaceAllTCPRequestRuleDefaultsOK +const ReplaceAllTCPRequestRuleDefaultsOKCode int = 200 + +/* +ReplaceAllTCPRequestRuleDefaultsOK All TCP Request Rule lines replaced + +swagger:response replaceAllTcpRequestRuleDefaultsOK +*/ +type ReplaceAllTCPRequestRuleDefaultsOK struct { + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleDefaultsOK creates ReplaceAllTCPRequestRuleDefaultsOK with default headers values +func NewReplaceAllTCPRequestRuleDefaultsOK() *ReplaceAllTCPRequestRuleDefaultsOK { + + return &ReplaceAllTCPRequestRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Tcp request rule defaults o k response +func (o *ReplaceAllTCPRequestRuleDefaultsOK) WithPayload(payload models.TCPRequestRules) *ReplaceAllTCPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule defaults o k response +func (o *ReplaceAllTCPRequestRuleDefaultsOK) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllTCPRequestRuleDefaultsAccepted +const ReplaceAllTCPRequestRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceAllTCPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllTcpRequestRuleDefaultsAccepted +*/ +type ReplaceAllTCPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleDefaultsAccepted creates ReplaceAllTCPRequestRuleDefaultsAccepted with default headers values +func NewReplaceAllTCPRequestRuleDefaultsAccepted() *ReplaceAllTCPRequestRuleDefaultsAccepted { + + return &ReplaceAllTCPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Tcp request rule defaults accepted response +func (o *ReplaceAllTCPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllTCPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Tcp request rule defaults accepted response +func (o *ReplaceAllTCPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Tcp request rule defaults accepted response +func (o *ReplaceAllTCPRequestRuleDefaultsAccepted) WithPayload(payload models.TCPRequestRules) *ReplaceAllTCPRequestRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule defaults accepted response +func (o *ReplaceAllTCPRequestRuleDefaultsAccepted) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPRequestRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllTCPRequestRuleDefaultsBadRequest +const ReplaceAllTCPRequestRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceAllTCPRequestRuleDefaultsBadRequest Bad request + +swagger:response replaceAllTcpRequestRuleDefaultsBadRequest +*/ +type ReplaceAllTCPRequestRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleDefaultsBadRequest creates ReplaceAllTCPRequestRuleDefaultsBadRequest with default headers values +func NewReplaceAllTCPRequestRuleDefaultsBadRequest() *ReplaceAllTCPRequestRuleDefaultsBadRequest { + + return &ReplaceAllTCPRequestRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Tcp request rule defaults bad request response +func (o *ReplaceAllTCPRequestRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPRequestRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Tcp request rule defaults bad request response +func (o *ReplaceAllTCPRequestRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Tcp request rule defaults bad request response +func (o *ReplaceAllTCPRequestRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllTCPRequestRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule defaults bad request response +func (o *ReplaceAllTCPRequestRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllTCPRequestRuleDefaultsDefault General Error + +swagger:response replaceAllTcpRequestRuleDefaultsDefault +*/ +type ReplaceAllTCPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleDefaultsDefault creates ReplaceAllTCPRequestRuleDefaultsDefault with default headers values +func NewReplaceAllTCPRequestRuleDefaultsDefault(code int) *ReplaceAllTCPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllTCPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all TCP request rule defaults default response +func (o *ReplaceAllTCPRequestRuleDefaultsDefault) WithStatusCode(code int) *ReplaceAllTCPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all TCP request rule defaults default response +func (o *ReplaceAllTCPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all TCP request rule defaults default response +func (o *ReplaceAllTCPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all TCP request rule defaults default response +func (o *ReplaceAllTCPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all TCP request rule defaults default response +func (o *ReplaceAllTCPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllTCPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all TCP request rule defaults default response +func (o *ReplaceAllTCPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_urlbuilder.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..f256d669 --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllTCPRequestRuleDefaultsURL generates an URL for the replace all TCP request rule defaults operation +type ReplaceAllTCPRequestRuleDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPRequestRuleDefaultsURL) WithBasePath(bp string) *ReplaceAllTCPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllTCPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllTCPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllTCPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllTCPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllTCPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllTCPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllTCPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllTCPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend.go new file mode 100644 index 00000000..d66efba9 --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllTCPRequestRuleFrontendHandlerFunc turns a function with the right signature into a replace all TCP request rule frontend handler +type ReplaceAllTCPRequestRuleFrontendHandlerFunc func(ReplaceAllTCPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllTCPRequestRuleFrontendHandlerFunc) Handle(params ReplaceAllTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllTCPRequestRuleFrontendHandler interface for that can handle valid replace all TCP request rule frontend params +type ReplaceAllTCPRequestRuleFrontendHandler interface { + Handle(ReplaceAllTCPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceAllTCPRequestRuleFrontend creates a new http.Handler for the replace all TCP request rule frontend operation +func NewReplaceAllTCPRequestRuleFrontend(ctx *middleware.Context, handler ReplaceAllTCPRequestRuleFrontendHandler) *ReplaceAllTCPRequestRuleFrontend { + return &ReplaceAllTCPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllTCPRequestRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules TCPRequestRule replaceAllTcpRequestRuleFrontend + +# Replace an TCP Request Rule list + +Replaces a whole list of TCP Request Rules with the list given in parameter +*/ +type ReplaceAllTCPRequestRuleFrontend struct { + Context *middleware.Context + Handler ReplaceAllTCPRequestRuleFrontendHandler +} + +func (o *ReplaceAllTCPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllTCPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_parameters.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_parameters.go new file mode 100644 index 00000000..3d386463 --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllTCPRequestRuleFrontendParams creates a new ReplaceAllTCPRequestRuleFrontendParams object +// with the default values initialized. +func NewReplaceAllTCPRequestRuleFrontendParams() ReplaceAllTCPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllTCPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllTCPRequestRuleFrontendParams contains all the bound params for the replace all TCP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllTCPRequestRuleFrontend +type ReplaceAllTCPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.TCPRequestRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllTCPRequestRuleFrontendParams() beforehand. +func (o *ReplaceAllTCPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllTCPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllTCPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllTCPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllTCPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllTCPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_responses.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_responses.go new file mode 100644 index 00000000..d384691a --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllTCPRequestRuleFrontendOKCode is the HTTP code returned for type ReplaceAllTCPRequestRuleFrontendOK +const ReplaceAllTCPRequestRuleFrontendOKCode int = 200 + +/* +ReplaceAllTCPRequestRuleFrontendOK All TCP Request Rule lines replaced + +swagger:response replaceAllTcpRequestRuleFrontendOK +*/ +type ReplaceAllTCPRequestRuleFrontendOK struct { + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleFrontendOK creates ReplaceAllTCPRequestRuleFrontendOK with default headers values +func NewReplaceAllTCPRequestRuleFrontendOK() *ReplaceAllTCPRequestRuleFrontendOK { + + return &ReplaceAllTCPRequestRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace all Tcp request rule frontend o k response +func (o *ReplaceAllTCPRequestRuleFrontendOK) WithPayload(payload models.TCPRequestRules) *ReplaceAllTCPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule frontend o k response +func (o *ReplaceAllTCPRequestRuleFrontendOK) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPRequestRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceAllTCPRequestRuleFrontendAccepted +const ReplaceAllTCPRequestRuleFrontendAcceptedCode int = 202 + +/* +ReplaceAllTCPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllTcpRequestRuleFrontendAccepted +*/ +type ReplaceAllTCPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.TCPRequestRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleFrontendAccepted creates ReplaceAllTCPRequestRuleFrontendAccepted with default headers values +func NewReplaceAllTCPRequestRuleFrontendAccepted() *ReplaceAllTCPRequestRuleFrontendAccepted { + + return &ReplaceAllTCPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Tcp request rule frontend accepted response +func (o *ReplaceAllTCPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceAllTCPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Tcp request rule frontend accepted response +func (o *ReplaceAllTCPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Tcp request rule frontend accepted response +func (o *ReplaceAllTCPRequestRuleFrontendAccepted) WithPayload(payload models.TCPRequestRules) *ReplaceAllTCPRequestRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule frontend accepted response +func (o *ReplaceAllTCPRequestRuleFrontendAccepted) SetPayload(payload models.TCPRequestRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPRequestRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPRequestRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceAllTCPRequestRuleFrontendBadRequest +const ReplaceAllTCPRequestRuleFrontendBadRequestCode int = 400 + +/* +ReplaceAllTCPRequestRuleFrontendBadRequest Bad request + +swagger:response replaceAllTcpRequestRuleFrontendBadRequest +*/ +type ReplaceAllTCPRequestRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleFrontendBadRequest creates ReplaceAllTCPRequestRuleFrontendBadRequest with default headers values +func NewReplaceAllTCPRequestRuleFrontendBadRequest() *ReplaceAllTCPRequestRuleFrontendBadRequest { + + return &ReplaceAllTCPRequestRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Tcp request rule frontend bad request response +func (o *ReplaceAllTCPRequestRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPRequestRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Tcp request rule frontend bad request response +func (o *ReplaceAllTCPRequestRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Tcp request rule frontend bad request response +func (o *ReplaceAllTCPRequestRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceAllTCPRequestRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp request rule frontend bad request response +func (o *ReplaceAllTCPRequestRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllTCPRequestRuleFrontendDefault General Error + +swagger:response replaceAllTcpRequestRuleFrontendDefault +*/ +type ReplaceAllTCPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPRequestRuleFrontendDefault creates ReplaceAllTCPRequestRuleFrontendDefault with default headers values +func NewReplaceAllTCPRequestRuleFrontendDefault(code int) *ReplaceAllTCPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllTCPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all TCP request rule frontend default response +func (o *ReplaceAllTCPRequestRuleFrontendDefault) WithStatusCode(code int) *ReplaceAllTCPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all TCP request rule frontend default response +func (o *ReplaceAllTCPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all TCP request rule frontend default response +func (o *ReplaceAllTCPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all TCP request rule frontend default response +func (o *ReplaceAllTCPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all TCP request rule frontend default response +func (o *ReplaceAllTCPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceAllTCPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all TCP request rule frontend default response +func (o *ReplaceAllTCPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_urlbuilder.go b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..91d9b792 --- /dev/null +++ b/operations/tcp_request_rule/replace_all_tcp_request_rule_frontend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllTCPRequestRuleFrontendURL generates an URL for the replace all TCP request rule frontend operation +type ReplaceAllTCPRequestRuleFrontendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPRequestRuleFrontendURL) WithBasePath(bp string) *ReplaceAllTCPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllTCPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllTCPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllTCPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllTCPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllTCPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllTCPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllTCPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllTCPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule.go b/operations/tcp_request_rule/replace_tcp_request_rule.go deleted file mode 100644 index b69eef45..00000000 --- a/operations/tcp_request_rule/replace_tcp_request_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceTCPRequestRuleHandlerFunc turns a function with the right signature into a replace TCP request rule handler -type ReplaceTCPRequestRuleHandlerFunc func(ReplaceTCPRequestRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceTCPRequestRuleHandlerFunc) Handle(params ReplaceTCPRequestRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceTCPRequestRuleHandler interface for that can handle valid replace TCP request rule params -type ReplaceTCPRequestRuleHandler interface { - Handle(ReplaceTCPRequestRuleParams, interface{}) middleware.Responder -} - -// NewReplaceTCPRequestRule creates a new http.Handler for the replace TCP request rule operation -func NewReplaceTCPRequestRule(ctx *middleware.Context, handler ReplaceTCPRequestRuleHandler) *ReplaceTCPRequestRule { - return &ReplaceTCPRequestRule{Context: ctx, Handler: handler} -} - -/*ReplaceTCPRequestRule swagger:route PUT /services/haproxy/configuration/tcp_request_rules/{id} TCPRequestRule replaceTcpRequestRule - -Replace a TCP Request Rule - -Replaces a TCP Request Rule configuration by it's ID in the specified parent. - -*/ -type ReplaceTCPRequestRule struct { - Context *middleware.Context - Handler ReplaceTCPRequestRuleHandler -} - -func (o *ReplaceTCPRequestRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceTCPRequestRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_backend.go b/operations/tcp_request_rule/replace_tcp_request_rule_backend.go new file mode 100644 index 00000000..6713ca04 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTCPRequestRuleBackendHandlerFunc turns a function with the right signature into a replace TCP request rule backend handler +type ReplaceTCPRequestRuleBackendHandlerFunc func(ReplaceTCPRequestRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTCPRequestRuleBackendHandlerFunc) Handle(params ReplaceTCPRequestRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTCPRequestRuleBackendHandler interface for that can handle valid replace TCP request rule backend params +type ReplaceTCPRequestRuleBackendHandler interface { + Handle(ReplaceTCPRequestRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceTCPRequestRuleBackend creates a new http.Handler for the replace TCP request rule backend operation +func NewReplaceTCPRequestRuleBackend(ctx *middleware.Context, handler ReplaceTCPRequestRuleBackendHandler) *ReplaceTCPRequestRuleBackend { + return &ReplaceTCPRequestRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceTCPRequestRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index} TCPRequestRule replaceTcpRequestRuleBackend + +# Replace a TCP Request Rule + +Replaces a TCP Request Rule configuration by it's index in the specified parent. +*/ +type ReplaceTCPRequestRuleBackend struct { + Context *middleware.Context + Handler ReplaceTCPRequestRuleBackendHandler +} + +func (o *ReplaceTCPRequestRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTCPRequestRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_backend_parameters.go b/operations/tcp_request_rule/replace_tcp_request_rule_backend_parameters.go new file mode 100644 index 00000000..4c11e122 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTCPRequestRuleBackendParams creates a new ReplaceTCPRequestRuleBackendParams object +// with the default values initialized. +func NewReplaceTCPRequestRuleBackendParams() ReplaceTCPRequestRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTCPRequestRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTCPRequestRuleBackendParams contains all the bound params for the replace TCP request rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTCPRequestRuleBackend +type ReplaceTCPRequestRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTCPRequestRuleBackendParams() beforehand. +func (o *ReplaceTCPRequestRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTCPRequestRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTCPRequestRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceTCPRequestRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTCPRequestRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTCPRequestRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTCPRequestRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_backend_responses.go b/operations/tcp_request_rule/replace_tcp_request_rule_backend_responses.go new file mode 100644 index 00000000..daaf0546 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTCPRequestRuleBackendOKCode is the HTTP code returned for type ReplaceTCPRequestRuleBackendOK +const ReplaceTCPRequestRuleBackendOKCode int = 200 + +/* +ReplaceTCPRequestRuleBackendOK TCP Request Rule replaced + +swagger:response replaceTcpRequestRuleBackendOK +*/ +type ReplaceTCPRequestRuleBackendOK struct { + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleBackendOK creates ReplaceTCPRequestRuleBackendOK with default headers values +func NewReplaceTCPRequestRuleBackendOK() *ReplaceTCPRequestRuleBackendOK { + + return &ReplaceTCPRequestRuleBackendOK{} +} + +// WithPayload adds the payload to the replace Tcp request rule backend o k response +func (o *ReplaceTCPRequestRuleBackendOK) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule backend o k response +func (o *ReplaceTCPRequestRuleBackendOK) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleBackendAcceptedCode is the HTTP code returned for type ReplaceTCPRequestRuleBackendAccepted +const ReplaceTCPRequestRuleBackendAcceptedCode int = 202 + +/* +ReplaceTCPRequestRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceTcpRequestRuleBackendAccepted +*/ +type ReplaceTCPRequestRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleBackendAccepted creates ReplaceTCPRequestRuleBackendAccepted with default headers values +func NewReplaceTCPRequestRuleBackendAccepted() *ReplaceTCPRequestRuleBackendAccepted { + + return &ReplaceTCPRequestRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Tcp request rule backend accepted response +func (o *ReplaceTCPRequestRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceTCPRequestRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Tcp request rule backend accepted response +func (o *ReplaceTCPRequestRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Tcp request rule backend accepted response +func (o *ReplaceTCPRequestRuleBackendAccepted) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule backend accepted response +func (o *ReplaceTCPRequestRuleBackendAccepted) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleBackendBadRequestCode is the HTTP code returned for type ReplaceTCPRequestRuleBackendBadRequest +const ReplaceTCPRequestRuleBackendBadRequestCode int = 400 + +/* +ReplaceTCPRequestRuleBackendBadRequest Bad request + +swagger:response replaceTcpRequestRuleBackendBadRequest +*/ +type ReplaceTCPRequestRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleBackendBadRequest creates ReplaceTCPRequestRuleBackendBadRequest with default headers values +func NewReplaceTCPRequestRuleBackendBadRequest() *ReplaceTCPRequestRuleBackendBadRequest { + + return &ReplaceTCPRequestRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule backend bad request response +func (o *ReplaceTCPRequestRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule backend bad request response +func (o *ReplaceTCPRequestRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp request rule backend bad request response +func (o *ReplaceTCPRequestRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule backend bad request response +func (o *ReplaceTCPRequestRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleBackendNotFoundCode is the HTTP code returned for type ReplaceTCPRequestRuleBackendNotFound +const ReplaceTCPRequestRuleBackendNotFoundCode int = 404 + +/* +ReplaceTCPRequestRuleBackendNotFound The specified resource was not found + +swagger:response replaceTcpRequestRuleBackendNotFound +*/ +type ReplaceTCPRequestRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleBackendNotFound creates ReplaceTCPRequestRuleBackendNotFound with default headers values +func NewReplaceTCPRequestRuleBackendNotFound() *ReplaceTCPRequestRuleBackendNotFound { + + return &ReplaceTCPRequestRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule backend not found response +func (o *ReplaceTCPRequestRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule backend not found response +func (o *ReplaceTCPRequestRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp request rule backend not found response +func (o *ReplaceTCPRequestRuleBackendNotFound) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule backend not found response +func (o *ReplaceTCPRequestRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTCPRequestRuleBackendDefault General Error + +swagger:response replaceTcpRequestRuleBackendDefault +*/ +type ReplaceTCPRequestRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleBackendDefault creates ReplaceTCPRequestRuleBackendDefault with default headers values +func NewReplaceTCPRequestRuleBackendDefault(code int) *ReplaceTCPRequestRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTCPRequestRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace TCP request rule backend default response +func (o *ReplaceTCPRequestRuleBackendDefault) WithStatusCode(code int) *ReplaceTCPRequestRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace TCP request rule backend default response +func (o *ReplaceTCPRequestRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace TCP request rule backend default response +func (o *ReplaceTCPRequestRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace TCP request rule backend default response +func (o *ReplaceTCPRequestRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace TCP request rule backend default response +func (o *ReplaceTCPRequestRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace TCP request rule backend default response +func (o *ReplaceTCPRequestRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_backend_urlbuilder.go b/operations/tcp_request_rule/replace_tcp_request_rule_backend_urlbuilder.go new file mode 100644 index 00000000..ae6a32f6 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTCPRequestRuleBackendURL generates an URL for the replace TCP request rule backend operation +type ReplaceTCPRequestRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPRequestRuleBackendURL) WithBasePath(bp string) *ReplaceTCPRequestRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPRequestRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTCPRequestRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceTCPRequestRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTCPRequestRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTCPRequestRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTCPRequestRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTCPRequestRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTCPRequestRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTCPRequestRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTCPRequestRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_defaults.go b/operations/tcp_request_rule/replace_tcp_request_rule_defaults.go new file mode 100644 index 00000000..d55832c2 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTCPRequestRuleDefaultsHandlerFunc turns a function with the right signature into a replace TCP request rule defaults handler +type ReplaceTCPRequestRuleDefaultsHandlerFunc func(ReplaceTCPRequestRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTCPRequestRuleDefaultsHandlerFunc) Handle(params ReplaceTCPRequestRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTCPRequestRuleDefaultsHandler interface for that can handle valid replace TCP request rule defaults params +type ReplaceTCPRequestRuleDefaultsHandler interface { + Handle(ReplaceTCPRequestRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceTCPRequestRuleDefaults creates a new http.Handler for the replace TCP request rule defaults operation +func NewReplaceTCPRequestRuleDefaults(ctx *middleware.Context, handler ReplaceTCPRequestRuleDefaultsHandler) *ReplaceTCPRequestRuleDefaults { + return &ReplaceTCPRequestRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceTCPRequestRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index} TCPRequestRule replaceTcpRequestRuleDefaults + +# Replace a TCP Request Rule + +Replaces a TCP Request Rule configuration by it's index in the specified parent. +*/ +type ReplaceTCPRequestRuleDefaults struct { + Context *middleware.Context + Handler ReplaceTCPRequestRuleDefaultsHandler +} + +func (o *ReplaceTCPRequestRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTCPRequestRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_defaults_parameters.go b/operations/tcp_request_rule/replace_tcp_request_rule_defaults_parameters.go new file mode 100644 index 00000000..c94104d5 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTCPRequestRuleDefaultsParams creates a new ReplaceTCPRequestRuleDefaultsParams object +// with the default values initialized. +func NewReplaceTCPRequestRuleDefaultsParams() ReplaceTCPRequestRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTCPRequestRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTCPRequestRuleDefaultsParams contains all the bound params for the replace TCP request rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTCPRequestRuleDefaults +type ReplaceTCPRequestRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTCPRequestRuleDefaultsParams() beforehand. +func (o *ReplaceTCPRequestRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTCPRequestRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTCPRequestRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceTCPRequestRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTCPRequestRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTCPRequestRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTCPRequestRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_defaults_responses.go b/operations/tcp_request_rule/replace_tcp_request_rule_defaults_responses.go new file mode 100644 index 00000000..7cc0268c --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTCPRequestRuleDefaultsOKCode is the HTTP code returned for type ReplaceTCPRequestRuleDefaultsOK +const ReplaceTCPRequestRuleDefaultsOKCode int = 200 + +/* +ReplaceTCPRequestRuleDefaultsOK TCP Request Rule replaced + +swagger:response replaceTcpRequestRuleDefaultsOK +*/ +type ReplaceTCPRequestRuleDefaultsOK struct { + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleDefaultsOK creates ReplaceTCPRequestRuleDefaultsOK with default headers values +func NewReplaceTCPRequestRuleDefaultsOK() *ReplaceTCPRequestRuleDefaultsOK { + + return &ReplaceTCPRequestRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace Tcp request rule defaults o k response +func (o *ReplaceTCPRequestRuleDefaultsOK) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule defaults o k response +func (o *ReplaceTCPRequestRuleDefaultsOK) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceTCPRequestRuleDefaultsAccepted +const ReplaceTCPRequestRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceTCPRequestRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceTcpRequestRuleDefaultsAccepted +*/ +type ReplaceTCPRequestRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleDefaultsAccepted creates ReplaceTCPRequestRuleDefaultsAccepted with default headers values +func NewReplaceTCPRequestRuleDefaultsAccepted() *ReplaceTCPRequestRuleDefaultsAccepted { + + return &ReplaceTCPRequestRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Tcp request rule defaults accepted response +func (o *ReplaceTCPRequestRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceTCPRequestRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Tcp request rule defaults accepted response +func (o *ReplaceTCPRequestRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Tcp request rule defaults accepted response +func (o *ReplaceTCPRequestRuleDefaultsAccepted) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule defaults accepted response +func (o *ReplaceTCPRequestRuleDefaultsAccepted) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceTCPRequestRuleDefaultsBadRequest +const ReplaceTCPRequestRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceTCPRequestRuleDefaultsBadRequest Bad request + +swagger:response replaceTcpRequestRuleDefaultsBadRequest +*/ +type ReplaceTCPRequestRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleDefaultsBadRequest creates ReplaceTCPRequestRuleDefaultsBadRequest with default headers values +func NewReplaceTCPRequestRuleDefaultsBadRequest() *ReplaceTCPRequestRuleDefaultsBadRequest { + + return &ReplaceTCPRequestRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule defaults bad request response +func (o *ReplaceTCPRequestRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule defaults bad request response +func (o *ReplaceTCPRequestRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp request rule defaults bad request response +func (o *ReplaceTCPRequestRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule defaults bad request response +func (o *ReplaceTCPRequestRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleDefaultsNotFoundCode is the HTTP code returned for type ReplaceTCPRequestRuleDefaultsNotFound +const ReplaceTCPRequestRuleDefaultsNotFoundCode int = 404 + +/* +ReplaceTCPRequestRuleDefaultsNotFound The specified resource was not found + +swagger:response replaceTcpRequestRuleDefaultsNotFound +*/ +type ReplaceTCPRequestRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleDefaultsNotFound creates ReplaceTCPRequestRuleDefaultsNotFound with default headers values +func NewReplaceTCPRequestRuleDefaultsNotFound() *ReplaceTCPRequestRuleDefaultsNotFound { + + return &ReplaceTCPRequestRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule defaults not found response +func (o *ReplaceTCPRequestRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule defaults not found response +func (o *ReplaceTCPRequestRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp request rule defaults not found response +func (o *ReplaceTCPRequestRuleDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule defaults not found response +func (o *ReplaceTCPRequestRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTCPRequestRuleDefaultsDefault General Error + +swagger:response replaceTcpRequestRuleDefaultsDefault +*/ +type ReplaceTCPRequestRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleDefaultsDefault creates ReplaceTCPRequestRuleDefaultsDefault with default headers values +func NewReplaceTCPRequestRuleDefaultsDefault(code int) *ReplaceTCPRequestRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTCPRequestRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace TCP request rule defaults default response +func (o *ReplaceTCPRequestRuleDefaultsDefault) WithStatusCode(code int) *ReplaceTCPRequestRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace TCP request rule defaults default response +func (o *ReplaceTCPRequestRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace TCP request rule defaults default response +func (o *ReplaceTCPRequestRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace TCP request rule defaults default response +func (o *ReplaceTCPRequestRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace TCP request rule defaults default response +func (o *ReplaceTCPRequestRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace TCP request rule defaults default response +func (o *ReplaceTCPRequestRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_defaults_urlbuilder.go b/operations/tcp_request_rule/replace_tcp_request_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..0350db02 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTCPRequestRuleDefaultsURL generates an URL for the replace TCP request rule defaults operation +type ReplaceTCPRequestRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPRequestRuleDefaultsURL) WithBasePath(bp string) *ReplaceTCPRequestRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPRequestRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTCPRequestRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceTCPRequestRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTCPRequestRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTCPRequestRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTCPRequestRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTCPRequestRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTCPRequestRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTCPRequestRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTCPRequestRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_frontend.go b/operations/tcp_request_rule/replace_tcp_request_rule_frontend.go new file mode 100644 index 00000000..c423b9e4 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_frontend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTCPRequestRuleFrontendHandlerFunc turns a function with the right signature into a replace TCP request rule frontend handler +type ReplaceTCPRequestRuleFrontendHandlerFunc func(ReplaceTCPRequestRuleFrontendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTCPRequestRuleFrontendHandlerFunc) Handle(params ReplaceTCPRequestRuleFrontendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTCPRequestRuleFrontendHandler interface for that can handle valid replace TCP request rule frontend params +type ReplaceTCPRequestRuleFrontendHandler interface { + Handle(ReplaceTCPRequestRuleFrontendParams, interface{}) middleware.Responder +} + +// NewReplaceTCPRequestRuleFrontend creates a new http.Handler for the replace TCP request rule frontend operation +func NewReplaceTCPRequestRuleFrontend(ctx *middleware.Context, handler ReplaceTCPRequestRuleFrontendHandler) *ReplaceTCPRequestRuleFrontend { + return &ReplaceTCPRequestRuleFrontend{Context: ctx, Handler: handler} +} + +/* + ReplaceTCPRequestRuleFrontend swagger:route PUT /services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index} TCPRequestRule replaceTcpRequestRuleFrontend + +# Replace a TCP Request Rule + +Replaces a TCP Request Rule configuration by it's index in the specified parent. +*/ +type ReplaceTCPRequestRuleFrontend struct { + Context *middleware.Context + Handler ReplaceTCPRequestRuleFrontendHandler +} + +func (o *ReplaceTCPRequestRuleFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTCPRequestRuleFrontendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_frontend_parameters.go b/operations/tcp_request_rule/replace_tcp_request_rule_frontend_parameters.go new file mode 100644 index 00000000..cb1bd52e --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_frontend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTCPRequestRuleFrontendParams creates a new ReplaceTCPRequestRuleFrontendParams object +// with the default values initialized. +func NewReplaceTCPRequestRuleFrontendParams() ReplaceTCPRequestRuleFrontendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTCPRequestRuleFrontendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTCPRequestRuleFrontendParams contains all the bound params for the replace TCP request rule frontend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTCPRequestRuleFrontend +type ReplaceTCPRequestRuleFrontendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPRequestRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Request Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTCPRequestRuleFrontendParams() beforehand. +func (o *ReplaceTCPRequestRuleFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPRequestRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTCPRequestRuleFrontendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTCPRequestRuleFrontendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceTCPRequestRuleFrontendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTCPRequestRuleFrontendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTCPRequestRuleFrontendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTCPRequestRuleFrontendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_frontend_responses.go b/operations/tcp_request_rule/replace_tcp_request_rule_frontend_responses.go new file mode 100644 index 00000000..58004dbd --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_frontend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTCPRequestRuleFrontendOKCode is the HTTP code returned for type ReplaceTCPRequestRuleFrontendOK +const ReplaceTCPRequestRuleFrontendOKCode int = 200 + +/* +ReplaceTCPRequestRuleFrontendOK TCP Request Rule replaced + +swagger:response replaceTcpRequestRuleFrontendOK +*/ +type ReplaceTCPRequestRuleFrontendOK struct { + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleFrontendOK creates ReplaceTCPRequestRuleFrontendOK with default headers values +func NewReplaceTCPRequestRuleFrontendOK() *ReplaceTCPRequestRuleFrontendOK { + + return &ReplaceTCPRequestRuleFrontendOK{} +} + +// WithPayload adds the payload to the replace Tcp request rule frontend o k response +func (o *ReplaceTCPRequestRuleFrontendOK) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleFrontendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule frontend o k response +func (o *ReplaceTCPRequestRuleFrontendOK) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleFrontendAcceptedCode is the HTTP code returned for type ReplaceTCPRequestRuleFrontendAccepted +const ReplaceTCPRequestRuleFrontendAcceptedCode int = 202 + +/* +ReplaceTCPRequestRuleFrontendAccepted Configuration change accepted and reload requested + +swagger:response replaceTcpRequestRuleFrontendAccepted +*/ +type ReplaceTCPRequestRuleFrontendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPRequestRule `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleFrontendAccepted creates ReplaceTCPRequestRuleFrontendAccepted with default headers values +func NewReplaceTCPRequestRuleFrontendAccepted() *ReplaceTCPRequestRuleFrontendAccepted { + + return &ReplaceTCPRequestRuleFrontendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Tcp request rule frontend accepted response +func (o *ReplaceTCPRequestRuleFrontendAccepted) WithReloadID(reloadID string) *ReplaceTCPRequestRuleFrontendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Tcp request rule frontend accepted response +func (o *ReplaceTCPRequestRuleFrontendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Tcp request rule frontend accepted response +func (o *ReplaceTCPRequestRuleFrontendAccepted) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleFrontendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule frontend accepted response +func (o *ReplaceTCPRequestRuleFrontendAccepted) SetPayload(payload *models.TCPRequestRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleFrontendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleFrontendBadRequestCode is the HTTP code returned for type ReplaceTCPRequestRuleFrontendBadRequest +const ReplaceTCPRequestRuleFrontendBadRequestCode int = 400 + +/* +ReplaceTCPRequestRuleFrontendBadRequest Bad request + +swagger:response replaceTcpRequestRuleFrontendBadRequest +*/ +type ReplaceTCPRequestRuleFrontendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleFrontendBadRequest creates ReplaceTCPRequestRuleFrontendBadRequest with default headers values +func NewReplaceTCPRequestRuleFrontendBadRequest() *ReplaceTCPRequestRuleFrontendBadRequest { + + return &ReplaceTCPRequestRuleFrontendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule frontend bad request response +func (o *ReplaceTCPRequestRuleFrontendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleFrontendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule frontend bad request response +func (o *ReplaceTCPRequestRuleFrontendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp request rule frontend bad request response +func (o *ReplaceTCPRequestRuleFrontendBadRequest) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleFrontendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule frontend bad request response +func (o *ReplaceTCPRequestRuleFrontendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleFrontendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPRequestRuleFrontendNotFoundCode is the HTTP code returned for type ReplaceTCPRequestRuleFrontendNotFound +const ReplaceTCPRequestRuleFrontendNotFoundCode int = 404 + +/* +ReplaceTCPRequestRuleFrontendNotFound The specified resource was not found + +swagger:response replaceTcpRequestRuleFrontendNotFound +*/ +type ReplaceTCPRequestRuleFrontendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleFrontendNotFound creates ReplaceTCPRequestRuleFrontendNotFound with default headers values +func NewReplaceTCPRequestRuleFrontendNotFound() *ReplaceTCPRequestRuleFrontendNotFound { + + return &ReplaceTCPRequestRuleFrontendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule frontend not found response +func (o *ReplaceTCPRequestRuleFrontendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleFrontendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule frontend not found response +func (o *ReplaceTCPRequestRuleFrontendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp request rule frontend not found response +func (o *ReplaceTCPRequestRuleFrontendNotFound) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleFrontendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp request rule frontend not found response +func (o *ReplaceTCPRequestRuleFrontendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTCPRequestRuleFrontendDefault General Error + +swagger:response replaceTcpRequestRuleFrontendDefault +*/ +type ReplaceTCPRequestRuleFrontendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPRequestRuleFrontendDefault creates ReplaceTCPRequestRuleFrontendDefault with default headers values +func NewReplaceTCPRequestRuleFrontendDefault(code int) *ReplaceTCPRequestRuleFrontendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTCPRequestRuleFrontendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace TCP request rule frontend default response +func (o *ReplaceTCPRequestRuleFrontendDefault) WithStatusCode(code int) *ReplaceTCPRequestRuleFrontendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace TCP request rule frontend default response +func (o *ReplaceTCPRequestRuleFrontendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace TCP request rule frontend default response +func (o *ReplaceTCPRequestRuleFrontendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTCPRequestRuleFrontendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace TCP request rule frontend default response +func (o *ReplaceTCPRequestRuleFrontendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace TCP request rule frontend default response +func (o *ReplaceTCPRequestRuleFrontendDefault) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleFrontendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace TCP request rule frontend default response +func (o *ReplaceTCPRequestRuleFrontendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPRequestRuleFrontendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_frontend_urlbuilder.go b/operations/tcp_request_rule/replace_tcp_request_rule_frontend_urlbuilder.go new file mode 100644 index 00000000..15d917f3 --- /dev/null +++ b/operations/tcp_request_rule/replace_tcp_request_rule_frontend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_request_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTCPRequestRuleFrontendURL generates an URL for the replace TCP request rule frontend operation +type ReplaceTCPRequestRuleFrontendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPRequestRuleFrontendURL) WithBasePath(bp string) *ReplaceTCPRequestRuleFrontendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPRequestRuleFrontendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTCPRequestRuleFrontendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/frontends/{parent_name}/tcp_request_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceTCPRequestRuleFrontendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTCPRequestRuleFrontendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTCPRequestRuleFrontendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTCPRequestRuleFrontendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTCPRequestRuleFrontendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTCPRequestRuleFrontendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTCPRequestRuleFrontendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTCPRequestRuleFrontendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_parameters.go b/operations/tcp_request_rule/replace_tcp_request_rule_parameters.go deleted file mode 100644 index 26e25ef2..00000000 --- a/operations/tcp_request_rule/replace_tcp_request_rule_parameters.go +++ /dev/null @@ -1,302 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceTCPRequestRuleParams creates a new ReplaceTCPRequestRuleParams object -// with the default values initialized. -func NewReplaceTCPRequestRuleParams() ReplaceTCPRequestRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceTCPRequestRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceTCPRequestRuleParams contains all the bound params for the replace TCP request rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceTCPRequestRule -type ReplaceTCPRequestRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Data *models.TCPRequestRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*TCP Request Rule ID - Required: true - In: path - */ - ID int64 - /*Parent name - Required: true - In: query - */ - ParentName string - /*Parent type - Required: true - In: query - */ - ParentType string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceTCPRequestRuleParams() beforehand. -func (o *ReplaceTCPRequestRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.TCPRequestRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qParentName, qhkParentName, _ := qs.GetOK("parent_name") - if err := o.bindParentName(qParentName, qhkParentName, route.Formats); err != nil { - res = append(res, err) - } - - qParentType, qhkParentType, _ := qs.GetOK("parent_type") - if err := o.bindParentType(qParentType, qhkParentType, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceTCPRequestRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceTCPRequestRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *ReplaceTCPRequestRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindParentName binds and validates parameter ParentName from query. -func (o *ReplaceTCPRequestRuleParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_name", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_name", "query", raw); err != nil { - return err - } - - o.ParentName = raw - - return nil -} - -// bindParentType binds and validates parameter ParentType from query. -func (o *ReplaceTCPRequestRuleParams) bindParentType(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("parent_type", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("parent_type", "query", raw); err != nil { - return err - } - - o.ParentType = raw - - if err := o.validateParentType(formats); err != nil { - return err - } - - return nil -} - -// validateParentType carries on validations for parameter ParentType -func (o *ReplaceTCPRequestRuleParams) validateParentType(formats strfmt.Registry) error { - - if err := validate.Enum("parent_type", "query", o.ParentType, []interface{}{"frontend", "backend"}); err != nil { - return err - } - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceTCPRequestRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceTCPRequestRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_responses.go b/operations/tcp_request_rule/replace_tcp_request_rule_responses.go deleted file mode 100644 index 8f608385..00000000 --- a/operations/tcp_request_rule/replace_tcp_request_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceTCPRequestRuleOKCode is the HTTP code returned for type ReplaceTCPRequestRuleOK -const ReplaceTCPRequestRuleOKCode int = 200 - -/*ReplaceTCPRequestRuleOK TCP Request Rule replaced - -swagger:response replaceTcpRequestRuleOK -*/ -type ReplaceTCPRequestRuleOK struct { - - /* - In: Body - */ - Payload *models.TCPRequestRule `json:"body,omitempty"` -} - -// NewReplaceTCPRequestRuleOK creates ReplaceTCPRequestRuleOK with default headers values -func NewReplaceTCPRequestRuleOK() *ReplaceTCPRequestRuleOK { - - return &ReplaceTCPRequestRuleOK{} -} - -// WithPayload adds the payload to the replace Tcp request rule o k response -func (o *ReplaceTCPRequestRuleOK) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp request rule o k response -func (o *ReplaceTCPRequestRuleOK) SetPayload(payload *models.TCPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPRequestRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceTCPRequestRuleAcceptedCode is the HTTP code returned for type ReplaceTCPRequestRuleAccepted -const ReplaceTCPRequestRuleAcceptedCode int = 202 - -/*ReplaceTCPRequestRuleAccepted Configuration change accepted and reload requested - -swagger:response replaceTcpRequestRuleAccepted -*/ -type ReplaceTCPRequestRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.TCPRequestRule `json:"body,omitempty"` -} - -// NewReplaceTCPRequestRuleAccepted creates ReplaceTCPRequestRuleAccepted with default headers values -func NewReplaceTCPRequestRuleAccepted() *ReplaceTCPRequestRuleAccepted { - - return &ReplaceTCPRequestRuleAccepted{} -} - -// WithReloadID adds the reloadId to the replace Tcp request rule accepted response -func (o *ReplaceTCPRequestRuleAccepted) WithReloadID(reloadID string) *ReplaceTCPRequestRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace Tcp request rule accepted response -func (o *ReplaceTCPRequestRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace Tcp request rule accepted response -func (o *ReplaceTCPRequestRuleAccepted) WithPayload(payload *models.TCPRequestRule) *ReplaceTCPRequestRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp request rule accepted response -func (o *ReplaceTCPRequestRuleAccepted) SetPayload(payload *models.TCPRequestRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPRequestRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceTCPRequestRuleBadRequestCode is the HTTP code returned for type ReplaceTCPRequestRuleBadRequest -const ReplaceTCPRequestRuleBadRequestCode int = 400 - -/*ReplaceTCPRequestRuleBadRequest Bad request - -swagger:response replaceTcpRequestRuleBadRequest -*/ -type ReplaceTCPRequestRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceTCPRequestRuleBadRequest creates ReplaceTCPRequestRuleBadRequest with default headers values -func NewReplaceTCPRequestRuleBadRequest() *ReplaceTCPRequestRuleBadRequest { - - return &ReplaceTCPRequestRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule bad request response -func (o *ReplaceTCPRequestRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceTCPRequestRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule bad request response -func (o *ReplaceTCPRequestRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Tcp request rule bad request response -func (o *ReplaceTCPRequestRuleBadRequest) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp request rule bad request response -func (o *ReplaceTCPRequestRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPRequestRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceTCPRequestRuleNotFoundCode is the HTTP code returned for type ReplaceTCPRequestRuleNotFound -const ReplaceTCPRequestRuleNotFoundCode int = 404 - -/*ReplaceTCPRequestRuleNotFound The specified resource was not found - -swagger:response replaceTcpRequestRuleNotFound -*/ -type ReplaceTCPRequestRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceTCPRequestRuleNotFound creates ReplaceTCPRequestRuleNotFound with default headers values -func NewReplaceTCPRequestRuleNotFound() *ReplaceTCPRequestRuleNotFound { - - return &ReplaceTCPRequestRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Tcp request rule not found response -func (o *ReplaceTCPRequestRuleNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceTCPRequestRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Tcp request rule not found response -func (o *ReplaceTCPRequestRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Tcp request rule not found response -func (o *ReplaceTCPRequestRuleNotFound) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp request rule not found response -func (o *ReplaceTCPRequestRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPRequestRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceTCPRequestRuleDefault General Error - -swagger:response replaceTcpRequestRuleDefault -*/ -type ReplaceTCPRequestRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceTCPRequestRuleDefault creates ReplaceTCPRequestRuleDefault with default headers values -func NewReplaceTCPRequestRuleDefault(code int) *ReplaceTCPRequestRuleDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceTCPRequestRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace TCP request rule default response -func (o *ReplaceTCPRequestRuleDefault) WithStatusCode(code int) *ReplaceTCPRequestRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace TCP request rule default response -func (o *ReplaceTCPRequestRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace TCP request rule default response -func (o *ReplaceTCPRequestRuleDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceTCPRequestRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace TCP request rule default response -func (o *ReplaceTCPRequestRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace TCP request rule default response -func (o *ReplaceTCPRequestRuleDefault) WithPayload(payload *models.Error) *ReplaceTCPRequestRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace TCP request rule default response -func (o *ReplaceTCPRequestRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPRequestRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_request_rule/replace_tcp_request_rule_urlbuilder.go b/operations/tcp_request_rule/replace_tcp_request_rule_urlbuilder.go deleted file mode 100644 index 63d92ad3..00000000 --- a/operations/tcp_request_rule/replace_tcp_request_rule_urlbuilder.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_request_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceTCPRequestRuleURL generates an URL for the replace TCP request rule operation -type ReplaceTCPRequestRuleURL struct { - ID int64 - - ForceReload *bool - ParentName string - ParentType string - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceTCPRequestRuleURL) WithBasePath(bp string) *ReplaceTCPRequestRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceTCPRequestRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceTCPRequestRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_request_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on ReplaceTCPRequestRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - parentName := o.ParentName - if parentName != "" { - qs.Set("parent_name", parentName) - } - - parentType := o.ParentType - if parentType != "" { - qs.Set("parent_type", parentType) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceTCPRequestRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceTCPRequestRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceTCPRequestRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceTCPRequestRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceTCPRequestRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceTCPRequestRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_response_rule/create_tcp_response_rule.go b/operations/tcp_response_rule/create_tcp_response_rule.go deleted file mode 100644 index fc4f62a6..00000000 --- a/operations/tcp_response_rule/create_tcp_response_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// CreateTCPResponseRuleHandlerFunc turns a function with the right signature into a create TCP response rule handler -type CreateTCPResponseRuleHandlerFunc func(CreateTCPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn CreateTCPResponseRuleHandlerFunc) Handle(params CreateTCPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// CreateTCPResponseRuleHandler interface for that can handle valid create TCP response rule params -type CreateTCPResponseRuleHandler interface { - Handle(CreateTCPResponseRuleParams, interface{}) middleware.Responder -} - -// NewCreateTCPResponseRule creates a new http.Handler for the create TCP response rule operation -func NewCreateTCPResponseRule(ctx *middleware.Context, handler CreateTCPResponseRuleHandler) *CreateTCPResponseRule { - return &CreateTCPResponseRule{Context: ctx, Handler: handler} -} - -/*CreateTCPResponseRule swagger:route POST /services/haproxy/configuration/tcp_response_rules TCPResponseRule createTcpResponseRule - -Add a new TCP Response Rule - -Adds a new TCP Response Rule of the specified type in the specified backend. - -*/ -type CreateTCPResponseRule struct { - Context *middleware.Context - Handler CreateTCPResponseRuleHandler -} - -func (o *CreateTCPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewCreateTCPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_backend.go b/operations/tcp_response_rule/create_tcp_response_rule_backend.go new file mode 100644 index 00000000..4aeaff1a --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTCPResponseRuleBackendHandlerFunc turns a function with the right signature into a create TCP response rule backend handler +type CreateTCPResponseRuleBackendHandlerFunc func(CreateTCPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTCPResponseRuleBackendHandlerFunc) Handle(params CreateTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTCPResponseRuleBackendHandler interface for that can handle valid create TCP response rule backend params +type CreateTCPResponseRuleBackendHandler interface { + Handle(CreateTCPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewCreateTCPResponseRuleBackend creates a new http.Handler for the create TCP response rule backend operation +func NewCreateTCPResponseRuleBackend(ctx *middleware.Context, handler CreateTCPResponseRuleBackendHandler) *CreateTCPResponseRuleBackend { + return &CreateTCPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + CreateTCPResponseRuleBackend swagger:route POST /services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index} TCPResponseRule createTcpResponseRuleBackend + +# Add a new TCP Response Rule + +Adds a new TCP Response Rule of the specified type in the specified backend. +*/ +type CreateTCPResponseRuleBackend struct { + Context *middleware.Context + Handler CreateTCPResponseRuleBackendHandler +} + +func (o *CreateTCPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTCPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_backend_parameters.go b/operations/tcp_response_rule/create_tcp_response_rule_backend_parameters.go new file mode 100644 index 00000000..1e80ee9c --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTCPResponseRuleBackendParams creates a new CreateTCPResponseRuleBackendParams object +// with the default values initialized. +func NewCreateTCPResponseRuleBackendParams() CreateTCPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTCPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTCPResponseRuleBackendParams contains all the bound params for the create TCP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTCPResponseRuleBackend +type CreateTCPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTCPResponseRuleBackendParams() beforehand. +func (o *CreateTCPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTCPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTCPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateTCPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTCPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTCPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTCPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_backend_responses.go b/operations/tcp_response_rule/create_tcp_response_rule_backend_responses.go new file mode 100644 index 00000000..08e0762f --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTCPResponseRuleBackendCreatedCode is the HTTP code returned for type CreateTCPResponseRuleBackendCreated +const CreateTCPResponseRuleBackendCreatedCode int = 201 + +/* +CreateTCPResponseRuleBackendCreated TCP Response Rule created + +swagger:response createTcpResponseRuleBackendCreated +*/ +type CreateTCPResponseRuleBackendCreated struct { + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleBackendCreated creates CreateTCPResponseRuleBackendCreated with default headers values +func NewCreateTCPResponseRuleBackendCreated() *CreateTCPResponseRuleBackendCreated { + + return &CreateTCPResponseRuleBackendCreated{} +} + +// WithPayload adds the payload to the create Tcp response rule backend created response +func (o *CreateTCPResponseRuleBackendCreated) WithPayload(payload *models.TCPResponseRule) *CreateTCPResponseRuleBackendCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule backend created response +func (o *CreateTCPResponseRuleBackendCreated) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleBackendCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPResponseRuleBackendAcceptedCode is the HTTP code returned for type CreateTCPResponseRuleBackendAccepted +const CreateTCPResponseRuleBackendAcceptedCode int = 202 + +/* +CreateTCPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response createTcpResponseRuleBackendAccepted +*/ +type CreateTCPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleBackendAccepted creates CreateTCPResponseRuleBackendAccepted with default headers values +func NewCreateTCPResponseRuleBackendAccepted() *CreateTCPResponseRuleBackendAccepted { + + return &CreateTCPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the create Tcp response rule backend accepted response +func (o *CreateTCPResponseRuleBackendAccepted) WithReloadID(reloadID string) *CreateTCPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Tcp response rule backend accepted response +func (o *CreateTCPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Tcp response rule backend accepted response +func (o *CreateTCPResponseRuleBackendAccepted) WithPayload(payload *models.TCPResponseRule) *CreateTCPResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule backend accepted response +func (o *CreateTCPResponseRuleBackendAccepted) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPResponseRuleBackendBadRequestCode is the HTTP code returned for type CreateTCPResponseRuleBackendBadRequest +const CreateTCPResponseRuleBackendBadRequestCode int = 400 + +/* +CreateTCPResponseRuleBackendBadRequest Bad request + +swagger:response createTcpResponseRuleBackendBadRequest +*/ +type CreateTCPResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleBackendBadRequest creates CreateTCPResponseRuleBackendBadRequest with default headers values +func NewCreateTCPResponseRuleBackendBadRequest() *CreateTCPResponseRuleBackendBadRequest { + + return &CreateTCPResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp response rule backend bad request response +func (o *CreateTCPResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTCPResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp response rule backend bad request response +func (o *CreateTCPResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp response rule backend bad request response +func (o *CreateTCPResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *CreateTCPResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule backend bad request response +func (o *CreateTCPResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPResponseRuleBackendConflictCode is the HTTP code returned for type CreateTCPResponseRuleBackendConflict +const CreateTCPResponseRuleBackendConflictCode int = 409 + +/* +CreateTCPResponseRuleBackendConflict The specified resource already exists + +swagger:response createTcpResponseRuleBackendConflict +*/ +type CreateTCPResponseRuleBackendConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleBackendConflict creates CreateTCPResponseRuleBackendConflict with default headers values +func NewCreateTCPResponseRuleBackendConflict() *CreateTCPResponseRuleBackendConflict { + + return &CreateTCPResponseRuleBackendConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp response rule backend conflict response +func (o *CreateTCPResponseRuleBackendConflict) WithConfigurationVersion(configurationVersion string) *CreateTCPResponseRuleBackendConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp response rule backend conflict response +func (o *CreateTCPResponseRuleBackendConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp response rule backend conflict response +func (o *CreateTCPResponseRuleBackendConflict) WithPayload(payload *models.Error) *CreateTCPResponseRuleBackendConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule backend conflict response +func (o *CreateTCPResponseRuleBackendConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleBackendConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTCPResponseRuleBackendDefault General Error + +swagger:response createTcpResponseRuleBackendDefault +*/ +type CreateTCPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleBackendDefault creates CreateTCPResponseRuleBackendDefault with default headers values +func NewCreateTCPResponseRuleBackendDefault(code int) *CreateTCPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &CreateTCPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create TCP response rule backend default response +func (o *CreateTCPResponseRuleBackendDefault) WithStatusCode(code int) *CreateTCPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create TCP response rule backend default response +func (o *CreateTCPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create TCP response rule backend default response +func (o *CreateTCPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *CreateTCPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create TCP response rule backend default response +func (o *CreateTCPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create TCP response rule backend default response +func (o *CreateTCPResponseRuleBackendDefault) WithPayload(payload *models.Error) *CreateTCPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create TCP response rule backend default response +func (o *CreateTCPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_backend_urlbuilder.go b/operations/tcp_response_rule/create_tcp_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..e40cd937 --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTCPResponseRuleBackendURL generates an URL for the create TCP response rule backend operation +type CreateTCPResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPResponseRuleBackendURL) WithBasePath(bp string) *CreateTCPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTCPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateTCPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTCPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTCPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTCPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTCPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTCPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTCPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTCPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_defaults.go b/operations/tcp_response_rule/create_tcp_response_rule_defaults.go new file mode 100644 index 00000000..e25f1c9f --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTCPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a create TCP response rule defaults handler +type CreateTCPResponseRuleDefaultsHandlerFunc func(CreateTCPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTCPResponseRuleDefaultsHandlerFunc) Handle(params CreateTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTCPResponseRuleDefaultsHandler interface for that can handle valid create TCP response rule defaults params +type CreateTCPResponseRuleDefaultsHandler interface { + Handle(CreateTCPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewCreateTCPResponseRuleDefaults creates a new http.Handler for the create TCP response rule defaults operation +func NewCreateTCPResponseRuleDefaults(ctx *middleware.Context, handler CreateTCPResponseRuleDefaultsHandler) *CreateTCPResponseRuleDefaults { + return &CreateTCPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + CreateTCPResponseRuleDefaults swagger:route POST /services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index} TCPResponseRule createTcpResponseRuleDefaults + +# Add a new TCP Response Rule + +Adds a new TCP Response Rule of the specified type in the specified backend. +*/ +type CreateTCPResponseRuleDefaults struct { + Context *middleware.Context + Handler CreateTCPResponseRuleDefaultsHandler +} + +func (o *CreateTCPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTCPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_defaults_parameters.go b/operations/tcp_response_rule/create_tcp_response_rule_defaults_parameters.go new file mode 100644 index 00000000..24eea127 --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTCPResponseRuleDefaultsParams creates a new CreateTCPResponseRuleDefaultsParams object +// with the default values initialized. +func NewCreateTCPResponseRuleDefaultsParams() CreateTCPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTCPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTCPResponseRuleDefaultsParams contains all the bound params for the create TCP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTCPResponseRuleDefaults +type CreateTCPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTCPResponseRuleDefaultsParams() beforehand. +func (o *CreateTCPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTCPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTCPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *CreateTCPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *CreateTCPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTCPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTCPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_defaults_responses.go b/operations/tcp_response_rule/create_tcp_response_rule_defaults_responses.go new file mode 100644 index 00000000..5f7087f1 --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTCPResponseRuleDefaultsCreatedCode is the HTTP code returned for type CreateTCPResponseRuleDefaultsCreated +const CreateTCPResponseRuleDefaultsCreatedCode int = 201 + +/* +CreateTCPResponseRuleDefaultsCreated TCP Response Rule created + +swagger:response createTcpResponseRuleDefaultsCreated +*/ +type CreateTCPResponseRuleDefaultsCreated struct { + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleDefaultsCreated creates CreateTCPResponseRuleDefaultsCreated with default headers values +func NewCreateTCPResponseRuleDefaultsCreated() *CreateTCPResponseRuleDefaultsCreated { + + return &CreateTCPResponseRuleDefaultsCreated{} +} + +// WithPayload adds the payload to the create Tcp response rule defaults created response +func (o *CreateTCPResponseRuleDefaultsCreated) WithPayload(payload *models.TCPResponseRule) *CreateTCPResponseRuleDefaultsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule defaults created response +func (o *CreateTCPResponseRuleDefaultsCreated) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleDefaultsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type CreateTCPResponseRuleDefaultsAccepted +const CreateTCPResponseRuleDefaultsAcceptedCode int = 202 + +/* +CreateTCPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response createTcpResponseRuleDefaultsAccepted +*/ +type CreateTCPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleDefaultsAccepted creates CreateTCPResponseRuleDefaultsAccepted with default headers values +func NewCreateTCPResponseRuleDefaultsAccepted() *CreateTCPResponseRuleDefaultsAccepted { + + return &CreateTCPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the create Tcp response rule defaults accepted response +func (o *CreateTCPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *CreateTCPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create Tcp response rule defaults accepted response +func (o *CreateTCPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create Tcp response rule defaults accepted response +func (o *CreateTCPResponseRuleDefaultsAccepted) WithPayload(payload *models.TCPResponseRule) *CreateTCPResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule defaults accepted response +func (o *CreateTCPResponseRuleDefaultsAccepted) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPResponseRuleDefaultsBadRequestCode is the HTTP code returned for type CreateTCPResponseRuleDefaultsBadRequest +const CreateTCPResponseRuleDefaultsBadRequestCode int = 400 + +/* +CreateTCPResponseRuleDefaultsBadRequest Bad request + +swagger:response createTcpResponseRuleDefaultsBadRequest +*/ +type CreateTCPResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleDefaultsBadRequest creates CreateTCPResponseRuleDefaultsBadRequest with default headers values +func NewCreateTCPResponseRuleDefaultsBadRequest() *CreateTCPResponseRuleDefaultsBadRequest { + + return &CreateTCPResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp response rule defaults bad request response +func (o *CreateTCPResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTCPResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp response rule defaults bad request response +func (o *CreateTCPResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp response rule defaults bad request response +func (o *CreateTCPResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *CreateTCPResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule defaults bad request response +func (o *CreateTCPResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTCPResponseRuleDefaultsConflictCode is the HTTP code returned for type CreateTCPResponseRuleDefaultsConflict +const CreateTCPResponseRuleDefaultsConflictCode int = 409 + +/* +CreateTCPResponseRuleDefaultsConflict The specified resource already exists + +swagger:response createTcpResponseRuleDefaultsConflict +*/ +type CreateTCPResponseRuleDefaultsConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleDefaultsConflict creates CreateTCPResponseRuleDefaultsConflict with default headers values +func NewCreateTCPResponseRuleDefaultsConflict() *CreateTCPResponseRuleDefaultsConflict { + + return &CreateTCPResponseRuleDefaultsConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create Tcp response rule defaults conflict response +func (o *CreateTCPResponseRuleDefaultsConflict) WithConfigurationVersion(configurationVersion string) *CreateTCPResponseRuleDefaultsConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create Tcp response rule defaults conflict response +func (o *CreateTCPResponseRuleDefaultsConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create Tcp response rule defaults conflict response +func (o *CreateTCPResponseRuleDefaultsConflict) WithPayload(payload *models.Error) *CreateTCPResponseRuleDefaultsConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create Tcp response rule defaults conflict response +func (o *CreateTCPResponseRuleDefaultsConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleDefaultsConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTCPResponseRuleDefaultsDefault General Error + +swagger:response createTcpResponseRuleDefaultsDefault +*/ +type CreateTCPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTCPResponseRuleDefaultsDefault creates CreateTCPResponseRuleDefaultsDefault with default headers values +func NewCreateTCPResponseRuleDefaultsDefault(code int) *CreateTCPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &CreateTCPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create TCP response rule defaults default response +func (o *CreateTCPResponseRuleDefaultsDefault) WithStatusCode(code int) *CreateTCPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create TCP response rule defaults default response +func (o *CreateTCPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create TCP response rule defaults default response +func (o *CreateTCPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *CreateTCPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create TCP response rule defaults default response +func (o *CreateTCPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create TCP response rule defaults default response +func (o *CreateTCPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *CreateTCPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create TCP response rule defaults default response +func (o *CreateTCPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTCPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_defaults_urlbuilder.go b/operations/tcp_response_rule/create_tcp_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..f0981354 --- /dev/null +++ b/operations/tcp_response_rule/create_tcp_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// CreateTCPResponseRuleDefaultsURL generates an URL for the create TCP response rule defaults operation +type CreateTCPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPResponseRuleDefaultsURL) WithBasePath(bp string) *CreateTCPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTCPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTCPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on CreateTCPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on CreateTCPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTCPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTCPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTCPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTCPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTCPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTCPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_parameters.go b/operations/tcp_response_rule/create_tcp_response_rule_parameters.go deleted file mode 100644 index 28a9e951..00000000 --- a/operations/tcp_response_rule/create_tcp_response_rule_parameters.go +++ /dev/null @@ -1,228 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewCreateTCPResponseRuleParams creates a new CreateTCPResponseRuleParams object -// with the default values initialized. -func NewCreateTCPResponseRuleParams() CreateTCPResponseRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return CreateTCPResponseRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// CreateTCPResponseRuleParams contains all the bound params for the create TCP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters createTCPResponseRule -type CreateTCPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /* - Required: true - In: body - */ - Data *models.TCPResponseRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewCreateTCPResponseRuleParams() beforehand. -func (o *CreateTCPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.TCPResponseRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *CreateTCPResponseRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *CreateTCPResponseRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewCreateTCPResponseRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *CreateTCPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *CreateTCPResponseRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_responses.go b/operations/tcp_response_rule/create_tcp_response_rule_responses.go deleted file mode 100644 index dbe5d85d..00000000 --- a/operations/tcp_response_rule/create_tcp_response_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// CreateTCPResponseRuleCreatedCode is the HTTP code returned for type CreateTCPResponseRuleCreated -const CreateTCPResponseRuleCreatedCode int = 201 - -/*CreateTCPResponseRuleCreated TCP Response Rule created - -swagger:response createTcpResponseRuleCreated -*/ -type CreateTCPResponseRuleCreated struct { - - /* - In: Body - */ - Payload *models.TCPResponseRule `json:"body,omitempty"` -} - -// NewCreateTCPResponseRuleCreated creates CreateTCPResponseRuleCreated with default headers values -func NewCreateTCPResponseRuleCreated() *CreateTCPResponseRuleCreated { - - return &CreateTCPResponseRuleCreated{} -} - -// WithPayload adds the payload to the create Tcp response rule created response -func (o *CreateTCPResponseRuleCreated) WithPayload(payload *models.TCPResponseRule) *CreateTCPResponseRuleCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp response rule created response -func (o *CreateTCPResponseRuleCreated) SetPayload(payload *models.TCPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPResponseRuleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateTCPResponseRuleAcceptedCode is the HTTP code returned for type CreateTCPResponseRuleAccepted -const CreateTCPResponseRuleAcceptedCode int = 202 - -/*CreateTCPResponseRuleAccepted Configuration change accepted and reload requested - -swagger:response createTcpResponseRuleAccepted -*/ -type CreateTCPResponseRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.TCPResponseRule `json:"body,omitempty"` -} - -// NewCreateTCPResponseRuleAccepted creates CreateTCPResponseRuleAccepted with default headers values -func NewCreateTCPResponseRuleAccepted() *CreateTCPResponseRuleAccepted { - - return &CreateTCPResponseRuleAccepted{} -} - -// WithReloadID adds the reloadId to the create Tcp response rule accepted response -func (o *CreateTCPResponseRuleAccepted) WithReloadID(reloadID string) *CreateTCPResponseRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the create Tcp response rule accepted response -func (o *CreateTCPResponseRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the create Tcp response rule accepted response -func (o *CreateTCPResponseRuleAccepted) WithPayload(payload *models.TCPResponseRule) *CreateTCPResponseRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp response rule accepted response -func (o *CreateTCPResponseRuleAccepted) SetPayload(payload *models.TCPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPResponseRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateTCPResponseRuleBadRequestCode is the HTTP code returned for type CreateTCPResponseRuleBadRequest -const CreateTCPResponseRuleBadRequestCode int = 400 - -/*CreateTCPResponseRuleBadRequest Bad request - -swagger:response createTcpResponseRuleBadRequest -*/ -type CreateTCPResponseRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateTCPResponseRuleBadRequest creates CreateTCPResponseRuleBadRequest with default headers values -func NewCreateTCPResponseRuleBadRequest() *CreateTCPResponseRuleBadRequest { - - return &CreateTCPResponseRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Tcp response rule bad request response -func (o *CreateTCPResponseRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *CreateTCPResponseRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Tcp response rule bad request response -func (o *CreateTCPResponseRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Tcp response rule bad request response -func (o *CreateTCPResponseRuleBadRequest) WithPayload(payload *models.Error) *CreateTCPResponseRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp response rule bad request response -func (o *CreateTCPResponseRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPResponseRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// CreateTCPResponseRuleConflictCode is the HTTP code returned for type CreateTCPResponseRuleConflict -const CreateTCPResponseRuleConflictCode int = 409 - -/*CreateTCPResponseRuleConflict The specified resource already exists - -swagger:response createTcpResponseRuleConflict -*/ -type CreateTCPResponseRuleConflict struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateTCPResponseRuleConflict creates CreateTCPResponseRuleConflict with default headers values -func NewCreateTCPResponseRuleConflict() *CreateTCPResponseRuleConflict { - - return &CreateTCPResponseRuleConflict{} -} - -// WithConfigurationVersion adds the configurationVersion to the create Tcp response rule conflict response -func (o *CreateTCPResponseRuleConflict) WithConfigurationVersion(configurationVersion int64) *CreateTCPResponseRuleConflict { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create Tcp response rule conflict response -func (o *CreateTCPResponseRuleConflict) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create Tcp response rule conflict response -func (o *CreateTCPResponseRuleConflict) WithPayload(payload *models.Error) *CreateTCPResponseRuleConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create Tcp response rule conflict response -func (o *CreateTCPResponseRuleConflict) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPResponseRuleConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*CreateTCPResponseRuleDefault General Error - -swagger:response createTcpResponseRuleDefault -*/ -type CreateTCPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewCreateTCPResponseRuleDefault creates CreateTCPResponseRuleDefault with default headers values -func NewCreateTCPResponseRuleDefault(code int) *CreateTCPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &CreateTCPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the create TCP response rule default response -func (o *CreateTCPResponseRuleDefault) WithStatusCode(code int) *CreateTCPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the create TCP response rule default response -func (o *CreateTCPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the create TCP response rule default response -func (o *CreateTCPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *CreateTCPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the create TCP response rule default response -func (o *CreateTCPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the create TCP response rule default response -func (o *CreateTCPResponseRuleDefault) WithPayload(payload *models.Error) *CreateTCPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the create TCP response rule default response -func (o *CreateTCPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *CreateTCPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_response_rule/create_tcp_response_rule_urlbuilder.go b/operations/tcp_response_rule/create_tcp_response_rule_urlbuilder.go deleted file mode 100644 index b058f029..00000000 --- a/operations/tcp_response_rule/create_tcp_response_rule_urlbuilder.go +++ /dev/null @@ -1,144 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/swag" -) - -// CreateTCPResponseRuleURL generates an URL for the create TCP response rule operation -type CreateTCPResponseRuleURL struct { - Backend string - ForceReload *bool - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateTCPResponseRuleURL) WithBasePath(bp string) *CreateTCPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *CreateTCPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *CreateTCPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_response_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *CreateTCPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *CreateTCPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *CreateTCPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on CreateTCPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on CreateTCPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *CreateTCPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule.go b/operations/tcp_response_rule/delete_tcp_response_rule.go deleted file mode 100644 index 5d7618ec..00000000 --- a/operations/tcp_response_rule/delete_tcp_response_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// DeleteTCPResponseRuleHandlerFunc turns a function with the right signature into a delete TCP response rule handler -type DeleteTCPResponseRuleHandlerFunc func(DeleteTCPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn DeleteTCPResponseRuleHandlerFunc) Handle(params DeleteTCPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// DeleteTCPResponseRuleHandler interface for that can handle valid delete TCP response rule params -type DeleteTCPResponseRuleHandler interface { - Handle(DeleteTCPResponseRuleParams, interface{}) middleware.Responder -} - -// NewDeleteTCPResponseRule creates a new http.Handler for the delete TCP response rule operation -func NewDeleteTCPResponseRule(ctx *middleware.Context, handler DeleteTCPResponseRuleHandler) *DeleteTCPResponseRule { - return &DeleteTCPResponseRule{Context: ctx, Handler: handler} -} - -/*DeleteTCPResponseRule swagger:route DELETE /services/haproxy/configuration/tcp_response_rules/{id} TCPResponseRule deleteTcpResponseRule - -Delete a TCP Response Rule - -Deletes a TCP Response Rule configuration by it's ID from the specified backend. - -*/ -type DeleteTCPResponseRule struct { - Context *middleware.Context - Handler DeleteTCPResponseRuleHandler -} - -func (o *DeleteTCPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewDeleteTCPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_backend.go b/operations/tcp_response_rule/delete_tcp_response_rule_backend.go new file mode 100644 index 00000000..59e83ca8 --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTCPResponseRuleBackendHandlerFunc turns a function with the right signature into a delete TCP response rule backend handler +type DeleteTCPResponseRuleBackendHandlerFunc func(DeleteTCPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTCPResponseRuleBackendHandlerFunc) Handle(params DeleteTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTCPResponseRuleBackendHandler interface for that can handle valid delete TCP response rule backend params +type DeleteTCPResponseRuleBackendHandler interface { + Handle(DeleteTCPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewDeleteTCPResponseRuleBackend creates a new http.Handler for the delete TCP response rule backend operation +func NewDeleteTCPResponseRuleBackend(ctx *middleware.Context, handler DeleteTCPResponseRuleBackendHandler) *DeleteTCPResponseRuleBackend { + return &DeleteTCPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + DeleteTCPResponseRuleBackend swagger:route DELETE /services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index} TCPResponseRule deleteTcpResponseRuleBackend + +# Delete a TCP Response Rule + +Deletes a TCP Response Rule configuration by it's index from the specified backend. +*/ +type DeleteTCPResponseRuleBackend struct { + Context *middleware.Context + Handler DeleteTCPResponseRuleBackendHandler +} + +func (o *DeleteTCPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTCPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_backend_parameters.go b/operations/tcp_response_rule/delete_tcp_response_rule_backend_parameters.go new file mode 100644 index 00000000..1d5e4f9b --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_backend_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTCPResponseRuleBackendParams creates a new DeleteTCPResponseRuleBackendParams object +// with the default values initialized. +func NewDeleteTCPResponseRuleBackendParams() DeleteTCPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTCPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTCPResponseRuleBackendParams contains all the bound params for the delete TCP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTCPResponseRuleBackend +type DeleteTCPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTCPResponseRuleBackendParams() beforehand. +func (o *DeleteTCPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTCPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTCPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteTCPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTCPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTCPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTCPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_backend_responses.go b/operations/tcp_response_rule/delete_tcp_response_rule_backend_responses.go new file mode 100644 index 00000000..fbbc2358 --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_backend_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTCPResponseRuleBackendAcceptedCode is the HTTP code returned for type DeleteTCPResponseRuleBackendAccepted +const DeleteTCPResponseRuleBackendAcceptedCode int = 202 + +/* +DeleteTCPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response deleteTcpResponseRuleBackendAccepted +*/ +type DeleteTCPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTCPResponseRuleBackendAccepted creates DeleteTCPResponseRuleBackendAccepted with default headers values +func NewDeleteTCPResponseRuleBackendAccepted() *DeleteTCPResponseRuleBackendAccepted { + + return &DeleteTCPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the delete Tcp response rule backend accepted response +func (o *DeleteTCPResponseRuleBackendAccepted) WithReloadID(reloadID string) *DeleteTCPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Tcp response rule backend accepted response +func (o *DeleteTCPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTCPResponseRuleBackendNoContentCode is the HTTP code returned for type DeleteTCPResponseRuleBackendNoContent +const DeleteTCPResponseRuleBackendNoContentCode int = 204 + +/* +DeleteTCPResponseRuleBackendNoContent TCP Response Rule deleted + +swagger:response deleteTcpResponseRuleBackendNoContent +*/ +type DeleteTCPResponseRuleBackendNoContent struct { +} + +// NewDeleteTCPResponseRuleBackendNoContent creates DeleteTCPResponseRuleBackendNoContent with default headers values +func NewDeleteTCPResponseRuleBackendNoContent() *DeleteTCPResponseRuleBackendNoContent { + + return &DeleteTCPResponseRuleBackendNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleBackendNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTCPResponseRuleBackendNotFoundCode is the HTTP code returned for type DeleteTCPResponseRuleBackendNotFound +const DeleteTCPResponseRuleBackendNotFoundCode int = 404 + +/* +DeleteTCPResponseRuleBackendNotFound The specified resource was not found + +swagger:response deleteTcpResponseRuleBackendNotFound +*/ +type DeleteTCPResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPResponseRuleBackendNotFound creates DeleteTCPResponseRuleBackendNotFound with default headers values +func NewDeleteTCPResponseRuleBackendNotFound() *DeleteTCPResponseRuleBackendNotFound { + + return &DeleteTCPResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Tcp response rule backend not found response +func (o *DeleteTCPResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTCPResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Tcp response rule backend not found response +func (o *DeleteTCPResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Tcp response rule backend not found response +func (o *DeleteTCPResponseRuleBackendNotFound) WithPayload(payload *models.Error) *DeleteTCPResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Tcp response rule backend not found response +func (o *DeleteTCPResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTCPResponseRuleBackendDefault General Error + +swagger:response deleteTcpResponseRuleBackendDefault +*/ +type DeleteTCPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPResponseRuleBackendDefault creates DeleteTCPResponseRuleBackendDefault with default headers values +func NewDeleteTCPResponseRuleBackendDefault(code int) *DeleteTCPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTCPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete TCP response rule backend default response +func (o *DeleteTCPResponseRuleBackendDefault) WithStatusCode(code int) *DeleteTCPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete TCP response rule backend default response +func (o *DeleteTCPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete TCP response rule backend default response +func (o *DeleteTCPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *DeleteTCPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete TCP response rule backend default response +func (o *DeleteTCPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete TCP response rule backend default response +func (o *DeleteTCPResponseRuleBackendDefault) WithPayload(payload *models.Error) *DeleteTCPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete TCP response rule backend default response +func (o *DeleteTCPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_backend_urlbuilder.go b/operations/tcp_response_rule/delete_tcp_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..09c695ba --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTCPResponseRuleBackendURL generates an URL for the delete TCP response rule backend operation +type DeleteTCPResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPResponseRuleBackendURL) WithBasePath(bp string) *DeleteTCPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTCPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteTCPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTCPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTCPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTCPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTCPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTCPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTCPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTCPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_defaults.go b/operations/tcp_response_rule/delete_tcp_response_rule_defaults.go new file mode 100644 index 00000000..77936502 --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTCPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a delete TCP response rule defaults handler +type DeleteTCPResponseRuleDefaultsHandlerFunc func(DeleteTCPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTCPResponseRuleDefaultsHandlerFunc) Handle(params DeleteTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTCPResponseRuleDefaultsHandler interface for that can handle valid delete TCP response rule defaults params +type DeleteTCPResponseRuleDefaultsHandler interface { + Handle(DeleteTCPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewDeleteTCPResponseRuleDefaults creates a new http.Handler for the delete TCP response rule defaults operation +func NewDeleteTCPResponseRuleDefaults(ctx *middleware.Context, handler DeleteTCPResponseRuleDefaultsHandler) *DeleteTCPResponseRuleDefaults { + return &DeleteTCPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + DeleteTCPResponseRuleDefaults swagger:route DELETE /services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index} TCPResponseRule deleteTcpResponseRuleDefaults + +# Delete a TCP Response Rule + +Deletes a TCP Response Rule configuration by it's index from the specified backend. +*/ +type DeleteTCPResponseRuleDefaults struct { + Context *middleware.Context + Handler DeleteTCPResponseRuleDefaultsHandler +} + +func (o *DeleteTCPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTCPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_defaults_parameters.go b/operations/tcp_response_rule/delete_tcp_response_rule_defaults_parameters.go new file mode 100644 index 00000000..4216d8c2 --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_defaults_parameters.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTCPResponseRuleDefaultsParams creates a new DeleteTCPResponseRuleDefaultsParams object +// with the default values initialized. +func NewDeleteTCPResponseRuleDefaultsParams() DeleteTCPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTCPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTCPResponseRuleDefaultsParams contains all the bound params for the delete TCP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTCPResponseRuleDefaults +type DeleteTCPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTCPResponseRuleDefaultsParams() beforehand. +func (o *DeleteTCPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTCPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTCPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *DeleteTCPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *DeleteTCPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTCPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTCPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_defaults_responses.go b/operations/tcp_response_rule/delete_tcp_response_rule_defaults_responses.go new file mode 100644 index 00000000..5d3a2506 --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_defaults_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTCPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type DeleteTCPResponseRuleDefaultsAccepted +const DeleteTCPResponseRuleDefaultsAcceptedCode int = 202 + +/* +DeleteTCPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response deleteTcpResponseRuleDefaultsAccepted +*/ +type DeleteTCPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTCPResponseRuleDefaultsAccepted creates DeleteTCPResponseRuleDefaultsAccepted with default headers values +func NewDeleteTCPResponseRuleDefaultsAccepted() *DeleteTCPResponseRuleDefaultsAccepted { + + return &DeleteTCPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the delete Tcp response rule defaults accepted response +func (o *DeleteTCPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *DeleteTCPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete Tcp response rule defaults accepted response +func (o *DeleteTCPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTCPResponseRuleDefaultsNoContentCode is the HTTP code returned for type DeleteTCPResponseRuleDefaultsNoContent +const DeleteTCPResponseRuleDefaultsNoContentCode int = 204 + +/* +DeleteTCPResponseRuleDefaultsNoContent TCP Response Rule deleted + +swagger:response deleteTcpResponseRuleDefaultsNoContent +*/ +type DeleteTCPResponseRuleDefaultsNoContent struct { +} + +// NewDeleteTCPResponseRuleDefaultsNoContent creates DeleteTCPResponseRuleDefaultsNoContent with default headers values +func NewDeleteTCPResponseRuleDefaultsNoContent() *DeleteTCPResponseRuleDefaultsNoContent { + + return &DeleteTCPResponseRuleDefaultsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleDefaultsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTCPResponseRuleDefaultsNotFoundCode is the HTTP code returned for type DeleteTCPResponseRuleDefaultsNotFound +const DeleteTCPResponseRuleDefaultsNotFoundCode int = 404 + +/* +DeleteTCPResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response deleteTcpResponseRuleDefaultsNotFound +*/ +type DeleteTCPResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPResponseRuleDefaultsNotFound creates DeleteTCPResponseRuleDefaultsNotFound with default headers values +func NewDeleteTCPResponseRuleDefaultsNotFound() *DeleteTCPResponseRuleDefaultsNotFound { + + return &DeleteTCPResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete Tcp response rule defaults not found response +func (o *DeleteTCPResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTCPResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete Tcp response rule defaults not found response +func (o *DeleteTCPResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete Tcp response rule defaults not found response +func (o *DeleteTCPResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *DeleteTCPResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete Tcp response rule defaults not found response +func (o *DeleteTCPResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTCPResponseRuleDefaultsDefault General Error + +swagger:response deleteTcpResponseRuleDefaultsDefault +*/ +type DeleteTCPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTCPResponseRuleDefaultsDefault creates DeleteTCPResponseRuleDefaultsDefault with default headers values +func NewDeleteTCPResponseRuleDefaultsDefault(code int) *DeleteTCPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTCPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete TCP response rule defaults default response +func (o *DeleteTCPResponseRuleDefaultsDefault) WithStatusCode(code int) *DeleteTCPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete TCP response rule defaults default response +func (o *DeleteTCPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete TCP response rule defaults default response +func (o *DeleteTCPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *DeleteTCPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete TCP response rule defaults default response +func (o *DeleteTCPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete TCP response rule defaults default response +func (o *DeleteTCPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *DeleteTCPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete TCP response rule defaults default response +func (o *DeleteTCPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTCPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_defaults_urlbuilder.go b/operations/tcp_response_rule/delete_tcp_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..5b664c0a --- /dev/null +++ b/operations/tcp_response_rule/delete_tcp_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteTCPResponseRuleDefaultsURL generates an URL for the delete TCP response rule defaults operation +type DeleteTCPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPResponseRuleDefaultsURL) WithBasePath(bp string) *DeleteTCPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTCPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTCPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on DeleteTCPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on DeleteTCPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTCPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTCPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTCPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTCPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTCPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTCPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_parameters.go b/operations/tcp_response_rule/delete_tcp_response_rule_parameters.go deleted file mode 100644 index f0c8281c..00000000 --- a/operations/tcp_response_rule/delete_tcp_response_rule_parameters.go +++ /dev/null @@ -1,227 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewDeleteTCPResponseRuleParams creates a new DeleteTCPResponseRuleParams object -// with the default values initialized. -func NewDeleteTCPResponseRuleParams() DeleteTCPResponseRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return DeleteTCPResponseRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// DeleteTCPResponseRuleParams contains all the bound params for the delete TCP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters deleteTCPResponseRule -type DeleteTCPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*TCP Response Rule ID - Required: true - In: path - */ - ID int64 - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewDeleteTCPResponseRuleParams() beforehand. -func (o *DeleteTCPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *DeleteTCPResponseRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *DeleteTCPResponseRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewDeleteTCPResponseRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *DeleteTCPResponseRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *DeleteTCPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *DeleteTCPResponseRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_responses.go b/operations/tcp_response_rule/delete_tcp_response_rule_responses.go deleted file mode 100644 index 9c6b0f6d..00000000 --- a/operations/tcp_response_rule/delete_tcp_response_rule_responses.go +++ /dev/null @@ -1,246 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// DeleteTCPResponseRuleAcceptedCode is the HTTP code returned for type DeleteTCPResponseRuleAccepted -const DeleteTCPResponseRuleAcceptedCode int = 202 - -/*DeleteTCPResponseRuleAccepted Configuration change accepted and reload requested - -swagger:response deleteTcpResponseRuleAccepted -*/ -type DeleteTCPResponseRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` -} - -// NewDeleteTCPResponseRuleAccepted creates DeleteTCPResponseRuleAccepted with default headers values -func NewDeleteTCPResponseRuleAccepted() *DeleteTCPResponseRuleAccepted { - - return &DeleteTCPResponseRuleAccepted{} -} - -// WithReloadID adds the reloadId to the delete Tcp response rule accepted response -func (o *DeleteTCPResponseRuleAccepted) WithReloadID(reloadID string) *DeleteTCPResponseRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the delete Tcp response rule accepted response -func (o *DeleteTCPResponseRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WriteResponse to the client -func (o *DeleteTCPResponseRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(202) -} - -// DeleteTCPResponseRuleNoContentCode is the HTTP code returned for type DeleteTCPResponseRuleNoContent -const DeleteTCPResponseRuleNoContentCode int = 204 - -/*DeleteTCPResponseRuleNoContent TCP Response Rule deleted - -swagger:response deleteTcpResponseRuleNoContent -*/ -type DeleteTCPResponseRuleNoContent struct { -} - -// NewDeleteTCPResponseRuleNoContent creates DeleteTCPResponseRuleNoContent with default headers values -func NewDeleteTCPResponseRuleNoContent() *DeleteTCPResponseRuleNoContent { - - return &DeleteTCPResponseRuleNoContent{} -} - -// WriteResponse to the client -func (o *DeleteTCPResponseRuleNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -// DeleteTCPResponseRuleNotFoundCode is the HTTP code returned for type DeleteTCPResponseRuleNotFound -const DeleteTCPResponseRuleNotFoundCode int = 404 - -/*DeleteTCPResponseRuleNotFound The specified resource was not found - -swagger:response deleteTcpResponseRuleNotFound -*/ -type DeleteTCPResponseRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteTCPResponseRuleNotFound creates DeleteTCPResponseRuleNotFound with default headers values -func NewDeleteTCPResponseRuleNotFound() *DeleteTCPResponseRuleNotFound { - - return &DeleteTCPResponseRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the delete Tcp response rule not found response -func (o *DeleteTCPResponseRuleNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteTCPResponseRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete Tcp response rule not found response -func (o *DeleteTCPResponseRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete Tcp response rule not found response -func (o *DeleteTCPResponseRuleNotFound) WithPayload(payload *models.Error) *DeleteTCPResponseRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete Tcp response rule not found response -func (o *DeleteTCPResponseRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteTCPResponseRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*DeleteTCPResponseRuleDefault General Error - -swagger:response deleteTcpResponseRuleDefault -*/ -type DeleteTCPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewDeleteTCPResponseRuleDefault creates DeleteTCPResponseRuleDefault with default headers values -func NewDeleteTCPResponseRuleDefault(code int) *DeleteTCPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &DeleteTCPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the delete TCP response rule default response -func (o *DeleteTCPResponseRuleDefault) WithStatusCode(code int) *DeleteTCPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the delete TCP response rule default response -func (o *DeleteTCPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the delete TCP response rule default response -func (o *DeleteTCPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *DeleteTCPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the delete TCP response rule default response -func (o *DeleteTCPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the delete TCP response rule default response -func (o *DeleteTCPResponseRuleDefault) WithPayload(payload *models.Error) *DeleteTCPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the delete TCP response rule default response -func (o *DeleteTCPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *DeleteTCPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_response_rule/delete_tcp_response_rule_urlbuilder.go b/operations/tcp_response_rule/delete_tcp_response_rule_urlbuilder.go deleted file mode 100644 index 3381314f..00000000 --- a/operations/tcp_response_rule/delete_tcp_response_rule_urlbuilder.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// DeleteTCPResponseRuleURL generates an URL for the delete TCP response rule operation -type DeleteTCPResponseRuleURL struct { - ID int64 - - Backend string - ForceReload *bool - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteTCPResponseRuleURL) WithBasePath(bp string) *DeleteTCPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *DeleteTCPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *DeleteTCPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_response_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on DeleteTCPResponseRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *DeleteTCPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *DeleteTCPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *DeleteTCPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on DeleteTCPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on DeleteTCPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *DeleteTCPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_backend.go b/operations/tcp_response_rule/get_all_tcp_response_rule_backend.go new file mode 100644 index 00000000..0816541b --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllTCPResponseRuleBackendHandlerFunc turns a function with the right signature into a get all TCP response rule backend handler +type GetAllTCPResponseRuleBackendHandlerFunc func(GetAllTCPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllTCPResponseRuleBackendHandlerFunc) Handle(params GetAllTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllTCPResponseRuleBackendHandler interface for that can handle valid get all TCP response rule backend params +type GetAllTCPResponseRuleBackendHandler interface { + Handle(GetAllTCPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetAllTCPResponseRuleBackend creates a new http.Handler for the get all TCP response rule backend operation +func NewGetAllTCPResponseRuleBackend(ctx *middleware.Context, handler GetAllTCPResponseRuleBackendHandler) *GetAllTCPResponseRuleBackend { + return &GetAllTCPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetAllTCPResponseRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/tcp_response_rules TCPResponseRule getAllTcpResponseRuleBackend + +# Return an array of all TCP Response Rules + +Returns all TCP Response Rules that are configured in specified backend. +*/ +type GetAllTCPResponseRuleBackend struct { + Context *middleware.Context + Handler GetAllTCPResponseRuleBackendHandler +} + +func (o *GetAllTCPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllTCPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_backend_parameters.go b/operations/tcp_response_rule/get_all_tcp_response_rule_backend_parameters.go new file mode 100644 index 00000000..ea8ca33b --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_backend_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllTCPResponseRuleBackendParams creates a new GetAllTCPResponseRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetAllTCPResponseRuleBackendParams() GetAllTCPResponseRuleBackendParams { + + return GetAllTCPResponseRuleBackendParams{} +} + +// GetAllTCPResponseRuleBackendParams contains all the bound params for the get all TCP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllTCPResponseRuleBackend +type GetAllTCPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllTCPResponseRuleBackendParams() beforehand. +func (o *GetAllTCPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllTCPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllTCPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_backend_responses.go b/operations/tcp_response_rule/get_all_tcp_response_rule_backend_responses.go new file mode 100644 index 00000000..abafdf6f --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_backend_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllTCPResponseRuleBackendOKCode is the HTTP code returned for type GetAllTCPResponseRuleBackendOK +const GetAllTCPResponseRuleBackendOKCode int = 200 + +/* +GetAllTCPResponseRuleBackendOK Successful operation + +swagger:response getAllTcpResponseRuleBackendOK +*/ +type GetAllTCPResponseRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.TCPResponseRules `json:"body,omitempty"` +} + +// NewGetAllTCPResponseRuleBackendOK creates GetAllTCPResponseRuleBackendOK with default headers values +func NewGetAllTCPResponseRuleBackendOK() *GetAllTCPResponseRuleBackendOK { + + return &GetAllTCPResponseRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Tcp response rule backend o k response +func (o *GetAllTCPResponseRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetAllTCPResponseRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Tcp response rule backend o k response +func (o *GetAllTCPResponseRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Tcp response rule backend o k response +func (o *GetAllTCPResponseRuleBackendOK) WithPayload(payload models.TCPResponseRules) *GetAllTCPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Tcp response rule backend o k response +func (o *GetAllTCPResponseRuleBackendOK) SetPayload(payload models.TCPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllTCPResponseRuleBackendDefault General Error + +swagger:response getAllTcpResponseRuleBackendDefault +*/ +type GetAllTCPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllTCPResponseRuleBackendDefault creates GetAllTCPResponseRuleBackendDefault with default headers values +func NewGetAllTCPResponseRuleBackendDefault(code int) *GetAllTCPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetAllTCPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all TCP response rule backend default response +func (o *GetAllTCPResponseRuleBackendDefault) WithStatusCode(code int) *GetAllTCPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all TCP response rule backend default response +func (o *GetAllTCPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all TCP response rule backend default response +func (o *GetAllTCPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetAllTCPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all TCP response rule backend default response +func (o *GetAllTCPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all TCP response rule backend default response +func (o *GetAllTCPResponseRuleBackendDefault) WithPayload(payload *models.Error) *GetAllTCPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all TCP response rule backend default response +func (o *GetAllTCPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_backend_urlbuilder.go b/operations/tcp_response_rule/get_all_tcp_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..36fbf779 --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_backend_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllTCPResponseRuleBackendURL generates an URL for the get all TCP response rule backend operation +type GetAllTCPResponseRuleBackendURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPResponseRuleBackendURL) WithBasePath(bp string) *GetAllTCPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllTCPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllTCPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllTCPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllTCPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllTCPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllTCPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllTCPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllTCPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_defaults.go b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults.go new file mode 100644 index 00000000..933a8b4e --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetAllTCPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a get all TCP response rule defaults handler +type GetAllTCPResponseRuleDefaultsHandlerFunc func(GetAllTCPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAllTCPResponseRuleDefaultsHandlerFunc) Handle(params GetAllTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetAllTCPResponseRuleDefaultsHandler interface for that can handle valid get all TCP response rule defaults params +type GetAllTCPResponseRuleDefaultsHandler interface { + Handle(GetAllTCPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetAllTCPResponseRuleDefaults creates a new http.Handler for the get all TCP response rule defaults operation +func NewGetAllTCPResponseRuleDefaults(ctx *middleware.Context, handler GetAllTCPResponseRuleDefaultsHandler) *GetAllTCPResponseRuleDefaults { + return &GetAllTCPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetAllTCPResponseRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules TCPResponseRule getAllTcpResponseRuleDefaults + +# Return an array of all TCP Response Rules + +Returns all TCP Response Rules that are configured in specified backend. +*/ +type GetAllTCPResponseRuleDefaults struct { + Context *middleware.Context + Handler GetAllTCPResponseRuleDefaultsHandler +} + +func (o *GetAllTCPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAllTCPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_parameters.go b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_parameters.go new file mode 100644 index 00000000..dc8b543b --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_parameters.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewGetAllTCPResponseRuleDefaultsParams creates a new GetAllTCPResponseRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetAllTCPResponseRuleDefaultsParams() GetAllTCPResponseRuleDefaultsParams { + + return GetAllTCPResponseRuleDefaultsParams{} +} + +// GetAllTCPResponseRuleDefaultsParams contains all the bound params for the get all TCP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAllTCPResponseRuleDefaults +type GetAllTCPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetAllTCPResponseRuleDefaultsParams() beforehand. +func (o *GetAllTCPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetAllTCPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetAllTCPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_responses.go b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_responses.go new file mode 100644 index 00000000..d6e92501 --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetAllTCPResponseRuleDefaultsOKCode is the HTTP code returned for type GetAllTCPResponseRuleDefaultsOK +const GetAllTCPResponseRuleDefaultsOKCode int = 200 + +/* +GetAllTCPResponseRuleDefaultsOK Successful operation + +swagger:response getAllTcpResponseRuleDefaultsOK +*/ +type GetAllTCPResponseRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.TCPResponseRules `json:"body,omitempty"` +} + +// NewGetAllTCPResponseRuleDefaultsOK creates GetAllTCPResponseRuleDefaultsOK with default headers values +func NewGetAllTCPResponseRuleDefaultsOK() *GetAllTCPResponseRuleDefaultsOK { + + return &GetAllTCPResponseRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get all Tcp response rule defaults o k response +func (o *GetAllTCPResponseRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetAllTCPResponseRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all Tcp response rule defaults o k response +func (o *GetAllTCPResponseRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all Tcp response rule defaults o k response +func (o *GetAllTCPResponseRuleDefaultsOK) WithPayload(payload models.TCPResponseRules) *GetAllTCPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all Tcp response rule defaults o k response +func (o *GetAllTCPResponseRuleDefaultsOK) SetPayload(payload models.TCPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetAllTCPResponseRuleDefaultsDefault General Error + +swagger:response getAllTcpResponseRuleDefaultsDefault +*/ +type GetAllTCPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetAllTCPResponseRuleDefaultsDefault creates GetAllTCPResponseRuleDefaultsDefault with default headers values +func NewGetAllTCPResponseRuleDefaultsDefault(code int) *GetAllTCPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetAllTCPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get all TCP response rule defaults default response +func (o *GetAllTCPResponseRuleDefaultsDefault) WithStatusCode(code int) *GetAllTCPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get all TCP response rule defaults default response +func (o *GetAllTCPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get all TCP response rule defaults default response +func (o *GetAllTCPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetAllTCPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get all TCP response rule defaults default response +func (o *GetAllTCPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get all TCP response rule defaults default response +func (o *GetAllTCPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *GetAllTCPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get all TCP response rule defaults default response +func (o *GetAllTCPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAllTCPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_urlbuilder.go b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..471a60ec --- /dev/null +++ b/operations/tcp_response_rule/get_all_tcp_response_rule_defaults_urlbuilder.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetAllTCPResponseRuleDefaultsURL generates an URL for the get all TCP response rule defaults operation +type GetAllTCPResponseRuleDefaultsURL struct { + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPResponseRuleDefaultsURL) WithBasePath(bp string) *GetAllTCPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetAllTCPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAllTCPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetAllTCPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetAllTCPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetAllTCPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAllTCPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAllTCPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAllTCPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetAllTCPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule.go b/operations/tcp_response_rule/get_tcp_response_rule.go deleted file mode 100644 index bad9f5e3..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rule.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetTCPResponseRuleHandlerFunc turns a function with the right signature into a get TCP response rule handler -type GetTCPResponseRuleHandlerFunc func(GetTCPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetTCPResponseRuleHandlerFunc) Handle(params GetTCPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetTCPResponseRuleHandler interface for that can handle valid get TCP response rule params -type GetTCPResponseRuleHandler interface { - Handle(GetTCPResponseRuleParams, interface{}) middleware.Responder -} - -// NewGetTCPResponseRule creates a new http.Handler for the get TCP response rule operation -func NewGetTCPResponseRule(ctx *middleware.Context, handler GetTCPResponseRuleHandler) *GetTCPResponseRule { - return &GetTCPResponseRule{Context: ctx, Handler: handler} -} - -/*GetTCPResponseRule swagger:route GET /services/haproxy/configuration/tcp_response_rules/{id} TCPResponseRule getTcpResponseRule - -Return one TCP Response Rule - -Returns one TCP Response Rule configuration by it's ID in the specified backend. - -*/ -type GetTCPResponseRule struct { - Context *middleware.Context - Handler GetTCPResponseRuleHandler -} - -func (o *GetTCPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetTCPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetTCPResponseRuleOKBody get TCP response rule o k body -// swagger:model GetTCPResponseRuleOKBody -type GetTCPResponseRuleOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - Data *models.TCPResponseRule `json:"data,omitempty"` -} - -// Validate validates this get TCP response rule o k body -func (o *GetTCPResponseRuleOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetTCPResponseRuleOKBody) validateData(formats strfmt.Registry) error { - - if swag.IsZero(o.Data) { // not required - return nil - } - - if o.Data != nil { - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getTcpResponseRuleOK" + "." + "data") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetTCPResponseRuleOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetTCPResponseRuleOKBody) UnmarshalBinary(b []byte) error { - var res GetTCPResponseRuleOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_backend.go b/operations/tcp_response_rule/get_tcp_response_rule_backend.go new file mode 100644 index 00000000..3d2f86c0 --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTCPResponseRuleBackendHandlerFunc turns a function with the right signature into a get TCP response rule backend handler +type GetTCPResponseRuleBackendHandlerFunc func(GetTCPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTCPResponseRuleBackendHandlerFunc) Handle(params GetTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTCPResponseRuleBackendHandler interface for that can handle valid get TCP response rule backend params +type GetTCPResponseRuleBackendHandler interface { + Handle(GetTCPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewGetTCPResponseRuleBackend creates a new http.Handler for the get TCP response rule backend operation +func NewGetTCPResponseRuleBackend(ctx *middleware.Context, handler GetTCPResponseRuleBackendHandler) *GetTCPResponseRuleBackend { + return &GetTCPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + GetTCPResponseRuleBackend swagger:route GET /services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index} TCPResponseRule getTcpResponseRuleBackend + +# Return one TCP Response Rule + +Returns one TCP Response Rule configuration by it's index in the specified backend. +*/ +type GetTCPResponseRuleBackend struct { + Context *middleware.Context + Handler GetTCPResponseRuleBackendHandler +} + +func (o *GetTCPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTCPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_backend_parameters.go b/operations/tcp_response_rule/get_tcp_response_rule_backend_parameters.go new file mode 100644 index 00000000..55cc0465 --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_backend_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTCPResponseRuleBackendParams creates a new GetTCPResponseRuleBackendParams object +// +// There are no default values defined in the spec. +func NewGetTCPResponseRuleBackendParams() GetTCPResponseRuleBackendParams { + + return GetTCPResponseRuleBackendParams{} +} + +// GetTCPResponseRuleBackendParams contains all the bound params for the get TCP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTCPResponseRuleBackend +type GetTCPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTCPResponseRuleBackendParams() beforehand. +func (o *GetTCPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetTCPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTCPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTCPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_backend_responses.go b/operations/tcp_response_rule/get_tcp_response_rule_backend_responses.go new file mode 100644 index 00000000..b93c0d24 --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_backend_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTCPResponseRuleBackendOKCode is the HTTP code returned for type GetTCPResponseRuleBackendOK +const GetTCPResponseRuleBackendOKCode int = 200 + +/* +GetTCPResponseRuleBackendOK Successful operation + +swagger:response getTcpResponseRuleBackendOK +*/ +type GetTCPResponseRuleBackendOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewGetTCPResponseRuleBackendOK creates GetTCPResponseRuleBackendOK with default headers values +func NewGetTCPResponseRuleBackendOK() *GetTCPResponseRuleBackendOK { + + return &GetTCPResponseRuleBackendOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp response rule backend o k response +func (o *GetTCPResponseRuleBackendOK) WithConfigurationVersion(configurationVersion string) *GetTCPResponseRuleBackendOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp response rule backend o k response +func (o *GetTCPResponseRuleBackendOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp response rule backend o k response +func (o *GetTCPResponseRuleBackendOK) WithPayload(payload *models.TCPResponseRule) *GetTCPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp response rule backend o k response +func (o *GetTCPResponseRuleBackendOK) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTCPResponseRuleBackendNotFoundCode is the HTTP code returned for type GetTCPResponseRuleBackendNotFound +const GetTCPResponseRuleBackendNotFoundCode int = 404 + +/* +GetTCPResponseRuleBackendNotFound The specified resource was not found + +swagger:response getTcpResponseRuleBackendNotFound +*/ +type GetTCPResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPResponseRuleBackendNotFound creates GetTCPResponseRuleBackendNotFound with default headers values +func NewGetTCPResponseRuleBackendNotFound() *GetTCPResponseRuleBackendNotFound { + + return &GetTCPResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp response rule backend not found response +func (o *GetTCPResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *GetTCPResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp response rule backend not found response +func (o *GetTCPResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp response rule backend not found response +func (o *GetTCPResponseRuleBackendNotFound) WithPayload(payload *models.Error) *GetTCPResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp response rule backend not found response +func (o *GetTCPResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTCPResponseRuleBackendDefault General Error + +swagger:response getTcpResponseRuleBackendDefault +*/ +type GetTCPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPResponseRuleBackendDefault creates GetTCPResponseRuleBackendDefault with default headers values +func NewGetTCPResponseRuleBackendDefault(code int) *GetTCPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &GetTCPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get TCP response rule backend default response +func (o *GetTCPResponseRuleBackendDefault) WithStatusCode(code int) *GetTCPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get TCP response rule backend default response +func (o *GetTCPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get TCP response rule backend default response +func (o *GetTCPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *GetTCPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get TCP response rule backend default response +func (o *GetTCPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get TCP response rule backend default response +func (o *GetTCPResponseRuleBackendDefault) WithPayload(payload *models.Error) *GetTCPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get TCP response rule backend default response +func (o *GetTCPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_backend_urlbuilder.go b/operations/tcp_response_rule/get_tcp_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..9df06942 --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_backend_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetTCPResponseRuleBackendURL generates an URL for the get TCP response rule backend operation +type GetTCPResponseRuleBackendURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPResponseRuleBackendURL) WithBasePath(bp string) *GetTCPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTCPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetTCPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTCPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTCPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTCPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTCPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTCPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTCPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTCPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_defaults.go b/operations/tcp_response_rule/get_tcp_response_rule_defaults.go new file mode 100644 index 00000000..e3ecd11a --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTCPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a get TCP response rule defaults handler +type GetTCPResponseRuleDefaultsHandlerFunc func(GetTCPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTCPResponseRuleDefaultsHandlerFunc) Handle(params GetTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTCPResponseRuleDefaultsHandler interface for that can handle valid get TCP response rule defaults params +type GetTCPResponseRuleDefaultsHandler interface { + Handle(GetTCPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewGetTCPResponseRuleDefaults creates a new http.Handler for the get TCP response rule defaults operation +func NewGetTCPResponseRuleDefaults(ctx *middleware.Context, handler GetTCPResponseRuleDefaultsHandler) *GetTCPResponseRuleDefaults { + return &GetTCPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + GetTCPResponseRuleDefaults swagger:route GET /services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index} TCPResponseRule getTcpResponseRuleDefaults + +# Return one TCP Response Rule + +Returns one TCP Response Rule configuration by it's index in the specified backend. +*/ +type GetTCPResponseRuleDefaults struct { + Context *middleware.Context + Handler GetTCPResponseRuleDefaultsHandler +} + +func (o *GetTCPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTCPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_defaults_parameters.go b/operations/tcp_response_rule/get_tcp_response_rule_defaults_parameters.go new file mode 100644 index 00000000..be37635f --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_defaults_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTCPResponseRuleDefaultsParams creates a new GetTCPResponseRuleDefaultsParams object +// +// There are no default values defined in the spec. +func NewGetTCPResponseRuleDefaultsParams() GetTCPResponseRuleDefaultsParams { + + return GetTCPResponseRuleDefaultsParams{} +} + +// GetTCPResponseRuleDefaultsParams contains all the bound params for the get TCP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTCPResponseRuleDefaults +type GetTCPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTCPResponseRuleDefaultsParams() beforehand. +func (o *GetTCPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *GetTCPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *GetTCPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTCPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_defaults_responses.go b/operations/tcp_response_rule/get_tcp_response_rule_defaults_responses.go new file mode 100644 index 00000000..f6f7bfe5 --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_defaults_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTCPResponseRuleDefaultsOKCode is the HTTP code returned for type GetTCPResponseRuleDefaultsOK +const GetTCPResponseRuleDefaultsOKCode int = 200 + +/* +GetTCPResponseRuleDefaultsOK Successful operation + +swagger:response getTcpResponseRuleDefaultsOK +*/ +type GetTCPResponseRuleDefaultsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewGetTCPResponseRuleDefaultsOK creates GetTCPResponseRuleDefaultsOK with default headers values +func NewGetTCPResponseRuleDefaultsOK() *GetTCPResponseRuleDefaultsOK { + + return &GetTCPResponseRuleDefaultsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp response rule defaults o k response +func (o *GetTCPResponseRuleDefaultsOK) WithConfigurationVersion(configurationVersion string) *GetTCPResponseRuleDefaultsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp response rule defaults o k response +func (o *GetTCPResponseRuleDefaultsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp response rule defaults o k response +func (o *GetTCPResponseRuleDefaultsOK) WithPayload(payload *models.TCPResponseRule) *GetTCPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp response rule defaults o k response +func (o *GetTCPResponseRuleDefaultsOK) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTCPResponseRuleDefaultsNotFoundCode is the HTTP code returned for type GetTCPResponseRuleDefaultsNotFound +const GetTCPResponseRuleDefaultsNotFoundCode int = 404 + +/* +GetTCPResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response getTcpResponseRuleDefaultsNotFound +*/ +type GetTCPResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPResponseRuleDefaultsNotFound creates GetTCPResponseRuleDefaultsNotFound with default headers values +func NewGetTCPResponseRuleDefaultsNotFound() *GetTCPResponseRuleDefaultsNotFound { + + return &GetTCPResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get Tcp response rule defaults not found response +func (o *GetTCPResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *GetTCPResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get Tcp response rule defaults not found response +func (o *GetTCPResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get Tcp response rule defaults not found response +func (o *GetTCPResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *GetTCPResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get Tcp response rule defaults not found response +func (o *GetTCPResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTCPResponseRuleDefaultsDefault General Error + +swagger:response getTcpResponseRuleDefaultsDefault +*/ +type GetTCPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTCPResponseRuleDefaultsDefault creates GetTCPResponseRuleDefaultsDefault with default headers values +func NewGetTCPResponseRuleDefaultsDefault(code int) *GetTCPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &GetTCPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get TCP response rule defaults default response +func (o *GetTCPResponseRuleDefaultsDefault) WithStatusCode(code int) *GetTCPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get TCP response rule defaults default response +func (o *GetTCPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get TCP response rule defaults default response +func (o *GetTCPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *GetTCPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get TCP response rule defaults default response +func (o *GetTCPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get TCP response rule defaults default response +func (o *GetTCPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *GetTCPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get TCP response rule defaults default response +func (o *GetTCPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTCPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_defaults_urlbuilder.go b/operations/tcp_response_rule/get_tcp_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..90041f71 --- /dev/null +++ b/operations/tcp_response_rule/get_tcp_response_rule_defaults_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetTCPResponseRuleDefaultsURL generates an URL for the get TCP response rule defaults operation +type GetTCPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPResponseRuleDefaultsURL) WithBasePath(bp string) *GetTCPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTCPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTCPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on GetTCPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on GetTCPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTCPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTCPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTCPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTCPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTCPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTCPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_parameters.go b/operations/tcp_response_rule/get_tcp_response_rule_parameters.go deleted file mode 100644 index cc5b0b9b..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rule_parameters.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetTCPResponseRuleParams creates a new GetTCPResponseRuleParams object -// no default values defined in spec. -func NewGetTCPResponseRuleParams() GetTCPResponseRuleParams { - - return GetTCPResponseRuleParams{} -} - -// GetTCPResponseRuleParams contains all the bound params for the get TCP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters getTCPResponseRule -type GetTCPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /*TCP Response Rule ID - Required: true - In: path - */ - ID int64 - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetTCPResponseRuleParams() beforehand. -func (o *GetTCPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *GetTCPResponseRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *GetTCPResponseRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetTCPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_responses.go b/operations/tcp_response_rule/get_tcp_response_rule_responses.go deleted file mode 100644 index 7258b7e1..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rule_responses.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetTCPResponseRuleOKCode is the HTTP code returned for type GetTCPResponseRuleOK -const GetTCPResponseRuleOKCode int = 200 - -/*GetTCPResponseRuleOK Successful operation - -swagger:response getTcpResponseRuleOK -*/ -type GetTCPResponseRuleOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetTCPResponseRuleOKBody `json:"body,omitempty"` -} - -// NewGetTCPResponseRuleOK creates GetTCPResponseRuleOK with default headers values -func NewGetTCPResponseRuleOK() *GetTCPResponseRuleOK { - - return &GetTCPResponseRuleOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Tcp response rule o k response -func (o *GetTCPResponseRuleOK) WithConfigurationVersion(configurationVersion int64) *GetTCPResponseRuleOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Tcp response rule o k response -func (o *GetTCPResponseRuleOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Tcp response rule o k response -func (o *GetTCPResponseRuleOK) WithPayload(payload *GetTCPResponseRuleOKBody) *GetTCPResponseRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Tcp response rule o k response -func (o *GetTCPResponseRuleOK) SetPayload(payload *GetTCPResponseRuleOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPResponseRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// GetTCPResponseRuleNotFoundCode is the HTTP code returned for type GetTCPResponseRuleNotFound -const GetTCPResponseRuleNotFoundCode int = 404 - -/*GetTCPResponseRuleNotFound The specified resource was not found - -swagger:response getTcpResponseRuleNotFound -*/ -type GetTCPResponseRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetTCPResponseRuleNotFound creates GetTCPResponseRuleNotFound with default headers values -func NewGetTCPResponseRuleNotFound() *GetTCPResponseRuleNotFound { - - return &GetTCPResponseRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Tcp response rule not found response -func (o *GetTCPResponseRuleNotFound) WithConfigurationVersion(configurationVersion int64) *GetTCPResponseRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Tcp response rule not found response -func (o *GetTCPResponseRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Tcp response rule not found response -func (o *GetTCPResponseRuleNotFound) WithPayload(payload *models.Error) *GetTCPResponseRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Tcp response rule not found response -func (o *GetTCPResponseRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPResponseRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetTCPResponseRuleDefault General Error - -swagger:response getTcpResponseRuleDefault -*/ -type GetTCPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetTCPResponseRuleDefault creates GetTCPResponseRuleDefault with default headers values -func NewGetTCPResponseRuleDefault(code int) *GetTCPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &GetTCPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get TCP response rule default response -func (o *GetTCPResponseRuleDefault) WithStatusCode(code int) *GetTCPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get TCP response rule default response -func (o *GetTCPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get TCP response rule default response -func (o *GetTCPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *GetTCPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get TCP response rule default response -func (o *GetTCPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get TCP response rule default response -func (o *GetTCPResponseRuleDefault) WithPayload(payload *models.Error) *GetTCPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get TCP response rule default response -func (o *GetTCPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_response_rule/get_tcp_response_rule_urlbuilder.go b/operations/tcp_response_rule/get_tcp_response_rule_urlbuilder.go deleted file mode 100644 index e19d58d5..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rule_urlbuilder.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// GetTCPResponseRuleURL generates an URL for the get TCP response rule operation -type GetTCPResponseRuleURL struct { - ID int64 - - Backend string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPResponseRuleURL) WithBasePath(bp string) *GetTCPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetTCPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_response_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on GetTCPResponseRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetTCPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetTCPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetTCPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetTCPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetTCPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetTCPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_response_rule/get_tcp_response_rules.go b/operations/tcp_response_rule/get_tcp_response_rules.go deleted file mode 100644 index 1b05a1e1..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rules.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - errors "github.com/go-openapi/errors" - middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" - swag "github.com/go-openapi/swag" - validate "github.com/go-openapi/validate" - - "github.com/haproxytech/models" -) - -// GetTCPResponseRulesHandlerFunc turns a function with the right signature into a get TCP response rules handler -type GetTCPResponseRulesHandlerFunc func(GetTCPResponseRulesParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetTCPResponseRulesHandlerFunc) Handle(params GetTCPResponseRulesParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// GetTCPResponseRulesHandler interface for that can handle valid get TCP response rules params -type GetTCPResponseRulesHandler interface { - Handle(GetTCPResponseRulesParams, interface{}) middleware.Responder -} - -// NewGetTCPResponseRules creates a new http.Handler for the get TCP response rules operation -func NewGetTCPResponseRules(ctx *middleware.Context, handler GetTCPResponseRulesHandler) *GetTCPResponseRules { - return &GetTCPResponseRules{Context: ctx, Handler: handler} -} - -/*GetTCPResponseRules swagger:route GET /services/haproxy/configuration/tcp_response_rules TCPResponseRule getTcpResponseRules - -Return an array of all TCP Response Rules - -Returns all TCP Response Rules that are configured in specified backend. - -*/ -type GetTCPResponseRules struct { - Context *middleware.Context - Handler GetTCPResponseRulesHandler -} - -func (o *GetTCPResponseRules) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewGetTCPResponseRulesParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} - -// GetTCPResponseRulesOKBody get TCP response rules o k body -// swagger:model GetTCPResponseRulesOKBody -type GetTCPResponseRulesOKBody struct { - - // version - Version int64 `json:"_version,omitempty"` - - // data - // Required: true - Data models.TCPResponseRules `json:"data"` -} - -// Validate validates this get TCP response rules o k body -func (o *GetTCPResponseRulesOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if err := o.validateData(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (o *GetTCPResponseRulesOKBody) validateData(formats strfmt.Registry) error { - - if err := validate.Required("getTcpResponseRulesOK"+"."+"data", "body", o.Data); err != nil { - return err - } - - if err := o.Data.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("getTcpResponseRulesOK" + "." + "data") - } - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (o *GetTCPResponseRulesOKBody) MarshalBinary() ([]byte, error) { - if o == nil { - return nil, nil - } - return swag.WriteJSON(o) -} - -// UnmarshalBinary interface implementation -func (o *GetTCPResponseRulesOKBody) UnmarshalBinary(b []byte) error { - var res GetTCPResponseRulesOKBody - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *o = res - return nil -} diff --git a/operations/tcp_response_rule/get_tcp_response_rules_parameters.go b/operations/tcp_response_rule/get_tcp_response_rules_parameters.go deleted file mode 100644 index 14bfd60c..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rules_parameters.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" -) - -// NewGetTCPResponseRulesParams creates a new GetTCPResponseRulesParams object -// no default values defined in spec. -func NewGetTCPResponseRulesParams() GetTCPResponseRulesParams { - - return GetTCPResponseRulesParams{} -} - -// GetTCPResponseRulesParams contains all the bound params for the get TCP response rules operation -// typically these are obtained from a http.Request -// -// swagger:parameters getTCPResponseRules -type GetTCPResponseRulesParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewGetTCPResponseRulesParams() beforehand. -func (o *GetTCPResponseRulesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *GetTCPResponseRulesParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *GetTCPResponseRulesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} diff --git a/operations/tcp_response_rule/get_tcp_response_rules_responses.go b/operations/tcp_response_rule/get_tcp_response_rules_responses.go deleted file mode 100644 index d66ab08f..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rules_responses.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// GetTCPResponseRulesOKCode is the HTTP code returned for type GetTCPResponseRulesOK -const GetTCPResponseRulesOKCode int = 200 - -/*GetTCPResponseRulesOK Successful operation - -swagger:response getTcpResponseRulesOK -*/ -type GetTCPResponseRulesOK struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *GetTCPResponseRulesOKBody `json:"body,omitempty"` -} - -// NewGetTCPResponseRulesOK creates GetTCPResponseRulesOK with default headers values -func NewGetTCPResponseRulesOK() *GetTCPResponseRulesOK { - - return &GetTCPResponseRulesOK{} -} - -// WithConfigurationVersion adds the configurationVersion to the get Tcp response rules o k response -func (o *GetTCPResponseRulesOK) WithConfigurationVersion(configurationVersion int64) *GetTCPResponseRulesOK { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get Tcp response rules o k response -func (o *GetTCPResponseRulesOK) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get Tcp response rules o k response -func (o *GetTCPResponseRulesOK) WithPayload(payload *GetTCPResponseRulesOKBody) *GetTCPResponseRulesOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get Tcp response rules o k response -func (o *GetTCPResponseRulesOK) SetPayload(payload *GetTCPResponseRulesOKBody) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPResponseRulesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*GetTCPResponseRulesDefault General Error - -swagger:response getTcpResponseRulesDefault -*/ -type GetTCPResponseRulesDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewGetTCPResponseRulesDefault creates GetTCPResponseRulesDefault with default headers values -func NewGetTCPResponseRulesDefault(code int) *GetTCPResponseRulesDefault { - if code <= 0 { - code = 500 - } - - return &GetTCPResponseRulesDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get TCP response rules default response -func (o *GetTCPResponseRulesDefault) WithStatusCode(code int) *GetTCPResponseRulesDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get TCP response rules default response -func (o *GetTCPResponseRulesDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the get TCP response rules default response -func (o *GetTCPResponseRulesDefault) WithConfigurationVersion(configurationVersion int64) *GetTCPResponseRulesDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the get TCP response rules default response -func (o *GetTCPResponseRulesDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the get TCP response rules default response -func (o *GetTCPResponseRulesDefault) WithPayload(payload *models.Error) *GetTCPResponseRulesDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get TCP response rules default response -func (o *GetTCPResponseRulesDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetTCPResponseRulesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_response_rule/get_tcp_response_rules_urlbuilder.go b/operations/tcp_response_rule/get_tcp_response_rules_urlbuilder.go deleted file mode 100644 index 34944cc5..00000000 --- a/operations/tcp_response_rule/get_tcp_response_rules_urlbuilder.go +++ /dev/null @@ -1,124 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" -) - -// GetTCPResponseRulesURL generates an URL for the get TCP response rules operation -type GetTCPResponseRulesURL struct { - Backend string - TransactionID *string - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPResponseRulesURL) WithBasePath(bp string) *GetTCPResponseRulesURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *GetTCPResponseRulesURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetTCPResponseRulesURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_response_rules" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *GetTCPResponseRulesURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *GetTCPResponseRulesURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetTCPResponseRulesURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetTCPResponseRulesURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetTCPResponseRulesURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *GetTCPResponseRulesURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_backend.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend.go new file mode 100644 index 00000000..72d958c8 --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllTCPResponseRuleBackendHandlerFunc turns a function with the right signature into a replace all TCP response rule backend handler +type ReplaceAllTCPResponseRuleBackendHandlerFunc func(ReplaceAllTCPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllTCPResponseRuleBackendHandlerFunc) Handle(params ReplaceAllTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllTCPResponseRuleBackendHandler interface for that can handle valid replace all TCP response rule backend params +type ReplaceAllTCPResponseRuleBackendHandler interface { + Handle(ReplaceAllTCPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceAllTCPResponseRuleBackend creates a new http.Handler for the replace all TCP response rule backend operation +func NewReplaceAllTCPResponseRuleBackend(ctx *middleware.Context, handler ReplaceAllTCPResponseRuleBackendHandler) *ReplaceAllTCPResponseRuleBackend { + return &ReplaceAllTCPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceAllTCPResponseRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/tcp_response_rules TCPResponseRule replaceAllTcpResponseRuleBackend + +# Replace a TCP Response Rule list + +Replaces a whole list of TCP Response Rules with the list given in parameter +*/ +type ReplaceAllTCPResponseRuleBackend struct { + Context *middleware.Context + Handler ReplaceAllTCPResponseRuleBackendHandler +} + +func (o *ReplaceAllTCPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllTCPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_parameters.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_parameters.go new file mode 100644 index 00000000..eccae8c8 --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllTCPResponseRuleBackendParams creates a new ReplaceAllTCPResponseRuleBackendParams object +// with the default values initialized. +func NewReplaceAllTCPResponseRuleBackendParams() ReplaceAllTCPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllTCPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllTCPResponseRuleBackendParams contains all the bound params for the replace all TCP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllTCPResponseRuleBackend +type ReplaceAllTCPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.TCPResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllTCPResponseRuleBackendParams() beforehand. +func (o *ReplaceAllTCPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllTCPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllTCPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllTCPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllTCPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllTCPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_responses.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_responses.go new file mode 100644 index 00000000..9ebcba00 --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllTCPResponseRuleBackendOKCode is the HTTP code returned for type ReplaceAllTCPResponseRuleBackendOK +const ReplaceAllTCPResponseRuleBackendOKCode int = 200 + +/* +ReplaceAllTCPResponseRuleBackendOK All TCP Response Rule lines replaced + +swagger:response replaceAllTcpResponseRuleBackendOK +*/ +type ReplaceAllTCPResponseRuleBackendOK struct { + + /* + In: Body + */ + Payload models.TCPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleBackendOK creates ReplaceAllTCPResponseRuleBackendOK with default headers values +func NewReplaceAllTCPResponseRuleBackendOK() *ReplaceAllTCPResponseRuleBackendOK { + + return &ReplaceAllTCPResponseRuleBackendOK{} +} + +// WithPayload adds the payload to the replace all Tcp response rule backend o k response +func (o *ReplaceAllTCPResponseRuleBackendOK) WithPayload(payload models.TCPResponseRules) *ReplaceAllTCPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp response rule backend o k response +func (o *ReplaceAllTCPResponseRuleBackendOK) SetPayload(payload models.TCPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPResponseRuleBackendAcceptedCode is the HTTP code returned for type ReplaceAllTCPResponseRuleBackendAccepted +const ReplaceAllTCPResponseRuleBackendAcceptedCode int = 202 + +/* +ReplaceAllTCPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceAllTcpResponseRuleBackendAccepted +*/ +type ReplaceAllTCPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.TCPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleBackendAccepted creates ReplaceAllTCPResponseRuleBackendAccepted with default headers values +func NewReplaceAllTCPResponseRuleBackendAccepted() *ReplaceAllTCPResponseRuleBackendAccepted { + + return &ReplaceAllTCPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Tcp response rule backend accepted response +func (o *ReplaceAllTCPResponseRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceAllTCPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Tcp response rule backend accepted response +func (o *ReplaceAllTCPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Tcp response rule backend accepted response +func (o *ReplaceAllTCPResponseRuleBackendAccepted) WithPayload(payload models.TCPResponseRules) *ReplaceAllTCPResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp response rule backend accepted response +func (o *ReplaceAllTCPResponseRuleBackendAccepted) SetPayload(payload models.TCPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPResponseRuleBackendBadRequestCode is the HTTP code returned for type ReplaceAllTCPResponseRuleBackendBadRequest +const ReplaceAllTCPResponseRuleBackendBadRequestCode int = 400 + +/* +ReplaceAllTCPResponseRuleBackendBadRequest Bad request + +swagger:response replaceAllTcpResponseRuleBackendBadRequest +*/ +type ReplaceAllTCPResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleBackendBadRequest creates ReplaceAllTCPResponseRuleBackendBadRequest with default headers values +func NewReplaceAllTCPResponseRuleBackendBadRequest() *ReplaceAllTCPResponseRuleBackendBadRequest { + + return &ReplaceAllTCPResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Tcp response rule backend bad request response +func (o *ReplaceAllTCPResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Tcp response rule backend bad request response +func (o *ReplaceAllTCPResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Tcp response rule backend bad request response +func (o *ReplaceAllTCPResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceAllTCPResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp response rule backend bad request response +func (o *ReplaceAllTCPResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllTCPResponseRuleBackendDefault General Error + +swagger:response replaceAllTcpResponseRuleBackendDefault +*/ +type ReplaceAllTCPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleBackendDefault creates ReplaceAllTCPResponseRuleBackendDefault with default headers values +func NewReplaceAllTCPResponseRuleBackendDefault(code int) *ReplaceAllTCPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllTCPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all TCP response rule backend default response +func (o *ReplaceAllTCPResponseRuleBackendDefault) WithStatusCode(code int) *ReplaceAllTCPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all TCP response rule backend default response +func (o *ReplaceAllTCPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all TCP response rule backend default response +func (o *ReplaceAllTCPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all TCP response rule backend default response +func (o *ReplaceAllTCPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all TCP response rule backend default response +func (o *ReplaceAllTCPResponseRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceAllTCPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all TCP response rule backend default response +func (o *ReplaceAllTCPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_urlbuilder.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..17300ead --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_backend_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllTCPResponseRuleBackendURL generates an URL for the replace all TCP response rule backend operation +type ReplaceAllTCPResponseRuleBackendURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPResponseRuleBackendURL) WithBasePath(bp string) *ReplaceAllTCPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllTCPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllTCPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllTCPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllTCPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllTCPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllTCPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllTCPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllTCPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults.go new file mode 100644 index 00000000..fb87a3ac --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceAllTCPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a replace all TCP response rule defaults handler +type ReplaceAllTCPResponseRuleDefaultsHandlerFunc func(ReplaceAllTCPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceAllTCPResponseRuleDefaultsHandlerFunc) Handle(params ReplaceAllTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceAllTCPResponseRuleDefaultsHandler interface for that can handle valid replace all TCP response rule defaults params +type ReplaceAllTCPResponseRuleDefaultsHandler interface { + Handle(ReplaceAllTCPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceAllTCPResponseRuleDefaults creates a new http.Handler for the replace all TCP response rule defaults operation +func NewReplaceAllTCPResponseRuleDefaults(ctx *middleware.Context, handler ReplaceAllTCPResponseRuleDefaultsHandler) *ReplaceAllTCPResponseRuleDefaults { + return &ReplaceAllTCPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceAllTCPResponseRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules TCPResponseRule replaceAllTcpResponseRuleDefaults + +# Replace a TCP Response Rule list + +Replaces a whole list of TCP Response Rules with the list given in parameter +*/ +type ReplaceAllTCPResponseRuleDefaults struct { + Context *middleware.Context + Handler ReplaceAllTCPResponseRuleDefaultsHandler +} + +func (o *ReplaceAllTCPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceAllTCPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_parameters.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_parameters.go new file mode 100644 index 00000000..e515668f --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_parameters.go @@ -0,0 +1,221 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceAllTCPResponseRuleDefaultsParams creates a new ReplaceAllTCPResponseRuleDefaultsParams object +// with the default values initialized. +func NewReplaceAllTCPResponseRuleDefaultsParams() ReplaceAllTCPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceAllTCPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceAllTCPResponseRuleDefaultsParams contains all the bound params for the replace all TCP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceAllTCPResponseRuleDefaults +type ReplaceAllTCPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data models.TCPResponseRules + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceAllTCPResponseRuleDefaultsParams() beforehand. +func (o *ReplaceAllTCPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPResponseRules + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceAllTCPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceAllTCPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceAllTCPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceAllTCPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceAllTCPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_responses.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_responses.go new file mode 100644 index 00000000..15bc7495 --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceAllTCPResponseRuleDefaultsOKCode is the HTTP code returned for type ReplaceAllTCPResponseRuleDefaultsOK +const ReplaceAllTCPResponseRuleDefaultsOKCode int = 200 + +/* +ReplaceAllTCPResponseRuleDefaultsOK All TCP Response Rule lines replaced + +swagger:response replaceAllTcpResponseRuleDefaultsOK +*/ +type ReplaceAllTCPResponseRuleDefaultsOK struct { + + /* + In: Body + */ + Payload models.TCPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleDefaultsOK creates ReplaceAllTCPResponseRuleDefaultsOK with default headers values +func NewReplaceAllTCPResponseRuleDefaultsOK() *ReplaceAllTCPResponseRuleDefaultsOK { + + return &ReplaceAllTCPResponseRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace all Tcp response rule defaults o k response +func (o *ReplaceAllTCPResponseRuleDefaultsOK) WithPayload(payload models.TCPResponseRules) *ReplaceAllTCPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp response rule defaults o k response +func (o *ReplaceAllTCPResponseRuleDefaultsOK) SetPayload(payload models.TCPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceAllTCPResponseRuleDefaultsAccepted +const ReplaceAllTCPResponseRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceAllTCPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceAllTcpResponseRuleDefaultsAccepted +*/ +type ReplaceAllTCPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload models.TCPResponseRules `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleDefaultsAccepted creates ReplaceAllTCPResponseRuleDefaultsAccepted with default headers values +func NewReplaceAllTCPResponseRuleDefaultsAccepted() *ReplaceAllTCPResponseRuleDefaultsAccepted { + + return &ReplaceAllTCPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace all Tcp response rule defaults accepted response +func (o *ReplaceAllTCPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceAllTCPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace all Tcp response rule defaults accepted response +func (o *ReplaceAllTCPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace all Tcp response rule defaults accepted response +func (o *ReplaceAllTCPResponseRuleDefaultsAccepted) WithPayload(payload models.TCPResponseRules) *ReplaceAllTCPResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp response rule defaults accepted response +func (o *ReplaceAllTCPResponseRuleDefaultsAccepted) SetPayload(payload models.TCPResponseRules) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.TCPResponseRules{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// ReplaceAllTCPResponseRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceAllTCPResponseRuleDefaultsBadRequest +const ReplaceAllTCPResponseRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceAllTCPResponseRuleDefaultsBadRequest Bad request + +swagger:response replaceAllTcpResponseRuleDefaultsBadRequest +*/ +type ReplaceAllTCPResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleDefaultsBadRequest creates ReplaceAllTCPResponseRuleDefaultsBadRequest with default headers values +func NewReplaceAllTCPResponseRuleDefaultsBadRequest() *ReplaceAllTCPResponseRuleDefaultsBadRequest { + + return &ReplaceAllTCPResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace all Tcp response rule defaults bad request response +func (o *ReplaceAllTCPResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all Tcp response rule defaults bad request response +func (o *ReplaceAllTCPResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all Tcp response rule defaults bad request response +func (o *ReplaceAllTCPResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceAllTCPResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all Tcp response rule defaults bad request response +func (o *ReplaceAllTCPResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceAllTCPResponseRuleDefaultsDefault General Error + +swagger:response replaceAllTcpResponseRuleDefaultsDefault +*/ +type ReplaceAllTCPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceAllTCPResponseRuleDefaultsDefault creates ReplaceAllTCPResponseRuleDefaultsDefault with default headers values +func NewReplaceAllTCPResponseRuleDefaultsDefault(code int) *ReplaceAllTCPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceAllTCPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace all TCP response rule defaults default response +func (o *ReplaceAllTCPResponseRuleDefaultsDefault) WithStatusCode(code int) *ReplaceAllTCPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace all TCP response rule defaults default response +func (o *ReplaceAllTCPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace all TCP response rule defaults default response +func (o *ReplaceAllTCPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceAllTCPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace all TCP response rule defaults default response +func (o *ReplaceAllTCPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace all TCP response rule defaults default response +func (o *ReplaceAllTCPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceAllTCPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace all TCP response rule defaults default response +func (o *ReplaceAllTCPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceAllTCPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_urlbuilder.go b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..43355561 --- /dev/null +++ b/operations/tcp_response_rule/replace_all_tcp_response_rule_defaults_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceAllTCPResponseRuleDefaultsURL generates an URL for the replace all TCP response rule defaults operation +type ReplaceAllTCPResponseRuleDefaultsURL struct { + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPResponseRuleDefaultsURL) WithBasePath(bp string) *ReplaceAllTCPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceAllTCPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceAllTCPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules" + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceAllTCPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceAllTCPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceAllTCPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceAllTCPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceAllTCPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceAllTCPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceAllTCPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule.go b/operations/tcp_response_rule/replace_tcp_response_rule.go deleted file mode 100644 index 4f513b77..00000000 --- a/operations/tcp_response_rule/replace_tcp_response_rule.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - middleware "github.com/go-openapi/runtime/middleware" -) - -// ReplaceTCPResponseRuleHandlerFunc turns a function with the right signature into a replace TCP response rule handler -type ReplaceTCPResponseRuleHandlerFunc func(ReplaceTCPResponseRuleParams, interface{}) middleware.Responder - -// Handle executing the request and returning a response -func (fn ReplaceTCPResponseRuleHandlerFunc) Handle(params ReplaceTCPResponseRuleParams, principal interface{}) middleware.Responder { - return fn(params, principal) -} - -// ReplaceTCPResponseRuleHandler interface for that can handle valid replace TCP response rule params -type ReplaceTCPResponseRuleHandler interface { - Handle(ReplaceTCPResponseRuleParams, interface{}) middleware.Responder -} - -// NewReplaceTCPResponseRule creates a new http.Handler for the replace TCP response rule operation -func NewReplaceTCPResponseRule(ctx *middleware.Context, handler ReplaceTCPResponseRuleHandler) *ReplaceTCPResponseRule { - return &ReplaceTCPResponseRule{Context: ctx, Handler: handler} -} - -/*ReplaceTCPResponseRule swagger:route PUT /services/haproxy/configuration/tcp_response_rules/{id} TCPResponseRule replaceTcpResponseRule - -Replace a TCP Response Rule - -Replaces a TCP Response Rule configuration by it's ID in the specified backend. - -*/ -type ReplaceTCPResponseRule struct { - Context *middleware.Context - Handler ReplaceTCPResponseRuleHandler -} - -func (o *ReplaceTCPResponseRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - r = rCtx - } - var Params = NewReplaceTCPResponseRuleParams() - - uprinc, aCtx, err := o.Context.Authorize(r, route) - if err != nil { - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - if aCtx != nil { - r = aCtx - } - var principal interface{} - if uprinc != nil { - principal = uprinc - } - - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params, principal) // actually handle the request - - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_backend.go b/operations/tcp_response_rule/replace_tcp_response_rule_backend.go new file mode 100644 index 00000000..0a6bf91a --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_backend.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTCPResponseRuleBackendHandlerFunc turns a function with the right signature into a replace TCP response rule backend handler +type ReplaceTCPResponseRuleBackendHandlerFunc func(ReplaceTCPResponseRuleBackendParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTCPResponseRuleBackendHandlerFunc) Handle(params ReplaceTCPResponseRuleBackendParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTCPResponseRuleBackendHandler interface for that can handle valid replace TCP response rule backend params +type ReplaceTCPResponseRuleBackendHandler interface { + Handle(ReplaceTCPResponseRuleBackendParams, interface{}) middleware.Responder +} + +// NewReplaceTCPResponseRuleBackend creates a new http.Handler for the replace TCP response rule backend operation +func NewReplaceTCPResponseRuleBackend(ctx *middleware.Context, handler ReplaceTCPResponseRuleBackendHandler) *ReplaceTCPResponseRuleBackend { + return &ReplaceTCPResponseRuleBackend{Context: ctx, Handler: handler} +} + +/* + ReplaceTCPResponseRuleBackend swagger:route PUT /services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index} TCPResponseRule replaceTcpResponseRuleBackend + +# Replace a TCP Response Rule + +Replaces a TCP Response Rule configuration by it's Index in the specified backend. +*/ +type ReplaceTCPResponseRuleBackend struct { + Context *middleware.Context + Handler ReplaceTCPResponseRuleBackendHandler +} + +func (o *ReplaceTCPResponseRuleBackend) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTCPResponseRuleBackendParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_backend_parameters.go b/operations/tcp_response_rule/replace_tcp_response_rule_backend_parameters.go new file mode 100644 index 00000000..b9141c45 --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_backend_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTCPResponseRuleBackendParams creates a new ReplaceTCPResponseRuleBackendParams object +// with the default values initialized. +func NewReplaceTCPResponseRuleBackendParams() ReplaceTCPResponseRuleBackendParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTCPResponseRuleBackendParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTCPResponseRuleBackendParams contains all the bound params for the replace TCP response rule backend operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTCPResponseRuleBackend +type ReplaceTCPResponseRuleBackendParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTCPResponseRuleBackendParams() beforehand. +func (o *ReplaceTCPResponseRuleBackendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTCPResponseRuleBackendParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTCPResponseRuleBackendParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceTCPResponseRuleBackendParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTCPResponseRuleBackendParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTCPResponseRuleBackendParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTCPResponseRuleBackendParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_backend_responses.go b/operations/tcp_response_rule/replace_tcp_response_rule_backend_responses.go new file mode 100644 index 00000000..9db168d1 --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_backend_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTCPResponseRuleBackendOKCode is the HTTP code returned for type ReplaceTCPResponseRuleBackendOK +const ReplaceTCPResponseRuleBackendOKCode int = 200 + +/* +ReplaceTCPResponseRuleBackendOK TCP Response Rule replaced + +swagger:response replaceTcpResponseRuleBackendOK +*/ +type ReplaceTCPResponseRuleBackendOK struct { + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleBackendOK creates ReplaceTCPResponseRuleBackendOK with default headers values +func NewReplaceTCPResponseRuleBackendOK() *ReplaceTCPResponseRuleBackendOK { + + return &ReplaceTCPResponseRuleBackendOK{} +} + +// WithPayload adds the payload to the replace Tcp response rule backend o k response +func (o *ReplaceTCPResponseRuleBackendOK) WithPayload(payload *models.TCPResponseRule) *ReplaceTCPResponseRuleBackendOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule backend o k response +func (o *ReplaceTCPResponseRuleBackendOK) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPResponseRuleBackendAcceptedCode is the HTTP code returned for type ReplaceTCPResponseRuleBackendAccepted +const ReplaceTCPResponseRuleBackendAcceptedCode int = 202 + +/* +ReplaceTCPResponseRuleBackendAccepted Configuration change accepted and reload requested + +swagger:response replaceTcpResponseRuleBackendAccepted +*/ +type ReplaceTCPResponseRuleBackendAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleBackendAccepted creates ReplaceTCPResponseRuleBackendAccepted with default headers values +func NewReplaceTCPResponseRuleBackendAccepted() *ReplaceTCPResponseRuleBackendAccepted { + + return &ReplaceTCPResponseRuleBackendAccepted{} +} + +// WithReloadID adds the reloadId to the replace Tcp response rule backend accepted response +func (o *ReplaceTCPResponseRuleBackendAccepted) WithReloadID(reloadID string) *ReplaceTCPResponseRuleBackendAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Tcp response rule backend accepted response +func (o *ReplaceTCPResponseRuleBackendAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Tcp response rule backend accepted response +func (o *ReplaceTCPResponseRuleBackendAccepted) WithPayload(payload *models.TCPResponseRule) *ReplaceTCPResponseRuleBackendAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule backend accepted response +func (o *ReplaceTCPResponseRuleBackendAccepted) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleBackendAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPResponseRuleBackendBadRequestCode is the HTTP code returned for type ReplaceTCPResponseRuleBackendBadRequest +const ReplaceTCPResponseRuleBackendBadRequestCode int = 400 + +/* +ReplaceTCPResponseRuleBackendBadRequest Bad request + +swagger:response replaceTcpResponseRuleBackendBadRequest +*/ +type ReplaceTCPResponseRuleBackendBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleBackendBadRequest creates ReplaceTCPResponseRuleBackendBadRequest with default headers values +func NewReplaceTCPResponseRuleBackendBadRequest() *ReplaceTCPResponseRuleBackendBadRequest { + + return &ReplaceTCPResponseRuleBackendBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp response rule backend bad request response +func (o *ReplaceTCPResponseRuleBackendBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTCPResponseRuleBackendBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp response rule backend bad request response +func (o *ReplaceTCPResponseRuleBackendBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp response rule backend bad request response +func (o *ReplaceTCPResponseRuleBackendBadRequest) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleBackendBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule backend bad request response +func (o *ReplaceTCPResponseRuleBackendBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleBackendBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPResponseRuleBackendNotFoundCode is the HTTP code returned for type ReplaceTCPResponseRuleBackendNotFound +const ReplaceTCPResponseRuleBackendNotFoundCode int = 404 + +/* +ReplaceTCPResponseRuleBackendNotFound The specified resource was not found + +swagger:response replaceTcpResponseRuleBackendNotFound +*/ +type ReplaceTCPResponseRuleBackendNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleBackendNotFound creates ReplaceTCPResponseRuleBackendNotFound with default headers values +func NewReplaceTCPResponseRuleBackendNotFound() *ReplaceTCPResponseRuleBackendNotFound { + + return &ReplaceTCPResponseRuleBackendNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp response rule backend not found response +func (o *ReplaceTCPResponseRuleBackendNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTCPResponseRuleBackendNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp response rule backend not found response +func (o *ReplaceTCPResponseRuleBackendNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp response rule backend not found response +func (o *ReplaceTCPResponseRuleBackendNotFound) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleBackendNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule backend not found response +func (o *ReplaceTCPResponseRuleBackendNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleBackendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTCPResponseRuleBackendDefault General Error + +swagger:response replaceTcpResponseRuleBackendDefault +*/ +type ReplaceTCPResponseRuleBackendDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleBackendDefault creates ReplaceTCPResponseRuleBackendDefault with default headers values +func NewReplaceTCPResponseRuleBackendDefault(code int) *ReplaceTCPResponseRuleBackendDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTCPResponseRuleBackendDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace TCP response rule backend default response +func (o *ReplaceTCPResponseRuleBackendDefault) WithStatusCode(code int) *ReplaceTCPResponseRuleBackendDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace TCP response rule backend default response +func (o *ReplaceTCPResponseRuleBackendDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace TCP response rule backend default response +func (o *ReplaceTCPResponseRuleBackendDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTCPResponseRuleBackendDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace TCP response rule backend default response +func (o *ReplaceTCPResponseRuleBackendDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace TCP response rule backend default response +func (o *ReplaceTCPResponseRuleBackendDefault) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleBackendDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace TCP response rule backend default response +func (o *ReplaceTCPResponseRuleBackendDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleBackendDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_backend_urlbuilder.go b/operations/tcp_response_rule/replace_tcp_response_rule_backend_urlbuilder.go new file mode 100644 index 00000000..d460eec1 --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_backend_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTCPResponseRuleBackendURL generates an URL for the replace TCP response rule backend operation +type ReplaceTCPResponseRuleBackendURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPResponseRuleBackendURL) WithBasePath(bp string) *ReplaceTCPResponseRuleBackendURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPResponseRuleBackendURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTCPResponseRuleBackendURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/backends/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceTCPResponseRuleBackendURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTCPResponseRuleBackendURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTCPResponseRuleBackendURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTCPResponseRuleBackendURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTCPResponseRuleBackendURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTCPResponseRuleBackendURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTCPResponseRuleBackendURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTCPResponseRuleBackendURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_defaults.go b/operations/tcp_response_rule/replace_tcp_response_rule_defaults.go new file mode 100644 index 00000000..cbc59e76 --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_defaults.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTCPResponseRuleDefaultsHandlerFunc turns a function with the right signature into a replace TCP response rule defaults handler +type ReplaceTCPResponseRuleDefaultsHandlerFunc func(ReplaceTCPResponseRuleDefaultsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTCPResponseRuleDefaultsHandlerFunc) Handle(params ReplaceTCPResponseRuleDefaultsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTCPResponseRuleDefaultsHandler interface for that can handle valid replace TCP response rule defaults params +type ReplaceTCPResponseRuleDefaultsHandler interface { + Handle(ReplaceTCPResponseRuleDefaultsParams, interface{}) middleware.Responder +} + +// NewReplaceTCPResponseRuleDefaults creates a new http.Handler for the replace TCP response rule defaults operation +func NewReplaceTCPResponseRuleDefaults(ctx *middleware.Context, handler ReplaceTCPResponseRuleDefaultsHandler) *ReplaceTCPResponseRuleDefaults { + return &ReplaceTCPResponseRuleDefaults{Context: ctx, Handler: handler} +} + +/* + ReplaceTCPResponseRuleDefaults swagger:route PUT /services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index} TCPResponseRule replaceTcpResponseRuleDefaults + +# Replace a TCP Response Rule + +Replaces a TCP Response Rule configuration by it's Index in the specified backend. +*/ +type ReplaceTCPResponseRuleDefaults struct { + Context *middleware.Context + Handler ReplaceTCPResponseRuleDefaultsHandler +} + +func (o *ReplaceTCPResponseRuleDefaults) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTCPResponseRuleDefaultsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_defaults_parameters.go b/operations/tcp_response_rule/replace_tcp_response_rule_defaults_parameters.go new file mode 100644 index 00000000..8233dfce --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_defaults_parameters.go @@ -0,0 +1,250 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTCPResponseRuleDefaultsParams creates a new ReplaceTCPResponseRuleDefaultsParams object +// with the default values initialized. +func NewReplaceTCPResponseRuleDefaultsParams() ReplaceTCPResponseRuleDefaultsParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceTCPResponseRuleDefaultsParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceTCPResponseRuleDefaultsParams contains all the bound params for the replace TCP response rule defaults operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTCPResponseRuleDefaults +type ReplaceTCPResponseRuleDefaultsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TCPResponseRule + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*TCP Response Rule Index + Required: true + In: path + */ + Index int64 + /*Parent name + Required: true + In: path + */ + ParentName string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTCPResponseRuleDefaultsParams() beforehand. +func (o *ReplaceTCPResponseRuleDefaultsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TCPResponseRule + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rIndex, rhkIndex, _ := route.Params.GetOK("index") + if err := o.bindIndex(rIndex, rhkIndex, route.Formats); err != nil { + res = append(res, err) + } + + rParentName, rhkParentName, _ := route.Params.GetOK("parent_name") + if err := o.bindParentName(rParentName, rhkParentName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTCPResponseRuleDefaultsParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTCPResponseRuleDefaultsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindIndex binds and validates parameter Index from path. +func (o *ReplaceTCPResponseRuleDefaultsParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("index", "path", "int64", raw) + } + o.Index = value + + return nil +} + +// bindParentName binds and validates parameter ParentName from path. +func (o *ReplaceTCPResponseRuleDefaultsParams) bindParentName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ParentName = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTCPResponseRuleDefaultsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTCPResponseRuleDefaultsParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_defaults_responses.go b/operations/tcp_response_rule/replace_tcp_response_rule_defaults_responses.go new file mode 100644 index 00000000..24d37892 --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_defaults_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTCPResponseRuleDefaultsOKCode is the HTTP code returned for type ReplaceTCPResponseRuleDefaultsOK +const ReplaceTCPResponseRuleDefaultsOKCode int = 200 + +/* +ReplaceTCPResponseRuleDefaultsOK TCP Response Rule replaced + +swagger:response replaceTcpResponseRuleDefaultsOK +*/ +type ReplaceTCPResponseRuleDefaultsOK struct { + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleDefaultsOK creates ReplaceTCPResponseRuleDefaultsOK with default headers values +func NewReplaceTCPResponseRuleDefaultsOK() *ReplaceTCPResponseRuleDefaultsOK { + + return &ReplaceTCPResponseRuleDefaultsOK{} +} + +// WithPayload adds the payload to the replace Tcp response rule defaults o k response +func (o *ReplaceTCPResponseRuleDefaultsOK) WithPayload(payload *models.TCPResponseRule) *ReplaceTCPResponseRuleDefaultsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule defaults o k response +func (o *ReplaceTCPResponseRuleDefaultsOK) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleDefaultsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPResponseRuleDefaultsAcceptedCode is the HTTP code returned for type ReplaceTCPResponseRuleDefaultsAccepted +const ReplaceTCPResponseRuleDefaultsAcceptedCode int = 202 + +/* +ReplaceTCPResponseRuleDefaultsAccepted Configuration change accepted and reload requested + +swagger:response replaceTcpResponseRuleDefaultsAccepted +*/ +type ReplaceTCPResponseRuleDefaultsAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TCPResponseRule `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleDefaultsAccepted creates ReplaceTCPResponseRuleDefaultsAccepted with default headers values +func NewReplaceTCPResponseRuleDefaultsAccepted() *ReplaceTCPResponseRuleDefaultsAccepted { + + return &ReplaceTCPResponseRuleDefaultsAccepted{} +} + +// WithReloadID adds the reloadId to the replace Tcp response rule defaults accepted response +func (o *ReplaceTCPResponseRuleDefaultsAccepted) WithReloadID(reloadID string) *ReplaceTCPResponseRuleDefaultsAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace Tcp response rule defaults accepted response +func (o *ReplaceTCPResponseRuleDefaultsAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace Tcp response rule defaults accepted response +func (o *ReplaceTCPResponseRuleDefaultsAccepted) WithPayload(payload *models.TCPResponseRule) *ReplaceTCPResponseRuleDefaultsAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule defaults accepted response +func (o *ReplaceTCPResponseRuleDefaultsAccepted) SetPayload(payload *models.TCPResponseRule) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleDefaultsAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPResponseRuleDefaultsBadRequestCode is the HTTP code returned for type ReplaceTCPResponseRuleDefaultsBadRequest +const ReplaceTCPResponseRuleDefaultsBadRequestCode int = 400 + +/* +ReplaceTCPResponseRuleDefaultsBadRequest Bad request + +swagger:response replaceTcpResponseRuleDefaultsBadRequest +*/ +type ReplaceTCPResponseRuleDefaultsBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleDefaultsBadRequest creates ReplaceTCPResponseRuleDefaultsBadRequest with default headers values +func NewReplaceTCPResponseRuleDefaultsBadRequest() *ReplaceTCPResponseRuleDefaultsBadRequest { + + return &ReplaceTCPResponseRuleDefaultsBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp response rule defaults bad request response +func (o *ReplaceTCPResponseRuleDefaultsBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTCPResponseRuleDefaultsBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp response rule defaults bad request response +func (o *ReplaceTCPResponseRuleDefaultsBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp response rule defaults bad request response +func (o *ReplaceTCPResponseRuleDefaultsBadRequest) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleDefaultsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule defaults bad request response +func (o *ReplaceTCPResponseRuleDefaultsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleDefaultsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTCPResponseRuleDefaultsNotFoundCode is the HTTP code returned for type ReplaceTCPResponseRuleDefaultsNotFound +const ReplaceTCPResponseRuleDefaultsNotFoundCode int = 404 + +/* +ReplaceTCPResponseRuleDefaultsNotFound The specified resource was not found + +swagger:response replaceTcpResponseRuleDefaultsNotFound +*/ +type ReplaceTCPResponseRuleDefaultsNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleDefaultsNotFound creates ReplaceTCPResponseRuleDefaultsNotFound with default headers values +func NewReplaceTCPResponseRuleDefaultsNotFound() *ReplaceTCPResponseRuleDefaultsNotFound { + + return &ReplaceTCPResponseRuleDefaultsNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace Tcp response rule defaults not found response +func (o *ReplaceTCPResponseRuleDefaultsNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTCPResponseRuleDefaultsNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace Tcp response rule defaults not found response +func (o *ReplaceTCPResponseRuleDefaultsNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace Tcp response rule defaults not found response +func (o *ReplaceTCPResponseRuleDefaultsNotFound) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleDefaultsNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace Tcp response rule defaults not found response +func (o *ReplaceTCPResponseRuleDefaultsNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleDefaultsNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTCPResponseRuleDefaultsDefault General Error + +swagger:response replaceTcpResponseRuleDefaultsDefault +*/ +type ReplaceTCPResponseRuleDefaultsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTCPResponseRuleDefaultsDefault creates ReplaceTCPResponseRuleDefaultsDefault with default headers values +func NewReplaceTCPResponseRuleDefaultsDefault(code int) *ReplaceTCPResponseRuleDefaultsDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTCPResponseRuleDefaultsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace TCP response rule defaults default response +func (o *ReplaceTCPResponseRuleDefaultsDefault) WithStatusCode(code int) *ReplaceTCPResponseRuleDefaultsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace TCP response rule defaults default response +func (o *ReplaceTCPResponseRuleDefaultsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace TCP response rule defaults default response +func (o *ReplaceTCPResponseRuleDefaultsDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTCPResponseRuleDefaultsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace TCP response rule defaults default response +func (o *ReplaceTCPResponseRuleDefaultsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace TCP response rule defaults default response +func (o *ReplaceTCPResponseRuleDefaultsDefault) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleDefaultsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace TCP response rule defaults default response +func (o *ReplaceTCPResponseRuleDefaultsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTCPResponseRuleDefaultsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_defaults_urlbuilder.go b/operations/tcp_response_rule/replace_tcp_response_rule_defaults_urlbuilder.go new file mode 100644 index 00000000..7e3890aa --- /dev/null +++ b/operations/tcp_response_rule/replace_tcp_response_rule_defaults_urlbuilder.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package tcp_response_rule + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceTCPResponseRuleDefaultsURL generates an URL for the replace TCP response rule defaults operation +type ReplaceTCPResponseRuleDefaultsURL struct { + Index int64 + ParentName string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPResponseRuleDefaultsURL) WithBasePath(bp string) *ReplaceTCPResponseRuleDefaultsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTCPResponseRuleDefaultsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTCPResponseRuleDefaultsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/defaults/{parent_name}/tcp_response_rules/{index}" + + index := swag.FormatInt64(o.Index) + if index != "" { + _path = strings.Replace(_path, "{index}", index, -1) + } else { + return nil, errors.New("index is required on ReplaceTCPResponseRuleDefaultsURL") + } + + parentName := o.ParentName + if parentName != "" { + _path = strings.Replace(_path, "{parent_name}", parentName, -1) + } else { + return nil, errors.New("parentName is required on ReplaceTCPResponseRuleDefaultsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTCPResponseRuleDefaultsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTCPResponseRuleDefaultsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTCPResponseRuleDefaultsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTCPResponseRuleDefaultsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTCPResponseRuleDefaultsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTCPResponseRuleDefaultsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_parameters.go b/operations/tcp_response_rule/replace_tcp_response_rule_parameters.go deleted file mode 100644 index 01dad684..00000000 --- a/operations/tcp_response_rule/replace_tcp_response_rule_parameters.go +++ /dev/null @@ -1,257 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" - - "github.com/haproxytech/models" -) - -// NewReplaceTCPResponseRuleParams creates a new ReplaceTCPResponseRuleParams object -// with the default values initialized. -func NewReplaceTCPResponseRuleParams() ReplaceTCPResponseRuleParams { - - var ( - // initialize parameters with default values - - forceReloadDefault = bool(false) - ) - - return ReplaceTCPResponseRuleParams{ - ForceReload: &forceReloadDefault, - } -} - -// ReplaceTCPResponseRuleParams contains all the bound params for the replace TCP response rule operation -// typically these are obtained from a http.Request -// -// swagger:parameters replaceTCPResponseRule -type ReplaceTCPResponseRuleParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Parent backend name - Required: true - In: query - */ - Backend string - /* - Required: true - In: body - */ - Data *models.TCPResponseRule - /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. - In: query - Default: false - */ - ForceReload *bool - /*TCP Response Rule ID - Required: true - In: path - */ - ID int64 - /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. - In: query - */ - TransactionID *string - /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. - In: query - */ - Version *int64 -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewReplaceTCPResponseRuleParams() beforehand. -func (o *ReplaceTCPResponseRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qBackend, qhkBackend, _ := qs.GetOK("backend") - if err := o.bindBackend(qBackend, qhkBackend, route.Formats); err != nil { - res = append(res, err) - } - - if runtime.HasBody(r) { - defer r.Body.Close() - var body models.TCPResponseRule - if err := route.Consumer.Consume(r.Body, &body); err != nil { - if err == io.EOF { - res = append(res, errors.Required("data", "body")) - } else { - res = append(res, errors.NewParseError("data", "body", "", err)) - } - } else { - // validate body object - if err := body.Validate(route.Formats); err != nil { - res = append(res, err) - } - - if len(res) == 0 { - o.Data = &body - } - } - } else { - res = append(res, errors.Required("data", "body")) - } - qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") - if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { - res = append(res, err) - } - - rID, rhkID, _ := route.Params.GetOK("id") - if err := o.bindID(rID, rhkID, route.Formats); err != nil { - res = append(res, err) - } - - qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") - if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { - res = append(res, err) - } - - qVersion, qhkVersion, _ := qs.GetOK("version") - if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindBackend binds and validates parameter Backend from query. -func (o *ReplaceTCPResponseRuleParams) bindBackend(rawData []string, hasKey bool, formats strfmt.Registry) error { - if !hasKey { - return errors.Required("backend", "query") - } - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // AllowEmptyValue: false - if err := validate.RequiredString("backend", "query", raw); err != nil { - return err - } - - o.Backend = raw - - return nil -} - -// bindForceReload binds and validates parameter ForceReload from query. -func (o *ReplaceTCPResponseRuleParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - // Default values have been previously initialized by NewReplaceTCPResponseRuleParams() - return nil - } - - value, err := swag.ConvertBool(raw) - if err != nil { - return errors.InvalidType("force_reload", "query", "bool", raw) - } - o.ForceReload = &value - - return nil -} - -// bindID binds and validates parameter ID from path. -func (o *ReplaceTCPResponseRuleParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: true - // Parameter is provided by construction from the route - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("id", "path", "int64", raw) - } - o.ID = value - - return nil -} - -// bindTransactionID binds and validates parameter TransactionID from query. -func (o *ReplaceTCPResponseRuleParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - o.TransactionID = &raw - - return nil -} - -// bindVersion binds and validates parameter Version from query. -func (o *ReplaceTCPResponseRuleParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - if raw == "" { // empty values pass all other validations - return nil - } - - value, err := swag.ConvertInt64(raw) - if err != nil { - return errors.InvalidType("version", "query", "int64", raw) - } - o.Version = &value - - return nil -} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_responses.go b/operations/tcp_response_rule/replace_tcp_response_rule_responses.go deleted file mode 100644 index 5282e066..00000000 --- a/operations/tcp_response_rule/replace_tcp_response_rule_responses.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - - "github.com/haproxytech/models" -) - -// ReplaceTCPResponseRuleOKCode is the HTTP code returned for type ReplaceTCPResponseRuleOK -const ReplaceTCPResponseRuleOKCode int = 200 - -/*ReplaceTCPResponseRuleOK TCP Response Rule replaced - -swagger:response replaceTcpResponseRuleOK -*/ -type ReplaceTCPResponseRuleOK struct { - - /* - In: Body - */ - Payload *models.TCPResponseRule `json:"body,omitempty"` -} - -// NewReplaceTCPResponseRuleOK creates ReplaceTCPResponseRuleOK with default headers values -func NewReplaceTCPResponseRuleOK() *ReplaceTCPResponseRuleOK { - - return &ReplaceTCPResponseRuleOK{} -} - -// WithPayload adds the payload to the replace Tcp response rule o k response -func (o *ReplaceTCPResponseRuleOK) WithPayload(payload *models.TCPResponseRule) *ReplaceTCPResponseRuleOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp response rule o k response -func (o *ReplaceTCPResponseRuleOK) SetPayload(payload *models.TCPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPResponseRuleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceTCPResponseRuleAcceptedCode is the HTTP code returned for type ReplaceTCPResponseRuleAccepted -const ReplaceTCPResponseRuleAcceptedCode int = 202 - -/*ReplaceTCPResponseRuleAccepted Configuration change accepted and reload requested - -swagger:response replaceTcpResponseRuleAccepted -*/ -type ReplaceTCPResponseRuleAccepted struct { - /*ID of the requested reload - - */ - ReloadID string `json:"Reload-ID"` - - /* - In: Body - */ - Payload *models.TCPResponseRule `json:"body,omitempty"` -} - -// NewReplaceTCPResponseRuleAccepted creates ReplaceTCPResponseRuleAccepted with default headers values -func NewReplaceTCPResponseRuleAccepted() *ReplaceTCPResponseRuleAccepted { - - return &ReplaceTCPResponseRuleAccepted{} -} - -// WithReloadID adds the reloadId to the replace Tcp response rule accepted response -func (o *ReplaceTCPResponseRuleAccepted) WithReloadID(reloadID string) *ReplaceTCPResponseRuleAccepted { - o.ReloadID = reloadID - return o -} - -// SetReloadID sets the reloadId to the replace Tcp response rule accepted response -func (o *ReplaceTCPResponseRuleAccepted) SetReloadID(reloadID string) { - o.ReloadID = reloadID -} - -// WithPayload adds the payload to the replace Tcp response rule accepted response -func (o *ReplaceTCPResponseRuleAccepted) WithPayload(payload *models.TCPResponseRule) *ReplaceTCPResponseRuleAccepted { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp response rule accepted response -func (o *ReplaceTCPResponseRuleAccepted) SetPayload(payload *models.TCPResponseRule) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPResponseRuleAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Reload-ID - - reloadID := o.ReloadID - if reloadID != "" { - rw.Header().Set("Reload-ID", reloadID) - } - - rw.WriteHeader(202) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceTCPResponseRuleBadRequestCode is the HTTP code returned for type ReplaceTCPResponseRuleBadRequest -const ReplaceTCPResponseRuleBadRequestCode int = 400 - -/*ReplaceTCPResponseRuleBadRequest Bad request - -swagger:response replaceTcpResponseRuleBadRequest -*/ -type ReplaceTCPResponseRuleBadRequest struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceTCPResponseRuleBadRequest creates ReplaceTCPResponseRuleBadRequest with default headers values -func NewReplaceTCPResponseRuleBadRequest() *ReplaceTCPResponseRuleBadRequest { - - return &ReplaceTCPResponseRuleBadRequest{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Tcp response rule bad request response -func (o *ReplaceTCPResponseRuleBadRequest) WithConfigurationVersion(configurationVersion int64) *ReplaceTCPResponseRuleBadRequest { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Tcp response rule bad request response -func (o *ReplaceTCPResponseRuleBadRequest) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Tcp response rule bad request response -func (o *ReplaceTCPResponseRuleBadRequest) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleBadRequest { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp response rule bad request response -func (o *ReplaceTCPResponseRuleBadRequest) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPResponseRuleBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(400) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ReplaceTCPResponseRuleNotFoundCode is the HTTP code returned for type ReplaceTCPResponseRuleNotFound -const ReplaceTCPResponseRuleNotFoundCode int = 404 - -/*ReplaceTCPResponseRuleNotFound The specified resource was not found - -swagger:response replaceTcpResponseRuleNotFound -*/ -type ReplaceTCPResponseRuleNotFound struct { - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceTCPResponseRuleNotFound creates ReplaceTCPResponseRuleNotFound with default headers values -func NewReplaceTCPResponseRuleNotFound() *ReplaceTCPResponseRuleNotFound { - - return &ReplaceTCPResponseRuleNotFound{} -} - -// WithConfigurationVersion adds the configurationVersion to the replace Tcp response rule not found response -func (o *ReplaceTCPResponseRuleNotFound) WithConfigurationVersion(configurationVersion int64) *ReplaceTCPResponseRuleNotFound { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace Tcp response rule not found response -func (o *ReplaceTCPResponseRuleNotFound) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace Tcp response rule not found response -func (o *ReplaceTCPResponseRuleNotFound) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace Tcp response rule not found response -func (o *ReplaceTCPResponseRuleNotFound) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPResponseRuleNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/*ReplaceTCPResponseRuleDefault General Error - -swagger:response replaceTcpResponseRuleDefault -*/ -type ReplaceTCPResponseRuleDefault struct { - _statusCode int - /*Configuration file version - - */ - ConfigurationVersion int64 `json:"Configuration-Version"` - - /* - In: Body - */ - Payload *models.Error `json:"body,omitempty"` -} - -// NewReplaceTCPResponseRuleDefault creates ReplaceTCPResponseRuleDefault with default headers values -func NewReplaceTCPResponseRuleDefault(code int) *ReplaceTCPResponseRuleDefault { - if code <= 0 { - code = 500 - } - - return &ReplaceTCPResponseRuleDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the replace TCP response rule default response -func (o *ReplaceTCPResponseRuleDefault) WithStatusCode(code int) *ReplaceTCPResponseRuleDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the replace TCP response rule default response -func (o *ReplaceTCPResponseRuleDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithConfigurationVersion adds the configurationVersion to the replace TCP response rule default response -func (o *ReplaceTCPResponseRuleDefault) WithConfigurationVersion(configurationVersion int64) *ReplaceTCPResponseRuleDefault { - o.ConfigurationVersion = configurationVersion - return o -} - -// SetConfigurationVersion sets the configurationVersion to the replace TCP response rule default response -func (o *ReplaceTCPResponseRuleDefault) SetConfigurationVersion(configurationVersion int64) { - o.ConfigurationVersion = configurationVersion -} - -// WithPayload adds the payload to the replace TCP response rule default response -func (o *ReplaceTCPResponseRuleDefault) WithPayload(payload *models.Error) *ReplaceTCPResponseRuleDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the replace TCP response rule default response -func (o *ReplaceTCPResponseRuleDefault) SetPayload(payload *models.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ReplaceTCPResponseRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - // response header Configuration-Version - - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) - if configurationVersion != "" { - rw.Header().Set("Configuration-Version", configurationVersion) - } - - rw.WriteHeader(o._statusCode) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/operations/tcp_response_rule/replace_tcp_response_rule_urlbuilder.go b/operations/tcp_response_rule/replace_tcp_response_rule_urlbuilder.go deleted file mode 100644 index 55c077cb..00000000 --- a/operations/tcp_response_rule/replace_tcp_response_rule_urlbuilder.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Copyright 2019 HAProxy Technologies -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package tcp_response_rule - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - "strings" - - "github.com/go-openapi/swag" -) - -// ReplaceTCPResponseRuleURL generates an URL for the replace TCP response rule operation -type ReplaceTCPResponseRuleURL struct { - ID int64 - - Backend string - ForceReload *bool - TransactionID *string - Version *int64 - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceTCPResponseRuleURL) WithBasePath(bp string) *ReplaceTCPResponseRuleURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ReplaceTCPResponseRuleURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ReplaceTCPResponseRuleURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/services/haproxy/configuration/tcp_response_rules/{id}" - - id := swag.FormatInt64(o.ID) - if id != "" { - _path = strings.Replace(_path, "{id}", id, -1) - } else { - return nil, errors.New("id is required on ReplaceTCPResponseRuleURL") - } - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/v2" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - backend := o.Backend - if backend != "" { - qs.Set("backend", backend) - } - - var forceReload string - if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) - } - if forceReload != "" { - qs.Set("force_reload", forceReload) - } - - var transactionID string - if o.TransactionID != nil { - transactionID = *o.TransactionID - } - if transactionID != "" { - qs.Set("transaction_id", transactionID) - } - - var version string - if o.Version != nil { - version = swag.FormatInt64(*o.Version) - } - if version != "" { - qs.Set("version", version) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ReplaceTCPResponseRuleURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ReplaceTCPResponseRuleURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ReplaceTCPResponseRuleURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ReplaceTCPResponseRuleURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ReplaceTCPResponseRuleURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ReplaceTCPResponseRuleURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/operations/traces/create_trace_entry.go b/operations/traces/create_trace_entry.go new file mode 100644 index 00000000..9eb6c54b --- /dev/null +++ b/operations/traces/create_trace_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTraceEntryHandlerFunc turns a function with the right signature into a create trace entry handler +type CreateTraceEntryHandlerFunc func(CreateTraceEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTraceEntryHandlerFunc) Handle(params CreateTraceEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTraceEntryHandler interface for that can handle valid create trace entry params +type CreateTraceEntryHandler interface { + Handle(CreateTraceEntryParams, interface{}) middleware.Responder +} + +// NewCreateTraceEntry creates a new http.Handler for the create trace entry operation +func NewCreateTraceEntry(ctx *middleware.Context, handler CreateTraceEntryHandler) *CreateTraceEntry { + return &CreateTraceEntry{Context: ctx, Handler: handler} +} + +/* + CreateTraceEntry swagger:route POST /services/haproxy/configuration/traces/entries Traces createTraceEntry + +# Add a new trace entry + +Adds a new trace entry into the traces section. The traces section will be created if needed. +*/ +type CreateTraceEntry struct { + Context *middleware.Context + Handler CreateTraceEntryHandler +} + +func (o *CreateTraceEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTraceEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/traces/create_trace_entry_parameters.go b/operations/traces/create_trace_entry_parameters.go new file mode 100644 index 00000000..98384016 --- /dev/null +++ b/operations/traces/create_trace_entry_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTraceEntryParams creates a new CreateTraceEntryParams object +// with the default values initialized. +func NewCreateTraceEntryParams() CreateTraceEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTraceEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTraceEntryParams contains all the bound params for the create trace entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTraceEntry +type CreateTraceEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TraceEntry + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTraceEntryParams() beforehand. +func (o *CreateTraceEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TraceEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTraceEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTraceEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTraceEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTraceEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/traces/create_trace_entry_responses.go b/operations/traces/create_trace_entry_responses.go new file mode 100644 index 00000000..55f387f7 --- /dev/null +++ b/operations/traces/create_trace_entry_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTraceEntryCreatedCode is the HTTP code returned for type CreateTraceEntryCreated +const CreateTraceEntryCreatedCode int = 201 + +/* +CreateTraceEntryCreated Trace entry added + +swagger:response createTraceEntryCreated +*/ +type CreateTraceEntryCreated struct { + + /* + In: Body + */ + Payload *models.TraceEntry `json:"body,omitempty"` +} + +// NewCreateTraceEntryCreated creates CreateTraceEntryCreated with default headers values +func NewCreateTraceEntryCreated() *CreateTraceEntryCreated { + + return &CreateTraceEntryCreated{} +} + +// WithPayload adds the payload to the create trace entry created response +func (o *CreateTraceEntryCreated) WithPayload(payload *models.TraceEntry) *CreateTraceEntryCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create trace entry created response +func (o *CreateTraceEntryCreated) SetPayload(payload *models.TraceEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTraceEntryCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTraceEntryAcceptedCode is the HTTP code returned for type CreateTraceEntryAccepted +const CreateTraceEntryAcceptedCode int = 202 + +/* +CreateTraceEntryAccepted Configuration change accepted and reload requested + +swagger:response createTraceEntryAccepted +*/ +type CreateTraceEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.TraceEntry `json:"body,omitempty"` +} + +// NewCreateTraceEntryAccepted creates CreateTraceEntryAccepted with default headers values +func NewCreateTraceEntryAccepted() *CreateTraceEntryAccepted { + + return &CreateTraceEntryAccepted{} +} + +// WithReloadID adds the reloadId to the create trace entry accepted response +func (o *CreateTraceEntryAccepted) WithReloadID(reloadID string) *CreateTraceEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create trace entry accepted response +func (o *CreateTraceEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create trace entry accepted response +func (o *CreateTraceEntryAccepted) WithPayload(payload *models.TraceEntry) *CreateTraceEntryAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create trace entry accepted response +func (o *CreateTraceEntryAccepted) SetPayload(payload *models.TraceEntry) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTraceEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTraceEntryBadRequestCode is the HTTP code returned for type CreateTraceEntryBadRequest +const CreateTraceEntryBadRequestCode int = 400 + +/* +CreateTraceEntryBadRequest Bad request + +swagger:response createTraceEntryBadRequest +*/ +type CreateTraceEntryBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTraceEntryBadRequest creates CreateTraceEntryBadRequest with default headers values +func NewCreateTraceEntryBadRequest() *CreateTraceEntryBadRequest { + + return &CreateTraceEntryBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create trace entry bad request response +func (o *CreateTraceEntryBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTraceEntryBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create trace entry bad request response +func (o *CreateTraceEntryBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create trace entry bad request response +func (o *CreateTraceEntryBadRequest) WithPayload(payload *models.Error) *CreateTraceEntryBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create trace entry bad request response +func (o *CreateTraceEntryBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTraceEntryBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTraceEntryConflictCode is the HTTP code returned for type CreateTraceEntryConflict +const CreateTraceEntryConflictCode int = 409 + +/* +CreateTraceEntryConflict The specified resource already exists + +swagger:response createTraceEntryConflict +*/ +type CreateTraceEntryConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTraceEntryConflict creates CreateTraceEntryConflict with default headers values +func NewCreateTraceEntryConflict() *CreateTraceEntryConflict { + + return &CreateTraceEntryConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create trace entry conflict response +func (o *CreateTraceEntryConflict) WithConfigurationVersion(configurationVersion string) *CreateTraceEntryConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create trace entry conflict response +func (o *CreateTraceEntryConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create trace entry conflict response +func (o *CreateTraceEntryConflict) WithPayload(payload *models.Error) *CreateTraceEntryConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create trace entry conflict response +func (o *CreateTraceEntryConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTraceEntryConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTraceEntryDefault General Error + +swagger:response createTraceEntryDefault +*/ +type CreateTraceEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTraceEntryDefault creates CreateTraceEntryDefault with default headers values +func NewCreateTraceEntryDefault(code int) *CreateTraceEntryDefault { + if code <= 0 { + code = 500 + } + + return &CreateTraceEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create trace entry default response +func (o *CreateTraceEntryDefault) WithStatusCode(code int) *CreateTraceEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create trace entry default response +func (o *CreateTraceEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create trace entry default response +func (o *CreateTraceEntryDefault) WithConfigurationVersion(configurationVersion string) *CreateTraceEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create trace entry default response +func (o *CreateTraceEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create trace entry default response +func (o *CreateTraceEntryDefault) WithPayload(payload *models.Error) *CreateTraceEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create trace entry default response +func (o *CreateTraceEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTraceEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/traces/create_trace_entry_urlbuilder.go b/operations/traces/create_trace_entry_urlbuilder.go new file mode 100644 index 00000000..9b537588 --- /dev/null +++ b/operations/traces/create_trace_entry_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateTraceEntryURL generates an URL for the create trace entry operation +type CreateTraceEntryURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTraceEntryURL) WithBasePath(bp string) *CreateTraceEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTraceEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTraceEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/traces/entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTraceEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTraceEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTraceEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTraceEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTraceEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTraceEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/traces/create_traces.go b/operations/traces/create_traces.go new file mode 100644 index 00000000..b6962b54 --- /dev/null +++ b/operations/traces/create_traces.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateTracesHandlerFunc turns a function with the right signature into a create traces handler +type CreateTracesHandlerFunc func(CreateTracesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateTracesHandlerFunc) Handle(params CreateTracesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateTracesHandler interface for that can handle valid create traces params +type CreateTracesHandler interface { + Handle(CreateTracesParams, interface{}) middleware.Responder +} + +// NewCreateTraces creates a new http.Handler for the create traces operation +func NewCreateTraces(ctx *middleware.Context, handler CreateTracesHandler) *CreateTraces { + return &CreateTraces{Context: ctx, Handler: handler} +} + +/* + CreateTraces swagger:route POST /services/haproxy/configuration/traces Traces createTraces + +# Create the traces section + +Create the traces section. +*/ +type CreateTraces struct { + Context *middleware.Context + Handler CreateTracesHandler +} + +func (o *CreateTraces) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateTracesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/traces/create_traces_parameters.go b/operations/traces/create_traces_parameters.go new file mode 100644 index 00000000..fdfb81f6 --- /dev/null +++ b/operations/traces/create_traces_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateTracesParams creates a new CreateTracesParams object +// with the default values initialized. +func NewCreateTracesParams() CreateTracesParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateTracesParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateTracesParams contains all the bound params for the create traces operation +// typically these are obtained from a http.Request +// +// swagger:parameters createTraces +type CreateTracesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Traces + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateTracesParams() beforehand. +func (o *CreateTracesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Traces + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateTracesParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateTracesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateTracesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateTracesParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/traces/create_traces_responses.go b/operations/traces/create_traces_responses.go new file mode 100644 index 00000000..d5a6ee4c --- /dev/null +++ b/operations/traces/create_traces_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateTracesCreatedCode is the HTTP code returned for type CreateTracesCreated +const CreateTracesCreatedCode int = 201 + +/* +CreateTracesCreated Traces section created + +swagger:response createTracesCreated +*/ +type CreateTracesCreated struct { + + /* + In: Body + */ + Payload *models.Traces `json:"body,omitempty"` +} + +// NewCreateTracesCreated creates CreateTracesCreated with default headers values +func NewCreateTracesCreated() *CreateTracesCreated { + + return &CreateTracesCreated{} +} + +// WithPayload adds the payload to the create traces created response +func (o *CreateTracesCreated) WithPayload(payload *models.Traces) *CreateTracesCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create traces created response +func (o *CreateTracesCreated) SetPayload(payload *models.Traces) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTracesCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTracesAcceptedCode is the HTTP code returned for type CreateTracesAccepted +const CreateTracesAcceptedCode int = 202 + +/* +CreateTracesAccepted Configuration change accepted and reload requested + +swagger:response createTracesAccepted +*/ +type CreateTracesAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Traces `json:"body,omitempty"` +} + +// NewCreateTracesAccepted creates CreateTracesAccepted with default headers values +func NewCreateTracesAccepted() *CreateTracesAccepted { + + return &CreateTracesAccepted{} +} + +// WithReloadID adds the reloadId to the create traces accepted response +func (o *CreateTracesAccepted) WithReloadID(reloadID string) *CreateTracesAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create traces accepted response +func (o *CreateTracesAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create traces accepted response +func (o *CreateTracesAccepted) WithPayload(payload *models.Traces) *CreateTracesAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create traces accepted response +func (o *CreateTracesAccepted) SetPayload(payload *models.Traces) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTracesAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTracesBadRequestCode is the HTTP code returned for type CreateTracesBadRequest +const CreateTracesBadRequestCode int = 400 + +/* +CreateTracesBadRequest Bad request + +swagger:response createTracesBadRequest +*/ +type CreateTracesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTracesBadRequest creates CreateTracesBadRequest with default headers values +func NewCreateTracesBadRequest() *CreateTracesBadRequest { + + return &CreateTracesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create traces bad request response +func (o *CreateTracesBadRequest) WithConfigurationVersion(configurationVersion string) *CreateTracesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create traces bad request response +func (o *CreateTracesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create traces bad request response +func (o *CreateTracesBadRequest) WithPayload(payload *models.Error) *CreateTracesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create traces bad request response +func (o *CreateTracesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTracesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateTracesConflictCode is the HTTP code returned for type CreateTracesConflict +const CreateTracesConflictCode int = 409 + +/* +CreateTracesConflict The specified resource already exists + +swagger:response createTracesConflict +*/ +type CreateTracesConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTracesConflict creates CreateTracesConflict with default headers values +func NewCreateTracesConflict() *CreateTracesConflict { + + return &CreateTracesConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create traces conflict response +func (o *CreateTracesConflict) WithConfigurationVersion(configurationVersion string) *CreateTracesConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create traces conflict response +func (o *CreateTracesConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create traces conflict response +func (o *CreateTracesConflict) WithPayload(payload *models.Error) *CreateTracesConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create traces conflict response +func (o *CreateTracesConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTracesConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateTracesDefault General Error + +swagger:response createTracesDefault +*/ +type CreateTracesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateTracesDefault creates CreateTracesDefault with default headers values +func NewCreateTracesDefault(code int) *CreateTracesDefault { + if code <= 0 { + code = 500 + } + + return &CreateTracesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create traces default response +func (o *CreateTracesDefault) WithStatusCode(code int) *CreateTracesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create traces default response +func (o *CreateTracesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create traces default response +func (o *CreateTracesDefault) WithConfigurationVersion(configurationVersion string) *CreateTracesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create traces default response +func (o *CreateTracesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create traces default response +func (o *CreateTracesDefault) WithPayload(payload *models.Error) *CreateTracesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create traces default response +func (o *CreateTracesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateTracesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/traces/create_traces_urlbuilder.go b/operations/traces/create_traces_urlbuilder.go new file mode 100644 index 00000000..1e9dc31d --- /dev/null +++ b/operations/traces/create_traces_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateTracesURL generates an URL for the create traces operation +type CreateTracesURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTracesURL) WithBasePath(bp string) *CreateTracesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateTracesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateTracesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/traces" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateTracesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateTracesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateTracesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateTracesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateTracesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateTracesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/traces/delete_trace_entry.go b/operations/traces/delete_trace_entry.go new file mode 100644 index 00000000..bf5d7ecd --- /dev/null +++ b/operations/traces/delete_trace_entry.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTraceEntryHandlerFunc turns a function with the right signature into a delete trace entry handler +type DeleteTraceEntryHandlerFunc func(DeleteTraceEntryParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTraceEntryHandlerFunc) Handle(params DeleteTraceEntryParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTraceEntryHandler interface for that can handle valid delete trace entry params +type DeleteTraceEntryHandler interface { + Handle(DeleteTraceEntryParams, interface{}) middleware.Responder +} + +// NewDeleteTraceEntry creates a new http.Handler for the delete trace entry operation +func NewDeleteTraceEntry(ctx *middleware.Context, handler DeleteTraceEntryHandler) *DeleteTraceEntry { + return &DeleteTraceEntry{Context: ctx, Handler: handler} +} + +/* + DeleteTraceEntry swagger:route DELETE /services/haproxy/configuration/traces/entries Traces deleteTraceEntry + +# Delete a trace entry + +Deletes a trace entry from the traces section. +*/ +type DeleteTraceEntry struct { + Context *middleware.Context + Handler DeleteTraceEntryHandler +} + +func (o *DeleteTraceEntry) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTraceEntryParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/traces/delete_trace_entry_parameters.go b/operations/traces/delete_trace_entry_parameters.go new file mode 100644 index 00000000..25467994 --- /dev/null +++ b/operations/traces/delete_trace_entry_parameters.go @@ -0,0 +1,197 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewDeleteTraceEntryParams creates a new DeleteTraceEntryParams object +// with the default values initialized. +func NewDeleteTraceEntryParams() DeleteTraceEntryParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTraceEntryParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTraceEntryParams contains all the bound params for the delete trace entry operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTraceEntry +type DeleteTraceEntryParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.TraceEntry + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTraceEntryParams() beforehand. +func (o *DeleteTraceEntryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TraceEntry + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTraceEntryParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTraceEntryParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTraceEntryParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTraceEntryParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/traces/delete_trace_entry_responses.go b/operations/traces/delete_trace_entry_responses.go new file mode 100644 index 00000000..2773ccea --- /dev/null +++ b/operations/traces/delete_trace_entry_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTraceEntryAcceptedCode is the HTTP code returned for type DeleteTraceEntryAccepted +const DeleteTraceEntryAcceptedCode int = 202 + +/* +DeleteTraceEntryAccepted Configuration change accepted and reload requested + +swagger:response deleteTraceEntryAccepted +*/ +type DeleteTraceEntryAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTraceEntryAccepted creates DeleteTraceEntryAccepted with default headers values +func NewDeleteTraceEntryAccepted() *DeleteTraceEntryAccepted { + + return &DeleteTraceEntryAccepted{} +} + +// WithReloadID adds the reloadId to the delete trace entry accepted response +func (o *DeleteTraceEntryAccepted) WithReloadID(reloadID string) *DeleteTraceEntryAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete trace entry accepted response +func (o *DeleteTraceEntryAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTraceEntryAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTraceEntryNoContentCode is the HTTP code returned for type DeleteTraceEntryNoContent +const DeleteTraceEntryNoContentCode int = 204 + +/* +DeleteTraceEntryNoContent Trace entry deleted + +swagger:response deleteTraceEntryNoContent +*/ +type DeleteTraceEntryNoContent struct { +} + +// NewDeleteTraceEntryNoContent creates DeleteTraceEntryNoContent with default headers values +func NewDeleteTraceEntryNoContent() *DeleteTraceEntryNoContent { + + return &DeleteTraceEntryNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTraceEntryNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTraceEntryNotFoundCode is the HTTP code returned for type DeleteTraceEntryNotFound +const DeleteTraceEntryNotFoundCode int = 404 + +/* +DeleteTraceEntryNotFound The specified resource was not found + +swagger:response deleteTraceEntryNotFound +*/ +type DeleteTraceEntryNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTraceEntryNotFound creates DeleteTraceEntryNotFound with default headers values +func NewDeleteTraceEntryNotFound() *DeleteTraceEntryNotFound { + + return &DeleteTraceEntryNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete trace entry not found response +func (o *DeleteTraceEntryNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTraceEntryNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete trace entry not found response +func (o *DeleteTraceEntryNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete trace entry not found response +func (o *DeleteTraceEntryNotFound) WithPayload(payload *models.Error) *DeleteTraceEntryNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete trace entry not found response +func (o *DeleteTraceEntryNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTraceEntryNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTraceEntryDefault General Error + +swagger:response deleteTraceEntryDefault +*/ +type DeleteTraceEntryDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTraceEntryDefault creates DeleteTraceEntryDefault with default headers values +func NewDeleteTraceEntryDefault(code int) *DeleteTraceEntryDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTraceEntryDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete trace entry default response +func (o *DeleteTraceEntryDefault) WithStatusCode(code int) *DeleteTraceEntryDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete trace entry default response +func (o *DeleteTraceEntryDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete trace entry default response +func (o *DeleteTraceEntryDefault) WithConfigurationVersion(configurationVersion string) *DeleteTraceEntryDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete trace entry default response +func (o *DeleteTraceEntryDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete trace entry default response +func (o *DeleteTraceEntryDefault) WithPayload(payload *models.Error) *DeleteTraceEntryDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete trace entry default response +func (o *DeleteTraceEntryDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTraceEntryDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/traces/delete_trace_entry_urlbuilder.go b/operations/traces/delete_trace_entry_urlbuilder.go new file mode 100644 index 00000000..e2665b0e --- /dev/null +++ b/operations/traces/delete_trace_entry_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// DeleteTraceEntryURL generates an URL for the delete trace entry operation +type DeleteTraceEntryURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTraceEntryURL) WithBasePath(bp string) *DeleteTraceEntryURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTraceEntryURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTraceEntryURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/traces/entries" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTraceEntryURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTraceEntryURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTraceEntryURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTraceEntryURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTraceEntryURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTraceEntryURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/traces/delete_traces.go b/operations/traces/delete_traces.go new file mode 100644 index 00000000..1c62e919 --- /dev/null +++ b/operations/traces/delete_traces.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteTracesHandlerFunc turns a function with the right signature into a delete traces handler +type DeleteTracesHandlerFunc func(DeleteTracesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteTracesHandlerFunc) Handle(params DeleteTracesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteTracesHandler interface for that can handle valid delete traces params +type DeleteTracesHandler interface { + Handle(DeleteTracesParams, interface{}) middleware.Responder +} + +// NewDeleteTraces creates a new http.Handler for the delete traces operation +func NewDeleteTraces(ctx *middleware.Context, handler DeleteTracesHandler) *DeleteTraces { + return &DeleteTraces{Context: ctx, Handler: handler} +} + +/* + DeleteTraces swagger:route DELETE /services/haproxy/configuration/traces Traces deleteTraces + +# Delete the traces section + +Delete the whole traces section. +*/ +type DeleteTraces struct { + Context *middleware.Context + Handler DeleteTracesHandler +} + +func (o *DeleteTraces) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteTracesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/traces/delete_traces_parameters.go b/operations/traces/delete_traces_parameters.go new file mode 100644 index 00000000..4531a1aa --- /dev/null +++ b/operations/traces/delete_traces_parameters.go @@ -0,0 +1,166 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteTracesParams creates a new DeleteTracesParams object +// with the default values initialized. +func NewDeleteTracesParams() DeleteTracesParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteTracesParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteTracesParams contains all the bound params for the delete traces operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteTraces +type DeleteTracesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteTracesParams() beforehand. +func (o *DeleteTracesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteTracesParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteTracesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteTracesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteTracesParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/traces/delete_traces_responses.go b/operations/traces/delete_traces_responses.go new file mode 100644 index 00000000..253c4f4a --- /dev/null +++ b/operations/traces/delete_traces_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteTracesAcceptedCode is the HTTP code returned for type DeleteTracesAccepted +const DeleteTracesAcceptedCode int = 202 + +/* +DeleteTracesAccepted Configuration change accepted and reload requested + +swagger:response deleteTracesAccepted +*/ +type DeleteTracesAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteTracesAccepted creates DeleteTracesAccepted with default headers values +func NewDeleteTracesAccepted() *DeleteTracesAccepted { + + return &DeleteTracesAccepted{} +} + +// WithReloadID adds the reloadId to the delete traces accepted response +func (o *DeleteTracesAccepted) WithReloadID(reloadID string) *DeleteTracesAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete traces accepted response +func (o *DeleteTracesAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteTracesAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteTracesNoContentCode is the HTTP code returned for type DeleteTracesNoContent +const DeleteTracesNoContentCode int = 204 + +/* +DeleteTracesNoContent Traces section deleted + +swagger:response deleteTracesNoContent +*/ +type DeleteTracesNoContent struct { +} + +// NewDeleteTracesNoContent creates DeleteTracesNoContent with default headers values +func NewDeleteTracesNoContent() *DeleteTracesNoContent { + + return &DeleteTracesNoContent{} +} + +// WriteResponse to the client +func (o *DeleteTracesNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteTracesNotFoundCode is the HTTP code returned for type DeleteTracesNotFound +const DeleteTracesNotFoundCode int = 404 + +/* +DeleteTracesNotFound The specified resource was not found + +swagger:response deleteTracesNotFound +*/ +type DeleteTracesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTracesNotFound creates DeleteTracesNotFound with default headers values +func NewDeleteTracesNotFound() *DeleteTracesNotFound { + + return &DeleteTracesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete traces not found response +func (o *DeleteTracesNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTracesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete traces not found response +func (o *DeleteTracesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete traces not found response +func (o *DeleteTracesNotFound) WithPayload(payload *models.Error) *DeleteTracesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete traces not found response +func (o *DeleteTracesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTracesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteTracesDefault General Error + +swagger:response deleteTracesDefault +*/ +type DeleteTracesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteTracesDefault creates DeleteTracesDefault with default headers values +func NewDeleteTracesDefault(code int) *DeleteTracesDefault { + if code <= 0 { + code = 500 + } + + return &DeleteTracesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete traces default response +func (o *DeleteTracesDefault) WithStatusCode(code int) *DeleteTracesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete traces default response +func (o *DeleteTracesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete traces default response +func (o *DeleteTracesDefault) WithConfigurationVersion(configurationVersion string) *DeleteTracesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete traces default response +func (o *DeleteTracesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete traces default response +func (o *DeleteTracesDefault) WithPayload(payload *models.Error) *DeleteTracesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete traces default response +func (o *DeleteTracesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteTracesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/traces/delete_traces_urlbuilder.go b/operations/traces/delete_traces_urlbuilder.go new file mode 100644 index 00000000..66e2e866 --- /dev/null +++ b/operations/traces/delete_traces_urlbuilder.go @@ -0,0 +1,138 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// DeleteTracesURL generates an URL for the delete traces operation +type DeleteTracesURL struct { + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTracesURL) WithBasePath(bp string) *DeleteTracesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteTracesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteTracesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/traces" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteTracesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteTracesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteTracesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteTracesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteTracesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteTracesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/traces/get_traces.go b/operations/traces/get_traces.go new file mode 100644 index 00000000..5acaec19 --- /dev/null +++ b/operations/traces/get_traces.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetTracesHandlerFunc turns a function with the right signature into a get traces handler +type GetTracesHandlerFunc func(GetTracesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetTracesHandlerFunc) Handle(params GetTracesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetTracesHandler interface for that can handle valid get traces params +type GetTracesHandler interface { + Handle(GetTracesParams, interface{}) middleware.Responder +} + +// NewGetTraces creates a new http.Handler for the get traces operation +func NewGetTraces(ctx *middleware.Context, handler GetTracesHandler) *GetTraces { + return &GetTraces{Context: ctx, Handler: handler} +} + +/* + GetTraces swagger:route GET /services/haproxy/configuration/traces Traces getTraces + +# Return the traces section contents + +Return the traces section contents. +*/ +type GetTraces struct { + Context *middleware.Context + Handler GetTracesHandler +} + +func (o *GetTraces) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetTracesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/traces/get_traces_parameters.go b/operations/traces/get_traces_parameters.go new file mode 100644 index 00000000..dbdba2c0 --- /dev/null +++ b/operations/traces/get_traces_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetTracesParams creates a new GetTracesParams object +// with the default values initialized. +func NewGetTracesParams() GetTracesParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetTracesParams{ + FullSection: &fullSectionDefault, + } +} + +// GetTracesParams contains all the bound params for the get traces operation +// typically these are obtained from a http.Request +// +// swagger:parameters getTraces +type GetTracesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetTracesParams() beforehand. +func (o *GetTracesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetTracesParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetTracesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetTracesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/traces/get_traces_responses.go b/operations/traces/get_traces_responses.go new file mode 100644 index 00000000..b98fed5f --- /dev/null +++ b/operations/traces/get_traces_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetTracesOKCode is the HTTP code returned for type GetTracesOK +const GetTracesOKCode int = 200 + +/* +GetTracesOK Successful operation + +swagger:response getTracesOK +*/ +type GetTracesOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Traces `json:"body,omitempty"` +} + +// NewGetTracesOK creates GetTracesOK with default headers values +func NewGetTracesOK() *GetTracesOK { + + return &GetTracesOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get traces o k response +func (o *GetTracesOK) WithConfigurationVersion(configurationVersion string) *GetTracesOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get traces o k response +func (o *GetTracesOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get traces o k response +func (o *GetTracesOK) WithPayload(payload *models.Traces) *GetTracesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get traces o k response +func (o *GetTracesOK) SetPayload(payload *models.Traces) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTracesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetTracesNotFoundCode is the HTTP code returned for type GetTracesNotFound +const GetTracesNotFoundCode int = 404 + +/* +GetTracesNotFound The specified resource was not found + +swagger:response getTracesNotFound +*/ +type GetTracesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTracesNotFound creates GetTracesNotFound with default headers values +func NewGetTracesNotFound() *GetTracesNotFound { + + return &GetTracesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get traces not found response +func (o *GetTracesNotFound) WithConfigurationVersion(configurationVersion string) *GetTracesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get traces not found response +func (o *GetTracesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get traces not found response +func (o *GetTracesNotFound) WithPayload(payload *models.Error) *GetTracesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get traces not found response +func (o *GetTracesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTracesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetTracesDefault General Error + +swagger:response getTracesDefault +*/ +type GetTracesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetTracesDefault creates GetTracesDefault with default headers values +func NewGetTracesDefault(code int) *GetTracesDefault { + if code <= 0 { + code = 500 + } + + return &GetTracesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get traces default response +func (o *GetTracesDefault) WithStatusCode(code int) *GetTracesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get traces default response +func (o *GetTracesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get traces default response +func (o *GetTracesDefault) WithConfigurationVersion(configurationVersion string) *GetTracesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get traces default response +func (o *GetTracesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get traces default response +func (o *GetTracesDefault) WithPayload(payload *models.Error) *GetTracesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get traces default response +func (o *GetTracesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetTracesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/traces/get_traces_urlbuilder.go b/operations/traces/get_traces_urlbuilder.go new file mode 100644 index 00000000..638dc31e --- /dev/null +++ b/operations/traces/get_traces_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetTracesURL generates an URL for the get traces operation +type GetTracesURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTracesURL) WithBasePath(bp string) *GetTracesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetTracesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetTracesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/traces" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetTracesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetTracesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetTracesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetTracesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetTracesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetTracesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/traces/replace_traces.go b/operations/traces/replace_traces.go new file mode 100644 index 00000000..d353da20 --- /dev/null +++ b/operations/traces/replace_traces.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceTracesHandlerFunc turns a function with the right signature into a replace traces handler +type ReplaceTracesHandlerFunc func(ReplaceTracesParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceTracesHandlerFunc) Handle(params ReplaceTracesParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceTracesHandler interface for that can handle valid replace traces params +type ReplaceTracesHandler interface { + Handle(ReplaceTracesParams, interface{}) middleware.Responder +} + +// NewReplaceTraces creates a new http.Handler for the replace traces operation +func NewReplaceTraces(ctx *middleware.Context, handler ReplaceTracesHandler) *ReplaceTraces { + return &ReplaceTraces{Context: ctx, Handler: handler} +} + +/* + ReplaceTraces swagger:route PUT /services/haproxy/configuration/traces Traces replaceTraces + +# Replace traces + +Replace the traces section contents +*/ +type ReplaceTraces struct { + Context *middleware.Context + Handler ReplaceTracesHandler +} + +func (o *ReplaceTraces) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceTracesParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/traces/replace_traces_parameters.go b/operations/traces/replace_traces_parameters.go new file mode 100644 index 00000000..d03db2e8 --- /dev/null +++ b/operations/traces/replace_traces_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceTracesParams creates a new ReplaceTracesParams object +// with the default values initialized. +func NewReplaceTracesParams() ReplaceTracesParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return ReplaceTracesParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// ReplaceTracesParams contains all the bound params for the replace traces operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceTraces +type ReplaceTracesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Traces + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceTracesParams() beforehand. +func (o *ReplaceTracesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Traces + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceTracesParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTracesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *ReplaceTracesParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceTracesParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceTracesParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceTracesParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/traces/replace_traces_responses.go b/operations/traces/replace_traces_responses.go new file mode 100644 index 00000000..b21ec909 --- /dev/null +++ b/operations/traces/replace_traces_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceTracesOKCode is the HTTP code returned for type ReplaceTracesOK +const ReplaceTracesOKCode int = 200 + +/* +ReplaceTracesOK Traces replaced + +swagger:response replaceTracesOK +*/ +type ReplaceTracesOK struct { + + /* + In: Body + */ + Payload *models.Traces `json:"body,omitempty"` +} + +// NewReplaceTracesOK creates ReplaceTracesOK with default headers values +func NewReplaceTracesOK() *ReplaceTracesOK { + + return &ReplaceTracesOK{} +} + +// WithPayload adds the payload to the replace traces o k response +func (o *ReplaceTracesOK) WithPayload(payload *models.Traces) *ReplaceTracesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace traces o k response +func (o *ReplaceTracesOK) SetPayload(payload *models.Traces) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTracesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTracesAcceptedCode is the HTTP code returned for type ReplaceTracesAccepted +const ReplaceTracesAcceptedCode int = 202 + +/* +ReplaceTracesAccepted Configuration change accepted and reload requested + +swagger:response replaceTracesAccepted +*/ +type ReplaceTracesAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Traces `json:"body,omitempty"` +} + +// NewReplaceTracesAccepted creates ReplaceTracesAccepted with default headers values +func NewReplaceTracesAccepted() *ReplaceTracesAccepted { + + return &ReplaceTracesAccepted{} +} + +// WithReloadID adds the reloadId to the replace traces accepted response +func (o *ReplaceTracesAccepted) WithReloadID(reloadID string) *ReplaceTracesAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace traces accepted response +func (o *ReplaceTracesAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace traces accepted response +func (o *ReplaceTracesAccepted) WithPayload(payload *models.Traces) *ReplaceTracesAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace traces accepted response +func (o *ReplaceTracesAccepted) SetPayload(payload *models.Traces) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTracesAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTracesBadRequestCode is the HTTP code returned for type ReplaceTracesBadRequest +const ReplaceTracesBadRequestCode int = 400 + +/* +ReplaceTracesBadRequest Bad request + +swagger:response replaceTracesBadRequest +*/ +type ReplaceTracesBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTracesBadRequest creates ReplaceTracesBadRequest with default headers values +func NewReplaceTracesBadRequest() *ReplaceTracesBadRequest { + + return &ReplaceTracesBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace traces bad request response +func (o *ReplaceTracesBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceTracesBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace traces bad request response +func (o *ReplaceTracesBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace traces bad request response +func (o *ReplaceTracesBadRequest) WithPayload(payload *models.Error) *ReplaceTracesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace traces bad request response +func (o *ReplaceTracesBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTracesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceTracesNotFoundCode is the HTTP code returned for type ReplaceTracesNotFound +const ReplaceTracesNotFoundCode int = 404 + +/* +ReplaceTracesNotFound The specified resource was not found + +swagger:response replaceTracesNotFound +*/ +type ReplaceTracesNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTracesNotFound creates ReplaceTracesNotFound with default headers values +func NewReplaceTracesNotFound() *ReplaceTracesNotFound { + + return &ReplaceTracesNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace traces not found response +func (o *ReplaceTracesNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceTracesNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace traces not found response +func (o *ReplaceTracesNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace traces not found response +func (o *ReplaceTracesNotFound) WithPayload(payload *models.Error) *ReplaceTracesNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace traces not found response +func (o *ReplaceTracesNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTracesNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceTracesDefault General Error + +swagger:response replaceTracesDefault +*/ +type ReplaceTracesDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceTracesDefault creates ReplaceTracesDefault with default headers values +func NewReplaceTracesDefault(code int) *ReplaceTracesDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceTracesDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace traces default response +func (o *ReplaceTracesDefault) WithStatusCode(code int) *ReplaceTracesDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace traces default response +func (o *ReplaceTracesDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace traces default response +func (o *ReplaceTracesDefault) WithConfigurationVersion(configurationVersion string) *ReplaceTracesDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace traces default response +func (o *ReplaceTracesDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace traces default response +func (o *ReplaceTracesDefault) WithPayload(payload *models.Error) *ReplaceTracesDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace traces default response +func (o *ReplaceTracesDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceTracesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/traces/replace_traces_urlbuilder.go b/operations/traces/replace_traces_urlbuilder.go new file mode 100644 index 00000000..44209481 --- /dev/null +++ b/operations/traces/replace_traces_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package traces + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// ReplaceTracesURL generates an URL for the replace traces operation +type ReplaceTracesURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTracesURL) WithBasePath(bp string) *ReplaceTracesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceTracesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceTracesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/traces" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceTracesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceTracesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceTracesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceTracesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceTracesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceTracesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/transactions/commit_transaction.go b/operations/transactions/commit_transaction.go index 39ab9bf1..aea62de6 100644 --- a/operations/transactions/commit_transaction.go +++ b/operations/transactions/commit_transaction.go @@ -23,7 +23,7 @@ package transactions import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // CommitTransactionHandlerFunc turns a function with the right signature into a commit transaction handler @@ -44,12 +44,12 @@ func NewCommitTransaction(ctx *middleware.Context, handler CommitTransactionHand return &CommitTransaction{Context: ctx, Handler: handler} } -/*CommitTransaction swagger:route PUT /services/haproxy/transactions/{id} Transactions commitTransaction +/* + CommitTransaction swagger:route PUT /services/haproxy/transactions/{id} Transactions commitTransaction -Commit transaction +# Commit transaction Commit transaction, execute all operations in transaction and return msg - */ type CommitTransaction struct { Context *middleware.Context @@ -59,21 +59,20 @@ type CommitTransaction struct { func (o *CommitTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewCommitTransactionParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *CommitTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/transactions/commit_transaction_parameters.go b/operations/transactions/commit_transaction_parameters.go index eade5c77..4bfe1e70 100644 --- a/operations/transactions/commit_transaction_parameters.go +++ b/operations/transactions/commit_transaction_parameters.go @@ -26,9 +26,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - - strfmt "github.com/go-openapi/strfmt" ) // NewCommitTransactionParams creates a new CommitTransactionParams object @@ -87,7 +86,6 @@ func (o *CommitTransactionParams) BindRequest(r *http.Request, route *middleware if err := o.bindID(rID, rhkID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -103,6 +101,7 @@ func (o *CommitTransactionParams) bindForceReload(rawData []string, hasKey bool, // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations // Default values have been previously initialized by NewCommitTransactionParams() return nil @@ -126,7 +125,6 @@ func (o *CommitTransactionParams) bindID(rawData []string, hasKey bool, formats // Required: true // Parameter is provided by construction from the route - o.ID = raw return nil diff --git a/operations/transactions/commit_transaction_responses.go b/operations/transactions/commit_transaction_responses.go index 0b886595..30a02783 100644 --- a/operations/transactions/commit_transaction_responses.go +++ b/operations/transactions/commit_transaction_responses.go @@ -24,19 +24,23 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // CommitTransactionOKCode is the HTTP code returned for type CommitTransactionOK const CommitTransactionOKCode int = 200 -/*CommitTransactionOK Transaction succesfully commited +/* +CommitTransactionOK Transaction successfully committed swagger:response commitTransactionOK */ type CommitTransactionOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -50,6 +54,17 @@ func NewCommitTransactionOK() *CommitTransactionOK { return &CommitTransactionOK{} } +// WithConfigurationVersion adds the configurationVersion to the commit transaction o k response +func (o *CommitTransactionOK) WithConfigurationVersion(configurationVersion string) *CommitTransactionOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the commit transaction o k response +func (o *CommitTransactionOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + // WithPayload adds the payload to the commit transaction o k response func (o *CommitTransactionOK) WithPayload(payload *models.Transaction) *CommitTransactionOK { o.Payload = payload @@ -64,6 +79,13 @@ func (o *CommitTransactionOK) SetPayload(payload *models.Transaction) { // WriteResponse to the client func (o *CommitTransactionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + rw.WriteHeader(200) if o.Payload != nil { payload := o.Payload @@ -76,11 +98,16 @@ func (o *CommitTransactionOK) WriteResponse(rw http.ResponseWriter, producer run // CommitTransactionAcceptedCode is the HTTP code returned for type CommitTransactionAccepted const CommitTransactionAcceptedCode int = 202 -/*CommitTransactionAccepted Configuration change accepted and reload requested +/* +CommitTransactionAccepted Configuration change accepted and reload requested swagger:response commitTransactionAccepted */ type CommitTransactionAccepted struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` /*ID of the requested reload */ @@ -98,6 +125,17 @@ func NewCommitTransactionAccepted() *CommitTransactionAccepted { return &CommitTransactionAccepted{} } +// WithConfigurationVersion adds the configurationVersion to the commit transaction accepted response +func (o *CommitTransactionAccepted) WithConfigurationVersion(configurationVersion string) *CommitTransactionAccepted { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the commit transaction accepted response +func (o *CommitTransactionAccepted) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + // WithReloadID adds the reloadId to the commit transaction accepted response func (o *CommitTransactionAccepted) WithReloadID(reloadID string) *CommitTransactionAccepted { o.ReloadID = reloadID @@ -123,6 +161,13 @@ func (o *CommitTransactionAccepted) SetPayload(payload *models.Transaction) { // WriteResponse to the client func (o *CommitTransactionAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + // response header Reload-ID reloadID := o.ReloadID @@ -142,7 +187,8 @@ func (o *CommitTransactionAccepted) WriteResponse(rw http.ResponseWriter, produc // CommitTransactionBadRequestCode is the HTTP code returned for type CommitTransactionBadRequest const CommitTransactionBadRequestCode int = 400 -/*CommitTransactionBadRequest Bad request +/* +CommitTransactionBadRequest Bad request swagger:response commitTransactionBadRequest */ @@ -150,7 +196,7 @@ type CommitTransactionBadRequest struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -165,13 +211,13 @@ func NewCommitTransactionBadRequest() *CommitTransactionBadRequest { } // WithConfigurationVersion adds the configurationVersion to the commit transaction bad request response -func (o *CommitTransactionBadRequest) WithConfigurationVersion(configurationVersion int64) *CommitTransactionBadRequest { +func (o *CommitTransactionBadRequest) WithConfigurationVersion(configurationVersion string) *CommitTransactionBadRequest { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the commit transaction bad request response -func (o *CommitTransactionBadRequest) SetConfigurationVersion(configurationVersion int64) { +func (o *CommitTransactionBadRequest) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -191,7 +237,7 @@ func (o *CommitTransactionBadRequest) WriteResponse(rw http.ResponseWriter, prod // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -208,7 +254,8 @@ func (o *CommitTransactionBadRequest) WriteResponse(rw http.ResponseWriter, prod // CommitTransactionNotFoundCode is the HTTP code returned for type CommitTransactionNotFound const CommitTransactionNotFoundCode int = 404 -/*CommitTransactionNotFound The specified resource was not found +/* +CommitTransactionNotFound The specified resource was not found swagger:response commitTransactionNotFound */ @@ -216,7 +263,7 @@ type CommitTransactionNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -231,13 +278,13 @@ func NewCommitTransactionNotFound() *CommitTransactionNotFound { } // WithConfigurationVersion adds the configurationVersion to the commit transaction not found response -func (o *CommitTransactionNotFound) WithConfigurationVersion(configurationVersion int64) *CommitTransactionNotFound { +func (o *CommitTransactionNotFound) WithConfigurationVersion(configurationVersion string) *CommitTransactionNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the commit transaction not found response -func (o *CommitTransactionNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *CommitTransactionNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -257,7 +304,7 @@ func (o *CommitTransactionNotFound) WriteResponse(rw http.ResponseWriter, produc // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -271,7 +318,75 @@ func (o *CommitTransactionNotFound) WriteResponse(rw http.ResponseWriter, produc } } -/*CommitTransactionDefault General Error +// CommitTransactionNotAcceptableCode is the HTTP code returned for type CommitTransactionNotAcceptable +const CommitTransactionNotAcceptableCode int = 406 + +/* +CommitTransactionNotAcceptable The specified resource cannot be handled + +swagger:response commitTransactionNotAcceptable +*/ +type CommitTransactionNotAcceptable struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCommitTransactionNotAcceptable creates CommitTransactionNotAcceptable with default headers values +func NewCommitTransactionNotAcceptable() *CommitTransactionNotAcceptable { + + return &CommitTransactionNotAcceptable{} +} + +// WithConfigurationVersion adds the configurationVersion to the commit transaction not acceptable response +func (o *CommitTransactionNotAcceptable) WithConfigurationVersion(configurationVersion string) *CommitTransactionNotAcceptable { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the commit transaction not acceptable response +func (o *CommitTransactionNotAcceptable) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the commit transaction not acceptable response +func (o *CommitTransactionNotAcceptable) WithPayload(payload *models.Error) *CommitTransactionNotAcceptable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the commit transaction not acceptable response +func (o *CommitTransactionNotAcceptable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CommitTransactionNotAcceptable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(406) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CommitTransactionDefault General Error swagger:response commitTransactionDefault */ @@ -280,7 +395,7 @@ type CommitTransactionDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -311,13 +426,13 @@ func (o *CommitTransactionDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the commit transaction default response -func (o *CommitTransactionDefault) WithConfigurationVersion(configurationVersion int64) *CommitTransactionDefault { +func (o *CommitTransactionDefault) WithConfigurationVersion(configurationVersion string) *CommitTransactionDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the commit transaction default response -func (o *CommitTransactionDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *CommitTransactionDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -337,7 +452,7 @@ func (o *CommitTransactionDefault) WriteResponse(rw http.ResponseWriter, produce // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/transactions/commit_transaction_urlbuilder.go b/operations/transactions/commit_transaction_urlbuilder.go index 928df9bb..a7fa52f0 100644 --- a/operations/transactions/commit_transaction_urlbuilder.go +++ b/operations/transactions/commit_transaction_urlbuilder.go @@ -70,18 +70,18 @@ func (o *CommitTransactionURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var forceReload string + var forceReloadQ string if o.ForceReload != nil { - forceReload = swag.FormatBool(*o.ForceReload) + forceReloadQ = swag.FormatBool(*o.ForceReload) } - if forceReload != "" { - qs.Set("force_reload", forceReload) + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) } _result.RawQuery = qs.Encode() diff --git a/operations/transactions/delete_transaction.go b/operations/transactions/delete_transaction.go index 85ee8ee5..0eca2f9f 100644 --- a/operations/transactions/delete_transaction.go +++ b/operations/transactions/delete_transaction.go @@ -23,7 +23,7 @@ package transactions import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // DeleteTransactionHandlerFunc turns a function with the right signature into a delete transaction handler @@ -44,12 +44,12 @@ func NewDeleteTransaction(ctx *middleware.Context, handler DeleteTransactionHand return &DeleteTransaction{Context: ctx, Handler: handler} } -/*DeleteTransaction swagger:route DELETE /services/haproxy/transactions/{id} Transactions deleteTransaction +/* + DeleteTransaction swagger:route DELETE /services/haproxy/transactions/{id} Transactions deleteTransaction -Delete a transaction +# Delete a transaction Deletes a transaction. - */ type DeleteTransaction struct { Context *middleware.Context @@ -59,21 +59,20 @@ type DeleteTransaction struct { func (o *DeleteTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewDeleteTransactionParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *DeleteTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/transactions/delete_transaction_parameters.go b/operations/transactions/delete_transaction_parameters.go index 8fdfd624..a88477c5 100644 --- a/operations/transactions/delete_transaction_parameters.go +++ b/operations/transactions/delete_transaction_parameters.go @@ -25,12 +25,12 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewDeleteTransactionParams creates a new DeleteTransactionParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewDeleteTransactionParams() DeleteTransactionParams { return DeleteTransactionParams{} @@ -65,7 +65,6 @@ func (o *DeleteTransactionParams) BindRequest(r *http.Request, route *middleware if err := o.bindID(rID, rhkID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -81,7 +80,6 @@ func (o *DeleteTransactionParams) bindID(rawData []string, hasKey bool, formats // Required: true // Parameter is provided by construction from the route - o.ID = raw return nil diff --git a/operations/transactions/delete_transaction_responses.go b/operations/transactions/delete_transaction_responses.go index 533aef84..21841b71 100644 --- a/operations/transactions/delete_transaction_responses.go +++ b/operations/transactions/delete_transaction_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // DeleteTransactionNoContentCode is the HTTP code returned for type DeleteTransactionNoContent const DeleteTransactionNoContentCode int = 204 -/*DeleteTransactionNoContent Transaction deleted +/* +DeleteTransactionNoContent Transaction deleted swagger:response deleteTransactionNoContent */ @@ -56,7 +56,8 @@ func (o *DeleteTransactionNoContent) WriteResponse(rw http.ResponseWriter, produ // DeleteTransactionNotFoundCode is the HTTP code returned for type DeleteTransactionNotFound const DeleteTransactionNotFoundCode int = 404 -/*DeleteTransactionNotFound The specified resource was not found +/* +DeleteTransactionNotFound The specified resource was not found swagger:response deleteTransactionNotFound */ @@ -64,7 +65,7 @@ type DeleteTransactionNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -79,13 +80,13 @@ func NewDeleteTransactionNotFound() *DeleteTransactionNotFound { } // WithConfigurationVersion adds the configurationVersion to the delete transaction not found response -func (o *DeleteTransactionNotFound) WithConfigurationVersion(configurationVersion int64) *DeleteTransactionNotFound { +func (o *DeleteTransactionNotFound) WithConfigurationVersion(configurationVersion string) *DeleteTransactionNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete transaction not found response -func (o *DeleteTransactionNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteTransactionNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -105,7 +106,7 @@ func (o *DeleteTransactionNotFound) WriteResponse(rw http.ResponseWriter, produc // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -119,7 +120,8 @@ func (o *DeleteTransactionNotFound) WriteResponse(rw http.ResponseWriter, produc } } -/*DeleteTransactionDefault General Error +/* +DeleteTransactionDefault General Error swagger:response deleteTransactionDefault */ @@ -128,7 +130,7 @@ type DeleteTransactionDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -159,13 +161,13 @@ func (o *DeleteTransactionDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the delete transaction default response -func (o *DeleteTransactionDefault) WithConfigurationVersion(configurationVersion int64) *DeleteTransactionDefault { +func (o *DeleteTransactionDefault) WithConfigurationVersion(configurationVersion string) *DeleteTransactionDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the delete transaction default response -func (o *DeleteTransactionDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *DeleteTransactionDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -185,7 +187,7 @@ func (o *DeleteTransactionDefault) WriteResponse(rw http.ResponseWriter, produce // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/transactions/delete_transaction_urlbuilder.go b/operations/transactions/delete_transaction_urlbuilder.go index 5f22a37f..54e156ec 100644 --- a/operations/transactions/delete_transaction_urlbuilder.go +++ b/operations/transactions/delete_transaction_urlbuilder.go @@ -66,7 +66,7 @@ func (o *DeleteTransactionURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/transactions/get_transaction.go b/operations/transactions/get_transaction.go index 6aa8a71d..4a8158d2 100644 --- a/operations/transactions/get_transaction.go +++ b/operations/transactions/get_transaction.go @@ -23,7 +23,7 @@ package transactions import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetTransactionHandlerFunc turns a function with the right signature into a get transaction handler @@ -44,12 +44,12 @@ func NewGetTransaction(ctx *middleware.Context, handler GetTransactionHandler) * return &GetTransaction{Context: ctx, Handler: handler} } -/*GetTransaction swagger:route GET /services/haproxy/transactions/{id} Transactions getTransaction +/* + GetTransaction swagger:route GET /services/haproxy/transactions/{id} Transactions getTransaction -Return one HAProxy configuration transactions +# Return one HAProxy configuration transactions Returns one HAProxy configuration transactions. - */ type GetTransaction struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetTransaction struct { func (o *GetTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetTransactionParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/transactions/get_transaction_parameters.go b/operations/transactions/get_transaction_parameters.go index 6349dad8..6f54d693 100644 --- a/operations/transactions/get_transaction_parameters.go +++ b/operations/transactions/get_transaction_parameters.go @@ -25,12 +25,12 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" - - strfmt "github.com/go-openapi/strfmt" + "github.com/go-openapi/strfmt" ) // NewGetTransactionParams creates a new GetTransactionParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetTransactionParams() GetTransactionParams { return GetTransactionParams{} @@ -65,7 +65,6 @@ func (o *GetTransactionParams) BindRequest(r *http.Request, route *middleware.Ma if err := o.bindID(rID, rhkID, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -81,7 +80,6 @@ func (o *GetTransactionParams) bindID(rawData []string, hasKey bool, formats str // Required: true // Parameter is provided by construction from the route - o.ID = raw return nil diff --git a/operations/transactions/get_transaction_responses.go b/operations/transactions/get_transaction_responses.go index 49c7e6d4..bdadf191 100644 --- a/operations/transactions/get_transaction_responses.go +++ b/operations/transactions/get_transaction_responses.go @@ -24,19 +24,23 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetTransactionOKCode is the HTTP code returned for type GetTransactionOK const GetTransactionOKCode int = 200 -/*GetTransactionOK Successful operation +/* +GetTransactionOK Successful operation swagger:response getTransactionOK */ type GetTransactionOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -50,6 +54,17 @@ func NewGetTransactionOK() *GetTransactionOK { return &GetTransactionOK{} } +// WithConfigurationVersion adds the configurationVersion to the get transaction o k response +func (o *GetTransactionOK) WithConfigurationVersion(configurationVersion string) *GetTransactionOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get transaction o k response +func (o *GetTransactionOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + // WithPayload adds the payload to the get transaction o k response func (o *GetTransactionOK) WithPayload(payload *models.Transaction) *GetTransactionOK { o.Payload = payload @@ -64,6 +79,13 @@ func (o *GetTransactionOK) SetPayload(payload *models.Transaction) { // WriteResponse to the client func (o *GetTransactionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + rw.WriteHeader(200) if o.Payload != nil { payload := o.Payload @@ -76,7 +98,8 @@ func (o *GetTransactionOK) WriteResponse(rw http.ResponseWriter, producer runtim // GetTransactionNotFoundCode is the HTTP code returned for type GetTransactionNotFound const GetTransactionNotFoundCode int = 404 -/*GetTransactionNotFound The specified resource was not found +/* +GetTransactionNotFound The specified resource was not found swagger:response getTransactionNotFound */ @@ -84,7 +107,7 @@ type GetTransactionNotFound struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -99,13 +122,13 @@ func NewGetTransactionNotFound() *GetTransactionNotFound { } // WithConfigurationVersion adds the configurationVersion to the get transaction not found response -func (o *GetTransactionNotFound) WithConfigurationVersion(configurationVersion int64) *GetTransactionNotFound { +func (o *GetTransactionNotFound) WithConfigurationVersion(configurationVersion string) *GetTransactionNotFound { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get transaction not found response -func (o *GetTransactionNotFound) SetConfigurationVersion(configurationVersion int64) { +func (o *GetTransactionNotFound) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -125,7 +148,7 @@ func (o *GetTransactionNotFound) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } @@ -139,7 +162,8 @@ func (o *GetTransactionNotFound) WriteResponse(rw http.ResponseWriter, producer } } -/*GetTransactionDefault General Error +/* +GetTransactionDefault General Error swagger:response getTransactionDefault */ @@ -148,7 +172,7 @@ type GetTransactionDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -179,13 +203,13 @@ func (o *GetTransactionDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get transaction default response -func (o *GetTransactionDefault) WithConfigurationVersion(configurationVersion int64) *GetTransactionDefault { +func (o *GetTransactionDefault) WithConfigurationVersion(configurationVersion string) *GetTransactionDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get transaction default response -func (o *GetTransactionDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetTransactionDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -205,7 +229,7 @@ func (o *GetTransactionDefault) WriteResponse(rw http.ResponseWriter, producer r // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/transactions/get_transaction_urlbuilder.go b/operations/transactions/get_transaction_urlbuilder.go index 58f26b58..f58256a2 100644 --- a/operations/transactions/get_transaction_urlbuilder.go +++ b/operations/transactions/get_transaction_urlbuilder.go @@ -66,7 +66,7 @@ func (o *GetTransactionURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/operations/transactions/get_transactions.go b/operations/transactions/get_transactions.go index d3781194..2a15d89d 100644 --- a/operations/transactions/get_transactions.go +++ b/operations/transactions/get_transactions.go @@ -23,7 +23,7 @@ package transactions import ( "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" ) // GetTransactionsHandlerFunc turns a function with the right signature into a get transactions handler @@ -44,12 +44,12 @@ func NewGetTransactions(ctx *middleware.Context, handler GetTransactionsHandler) return &GetTransactions{Context: ctx, Handler: handler} } -/*GetTransactions swagger:route GET /services/haproxy/transactions Transactions getTransactions +/* + GetTransactions swagger:route GET /services/haproxy/transactions Transactions getTransactions Return list of HAProxy configuration transactions. Returns a list of HAProxy configuration transactions. Transactions can be filtered by their status. - */ type GetTransactions struct { Context *middleware.Context @@ -59,21 +59,20 @@ type GetTransactions struct { func (o *GetTransactions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewGetTransactionsParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +81,6 @@ func (o *GetTransactions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } diff --git a/operations/transactions/get_transactions_parameters.go b/operations/transactions/get_transactions_parameters.go index b903b815..7843dd56 100644 --- a/operations/transactions/get_transactions_parameters.go +++ b/operations/transactions/get_transactions_parameters.go @@ -26,13 +26,13 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewGetTransactionsParams creates a new GetTransactionsParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewGetTransactionsParams() GetTransactionsParams { return GetTransactionsParams{} @@ -68,7 +68,6 @@ func (o *GetTransactionsParams) BindRequest(r *http.Request, route *middleware.M if err := o.bindStatus(qStatus, qhkStatus, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -84,10 +83,10 @@ func (o *GetTransactionsParams) bindStatus(rawData []string, hasKey bool, format // Required: false // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations return nil } - o.Status = &raw if err := o.validateStatus(formats); err != nil { @@ -100,7 +99,7 @@ func (o *GetTransactionsParams) bindStatus(rawData []string, hasKey bool, format // validateStatus carries on validations for parameter Status func (o *GetTransactionsParams) validateStatus(formats strfmt.Registry) error { - if err := validate.Enum("status", "query", *o.Status, []interface{}{"failed", "in_progress"}); err != nil { + if err := validate.EnumCase("status", "query", *o.Status, []interface{}{"failed", "in_progress"}, true); err != nil { return err } diff --git a/operations/transactions/get_transactions_responses.go b/operations/transactions/get_transactions_responses.go index c075cfcb..57f083e4 100644 --- a/operations/transactions/get_transactions_responses.go +++ b/operations/transactions/get_transactions_responses.go @@ -24,15 +24,15 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // GetTransactionsOKCode is the HTTP code returned for type GetTransactionsOK const GetTransactionsOKCode int = 200 -/*GetTransactionsOK Success +/* +GetTransactionsOK Success swagger:response getTransactionsOK */ @@ -76,7 +76,8 @@ func (o *GetTransactionsOK) WriteResponse(rw http.ResponseWriter, producer runti } } -/*GetTransactionsDefault General Error +/* +GetTransactionsDefault General Error swagger:response getTransactionsDefault */ @@ -85,7 +86,7 @@ type GetTransactionsDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -116,13 +117,13 @@ func (o *GetTransactionsDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the get transactions default response -func (o *GetTransactionsDefault) WithConfigurationVersion(configurationVersion int64) *GetTransactionsDefault { +func (o *GetTransactionsDefault) WithConfigurationVersion(configurationVersion string) *GetTransactionsDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the get transactions default response -func (o *GetTransactionsDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *GetTransactionsDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -142,7 +143,7 @@ func (o *GetTransactionsDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/transactions/get_transactions_urlbuilder.go b/operations/transactions/get_transactions_urlbuilder.go index d4905715..fea02a57 100644 --- a/operations/transactions/get_transactions_urlbuilder.go +++ b/operations/transactions/get_transactions_urlbuilder.go @@ -58,18 +58,18 @@ func (o *GetTransactionsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - var status string + var statusQ string if o.Status != nil { - status = *o.Status + statusQ = *o.Status } - if status != "" { - qs.Set("status", status) + if statusQ != "" { + qs.Set("status", statusQ) } _result.RawQuery = qs.Encode() diff --git a/operations/transactions/start_transaction.go b/operations/transactions/start_transaction.go index 106f7be5..e9192fa5 100644 --- a/operations/transactions/start_transaction.go +++ b/operations/transactions/start_transaction.go @@ -21,9 +21,12 @@ package transactions // Editing this file might prove futile when you re-run the generate command import ( + "context" "net/http" - middleware "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // StartTransactionHandlerFunc turns a function with the right signature into a start transaction handler @@ -44,12 +47,12 @@ func NewStartTransaction(ctx *middleware.Context, handler StartTransactionHandle return &StartTransaction{Context: ctx, Handler: handler} } -/*StartTransaction swagger:route POST /services/haproxy/transactions Transactions startTransaction +/* + StartTransaction swagger:route POST /services/haproxy/transactions Transactions startTransaction -Start a new transaction +# Start a new transaction Starts a new transaction and returns it's id - */ type StartTransaction struct { Context *middleware.Context @@ -59,21 +62,20 @@ type StartTransaction struct { func (o *StartTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { route, rCtx, _ := o.Context.RouteInfo(r) if rCtx != nil { - r = rCtx + *r = *rCtx } var Params = NewStartTransactionParams() - uprinc, aCtx, err := o.Context.Authorize(r, route) if err != nil { o.Context.Respond(rw, r, route.Produces, route, err) return } if aCtx != nil { - r = aCtx + *r = *aCtx } var principal interface{} if uprinc != nil { - principal = uprinc + principal = uprinc.(interface{}) // this is really a interface{}, I promise } if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params @@ -82,7 +84,47 @@ func (o *StartTransaction) ServeHTTP(rw http.ResponseWriter, r *http.Request) { } res := o.Handler.Handle(Params, principal) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) } + +// StartTransactionTooManyRequestsBody start transaction too many requests body +// Example: {"code":429,"message":"cannot start a new transaction, reached the maximum amount of 20 active transactions available"} +// +// swagger:model StartTransactionTooManyRequestsBody +type StartTransactionTooManyRequestsBody struct { + + // code + Code int64 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` +} + +// Validate validates this start transaction too many requests body +func (o *StartTransactionTooManyRequestsBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this start transaction too many requests body based on context it is used +func (o *StartTransactionTooManyRequestsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *StartTransactionTooManyRequestsBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *StartTransactionTooManyRequestsBody) UnmarshalBinary(b []byte) error { + var res StartTransactionTooManyRequestsBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/operations/transactions/start_transaction_parameters.go b/operations/transactions/start_transaction_parameters.go index b7bef040..d3999c24 100644 --- a/operations/transactions/start_transaction_parameters.go +++ b/operations/transactions/start_transaction_parameters.go @@ -26,14 +26,14 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" "github.com/go-openapi/validate" - - strfmt "github.com/go-openapi/strfmt" ) // NewStartTransactionParams creates a new StartTransactionParams object -// no default values defined in spec. +// +// There are no default values defined in the spec. func NewStartTransactionParams() StartTransactionParams { return StartTransactionParams{} @@ -70,7 +70,6 @@ func (o *StartTransactionParams) BindRequest(r *http.Request, route *middleware. if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { res = append(res, err) } - if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -80,7 +79,7 @@ func (o *StartTransactionParams) BindRequest(r *http.Request, route *middleware. // bindVersion binds and validates parameter Version from query. func (o *StartTransactionParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { if !hasKey { - return errors.Required("version", "query") + return errors.Required("version", "query", rawData) } var raw string if len(rawData) > 0 { @@ -89,6 +88,7 @@ func (o *StartTransactionParams) bindVersion(rawData []string, hasKey bool, form // Required: true // AllowEmptyValue: false + if err := validate.RequiredString("version", "query", raw); err != nil { return err } diff --git a/operations/transactions/start_transaction_responses.go b/operations/transactions/start_transaction_responses.go index e70a582f..03385c7e 100644 --- a/operations/transactions/start_transaction_responses.go +++ b/operations/transactions/start_transaction_responses.go @@ -24,19 +24,23 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - "github.com/haproxytech/models" + "github.com/haproxytech/client-native/v6/models" ) // StartTransactionCreatedCode is the HTTP code returned for type StartTransactionCreated const StartTransactionCreatedCode int = 201 -/*StartTransactionCreated Transaction started +/* +StartTransactionCreated Transaction started swagger:response startTransactionCreated */ type StartTransactionCreated struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -50,6 +54,17 @@ func NewStartTransactionCreated() *StartTransactionCreated { return &StartTransactionCreated{} } +// WithConfigurationVersion adds the configurationVersion to the start transaction created response +func (o *StartTransactionCreated) WithConfigurationVersion(configurationVersion string) *StartTransactionCreated { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the start transaction created response +func (o *StartTransactionCreated) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + // WithPayload adds the payload to the start transaction created response func (o *StartTransactionCreated) WithPayload(payload *models.Transaction) *StartTransactionCreated { o.Payload = payload @@ -64,6 +79,13 @@ func (o *StartTransactionCreated) SetPayload(payload *models.Transaction) { // WriteResponse to the client func (o *StartTransactionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + rw.WriteHeader(201) if o.Payload != nil { payload := o.Payload @@ -73,7 +95,53 @@ func (o *StartTransactionCreated) WriteResponse(rw http.ResponseWriter, producer } } -/*StartTransactionDefault General Error +// StartTransactionTooManyRequestsCode is the HTTP code returned for type StartTransactionTooManyRequests +const StartTransactionTooManyRequestsCode int = 429 + +/* +StartTransactionTooManyRequests Too many open transactions + +swagger:response startTransactionTooManyRequests +*/ +type StartTransactionTooManyRequests struct { + + /* + In: Body + */ + Payload *StartTransactionTooManyRequestsBody `json:"body,omitempty"` +} + +// NewStartTransactionTooManyRequests creates StartTransactionTooManyRequests with default headers values +func NewStartTransactionTooManyRequests() *StartTransactionTooManyRequests { + + return &StartTransactionTooManyRequests{} +} + +// WithPayload adds the payload to the start transaction too many requests response +func (o *StartTransactionTooManyRequests) WithPayload(payload *StartTransactionTooManyRequestsBody) *StartTransactionTooManyRequests { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the start transaction too many requests response +func (o *StartTransactionTooManyRequests) SetPayload(payload *StartTransactionTooManyRequestsBody) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *StartTransactionTooManyRequests) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(429) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +StartTransactionDefault General Error swagger:response startTransactionDefault */ @@ -82,7 +150,7 @@ type StartTransactionDefault struct { /*Configuration file version */ - ConfigurationVersion int64 `json:"Configuration-Version"` + ConfigurationVersion string `json:"Configuration-Version"` /* In: Body @@ -113,13 +181,13 @@ func (o *StartTransactionDefault) SetStatusCode(code int) { } // WithConfigurationVersion adds the configurationVersion to the start transaction default response -func (o *StartTransactionDefault) WithConfigurationVersion(configurationVersion int64) *StartTransactionDefault { +func (o *StartTransactionDefault) WithConfigurationVersion(configurationVersion string) *StartTransactionDefault { o.ConfigurationVersion = configurationVersion return o } // SetConfigurationVersion sets the configurationVersion to the start transaction default response -func (o *StartTransactionDefault) SetConfigurationVersion(configurationVersion int64) { +func (o *StartTransactionDefault) SetConfigurationVersion(configurationVersion string) { o.ConfigurationVersion = configurationVersion } @@ -139,7 +207,7 @@ func (o *StartTransactionDefault) WriteResponse(rw http.ResponseWriter, producer // response header Configuration-Version - configurationVersion := swag.FormatInt64(o.ConfigurationVersion) + configurationVersion := o.ConfigurationVersion if configurationVersion != "" { rw.Header().Set("Configuration-Version", configurationVersion) } diff --git a/operations/transactions/start_transaction_urlbuilder.go b/operations/transactions/start_transaction_urlbuilder.go index f8e444d8..db15c199 100644 --- a/operations/transactions/start_transaction_urlbuilder.go +++ b/operations/transactions/start_transaction_urlbuilder.go @@ -60,15 +60,15 @@ func (o *StartTransactionURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/v2" + _basePath = "/v3" } _result.Path = golangswaggerpaths.Join(_basePath, _path) qs := make(url.Values) - version := swag.FormatInt64(o.Version) - if version != "" { - qs.Set("version", version) + versionQ := swag.FormatInt64(o.Version) + if versionQ != "" { + qs.Set("version", versionQ) } _result.RawQuery = qs.Encode() diff --git a/operations/user/create_user.go b/operations/user/create_user.go new file mode 100644 index 00000000..09f71d2b --- /dev/null +++ b/operations/user/create_user.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateUserHandlerFunc turns a function with the right signature into a create user handler +type CreateUserHandlerFunc func(CreateUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateUserHandlerFunc) Handle(params CreateUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateUserHandler interface for that can handle valid create user params +type CreateUserHandler interface { + Handle(CreateUserParams, interface{}) middleware.Responder +} + +// NewCreateUser creates a new http.Handler for the create user operation +func NewCreateUser(ctx *middleware.Context, handler CreateUserHandler) *CreateUser { + return &CreateUser{Context: ctx, Handler: handler} +} + +/* + CreateUser swagger:route POST /services/haproxy/configuration/users User createUser + +Add a new userlist user +*/ +type CreateUser struct { + Context *middleware.Context + Handler CreateUserHandler +} + +func (o *CreateUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateUserParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/user/create_user_parameters.go b/operations/user/create_user_parameters.go new file mode 100644 index 00000000..60ca7454 --- /dev/null +++ b/operations/user/create_user_parameters.go @@ -0,0 +1,229 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateUserParams creates a new CreateUserParams object +// with the default values initialized. +func NewCreateUserParams() CreateUserParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return CreateUserParams{ + ForceReload: &forceReloadDefault, + } +} + +// CreateUserParams contains all the bound params for the create user operation +// typically these are obtained from a http.Request +// +// swagger:parameters createUser +type CreateUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.User + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateUserParams() beforehand. +func (o *CreateUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.User + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateUserParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateUserParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateUserParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *CreateUserParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateUserParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/user/create_user_responses.go b/operations/user/create_user_responses.go new file mode 100644 index 00000000..24099a04 --- /dev/null +++ b/operations/user/create_user_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateUserCreatedCode is the HTTP code returned for type CreateUserCreated +const CreateUserCreatedCode int = 201 + +/* +CreateUserCreated User created + +swagger:response createUserCreated +*/ +type CreateUserCreated struct { + + /* + In: Body + */ + Payload *models.User `json:"body,omitempty"` +} + +// NewCreateUserCreated creates CreateUserCreated with default headers values +func NewCreateUserCreated() *CreateUserCreated { + + return &CreateUserCreated{} +} + +// WithPayload adds the payload to the create user created response +func (o *CreateUserCreated) WithPayload(payload *models.User) *CreateUserCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user created response +func (o *CreateUserCreated) SetPayload(payload *models.User) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserAcceptedCode is the HTTP code returned for type CreateUserAccepted +const CreateUserAcceptedCode int = 202 + +/* +CreateUserAccepted Configuration change accepted and reload requested + +swagger:response createUserAccepted +*/ +type CreateUserAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.User `json:"body,omitempty"` +} + +// NewCreateUserAccepted creates CreateUserAccepted with default headers values +func NewCreateUserAccepted() *CreateUserAccepted { + + return &CreateUserAccepted{} +} + +// WithReloadID adds the reloadId to the create user accepted response +func (o *CreateUserAccepted) WithReloadID(reloadID string) *CreateUserAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create user accepted response +func (o *CreateUserAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create user accepted response +func (o *CreateUserAccepted) WithPayload(payload *models.User) *CreateUserAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user accepted response +func (o *CreateUserAccepted) SetPayload(payload *models.User) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserBadRequestCode is the HTTP code returned for type CreateUserBadRequest +const CreateUserBadRequestCode int = 400 + +/* +CreateUserBadRequest Bad request + +swagger:response createUserBadRequest +*/ +type CreateUserBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateUserBadRequest creates CreateUserBadRequest with default headers values +func NewCreateUserBadRequest() *CreateUserBadRequest { + + return &CreateUserBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create user bad request response +func (o *CreateUserBadRequest) WithConfigurationVersion(configurationVersion string) *CreateUserBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create user bad request response +func (o *CreateUserBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create user bad request response +func (o *CreateUserBadRequest) WithPayload(payload *models.Error) *CreateUserBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user bad request response +func (o *CreateUserBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserConflictCode is the HTTP code returned for type CreateUserConflict +const CreateUserConflictCode int = 409 + +/* +CreateUserConflict The specified resource already exists + +swagger:response createUserConflict +*/ +type CreateUserConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateUserConflict creates CreateUserConflict with default headers values +func NewCreateUserConflict() *CreateUserConflict { + + return &CreateUserConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create user conflict response +func (o *CreateUserConflict) WithConfigurationVersion(configurationVersion string) *CreateUserConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create user conflict response +func (o *CreateUserConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create user conflict response +func (o *CreateUserConflict) WithPayload(payload *models.Error) *CreateUserConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user conflict response +func (o *CreateUserConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateUserDefault General Error + +swagger:response createUserDefault +*/ +type CreateUserDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateUserDefault creates CreateUserDefault with default headers values +func NewCreateUserDefault(code int) *CreateUserDefault { + if code <= 0 { + code = 500 + } + + return &CreateUserDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create user default response +func (o *CreateUserDefault) WithStatusCode(code int) *CreateUserDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create user default response +func (o *CreateUserDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create user default response +func (o *CreateUserDefault) WithConfigurationVersion(configurationVersion string) *CreateUserDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create user default response +func (o *CreateUserDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create user default response +func (o *CreateUserDefault) WithPayload(payload *models.Error) *CreateUserDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create user default response +func (o *CreateUserDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/user/create_user_urlbuilder.go b/operations/user/create_user_urlbuilder.go new file mode 100644 index 00000000..a1f26257 --- /dev/null +++ b/operations/user/create_user_urlbuilder.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateUserURL generates an URL for the create user operation +type CreateUserURL struct { + ForceReload *bool + TransactionID *string + Userlist string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserURL) WithBasePath(bp string) *CreateUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/users" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/user/delete_user.go b/operations/user/delete_user.go new file mode 100644 index 00000000..76d26210 --- /dev/null +++ b/operations/user/delete_user.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteUserHandlerFunc turns a function with the right signature into a delete user handler +type DeleteUserHandlerFunc func(DeleteUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteUserHandlerFunc) Handle(params DeleteUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteUserHandler interface for that can handle valid delete user params +type DeleteUserHandler interface { + Handle(DeleteUserParams, interface{}) middleware.Responder +} + +// NewDeleteUser creates a new http.Handler for the delete user operation +func NewDeleteUser(ctx *middleware.Context, handler DeleteUserHandler) *DeleteUser { + return &DeleteUser{Context: ctx, Handler: handler} +} + +/* + DeleteUser swagger:route DELETE /services/haproxy/configuration/users/{username} User deleteUser + +Delete a user +*/ +type DeleteUser struct { + Context *middleware.Context + Handler DeleteUserHandler +} + +func (o *DeleteUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteUserParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/user/delete_user_parameters.go b/operations/user/delete_user_parameters.go new file mode 100644 index 00000000..e26f693d --- /dev/null +++ b/operations/user/delete_user_parameters.go @@ -0,0 +1,222 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NewDeleteUserParams creates a new DeleteUserParams object +// with the default values initialized. +func NewDeleteUserParams() DeleteUserParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteUserParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteUserParams contains all the bound params for the delete user operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteUser +type DeleteUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string + /*User username + Required: true + In: path + */ + Username string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteUserParams() beforehand. +func (o *DeleteUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + + rUsername, rhkUsername, _ := route.Params.GetOK("username") + if err := o.bindUsername(rUsername, rhkUsername, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteUserParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteUserParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteUserParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *DeleteUserParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} + +// bindUsername binds and validates parameter Username from path. +func (o *DeleteUserParams) bindUsername(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Username = raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteUserParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/user/delete_user_responses.go b/operations/user/delete_user_responses.go new file mode 100644 index 00000000..d4268586 --- /dev/null +++ b/operations/user/delete_user_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteUserAcceptedCode is the HTTP code returned for type DeleteUserAccepted +const DeleteUserAcceptedCode int = 202 + +/* +DeleteUserAccepted Configuration change accepted and reload requested + +swagger:response deleteUserAccepted +*/ +type DeleteUserAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteUserAccepted creates DeleteUserAccepted with default headers values +func NewDeleteUserAccepted() *DeleteUserAccepted { + + return &DeleteUserAccepted{} +} + +// WithReloadID adds the reloadId to the delete user accepted response +func (o *DeleteUserAccepted) WithReloadID(reloadID string) *DeleteUserAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete user accepted response +func (o *DeleteUserAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteUserAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteUserNoContentCode is the HTTP code returned for type DeleteUserNoContent +const DeleteUserNoContentCode int = 204 + +/* +DeleteUserNoContent User deleted + +swagger:response deleteUserNoContent +*/ +type DeleteUserNoContent struct { +} + +// NewDeleteUserNoContent creates DeleteUserNoContent with default headers values +func NewDeleteUserNoContent() *DeleteUserNoContent { + + return &DeleteUserNoContent{} +} + +// WriteResponse to the client +func (o *DeleteUserNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteUserNotFoundCode is the HTTP code returned for type DeleteUserNotFound +const DeleteUserNotFoundCode int = 404 + +/* +DeleteUserNotFound The specified resource was not found + +swagger:response deleteUserNotFound +*/ +type DeleteUserNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteUserNotFound creates DeleteUserNotFound with default headers values +func NewDeleteUserNotFound() *DeleteUserNotFound { + + return &DeleteUserNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete user not found response +func (o *DeleteUserNotFound) WithConfigurationVersion(configurationVersion string) *DeleteUserNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete user not found response +func (o *DeleteUserNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete user not found response +func (o *DeleteUserNotFound) WithPayload(payload *models.Error) *DeleteUserNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user not found response +func (o *DeleteUserNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteUserDefault General Error + +swagger:response deleteUserDefault +*/ +type DeleteUserDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteUserDefault creates DeleteUserDefault with default headers values +func NewDeleteUserDefault(code int) *DeleteUserDefault { + if code <= 0 { + code = 500 + } + + return &DeleteUserDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete user default response +func (o *DeleteUserDefault) WithStatusCode(code int) *DeleteUserDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete user default response +func (o *DeleteUserDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete user default response +func (o *DeleteUserDefault) WithConfigurationVersion(configurationVersion string) *DeleteUserDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete user default response +func (o *DeleteUserDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete user default response +func (o *DeleteUserDefault) WithPayload(payload *models.Error) *DeleteUserDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete user default response +func (o *DeleteUserDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/user/delete_user_urlbuilder.go b/operations/user/delete_user_urlbuilder.go new file mode 100644 index 00000000..7445935c --- /dev/null +++ b/operations/user/delete_user_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteUserURL generates an URL for the delete user operation +type DeleteUserURL struct { + Username string + + ForceReload *bool + TransactionID *string + Userlist string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserURL) WithBasePath(bp string) *DeleteUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/users/{username}" + + username := o.Username + if username != "" { + _path = strings.Replace(_path, "{username}", username, -1) + } else { + return nil, errors.New("username is required on DeleteUserURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/user/get_user.go b/operations/user/get_user.go new file mode 100644 index 00000000..fa0ea8f2 --- /dev/null +++ b/operations/user/get_user.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetUserHandlerFunc turns a function with the right signature into a get user handler +type GetUserHandlerFunc func(GetUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetUserHandlerFunc) Handle(params GetUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetUserHandler interface for that can handle valid get user params +type GetUserHandler interface { + Handle(GetUserParams, interface{}) middleware.Responder +} + +// NewGetUser creates a new http.Handler for the get user operation +func NewGetUser(ctx *middleware.Context, handler GetUserHandler) *GetUser { + return &GetUser{Context: ctx, Handler: handler} +} + +/* + GetUser swagger:route GET /services/haproxy/configuration/users/{username} User getUser + +Return one userlist user +*/ +type GetUser struct { + Context *middleware.Context + Handler GetUserHandler +} + +func (o *GetUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetUserParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/user/get_user_parameters.go b/operations/user/get_user_parameters.go new file mode 100644 index 00000000..126c02bf --- /dev/null +++ b/operations/user/get_user_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetUserParams creates a new GetUserParams object +// +// There are no default values defined in the spec. +func NewGetUserParams() GetUserParams { + + return GetUserParams{} +} + +// GetUserParams contains all the bound params for the get user operation +// typically these are obtained from a http.Request +// +// swagger:parameters getUser +type GetUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string + /*User username + Required: true + In: path + */ + Username string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetUserParams() beforehand. +func (o *GetUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + + rUsername, rhkUsername, _ := route.Params.GetOK("username") + if err := o.bindUsername(rUsername, rhkUsername, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetUserParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *GetUserParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} + +// bindUsername binds and validates parameter Username from path. +func (o *GetUserParams) bindUsername(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Username = raw + + return nil +} diff --git a/operations/user/get_user_responses.go b/operations/user/get_user_responses.go new file mode 100644 index 00000000..84f90439 --- /dev/null +++ b/operations/user/get_user_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetUserOKCode is the HTTP code returned for type GetUserOK +const GetUserOKCode int = 200 + +/* +GetUserOK Successful operation + +swagger:response getUserOK +*/ +type GetUserOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.User `json:"body,omitempty"` +} + +// NewGetUserOK creates GetUserOK with default headers values +func NewGetUserOK() *GetUserOK { + + return &GetUserOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get user o k response +func (o *GetUserOK) WithConfigurationVersion(configurationVersion string) *GetUserOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get user o k response +func (o *GetUserOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get user o k response +func (o *GetUserOK) WithPayload(payload *models.User) *GetUserOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user o k response +func (o *GetUserOK) SetPayload(payload *models.User) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserNotFoundCode is the HTTP code returned for type GetUserNotFound +const GetUserNotFoundCode int = 404 + +/* +GetUserNotFound The specified resource already exists + +swagger:response getUserNotFound +*/ +type GetUserNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetUserNotFound creates GetUserNotFound with default headers values +func NewGetUserNotFound() *GetUserNotFound { + + return &GetUserNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get user not found response +func (o *GetUserNotFound) WithConfigurationVersion(configurationVersion string) *GetUserNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get user not found response +func (o *GetUserNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get user not found response +func (o *GetUserNotFound) WithPayload(payload *models.Error) *GetUserNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user not found response +func (o *GetUserNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetUserDefault General Error + +swagger:response getUserDefault +*/ +type GetUserDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetUserDefault creates GetUserDefault with default headers values +func NewGetUserDefault(code int) *GetUserDefault { + if code <= 0 { + code = 500 + } + + return &GetUserDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get user default response +func (o *GetUserDefault) WithStatusCode(code int) *GetUserDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get user default response +func (o *GetUserDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get user default response +func (o *GetUserDefault) WithConfigurationVersion(configurationVersion string) *GetUserDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get user default response +func (o *GetUserDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get user default response +func (o *GetUserDefault) WithPayload(payload *models.Error) *GetUserDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get user default response +func (o *GetUserDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/user/get_user_urlbuilder.go b/operations/user/get_user_urlbuilder.go new file mode 100644 index 00000000..e7692dbc --- /dev/null +++ b/operations/user/get_user_urlbuilder.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// GetUserURL generates an URL for the get user operation +type GetUserURL struct { + Username string + + TransactionID *string + Userlist string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserURL) WithBasePath(bp string) *GetUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/users/{username}" + + username := o.Username + if username != "" { + _path = strings.Replace(_path, "{username}", username, -1) + } else { + return nil, errors.New("username is required on GetUserURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/user/get_users.go b/operations/user/get_users.go new file mode 100644 index 00000000..00deb265 --- /dev/null +++ b/operations/user/get_users.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetUsersHandlerFunc turns a function with the right signature into a get users handler +type GetUsersHandlerFunc func(GetUsersParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetUsersHandlerFunc) Handle(params GetUsersParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetUsersHandler interface for that can handle valid get users params +type GetUsersHandler interface { + Handle(GetUsersParams, interface{}) middleware.Responder +} + +// NewGetUsers creates a new http.Handler for the get users operation +func NewGetUsers(ctx *middleware.Context, handler GetUsersHandler) *GetUsers { + return &GetUsers{Context: ctx, Handler: handler} +} + +/* + GetUsers swagger:route GET /services/haproxy/configuration/users User getUsers + +Return an array of userlist users +*/ +type GetUsers struct { + Context *middleware.Context + Handler GetUsersHandler +} + +func (o *GetUsers) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetUsersParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/user/get_users_parameters.go b/operations/user/get_users_parameters.go new file mode 100644 index 00000000..d7e2b7c8 --- /dev/null +++ b/operations/user/get_users_parameters.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewGetUsersParams creates a new GetUsersParams object +// +// There are no default values defined in the spec. +func NewGetUsersParams() GetUsersParams { + + return GetUsersParams{} +} + +// GetUsersParams contains all the bound params for the get users operation +// typically these are obtained from a http.Request +// +// swagger:parameters getUsers +type GetUsersParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetUsersParams() beforehand. +func (o *GetUsersParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetUsersParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *GetUsersParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} diff --git a/operations/user/get_users_responses.go b/operations/user/get_users_responses.go new file mode 100644 index 00000000..bbbf5aa6 --- /dev/null +++ b/operations/user/get_users_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetUsersOKCode is the HTTP code returned for type GetUsersOK +const GetUsersOKCode int = 200 + +/* +GetUsersOK Successful operation + +swagger:response getUsersOK +*/ +type GetUsersOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Users `json:"body,omitempty"` +} + +// NewGetUsersOK creates GetUsersOK with default headers values +func NewGetUsersOK() *GetUsersOK { + + return &GetUsersOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get users o k response +func (o *GetUsersOK) WithConfigurationVersion(configurationVersion string) *GetUsersOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get users o k response +func (o *GetUsersOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get users o k response +func (o *GetUsersOK) WithPayload(payload models.Users) *GetUsersOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get users o k response +func (o *GetUsersOK) SetPayload(payload models.Users) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUsersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Users{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetUsersDefault General Error + +swagger:response getUsersDefault +*/ +type GetUsersDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetUsersDefault creates GetUsersDefault with default headers values +func NewGetUsersDefault(code int) *GetUsersDefault { + if code <= 0 { + code = 500 + } + + return &GetUsersDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get users default response +func (o *GetUsersDefault) WithStatusCode(code int) *GetUsersDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get users default response +func (o *GetUsersDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get users default response +func (o *GetUsersDefault) WithConfigurationVersion(configurationVersion string) *GetUsersDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get users default response +func (o *GetUsersDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get users default response +func (o *GetUsersDefault) WithPayload(payload *models.Error) *GetUsersDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get users default response +func (o *GetUsersDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUsersDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/user/get_users_urlbuilder.go b/operations/user/get_users_urlbuilder.go new file mode 100644 index 00000000..110439a6 --- /dev/null +++ b/operations/user/get_users_urlbuilder.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetUsersURL generates an URL for the get users operation +type GetUsersURL struct { + TransactionID *string + Userlist string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUsersURL) WithBasePath(bp string) *GetUsersURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUsersURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetUsersURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/users" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetUsersURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetUsersURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetUsersURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetUsersURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetUsersURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetUsersURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/user/replace_user.go b/operations/user/replace_user.go new file mode 100644 index 00000000..8eb70bf5 --- /dev/null +++ b/operations/user/replace_user.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// ReplaceUserHandlerFunc turns a function with the right signature into a replace user handler +type ReplaceUserHandlerFunc func(ReplaceUserParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn ReplaceUserHandlerFunc) Handle(params ReplaceUserParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// ReplaceUserHandler interface for that can handle valid replace user params +type ReplaceUserHandler interface { + Handle(ReplaceUserParams, interface{}) middleware.Responder +} + +// NewReplaceUser creates a new http.Handler for the replace user operation +func NewReplaceUser(ctx *middleware.Context, handler ReplaceUserHandler) *ReplaceUser { + return &ReplaceUser{Context: ctx, Handler: handler} +} + +/* + ReplaceUser swagger:route PUT /services/haproxy/configuration/users/{username} User replaceUser + +Replace a user +*/ +type ReplaceUser struct { + Context *middleware.Context + Handler ReplaceUserHandler +} + +func (o *ReplaceUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewReplaceUserParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/user/replace_user_parameters.go b/operations/user/replace_user_parameters.go new file mode 100644 index 00000000..a41ac731 --- /dev/null +++ b/operations/user/replace_user_parameters.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewReplaceUserParams creates a new ReplaceUserParams object +// with the default values initialized. +func NewReplaceUserParams() ReplaceUserParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return ReplaceUserParams{ + ForceReload: &forceReloadDefault, + } +} + +// ReplaceUserParams contains all the bound params for the replace user operation +// typically these are obtained from a http.Request +// +// swagger:parameters replaceUser +type ReplaceUserParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.User + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Parent userlist name + Required: true + In: query + */ + Userlist string + /*User username + Required: true + In: path + */ + Username string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewReplaceUserParams() beforehand. +func (o *ReplaceUserParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.User + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qUserlist, qhkUserlist, _ := qs.GetOK("userlist") + if err := o.bindUserlist(qUserlist, qhkUserlist, route.Formats); err != nil { + res = append(res, err) + } + + rUsername, rhkUsername, _ := route.Params.GetOK("username") + if err := o.bindUsername(rUsername, rhkUsername, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *ReplaceUserParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewReplaceUserParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *ReplaceUserParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindUserlist binds and validates parameter Userlist from query. +func (o *ReplaceUserParams) bindUserlist(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("userlist", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("userlist", "query", raw); err != nil { + return err + } + o.Userlist = raw + + return nil +} + +// bindUsername binds and validates parameter Username from path. +func (o *ReplaceUserParams) bindUsername(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Username = raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *ReplaceUserParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/user/replace_user_responses.go b/operations/user/replace_user_responses.go new file mode 100644 index 00000000..e3a55d6a --- /dev/null +++ b/operations/user/replace_user_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// ReplaceUserOKCode is the HTTP code returned for type ReplaceUserOK +const ReplaceUserOKCode int = 200 + +/* +ReplaceUserOK User replaced + +swagger:response replaceUserOK +*/ +type ReplaceUserOK struct { + + /* + In: Body + */ + Payload *models.User `json:"body,omitempty"` +} + +// NewReplaceUserOK creates ReplaceUserOK with default headers values +func NewReplaceUserOK() *ReplaceUserOK { + + return &ReplaceUserOK{} +} + +// WithPayload adds the payload to the replace user o k response +func (o *ReplaceUserOK) WithPayload(payload *models.User) *ReplaceUserOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace user o k response +func (o *ReplaceUserOK) SetPayload(payload *models.User) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceUserAcceptedCode is the HTTP code returned for type ReplaceUserAccepted +const ReplaceUserAcceptedCode int = 202 + +/* +ReplaceUserAccepted Configuration change accepted and reload requested + +swagger:response replaceUserAccepted +*/ +type ReplaceUserAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.User `json:"body,omitempty"` +} + +// NewReplaceUserAccepted creates ReplaceUserAccepted with default headers values +func NewReplaceUserAccepted() *ReplaceUserAccepted { + + return &ReplaceUserAccepted{} +} + +// WithReloadID adds the reloadId to the replace user accepted response +func (o *ReplaceUserAccepted) WithReloadID(reloadID string) *ReplaceUserAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the replace user accepted response +func (o *ReplaceUserAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the replace user accepted response +func (o *ReplaceUserAccepted) WithPayload(payload *models.User) *ReplaceUserAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace user accepted response +func (o *ReplaceUserAccepted) SetPayload(payload *models.User) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceUserAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceUserBadRequestCode is the HTTP code returned for type ReplaceUserBadRequest +const ReplaceUserBadRequestCode int = 400 + +/* +ReplaceUserBadRequest Bad request + +swagger:response replaceUserBadRequest +*/ +type ReplaceUserBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceUserBadRequest creates ReplaceUserBadRequest with default headers values +func NewReplaceUserBadRequest() *ReplaceUserBadRequest { + + return &ReplaceUserBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace user bad request response +func (o *ReplaceUserBadRequest) WithConfigurationVersion(configurationVersion string) *ReplaceUserBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace user bad request response +func (o *ReplaceUserBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace user bad request response +func (o *ReplaceUserBadRequest) WithPayload(payload *models.Error) *ReplaceUserBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace user bad request response +func (o *ReplaceUserBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceUserBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// ReplaceUserNotFoundCode is the HTTP code returned for type ReplaceUserNotFound +const ReplaceUserNotFoundCode int = 404 + +/* +ReplaceUserNotFound The specified resource was not found + +swagger:response replaceUserNotFound +*/ +type ReplaceUserNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceUserNotFound creates ReplaceUserNotFound with default headers values +func NewReplaceUserNotFound() *ReplaceUserNotFound { + + return &ReplaceUserNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the replace user not found response +func (o *ReplaceUserNotFound) WithConfigurationVersion(configurationVersion string) *ReplaceUserNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace user not found response +func (o *ReplaceUserNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace user not found response +func (o *ReplaceUserNotFound) WithPayload(payload *models.Error) *ReplaceUserNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace user not found response +func (o *ReplaceUserNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceUserNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +ReplaceUserDefault General Error + +swagger:response replaceUserDefault +*/ +type ReplaceUserDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewReplaceUserDefault creates ReplaceUserDefault with default headers values +func NewReplaceUserDefault(code int) *ReplaceUserDefault { + if code <= 0 { + code = 500 + } + + return &ReplaceUserDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the replace user default response +func (o *ReplaceUserDefault) WithStatusCode(code int) *ReplaceUserDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the replace user default response +func (o *ReplaceUserDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the replace user default response +func (o *ReplaceUserDefault) WithConfigurationVersion(configurationVersion string) *ReplaceUserDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the replace user default response +func (o *ReplaceUserDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the replace user default response +func (o *ReplaceUserDefault) WithPayload(payload *models.Error) *ReplaceUserDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the replace user default response +func (o *ReplaceUserDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ReplaceUserDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/user/replace_user_urlbuilder.go b/operations/user/replace_user_urlbuilder.go new file mode 100644 index 00000000..546b820a --- /dev/null +++ b/operations/user/replace_user_urlbuilder.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package user + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// ReplaceUserURL generates an URL for the replace user operation +type ReplaceUserURL struct { + Username string + + ForceReload *bool + TransactionID *string + Userlist string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceUserURL) WithBasePath(bp string) *ReplaceUserURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *ReplaceUserURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *ReplaceUserURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/users/{username}" + + username := o.Username + if username != "" { + _path = strings.Replace(_path, "{username}", username, -1) + } else { + return nil, errors.New("username is required on ReplaceUserURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + userlistQ := o.Userlist + if userlistQ != "" { + qs.Set("userlist", userlistQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *ReplaceUserURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *ReplaceUserURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *ReplaceUserURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on ReplaceUserURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on ReplaceUserURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *ReplaceUserURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/userlist/create_userlist.go b/operations/userlist/create_userlist.go new file mode 100644 index 00000000..15126425 --- /dev/null +++ b/operations/userlist/create_userlist.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// CreateUserlistHandlerFunc turns a function with the right signature into a create userlist handler +type CreateUserlistHandlerFunc func(CreateUserlistParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn CreateUserlistHandlerFunc) Handle(params CreateUserlistParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// CreateUserlistHandler interface for that can handle valid create userlist params +type CreateUserlistHandler interface { + Handle(CreateUserlistParams, interface{}) middleware.Responder +} + +// NewCreateUserlist creates a new http.Handler for the create userlist operation +func NewCreateUserlist(ctx *middleware.Context, handler CreateUserlistHandler) *CreateUserlist { + return &CreateUserlist{Context: ctx, Handler: handler} +} + +/* + CreateUserlist swagger:route POST /services/haproxy/configuration/userlists Userlist createUserlist + +# Add a new userlist + +Adds a new userlist to the configuration file. +*/ +type CreateUserlist struct { + Context *middleware.Context + Handler CreateUserlistHandler +} + +func (o *CreateUserlist) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewCreateUserlistParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/userlist/create_userlist_parameters.go b/operations/userlist/create_userlist_parameters.go new file mode 100644 index 00000000..76842237 --- /dev/null +++ b/operations/userlist/create_userlist_parameters.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/haproxytech/client-native/v6/models" +) + +// NewCreateUserlistParams creates a new CreateUserlistParams object +// with the default values initialized. +func NewCreateUserlistParams() CreateUserlistParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + fullSectionDefault = bool(false) + ) + + return CreateUserlistParams{ + ForceReload: &forceReloadDefault, + + FullSection: &fullSectionDefault, + } +} + +// CreateUserlistParams contains all the bound params for the create userlist operation +// typically these are obtained from a http.Request +// +// swagger:parameters createUserlist +type CreateUserlistParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Data *models.Userlist + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewCreateUserlistParams() beforehand. +func (o *CreateUserlistParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Userlist + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("data", "body", "")) + } else { + res = append(res, errors.NewParseError("data", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Data = &body + } + } + } else { + res = append(res, errors.Required("data", "body", "")) + } + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *CreateUserlistParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateUserlistParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *CreateUserlistParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewCreateUserlistParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *CreateUserlistParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *CreateUserlistParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/userlist/create_userlist_responses.go b/operations/userlist/create_userlist_responses.go new file mode 100644 index 00000000..a977a916 --- /dev/null +++ b/operations/userlist/create_userlist_responses.go @@ -0,0 +1,356 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// CreateUserlistCreatedCode is the HTTP code returned for type CreateUserlistCreated +const CreateUserlistCreatedCode int = 201 + +/* +CreateUserlistCreated Userlist created + +swagger:response createUserlistCreated +*/ +type CreateUserlistCreated struct { + + /* + In: Body + */ + Payload *models.Userlist `json:"body,omitempty"` +} + +// NewCreateUserlistCreated creates CreateUserlistCreated with default headers values +func NewCreateUserlistCreated() *CreateUserlistCreated { + + return &CreateUserlistCreated{} +} + +// WithPayload adds the payload to the create userlist created response +func (o *CreateUserlistCreated) WithPayload(payload *models.Userlist) *CreateUserlistCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create userlist created response +func (o *CreateUserlistCreated) SetPayload(payload *models.Userlist) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserlistCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserlistAcceptedCode is the HTTP code returned for type CreateUserlistAccepted +const CreateUserlistAcceptedCode int = 202 + +/* +CreateUserlistAccepted Configuration change accepted and reload requested + +swagger:response createUserlistAccepted +*/ +type CreateUserlistAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` + + /* + In: Body + */ + Payload *models.Userlist `json:"body,omitempty"` +} + +// NewCreateUserlistAccepted creates CreateUserlistAccepted with default headers values +func NewCreateUserlistAccepted() *CreateUserlistAccepted { + + return &CreateUserlistAccepted{} +} + +// WithReloadID adds the reloadId to the create userlist accepted response +func (o *CreateUserlistAccepted) WithReloadID(reloadID string) *CreateUserlistAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the create userlist accepted response +func (o *CreateUserlistAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WithPayload adds the payload to the create userlist accepted response +func (o *CreateUserlistAccepted) WithPayload(payload *models.Userlist) *CreateUserlistAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create userlist accepted response +func (o *CreateUserlistAccepted) SetPayload(payload *models.Userlist) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserlistAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserlistBadRequestCode is the HTTP code returned for type CreateUserlistBadRequest +const CreateUserlistBadRequestCode int = 400 + +/* +CreateUserlistBadRequest Bad request + +swagger:response createUserlistBadRequest +*/ +type CreateUserlistBadRequest struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateUserlistBadRequest creates CreateUserlistBadRequest with default headers values +func NewCreateUserlistBadRequest() *CreateUserlistBadRequest { + + return &CreateUserlistBadRequest{} +} + +// WithConfigurationVersion adds the configurationVersion to the create userlist bad request response +func (o *CreateUserlistBadRequest) WithConfigurationVersion(configurationVersion string) *CreateUserlistBadRequest { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create userlist bad request response +func (o *CreateUserlistBadRequest) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create userlist bad request response +func (o *CreateUserlistBadRequest) WithPayload(payload *models.Error) *CreateUserlistBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create userlist bad request response +func (o *CreateUserlistBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserlistBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// CreateUserlistConflictCode is the HTTP code returned for type CreateUserlistConflict +const CreateUserlistConflictCode int = 409 + +/* +CreateUserlistConflict The specified resource already exists + +swagger:response createUserlistConflict +*/ +type CreateUserlistConflict struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateUserlistConflict creates CreateUserlistConflict with default headers values +func NewCreateUserlistConflict() *CreateUserlistConflict { + + return &CreateUserlistConflict{} +} + +// WithConfigurationVersion adds the configurationVersion to the create userlist conflict response +func (o *CreateUserlistConflict) WithConfigurationVersion(configurationVersion string) *CreateUserlistConflict { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create userlist conflict response +func (o *CreateUserlistConflict) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create userlist conflict response +func (o *CreateUserlistConflict) WithPayload(payload *models.Error) *CreateUserlistConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create userlist conflict response +func (o *CreateUserlistConflict) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserlistConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +CreateUserlistDefault General Error + +swagger:response createUserlistDefault +*/ +type CreateUserlistDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewCreateUserlistDefault creates CreateUserlistDefault with default headers values +func NewCreateUserlistDefault(code int) *CreateUserlistDefault { + if code <= 0 { + code = 500 + } + + return &CreateUserlistDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the create userlist default response +func (o *CreateUserlistDefault) WithStatusCode(code int) *CreateUserlistDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the create userlist default response +func (o *CreateUserlistDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the create userlist default response +func (o *CreateUserlistDefault) WithConfigurationVersion(configurationVersion string) *CreateUserlistDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the create userlist default response +func (o *CreateUserlistDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the create userlist default response +func (o *CreateUserlistDefault) WithPayload(payload *models.Error) *CreateUserlistDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the create userlist default response +func (o *CreateUserlistDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *CreateUserlistDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/userlist/create_userlist_urlbuilder.go b/operations/userlist/create_userlist_urlbuilder.go new file mode 100644 index 00000000..f3817054 --- /dev/null +++ b/operations/userlist/create_userlist_urlbuilder.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// CreateUserlistURL generates an URL for the create userlist operation +type CreateUserlistURL struct { + ForceReload *bool + FullSection *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserlistURL) WithBasePath(bp string) *CreateUserlistURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *CreateUserlistURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *CreateUserlistURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/userlists" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *CreateUserlistURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *CreateUserlistURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *CreateUserlistURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on CreateUserlistURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on CreateUserlistURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *CreateUserlistURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/userlist/delete_userlist.go b/operations/userlist/delete_userlist.go new file mode 100644 index 00000000..7c938328 --- /dev/null +++ b/operations/userlist/delete_userlist.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// DeleteUserlistHandlerFunc turns a function with the right signature into a delete userlist handler +type DeleteUserlistHandlerFunc func(DeleteUserlistParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteUserlistHandlerFunc) Handle(params DeleteUserlistParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// DeleteUserlistHandler interface for that can handle valid delete userlist params +type DeleteUserlistHandler interface { + Handle(DeleteUserlistParams, interface{}) middleware.Responder +} + +// NewDeleteUserlist creates a new http.Handler for the delete userlist operation +func NewDeleteUserlist(ctx *middleware.Context, handler DeleteUserlistHandler) *DeleteUserlist { + return &DeleteUserlist{Context: ctx, Handler: handler} +} + +/* + DeleteUserlist swagger:route DELETE /services/haproxy/configuration/userlists/{name} Userlist deleteUserlist + +# Delete a userlist + +Deletes a userlist configuration by it's name. +*/ +type DeleteUserlist struct { + Context *middleware.Context + Handler DeleteUserlistHandler +} + +func (o *DeleteUserlist) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteUserlistParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/userlist/delete_userlist_parameters.go b/operations/userlist/delete_userlist_parameters.go new file mode 100644 index 00000000..544b3040 --- /dev/null +++ b/operations/userlist/delete_userlist_parameters.go @@ -0,0 +1,190 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewDeleteUserlistParams creates a new DeleteUserlistParams object +// with the default values initialized. +func NewDeleteUserlistParams() DeleteUserlistParams { + + var ( + // initialize parameters with default values + + forceReloadDefault = bool(false) + ) + + return DeleteUserlistParams{ + ForceReload: &forceReloadDefault, + } +} + +// DeleteUserlistParams contains all the bound params for the delete userlist operation +// typically these are obtained from a http.Request +// +// swagger:parameters deleteUserlist +type DeleteUserlistParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*If set, do a force reload, do not wait for the configured reload-delay. Cannot be used when transaction is specified, as changes in transaction are not applied directly to configuration. + In: query + Default: false + */ + ForceReload *bool + /*Userlist name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string + /*Version used for checking configuration version. Cannot be used when transaction is specified, transaction has it's own version. + In: query + */ + Version *int64 +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteUserlistParams() beforehand. +func (o *DeleteUserlistParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qForceReload, qhkForceReload, _ := qs.GetOK("force_reload") + if err := o.bindForceReload(qForceReload, qhkForceReload, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + + qVersion, qhkVersion, _ := qs.GetOK("version") + if err := o.bindVersion(qVersion, qhkVersion, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindForceReload binds and validates parameter ForceReload from query. +func (o *DeleteUserlistParams) bindForceReload(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewDeleteUserlistParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("force_reload", "query", "bool", raw) + } + o.ForceReload = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *DeleteUserlistParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *DeleteUserlistParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} + +// bindVersion binds and validates parameter Version from query. +func (o *DeleteUserlistParams) bindVersion(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("version", "query", "int64", raw) + } + o.Version = &value + + return nil +} diff --git a/operations/userlist/delete_userlist_responses.go b/operations/userlist/delete_userlist_responses.go new file mode 100644 index 00000000..1bc0a5f3 --- /dev/null +++ b/operations/userlist/delete_userlist_responses.go @@ -0,0 +1,249 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// DeleteUserlistAcceptedCode is the HTTP code returned for type DeleteUserlistAccepted +const DeleteUserlistAcceptedCode int = 202 + +/* +DeleteUserlistAccepted Configuration change accepted and reload requested + +swagger:response deleteUserlistAccepted +*/ +type DeleteUserlistAccepted struct { + /*ID of the requested reload + + */ + ReloadID string `json:"Reload-ID"` +} + +// NewDeleteUserlistAccepted creates DeleteUserlistAccepted with default headers values +func NewDeleteUserlistAccepted() *DeleteUserlistAccepted { + + return &DeleteUserlistAccepted{} +} + +// WithReloadID adds the reloadId to the delete userlist accepted response +func (o *DeleteUserlistAccepted) WithReloadID(reloadID string) *DeleteUserlistAccepted { + o.ReloadID = reloadID + return o +} + +// SetReloadID sets the reloadId to the delete userlist accepted response +func (o *DeleteUserlistAccepted) SetReloadID(reloadID string) { + o.ReloadID = reloadID +} + +// WriteResponse to the client +func (o *DeleteUserlistAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Reload-ID + + reloadID := o.ReloadID + if reloadID != "" { + rw.Header().Set("Reload-ID", reloadID) + } + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(202) +} + +// DeleteUserlistNoContentCode is the HTTP code returned for type DeleteUserlistNoContent +const DeleteUserlistNoContentCode int = 204 + +/* +DeleteUserlistNoContent Userlist deleted + +swagger:response deleteUserlistNoContent +*/ +type DeleteUserlistNoContent struct { +} + +// NewDeleteUserlistNoContent creates DeleteUserlistNoContent with default headers values +func NewDeleteUserlistNoContent() *DeleteUserlistNoContent { + + return &DeleteUserlistNoContent{} +} + +// WriteResponse to the client +func (o *DeleteUserlistNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteUserlistNotFoundCode is the HTTP code returned for type DeleteUserlistNotFound +const DeleteUserlistNotFoundCode int = 404 + +/* +DeleteUserlistNotFound The specified resource was not found + +swagger:response deleteUserlistNotFound +*/ +type DeleteUserlistNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteUserlistNotFound creates DeleteUserlistNotFound with default headers values +func NewDeleteUserlistNotFound() *DeleteUserlistNotFound { + + return &DeleteUserlistNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the delete userlist not found response +func (o *DeleteUserlistNotFound) WithConfigurationVersion(configurationVersion string) *DeleteUserlistNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete userlist not found response +func (o *DeleteUserlistNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete userlist not found response +func (o *DeleteUserlistNotFound) WithPayload(payload *models.Error) *DeleteUserlistNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete userlist not found response +func (o *DeleteUserlistNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserlistNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +DeleteUserlistDefault General Error + +swagger:response deleteUserlistDefault +*/ +type DeleteUserlistDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteUserlistDefault creates DeleteUserlistDefault with default headers values +func NewDeleteUserlistDefault(code int) *DeleteUserlistDefault { + if code <= 0 { + code = 500 + } + + return &DeleteUserlistDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete userlist default response +func (o *DeleteUserlistDefault) WithStatusCode(code int) *DeleteUserlistDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete userlist default response +func (o *DeleteUserlistDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the delete userlist default response +func (o *DeleteUserlistDefault) WithConfigurationVersion(configurationVersion string) *DeleteUserlistDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the delete userlist default response +func (o *DeleteUserlistDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the delete userlist default response +func (o *DeleteUserlistDefault) WithPayload(payload *models.Error) *DeleteUserlistDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete userlist default response +func (o *DeleteUserlistDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteUserlistDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/userlist/delete_userlist_urlbuilder.go b/operations/userlist/delete_userlist_urlbuilder.go new file mode 100644 index 00000000..712974da --- /dev/null +++ b/operations/userlist/delete_userlist_urlbuilder.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// DeleteUserlistURL generates an URL for the delete userlist operation +type DeleteUserlistURL struct { + Name string + + ForceReload *bool + TransactionID *string + Version *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserlistURL) WithBasePath(bp string) *DeleteUserlistURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteUserlistURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteUserlistURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/userlists/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on DeleteUserlistURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var forceReloadQ string + if o.ForceReload != nil { + forceReloadQ = swag.FormatBool(*o.ForceReload) + } + if forceReloadQ != "" { + qs.Set("force_reload", forceReloadQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + var versionQ string + if o.Version != nil { + versionQ = swag.FormatInt64(*o.Version) + } + if versionQ != "" { + qs.Set("version", versionQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteUserlistURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DeleteUserlistURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteUserlistURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteUserlistURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteUserlistURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DeleteUserlistURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/userlist/get_userlist.go b/operations/userlist/get_userlist.go new file mode 100644 index 00000000..f8c67599 --- /dev/null +++ b/operations/userlist/get_userlist.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetUserlistHandlerFunc turns a function with the right signature into a get userlist handler +type GetUserlistHandlerFunc func(GetUserlistParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetUserlistHandlerFunc) Handle(params GetUserlistParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetUserlistHandler interface for that can handle valid get userlist params +type GetUserlistHandler interface { + Handle(GetUserlistParams, interface{}) middleware.Responder +} + +// NewGetUserlist creates a new http.Handler for the get userlist operation +func NewGetUserlist(ctx *middleware.Context, handler GetUserlistHandler) *GetUserlist { + return &GetUserlist{Context: ctx, Handler: handler} +} + +/* + GetUserlist swagger:route GET /services/haproxy/configuration/userlists/{name} Userlist getUserlist + +# Return one userlist + +Returns one userlist configuration by it's name. +*/ +type GetUserlist struct { + Context *middleware.Context + Handler GetUserlistHandler +} + +func (o *GetUserlist) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetUserlistParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/userlist/get_userlist_parameters.go b/operations/userlist/get_userlist_parameters.go new file mode 100644 index 00000000..aabf0c2b --- /dev/null +++ b/operations/userlist/get_userlist_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetUserlistParams creates a new GetUserlistParams object +// with the default values initialized. +func NewGetUserlistParams() GetUserlistParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetUserlistParams{ + FullSection: &fullSectionDefault, + } +} + +// GetUserlistParams contains all the bound params for the get userlist operation +// typically these are obtained from a http.Request +// +// swagger:parameters getUserlist +type GetUserlistParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*Userlist name + Required: true + In: path + */ + Name string + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetUserlistParams() beforehand. +func (o *GetUserlistParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + rName, rhkName, _ := route.Params.GetOK("name") + if err := o.bindName(rName, rhkName, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetUserlistParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetUserlistParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindName binds and validates parameter Name from path. +func (o *GetUserlistParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Name = raw + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetUserlistParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/userlist/get_userlist_responses.go b/operations/userlist/get_userlist_responses.go new file mode 100644 index 00000000..a6479d6a --- /dev/null +++ b/operations/userlist/get_userlist_responses.go @@ -0,0 +1,244 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetUserlistOKCode is the HTTP code returned for type GetUserlistOK +const GetUserlistOKCode int = 200 + +/* +GetUserlistOK Successful operation + +swagger:response getUserlistOK +*/ +type GetUserlistOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Userlist `json:"body,omitempty"` +} + +// NewGetUserlistOK creates GetUserlistOK with default headers values +func NewGetUserlistOK() *GetUserlistOK { + + return &GetUserlistOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get userlist o k response +func (o *GetUserlistOK) WithConfigurationVersion(configurationVersion string) *GetUserlistOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get userlist o k response +func (o *GetUserlistOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get userlist o k response +func (o *GetUserlistOK) WithPayload(payload *models.Userlist) *GetUserlistOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get userlist o k response +func (o *GetUserlistOK) SetPayload(payload *models.Userlist) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserlistOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetUserlistNotFoundCode is the HTTP code returned for type GetUserlistNotFound +const GetUserlistNotFoundCode int = 404 + +/* +GetUserlistNotFound The specified resource already exists + +swagger:response getUserlistNotFound +*/ +type GetUserlistNotFound struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetUserlistNotFound creates GetUserlistNotFound with default headers values +func NewGetUserlistNotFound() *GetUserlistNotFound { + + return &GetUserlistNotFound{} +} + +// WithConfigurationVersion adds the configurationVersion to the get userlist not found response +func (o *GetUserlistNotFound) WithConfigurationVersion(configurationVersion string) *GetUserlistNotFound { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get userlist not found response +func (o *GetUserlistNotFound) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get userlist not found response +func (o *GetUserlistNotFound) WithPayload(payload *models.Error) *GetUserlistNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get userlist not found response +func (o *GetUserlistNotFound) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserlistNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/* +GetUserlistDefault General Error + +swagger:response getUserlistDefault +*/ +type GetUserlistDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetUserlistDefault creates GetUserlistDefault with default headers values +func NewGetUserlistDefault(code int) *GetUserlistDefault { + if code <= 0 { + code = 500 + } + + return &GetUserlistDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get userlist default response +func (o *GetUserlistDefault) WithStatusCode(code int) *GetUserlistDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get userlist default response +func (o *GetUserlistDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get userlist default response +func (o *GetUserlistDefault) WithConfigurationVersion(configurationVersion string) *GetUserlistDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get userlist default response +func (o *GetUserlistDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get userlist default response +func (o *GetUserlistDefault) WithPayload(payload *models.Error) *GetUserlistDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get userlist default response +func (o *GetUserlistDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserlistDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/userlist/get_userlist_urlbuilder.go b/operations/userlist/get_userlist_urlbuilder.go new file mode 100644 index 00000000..3a425750 --- /dev/null +++ b/operations/userlist/get_userlist_urlbuilder.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// GetUserlistURL generates an URL for the get userlist operation +type GetUserlistURL struct { + Name string + + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserlistURL) WithBasePath(bp string) *GetUserlistURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserlistURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetUserlistURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/userlists/{name}" + + name := o.Name + if name != "" { + _path = strings.Replace(_path, "{name}", name, -1) + } else { + return nil, errors.New("name is required on GetUserlistURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetUserlistURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetUserlistURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetUserlistURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetUserlistURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetUserlistURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetUserlistURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operations/userlist/get_userlists.go b/operations/userlist/get_userlists.go new file mode 100644 index 00000000..dd92c871 --- /dev/null +++ b/operations/userlist/get_userlists.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetUserlistsHandlerFunc turns a function with the right signature into a get userlists handler +type GetUserlistsHandlerFunc func(GetUserlistsParams, interface{}) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetUserlistsHandlerFunc) Handle(params GetUserlistsParams, principal interface{}) middleware.Responder { + return fn(params, principal) +} + +// GetUserlistsHandler interface for that can handle valid get userlists params +type GetUserlistsHandler interface { + Handle(GetUserlistsParams, interface{}) middleware.Responder +} + +// NewGetUserlists creates a new http.Handler for the get userlists operation +func NewGetUserlists(ctx *middleware.Context, handler GetUserlistsHandler) *GetUserlists { + return &GetUserlists{Context: ctx, Handler: handler} +} + +/* + GetUserlists swagger:route GET /services/haproxy/configuration/userlists Userlist getUserlists + +# Return an array of userlists + +Returns an array of all configured userlists. +*/ +type GetUserlists struct { + Context *middleware.Context + Handler GetUserlistsHandler +} + +func (o *GetUserlists) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetUserlistsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal interface{} + if uprinc != nil { + principal = uprinc.(interface{}) // this is really a interface{}, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operations/userlist/get_userlists_parameters.go b/operations/userlist/get_userlists_parameters.go new file mode 100644 index 00000000..24a0fff0 --- /dev/null +++ b/operations/userlist/get_userlists_parameters.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewGetUserlistsParams creates a new GetUserlistsParams object +// with the default values initialized. +func NewGetUserlistsParams() GetUserlistsParams { + + var ( + // initialize parameters with default values + + fullSectionDefault = bool(false) + ) + + return GetUserlistsParams{ + FullSection: &fullSectionDefault, + } +} + +// GetUserlistsParams contains all the bound params for the get userlists operation +// typically these are obtained from a http.Request +// +// swagger:parameters getUserlists +type GetUserlistsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Indicates if the action affects the specified child resources as well + In: query + Default: false + */ + FullSection *bool + /*ID of the transaction where we want to add the operation. Cannot be used when version is specified. + In: query + */ + TransactionID *string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetUserlistsParams() beforehand. +func (o *GetUserlistsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qFullSection, qhkFullSection, _ := qs.GetOK("full_section") + if err := o.bindFullSection(qFullSection, qhkFullSection, route.Formats); err != nil { + res = append(res, err) + } + + qTransactionID, qhkTransactionID, _ := qs.GetOK("transaction_id") + if err := o.bindTransactionID(qTransactionID, qhkTransactionID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindFullSection binds and validates parameter FullSection from query. +func (o *GetUserlistsParams) bindFullSection(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + // Default values have been previously initialized by NewGetUserlistsParams() + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("full_section", "query", "bool", raw) + } + o.FullSection = &value + + return nil +} + +// bindTransactionID binds and validates parameter TransactionID from query. +func (o *GetUserlistsParams) bindTransactionID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + o.TransactionID = &raw + + return nil +} diff --git a/operations/userlist/get_userlists_responses.go b/operations/userlist/get_userlists_responses.go new file mode 100644 index 00000000..46b25464 --- /dev/null +++ b/operations/userlist/get_userlists_responses.go @@ -0,0 +1,180 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/haproxytech/client-native/v6/models" +) + +// GetUserlistsOKCode is the HTTP code returned for type GetUserlistsOK +const GetUserlistsOKCode int = 200 + +/* +GetUserlistsOK Successful operation + +swagger:response getUserlistsOK +*/ +type GetUserlistsOK struct { + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload models.Userlists `json:"body,omitempty"` +} + +// NewGetUserlistsOK creates GetUserlistsOK with default headers values +func NewGetUserlistsOK() *GetUserlistsOK { + + return &GetUserlistsOK{} +} + +// WithConfigurationVersion adds the configurationVersion to the get userlists o k response +func (o *GetUserlistsOK) WithConfigurationVersion(configurationVersion string) *GetUserlistsOK { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get userlists o k response +func (o *GetUserlistsOK) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get userlists o k response +func (o *GetUserlistsOK) WithPayload(payload models.Userlists) *GetUserlistsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get userlists o k response +func (o *GetUserlistsOK) SetPayload(payload models.Userlists) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserlistsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Userlists{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +/* +GetUserlistsDefault General Error + +swagger:response getUserlistsDefault +*/ +type GetUserlistsDefault struct { + _statusCode int + /*Configuration file version + + */ + ConfigurationVersion string `json:"Configuration-Version"` + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetUserlistsDefault creates GetUserlistsDefault with default headers values +func NewGetUserlistsDefault(code int) *GetUserlistsDefault { + if code <= 0 { + code = 500 + } + + return &GetUserlistsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get userlists default response +func (o *GetUserlistsDefault) WithStatusCode(code int) *GetUserlistsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get userlists default response +func (o *GetUserlistsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithConfigurationVersion adds the configurationVersion to the get userlists default response +func (o *GetUserlistsDefault) WithConfigurationVersion(configurationVersion string) *GetUserlistsDefault { + o.ConfigurationVersion = configurationVersion + return o +} + +// SetConfigurationVersion sets the configurationVersion to the get userlists default response +func (o *GetUserlistsDefault) SetConfigurationVersion(configurationVersion string) { + o.ConfigurationVersion = configurationVersion +} + +// WithPayload adds the payload to the get userlists default response +func (o *GetUserlistsDefault) WithPayload(payload *models.Error) *GetUserlistsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get userlists default response +func (o *GetUserlistsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetUserlistsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + // response header Configuration-Version + + configurationVersion := o.ConfigurationVersion + if configurationVersion != "" { + rw.Header().Set("Configuration-Version", configurationVersion) + } + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operations/userlist/get_userlists_urlbuilder.go b/operations/userlist/get_userlists_urlbuilder.go new file mode 100644 index 00000000..efe8cd2a --- /dev/null +++ b/operations/userlist/get_userlists_urlbuilder.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package userlist + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + + "github.com/go-openapi/swag" +) + +// GetUserlistsURL generates an URL for the get userlists operation +type GetUserlistsURL struct { + FullSection *bool + TransactionID *string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserlistsURL) WithBasePath(bp string) *GetUserlistsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetUserlistsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetUserlistsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/services/haproxy/configuration/userlists" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/v3" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var fullSectionQ string + if o.FullSection != nil { + fullSectionQ = swag.FormatBool(*o.FullSection) + } + if fullSectionQ != "" { + qs.Set("full_section", fullSectionQ) + } + + var transactionIDQ string + if o.TransactionID != nil { + transactionIDQ = *o.TransactionID + } + if transactionIDQ != "" { + qs.Set("transaction_id", transactionIDQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetUserlistsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetUserlistsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetUserlistsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetUserlistsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetUserlistsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetUserlistsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rate/error.go b/rate/error.go new file mode 100644 index 00000000..458d8da5 --- /dev/null +++ b/rate/error.go @@ -0,0 +1,29 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package rate + +import "fmt" + +func NewTransactionLimitReachedError(limit uint64) error { + return &TransactionLimitReachedError{limit: limit} +} + +type TransactionLimitReachedError struct { + limit uint64 +} + +func (l TransactionLimitReachedError) Error() string { + return fmt.Sprintf("cannot start a new transaction, reached the maximum amount of %d active transactions available", l.limit) +} diff --git a/rate/limiter.go b/rate/limiter.go new file mode 100644 index 00000000..17e14b39 --- /dev/null +++ b/rate/limiter.go @@ -0,0 +1,19 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package rate + +type Threshold interface { + LimitReached() error +} diff --git a/rate/threshold_limit.go b/rate/threshold_limit.go new file mode 100644 index 00000000..2ced6633 --- /dev/null +++ b/rate/threshold_limit.go @@ -0,0 +1,34 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package rate + +type thresholdLimit struct { + actual func() uint64 + limit uint64 +} + +func (t *thresholdLimit) LimitReached() (err error) { + if t.actual() >= t.limit { + err = NewTransactionLimitReachedError(t.limit) + } + return err +} + +func NewThresholdLimit(limit uint64, actual func() uint64) Threshold { + return &thresholdLimit{ + actual: actual, + limit: limit, + } +} diff --git a/rate/threshold_limit_test.go b/rate/threshold_limit_test.go new file mode 100644 index 00000000..31e1dfe6 --- /dev/null +++ b/rate/threshold_limit_test.go @@ -0,0 +1,43 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package rate + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_thresholdLimit_LimitReached(t *testing.T) { + t.Run("ko", func(t *testing.T) { + tl := thresholdLimit{ + actual: func() uint64 { + return 10 + }, + limit: 10, + } + assert.Error(t, tl.LimitReached()) + }) + t.Run("ok", func(t *testing.T) { + tl := thresholdLimit{ + actual: func() uint64 { + return 0 + }, + limit: 10, + } + require.NoError(t, tl.LimitReached()) + }) +} diff --git a/resilient/client.go b/resilient/client.go new file mode 100644 index 00000000..bb063168 --- /dev/null +++ b/resilient/client.go @@ -0,0 +1,69 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package resilient + +import ( + "context" + "errors" + + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/client-native/v6/runtime" + cn "github.com/haproxytech/dataplaneapi/client-native" + dataplaneapi_config "github.com/haproxytech/dataplaneapi/configuration" +) + +type Client struct { + client_native.HAProxyClient +} + +func NewClient(c client_native.HAProxyClient) *Client { + return &Client{ + c, + } +} + +// Runtime is a wrapper around HAProxyClient.Runtime +// that retries once to configure the runtime client if it failed +func (c *Client) Runtime() (runtime.Runtime, error) { + runtime, err := c.HAProxyClient.Runtime() + + // We already have a valid runtime + // Let's return it + if err == nil { + return runtime, nil + } + + // Now, for let's try to reconfigure once the runtime + cfg, err := c.Configuration() + if err != nil { + return nil, err + } + + dpapiCfg := dataplaneapi_config.Get() + haproxyOptions := dpapiCfg.HAProxy + + // Let's disable the delayed start by putting a max value to 0 + // This is important to not block the handlers by waiting the DelayedStartMax that we wait for when we start + haproxyOptions.DelayedStartMax = 0 + // let's retry + rnt := cn.ConfigureRuntimeClient(context.Background(), cfg, haproxyOptions) + if rnt == nil { + return nil, errors.New("retry - unable to configure runtime client") + } + c.ReplaceRuntime(rnt) + + return c.HAProxyClient.Runtime() +} diff --git a/runtime/README.md b/runtime/README.md new file mode 100644 index 00000000..02126d73 --- /dev/null +++ b/runtime/README.md @@ -0,0 +1,81 @@ +# ![HAProxy](../assets/images/haproxy-weblogo-210x49.png "HAProxy") + +# Runtime command socket for debugging purpose + +## Goal +Dataplaneapi provides a command socket for debugging purpose. + +The path for this socket can be defined : +- as dataplaneapi process argument (*--debug-socket-path*). Refer to [dataplaneapi README](../README.md) +- in the dataplaneapi configuration file. Refer to [configuration file](../configuration/README.md) + +Note : if --debug-socket-path* is not set, the command socket will not run. + +## Check the socket path at start up + +You can check the socket path when starting dataplaneapi in the logs: +``` +"level":"info","msg":"-- command socket Starting on /path/to/dataplane-debug.sock","time":"2023-09-13T11:44:08+02:00"} +`````` + +## Help + +To display the available comands: + +``` +echo "help" | socat - /path/to/dataplane-debug.sock +``` + +will output: +``` +Dataplaneapi runtime commands: + conf show HAProxy configuration + goroutines display number of goroutines + stack output stack trace + version show dataplaneapi version + pprof pprof dumps + dapiconf show dataplaneapi configuration + +type help <command> for more info +``` + + +To get more info on a command, for example on the `conf` command: +``` +echo "help conf" | socat - /path/to/dataplane-debug.sock +``` +will output: +``` +Dataplaneapi runtime + +command conf: +conf show HAProxy current raw configuration +conf raw version [transactionID] show HAProxy raw configuration for version (transactionID is optional default "" (for a transactionID, put '0' for version)) +conf structured show HAProxy current structured configuration +conf structured version [transactionID] show HAProxy structured configuration for version (transactionID is optional default "" (for a transactionID, put '0' for version)) + +``` +## Available commands + +-`conf` to show the HAProxy configuration (possibly for version/transaction): + - `conf`: for current raw version + - `conf raw`: for current raw version + - `conf structured` for current structured version +Adding `version [transactionID]` to `conf raw` or `conf structured` allow to show the configuration for a given version or transaction. +Note that for a transactionID, version should be 0, for example : *conf raw 0 123-456-789* +- `dapiconf` for the dataplaneapi configuration +- `gouroutines` for the number of goroutines +- `stack` for the stack trace +- `version` for the dataplaneapi version +- `pprof` for pprof dumps + + +### More info for : `pprof` +To have some examples on how to use pprof, the following command will give you some good guidance: + +``` +echo "pprof examples" | socat - /path/to/dataplane-debug.sock +``` + +### More info for: `dapiconf` +`dapiconf` dumps the *Configuration*. You can find an example of the output, when the dataplane is run with ` -f example-full.yaml` [dapiconf output](./example/dapiconf_output.txt) diff --git a/runtime/commands.go b/runtime/commands.go new file mode 100644 index 00000000..27633af3 --- /dev/null +++ b/runtime/commands.go @@ -0,0 +1,74 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package runtime + +import ( + "sync" + + commands "github.com/haproxytech/dataplaneapi/runtime/commands" +) + +type Commands struct { + cmdS map[string]commands.Command + muCmds sync.Mutex + help commands.Help + init sync.Once + initHelp sync.Once +} + +func (c *Commands) Get(key string) (commands.Command, bool) { + if key == "help" { + c.initHelp.Do(func() { + c.help.Header = []byte("Dataplaneapi runtime commands:\n") + c.help.Footer = []byte("\ntype help <command> for more info") + }) + return c.help, true + } + cmd, ok := c.cmdS[key] + return cmd, ok +} + +func (c *Commands) Register(cmd commands.Command) { + c.init.Do(func() { + c.cmdS = map[string]commands.Command{} + }) + c.muCmds.Lock() + defer c.muCmds.Unlock() + c.cmdS[cmd.Definition().Key] = cmd + c.help.Commands = append(c.help.Commands, cmd.Definition()) +} + +func (c *Commands) UnRegister(cmdKey string) { + c.muCmds.Lock() + defer c.muCmds.Unlock() + delete(c.cmdS, cmdKey) +} + +type Command interface { + Definition() definition + Command(cmd []string) (response []byte, err error) +} + +type definition struct { + Key string + Info string + Commands []allCommands +} + +type allCommands struct { + Command string + Info string +} diff --git a/runtime/commands/config_dapi.go b/runtime/commands/config_dapi.go new file mode 100644 index 00000000..67578269 --- /dev/null +++ b/runtime/commands/config_dapi.go @@ -0,0 +1,46 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +import ( + "fmt" + + "github.com/haproxytech/dataplaneapi/configuration" + "github.com/kr/pretty" +) + +type DataplaneapiConfiguration struct{} + +func (g DataplaneapiConfiguration) Definition() definition { + return definition{ + Key: "dapiconf", + Info: "show dataplaneapi configuration", + Commands: []allCommands{ + {"dapiconf", "show dataplaneapi configuration"}, + }, + } +} + +func (g DataplaneapiConfiguration) Command(_ []string) (response []byte, err error) { + cfg := configuration.Get() + var loadMsg []string + loadMsg, err = cfg.Load() + b := fmt.Sprintf("%# v", pretty.Formatter(cfg)) + if len(loadMsg) > 0 { + fmt.Print(loadMsg) + } + return []byte(b), err +} diff --git a/runtime/commands/config_haproxy.go b/runtime/commands/config_haproxy.go new file mode 100644 index 00000000..03b86036 --- /dev/null +++ b/runtime/commands/config_haproxy.go @@ -0,0 +1,82 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +import ( + "errors" + "strconv" + + client_native "github.com/haproxytech/client-native/v6" +) + +const ( + ConfCmdKey = "conf" +) + +type HAProxyConfiguration struct { + Client client_native.HAProxyClient +} + +func (g HAProxyConfiguration) Definition() definition { + return definition{ + Key: ConfCmdKey, + Info: "show HAProxy configuration", + Commands: []allCommands{ + {"conf", "show HAProxy current raw configuration"}, + {"conf raw version [transactionID]", "show HAProxy raw configuration for version (transactionID is optional default \"\" (for a transactionID, put '0' for version))"}, + {"conf structured", "show HAProxy current structured configuration"}, + {"conf structured version [transactionID]", "show HAProxy structured configuration for version (transactionID is optional default \"\" (for a transactionID, put '0' for version))"}, + }, + } +} + +func (g HAProxyConfiguration) Command(cmd []string) (response []byte, err error) { + configurationClient, err := g.Client.Configuration() + if err != nil { + return []byte{}, err + } + var version int64 + transactionID := "" + configType := "raw" + + if len(cmd) >= 2 { + configType = cmd[1] + } + + if len(cmd) >= 3 { + versionS := cmd[2] + version, err = strconv.ParseInt(versionS, 10, 64) + if err != nil { + return []byte{}, err + } + if len(cmd) >= 4 { + transactionID = cmd[3] + } + } + + var config string + switch configType { + case "raw": + _, config, err = configurationClient.GetRawConfiguration(transactionID, version) + if err != nil { + return []byte{}, err + } + case "structured": + return []byte{}, errors.New("structured not implemented in community edition") + } + + return []byte(config), nil +} diff --git a/runtime/commands/goroutines.go b/runtime/commands/goroutines.go new file mode 100644 index 00000000..073f18b5 --- /dev/null +++ b/runtime/commands/goroutines.go @@ -0,0 +1,37 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +import ( + "runtime" + "strconv" +) + +type Goroutines struct{} + +func (g Goroutines) Definition() definition { + return definition{ + Key: "goroutines", + Info: "display number of goroutines", + Commands: []allCommands{ + {"goroutines", "display number of goroutines"}, + }, + } +} + +func (g Goroutines) Command(_ []string) (response []byte, err error) { + return []byte(strconv.Itoa(runtime.NumGoroutine())), nil +} diff --git a/runtime/commands/help.go b/runtime/commands/help.go new file mode 100644 index 00000000..799e1541 --- /dev/null +++ b/runtime/commands/help.go @@ -0,0 +1,83 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +import ( + "fmt" + "strconv" + "strings" +) + +type Help struct { + Header []byte + Footer []byte + Commands []definition +} + +func (g Help) Definition() definition { + return definition{ + Key: "help", + Info: "show help", + Commands: []allCommands{ + {"help", "show help"}, + }, + } +} + +func (g Help) Command(cmd []string) (response []byte, err error) { + if len(cmd) < 2 { + return g.getGeneralHelp(), nil + } + return g.getCommandHelp(cmd[1]), nil +} + +func (g Help) getGeneralHelp() (response []byte) { + response = append(response, g.Header...) + for _, c := range g.Commands { + line := fmt.Sprintf("%15s %s\n", c.Key, c.Info) + response = append(response, []byte(line)...) + } + + response = append(response, g.Footer...) + return response +} + +func (g Help) getCommandHelp(command string) (response []byte) { + response = append(response, []byte("Dataplaneapi runtime\n\ncommand "+command+":\n")...) + found := false + for _, c := range g.Commands { + cmd := strings.Split(c.Commands[0].Command, " ") + if cmd[0] == command { + maxLen := 0 + for _, cmd := range c.Commands { + if len(cmd.Command) > maxLen { + maxLen = len(cmd.Command) + } + } + format := "%-" + strconv.Itoa(maxLen+2) + "s %s\n" + for _, cmd := range c.Commands { + found = true + line := fmt.Sprintf(format, cmd.Command, cmd.Info) + response = append(response, []byte(line)...) + } + } + } + if !found { + return g.getGeneralHelp() + } + + return response +} diff --git a/runtime/commands/interface.go b/runtime/commands/interface.go new file mode 100644 index 00000000..f13d1bd4 --- /dev/null +++ b/runtime/commands/interface.go @@ -0,0 +1,32 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +type Command interface { + Definition() definition + Command(cmd []string) (response []byte, err error) +} + +type definition struct { + Key string + Info string + Commands []allCommands +} + +type allCommands struct { + Command string + Info string +} diff --git a/runtime/commands/pprof.go b/runtime/commands/pprof.go new file mode 100644 index 00000000..c5f04ae9 --- /dev/null +++ b/runtime/commands/pprof.go @@ -0,0 +1,248 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +import ( + "context" + "errors" + "fmt" + "net/http" + np "net/http/pprof" + "os" + "runtime/pprof" + "strings" + "sync" + "time" + + "github.com/haproxytech/dataplaneapi/log" +) + +type PProf struct{} + +func (g PProf) Definition() definition { + return definition{ + Key: "pprof", + Info: "pprof dumps", + Commands: []allCommands{ + {"pprof examples", "pprof usage examples"}, + {"pprof cpu start filename [1h42m]", "start cpu pprof, time is optional default 10 mins"}, + {"pprof cpu stop", "stop cpu pprof"}, + {"pprof mem filename", "dump mem pprof"}, + {"pprof web start port [10m]", "pprof web interface, time is optional default 10 mins"}, + {"pprof web stop", "pprof web interface"}, + }, + } +} + +var ( + pprofServer *http.Server + mu sync.Mutex + stopWebServer context.CancelFunc + stopCPUProfiling context.CancelFunc +) + +func (g PProf) Command(cmd []string) (response []byte, err error) { + if len(cmd) < 3 { + if len(cmd) != 2 || cmd[1] != "examples" { + return []byte(strings.Trim("", " ")), errors.New("unrecognized command") + } + } + mu.Lock() + defer mu.Unlock() + switch cmd[1] { + case "web": + switch cmd[2] { + case "start": + if stopWebServer != nil { + return []byte{}, errors.New("pprof web is already running") + } + if len(cmd) < 4 { + return []byte{}, errors.New("port required: pprof web start port") + } + sleepTime := time.Minute * 10 + if len(cmd) > 4 { + sleepTime, err = time.ParseDuration(cmd[4]) + if err != nil { + return []byte{}, err + } + } + mux := http.NewServeMux() + + mux.HandleFunc("/debug/pprof/", np.Index) + mux.HandleFunc("/debug/pprof/cmdline", np.Cmdline) + mux.HandleFunc("/debug/pprof/profile", np.Profile) + mux.HandleFunc("/debug/pprof/symbol", np.Symbol) + mux.HandleFunc("/debug/pprof/trace", np.Trace) + + pprofServer = &http.Server{ + Addr: ":" + cmd[3], + Handler: mux, + } + + go func() { + err = pprofServer.ListenAndServe() + if err != nil { + log.Error(err) + } + }() + + var ctx context.Context + ctx, stopWebServer = context.WithCancel(context.Background()) + + go func(context.Context) { + <-ctx.Done() + mu.Lock() + defer mu.Unlock() + ctxServer := context.Background() + err = pprofServer.Shutdown(ctxServer) //nolint:contextcheck + if err != nil { + return + } + pprofServer = nil + }(ctx) + + go func() { + time.Sleep(sleepTime) + mu.Lock() + defer mu.Unlock() + select { + case <-ctx.Done(): + return + default: + } + if stopWebServer != nil { + stopWebServer() + } + }() + + return fmt.Appendf(nil, "pprof web started on port %s with duration of %s", cmd[3], sleepTime), nil + case "stop": + if stopWebServer != nil { + stopWebServer() + return []byte("pprof web server stopping"), nil + } + return []byte(""), errors.New("pprof web server not running") + default: + return []byte{}, errors.New("unrecognized command") + } + case "cpu": + switch cmd[2] { + case "start": + if len(cmd) < 4 { + return []byte{}, errors.New("filename required: pprof cpu start filename") + } + sleepTime := time.Minute * 10 + if len(cmd) > 4 { + sleepTime, err = time.ParseDuration(cmd[4]) + if err != nil { + return []byte{}, err + } + } + f, err := os.Create(cmd[3]) + if err != nil { + return []byte{}, err + } + err = pprof.StartCPUProfile(f) + if err != nil { + return []byte{}, err + } + var ctx context.Context + ctx, stopCPUProfiling = context.WithCancel(context.Background()) + + go func(context.Context) { + <-ctx.Done() + mu.Lock() + defer mu.Unlock() + pprof.StopCPUProfile() + stopCPUProfiling = nil + }(ctx) + + go func() { + time.Sleep(sleepTime) + mu.Lock() + defer mu.Unlock() + select { + case <-ctx.Done(): + return + default: + } + if stopCPUProfiling != nil { + stopCPUProfiling() + } + }() + + return fmt.Appendf(nil, "CPU Profile with duration of %s", sleepTime), nil + case "stop": + if stopCPUProfiling == nil { + return []byte(""), errors.New("CPU Profile not running") + } + stopCPUProfiling() + return []byte("CPU Profile stopped"), nil + default: + return []byte{}, errors.New("unrecognized command") + } + case "mem": + if len(cmd) < 3 { + return []byte{}, errors.New("filename required: pprof mem filename") + } + f, err := os.Create(cmd[2]) + if err != nil { + return []byte{}, err + } + err = pprof.WriteHeapProfile(f) + if err != nil { + return []byte{}, err + } + f.Close() + return []byte("pprof.WriteHeapProfile executed"), nil + case "examples": + return []byte(pprofExamples), nil + default: + return []byte{}, errors.New("unrecognized command") + } +} + +const pprofExamples = `CPU profiling: + echo "pprof cpu start /tmp/dataplane.cpu.pprof 1h42m" | socat -t 30 UNIX-CONNECT:dataplaneapi.sock - + ... + # make api requests + ... + echo "pprof cpu stop" | socat -t 30 UNIX-CONNECT:dataplaneapi.sock - + # to view in browser, run + go tool pprof -web dataplane.cpu.pprof + +MEMORY profiling: + echo "pprof mem /tmp/dataplane.mem.pprof" | socat -t 30 UNIX-CONNECT:dataplaneapi.sock - + # to view in browser, run + go tool pprof -web dataplane.mem.pprof + +WEB: + echo "pprof web start 8888 1h" | socat -t 30 UNIX-CONNECT:dataplaneapi.sock - + # heap + go tool pprof http://localhost:6060/debug/pprof/heap + # profile + go tool pprof -web http://localhost:8888/debug/pprof/profile + # trace + curl -s http://127.0.0.1:8888/debug/pprof/trace?seconds=60 > cpu-trace.out + go tool trace cpu-trace.out + # pprof + curl -s http://127.0.0.1:8888/debug/pprof/profile?seconds=60 > ./cpu.out + ... + # various API requests + ... + go tool pprof -web cpu.out + echo "pprof web stop" | socat -t 30 UNIX-CONNECT:dataplaneapi.sock - +` diff --git a/runtime/commands/stack.go b/runtime/commands/stack.go new file mode 100644 index 00000000..844a87fc --- /dev/null +++ b/runtime/commands/stack.go @@ -0,0 +1,119 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +import ( + "bytes" + "errors" + "fmt" + "io" + "path/filepath" + "runtime" + "strings" + + "github.com/maruel/panicparse/v2/stack" +) + +type Stack struct{} + +func (g Stack) Definition() definition { + return definition{ + Key: "stack", + Info: "output stack trace", + Commands: []allCommands{ + {"stack", "output stack trace"}, + {"stack raw", "output stack trace - go stack trace"}, + }, + } +} + +func (g Stack) Command(cmd []string) (response []byte, err error) { + if len(cmd) < 2 || cmd[1] != "raw" { + dmp, err := MakeStackDump() + if err != nil { + return []byte{}, err + } + return []byte(dmp), nil + } + buffSize := int(128 * 1e6) + buff := make([]byte, buffSize) + runtime.Stack(buff, true) + trace := bytes.Trim(buff, "\x00") // this dramatically speeds up output + + return trace, nil +} + +func MakeStackDump() (string, error) { + buffSize := int(128 * 1e6) + + buff := make([]byte, buffSize) + runtime.Stack(buff, true) + + var result strings.Builder + trace := bytes.Trim(buff, "\x00") + + s, _, err := stack.ScanSnapshot(bytes.NewReader(trace), io.Discard, stack.DefaultOpts()) + if err != nil && !errors.Is(err, io.EOF) { + return "", err + } + + // Find out similar goroutine traces and group them into buckets. + buckets := s.Aggregate(stack.AnyValue).Buckets + + // Calculate alignment. + srcLen := 0 + pkgLen := 0 + for _, bucket := range buckets { + for _, line := range bucket.Stack.Calls { + if l := len(fmt.Sprintf("%s:%d", line.SrcName, line.Line)); l > srcLen { + srcLen = l + } + if l := len(filepath.Base(line.Func.ImportPath)); l > pkgLen { + pkgLen = l + } + } + } + + for _, bucket := range buckets { + // Print the goroutine header. + extra := "" + if s := bucket.SleepString(); s != "" { + extra += " [" + s + "]" + } + if bucket.Locked { + extra += " [locked]" + } + + if len(bucket.CreatedBy.Calls) != 0 { + extra += fmt.Sprintf(" [Created by %s.%s @ %s:%d]", bucket.CreatedBy.Calls[0].Func.DirName, bucket.CreatedBy.Calls[0].Func.Name, bucket.CreatedBy.Calls[0].SrcName, bucket.CreatedBy.Calls[0].Line) + } + result.WriteString(fmt.Sprintf("%d: %s%s\n", len(bucket.IDs), bucket.State, extra)) + + // Print the stack lines. + for _, line := range bucket.Stack.Calls { + arg := line.Args + result.WriteString(fmt.Sprintf( + " %-*s %-*s %s(%s)\n", + pkgLen, line.Func.DirName, srcLen, + fmt.Sprintf("%s:%d", line.SrcName, line.Line), + line.Func.Name, &arg)) + } + if bucket.Stack.Elided { + result.WriteString(" (...)\n") + } + } + return result.String(), nil +} diff --git a/runtime/commands/version.go b/runtime/commands/version.go new file mode 100644 index 00000000..36c8e2bc --- /dev/null +++ b/runtime/commands/version.go @@ -0,0 +1,34 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package commands + +type DataplaneapiVersion struct { + Version string +} + +func (g DataplaneapiVersion) Definition() definition { + return definition{ + Key: "version", + Info: "show dataplaneapi version", + Commands: []allCommands{ + {"version", "show dataplaneapi version"}, + }, + } +} + +func (g DataplaneapiVersion) Command(_ []string) (response []byte, err error) { + return []byte(g.Version), nil +} diff --git a/runtime/example/dapiconf_output.txt b/runtime/example/dapiconf_output.txt new file mode 100644 index 00000000..eb0fcfe7 --- /dev/null +++ b/runtime/example/dapiconf_output.txt @@ -0,0 +1,297 @@ +&configuration.Configuration{ + Cluster: configuration.ClusterConfiguration{ + APIRegisterPath: configuration.AtomicString{}, + APIBasePath: configuration.AtomicString{}, + ActiveBootstrapKey: configuration.AtomicString{}, + Token: configuration.AtomicString{}, + ID: configuration.AtomicString{ + value: atomic.Value{ + v: "cluster123456", + }, + }, + Port: configuration.AtomicInt{ + value: atomic.Value{ + v: int(80), + }, + }, + BootstrapKey: configuration.AtomicString{}, + APINodesPath: configuration.AtomicString{}, + URL: configuration.AtomicString{}, + StorageDir: configuration.AtomicString{}, + CertificateDir: configuration.AtomicString{}, + CertificateFetched: configuration.AtomicBool{}, + Name: configuration.AtomicString{ + value: atomic.Value{ + v: "cluster777Name", + }, + }, + Description: configuration.AtomicString{}, + ClusterID: configuration.AtomicString{}, + ClusterLogTargets: nil, + }, + Notify: configuration.NotifyConfiguration{ + BootstrapKeyChanged: &configuration.ChanNotify{ + subscribers: {"monitorBootstrapKey":0xc000e4be60}, + mu: sync.RWMutex{}, + }, + ServerStarted: &configuration.ChanNotify{ + subscribers: {"clusterMonitor":0xc000e4be00}, + mu: sync.RWMutex{}, + }, + CertificateRefresh: &configuration.ChanNotify{ + subscribers: {"monitorCertificateRefresh":0xc000e4bec0}, + mu: sync.RWMutex{}, + }, + Reload: &configuration.ChanNotify{ + subscribers: {"main":0xc001916060}, + mu: sync.RWMutex{}, + }, + Shutdown: &configuration.ChanNotify{ + subscribers: {"main":0xc001988000}, + mu: sync.RWMutex{}, + }, + }, + Mode: configuration.AtomicString{ + value: atomic.Value{ + v: "cluster", + }, + }, + storage: &configuration.StorageYML{ + cfg: &configuration.StorageDataplaneAPIConfiguration{ + Version: &int(2), + Name: &"famous_condor", + Mode: &"cluster", + DeprecatedBootstrapKey: (*string)(nil), + Status: &"", + Dataplaneapi: &configuration.configTypeDataplaneapi{ + WriteTimeout: &"60s", + GracefulTimeout: &"15s", + ShowSystemInfo: &bool(false), + MaxHeaderSize: &"1MiB", + SocketPath: &"/var/run/data-plane.sock", + DebugSocketPath: &"/home/helene/go/src/gitlab.int.haproxy.com/dataplaneapi/.test/dataplane-debug.sock", + Host: &"localhost", + Port: &int(80), + ListenLimit: &int(1024), + DisableInotify: &bool(false), + ReadTimeout: &"30s", + Advertised: &configuration.configTypeAdvertised{ + APIAddress: &"10.2.3.4", + APIPort: &int64(80), + }, + CleanupTimeout: &"10s", + KeepAlive: &"3m", + PIDFile: &"/tmp/dataplane.pid", + UID: (*int)(nil), + GID: (*int)(nil), + TLS: &configuration.configTypeTLS{ + TLSHost: (*string)(nil), + TLSPort: &int(6443), + TLSCertificate: (*flags.Filename)(nil), + TLSCertificateKey: (*flags.Filename)(nil), + TLSCACertificate: (*flags.Filename)(nil), + TLSListenLimit: &int(10), + TLSKeepAlive: &"1m", + TLSReadTimeout: &"10s", + TLSWriteTimeout: &"10s", + }, + EnabledListeners: &[]string{"http"}, + Userlist: &configuration.configTypeUserlist{ + Userlist: &"controller", + UserListFile: (*string)(nil), + }, + Transaction: &configuration.configTypeTransaction{ + TransactionDir: &"/tmp/haproxy", + BackupsNumber: &int(0), + BackupsDir: &"/tmp/backups", + MaxOpenTransactions: &int64(20), + }, + Resources: &configuration.configTypeResources{ + MapsDir: &"/etc/haproxy/maps", + SSLCertsDir: &"/etc/haproxy/ssl", + DataplaneStorageDir: (*string)(nil), + ControllerStorageDir: (*string)(nil), + UpdateMapFiles: &bool(false), + UpdateMapFilesPeriod: &int64(10), + SpoeDir: &"/etc/haproxy/spoe", + SpoeTransactionDir: &"/tmp/spoe-haproxy", + }, + User: { + { + Name: "admin", + Insecure: &bool(true), + Password: &"adminpwd", + }, + }, + }, + Haproxy: &configuration.configTypeHaproxy{ + ConfigFile: &"/etc/haproxy/haproxy.cfg", + HAProxy: &"haproxy", + MasterRuntime: (*string)(nil), + NodeIDFile: (*string)(nil), + MasterWorkerMode: &bool(false), + Reload: &configuration.configTypeReload{ + ReloadDelay: &int(5), + ReloadCmd: &"systemctl reload haproxy", + RestartCmd: &"systemctl restart haproxy", + StatusCmd: &"systemctl status haproxy", + ServiceName: &"haproxy.service", + ReloadRetention: &int(1), + ReloadStrategy: &"custom", + ValidateCmd: (*string)(nil), + }, + }, + Cluster: &configuration.configTypeCluster{ + APINodesPath: &"", + Token: &"", + ClusterTLSCertDir: (*string)(nil), + ActiveBootstrapKey: &"", + APIRegisterPath: &"", + URL: &"", + Port: &int(80), + StorageDir: &"", + BootstrapKey: &"", + ID: &"cluster123456", + APIBasePath: &"", + CertificateDir: &"", + CertificateFetched: &bool(false), + Name: &"cluster777Name", + Description: &"", + ClusterID: &"", + ClusterLogTargets: nil, + }, + ServiceDiscovery: (*configuration.configTypeServiceDiscovery)(nil), + Log: &configuration.configTypeLog{ + LogTo: &"stdout", + LogFile: &"/var/log/dataplaneapi/dataplaneapi.log", + LogLevel: &"warning", + LogFormat: &"text", + ACLFormat: &"%h", + Syslog: &configuration.configTypeSyslog{ + SyslogAddr: (*string)(nil), + SyslogProto: &"tcp", + SyslogTag: &"dataplaneapi", + SyslogLevel: &"debug", + SyslogFacility: &"local0", + }, + }, + LogTargets: &log.Targets{ + { + LogTo: "stdout", + LogFile: "", + LogLevel: "debug", + LogFormat: "json", + ACLFormat: "", + SyslogAddr: "", + SyslogProto: "", + SyslogTag: "", + SyslogLevel: "", + SyslogFacility: "", + SyslogMsgID: "", + LogTypes: {"access", "app"}, + }, + { + LogTo: "file", + LogFile: "/var/log/dataplanepi.log", + LogLevel: "info", + LogFormat: "text", + ACLFormat: "", + SyslogAddr: "", + SyslogProto: "", + SyslogTag: "", + SyslogLevel: "", + SyslogFacility: "", + SyslogMsgID: "", + LogTypes: {"app"}, + }, + { + LogTo: "syslog", + LogFile: "", + LogLevel: "info", + LogFormat: "", + ACLFormat: "", + SyslogAddr: "127.0.0.1", + SyslogProto: "tcp", + SyslogTag: "dataplaneapi", + SyslogLevel: "debug", + SyslogFacility: "local0", + SyslogMsgID: "", + LogTypes: {"access"}, + }, + }, + }, + filename: "./.test/etc/example-full.yaml", + }, + Name: configuration.AtomicString{ + value: atomic.Value{ + v: "famous_condor", + }, + }, + Cmdline: configuration.AtomicString{ + value: atomic.Value{ + v: "./build/dataplaneapi -f ./.test/etc/example-full.yaml ", + }, + }, + Status: configuration.AtomicString{}, + DeprecatedBootstrapKey: configuration.AtomicString{}, + reloadSignal: 0xc0012e4ea0, + shutdownSignal: 0xc0012e4de0, + MapSync: &configuration.MapSync{ + mapQuitChan: 0xc00005a300, + mu: sync.RWMutex{}, + }, + Syslog: log.SyslogOptions{SyslogAddr:"", SyslogProto:"tcp", SyslogTag:"dataplaneapi", SyslogLevel:"debug", SyslogFacility:"local0", SyslogMsgID:""}, + Logging: log.LoggingOptions{LogTo:"stdout", LogFile:"/var/log/dataplaneapi/dataplaneapi.log", LogLevel:"warning", LogFormat:"text", ACLFormat:"%h"}, + RuntimeData: configuration.RuntimeData{Host:"127.0.0.1", APIBasePath:"/v2", Port:80}, + ServiceDiscovery: configuration.ServiceDiscovery{}, + Users: { + {Name:"admin", Password:"adminpwd", Insecure:true}, + }, + APIOptions: configuration.APIConfiguration{APIAddress:"10.2.3.4", APIPort:80}, + LogTargets: { + { + LogTo: "stdout", + LogFile: "", + LogLevel: "debug", + LogFormat: "json", + ACLFormat: "", + SyslogAddr: "", + SyslogProto: "", + SyslogTag: "", + SyslogLevel: "", + SyslogFacility: "", + SyslogMsgID: "", + LogTypes: {"access", "app"}, + }, + { + LogTo: "file", + LogFile: "/var/log/dataplanepi.log", + LogLevel: "info", + LogFormat: "text", + ACLFormat: "", + SyslogAddr: "", + SyslogProto: "", + SyslogTag: "", + SyslogLevel: "", + SyslogFacility: "", + SyslogMsgID: "", + LogTypes: {"app"}, + }, + { + LogTo: "syslog", + LogFile: "", + LogLevel: "info", + LogFormat: "", + ACLFormat: "", + SyslogAddr: "127.0.0.1", + SyslogProto: "tcp", + SyslogTag: "dataplaneapi", + SyslogLevel: "debug", + SyslogFacility: "local0", + SyslogMsgID: "", + LogTypes: {"access"}, + }, + }, + HAProxy: configuration.HAProxyConfiguration{SpoeDir:"/etc/haproxy/spoe", ServiceName:"haproxy.service", HAProxy:"haproxy", UserListFile:"", ReloadCmd:"systemctl reload haproxy", RestartCmd:"systemctl restart haproxy", StatusCmd:"systemctl status haproxy", NodeIDFile:"", PIDFile:"/tmp/dataplane.pid", ReloadStrategy:"custom", TransactionDir:"/tmp/haproxy", ValidateCmd:"", BackupsDir:"/tmp/backups", MapsDir:"/etc/haproxy/maps", SpoeTransactionDir:"/tmp/spoe-haproxy", DataplaneConfig:"./.test/etc/example-full.yaml", ConfigFile:"/etc/haproxy/haproxy.cfg", Userlist:"controller", MasterRuntime:"", SSLCertsDir:"/etc/haproxy/ssl", GeneralStorageDir:"/etc/haproxy/general", ClusterTLSCertDir:"", UpdateMapFilesPeriod:10, ReloadDelay:5, MaxOpenTransactions:20, BackupsNumber:0, ReloadRetention:1, UID:0, GID:0, UpdateMapFiles:false, ShowSystemInfo:false, MasterWorkerMode:false, DisableInotify:false, DebugSocketPath:"/home/helene/go/src/gitlab.int.haproxy.com/dataplaneapi/.test/dataplane-debug.sock"}, + mutex: sync.Mutex{}, +} diff --git a/runtime/runtime.go b/runtime/runtime.go new file mode 100644 index 00000000..ea264196 --- /dev/null +++ b/runtime/runtime.go @@ -0,0 +1,123 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package runtime + +import ( + "context" + "net" + "strings" + "sync" + "syscall" + + client_native "github.com/haproxytech/client-native/v6" + "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/log" + commands "github.com/haproxytech/dataplaneapi/runtime/commands" +) + +var ( + debugServerOnce sync.Once + debugServer *DebugServer +) + +type DebugServer struct { + Client client_native.HAProxyClient + DAPIVersion string + CnChannel chan client_native.HAProxyClient + comm Commands +} + +func GetServer() *DebugServer { + debugServerOnce.Do(func() { + debugServer = &DebugServer{} + debugServer.CnChannel = make(chan client_native.HAProxyClient) + }) + return debugServer +} + +func (s *DebugServer) Start(ctx context.Context, cancelFunc context.CancelFunc) { + go s.handleClientNativeClientUpdate(ctx) + + cfg := configuration.Get() + log.Debug("-- command socket waiting for DAPI conf readiness...") + <-cfg.Notify.ServerStarted.Subscribe("commandSocket") + log.Debug("-- command socket Server. conf ready...") + + cfg.Load() + if cfg.HAProxy.DebugSocketPath == "" { + log.Debug("-- command socket not set (--debug_socket_path). Not running the command socket server") + cancelFunc() + return + } + _ = syscall.Unlink(cfg.HAProxy.DebugSocketPath) // we don't care if it can't be removed + + var lc net.ListenConfig + l, err := lc.Listen(ctx, "unix", cfg.HAProxy.DebugSocketPath) + if err != nil { // but we care if we can't listen on it + log.Error(err) + return + } + + ver := strings.TrimSpace(s.DAPIVersion) + + s.comm.Register(commands.Goroutines{}) + s.comm.Register(commands.Stack{}) + s.comm.Register(commands.DataplaneapiVersion{Version: ver}) + s.comm.Register(commands.PProf{}) + s.comm.Register(commands.DataplaneapiConfiguration{}) + + stopped := false + + go func() { + <-ctx.Done() + stopped = true + l.Close() + log.Info("-- command socket Shutting down...") + }() + + log.Infof("-- command socket Starting on %s", cfg.HAProxy.DebugSocketPath) + go func() { + for { + fd, err := l.Accept() + if err != nil { + if stopped { + return + } + log.Info("runtime accept error", err.Error()) + return + } + go serve(&s.comm, fd) + } + }() +} + +func (s *DebugServer) handleClientNativeClientUpdate(ctx context.Context) { + for { + select { + case cn, ok := <-s.CnChannel: + if !ok { + return + } + log.Debug("-- command socket updating client_native client") + s.comm.UnRegister(commands.ConfCmdKey) + s.comm.Register(commands.HAProxyConfiguration{Client: cn}) + s.Client = cn + case <-ctx.Done(): + log.Debug("-- command socket handleClientNativeClientUpdate stopped") + return + } + } +} diff --git a/runtime/serve.go b/runtime/serve.go new file mode 100644 index 00000000..624cbe37 --- /dev/null +++ b/runtime/serve.go @@ -0,0 +1,63 @@ +// Copyright 2023 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package runtime + +import ( + "net" + "strings" + + "github.com/haproxytech/dataplaneapi/log" +) + +func serve(comm *Commands, conn net.Conn) { + buf := make([]byte, 512) + nr, err := conn.Read(buf) + defer conn.Close() + if err != nil { + log.Error("-- command socket: " + err.Error()) + return + } + + data := buf[0:nr] + log.Debugf("-- command socket got: %s", data) + + cmd := strings.Fields(string(data)) + c, ok := comm.Get(cmd[0]) + if cmd[0] == "exit" { + return + } + if !ok { + c, _ = comm.Get("help") + } + + rsp, err := c.Command(cmd) + if err != nil { + _, e := conn.Write([]byte(err.Error())) + if e != nil { + log.Error("-- command socket write: " + e.Error()) + } + return + } + _, e := conn.Write(rsp) + if e != nil { + log.Error("-- command socket write: " + e.Error()) + } + if len(rsp) < 1 || rsp[len(rsp)-1] != '\n' { + if _, err = conn.Write([]byte("\n")); err != nil { + log.Error("-- command socket write: " + err.Error()) + } + } +} diff --git a/server.go b/server.go index 198be0a6..011b035c 100644 --- a/server.go +++ b/server.go @@ -23,7 +23,6 @@ import ( "crypto/x509" "errors" "fmt" - "io/ioutil" "log" "net" "net/http" @@ -54,6 +53,7 @@ var defaultSchemes []string func init() { defaultSchemes = []string{ schemeHTTP, + schemeHTTPS, } } @@ -96,7 +96,7 @@ type Server struct { ListenLimit int `long:"listen-limit" description:"limit the number of outstanding requests"` KeepAlive time.Duration `long:"keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)" default:"3m"` ReadTimeout time.Duration `long:"read-timeout" description:"maximum duration before timing out read of the request" default:"30s"` - WriteTimeout time.Duration `long:"write-timeout" description:"maximum duration before timing out write of the response" default:"60s"` + WriteTimeout time.Duration `long:"write-timeout" description:"maximum duration before timing out write of the response" default:"30s"` httpServerL net.Listener TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"` @@ -148,7 +148,6 @@ func (s *Server) SetAPI(api *operations.DataPlaneAPI) { } s.api = api - s.api.Logger = log.Printf s.handler = configureAPI(api) } @@ -189,8 +188,6 @@ func (s *Server) Serve() (err error) { go handleInterrupt(once, s) servers := []*http.Server{} - wg.Add(1) - go s.handleShutdown(wg, &servers) if s.hasScheme(schemeUnix) { domainSocket := new(http.Server) @@ -267,7 +264,7 @@ func (s *Server) Serve() (err error) { // https://github.com/golang/go/tree/master/src/crypto/elliptic CurvePreferences: []tls.CurveID{tls.CurveP256}, // Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility - NextProtos: []string{"http/1.1", "h2"}, + NextProtos: []string{"h2", "http/1.1"}, // https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols MinVersion: tls.VersionTLS12, // These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy @@ -292,7 +289,7 @@ func (s *Server) Serve() (err error) { if s.TLSCACertificate != "" { // include specified CA certificate - caCert, caCertErr := ioutil.ReadFile(string(s.TLSCACertificate)) + caCert, caCertErr := os.ReadFile(string(s.TLSCACertificate)) if caCertErr != nil { return caCertErr } @@ -308,7 +305,7 @@ func (s *Server) Serve() (err error) { // call custom TLS configurator configureTLS(httpsServer.TLSConfig) - if len(httpsServer.TLSConfig.Certificates) == 0 { + if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil { // after standard and custom config are passed, this ends up with no certificate if s.TLSCertificate == "" { if s.TLSCertificateKey == "" { @@ -323,9 +320,6 @@ func (s *Server) Serve() (err error) { s.Fatalf("no certificate was configured for TLS") } - // must have at least one certificate or panics - httpsServer.TLSConfig.BuildNameToCertificate() - configureServer(httpsServer, "https", s.httpsServerL.Addr().String()) servers = append(servers, httpsServer) @@ -340,6 +334,10 @@ func (s *Server) Serve() (err error) { }(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig)) } + wg.Add(1) + go s.handleShutdown(wg, &servers) + + serverStartedCallback() wg.Wait() return nil } @@ -435,6 +433,9 @@ func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout) defer cancel() + // first execute the pre-shutdown hook + s.api.PreServerShutdown() + shutdownChan := make(chan bool) for i := range servers { server := servers[i] @@ -504,7 +505,7 @@ func (s *Server) TLSListener() (net.Listener, error) { func handleInterrupt(once *sync.Once, s *Server) { once.Do(func() { - for _ = range s.interrupt { + for range s.interrupt { if s.interrupted { s.Logf("Server already shutting down") continue diff --git a/storage/README.md b/storage/README.md new file mode 100644 index 00000000..b7b727ee --- /dev/null +++ b/storage/README.md @@ -0,0 +1,21 @@ +# ![HAProxy](../assets/images/haproxy-weblogo-210x49.png "HAProxy") + +# Data Plane API internal storage (dataplane_storage_dir) + + +## Dataplane API internal storage location + +Location of Dataplane API storage is managed by : +- dataplane API start argument `dataplane-storage-dir` (default value: `/etc/haproxy/dataplane`) + + +It can be overriden by a field in Daplane API configuration file: +- `dataplaneapi.resources.dataplane_storage_dir`: refer to [example-full](examples/example-full.yaml) + +## Files stored in Dataplane API internal storage location + +| File name | content | example | Comment | +|-----------|-------------------|---------|---------| +| cluster.json| Cluster configuration + Cluster users | [cluster.json](./examples/dapi-storage/cluster.json) | Prior to 3.0 was in Dapi config file: `cluster`, `dataplaneapi.user`, `status` sections| +| service_discovery/consul.json | Consul configuration| | Prior to 3.0 was in Dapi config file `service_discovery.consuls` section | +| service_discovery/aws.json | AWS configuration| | Prior to 3.0 was in Dapi config file `service_discovery.aws_regions` section | diff --git a/storage/cluster.go b/storage/cluster.go new file mode 100644 index 00000000..c90edfab --- /dev/null +++ b/storage/cluster.go @@ -0,0 +1,255 @@ +package storage + +import ( + "slices" + "sync" + + "github.com/haproxytech/dataplaneapi/storagetype" +) + +const ( + ClusterModeDataFileName = "cluster.json" +) + +type ClusterModeStorage interface { + Cluster + Users + + Load() error + Store() error + // IsClusterMode returns true if the storage is in cluster mode, false otherwise. + // i.e. if ClusterModeData are not empty + IsClusterMode() bool +} + +type Cluster interface { + // GetCluster does not load the data from the storage. Use Load() to load the data if needed. + GetCluster() *storagetype.Cluster + // GetStatus does not load the data from the storage. Use Load() to load the data if needed. + GetStatus() *string + + // SetClusterAndStore adds a new cluster to the storage and stores in the storage file. + SetClusterAndStore(cluster *storagetype.Cluster) error + // SetStatusAndStore sets a new status to the storage and stores in the storage file. + SetStatusAndStore(status *string) error + // UnsetClusterAndStore removes a cluster from the storage and stores in the storage file. + UnsetClusterAndStore() error +} + +type Users interface { + // GetUsers does not load the users from the storage. Use Load() to load the users if needed. + GetUsers() storagetype.Users + // AddUsersAndStore adds a list of users to the storage and stores in the storage file. + AddUsersAndStore(users storagetype.Users) error + // AddUserAndStore adds a new user to the storage and stores in the storage file. + AddUserAndStore(user storagetype.User) error + // RemoveUserAndStore removes a user from the storage and stores in the storage file. + RemoveUserAndStore(user storagetype.User) error + // ReplaceAllUsersAndStore replaces the list of users in the storage and stores in the storage file. + ReplaceAllUsersAndStore(users storagetype.Users) error +} + +type clusterModeStorageImpl struct { + ClusterModeData storagetype.ClusterModeData + storage Storage[storagetype.ClusterModeData] + mu sync.RWMutex +} + +// NewClusterModeStorage creates a new clusterStorageImpl with initial configuration from a file path. +func NewClusterModeStorage(path string) (ClusterModeStorage, error) { + fs := &fileStorage[storagetype.ClusterModeData]{path} + if err := fs.initFile(); err != nil { + return nil, err + } + clusterStorage, err := fs.Get() + if err != nil { + return nil, err + } + return &clusterModeStorageImpl{ + storage: fs, + ClusterModeData: clusterStorage, + }, nil +} + +func (cs *clusterModeStorageImpl) GetCluster() *storagetype.Cluster { + cs.mu.RLock() + defer cs.mu.RUnlock() + return cs.ClusterModeData.Cluster +} + +func (cs *clusterModeStorageImpl) GetStatus() *string { + cs.mu.RLock() + defer cs.mu.RUnlock() + return cs.ClusterModeData.Status +} + +func (cs *clusterModeStorageImpl) Load() error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cluster, err := cs.load() + if err != nil { + return err + } + cs.ClusterModeData = cluster + + return nil +} + +func (cs *clusterModeStorageImpl) Store() error { + cs.mu.Lock() + defer cs.mu.Unlock() + + if err := cs.store(); err != nil { + return err + } + return nil +} + +func (cs *clusterModeStorageImpl) IsClusterMode() bool { + cs.mu.RLock() + defer cs.mu.RUnlock() + return cs.ClusterModeData.IsClusterMode() +} + +func (cs *clusterModeStorageImpl) SetClusterAndStore(cluster *storagetype.Cluster) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + oldCluster := cs.ClusterModeData.Cluster + cs.ClusterModeData.Cluster = cluster + + // In case something went wrong while storing, set back the old value + if err := cs.store(); err != nil { + cs.ClusterModeData.Cluster = oldCluster + return err + } + return nil +} + +func (cs *clusterModeStorageImpl) SetStatusAndStore(status *string) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + oldStatus := cs.ClusterModeData.Status + cs.ClusterModeData.Status = status + + // In case something went wrong while storing, set back the old value + if err := cs.store(); err != nil { + cs.ClusterModeData.Status = oldStatus + return err + } + return nil +} + +func (cs *clusterModeStorageImpl) UnsetClusterAndStore() error { + cs.mu.Lock() + defer cs.mu.Unlock() + + oldCluster := cs.ClusterModeData.Cluster + cs.ClusterModeData.Cluster = nil + + // In case something went wrong while storing, set back the old value + if err := cs.store(); err != nil { + cs.ClusterModeData.Cluster = oldCluster + return err + } + + return cs.store() +} + +func (cs *clusterModeStorageImpl) GetUsers() storagetype.Users { + cs.mu.RLock() + defer cs.mu.RUnlock() + return cs.ClusterModeData.Users +} + +func (cs *clusterModeStorageImpl) AddUserAndStore(user storagetype.User) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.addUser(user) + + // In case something went wrong whil storing, delete the user from the store + if err := cs.store(); err != nil { + cs.removeUser(user) + return err + } + return nil +} + +func (cs *clusterModeStorageImpl) AddUsersAndStore(users storagetype.Users) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.addUsers(users) + + // In case something went wrong whil storing, delete the user from the store + if err := cs.store(); err != nil { + cs.removeUsers(users) + return err + } + return nil +} + +func (cs *clusterModeStorageImpl) ReplaceAllUsersAndStore(users storagetype.Users) error { + cs.mu.Lock() + defer cs.mu.Unlock() + oldUsers := cs.ClusterModeData.Users + + cs.ClusterModeData.Users = users + if err := cs.store(); err != nil { + cs.ClusterModeData.Users = oldUsers + return err + } + return nil +} + +func (cs *clusterModeStorageImpl) RemoveUserAndStore(user storagetype.User) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.removeUser(user) + + // In case something went wrong while storing, add the user to the store + if err := cs.store(); err != nil { + cs.addUser(user) + return err + } + return nil +} + +func (cs *clusterModeStorageImpl) addUser(user storagetype.User) { + cs.ClusterModeData.Users = append(cs.ClusterModeData.Users, user) +} + +func (cs *clusterModeStorageImpl) addUsers(users storagetype.Users) { + cs.ClusterModeData.Users = append(cs.ClusterModeData.Users, users...) +} + +func (cs *clusterModeStorageImpl) removeUser(user storagetype.User) { + for i, u := range cs.ClusterModeData.Users { + if u.Name == user.Name { + cs.ClusterModeData.Users = slices.Delete(cs.ClusterModeData.Users, i, i+1) + break + } + } +} + +func (cs *clusterModeStorageImpl) removeUsers(users storagetype.Users) { + for _, user := range users { + cs.removeUser(user) + } +} + +func (cs *clusterModeStorageImpl) setUsers(users *storagetype.Users) { + cs.ClusterModeData.Users = *users +} + +func (cs *clusterModeStorageImpl) store() error { + return cs.storage.Store(cs.ClusterModeData) +} + +func (cs *clusterModeStorageImpl) load() (storagetype.ClusterModeData, error) { + return cs.storage.Get() +} diff --git a/storage/cluster_test.go b/storage/cluster_test.go new file mode 100644 index 00000000..848c0382 --- /dev/null +++ b/storage/cluster_test.go @@ -0,0 +1,193 @@ +// Copyright 2024 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package storage + +import ( + "path/filepath" + "testing" + + "github.com/haproxytech/client-native/v6/misc" + "github.com/haproxytech/dataplaneapi/storagetype" + "github.com/stretchr/testify/require" +) + +func TestAddUser(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "add 1 user", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + dir := t.TempDir() + clusterStoragePath := filepath.Join(dir, ClusterModeDataFileName) + + // create log store with initial configuration + fs := &fileStorage[storagetype.ClusterModeData]{clusterStoragePath} + users := setup(t, fs) + clusterStorage, err := NewClusterModeStorage(clusterStoragePath) + require.NoError(t, err) + + // apply change on users slice + addUser(&users) + + // now add this user to storage + err = clusterStorage.AddUserAndStore(userToAdd()) + require.NoError(t, err, "failed to add user") + + // check change has been applied + require.Equal(t, users, clusterStorage.GetUsers()) + // reload storage and check + err = clusterStorage.Load() + require.NoError(t, err, "failed to load users") + require.Equal(t, users, clusterStorage.GetUsers()) + }) + } +} + +func TestRemoveUser(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "remove one user", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + dir := t.TempDir() + clusterStoragePath := filepath.Join(dir, ClusterModeDataFileName) + + // create log store with initial configuration + fs := &fileStorage[storagetype.ClusterModeData]{clusterStoragePath} + users := setup(t, fs) + clusterStorage, err := NewClusterModeStorage(clusterStoragePath) + require.NoError(t, err) + + // apply change on users slice + removeUser(&users) + + // now add this user to storage + err = clusterStorage.RemoveUserAndStore(userToRemove()) + require.NoError(t, err, "failed to remove user") + + // check change has been applied + require.Equal(t, users, clusterStorage.GetUsers()) + // reload storage and check + err = clusterStorage.Load() + require.NoError(t, err, "failed to load users") + require.Equal(t, users, clusterStorage.GetUsers()) + }) + } +} + +func TestReplaceAllUsers(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "replace all users", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + dir := t.TempDir() + clusterStoragePath := filepath.Join(dir, ClusterModeDataFileName) + + // create log store with initial configuration + fs := &fileStorage[storagetype.ClusterModeData]{clusterStoragePath} + _ = setup(t, fs) + clusterStorage, err := NewClusterModeStorage(clusterStoragePath) + require.NoError(t, err) + + // now add this user to storage + err = clusterStorage.ReplaceAllUsersAndStore(usersToReplace()) + require.NoError(t, err, "failed to replace all users") + + // check change has been applied + require.Equal(t, usersToReplace(), clusterStorage.GetUsers()) + // reload storage and check + err = clusterStorage.Load() + require.NoError(t, err, "failed to load users") + require.Equal(t, usersToReplace(), clusterStorage.GetUsers()) + }) + } +} + +func setup(t *testing.T, fs *fileStorage[storagetype.ClusterModeData]) storagetype.Users { + t.Helper() + users := getSetupUsers() + clusterMode := storagetype.ClusterModeData{ + Users: users, + } + err := fs.Store(clusterMode) + require.NoError(t, err, "failed to write setup users") + return users +} + +func getSetupUsers() storagetype.Users { + return storagetype.Users{ + storagetype.User{ + Name: "admin", + Password: misc.StringP("admin"), + }, + storagetype.User{ + Name: "user1", + Password: misc.StringP("user1"), + }, + storagetype.User{ + Name: "user2", + Password: misc.StringP("user2"), + }, + } +} + +func addUser(users *storagetype.Users) { + *users = append(*users, userToAdd()) +} + +func removeUser(users *storagetype.Users) { + *users = (*users)[:len(*users)-1] +} + +func userToAdd() storagetype.User { + return storagetype.User{ + Name: "useradded", + Password: misc.StringP("useradded"), + Insecure: misc.BoolP(true), + } +} + +func userToRemove() storagetype.User { + return storagetype.User{ + Name: "user2", + Password: misc.StringP("user2"), + } +} + +func usersToReplace() storagetype.Users { + return storagetype.Users{ + storagetype.User{ + Name: "toreplace1", + Password: misc.StringP("toreplace1"), + }, + storagetype.User{ + Name: "toreplace2", + Password: misc.StringP("replace2"), + }, + } +} diff --git a/storage/file_storage.go b/storage/file_storage.go new file mode 100644 index 00000000..056603da --- /dev/null +++ b/storage/file_storage.go @@ -0,0 +1,66 @@ +package storage + +import ( + "log" + "os" + "path/filepath" + + "github.com/google/renameio" + native_misc "github.com/haproxytech/client-native/v6/misc" + jsoniter "github.com/json-iterator/go" +) + +type fileStorage[T Storable] struct { + filePath string +} + +func (f *fileStorage[T]) Get() (T, error) { + returnData := new(T) + + data, err := os.ReadFile(f.filePath) + if err != nil { + return *returnData, err + } + + if len(data) == 0 { + return *returnData, nil + } + json := jsoniter.ConfigFastest + if err := json.Unmarshal(data, returnData); err != nil { + return *returnData, err + } + + return *returnData, nil +} + +func (f *fileStorage[T]) Store(data T) error { + if err := f.initFile(); err != nil { + return err + } + json := jsoniter.ConfigFastest + jsonData, err := json.MarshalIndent(data, "", " ") + if err != nil { + return err + } + + if err = renameio.WriteFile(f.filePath, jsonData, 0o644); err != nil { + return err + } + return nil +} + +func (f *fileStorage[T]) initFile() error { + if _, err := native_misc.CheckOrCreateWritableDirectory(filepath.Dir(f.filePath)); err != nil { + log.Fatalf("error initializing dataplane internal storage: %v", err) + } + if _, err := os.Stat(f.filePath); err != nil { + if os.IsNotExist(err) { + if _, errCreate := os.Create(f.filePath); errCreate != nil { + return errCreate + } + return os.Chmod(f.filePath, 0o644) + } + return err + } + return nil +} diff --git a/storage/service_discovery_aws.go b/storage/service_discovery_aws.go new file mode 100644 index 00000000..c0661891 --- /dev/null +++ b/storage/service_discovery_aws.go @@ -0,0 +1,174 @@ +package storage + +import ( + "slices" + "sync" + + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/storagetype" +) + +const ( + AWSRegionFileName = "service_discovery/aws.json" +) + +type SDAWStorage interface { + AWS + + Load() error + Store() error +} + +type AWS interface { + // GetAWS does not load the AWSRegions from the storage. Use Load() to load the them if needed. + GetAWSRegions() storagetype.AWSRegions + // AddAWSRegionsAndStore adds a list of AWSRegions to the storage and stores in the storage file. + AddAWSRegionsAndStore(AWS storagetype.AWSRegions) error + // AddAWSRegionAndStore adds a new AWSRegion to the storage and stores in the storage file. + AddAWSRegionAndStore(AWS *models.AwsRegion) error + // RemoveAWSAndStore removes a AWSRegion from the storage and stores in the storage file. + RemoveAWSRegionAndStore(AWS *models.AwsRegion) error + // ReplaceAllAWSRegionsAndStore replaces the list of AWSRegions in the storage and stores in the storage file. + ReplaceAllAWSRegionsAndStore(AWS storagetype.AWSRegions) error +} + +type AWSRegionStorageImpl struct { + AWSData storagetype.AWSRegionData + storage Storage[storagetype.AWSRegionData] + mu sync.RWMutex +} + +// NewSDAWSRegionStorage creates a new AWSRegionStorageImpl with initial configuration from a file path. +func NewSDAWSRegionStorage(path string) (SDAWStorage, error) { + fs := &fileStorage[storagetype.AWSRegionData]{path} + if err := fs.initFile(); err != nil { + return nil, err + } + AWSData, err := fs.Get() + if err != nil { + return nil, err + } + return &AWSRegionStorageImpl{ + storage: fs, + AWSData: AWSData, + }, nil +} + +func (cs *AWSRegionStorageImpl) GetAWSRegions() storagetype.AWSRegions { + cs.mu.RLock() + defer cs.mu.RUnlock() + return cs.AWSData.AWSRegions +} + +func (cs *AWSRegionStorageImpl) Load() error { + cs.mu.Lock() + defer cs.mu.Unlock() + + AWS, err := cs.load() + if err != nil { + return err + } + cs.AWSData = AWS + + return nil +} + +func (cs *AWSRegionStorageImpl) Store() error { + cs.mu.Lock() + defer cs.mu.Unlock() + + if err := cs.store(); err != nil { + return err + } + return nil +} + +func (cs *AWSRegionStorageImpl) AddAWSRegionAndStore(region *models.AwsRegion) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.addAWSRegion(region) + + // In case something went wrong whil storing, delete the AWS from the store + if err := cs.store(); err != nil { + cs.removeAWSRegion(region) + return err + } + return nil +} + +func (cs *AWSRegionStorageImpl) AddAWSRegionsAndStore(regions storagetype.AWSRegions) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.addAWSRegions(regions) + + // In case something went wrong whil storing, delete the AWS from the store + if err := cs.store(); err != nil { + cs.removeAWSRegions(regions) + return err + } + return nil +} + +func (cs *AWSRegionStorageImpl) ReplaceAllAWSRegionsAndStore(regions storagetype.AWSRegions) error { + cs.mu.Lock() + defer cs.mu.Unlock() + oldAWS := cs.AWSData.AWSRegions + + cs.AWSData.AWSRegions = regions + if err := cs.store(); err != nil { + cs.AWSData.AWSRegions = oldAWS + return err + } + return nil +} + +func (cs *AWSRegionStorageImpl) RemoveAWSRegionAndStore(region *models.AwsRegion) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.removeAWSRegion(region) + + // In case something went wrong while storing, add the AWS to the store + if err := cs.store(); err != nil { + cs.addAWSRegion(region) + return err + } + return nil +} + +func (cs *AWSRegionStorageImpl) addAWSRegion(region *models.AwsRegion) { + cs.AWSData.AWSRegions = append(cs.AWSData.AWSRegions, region) +} + +func (cs *AWSRegionStorageImpl) addAWSRegions(regions storagetype.AWSRegions) { + cs.AWSData.AWSRegions = append(cs.AWSData.AWSRegions, regions...) +} + +func (cs *AWSRegionStorageImpl) removeAWSRegion(region *models.AwsRegion) { + for i, u := range cs.AWSData.AWSRegions { + if u.Name == region.Name { + cs.AWSData.AWSRegions = slices.Delete(cs.AWSData.AWSRegions, i, i+1) + break + } + } +} + +func (cs *AWSRegionStorageImpl) removeAWSRegions(regions storagetype.AWSRegions) { + for _, AWS := range cs.AWSData.AWSRegions { + cs.removeAWSRegion(AWS) + } +} + +func (cs *AWSRegionStorageImpl) setAWSRegions(regions storagetype.AWSRegions) { + cs.AWSData.AWSRegions = regions +} + +func (cs *AWSRegionStorageImpl) store() error { + return cs.storage.Store(cs.AWSData) +} + +func (cs *AWSRegionStorageImpl) load() (storagetype.AWSRegionData, error) { + return cs.storage.Get() +} diff --git a/storage/service_discovery_consul.go b/storage/service_discovery_consul.go new file mode 100644 index 00000000..ae25df49 --- /dev/null +++ b/storage/service_discovery_consul.go @@ -0,0 +1,174 @@ +package storage + +import ( + "slices" + "sync" + + "github.com/haproxytech/client-native/v6/models" + "github.com/haproxytech/dataplaneapi/storagetype" +) + +const ( + ConsulFileName = "service_discovery/consul.json" +) + +type SDConsulStorage interface { + Consul + + Load() error + Store() error +} + +type Consul interface { + // GetConsuls does not load the consuls from the storage. Use Load() to load the them if needed. + GetConsuls() storagetype.Consuls + // AddConsulsAndStore adds a list of consuls to the storage and stores in the storage file. + AddConsulsAndStore(consuls storagetype.Consuls) error + // AddConsulAndStore adds a new consul to the storage and stores in the storage file. + AddConsulAndStore(consul *models.Consul) error + // RemoveConsulAndStore removes a consul from the storage and stores in the storage file. + RemoveConsulAndStore(consul *models.Consul) error + // ReplaceAllConsulsAndStore replaces the list of consuls in the storage and stores in the storage file. + ReplaceAllConsulsAndStore(consuls storagetype.Consuls) error +} + +type consulStorageImpl struct { + ConsulData storagetype.ConsulData + storage Storage[storagetype.ConsulData] + mu sync.RWMutex +} + +// NewSDConsulStorage creates a new consulStorageImpl with initial configuration from a file path. +func NewSDConsulStorage(path string) (SDConsulStorage, error) { + fs := &fileStorage[storagetype.ConsulData]{path} + if err := fs.initFile(); err != nil { + return nil, err + } + consulData, err := fs.Get() + if err != nil { + return nil, err + } + return &consulStorageImpl{ + storage: fs, + ConsulData: consulData, + }, nil +} + +func (cs *consulStorageImpl) GetConsuls() storagetype.Consuls { + cs.mu.RLock() + defer cs.mu.RUnlock() + return cs.ConsulData.Consuls +} + +func (cs *consulStorageImpl) Load() error { + cs.mu.Lock() + defer cs.mu.Unlock() + + consul, err := cs.load() + if err != nil { + return err + } + cs.ConsulData = consul + + return nil +} + +func (cs *consulStorageImpl) Store() error { + cs.mu.Lock() + defer cs.mu.Unlock() + + if err := cs.store(); err != nil { + return err + } + return nil +} + +func (cs *consulStorageImpl) AddConsulAndStore(consul *models.Consul) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.addConsul(consul) + + // In case something went wrong whil storing, delete the consul from the store + if err := cs.store(); err != nil { + cs.removeConsul(consul) + return err + } + return nil +} + +func (cs *consulStorageImpl) AddConsulsAndStore(consuls storagetype.Consuls) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.addConsuls(consuls) + + // In case something went wrong whil storing, delete the consul from the store + if err := cs.store(); err != nil { + cs.removeConsuls(consuls) + return err + } + return nil +} + +func (cs *consulStorageImpl) ReplaceAllConsulsAndStore(consuls storagetype.Consuls) error { + cs.mu.Lock() + defer cs.mu.Unlock() + oldConsuls := cs.ConsulData.Consuls + + cs.ConsulData.Consuls = consuls + if err := cs.store(); err != nil { + cs.ConsulData.Consuls = oldConsuls + return err + } + return nil +} + +func (cs *consulStorageImpl) RemoveConsulAndStore(consul *models.Consul) error { + cs.mu.Lock() + defer cs.mu.Unlock() + + cs.removeConsul(consul) + + // In case something went wrong while storing, add the consul to the store + if err := cs.store(); err != nil { + cs.addConsul(consul) + return err + } + return nil +} + +func (cs *consulStorageImpl) addConsul(consul *models.Consul) { + cs.ConsulData.Consuls = append(cs.ConsulData.Consuls, consul) +} + +func (cs *consulStorageImpl) addConsuls(consuls storagetype.Consuls) { + cs.ConsulData.Consuls = append(cs.ConsulData.Consuls, consuls...) +} + +func (cs *consulStorageImpl) removeConsul(consul *models.Consul) { + for i, u := range cs.ConsulData.Consuls { + if u.Name == consul.Name { + cs.ConsulData.Consuls = slices.Delete(cs.ConsulData.Consuls, i, i+1) + break + } + } +} + +func (cs *consulStorageImpl) removeConsuls(consuls storagetype.Consuls) { + for _, consul := range consuls { + cs.removeConsul(consul) + } +} + +func (cs *consulStorageImpl) setConsuls(consuls storagetype.Consuls) { + cs.ConsulData.Consuls = consuls +} + +func (cs *consulStorageImpl) store() error { + return cs.storage.Store(cs.ConsulData) +} + +func (cs *consulStorageImpl) load() (storagetype.ConsulData, error) { + return cs.storage.Get() +} diff --git a/storage/storage.go b/storage/storage.go new file mode 100644 index 00000000..d523d395 --- /dev/null +++ b/storage/storage.go @@ -0,0 +1,15 @@ +package storage + +import ( + "github.com/haproxytech/dataplaneapi/storagetype" +) + +// type constraint for storable objects, add more when need arises with | +type Storable interface { + storagetype.ClusterModeData | storagetype.ConsulData | storagetype.AWSRegionData +} + +type Storage[T Storable] interface { + Get() (T, error) + Store(data T) error +} diff --git a/storagetype/aws.go b/storagetype/aws.go new file mode 100644 index 00000000..39cafc7b --- /dev/null +++ b/storagetype/aws.go @@ -0,0 +1,25 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storagetype + +import "github.com/haproxytech/client-native/v6/models" + +type ( + AWSRegions []*models.AwsRegion + AWSRegionData struct { + AWSRegions AWSRegions `json:"aws_regions,omitempty"` + } +) diff --git a/storagetype/cluster.go b/storagetype/cluster.go new file mode 100644 index 00000000..d5faf82a --- /dev/null +++ b/storagetype/cluster.go @@ -0,0 +1,82 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storagetype + +import ( + "github.com/haproxytech/client-native/v6/models" +) + +type Cluster struct { + APINodesPath *string `json:"api_nodes_path,omitempty" yaml:"api_nodes_path,omitempty"` + Token *string `json:"token,omitempty" yaml:"token,omitempty"` + ClusterTLSCertDir *string `json:"cluster_tls_dir,omitempty" yaml:"cluster_tls_dir,omitempty"` + ActiveBootstrapKey *string `json:"active_bootstrap_key,omitempty" yaml:"active_bootstrap_key,omitempty"` + APIRegisterPath *string `json:"api_register_path,omitempty" yaml:"api_register_path,omitempty"` + URL *string `json:"url,omitempty" yaml:"url,omitempty"` + Port *int `json:"port,omitempty" yaml:"port,omitempty"` + StorageDir *string `json:"storage_dir,omitempty" yaml:"storage_dir,omitempty"` + BootstrapKey *string `json:"bootstrap_key,omitempty" yaml:"bootstrap_key,omitempty"` + ID *string `json:"id,omitempty" yaml:"id,omitempty"` + APIBasePath *string `json:"api_base_path,omitempty" yaml:"api_base_path,omitempty"` + CertificateDir *string `json:"cert_path,omitempty" yaml:"cert_path,omitempty"` + CertificateFetched *bool `json:"cert_fetched,omitempty" yaml:"cert_fetched,omitempty"` + Name *string `json:"name,omitempty" yaml:"name,omitempty"` + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + ClusterID *string `json:"cluster_id,omitempty" yaml:"cluster_id,omitempty" group:"cluster" save:"true"` + ClusterLogTargets []*models.ClusterLogTarget `json:"cluster_log_targets,omitempty" yaml:"cluster_log_targets,omitempty" group:"cluster" save:"true"` +} + +func (c Cluster) LogDisplayName() string { + if c.ClusterID != nil { + return *c.ClusterID + } + if c.BootstrapKey != nil { + return *c.BootstrapKey + } + return "" +} + +func (c Cluster) IsEmpty() bool { + res := isEmptyOrNilS(c.APINodesPath) && + isEmptyOrNilS(c.Token) && + isEmptyOrNilS(c.ClusterTLSCertDir) && + isEmptyOrNilS(c.ActiveBootstrapKey) && + isEmptyOrNilS(c.APIRegisterPath) && + isEmptyOrNilS(c.URL) && + isEmptyOrNilI(c.Port) && + isEmptyOrNilS(c.StorageDir) && + isEmptyOrNilS(c.BootstrapKey) && + isEmptyOrNilS(c.ID) && + isEmptyOrNilS(c.APIBasePath) && + isEmptyOrNilS(c.CertificateDir) && + isEmptyOrNilB(c.CertificateFetched) && + isEmptyOrNilS(c.Name) && + isEmptyOrNilS(c.Description) + + return res +} + +func isEmptyOrNilS(s *string) bool { + return (s == nil || *s == "") +} + +func isEmptyOrNilI(i *int) bool { + return (i == nil || *i == 0) +} + +func isEmptyOrNilB(b *bool) bool { + return (b == nil || !*b) +} diff --git a/storagetype/consul.go b/storagetype/consul.go new file mode 100644 index 00000000..d6d9ddb7 --- /dev/null +++ b/storagetype/consul.go @@ -0,0 +1,25 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storagetype + +import "github.com/haproxytech/client-native/v6/models" + +type ( + Consuls []*models.Consul + ConsulData struct { + Consuls Consuls `json:"consuls,omitempty"` + } +) diff --git a/storagetype/custermode.go b/storagetype/custermode.go new file mode 100644 index 00000000..c0a6c4a2 --- /dev/null +++ b/storagetype/custermode.go @@ -0,0 +1,30 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storagetype + +type ClusterModeData struct { + Users Users `json:"users,omitempty"` + Status *string `json:"status,omitempty" yaml:"status,omitempty"` + Cluster *Cluster `json:"cluster,omitempty"` +} + +// IsClusterMode returns true if the storage is in cluster mode (i.e ClusterModeStorage is not empty) +func (cs ClusterModeData) IsClusterMode() bool { + if cs.Cluster == nil { + return false + } + return !cs.Cluster.IsEmpty() +} diff --git a/storagetype/user.go b/storagetype/user.go new file mode 100644 index 00000000..027f0fca --- /dev/null +++ b/storagetype/user.go @@ -0,0 +1,37 @@ +// Copyright 2021 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package storagetype + +import ( + "strings" +) + +const ( + DapiClusterUserPrefix = "dpapi-c-" +) + +type ( + Users []User + User struct { + Name string `json:"name" yaml:"name"` + Insecure *bool `json:"insecure,omitempty" yaml:"insecure,omitempty"` + Password *string `json:"password,omitempty" yaml:"password,omitempty"` + } +) + +func (u User) IsClusterUser() bool { + return strings.HasPrefix(u.Name, DapiClusterUserPrefix) +} diff --git a/test/configuration/expected/aws-1.json b/test/configuration/expected/aws-1.json new file mode 100644 index 00000000..c794b55f --- /dev/null +++ b/test/configuration/expected/aws-1.json @@ -0,0 +1,24 @@ +{ + "aws_regions": [ + { + "access_key_id": "AKIAIOSFODNN7EXAMPLE", + "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + "enabled": null, + "id": "idtest2", + "ipv4_address": null, + "name": "famous_condor2", + "region": "us-east-2", + "retry_timeout": null + }, + { + "access_key_id": "AKIAIOSFODNN7EXAMPLE", + "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + "enabled": null, + "id": "idtest", + "ipv4_address": null, + "name": "famous_condor", + "region": "us-east-1", + "retry_timeout": null + } + ] +} diff --git a/test/configuration/expected/aws-2.json b/test/configuration/expected/aws-2.json new file mode 100644 index 00000000..3b3055e6 --- /dev/null +++ b/test/configuration/expected/aws-2.json @@ -0,0 +1,34 @@ +{ + "aws_regions": [ + { + "access_key_id": "AKIAIOSFODNN7EXAMPLE", + "enabled": null, + "id": "idtest2", + "ipv4_address": null, + "name": "famous_condor2", + "region": "us-east-2", + "retry_timeout": null, + "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + }, + { + "access_key_id": "AKIAIOSFODNN7EXAMPLE", + "enabled": null, + "id": "idtest7", + "ipv4_address": null, + "name": "famous_condor7", + "region": "us-east-7", + "retry_timeout": null, + "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + }, + { + "access_key_id": "AKIAIOSFODNN7EXAMPLE", + "enabled": null, + "id": "idtest", + "ipv4_address": null, + "name": "famous_condor", + "region": "us-east-1", + "retry_timeout": null, + "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + } + ] +} diff --git a/test/configuration/expected/cluster-1.json b/test/configuration/expected/cluster-1.json new file mode 100644 index 00000000..37acd29d --- /dev/null +++ b/test/configuration/expected/cluster-1.json @@ -0,0 +1,29 @@ +{ + "users": [ + { + "name": "dpapi-c-vU9DIiJH", + "insecure": false, + "password": "$6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0" + } + ], + "status": "active", + "cluster": { + "api_nodes_path": "/nodes", + "token": "01J3MCAA2W7QREFKXW6XVDNYX4", + "cluster_tls_dir": "/var/lib/dataplaneapi/storage", + "active_bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "api_register_path": "/clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes", + "url": "http://127.0.0.1", + "port": 4449, + "storage_dir": "/etc/haproxy", + "bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "id": "01J3MCAA2WAVV294QGPG750BYA", + "api_base_path": "/v1", + "cert_path": "/var/lib/dataplaneapi/storage/certs-cluster", + "cert_fetched": true, + "use_hash_storage": false, + "name": "hd-laptop", + "description": "", + "cluster_id": "ab8d85c5-4f12-4eec-b270-79bf53d48d44" + } + } diff --git a/test/configuration/expected/cluster-3.json b/test/configuration/expected/cluster-3.json new file mode 100644 index 00000000..34dd332c --- /dev/null +++ b/test/configuration/expected/cluster-3.json @@ -0,0 +1,34 @@ +{ + "users": [ + { + "name": "dpapi-c-vU9DIiJH", + "insecure": false, + "password": "$6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0" + }, + { + "name": "dpapi-c-vU9DIiJH-2", + "insecure": false, + "password": "$6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0" + } + ], + "status": "active", + "cluster": { + "api_nodes_path": "/nodes", + "token": "01J3MCAA2W7QREFKXW6XVDNYX4", + "cluster_tls_dir": "/var/lib/dataplaneapi/storage", + "active_bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "api_register_path": "/clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes", + "url": "http://127.0.0.1", + "port": 4449, + "storage_dir": "/etc/haproxy", + "bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "id": "01J3MCAA2WAVV294QGPG750BYA", + "api_base_path": "/v1", + "cert_path": "/var/lib/dataplaneapi/storage/certs-cluster", + "cert_fetched": true, + "use_hash_storage": false, + "name": "hd-laptop", + "description": "", + "cluster_id": "ab8d85c5-4f12-4eec-b270-79bf53d48d44" + } + } diff --git a/test/configuration/expected/consul-1.json b/test/configuration/expected/consul-1.json new file mode 100644 index 00000000..637d1a8e --- /dev/null +++ b/test/configuration/expected/consul-1.json @@ -0,0 +1,24 @@ +{ + "consuls": [ + { + "address": "127.0.0.1", + "description": "description 1", + "enabled": true, + "id": "111", + "name": "consul1", + "port": 8500, + "retry_timeout": 10, + "server_slots_base": 10 + }, + { + "address": "127.0.0.1", + "description": "description 2", + "enabled": true, + "name": "consul2", + "id": "222", + "port": 222, + "retry_timeout": 10, + "server_slots_base": 10 + } + ] + } diff --git a/test/configuration/expected/consul-1_2.json b/test/configuration/expected/consul-1_2.json new file mode 100644 index 00000000..a60f00f8 --- /dev/null +++ b/test/configuration/expected/consul-1_2.json @@ -0,0 +1,34 @@ +{ + "consuls": [ + { + "address": "127.0.0.1", + "description": "description 1", + "enabled": true, + "id": "111", + "name": "existing_consul1", + "port": 8500, + "retry_timeout": 10, + "server_slots_base": 10 + }, + { + "address": "127.0.0.1", + "description": "description 7", + "enabled": true, + "id": "777", + "name": "consul7", + "port": 777, + "retry_timeout": 10, + "server_slots_base": 10 + }, + { + "address": "127.0.0.1", + "description": "description 2", + "enabled": true, + "id": "222", + "name": "consul2", + "port": 222, + "retry_timeout": 10, + "server_slots_base": 10 + } + ] + } diff --git a/test/configuration/expected/dataplaneapi-1.yaml b/test/configuration/expected/dataplaneapi-1.yaml new file mode 100644 index 00000000..4c5a0f4c --- /dev/null +++ b/test/configuration/expected/dataplaneapi-1.yaml @@ -0,0 +1,43 @@ +config_version: 2 +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + advertised: + api_address: "" + api_port: 0 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + waf_dir: /etc/haproxy/waf + spoe_dir: /etc/haproxy/spoe +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" + reload_strategy: custom +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true + validate_cmd: null + reload_delay: null + transaction_dir: null + backups_dir: null + backups_number: null +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug diff --git a/test/configuration/expected/dataplaneapi-2.yaml b/test/configuration/expected/dataplaneapi-2.yaml new file mode 100644 index 00000000..affe666c --- /dev/null +++ b/test/configuration/expected/dataplaneapi-2.yaml @@ -0,0 +1,47 @@ +config_version: 2 +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + advertised: + api_address: "" + api_port: 0 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + user: + - name: admin + insecure: false + password: adminpwd + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + waf_dir: /etc/haproxy/waf + spoe_dir: /etc/haproxy/spoe +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" + reload_strategy: custom +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true + validate_cmd: null + reload_delay: null + transaction_dir: null + backups_dir: null + backups_number: null +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug diff --git a/test/configuration/fixture/aws-1_2.json b/test/configuration/fixture/aws-1_2.json new file mode 100644 index 00000000..4fc73c0e --- /dev/null +++ b/test/configuration/fixture/aws-1_2.json @@ -0,0 +1,24 @@ +{ + "aws_regions": [ + { + "access_key_id": "AKIAIOSFODNN7EXAMPLE", + "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + "enabled": null, + "id": "idtest2", + "ipv4_address": null, + "name": "famous_condor2", + "region": "us-east-2", + "retry_timeout": null + }, + { + "access_key_id": "AKIAIOSFODNN7EXAMPLE", + "secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + "enabled": null, + "id": "idtest7", + "ipv4_address": null, + "name": "famous_condor7", + "region": "us-east-7", + "retry_timeout": null + } + ] + } diff --git a/test/configuration/fixture/cluster-1_2.json b/test/configuration/fixture/cluster-1_2.json new file mode 100644 index 00000000..37acd29d --- /dev/null +++ b/test/configuration/fixture/cluster-1_2.json @@ -0,0 +1,29 @@ +{ + "users": [ + { + "name": "dpapi-c-vU9DIiJH", + "insecure": false, + "password": "$6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0" + } + ], + "status": "active", + "cluster": { + "api_nodes_path": "/nodes", + "token": "01J3MCAA2W7QREFKXW6XVDNYX4", + "cluster_tls_dir": "/var/lib/dataplaneapi/storage", + "active_bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "api_register_path": "/clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes", + "url": "http://127.0.0.1", + "port": 4449, + "storage_dir": "/etc/haproxy", + "bootstrap_key": "eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0=", + "id": "01J3MCAA2WAVV294QGPG750BYA", + "api_base_path": "/v1", + "cert_path": "/var/lib/dataplaneapi/storage/certs-cluster", + "cert_fetched": true, + "use_hash_storage": false, + "name": "hd-laptop", + "description": "", + "cluster_id": "ab8d85c5-4f12-4eec-b270-79bf53d48d44" + } + } diff --git a/test/configuration/fixture/consul-1_2.json b/test/configuration/fixture/consul-1_2.json new file mode 100644 index 00000000..75529561 --- /dev/null +++ b/test/configuration/fixture/consul-1_2.json @@ -0,0 +1,24 @@ +{ + "consuls": [ + { + "address": "127.0.0.1", + "description": "description 1", + "enabled": true, + "id": "111", + "name": "existing_consul1", + "port": 8500, + "retry_timeout": 10, + "server_slots_base": 10 + }, + { + "address": "127.0.0.1", + "description": "description 7", + "enabled": true, + "id": "777", + "name": "consul7", + "port": 777, + "retry_timeout": 10, + "server_slots_base": 10 + } + ] + } diff --git a/test/configuration/fixture/dataplaneapi-1.yaml b/test/configuration/fixture/dataplaneapi-1.yaml new file mode 100644 index 00000000..16876d31 --- /dev/null +++ b/test/configuration/fixture/dataplaneapi-1.yaml @@ -0,0 +1,59 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + user: + - name: dpapi-c-vU9DIiJH + insecure: false + password: >- + $6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0 + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe + waf_dir: /etc/haproxy/waf +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true +status: active +cluster: + api_nodes_path: /nodes + token: 01J3MCAA2W7QREFKXW6XVDNYX4 + cluster_tls_dir: /var/lib/dataplaneapi/storage + active_bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + api_register_path: /clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes + url: 'http://127.0.0.1' + port: 4449 + storage_dir: /etc/haproxy + bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + id: 01J3MCAA2WAVV294QGPG750BYA + api_base_path: /v1 + cert_path: /var/lib/dataplaneapi/storage/certs-cluster + cert_fetched: true + use_hash_storage: false + name: hd-laptop + description: '' + cluster_id: ab8d85c5-4f12-4eec-b270-79bf53d48d44 diff --git a/test/configuration/fixture/dataplaneapi-2.yaml b/test/configuration/fixture/dataplaneapi-2.yaml new file mode 100644 index 00000000..790e7082 --- /dev/null +++ b/test/configuration/fixture/dataplaneapi-2.yaml @@ -0,0 +1,62 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + user: + - name: dpapi-c-vU9DIiJH + insecure: false + password: >- + $6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0 + - name: admin + insecure: false + password: adminpwd + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe + waf_dir: /etc/haproxy/waf +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true +status: active +cluster: + api_nodes_path: /nodes + token: 01J3MCAA2W7QREFKXW6XVDNYX4 + cluster_tls_dir: /var/lib/dataplaneapi/storage + active_bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + api_register_path: /clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes + url: 'http://127.0.0.1' + port: 4449 + storage_dir: /etc/haproxy + bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + id: 01J3MCAA2WAVV294QGPG750BYA + api_base_path: /v1 + cert_path: /var/lib/dataplaneapi/storage/certs-cluster + cert_fetched: true + use_hash_storage: false + name: hd-laptop + description: '' + cluster_id: ab8d85c5-4f12-4eec-b270-79bf53d48d44 diff --git a/test/configuration/fixture/dataplaneapi-3.yaml b/test/configuration/fixture/dataplaneapi-3.yaml new file mode 100644 index 00000000..d50a1b91 --- /dev/null +++ b/test/configuration/fixture/dataplaneapi-3.yaml @@ -0,0 +1,62 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + user: + - name: dpapi-c-vU9DIiJH-2 + insecure: false + password: >- + $6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0 + - name: admin + insecure: false + password: adminpwd + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe + waf_dir: /etc/haproxy/waf +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true +status: active +cluster: + api_nodes_path: /nodes + token: 01J3MCAA2W7QREFKXW6XVDNYX4 + cluster_tls_dir: /var/lib/dataplaneapi/storage + active_bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + api_register_path: /clusters/ab8d85c5-4f12-4eec-b270-79bf53d48d44/nodes + url: 'http://127.0.0.1' + port: 4449 + storage_dir: /etc/haproxy + bootstrap_key: >- + eyJhZGRyZXNzIjoiMTI3LjAuMC4xIiwiYXBpLWJhc2UtcGF0aCI6Ii92MSIsImNsdXN0ZXItaWQiOiJhYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQiLCJkZXNjcmlwdGlvbiI6IiIsImV4cGlyaW5nLXRpbWUiOiIxNzIxOTc4MzA1IiwibmFtZSI6ImRlZmF1bHQiLCJub2Rlcy1wYXRoIjoiL25vZGVzIiwicG9ydCI6IjQ0NDkiLCJyZWdpc3Rlci1tZXRob2QiOiJQT1NUIiwicmVnaXN0ZXItcGF0aCI6Ii9jbHVzdGVycy9hYjhkODVjNS00ZjEyLTRlZWMtYjI3MC03OWJmNTNkNDhkNDQvbm9kZXMiLCJzY2hlbWEiOiJodHRwIiwic3RvcmFnZS1kaXIiOiIvdmFyL2xpYi9kYXRhcGxhbmVhcGkvc3RvcmFnZSIsInVpZCI6IjAxSjNNQzJSREJGUDQ0MVYxMVpTUENNQ1dHIn0= + id: 01J3MCAA2WAVV294QGPG750BYA + api_base_path: /v1 + cert_path: /var/lib/dataplaneapi/storage/certs-cluster + cert_fetched: true + use_hash_storage: false + name: hd-laptop + description: '' + cluster_id: ab8d85c5-4f12-4eec-b270-79bf53d48d44 diff --git a/test/configuration/fixture/dataplaneapi-sd-aws-1.yaml b/test/configuration/fixture/dataplaneapi-sd-aws-1.yaml new file mode 100644 index 00000000..d5d77a99 --- /dev/null +++ b/test/configuration/fixture/dataplaneapi-sd-aws-1.yaml @@ -0,0 +1,50 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + user: + - name: dpapi-c-vU9DIiJH + insecure: false + password: >- + $6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0 + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe + waf_dir: /etc/haproxy/waf +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true +service_discovery: + aws_regions: + - accesskeyid: AKIAIOSFODNN7EXAMPLE + secretaccesskey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY + id: idtest2 + region: us-east-2 + name: famous_condor2 + - accesskeyid: AKIAIOSFODNN7EXAMPLE + secretaccesskey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY + id: idtest + region: us-east-1 + name: famous_condor diff --git a/test/configuration/fixture/dataplaneapi-sd-consul-1.yaml b/test/configuration/fixture/dataplaneapi-sd-consul-1.yaml new file mode 100644 index 00000000..21f8c882 --- /dev/null +++ b/test/configuration/fixture/dataplaneapi-sd-consul-1.yaml @@ -0,0 +1,56 @@ +name: famous_condor +dataplaneapi: + host: 0.0.0.0 + port: 8080 + userlist: + userlist_file: /etc/haproxy/userlist.cfg + user: + - name: dpapi-c-vU9DIiJH + insecure: false + password: >- + $6$nBKS6wIN2HSF4uKu$3hp8zVGf6.JaUgi3XknJogqc6v3Ls3StY0Z0.8aCGl7uR0/fuX/JarE82aE80xnKz5O/jrBwxaL07Js/Tc9xc0 + resources: + maps_dir: /etc/haproxy/maps + ssl_certs_dir: /etc/haproxy/ssl + general_storage_dir: /etc/haproxy/general + dataplane_storage_dir: /etc/haproxy/dataplane + spoe_dir: /etc/haproxy/spoe + waf_dir: /etc/haproxy/waf +haproxy: + config_file: /etc/haproxy/haproxy.cfg + haproxy_bin: /usr/local/sbin/haproxy + reload: + reload_cmd: kill -s 12 1 + restart_cmd: kill -s 12 1 + status_cmd: pgrep haproxy + start_cmd: "true" + stop_cmd: "false" +log: + log_to: file + log_file: /var/log/dataplaneapi.log + log_level: debug +keepalived: + config_file: /dev/null + start_cmd: /bin/true + reload_cmd: /bin/true + restart_cmd: /bin/false + stop_cmd: /bin/true + status_cmd: /bin/true +service_discovery: + consuls: + - address: "127.0.0.1" + description: "description 1" + name: "consul1" + enabled: true + id: "111" + port: 8500 + retrytimeout: 10 + serverslotsbase: 10 + - address: "127.0.0.1" + description: "description 2" + name: "consul2" + id: "222" + enabled: true + port: 222 + retrytimeout: 10 + serverslotsbase: 10 diff --git a/test/configuration/fixture/empty.json b/test/configuration/fixture/empty.json new file mode 100644 index 00000000..e69de29b diff --git a/test/configuration/migration_test.go b/test/configuration/migration_test.go new file mode 100644 index 00000000..a540d8da --- /dev/null +++ b/test/configuration/migration_test.go @@ -0,0 +1,316 @@ +// Copyright 2019 HAProxy Technologies +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package clustermode_test + +import ( + "encoding/json" + "fmt" + "os" + "path" + "reflect" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/renameio" + "github.com/haproxytech/dataplaneapi/configuration" + "github.com/haproxytech/dataplaneapi/storagetype" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" +) + +var ( + fixtureDir = "fixture" + expectedDir = "expected" +) + +func initConfiguration(dapiCfgPath, dapiStorageDir string) *configuration.Configuration { + testCfg := &configuration.Configuration{ + HAProxy: configuration.HAProxyConfiguration{ + DataplaneStorageDir: dapiStorageDir, + DataplaneConfig: dapiCfgPath, + }, + } + return testCfg +} + +func TestConfiguration_LoadDataplaneStorageConfig(t *testing.T) { + tests := []struct { + name string + fixtureDapiCfg string + fixtureCluster string + expectedDapiCfg string + expectedCluster string + }{ + { + name: "from empty cluster.json, 1 cluster user", + fixtureDapiCfg: "dataplaneapi-1.yaml", + fixtureCluster: "empty.json", + expectedDapiCfg: "dataplaneapi-1.yaml", + expectedCluster: "cluster-1.json", + }, + { + // Migration already done, we start with cluster-2.json that is the same as expected/cluster-1.json + // Same results as "empty cluster.json" should be. + name: "from non empty cluster.json", + fixtureDapiCfg: "dataplaneapi-1.yaml", // same as empty cluster.son + fixtureCluster: "cluster-1_2.json", + expectedDapiCfg: "dataplaneapi-1.yaml", // same as empty cluster.son + expectedCluster: "cluster-1.json", // same as empty cluster.son + }, + { + name: "from empty cluster.json, 1 cluster user, 1 single mode user", + fixtureDapiCfg: "dataplaneapi-2.yaml", + fixtureCluster: "empty.json", + expectedDapiCfg: "dataplaneapi-2.yaml", + expectedCluster: "cluster-1.json", + }, + { + name: "from non empty cluster.json, 1 cluster user, 1 single mode user", + fixtureDapiCfg: "dataplaneapi-2.yaml", + fixtureCluster: "cluster-1_2.json", + expectedDapiCfg: "dataplaneapi-2.yaml", + expectedCluster: "cluster-1.json", + }, + { + name: "from non empty cluster.json, adding 1 cluster user", + fixtureDapiCfg: "dataplaneapi-3.yaml", + fixtureCluster: "cluster-1_2.json", + expectedDapiCfg: "dataplaneapi-2.yaml", + expectedCluster: "cluster-3.json", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + dapiCfgPathSrc := path.Join(fixtureDir, tc.fixtureDapiCfg) + dapiStoragePathSrc := path.Join(fixtureDir, tc.fixtureCluster) + + dir := t.TempDir() + dapiCfgPath := path.Join(dir, "dataplaneapi.yaml") + dapiStoragePath := path.Join(dir, "cluster.json") + + // Copy dapi config file to tmp dir + bytesRead, err := os.ReadFile(dapiCfgPathSrc) + require.NoError(t, err) + err = renameio.WriteFile(dapiCfgPath, bytesRead, 0o644) + require.NoError(t, err) + bytesRead, err = os.ReadFile(dapiStoragePathSrc) + require.NoError(t, err) + err = renameio.WriteFile(dapiStoragePath, bytesRead, 0o644) + require.NoError(t, err) + + // Load dapi config + cfg := initConfiguration(dapiCfgPath, dir) + cfg.Load() + // override storage Dir + cfg.HAProxy.DataplaneStorageDir = dir + + // Load and migrate + cfg.LoadDataplaneStorageConfig() + cfg.Save() + + // Check migrated cluster.json + // Check dataplaneapi.yaml (removed cluster...)dapiCfgMigrated, err := os.ReadFile(dapiCfgPath) + var areEqual bool + dapiCfg := getDapiCfg(t, dapiCfgPath) + dapiExectedCfg := getDapiCfg(t, path.Join(expectedDir, tc.expectedDapiCfg)) + areEqual = reflect.DeepEqual(dapiExectedCfg, dapiCfg) + require.True(t, areEqual, "migrated dataplaneapi.yaml is not equal to expected") + + dapiStorageMigrated := getClusterMode(t, dapiStoragePath) + dapiExpectedStorage := getClusterMode(t, path.Join(expectedDir, tc.expectedCluster)) + areEqual = reflect.DeepEqual(dapiExpectedStorage, dapiStorageMigrated) + require.True(t, areEqual, fmt.Sprintf("test: %s migrated cluster.json is not equal to expected", tc.name)) + }) + } +} + +func getClusterMode(t *testing.T, dapiStoragePath string) *storagetype.ClusterModeData { + t.Helper() + dapiStorageJ, err := os.ReadFile(dapiStoragePath) + require.NoError(t, err) + var cmd storagetype.ClusterModeData + json.Unmarshal(dapiStorageJ, &cmd) + return &cmd +} + +func getDapiCfg(t *testing.T, dapiCfgPath string) *configuration.Configuration { + t.Helper() + dapiCfgJ, err := os.ReadFile(dapiCfgPath) + require.NoError(t, err) + var cfg configuration.Configuration + yaml.Unmarshal(dapiCfgJ, &cfg) + return &cfg +} + +func TestConfiguration_LoadDataplaneStorageConfig_SD_Consul(t *testing.T) { + tests := []struct { + name string + fixtureDapiCfg string + fixtureConsul string + expectedDapiCfg string + expectedConsul string + }{ + { + name: "from empty consul.json", + fixtureDapiCfg: "dataplaneapi-sd-consul-1.yaml", + fixtureConsul: "empty.json", + expectedDapiCfg: "dataplaneapi-1.yaml", + expectedConsul: "consul-1.json", + }, + { + name: "from non empty consul.json", + fixtureDapiCfg: "dataplaneapi-sd-consul-1.yaml", + fixtureConsul: "consul-1_2.json", + expectedDapiCfg: "dataplaneapi-1.yaml", + expectedConsul: "consul-1_2.json", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + dapiCfgPathSrc := path.Join(fixtureDir, tc.fixtureDapiCfg) + dapiStorageConsulPathSrc := path.Join(fixtureDir, tc.fixtureConsul) + + dir := t.TempDir() + dapiCfgPath := path.Join(dir, "dataplaneapi.yaml") + dapiStoragePath := path.Join(dir, "service_discovery", "consul.json") + os.MkdirAll(path.Join(dir, "service_discovery"), 0o755) + + // Copy dapi config file to tmp dir + bytesRead, err := os.ReadFile(dapiCfgPathSrc) + require.NoError(t, err) + err = renameio.WriteFile(dapiCfgPath, bytesRead, 0o644) + require.NoError(t, err) + bytesRead, err = os.ReadFile(dapiStorageConsulPathSrc) + require.NoError(t, err) + err = renameio.WriteFile(dapiStoragePath, bytesRead, 0o644) + require.NoError(t, err) + + // Load dapi config + cfg := initConfiguration(dapiCfgPath, dir) + cfg.Load() + // override storage Dir + cfg.HAProxy.DataplaneStorageDir = dir + + // Load and migrate + cfg.LoadDataplaneStorageConfig() + cfg.Save() + + // Check migrated consul.json + // Check dataplaneapi.yaml (removed cluster...)dapiCfgMigrated, err := os.ReadFile(dapiCfgPath) + var areEqual bool + dapiCfg := getDapiCfg(t, dapiCfgPath) + dapiExectedCfg := getDapiCfg(t, path.Join(expectedDir, tc.expectedDapiCfg)) + areEqual = reflect.DeepEqual(dapiExectedCfg, dapiCfg) + require.True(t, areEqual, "migrated dataplaneapi.yaml is not equal to expected") + + dapiStorageMigrated := getConsul(t, dapiStoragePath) + dapiExpectedStorage := getConsul(t, path.Join(expectedDir, tc.expectedConsul)) + areEqual = reflect.DeepEqual(dapiExpectedStorage, dapiStorageMigrated) + diff := cmp.Diff(dapiExpectedStorage, dapiStorageMigrated) + fmt.Println(diff) + require.True(t, areEqual, fmt.Sprintf("test: %s migrated consul.json is not equal to expected", tc.name)) + }) + } +} + +func TestConfiguration_LoadDataplaneStorageConfig_SD_AWS(t *testing.T) { + tests := []struct { + name string + fixtureDapiCfg string + fixtureAWS string + expectedDapiCfg string + expectedAWS string + }{ + { + name: "from empty aws.json", + fixtureDapiCfg: "dataplaneapi-sd-aws-1.yaml", + fixtureAWS: "empty.json", + expectedDapiCfg: "dataplaneapi-1.yaml", + expectedAWS: "aws-1.json", + }, + { + name: "from non empty aws.json", + fixtureDapiCfg: "dataplaneapi-sd-aws-1.yaml", + fixtureAWS: "aws-1_2.json", + expectedDapiCfg: "dataplaneapi-1.yaml", + expectedAWS: "aws-2.json", + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + dapiCfgPathSrc := path.Join(fixtureDir, tc.fixtureDapiCfg) + dapiStorageConsulPathSrc := path.Join(fixtureDir, tc.fixtureAWS) + + dir := t.TempDir() + dapiCfgPath := path.Join(dir, "dataplaneapi.yaml") + dapiStoragePath := path.Join(dir, "service_discovery", "aws.json") + os.MkdirAll(path.Join(dir, "service_discovery"), 0o755) + + // Copy dapi config file to tmp dir + bytesRead, err := os.ReadFile(dapiCfgPathSrc) + require.NoError(t, err) + err = renameio.WriteFile(dapiCfgPath, bytesRead, 0o644) + require.NoError(t, err) + bytesRead, err = os.ReadFile(dapiStorageConsulPathSrc) + require.NoError(t, err) + err = renameio.WriteFile(dapiStoragePath, bytesRead, 0o644) + require.NoError(t, err) + + // Load dapi config + cfg := initConfiguration(dapiCfgPath, dir) + cfg.Load() + // override storage Dir + cfg.HAProxy.DataplaneStorageDir = dir + + // Load and migrate + cfg.LoadDataplaneStorageConfig() + cfg.Save() + + // Check aws.json + // Check dataplaneapi.yaml (removed cluster...)dapiCfgMigrated, err := os.ReadFile(dapiCfgPath) + var areEqual bool + dapiCfg := getDapiCfg(t, dapiCfgPath) + dapiExectedCfg := getDapiCfg(t, path.Join(expectedDir, tc.expectedDapiCfg)) + areEqual = reflect.DeepEqual(dapiExectedCfg, dapiCfg) + require.True(t, areEqual, "migrated dataplaneapi.yaml is not equal to expected") + + dapiStorageMigrated := getAWS(t, dapiStoragePath) + dapiExpectedStorage := getAWS(t, path.Join(expectedDir, tc.expectedAWS)) + areEqual = reflect.DeepEqual(dapiExpectedStorage, dapiStorageMigrated) + diff := cmp.Diff(dapiExpectedStorage, dapiStorageMigrated) + fmt.Println(diff) + require.True(t, areEqual, fmt.Sprintf("test: %s migrated aws.json is not equal to expected", tc.name)) + }) + } +} + +func getConsul(t *testing.T, dapiStoragePath string) *storagetype.ConsulData { + t.Helper() + dapiStorageJ, err := os.ReadFile(dapiStoragePath) + require.NoError(t, err) + var data storagetype.ConsulData + json.Unmarshal(dapiStorageJ, &data) + return &data +} + +func getAWS(t *testing.T, dapiStoragePath string) *storagetype.AWSRegionData { + t.Helper() + dapiStorageJ, err := os.ReadFile(dapiStoragePath) + require.NoError(t, err) + var data storagetype.AWSRegionData + json.Unmarshal(dapiStorageJ, &data) + return &data +}